# quake_server v0.1.0 - Table of Contents > The server of the Quake engine in Elixir: runs a QuakeC game's levels, its physics, monster movement and builtins. ## Pages - [QuakeServer](readme.md) - [Changelog](changelog.md) ## Modules - [QuakeServer.Angles](QuakeServer.Angles.md): Angles as FTE's server reads them: `{pitch, yaw, roll}` in degrees, pitch above zero looking down. - [QuakeServer.Animation](QuakeServer.Animation.md): The animation of the entities a program sends itself, carried to each watching player as GoldSrc's engine carries `entity_state_t`'s `sequence`, `frame`, `animtime` and `framerate` for every entity it sends (`delta.lst`). - [QuakeServer.Args](QuakeServer.Args.md): A builtin's arguments and result: argument `i` (from 0) sits in the program's parameter slots at `4 + 3 * i`, and the result goes to slot 1. - [QuakeServer.Autocvars](QuakeServer.Autocvars.md): A program's `autocvar_` globals kept equal to console variable ``, and a server's info keys kept equal to its `:serverinfo` and `:userinfo` variables, as FTE keeps them (`PR_AutoCvar`, `Cvar_SetCore`). - [QuakeServer.Builtins](QuakeServer.Builtins.md): The engine functions a QuakeC program calls by number, as FTE runs them for a server program: vectors and angles, entities and models, traces, sounds, monster movement, searches, console variables, messages and level changes. Where FTE's rule depends on the kind of program, a QuakeWorld program is one whose `crc` is 54730. - [QuakeServer.Builtins.Aim](QuakeServer.Builtins.Aim.md): The `aim` builtin as FTE runs it (`PF_aim`): the direction a shot from `entity` should take, from its origin raised by its `view_ofs` height, given `v_forward`. - [QuakeServer.Builtins.Print](QuakeServer.Builtins.Print.md): The print builtins as FTE runs them: `bprint` (23) to every player, `sprint` (24) to one, and `centerprint` (73) in the middle of one player's screen, their text joined from every argument after the leading ones. A QuakeWorld program (`crc` 54730) gives `bprint` and `sprint` a print level before the text; otherwise the level is 2 (`PRINT_HIGH`). Prints reach a player's reliable messages (`QuakeServer.Outbox`) and, as `{:print, :notify | :center, text}`, the server's events. A `sprint` or `centerprint` to an entity that is not a player prints that it was tried. - [QuakeServer.Builtins.Text](QuakeServer.Builtins.Text.md): Numbers as FTE's `ftos` and `vtos` write them for a QuakeC program. - [QuakeServer.Builtins.Write](QuakeServer.Builtins.Write.md): The message-writing builtins (`WriteByte` to `WriteEntity`, numbers 52 to 59, and FTE's `WriteFloat`, `WriteInt` and `WriteUnterminatedString`), which append bytes to a message in FTE's encodings. - [QuakeServer.Cheats](QuakeServer.Cheats.md): FTE's player cheat commands, for the host's player (entity 1), allowed as FTE's `SV_MayCheat` allows them: with `sv_cheats` set, or always on a single-player server. - [QuakeServer.Console](QuakeServer.Console.md): The console: the commands a program queues with `localcmd`, the lines of the configuration files they `exec`, and commands typed or sent to it, run against the host's `QuakeServer.Cvars` table as FTE's console runs them. - [QuakeServer.Console.Bindings](QuakeServer.Console.Bindings.md): FTE's key bindings (`keys.c`): the console's `bind`, `in_bind`, `bindlevel`, `unbind` and `unbindall`, and the lookups the client and menu programs make, kept in the host's `QuakeServer.Cvars` table (`QuakeServer.Cvars.binding/3`) so every holder of it shares them. - [QuakeServer.Console.Configs](QuakeServer.Console.Configs.md): The console's `exec` and `cfg_save`, as FTE's `Cmd_Exec_f` and `Cmd_WriteConfig_f` run them, with FTE's main config `fte.cfg`. - [QuakeServer.Console.Variables](QuakeServer.Console.Variables.md): The console's commands about console variables, run on the host's `QuakeServer.Cvars` table as FTE's `cmd.c` and `cvar.c` run them. - [QuakeServer.Contents](QuakeServer.Contents.md): FTE's contents as bits (`bspfile.h`), and the translation from the codes Quake and Half-Life maps store (`Q1BSP_TranslateContents`, and the contents a brush entity's negative `skin` forces on all of its brushes). - [QuakeServer.Cvars](QuakeServer.Cvars.md): FTE's console variables: one table every process of a game reads and writes, the server, its client program and its menu alike, as FTE's single process has one set. - [QuakeServer.Cvars.Cvar](QuakeServer.Cvars.Cvar.md): One console variable as `QuakeServer.Cvars.fetch/2` reads it. - [QuakeServer.Cvars.Engine](QuakeServer.Cvars.Engine.md): The console variables FTE's engine registers that a game here reads: the server's physics and rules, the client's screen, sound and player settings, and every engine variable FreeHL's programs and configs name. Each has FTE's default (for the server's physics, the default this server plays by), flags, second name and description. - [QuakeServer.Edicts](QuakeServer.Edicts.md): Entities of a running level: making and freeing them, and their fields by name. - [QuakeServer.EntityTable](QuakeServer.EntityTable.md): The entity references in a file the program carries from one level to the next, translated by Half-Life's level transition rule (GoldSrc's engine and the HLSDK's `CSaveRestoreBuffer`: a saved reference is an index into the save's entity table, restored as the entity that table entry was restored into, and as null when the entry was not carried into the level). The rule is Half-Life's (GoldSrc and the HLSDK), not FreeHL's under FTE, where a number read back is the entity of that number in the new level whatever it now is. - [QuakeServer.Events](QuakeServer.Events.md): What the server tells the client happened: particles and printed messages, added to the server's events. Sounds are `QuakeServer.Sounds`. - [QuakeServer.Extensions](QuakeServer.Extensions.md): The builtins of an FTE server program: Quake's (`QuakeServer.Builtins`) and FTE's extensions to them, by number and, for builtins a program binds by name, by name. - [QuakeServer.Extensions.Buffers](QuakeServer.Extensions.Buffers.md): FTE's string buffer builtins beyond making, reading and writing single strings (`QuakeServer.Extensions.Store`) - [QuakeServer.Extensions.Control](QuakeServer.Extensions.Control.md): FTE's `abort` (211), which stops every QuakeC function running (`QuakeC.Exec.abort/1`), and `checkcommand` (294), which says what a console name is, in the order the console looks: 1 a command (the console's own, `QuakeServer.Console.command?/1`, or one the program registered), 2 an alias, 3 a console variable, 0 nothing. - [QuakeServer.Extensions.Effects](QuakeServer.Extensions.Effects.md): FTE's effect and sound builtins: named particle effects by number, effects at a point and along a trail, the `te_` temporary effects, sounds at a point and with pitch, and sound numbers. Each becomes an event for the client (`QuakeServer.Server.emit/2`) - [QuakeServer.Extensions.Encoding](QuakeServer.Extensions.Encoding.md): FTE's builtins that recode text and bytes - [QuakeServer.Extensions.EntityText](QuakeServer.Extensions.EntityText.md): FTE's builtins that write entities as text and read them back, as its `PR_SaveEnt` and `PR_RestoreEnt`, and that list or protect entities - [QuakeServer.Extensions.Files](QuakeServer.Extensions.Files.md): FTE's file builtins beyond opening, reading and writing (`QuakeServer.Extensions.Store`) - [QuakeServer.Extensions.Format](QuakeServer.Extensions.Format.md): QuakeC's `sprintf`: C's conversions over the builtin's arguments. - [QuakeServer.Extensions.Json](QuakeServer.Extensions.Json.md): FTE's JSON builtins: `json_parse` lays the parsed tree out in the program's memory and returns its root node's address (null when the text is not JSON); the others read a node: `json_get_value_type` (0 string, 1 number, 2 object, 3 array, 4 true, 5 false, 6 null), `json_get_name`, `json_get_integer`, `json_get_float`, `json_get_string`, `json_get_length`, `json_get_child_at_index` and `json_find_object_child` (null when absent). `json_free` gives the tree's memory back. A null node reads as JSON null. `js_run_script` returns null, as FTE does outside its web build. - [QuakeServer.Extensions.Levels](QuakeServer.Extensions.Levels.md): FTE's `changelevel(map, optional startspot)`: the first change asked for in a frame is kept, in the server's `changelevel` and, given a second argument, the landmark in `changelevel_startspot`; later ones are ignored. - [QuakeServer.Extensions.Lights](QuakeServer.Extensions.Lights.md): FTE's light builtins: `getlight` (the world's light at a point, 0 to 255 a channel, as `Cauldron3D.Bsp.Light.at/4` finds it), `lightstyle` with an optional colour, `getlightstyle` (the pattern, and the colour through its second argument) and `getlightstylergb` (the colour scaled by the pattern's brightness now, `m` being 1.03). - [QuakeServer.Extensions.Maths](QuakeServer.Extensions.Maths.md): FTE's arithmetic builtins: trigonometry, powers, logarithms, modulo, clamping, bit shifts, angle and vector helpers, and turning the `v_forward`, `v_right`, `v_up` axes. - [QuakeServer.Extensions.Memory](QuakeServer.Extensions.Memory.md): FTE's builtins over a program's memory as bytes: `createbuffer` (a zeroed block one byte longer than asked, or null for a size below 1), `memrealloc` (a new block holding the old one's bytes, the old one given back; a size of 0 is taken as 1, one below 0 or above 16 MiB fails with null), `memcmp` (bytes compared as unsigned, the sign of the first difference) and `memstrsize` (a string's length in bytes). - [QuakeServer.Extensions.Models](QuakeServer.Extensions.Models.md): FTE's model builtins: model numbers by name and names by number; a studio model's sequences ("frames") by name and action, their length and their events; skeleton objects; tags (a studio model's bones, then its attachments, numbered from 1) and where a tag lies on an entity in the world; and the surfaces of a brush model, with their corners' position, texture axes, normal, texture and lightmap places and light. - [QuakeServer.Extensions.Movement](QuakeServer.Extensions.Movement.md): FTE's movement builtins: the engine's player movement (`runstandardplayerphysics`), area portals (`openportal`) and the rigid-body physics calls. - [QuakeServer.Extensions.Net](QuakeServer.Extensions.Net.md): FTE's message builtins beyond Quake's: writing floats and integers, and `multicast`, which sends the message built with `MSG_MULTICAST` (`QuakeServer.Multicast.send/4`) and starts a new one. - [QuakeServer.Extensions.Polygons](QuakeServer.Extensions.Polygons.md): FTE's server polygon builtins, for drawing in the world from the server program: `R_BeginPolygon(texture, flags, is2d)`, `R_PolygonVertex(origin, texcoords, rgb, alpha)` and `R_EndPolygon()`. Each finished polygon becomes the event `{:polygon, %{texture:, flags:, flat?:, vertices: [{origin, texcoords, rgb, alpha}]}}` (`QuakeServer.Server.emit/2`), and the next starts on the same texture. - [QuakeServer.Extensions.Routes](QuakeServer.Extensions.Routes.md): FTE's `route_calculate` (`sv_move.c`): a path over the level's waypoints from where an entity stands to a destination, handed to the program's callback at the start of the next frame (`run/1`) as a list of nodes in allocated memory. - [QuakeServer.Extensions.Settings](QuakeServer.Extensions.Settings.md): FTE's builtins about the engine around the program: console variables (`cvar`, `cvar_string`, `cvar_set`, `cvar_setf`, `registercvar`, `cvar_defstring`, `cvar_type`, `cvar_description`, `buf_cvarlist`, `cvars_haveunsaved`, as FTE's `pr_bgcmd.c` runs them on the host's `QuakeServer.Cvars` table), server and player info keys, which extensions and functions exist, calling functions by name, the time, printing, console commands, registered stats, and the kinds of client. - [QuakeServer.Extensions.Store](QuakeServer.Extensions.Store.md): FTE's builtins that keep things: hash tables, allocated memory, files, file searches and string buffers. - [QuakeServer.Extensions.Strings](QuakeServer.Extensions.Strings.md): FTE's string builtins: length, joining, cutting, searching, comparing, case, number conversion, `sprintf`, and the tokenizers whose tokens `argv` reads back. - [QuakeServer.Extensions.Things](QuakeServer.Extensions.Things.md): FTE's entity builtins: finding by float, flags and string into chains, entity numbers, copying, freeing at once, box traces and tossed traces, potentially-visible checks, touching triggers, turning in pitch, attachments, and reading and writing fields by their place in the program's field list. - [QuakeServer.Extensions.Web](QuakeServer.Extensions.Web.md): FTE's network builtins - [QuakeServer.Keys](QuakeServer.Keys.md): FTE's key numbers (`keynum_t`), key names and modifiers, and the QuakeC key codes the client and menu programs use for them, as FTE's `keys.c` and `pr_clcmd.c` number, name and translate them. - [QuakeServer.Markup](QuakeServer.Markup.md): Text with FTE's markup reduced to the characters it shows, as FTE's `COM_ParseFunString` followed by `COM_DeFunString` with flags ignored: colour and style codes are dropped and a link's hidden part with them. - [QuakeServer.Messages](QuakeServer.Messages.md): The bytes a QuakeC program writes with `WriteByte` and the rest, read back into events for the client. - [QuakeServer.Models](QuakeServer.Models.md): The models a level has asked for, by index, as the server needs them: their box, and for brush models the hulls things collide with. - [QuakeServer.Multicast](QuakeServer.Multicast.md): FTE's `multicast` (`SV_MulticastProtExt`): the message a program built with `MSG_MULTICAST` goes to the players `to` names, each choosing as the player is when it is sent, into the player's reliable messages or datagram (`QuakeServer.Outbox`). - [QuakeServer.Network](QuakeServer.Network.md): FTE's delivery of the entities a program sends itself (`SendEntity`) to the client programs of the players watching (`sv_ents.c`). - [QuakeServer.Outbox](QuakeServer.Outbox.md): What the server holds for each player until the player's next packet, as FTE keeps it for a client: the reliable messages (`MSG_ONE`, reliable multicasts, prints), the datagram (unreliable multicasts), and the last centerprint, which goes out with the next packet after the reliable messages queued before it. - [QuakeServer.Physics](QuakeServer.Physics.md): One physics frame of a level, as FTE's server runs it (`sv_phys.c`): the program's `StartFrame`, then every entity by its move type (`WPhys_RunEntity`), then `EndFrame`, and the clock moved on by the frame. - [QuakeServer.Physics.Command](QuakeServer.Physics.Command.md): A player's command run by a program that defines `SV_RunClientCommand`, as FTE runs one when it arrives (`SV_RunFullQCMovement`, then `SV_PostRunCmd`): the `input_` globals are set from the command; unless the server is fixing the player's view (`fixangle`), `v_angle` and `movement` are too; the button fields and `impulse` are set; the velocity is bounded; while alive, the body turns to the view (a third of the pitch) and rolls with sideways speed; then `PlayerPreThink`, the player's think and `SV_RunClientCommand` run, and `PlayerPostThink` and the missile it spawned (`newmis`) after. When the program turned the view itself, the new view angles are kept for the client in the server's `ext.setangle`. The player is from then on left out of the physics frames (`QuakeServer.Physics.independent?/2`). - [QuakeServer.Physics.Move](QuakeServer.Physics.Move.md): FTE's solid-body movement (`sv_phys.c`): sliding along what a box hits (`WPhys_FlyMove`), moving a box at once (`WPhys_PushEntity`), the touches two entities run when they meet (`WPhys_Impact`), and the velocity clip a surface gives (`ClipVelocity`). - [QuakeServer.Physics.Push](QuakeServer.Physics.Push.md): FTE's straight push: a pusher moved by `move` takes along what stands on it and what its new place overlaps, by setting each one's origin and testing the spot. One that will not fit is nudged an eighth of a unit further, then left where it was if that is free; a box with no width, one not solid or a box trigger (flattened), or anything in a liquid pusher's way never blocks. Anything else blocks: the pusher and everything moved go back, and the pusher's `blocked` runs. Nothing is touched by the push itself. - [QuakeServer.Physics.PushTurn](QuakeServer.Physics.PushTurn.md): FTE's turning push: a pusher moved by `move` and turned by `turn` takes along what stands on it and what its new place overlaps. Each one is moved by `move`, turned by `turn` and swung round the pusher's origin by it, then its spot is tested. One that will not fit is put back if that is free, else pushed by `move` through the world, else nudged an eighth of a unit each way. A box with no width, anything in a liquid pusher's way, or one not solid or a box trigger (flattened) never blocks; anything else blocks: everything goes back, the pusher's `blocked` runs. Once all have moved, each touches the triggers it is in. - [QuakeServer.Physics.Pushed](QuakeServer.Physics.Pushed.md): What FTE's two pushes share (`QuakeServer.Physics.Push` and `QuakeServer.Physics.PushTurn`): which entities a pusher's move reaches, the pusher's `blocked` call, and putting moved entities back. - [QuakeServer.Physics.Pusher](QuakeServer.Physics.Pusher.md): Doors, lifts and trains, as FTE runs them (`WPhys_Physics_Pusher`): brush models that move on their own clock (`ltime`) by their `velocity` and turn by their `avelocity`, through `QuakeServer.Physics.Push` (moving only) or `QuakeServer.Physics.PushTurn` (turning). Each frame a pusher moves for the frame, or only until its `nextthink` when that comes first; the clock advances only when the push went through. When the clock has reached `nextthink` the think runs, with the program's `time` the frame's start. A pusher its think moved or turned is put back and pushed that far, taking along what it carries. - [QuakeServer.Physics.Walk](QuakeServer.Physics.Walk.md): FTE's walking movement (`sv_phys.c`), for walking entities other than players that move themselves: gravity (`WPhys_AddGravity`), the water check (`WPhys_CheckWater`), getting out of the world when stuck (`WPhys_CheckStuck`), and the walk itself with stepping up and down stairs (`WPhys_WalkMove`), slowed against walls it faces (`WPhys_WallFriction`). - [QuakeServer.Player](QuakeServer.Player.md): The player's command applied before physics for a program that does not run its players' commands itself, as FTE's NetQuake player physics (`SV_ClientThink`) does: view angles and buttons copied in, the body turned to the view and rolled by strafing, punch angles decayed, and the velocity accelerated on the ground (with friction, stronger at ledges), in the air, or in water. - [QuakeServer.Pmove](QuakeServer.Pmove.md): FTE's QuakeWorld player movement (`PM_PlayerMove`): one command of a player's input moving a box through the world and the entities near it. - [QuakeServer.Pmove.Command](QuakeServer.Pmove.Command.md): One command: `angles` as signed 16-bit numbers (360 degrees is 65536), the `forward`, `side` and `up` moves, the `buttons` bits (2 is jump) and its length `msec` in milliseconds. - [QuakeServer.Pmove.Movevars](QuakeServer.Pmove.Movevars.md): The movement settings. `entgravity` scales `gravity` for the player; `edge_box` tests for ledges with the player's box instead of a line; `coordtype` is `:float`, or `:fixed_13_3` for positions snapped to eighths before testing where the player fits, unless `noround`. - [QuakeServer.Pmove.Physent](QuakeServer.Pmove.Physent.md): Something the player can collide with or stand in: entity number `entity` at `origin`, either a brush model (`model`, as `QuakeServer.Models.get/2` gives it, turned by `angles`) or, with `model` `nil`, a box of `mins`..`maxs`. - [QuakeServer.Precaches](QuakeServer.Precaches.md): The server's sound list and particle effect list as FTE gives them to a player's client: the first time a player is sent them, the whole sound list as `svcfte_soundlistshort` and each effect as `svcfte_precache`, as FTE's signon does; after that every sound or effect added since, as `svcfte_precache`, as FTE sends a precache made while the level runs. All go into the player's reliable messages (`QuakeServer.Outbox`). - [QuakeServer.Q](QuakeServer.Q.md): The fixed numbers QuakeC programs share with FTE's server: move types, solid kinds, entity flags, contents, effects, spawn flags and message types. - [QuakeServer.Requests](QuakeServer.Requests.md): A client program's `sendevent` arriving at the server, as FTE handles one (its `qcrequest`): the program's function `CSEv__` runs with `self` the player and the values in its parameters, `types` being one letter a value — `f` float, `v` vector, `i` integer, `s` string, `e` entity. Without values the function is `CSEv__` when the name holds an underscore and `CSEv_` otherwise. A name the program has no function for prints that the request is not supported. - [QuakeServer.Runner](QuakeServer.Runner.md): A level running in a process of its own, on its own clock, as FTE's listen server runs one for its own client (`SV_Frame`, `SV_Physics`): the host clock follows real time, and physics frames catch up to it whenever it is at least the cvar `sv_mintic` ahead, each frame as long as it is ahead up to `sv_maxtic`; after `sv_limittics` frames of `sv_maxtic` the rest is dropped. A player's command runs as it arrives (`QuakeServer.Server.client_command/3`), covering its `msec` milliseconds when given, else its `timelength` in whole milliseconds, up to 250. A command's `sequence` (the client's number for it) is the one the server acknowledges in every packet after it runs, as FTE's server sends a client's `last_sequence` (`PEXT2_PREDINFO`): 0 when the program does not run its players' commands itself, telling the client it cannot predict. - [QuakeServer.Server](QuakeServer.Server.md): A running level of a QuakeC game: the program and its entities, the map, the models and sounds it has asked for, and what happened this frame for a client to show. - [QuakeServer.Signon](QuakeServer.Signon.md): The messages FTE sends a client after the level's model and sound lists and before the client begins (`SV_SendClientPrespawnInfo`, `SVQW_Spawn_f`): the static entities (`makestatic`), oldest first, then the static sounds (`ambientsound`), then each player slot's info keys. - [QuakeServer.Sounds](QuakeServer.Sounds.md): A sound started on the server, as FTE starts one (`SVQ1_StartSound`, `SV_StartSound`): it goes to the players as a sound message (`QuakeServer.Multicast`) and to the server's events as `{:sound, %{entity:, channel:, name:, volume:, attenuation:, origin:, pitch:}}`. - [QuakeServer.Source](QuakeServer.Source.md): Where a server finds its game: the compiled QuakeC program, the maps and the model files. A game names a module with these callbacks as `QuakeServer.Server.start/2`'s `:source`. - [QuakeServer.Spawn](QuakeServer.Spawn.md): A map's entities brought to life: the first is the world itself, every later one a fresh entity; each has its keys written into its fields and then its spawn function run with it as `self`. - [QuakeServer.Steps](QuakeServer.Steps.md): Monster movement as FTE's `sv_move.c` has it, with gravity along -z: a step that climbs stairs and slopes and refuses ledges, flying and swimming that rise or sink toward the enemy, turning toward `ideal_yaw`, and the choice of a new direction toward a goal when the way ahead is blocked. - [QuakeServer.TextNumbers](QuakeServer.TextNumbers.md): Numbers read from text as C's `strtod`, `strtol` and `atof` read them, the readings FTE's `stof` builtin and its entity-key parser (`ED_ParseEpair`) use. - [QuakeServer.Visibility](QuakeServer.Visibility.md): What a map's visibility lets a viewer potentially see, as FTE's server works it out for Quake and Half-Life maps (`q1bsp.c`): the leaves an entity's box touches, recorded when it is linked, and the leaves seen from every leaf within 8 units of a viewer's eye (the fat PVS), and the leaves that may hear a point (its PHS). - [QuakeServer.World](QuakeServer.World.md): Where a level's entities are, and what moving boxes run into, as FTE's `world.c` has it. - [QuakeServer.World.Area](QuakeServer.World.Area.md): The grid linked entities are filed in: 128 by 128 cells across the world model's ground, each at least 128 units wide, and one list for entities too large for it. - [QuakeServer.World.Hitboxes](QuakeServer.World.Hitboxes.md): A move against a studio model's hitboxes, posed as FTE's server poses it (`HLMDL_Trace`): a hitbox struck gives the trace its group as `surface_id`, its bone (from 1) as `bone_id`, its number (from 1) as `brush_id` and its face (from 1, 0 when the move started inside it) as `brush_face`. - [QuakeServer.World.Hulls](QuakeServer.World.Hulls.md): Boxes moved through a brush model's collision hulls, stopped by the contents a mask of `QuakeServer.Contents` bits names. - [QuakeServer.World.Trace](QuakeServer.World.Trace.md): What a move through the world ran into, with every field FTE's `trace_t` gives a program.