DarkPlaces
Game engine based on the Quake 1 engine by id Software, developed by LadyHavoc
 
sv_main.c
Go to the documentation of this file.
1/*
2Copyright (C) 1996-1997 Id Software, Inc.
3
4This program is free software; you can redistribute it and/or
5modify it under the terms of the GNU General Public License
6as published by the Free Software Foundation; either version 2
7of the License, or (at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12
13See the GNU General Public License for more details.
14
15You should have received a copy of the GNU General Public License
16along with this program; if not, write to the Free Software
17Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
19*/
20// sv_main.c -- server main program
21
22#include "quakedef.h"
23#include "sv_demo.h"
24#include "libcurl.h"
25#include "csprogs.h"
26#include "thread.h"
27
28// current client
30
31static void SV_SaveEntFile_f(cmd_state_t *cmd);
33static void SV_Download_f(cmd_state_t *cmd);
34static void SV_VM_Setup(void);
36
37cvar_t sv_worldmessage = {CF_SERVER | CF_READONLY, "sv_worldmessage", "", "title of current level"};
38cvar_t sv_worldname = {CF_SERVER | CF_READONLY, "sv_worldname", "", "name of current worldmodel"};
39cvar_t sv_worldnamenoextension = {CF_SERVER | CF_READONLY, "sv_worldnamenoextension", "", "name of current worldmodel without extension"};
40cvar_t sv_worldbasename = {CF_SERVER | CF_READONLY, "sv_worldbasename", "", "name of current worldmodel without maps/ prefix or extension"};
41
42cvar_t sv_disablenotify = {CF_SERVER, "sv_disablenotify", "0", "suppress broadcast prints when certain cvars are changed (CF_NOTIFY flag in engine code)"};
43cvar_t coop = {CF_SERVER, "coop","0", "coop mode, 0 = no coop, 1 = coop mode, multiple players playing through the singleplayer game (coop mode also shuts off deathmatch)"};
44cvar_t deathmatch = {CF_SERVER, "deathmatch","0", "deathmatch mode, values depend on mod but typically 0 = no deathmatch, 1 = normal deathmatch with respawning weapons, 2 = weapons stay (players can only pick up new weapons)"};
45cvar_t fraglimit = {CF_SERVER | CF_NOTIFY, "fraglimit","0", "ends level if this many frags is reached by any player"};
46cvar_t gamecfg = {CF_SERVER, "gamecfg", "0", "unused cvar in quake, can be used by mods"};
47cvar_t noexit = {CF_SERVER | CF_NOTIFY, "noexit","0", "kills anyone attempting to use an exit"};
48cvar_t nomonsters = {CF_SERVER, "nomonsters", "0", "unused cvar in quake, can be used by mods"};
49cvar_t pausable = {CF_SERVER, "pausable","1", "allow players to pause or not (otherwise, only the server admin can)"};
50cvar_t pr_checkextension = {CF_SERVER | CF_READONLY, "pr_checkextension", "1", "indicates to QuakeC that the standard quakec extensions system is available (if 0, quakec should not attempt to use extensions)"};
51cvar_t samelevel = {CF_SERVER | CF_NOTIFY, "samelevel","0", "repeats same level if level ends (due to timelimit or someone hitting an exit)"};
52cvar_t skill = {CF_SERVER, "skill","1", "difficulty level of game, affects monster layouts in levels, 0 = easy, 1 = normal, 2 = hard, 3 = nightmare (same layout as hard but monsters fire twice)"};
53cvar_t host_timescale = {CF_CLIENT | CF_SERVER, "host_timescale", "1.0", "controls game speed, 0.5 is half speed, 2 is double speed"};
54
55cvar_t sv_accelerate = {CF_SERVER, "sv_accelerate", "10", "rate at which a player accelerates to sv_maxspeed"};
56cvar_t sv_aim = {CF_SERVER | CF_ARCHIVE, "sv_aim", "2", "maximum cosine angle for quake's vertical autoaim, a value above 1 completely disables the autoaim, quake used 0.93"};
57cvar_t sv_airaccel_qw = {CF_SERVER, "sv_airaccel_qw", "1", "ratio of QW-style air control as opposed to simple acceleration; when < 0, the speed is clamped against the maximum allowed forward speed after the move"};
58cvar_t sv_airaccel_qw_stretchfactor = {CF_SERVER, "sv_airaccel_qw_stretchfactor", "0", "when set, the maximum acceleration increase the player may get compared to forward-acceleration when strafejumping"};
59cvar_t sv_airaccel_sideways_friction = {CF_SERVER, "sv_airaccel_sideways_friction", "", "anti-sideways movement stabilization (reduces speed gain when zigzagging); when < 0, only so much friction is applied that braking (by accelerating backwards) cannot be stronger"};
60cvar_t sv_airaccelerate = {CF_SERVER, "sv_airaccelerate", "-1", "rate at which a player accelerates to sv_maxairspeed while in the air, if less than 0 the sv_accelerate variable is used instead"};
61cvar_t sv_airstopaccelerate = {CF_SERVER, "sv_airstopaccelerate", "0", "when set, replacement for sv_airaccelerate when moving backwards"};
62cvar_t sv_airspeedlimit_nonqw = {CF_SERVER, "sv_airspeedlimit_nonqw", "0", "when set, this is a soft speed limit while in air when using airaccel_qw not equal to 1"};
63cvar_t sv_airstrafeaccelerate = {CF_SERVER, "sv_airstrafeaccelerate", "0", "when set, replacement for sv_airaccelerate when just strafing"};
64cvar_t sv_maxairstrafespeed = {CF_SERVER, "sv_maxairstrafespeed", "0", "when set, replacement for sv_maxairspeed when just strafing"};
65cvar_t sv_airstrafeaccel_qw = {CF_SERVER, "sv_airstrafeaccel_qw", "0", "when set, replacement for sv_airaccel_qw when just strafing"};
66cvar_t sv_aircontrol = {CF_SERVER, "sv_aircontrol", "0", "CPMA-style air control"};
67cvar_t sv_aircontrol_power = {CF_SERVER, "sv_aircontrol_power", "2", "CPMA-style air control exponent"};
68cvar_t sv_aircontrol_penalty = {CF_SERVER, "sv_aircontrol_penalty", "0", "deceleration while using CPMA-style air control"};
69cvar_t sv_allowdownloads = {CF_SERVER, "sv_allowdownloads", "1", "whether to allow clients to download files from the server (does not affect http downloads)"};
70cvar_t sv_allowdownloads_archive = {CF_SERVER, "sv_allowdownloads_archive", "0", "whether to allow downloads of archives (pak/pk3)"};
71cvar_t sv_allowdownloads_config = {CF_SERVER, "sv_allowdownloads_config", "0", "whether to allow downloads of config files (cfg)"};
72cvar_t sv_allowdownloads_dlcache = {CF_SERVER, "sv_allowdownloads_dlcache", "0", "whether to allow downloads of dlcache files (dlcache/)"};
73cvar_t sv_allowdownloads_inarchive = {CF_SERVER, "sv_allowdownloads_inarchive", "0", "whether to allow downloads from archives (pak/pk3)"};
74cvar_t sv_areagrid_link_SOLID_NOT = {CF_SERVER | CF_NOTIFY, "sv_areagrid_link_SOLID_NOT", "1", "set to 0 to prevent SOLID_NOT entities from being linked to the area grid, and unlink any that are already linked (in the code paths that would otherwise link them), for better performance"};
75cvar_t sv_areagrid_mingridsize = {CF_SERVER | CF_NOTIFY, "sv_areagrid_mingridsize", "128", "minimum areagrid cell size, smaller values work better for lots of small objects, higher values for large objects"};
76cvar_t sv_checkforpacketsduringsleep = {CF_SERVER, "sv_checkforpacketsduringsleep", "0", "uses select() function to wait between frames which can be interrupted by packets being received, instead of Sleep()/usleep()/SDL_Sleep() functions which do not check for packets"};
77cvar_t sv_clmovement_enable = {CF_SERVER, "sv_clmovement_enable", "1", "whether to allow clients to use cl_movement prediction, which can cause choppy movement on the server which may annoy other players"};
78cvar_t sv_clmovement_minping = {CF_SERVER, "sv_clmovement_minping", "0", "if client ping is below this time in milliseconds, then their ability to use cl_movement prediction is disabled for a while (as they don't need it)"};
79cvar_t sv_clmovement_minping_disabletime = {CF_SERVER, "sv_clmovement_minping_disabletime", "1000", "when client falls below minping, disable their prediction for this many milliseconds (should be at least 1000 or else their prediction may turn on/off frequently)"};
80cvar_t sv_clmovement_inputtimeout = {CF_SERVER, "sv_clmovement_inputtimeout", "0.1", "when a client does not send input for this many seconds (max 0.1), force them to move anyway (unlike QuakeWorld)"};
81cvar_t sv_cullentities_nevercullbmodels = {CF_SERVER, "sv_cullentities_nevercullbmodels", "0", "if enabled the clients are always notified of moving doors and lifts and other submodels of world (warning: eats a lot of network bandwidth on some levels!)"};
82cvar_t sv_cullentities_pvs = {CF_SERVER, "sv_cullentities_pvs", "1", "fast but loose culling of hidden entities"};
83cvar_t sv_cullentities_stats = {CF_SERVER, "sv_cullentities_stats", "0", "displays stats on network entities culled by various methods for each client"};
84cvar_t sv_cullentities_trace = {CF_SERVER, "sv_cullentities_trace", "0", "somewhat slow but very tight culling of hidden entities, minimizes network traffic and makes wallhack cheats useless"};
85cvar_t sv_cullentities_trace_delay = {CF_SERVER, "sv_cullentities_trace_delay", "1", "number of seconds until the entity gets actually culled (also applies to portal camera eyes even if sv_cullentities_trace is 0)"};
86cvar_t sv_cullentities_trace_delay_players = {CF_SERVER, "sv_cullentities_trace_delay_players", "0.2", "number of seconds until the entity gets actually culled if it is a player entity"};
87cvar_t sv_cullentities_trace_enlarge = {CF_SERVER, "sv_cullentities_trace_enlarge", "0", "box enlargement for entity culling (also applies to portal camera eyes even if sv_cullentities_trace is 0)"};
88cvar_t sv_cullentities_trace_expand = {CF_SERVER, "sv_cullentities_trace_expand", "0", "box is expanded by this many units for entity culling (also applies to portal camera eyes even if sv_cullentities_trace is 0)"};
89cvar_t sv_cullentities_trace_eyejitter = {CF_SERVER, "sv_cullentities_trace_eyejitter", "16", "jitter the eye by this much for each trace (also applies to portal camera eyes even if sv_cullentities_trace is 0)"};
90cvar_t sv_cullentities_trace_prediction = {CF_SERVER, "sv_cullentities_trace_prediction", "1", "also trace from the predicted player position"};
91cvar_t sv_cullentities_trace_prediction_time = {CF_SERVER, "sv_cullentities_trace_prediction_time", "0.2", "maximum ping time to predict in seconds"};
92cvar_t sv_cullentities_trace_entityocclusion = {CF_SERVER, "sv_cullentities_trace_entityocclusion", "0", "also check if doors and other bsp models are in the way"};
93cvar_t sv_cullentities_trace_samples = {CF_SERVER, "sv_cullentities_trace_samples", "2", "number of samples to test for entity culling"};
94cvar_t sv_cullentities_trace_samples_extra = {CF_SERVER, "sv_cullentities_trace_samples_extra", "2", "number of samples to test for entity culling when the entity affects its surroundings by e.g. dlight (also applies to portal camera eyes even if sv_cullentities_trace is 0)"};
95cvar_t sv_cullentities_trace_samples_players = {CF_SERVER, "sv_cullentities_trace_samples_players", "8", "number of samples to test for entity culling when the entity is a player entity"};
96cvar_t sv_cullentities_trace_spectators = {CF_SERVER, "sv_cullentities_trace_spectators", "0", "enables trace entity culling for clients that are spectating"};
97cvar_t sv_debugmove = {CF_SERVER | CF_NOTIFY, "sv_debugmove", "0", "disables collision detection optimizations for debugging purposes"};
98cvar_t sv_dedicated = {CF_SERVER | CF_READONLY, "sv_dedicated", "0", "for scripts and SVQC to detect when they're running on a dedicated server"};
99cvar_t sv_echobprint = {CF_SERVER | CF_ARCHIVE, "sv_echobprint", "1", "prints gamecode bprint() calls to server console"};
100cvar_t sv_edgefriction = {CF_SERVER, "edgefriction", "1", "how much you slow down when nearing a ledge you might fall off, multiplier of sv_friction (Quake used 2, QuakeWorld used 1 due to a bug in physics code)"};
101cvar_t sv_entpatch = {CF_SERVER, "sv_entpatch", "1", "enables loading of .ent files to override entities in the bsp (for example Threewave CTF server pack contains .ent patch files enabling play of CTF on id1 maps)"};
102cvar_t sv_freezenonclients = {CF_SERVER | CF_NOTIFY, "sv_freezenonclients", "0", "freezes time, except for players, allowing you to walk around and take screenshots of explosions"};
103cvar_t sv_friction = {CF_SERVER | CF_NOTIFY, "sv_friction","4", "how fast you slow down"};
104cvar_t sv_gameplayfix_blowupfallenzombies = {CF_SERVER, "sv_gameplayfix_blowupfallenzombies", "1", "causes findradius to detect SOLID_NOT entities such as zombies and corpses on the floor, allowing splash damage to apply to them"};
105cvar_t sv_gameplayfix_consistentplayerprethink = {CF_SERVER, "sv_gameplayfix_consistentplayerprethink", "0", "improves fairness in multiplayer by running all PlayerPreThink functions (which fire weapons) before performing physics, then running all PlayerPostThink functions"};
106cvar_t sv_gameplayfix_delayprojectiles = {CF_SERVER, "sv_gameplayfix_delayprojectiles", "1", "causes entities to not move on the same frame they are spawned, meaning that projectiles wait until the next frame to perform their first move, giving proper interpolation and rocket trails, but making weapons harder to use at low framerates"};
107cvar_t sv_gameplayfix_droptofloorstartsolid = {CF_SERVER, "sv_gameplayfix_droptofloorstartsolid", "1", "prevents items and monsters that start in a solid area from falling out of the level (makes droptofloor treat trace_startsolid as an acceptable outcome)"};
108cvar_t sv_gameplayfix_droptofloorstartsolid_nudgetocorrect = {CF_SERVER, "sv_gameplayfix_droptofloorstartsolid_nudgetocorrect", "1", "tries to nudge stuck items and monsters out of walls before droptofloor is performed"};
109cvar_t sv_gameplayfix_easierwaterjump = {CF_SERVER, "sv_gameplayfix_easierwaterjump", "1", "changes water jumping to make it easier to get out of water (exactly like in QuakeWorld)"};
110cvar_t sv_gameplayfix_findradiusdistancetobox = {CF_SERVER, "sv_gameplayfix_findradiusdistancetobox", "1", "causes findradius to check the distance to the corner of a box rather than the center of the box, makes findradius detect bmodels such as very large doors that would otherwise be unaffected by splash damage"};
111cvar_t sv_gameplayfix_gravityunaffectedbyticrate = {CF_SERVER, "sv_gameplayfix_gravityunaffectedbyticrate", "0", "fix some ticrate issues in physics."};
112cvar_t sv_gameplayfix_grenadebouncedownslopes = {CF_SERVER, "sv_gameplayfix_grenadebouncedownslopes", "1", "prevents MOVETYPE_BOUNCE (grenades) from getting stuck when fired down a downward sloping surface"};
113cvar_t sv_gameplayfix_impactbeforeonground = {CF_SERVER, "sv_gameplayfix_impactbeforeonground", "0", "enables a bug from old DP versions in which entity .touch functions are called before FL_ONGROUND is set when a collision is detected in SV_FlyMove() (used by MOVETYPE_WALK and MOVETYPE_STEP), Quake 1.5 and Combat+ mods require this, it breaks id1 fiends"};
114cvar_t sv_gameplayfix_multiplethinksperframe = {CF_SERVER, "sv_gameplayfix_multiplethinksperframe", "1", "allows entities to think more often than the server framerate, primarily useful for very high fire rate weapons"};
115cvar_t sv_gameplayfix_noairborncorpse = {CF_SERVER, "sv_gameplayfix_noairborncorpse", "1", "causes entities (corpses, items, etc) sitting ontop of moving entities (players) to fall when the moving entity (player) is no longer supporting them"};
116cvar_t sv_gameplayfix_noairborncorpse_allowsuspendeditems = {CF_SERVER, "sv_gameplayfix_noairborncorpse_allowsuspendeditems", "1", "causes entities sitting ontop of objects that are instantaneously remove to float in midair (special hack to allow a common level design trick for floating items)"};
117cvar_t sv_gameplayfix_nudgeoutofsolid = {CF_SERVER, "sv_gameplayfix_nudgeoutofsolid", "0", "attempts to fix physics errors where an object ended up in solid for some reason, smarter than sv_gameplayfix_unstick* except on Q1BSP with mod_q1bsp_polygoncollisions disabled (there it falls back to the unsticking method)"};
118cvar_t sv_gameplayfix_nudgeoutofsolid_separation = {CF_SERVER, "sv_gameplayfix_nudgeoutofsolid_separation", "0.03125", "keep objects this distance apart to prevent collision issues on seams"};
119cvar_t sv_gameplayfix_q2airaccelerate = {CF_SERVER, "sv_gameplayfix_q2airaccelerate", "0", "Quake2-style air acceleration"};
120cvar_t sv_gameplayfix_nogravityonground = {CF_SERVER, "sv_gameplayfix_nogravityonground", "0", "turn off gravity when on ground (to get rid of sliding)"};
121cvar_t sv_gameplayfix_setmodelrealbox = {CF_SERVER, "sv_gameplayfix_setmodelrealbox", "1", "fixes a bug in Quake that made setmodel always set the entity box to ('-16 -16 -16', '16 16 16') rather than properly checking the model box, breaks some poorly coded mods"};
122cvar_t sv_gameplayfix_slidemoveprojectiles = {CF_SERVER, "sv_gameplayfix_slidemoveprojectiles", "1", "allows MOVETYPE_FLY/FLYMISSILE/TOSS/BOUNCE/BOUNCEMISSILE entities to finish their move in a frame even if they hit something, fixes 'gravity accumulation' bug for grenades on steep slopes"};
123cvar_t sv_gameplayfix_stepdown = {CF_SERVER, "sv_gameplayfix_stepdown", "0", "attempts to step down stairs, not just up them (prevents the familiar thud..thud..thud.. when running down stairs and slopes)"};
124cvar_t sv_gameplayfix_stepmultipletimes = {CF_SERVER, "sv_gameplayfix_stepmultipletimes", "0", "applies step-up onto a ledge more than once in a single frame, when running quickly up stairs"};
125cvar_t sv_gameplayfix_nostepmoveonsteepslopes = {CF_SERVER, "sv_gameplayfix_nostepmoveonsteepslopes", "0", "crude fix which prevents MOVETYPE_STEP (not swimming or flying) to move on slopes whose angle is bigger than 45 degree"};
126cvar_t sv_gameplayfix_swiminbmodels = {CF_SERVER, "sv_gameplayfix_swiminbmodels", "1", "causes pointcontents (used to determine if you are in a liquid) to check bmodel entities as well as the world model, so you can swim around in (possibly moving) water bmodel entities"};
127cvar_t sv_gameplayfix_upwardvelocityclearsongroundflag = {CF_SERVER, "sv_gameplayfix_upwardvelocityclearsongroundflag", "1", "prevents monsters, items, and most other objects from being stuck to the floor when pushed around by damage, and other situations in mods"};
128cvar_t sv_gameplayfix_downtracesupportsongroundflag = {CF_SERVER, "sv_gameplayfix_downtracesupportsongroundflag", "1", "prevents very short moves from clearing onground (which may make the player stick to the floor at high netfps), fixes groundentity not being set when walking onto a mover with sv_gameplayfix_nogravityonground"};
129cvar_t sv_gameplayfix_q1bsptracelinereportstexture = {CF_SERVER, "sv_gameplayfix_q1bsptracelinereportstexture", "1", "enables mods to get accurate trace_texture results on q1bsp by using a surface-hitting traceline implementation rather than the standard solidbsp method, q3bsp always reports texture accurately"};
130cvar_t sv_gameplayfix_unstickplayers = {CF_SERVER, "sv_gameplayfix_unstickplayers", "1", "big hack to try and fix the rare case of MOVETYPE_WALK entities getting stuck in the world clipping hull. Quake did something similar."};
131cvar_t sv_gameplayfix_unstickentities = {CF_SERVER, "sv_gameplayfix_unstickentities", "0", "hack to check if entities are crossing world collision hull and try to move them to the right position. Quake didn't do this so maps shouldn't depend on it."};
132cvar_t sv_gameplayfix_fixedcheckwatertransition = {CF_SERVER, "sv_gameplayfix_fixedcheckwatertransition", "1", "fix two very stupid bugs in SV_CheckWaterTransition when watertype is CONTENTS_EMPTY (the bugs causes waterlevel to be 1 on first frame, -1 on second frame - the fix makes it 0 on both frames)"};
133cvar_t sv_gameplayfix_nosquashentities = {CF_SERVER, "sv_gameplayfix_nosquashentities", "0", "Entity hitboxes will not be resized or disabled when they are crushed by movers, and will continue to be affected by movers."};
134cvar_t sv_gravity = {CF_SERVER | CF_NOTIFY, "sv_gravity","800", "how fast you fall (512 = roughly earth gravity)"};
135cvar_t sv_init_frame_count = {CF_SERVER, "sv_init_frame_count", "2", "number of frames to run to allow everything to settle before letting clients connect"};
136cvar_t sv_idealpitchscale = {CF_SERVER, "sv_idealpitchscale","0.8", "how much to look up/down slopes and stairs when not using freelook"};
137cvar_t sv_jumpstep = {CF_SERVER | CF_NOTIFY, "sv_jumpstep", "0", "whether you can step up while jumping"};
138cvar_t sv_jumpvelocity = {CF_SERVER, "sv_jumpvelocity", "270", "cvar that can be used by QuakeC code for jump velocity"};
139cvar_t sv_legacy_bbox_expand = {CF_SERVER, "sv_legacy_bbox_expand", "1", "before linking an entity to the area grid, decrease its mins and increase its maxs by '1 1 1', or '15 15 1' if it has flag FL_ITEM (this is the Quake/QuakeWorld behaviour); disable to make SVQC bboxes consistent with CSQC which never does this expansion"};
140cvar_t sv_maxairspeed = {CF_SERVER, "sv_maxairspeed", "30", "maximum speed a player can accelerate to when airborn (note that it is possible to completely stop by moving the opposite direction)"};
141cvar_t sv_maxrate = {CF_SERVER | CF_ARCHIVE | CF_NOTIFY, "sv_maxrate", "1000000", "upper limit on client rate cvar, should reflect your network connection quality"};
142cvar_t sv_maxspeed = {CF_SERVER | CF_NOTIFY, "sv_maxspeed", "320", "maximum speed a player can accelerate to when on ground (can be exceeded by tricks)"};
143cvar_t sv_maxvelocity = {CF_SERVER | CF_NOTIFY, "sv_maxvelocity","2000", "universal speed limit on all entities"};
144cvar_t sv_nostep = {CF_SERVER | CF_NOTIFY, "sv_nostep","0", "prevents MOVETYPE_STEP entities (monsters) from moving"};
145cvar_t sv_playerphysicsqc = {CF_SERVER | CF_NOTIFY, "sv_playerphysicsqc", "1", "enables QuakeC function to override player physics"};
146cvar_t sv_progs = {CF_SERVER, "sv_progs", "progs.dat", "selects which quakec progs.dat file to run" };
147cvar_t sv_protocolname = {CF_SERVER, "sv_protocolname", "DP7", "selects network protocol to host for (values include QUAKE, QUAKEDP, NEHAHRAMOVIE, DP1 and up)"};
148cvar_t sv_qcstats = {CF_SERVER, "sv_qcstats", "0", "Disables engine sending of stats 220 and above, for use by certain games such as Xonotic, NOTE: it's strongly recommended that SVQC send correct STAT_MOVEVARS_TICRATE and STAT_MOVEVARS_TIMESCALE"};
149cvar_t sv_random_seed = {CF_SERVER, "sv_random_seed", "", "random seed; when set, on every map start this random seed is used to initialize the random number generator. Don't touch it unless for benchmarking or debugging"};
150cvar_t host_limitlocal = {CF_SERVER, "host_limitlocal", "0", "whether to apply rate limiting to the local player in a listen server (only useful for testing)"};
151cvar_t sv_sound_land = {CF_SERVER, "sv_sound_land", "demon/dland2.wav", "sound to play when MOVETYPE_STEP entity hits the ground at high speed (empty cvar disables the sound)"};
152cvar_t sv_sound_watersplash = {CF_SERVER, "sv_sound_watersplash", "misc/h2ohit1.wav", "sound to play when MOVETYPE_FLY/TOSS/BOUNCE/STEP entity enters or leaves water (empty cvar disables the sound)"};
153cvar_t sv_stepheight = {CF_SERVER | CF_NOTIFY, "sv_stepheight", "18", "how high you can step up (TW_SV_STEPCONTROL extension)"};
154cvar_t sv_stopspeed = {CF_SERVER | CF_NOTIFY, "sv_stopspeed","100", "how fast you come to a complete stop"};
155cvar_t sv_wallfriction = {CF_SERVER | CF_NOTIFY, "sv_wallfriction", "1", "how much you slow down when sliding along a wall"};
156cvar_t sv_wateraccelerate = {CF_SERVER, "sv_wateraccelerate", "-1", "rate at which a player accelerates to sv_maxspeed while in water, if less than 0 the sv_accelerate variable is used instead"};
157cvar_t sv_waterfriction = {CF_SERVER | CF_NOTIFY, "sv_waterfriction","-1", "how fast you slow down in water, if less than 0 the sv_friction variable is used instead"};
158cvar_t sv_warsowbunny_airforwardaccel = {CF_SERVER, "sv_warsowbunny_airforwardaccel", "1.00001", "how fast you accelerate until you reach sv_maxspeed"};
159cvar_t sv_warsowbunny_accel = {CF_SERVER, "sv_warsowbunny_accel", "0.1585", "how fast you accelerate until after reaching sv_maxspeed (it gets harder as you near sv_warsowbunny_topspeed)"};
160cvar_t sv_warsowbunny_topspeed = {CF_SERVER, "sv_warsowbunny_topspeed", "925", "soft speed limit (can get faster with rjs and on ramps)"};
161cvar_t sv_warsowbunny_turnaccel = {CF_SERVER, "sv_warsowbunny_turnaccel", "0", "max sharpness of turns (also master switch for the sv_warsowbunny_* mode; set this to 9 to enable)"};
162cvar_t sv_warsowbunny_backtosideratio = {CF_SERVER, "sv_warsowbunny_backtosideratio", "0.8", "lower values make it easier to change direction without losing speed; the drawback is \"understeering\" in sharp turns"};
163cvar_t sv_onlycsqcnetworking = {CF_SERVER, "sv_onlycsqcnetworking", "0", "disables legacy entity networking code for higher performance (except on clients, which can still be legacy)"};
164cvar_t sv_areadebug = {CF_SERVER, "sv_areadebug", "0", "disables physics culling for debugging purposes (only for development)"};
165
166cvar_t sys_ticrate = {CF_SERVER | CF_ARCHIVE, "sys_ticrate","0.01388889", "how long a server frame is in seconds, 0.05 is 20fps server rate, 0.1 is 10fps (can not be set higher than 0.1), 0 runs as many server frames as possible (makes games against bots a little smoother, overwhelms network players), 1/72 matches QuakeWorld physics"};
167cvar_t sv_maxphysicsframesperserverframe = {CF_SERVER, "sv_maxphysicsframesperserverframe","10", "maximum number of physics frames per server frame"};
168cvar_t sv_lagreporting_always = {CF_SERVER, "sv_lagreporting_always", "0", "report lag even in singleplayer, listen, an empty dedicated server, or during intermission"};
169cvar_t sv_lagreporting_strict = {CF_SERVER, "sv_lagreporting_strict", "0", "log any extra frames run to catch up after a holdup (only applies when sv_maxphysicsframesperserverframe > 1)"};
170cvar_t sv_threaded = {CF_SERVER, "sv_threaded", "0", "enables a separate thread for server code, improving performance, especially when hosting a game while playing, EXPERIMENTAL, may be crashy"};
171
172cvar_t teamplay = {CF_SERVER | CF_NOTIFY, "teamplay","0", "teamplay mode, values depend on mod but typically 0 = no teams, 1 = no team damage no self damage, 2 = team damage and self damage, some mods support 3 = no team damage but can damage self"};
173cvar_t timelimit = {CF_SERVER | CF_NOTIFY, "timelimit","0", "ends level at this time (in minutes)"};
174
175cvar_t sv_rollspeed = {CF_CLIENT, "sv_rollspeed", "200", "how much strafing is necessary to tilt the view"};
176cvar_t sv_rollangle = {CF_CLIENT, "sv_rollangle", "2.0", "how much to tilt the view when strafing"};
177
178cvar_t saved1 = {CF_SERVER | CF_ARCHIVE, "saved1", "0", "unused cvar in quake that is saved to config.cfg on exit, can be used by mods"};
179cvar_t saved2 = {CF_SERVER | CF_ARCHIVE, "saved2", "0", "unused cvar in quake that is saved to config.cfg on exit, can be used by mods"};
180cvar_t saved3 = {CF_SERVER | CF_ARCHIVE, "saved3", "0", "unused cvar in quake that is saved to config.cfg on exit, can be used by mods"};
181cvar_t saved4 = {CF_SERVER | CF_ARCHIVE, "saved4", "0", "unused cvar in quake that is saved to config.cfg on exit, can be used by mods"};
182cvar_t savedgamecfg = {CF_SERVER | CF_ARCHIVE, "savedgamecfg", "0", "unused cvar in quake that is saved to config.cfg on exit, can be used by mods"};
183cvar_t scratch1 = {CF_SERVER, "scratch1", "0", "unused cvar in quake, can be used by mods"};
184cvar_t scratch2 = {CF_SERVER,"scratch2", "0", "unused cvar in quake, can be used by mods"};
185cvar_t scratch3 = {CF_SERVER, "scratch3", "0", "unused cvar in quake, can be used by mods"};
186cvar_t scratch4 = {CF_SERVER, "scratch4", "0", "unused cvar in quake, can be used by mods"};
187cvar_t temp1 = {CF_SERVER, "temp1","0", "general cvar for mods to use, in stock id1 this selects which death animation to use on players (0 = random death, other values select specific death scenes)"};
188
189cvar_t nehx00 = {CF_SERVER, "nehx00", "0", "nehahra data storage cvar (used in singleplayer)"};
190cvar_t nehx01 = {CF_SERVER, "nehx01", "0", "nehahra data storage cvar (used in singleplayer)"};
191cvar_t nehx02 = {CF_SERVER, "nehx02", "0", "nehahra data storage cvar (used in singleplayer)"};
192cvar_t nehx03 = {CF_SERVER, "nehx03", "0", "nehahra data storage cvar (used in singleplayer)"};
193cvar_t nehx04 = {CF_SERVER, "nehx04", "0", "nehahra data storage cvar (used in singleplayer)"};
194cvar_t nehx05 = {CF_SERVER, "nehx05", "0", "nehahra data storage cvar (used in singleplayer)"};
195cvar_t nehx06 = {CF_SERVER, "nehx06", "0", "nehahra data storage cvar (used in singleplayer)"};
196cvar_t nehx07 = {CF_SERVER, "nehx07", "0", "nehahra data storage cvar (used in singleplayer)"};
197cvar_t nehx08 = {CF_SERVER, "nehx08", "0", "nehahra data storage cvar (used in singleplayer)"};
198cvar_t nehx09 = {CF_SERVER, "nehx09", "0", "nehahra data storage cvar (used in singleplayer)"};
199cvar_t nehx10 = {CF_SERVER, "nehx10", "0", "nehahra data storage cvar (used in singleplayer)"};
200cvar_t nehx11 = {CF_SERVER, "nehx11", "0", "nehahra data storage cvar (used in singleplayer)"};
201cvar_t nehx12 = {CF_SERVER, "nehx12", "0", "nehahra data storage cvar (used in singleplayer)"};
202cvar_t nehx13 = {CF_SERVER, "nehx13", "0", "nehahra data storage cvar (used in singleplayer)"};
203cvar_t nehx14 = {CF_SERVER, "nehx14", "0", "nehahra data storage cvar (used in singleplayer)"};
204cvar_t nehx15 = {CF_SERVER, "nehx15", "0", "nehahra data storage cvar (used in singleplayer)"};
205cvar_t nehx16 = {CF_SERVER, "nehx16", "0", "nehahra data storage cvar (used in singleplayer)"};
206cvar_t nehx17 = {CF_SERVER, "nehx17", "0", "nehahra data storage cvar (used in singleplayer)"};
207cvar_t nehx18 = {CF_SERVER, "nehx18", "0", "nehahra data storage cvar (used in singleplayer)"};
208cvar_t nehx19 = {CF_SERVER, "nehx19", "0", "nehahra data storage cvar (used in singleplayer)"};
209cvar_t cutscene = {CF_SERVER, "cutscene", "1", "enables cutscenes in nehahra, can be used by other mods"};
210
211cvar_t sv_autodemo_perclient = {CF_SERVER | CF_ARCHIVE, "sv_autodemo_perclient", "0", "set to 1 to enable autorecorded per-client demos (they'll start to record at the beginning of a match); set it to 2 to also record client->server packets (for debugging)"};
212cvar_t sv_autodemo_perclient_nameformat = {CF_SERVER | CF_ARCHIVE, "sv_autodemo_perclient_nameformat", "sv_autodemos/%Y-%m-%d_%H-%M", "The format of the sv_autodemo_perclient filename, followed by the map name, the client number and the IP address + port number, separated by underscores (the date is encoded using strftime escapes)" };
213cvar_t sv_autodemo_perclient_discardable = {CF_SERVER | CF_ARCHIVE, "sv_autodemo_perclient_discardable", "0", "Allow game code to decide whether a demo should be kept or discarded."};
214
215cvar_t halflifebsp = {CF_SERVER, "halflifebsp", "0", "indicates the current map is hlbsp format (useful to know because of different bounding box sizes)"};
216cvar_t sv_mapformat_is_quake2 = {CF_SERVER, "sv_mapformat_is_quake2", "0", "indicates the current map is q2bsp format (useful to know because of different entity behaviors, .frame on submodels and other things)"};
217cvar_t sv_mapformat_is_quake3 = {CF_SERVER, "sv_mapformat_is_quake3", "0", "indicates the current map is q3bsp format (useful to know because of different entity behaviors)"};
218
219cvar_t sv_writepicture_quality = {CF_SERVER | CF_ARCHIVE, "sv_writepicture_quality", "10", "WritePicture quality offset (higher means better quality, but slower)"};
220
221cvar_t sv_sendentities_csqc_randomize_order = {CF_SERVER, "sv_sendentities_csqc_randomize_order", "1", "Randomize the order of sending CSQC entities (should behave better when packet size or bandwidth limits are exceeded)."};
222
225
227
229extern float scr_centertime_off;
230
231// MUST match effectnameindex_t in client.h
233{
234 "",
235 "TE_GUNSHOT",
236 "TE_GUNSHOTQUAD",
237 "TE_SPIKE",
238 "TE_SPIKEQUAD",
239 "TE_SUPERSPIKE",
240 "TE_SUPERSPIKEQUAD",
241 "TE_WIZSPIKE",
242 "TE_KNIGHTSPIKE",
243 "TE_EXPLOSION",
244 "TE_EXPLOSIONQUAD",
245 "TE_TAREXPLOSION",
246 "TE_TELEPORT",
247 "TE_LAVASPLASH",
248 "TE_SMALLFLASH",
249 "TE_FLAMEJET",
250 "EF_FLAME",
251 "TE_BLOOD",
252 "TE_SPARK",
253 "TE_PLASMABURN",
254 "TE_TEI_G3",
255 "TE_TEI_SMOKE",
256 "TE_TEI_BIGEXPLOSION",
257 "TE_TEI_PLASMAHIT",
258 "EF_STARDUST",
259 "TR_ROCKET",
260 "TR_GRENADE",
261 "TR_BLOOD",
262 "TR_WIZSPIKE",
263 "TR_SLIGHTBLOOD",
264 "TR_KNIGHTSPIKE",
265 "TR_VORESPIKE",
266 "TR_NEHAHRASMOKE",
267 "TR_NEXUIZPLASMA",
268 "TR_GLOWTRAIL",
269 "SVC_PARTICLE"
270};
271
272
273static void SV_CheckRequiredFuncs(prvm_prog_t *prog, const char *filename)
274{
275 // no required funcs?!
276}
277
278#define SV_REQFIELDS (sizeof(sv_reqfields) / sizeof(prvm_required_field_t))
279
281{
282#define PRVM_DECLARE_serverglobalfloat(x)
283#define PRVM_DECLARE_serverglobalvector(x)
284#define PRVM_DECLARE_serverglobalstring(x)
285#define PRVM_DECLARE_serverglobaledict(x)
286#define PRVM_DECLARE_serverglobalfunction(x)
287#define PRVM_DECLARE_clientglobalfloat(x)
288#define PRVM_DECLARE_clientglobalvector(x)
289#define PRVM_DECLARE_clientglobalstring(x)
290#define PRVM_DECLARE_clientglobaledict(x)
291#define PRVM_DECLARE_clientglobalfunction(x)
292#define PRVM_DECLARE_menuglobalfloat(x)
293#define PRVM_DECLARE_menuglobalvector(x)
294#define PRVM_DECLARE_menuglobalstring(x)
295#define PRVM_DECLARE_menuglobaledict(x)
296#define PRVM_DECLARE_menuglobalfunction(x)
297#define PRVM_DECLARE_serverfieldfloat(x) {ev_float, #x},
298#define PRVM_DECLARE_serverfieldvector(x) {ev_vector, #x},
299#define PRVM_DECLARE_serverfieldstring(x) {ev_string, #x},
300#define PRVM_DECLARE_serverfieldedict(x) {ev_entity, #x},
301#define PRVM_DECLARE_serverfieldfunction(x) {ev_function, #x},
302#define PRVM_DECLARE_clientfieldfloat(x)
303#define PRVM_DECLARE_clientfieldvector(x)
304#define PRVM_DECLARE_clientfieldstring(x)
305#define PRVM_DECLARE_clientfieldedict(x)
306#define PRVM_DECLARE_clientfieldfunction(x)
307#define PRVM_DECLARE_menufieldfloat(x)
308#define PRVM_DECLARE_menufieldvector(x)
309#define PRVM_DECLARE_menufieldstring(x)
310#define PRVM_DECLARE_menufieldedict(x)
311#define PRVM_DECLARE_menufieldfunction(x)
312#define PRVM_DECLARE_serverfunction(x)
313#define PRVM_DECLARE_clientfunction(x)
314#define PRVM_DECLARE_menufunction(x)
315#define PRVM_DECLARE_field(x)
316#define PRVM_DECLARE_global(x)
317#define PRVM_DECLARE_function(x)
318#include "prvm_offsets.h"
319#undef PRVM_DECLARE_serverglobalfloat
320#undef PRVM_DECLARE_serverglobalvector
321#undef PRVM_DECLARE_serverglobalstring
322#undef PRVM_DECLARE_serverglobaledict
323#undef PRVM_DECLARE_serverglobalfunction
324#undef PRVM_DECLARE_clientglobalfloat
325#undef PRVM_DECLARE_clientglobalvector
326#undef PRVM_DECLARE_clientglobalstring
327#undef PRVM_DECLARE_clientglobaledict
328#undef PRVM_DECLARE_clientglobalfunction
329#undef PRVM_DECLARE_menuglobalfloat
330#undef PRVM_DECLARE_menuglobalvector
331#undef PRVM_DECLARE_menuglobalstring
332#undef PRVM_DECLARE_menuglobaledict
333#undef PRVM_DECLARE_menuglobalfunction
334#undef PRVM_DECLARE_serverfieldfloat
335#undef PRVM_DECLARE_serverfieldvector
336#undef PRVM_DECLARE_serverfieldstring
337#undef PRVM_DECLARE_serverfieldedict
338#undef PRVM_DECLARE_serverfieldfunction
339#undef PRVM_DECLARE_clientfieldfloat
340#undef PRVM_DECLARE_clientfieldvector
341#undef PRVM_DECLARE_clientfieldstring
342#undef PRVM_DECLARE_clientfieldedict
343#undef PRVM_DECLARE_clientfieldfunction
344#undef PRVM_DECLARE_menufieldfloat
345#undef PRVM_DECLARE_menufieldvector
346#undef PRVM_DECLARE_menufieldstring
347#undef PRVM_DECLARE_menufieldedict
348#undef PRVM_DECLARE_menufieldfunction
349#undef PRVM_DECLARE_serverfunction
350#undef PRVM_DECLARE_clientfunction
351#undef PRVM_DECLARE_menufunction
352#undef PRVM_DECLARE_field
353#undef PRVM_DECLARE_global
354#undef PRVM_DECLARE_function
355};
356
357#define SV_REQGLOBALS (sizeof(sv_reqglobals) / sizeof(prvm_required_field_t))
358
360{
361#define PRVM_DECLARE_serverglobalfloat(x) {ev_float, #x},
362#define PRVM_DECLARE_serverglobalvector(x) {ev_vector, #x},
363#define PRVM_DECLARE_serverglobalstring(x) {ev_string, #x},
364#define PRVM_DECLARE_serverglobaledict(x) {ev_entity, #x},
365#define PRVM_DECLARE_serverglobalfunction(x) {ev_function, #x},
366#define PRVM_DECLARE_clientglobalfloat(x)
367#define PRVM_DECLARE_clientglobalvector(x)
368#define PRVM_DECLARE_clientglobalstring(x)
369#define PRVM_DECLARE_clientglobaledict(x)
370#define PRVM_DECLARE_clientglobalfunction(x)
371#define PRVM_DECLARE_menuglobalfloat(x)
372#define PRVM_DECLARE_menuglobalvector(x)
373#define PRVM_DECLARE_menuglobalstring(x)
374#define PRVM_DECLARE_menuglobaledict(x)
375#define PRVM_DECLARE_menuglobalfunction(x)
376#define PRVM_DECLARE_serverfieldfloat(x)
377#define PRVM_DECLARE_serverfieldvector(x)
378#define PRVM_DECLARE_serverfieldstring(x)
379#define PRVM_DECLARE_serverfieldedict(x)
380#define PRVM_DECLARE_serverfieldfunction(x)
381#define PRVM_DECLARE_clientfieldfloat(x)
382#define PRVM_DECLARE_clientfieldvector(x)
383#define PRVM_DECLARE_clientfieldstring(x)
384#define PRVM_DECLARE_clientfieldedict(x)
385#define PRVM_DECLARE_clientfieldfunction(x)
386#define PRVM_DECLARE_menufieldfloat(x)
387#define PRVM_DECLARE_menufieldvector(x)
388#define PRVM_DECLARE_menufieldstring(x)
389#define PRVM_DECLARE_menufieldedict(x)
390#define PRVM_DECLARE_menufieldfunction(x)
391#define PRVM_DECLARE_serverfunction(x)
392#define PRVM_DECLARE_clientfunction(x)
393#define PRVM_DECLARE_menufunction(x)
394#define PRVM_DECLARE_field(x)
395#define PRVM_DECLARE_global(x)
396#define PRVM_DECLARE_function(x)
397#include "prvm_offsets.h"
398#undef PRVM_DECLARE_serverglobalfloat
399#undef PRVM_DECLARE_serverglobalvector
400#undef PRVM_DECLARE_serverglobalstring
401#undef PRVM_DECLARE_serverglobaledict
402#undef PRVM_DECLARE_serverglobalfunction
403#undef PRVM_DECLARE_clientglobalfloat
404#undef PRVM_DECLARE_clientglobalvector
405#undef PRVM_DECLARE_clientglobalstring
406#undef PRVM_DECLARE_clientglobaledict
407#undef PRVM_DECLARE_clientglobalfunction
408#undef PRVM_DECLARE_menuglobalfloat
409#undef PRVM_DECLARE_menuglobalvector
410#undef PRVM_DECLARE_menuglobalstring
411#undef PRVM_DECLARE_menuglobaledict
412#undef PRVM_DECLARE_menuglobalfunction
413#undef PRVM_DECLARE_serverfieldfloat
414#undef PRVM_DECLARE_serverfieldvector
415#undef PRVM_DECLARE_serverfieldstring
416#undef PRVM_DECLARE_serverfieldedict
417#undef PRVM_DECLARE_serverfieldfunction
418#undef PRVM_DECLARE_clientfieldfloat
419#undef PRVM_DECLARE_clientfieldvector
420#undef PRVM_DECLARE_clientfieldstring
421#undef PRVM_DECLARE_clientfieldedict
422#undef PRVM_DECLARE_clientfieldfunction
423#undef PRVM_DECLARE_menufieldfloat
424#undef PRVM_DECLARE_menufieldvector
425#undef PRVM_DECLARE_menufieldstring
426#undef PRVM_DECLARE_menufieldedict
427#undef PRVM_DECLARE_menufieldfunction
428#undef PRVM_DECLARE_serverfunction
429#undef PRVM_DECLARE_clientfunction
430#undef PRVM_DECLARE_menufunction
431#undef PRVM_DECLARE_field
432#undef PRVM_DECLARE_global
433#undef PRVM_DECLARE_function
434};
435
436static void Host_Timescale_c(cvar_t *var)
437{
438 if(var->value < 0.00001 && var->value != 0)
439 Cvar_SetValueQuick(var, 0);
440}
441
442//============================================================================
443
445{
446 World_PrintAreaStats(&sv.world, "server");
447}
448
449static void SV_ServerOptions (void)
450{
451 int i;
452
453 // general default
454 svs.maxclients = 8;
455
456// COMMANDLINEOPTION: Server: -dedicated [playerlimit] starts a dedicated server (with a command console), default playerlimit is 8
457// COMMANDLINEOPTION: Server: -listen [playerlimit] starts a multiplayer server with graphical client, like singleplayer but other players can connect, default playerlimit is 8
458 // if no client is in the executable or -dedicated is specified on
459 // commandline, start a dedicated server
460 i = Sys_CheckParm ("-dedicated");
461 if (i || !cl_available)
462 {
463 // check for -dedicated specifying how many players
464 if (i && i + 1 < sys.argc && atoi (sys.argv[i+1]) >= 1)
465 svs.maxclients = atoi (sys.argv[i+1]);
466 if (Sys_CheckParm ("-listen"))
467 Con_Printf ("Only one of -dedicated or -listen can be specified\n");
468 // default sv_public on for dedicated servers (often hosted by serious administrators), off for listen servers (often hosted by clueless users)
471 }
472 else if (cl_available)
473 {
474 // client exists and not dedicated, check if -listen is specified
476 i = Sys_CheckParm ("-listen");
477 if (i)
478 {
479 // default players unless specified
480 if (i + 1 < sys.argc && atoi (sys.argv[i+1]) >= 1)
481 svs.maxclients = atoi (sys.argv[i+1]);
482 }
483 else
484 {
485 // default players in some games, singleplayer in most
487 svs.maxclients = 1;
488 }
489 }
490
492
494
497}
498
499/*
500===============
501SV_Init
502===============
503*/
504void SV_Init (void)
505{
506 // init the csqc progs cvars, since they are updated/used by the server code
507 // TODO: fix this since this is a quick hack to make some of [515]'s broken code run ;) [9/13/2006 Black]
508 extern cvar_t csqc_progname; //[515]: csqc crc check and right csprogs name according to progs.dat
509 extern cvar_t csqc_progcrc;
510 extern cvar_t csqc_progsize;
512
517
522
523 Cmd_AddCommand(CF_SHARED, "sv_saveentfile", SV_SaveEntFile_f, "save map entities to .ent file (to allow external editing)");
524 Cmd_AddCommand(CF_SHARED, "sv_areastats", SV_AreaStats_f, "prints statistics on entity culling during collision traces");
525 Cmd_AddCommand(CF_CLIENT | CF_SERVER_FROM_CLIENT, "sv_startdownload", SV_StartDownload_f, "begins sending a file to the client (network protocol use only)");
526 Cmd_AddCommand(CF_CLIENT | CF_SERVER_FROM_CLIENT, "download", SV_Download_f, "downloads a specified file from the server");
527
542 Cvar_RegisterVirtual (&host_timescale, "timescale");
639 Cvar_RegisterVirtual(&host_limitlocal, "sv_ratelimitlocalplayer");
654
660
663
666
677
678 // LadyHavoc: Nehahra uses these to pass data around cutscene demos
699 Cvar_RegisterVariable (&cutscene); // for Nehahra but useful to other mods as well
700
704
708
710
712
715
716 sv_mempool = Mem_AllocPool("server", 0, NULL);
717
720}
721
723{
724 char vabuf[1024];
725 if (!sv.active || !sv.worldmodel)
726 {
727 Con_Print("Not running a server\n");
728 return;
729 }
730 FS_WriteFile(va(vabuf, sizeof(vabuf), "%s.ent", sv.worldnamenoextension), sv.worldmodel->brush.entities, (fs_offset_t)strlen(sv.worldmodel->brush.entities));
731}
732
733/*
734==============================================================================
735
736CLIENT SPAWNING
737
738==============================================================================
739*/
740
741/*
742================
743SV_SendServerinfo
744
745Sends the first message from the server to a connected client.
746This will be sent on the initial connection and upon each server load.
747================
748*/
750{
751 prvm_prog_t *prog = SVVM_prog;
752 int i;
753 char message[128];
754 char vabuf[1024];
755
756 // we know that this client has a netconnection and thus is not a bot
757
758 // edicts get reallocated on level changes, so we need to update it here
759 client->edict = PRVM_EDICT_NUM((client - svs.clients) + 1);
760
761 // clear cached stuff that depends on the level
762 client->weaponmodel[0] = 0;
763 client->weaponmodelindex = 0;
764
765 // LadyHavoc: clear entityframe tracking
766 client->latestframenum = 0;
767
768 // initialize the movetime, so a speedhack can't make use of the time before this client joined
769 client->cmd.time = sv.time;
770
771 if (client->entitydatabase)
773 if (client->entitydatabase4)
775 if (client->entitydatabase5)
777
778 memset(client->stats, 0, sizeof(client->stats));
779 memset(client->statsdeltabits, 0, sizeof(client->statsdeltabits));
780
782 {
785 else if (sv.protocol == PROTOCOL_DARKPLACES4)
787 else
789 }
790
791 // reset csqc entity versions
792 for (i = 0;i < prog->max_edicts;i++)
793 {
794 client->csqcentityscope[i] = 0;
795 client->csqcentitysendflags[i] = 0xFFFFFF;
796 }
797 for (i = 0;i < NUM_CSQCENTITYDB_FRAMES;i++)
798 {
799 client->csqcentityframehistory[i].num = 0;
800 client->csqcentityframehistory[i].framenum = -1;
801 }
802 client->csqcnumedicts = 0;
803 client->csqcentityframehistory_next = 0;
804
805 SZ_Clear (&client->netconnection->message);
807 dpsnprintf (message, sizeof (message), "\nServer: %s (progs %i crc)\n", engineversion, prog->filecrc);
809
810 SV_StopDemoRecording(client); // to split up demos into different files
812 {
813 char demofile[MAX_OSPATH];
814 char ipaddress[MAX_QPATH];
815 char timestring[128];
816 size_t j;
817
818 // start a new demo file
819 LHNETADDRESS_ToString(&(client->netconnection->peeraddress), ipaddress, sizeof(ipaddress), true);
820 for(j = 0; ipaddress[j]; ++j)
821 if(!isalnum(ipaddress[j]))
822 ipaddress[j] = '-';
823 Sys_TimeString(timestring, sizeof(timestring), sv_autodemo_perclient_nameformat.string);
824 dpsnprintf(demofile, sizeof(demofile), "%s_%s_%d_%s.dem", timestring,
825 sv.worldbasename, PRVM_NUM_FOR_EDICT(client->edict), ipaddress);
826
827 SV_StartDemoRecording(client, demofile, -1);
828 }
829
830 //[515]: init csprogs according to version of svprogs, check the crc, etc.
831 if (sv.csqc_progname[0])
832 {
833 Con_DPrintf("sending csqc info to client (\"%s\" with size %i and crc %i)\n", sv.csqc_progname, sv.csqc_progsize, sv.csqc_progcrc);
835 MSG_WriteString (&client->netconnection->message, va(vabuf, sizeof(vabuf), "csqc_progname %s\n", sv.csqc_progname));
837 MSG_WriteString (&client->netconnection->message, va(vabuf, sizeof(vabuf), "csqc_progsize %i\n", sv.csqc_progsize));
839 MSG_WriteString (&client->netconnection->message, va(vabuf, sizeof(vabuf), "csqc_progcrc %i\n", sv.csqc_progcrc));
840
841 if(client->sv_demo_file != NULL)
842 {
843 int k;
844 static char buf[NET_MAXMESSAGE];
845 sizebuf_t sb;
846
847 sb.data = (unsigned char *) buf;
848 sb.maxsize = sizeof(buf);
849 k = 0;
851 SV_WriteDemoMessage(client, &sb, false);
852 }
853
854 //[515]: init stufftext string (it is sent before svc_serverinfo)
855 if (PRVM_GetString(prog, PRVM_serverglobalstring(SV_InitCmd)))
856 {
858 MSG_WriteString (&client->netconnection->message, va(vabuf, sizeof(vabuf), "%s\n", PRVM_GetString(prog, PRVM_serverglobalstring(SV_InitCmd))));
859 }
860 }
861
862 //if (sv_allowdownloads.integer)
863 // always send the info that the server supports the protocol, even if downloads are forbidden
864 // only because of that, the CSQC exception can work
865 {
867 MSG_WriteString (&client->netconnection->message, "cl_serverextension_download 2\n");
868 }
869
870 // send at this time so it's guaranteed to get executed at the right time
871 {
872 client_t *save;
873 save = host_client;
874 host_client = client;
876 host_client = save;
877 }
878
882
885 else
887
889
890 for (i = 1;i < MAX_MODELS && sv.model_precache[i][0];i++)
892 MSG_WriteByte (&client->netconnection->message, 0);
893
894 for (i = 1;i < MAX_SOUNDS && sv.sound_precache[i][0];i++)
896 MSG_WriteByte (&client->netconnection->message, 0);
897
898// send music
902
903// set view
904// store this in clientcamera, too
905 client->clientcamera = PRVM_NUM_FOR_EDICT(client->edict);
908
910 MSG_WriteByte (&client->netconnection->message, 1);
911
912 client->prespawned = false; // need prespawn, spawn, etc
913 client->spawned = false; // need prespawn, spawn, etc
914 client->begun = false; // need prespawn, spawn, etc
915 client->sendsignon = 1; // send this message, and increment to 2, 2 will be set to 0 by the prespawn command
916
917 // clear movement info until client enters the new level properly
918 memset(&client->cmd, 0, sizeof(client->cmd));
919 client->movesequence = 0;
921 memset(&client->movement_count, 0, sizeof(client->movement_count));
922 client->ping = 0;
923
924 // allow the client some time to send his keepalives, even if map loading took ages
926}
927
928/*
929================
930SV_ConnectClient
931
932Initializes a client_t for a new net connection. This will only be called
933once for a player each game, not once for each level change.
934================
935*/
936void SV_ConnectClient (int clientnum, netconn_t *netconnection)
937{
938 prvm_prog_t *prog = SVVM_prog;
939 client_t *client;
940 int i;
941
942 client = svs.clients + clientnum;
943
944// set up the client_t
945 if (sv.loadgame)
946 {
947 float backupparms[NUM_SPAWN_PARMS];
948 memcpy(backupparms, client->spawn_parms, sizeof(backupparms));
949 memset(client, 0, sizeof(*client));
950 memcpy(client->spawn_parms, backupparms, sizeof(backupparms));
951 }
952 else
953 memset(client, 0, sizeof(*client));
954 client->active = true;
955 client->netconnection = netconnection;
956
957 Con_DPrintf("Client %s connected\n", client->netconnection ? client->netconnection->address : "botclient");
958
959 if(client->netconnection && client->netconnection->crypto.authenticated)
960 {
961 Con_Printf("%s connection to %s has been established: client is %s@%s%.*s, I am %.*s@%s%.*s\n",
962 client->netconnection->crypto.use_aes ? "Encrypted" : "Authenticated",
963 client->netconnection->address,
964 client->netconnection->crypto.client_idfp[0] ? client->netconnection->crypto.client_idfp : "-",
965 (client->netconnection->crypto.client_issigned || !client->netconnection->crypto.client_keyfp[0]) ? "" : "~",
968 (client->netconnection->crypto.server_issigned || !client->netconnection->crypto.server_keyfp[0]) ? "" : "~",
970 );
971 }
972
973 dp_strlcpy(client->name, "unconnected", sizeof(client->name));
974 dp_strlcpy(client->old_name, "unconnected", sizeof(client->old_name));
975 client->prespawned = false;
976 client->spawned = false;
977 client->begun = false;
978 client->edict = PRVM_EDICT_NUM(clientnum+1);
979 if (client->netconnection)
980 client->netconnection->message.allowoverflow = true; // we can catch it
981 // prepare the unreliable message buffer
982 client->unreliablemsg.data = client->unreliablemsg_data;
983 client->unreliablemsg.maxsize = sizeof(client->unreliablemsg_data);
984 // updated by receiving "rate" command from client, this is also the default if not using a DP client
985 client->rate = 1000000000;
986 client->connecttime = host.realtime;
987
988 if (!sv.loadgame)
989 {
990 // call the progs to get default spawn parms for the new client
991 // set self to world to intentionally cause errors with broken SetNewParms code in some mods
994 prog->ExecuteProgram(prog, PRVM_serverfunction(SetNewParms), "QC function SetNewParms is missing");
995 for (i=0 ; i<NUM_SPAWN_PARMS ; i++)
997
998 // set up the entity for this client (including .colormap, .team, etc)
999 PRVM_ED_ClearEdict(prog, client->edict);
1000 }
1001
1002 // don't call SendServerinfo for a fresh botclient because its fields have
1003 // not been set up by the qc yet
1004 if (client->netconnection)
1005 SV_SendServerinfo (client);
1006 else
1007 client->prespawned = client->spawned = client->begun = true;
1008}
1009
1010/*
1011=====================
1012SV_DropClient
1013
1014Called when the player is getting totally kicked off the host
1015if (leaving = true), don't bother sending signofs
1016=====================
1017*/
1018void SV_DropClient(qbool leaving, const char *fmt, ... )
1019{
1020 prvm_prog_t *prog = SVVM_prog;
1021 int i;
1022
1023 va_list argptr;
1024 char reason[512] = "";
1025
1026 Con_Printf("Client \"%s\" dropped", host_client->name);
1027
1028 if(fmt)
1029 {
1030 va_start(argptr, fmt);
1031 dpvsnprintf(reason, sizeof(reason), fmt, argptr);
1032 va_end(argptr);
1033
1034 Con_Printf(" (%s)\n", reason);
1035 }
1036 else
1037 {
1038 Con_Printf(" \n");
1039 }
1040
1042
1043 // make sure edict is not corrupt (from a level change for example)
1045
1047 {
1048 // tell the client to be gone
1049 if (!leaving)
1050 {
1051 // LadyHavoc: no opportunity for resending, so use unreliable 3 times
1052 unsigned char bufdata[520]; // Disconnect reason string can be 512 characters
1053 sizebuf_t buf;
1054 memset(&buf, 0, sizeof(buf));
1055 buf.data = bufdata;
1056 buf.maxsize = sizeof(bufdata);
1058 if(fmt)
1059 {
1061 MSG_WriteString(&buf, reason);
1062 else
1063 SV_ClientPrintf("%s\n", reason);
1064 }
1068 }
1069 }
1070
1071 // call qc ClientDisconnect function
1072 // LadyHavoc: don't call QC if server is dead (avoids recursive
1073 // Host_Error in some mods when they run out of edicts)
1075 {
1076 // call the prog function for removing a client
1077 // this will set the body to a dead frame, among other things
1078 int saveSelf = PRVM_serverglobaledict(self);
1082 prog->ExecuteProgram(prog, PRVM_serverfunction(ClientDisconnect), "QC function ClientDisconnect is missing");
1083 PRVM_serverglobaledict(self) = saveSelf;
1084 }
1085
1087 {
1088 // break the net connection
1091
1092 if(fmt)
1093 SV_BroadcastPrintf("\003^3%s left the game (%s)\n", host_client->name, reason);
1094 else
1095 SV_BroadcastPrintf("\003^3%s left the game\n", host_client->name);
1096 }
1097
1098 // if a download is active, close it
1100 {
1101 Con_DPrintf("Download of %s aborted when %s dropped\n", host_client->download_name, host_client->name);
1104 host_client->download_name[0] = 0;
1107 }
1108
1109 // remove leaving player from scoreboard
1110 host_client->name[0] = 0;
1111 host_client->colors = 0;
1112 host_client->frags = 0;
1113 // send notification to all clients
1114 // get number of client manually just to make sure we get it right...
1125
1126 // free the client now
1133
1134 if (sv.active)
1135 {
1136 // clear a fields that matter to DP_SV_CLIENTNAME and DP_SV_CLIENTCOLORS, and also frags
1138 }
1139
1140 // clear the client struct (this sets active to false)
1141 memset(host_client, 0, sizeof(*host_client));
1142
1143 // update server listing on the master because player count changed
1144 // (which the master uses for filtering empty/full servers)
1146
1147 if (sv.loadgame)
1148 {
1149 for (i = 0;i < svs.maxclients;i++)
1150 if (svs.clients[i].active && !svs.clients[i].spawned)
1151 break;
1152 if (i == svs.maxclients)
1153 {
1154 Con_Printf("Loaded game, everyone rejoined - unpausing\n");
1155 sv.paused = sv.loadgame = false; // we're basically done with loading now
1156 }
1157 }
1158}
1159
1165
1166/*
1167 * Compression extension negotiation:
1168 *
1169 * Server to client:
1170 * cl_serverextension_download 2
1171 *
1172 * Client to server:
1173 * download <filename> <list of zero or more suppported compressions in order of preference>
1174 * e.g.
1175 * download maps/map1.bsp lzo deflate huffman
1176 *
1177 * Server to client:
1178 * cl_downloadbegin <compressed size> <filename> <compression method actually used>
1179 * e.g.
1180 * cl_downloadbegin 123456 maps/map1.bsp deflate
1181 *
1182 * The server may choose not to compress the file by sending no compression name, like:
1183 * cl_downloadbegin 345678 maps/map1.bsp
1184 *
1185 * NOTE: the "download" command may only specify compression algorithms if
1186 * cl_serverextension_download is 2!
1187 * If cl_serverextension_download has a different value, the client must
1188 * assume this extension is not supported!
1189 */
1190
1192{
1193 int i;
1194 int argc = Cmd_Argc(cmd);
1195
1196 // first reset them all
1198
1199 for(i = 2; i < argc; ++i)
1200 {
1201 if(!strcmp(Cmd_Argv(cmd, i), "deflate"))
1202 {
1204 break;
1205 }
1206 }
1207}
1208
1210{
1211 const char *whichpack, *whichpack2, *extension;
1212 qbool is_csqc; // so we need to check only once
1213
1214 if (Cmd_Argc(cmd) < 2)
1215 {
1216 SV_ClientPrintf("usage: download <filename> {<extensions>}*\n");
1217 SV_ClientPrintf(" supported extensions: deflate\n");
1218 return;
1219 }
1220
1221 if (FS_CheckNastyPath(Cmd_Argv(cmd, 1), false))
1222 {
1223 SV_ClientPrintf("Download rejected: nasty filename \"%s\"\n", Cmd_Argv(cmd, 1));
1224 return;
1225 }
1226
1228 {
1229 // at this point we'll assume the previous download should be aborted
1230 Con_DPrintf("Download of %s aborted by %s starting a new download\n", host_client->download_name, host_client->name);
1231 SV_ClientCommands("\nstopdownload\n");
1232
1233 // close the file and reset variables
1236 host_client->download_name[0] = 0;
1239 }
1240
1241 is_csqc = (sv.csqc_progname[0] && strcmp(Cmd_Argv(cmd, 1), sv.csqc_progname) == 0);
1242
1243 if (!sv_allowdownloads.integer && !is_csqc)
1244 {
1245 SV_ClientPrintf("Downloads are disabled on this server\n");
1246 SV_ClientCommands("\nstopdownload\n");
1247 return;
1248 }
1249
1251
1254
1255 // host_client is asking to download a specified file
1257 Con_DPrintf("Download request for %s by %s\n", host_client->download_name, host_client->name);
1258
1259 if(is_csqc)
1260 {
1261 char extensions[MAX_QPATH]; // make sure this can hold all extensions
1262 extensions[0] = '\0';
1263
1265 dp_strlcat(extensions, " deflate", sizeof(extensions));
1266
1267 Con_DPrintf("Downloading %s to %s\n", host_client->download_name, host_client->name);
1268
1271 else
1273
1274 // no, no space is needed between %s and %s :P
1275 SV_ClientCommands("\ncl_downloadbegin %i %s%s\n", (int)FS_FileSize(host_client->download_file), host_client->download_name, extensions);
1276
1279 host_client->sendsignon = true; // make sure this message is sent
1280 return;
1281 }
1282
1284 {
1285 SV_ClientPrintf("Download rejected: server does not have the file \"%s\"\nYou may need to separately download or purchase the data archives for this game/mod to get this file\n", host_client->download_name);
1286 SV_ClientCommands("\nstopdownload\n");
1287 return;
1288 }
1289
1290 // check if the user is trying to download part of registered Quake(r)
1292 whichpack2 = FS_WhichPack("gfx/pop.lmp");
1293 if ((whichpack && whichpack2 && !strcasecmp(whichpack, whichpack2)) || FS_IsRegisteredQuakePack(host_client->download_name))
1294 {
1295 SV_ClientPrintf("Download rejected: file \"%s\" is part of registered Quake(r)\nYou must purchase Quake(r) from id Software or a retailer to get this file\nPlease go to http://www.idsoftware.com/games/quake/quake/index.php?game_section=buy\n", host_client->download_name);
1296 SV_ClientCommands("\nstopdownload\n");
1297 return;
1298 }
1299
1300 // check if the server has forbidden archive downloads entirely
1302 {
1304 if (whichpack)
1305 {
1306 SV_ClientPrintf("Download rejected: file \"%s\" is in an archive (\"%s\")\nYou must separately download or purchase the data archives for this game/mod to get this file\n", host_client->download_name, whichpack);
1307 SV_ClientCommands("\nstopdownload\n");
1308 return;
1309 }
1310 }
1311
1313 {
1314 if (!strcasecmp(extension, "cfg"))
1315 {
1316 SV_ClientPrintf("Download rejected: file \"%s\" is a .cfg file which is forbidden for security reasons\nYou must separately download or purchase the data archives for this game/mod to get this file\n", host_client->download_name);
1317 SV_ClientCommands("\nstopdownload\n");
1318 return;
1319 }
1320 }
1321
1323 {
1324 if (!strncasecmp(host_client->download_name, "dlcache/", 8))
1325 {
1326 SV_ClientPrintf("Download rejected: file \"%s\" is in the dlcache/ directory which is forbidden for security reasons\nYou must separately download or purchase the data archives for this game/mod to get this file\n", host_client->download_name);
1327 SV_ClientCommands("\nstopdownload\n");
1328 return;
1329 }
1330 }
1331
1333 {
1334 if (!strcasecmp(extension, "pak") || !strcasecmp(extension, "pk3") || !strcasecmp(extension, "dpk"))
1335 {
1336 SV_ClientPrintf("Download rejected: file \"%s\" is an archive\nYou must separately download or purchase the data archives for this game/mod to get this file\n", host_client->download_name);
1337 SV_ClientCommands("\nstopdownload\n");
1338 return;
1339 }
1340 }
1341
1344 {
1345 SV_ClientPrintf("Download rejected: server could not open the file \"%s\"\n", host_client->download_name);
1346 SV_ClientCommands("\nstopdownload\n");
1347 return;
1348 }
1349
1351 {
1352 SV_ClientPrintf("Download rejected: file \"%s\" is very large\n", host_client->download_name);
1353 SV_ClientCommands("\nstopdownload\n");
1356 return;
1357 }
1358
1360 {
1361 SV_ClientPrintf("Download rejected: file \"%s\" is not a regular file\n", host_client->download_name);
1362 SV_ClientCommands("\nstopdownload\n");
1365 return;
1366 }
1367
1368 Con_DPrintf("Downloading %s to %s\n", host_client->download_name, host_client->name);
1369
1370 /*
1371 * we can only do this if we would actually deflate on the fly
1372 * which we do not (yet)!
1373 {
1374 char extensions[MAX_QPATH]; // make sure this can hold all extensions
1375 extensions[0] = '\0';
1376
1377 if(host_client->download_deflate)
1378 strlcat(extensions, " deflate", sizeof(extensions));
1379
1380 // no, no space is needed between %s and %s :P
1381 SV_ClientCommands("\ncl_downloadbegin %i %s%s\n", (int)FS_FileSize(host_client->download_file), host_client->download_name, extensions);
1382 }
1383 */
1384 SV_ClientCommands("\ncl_downloadbegin %i %s\n", (int)FS_FileSize(host_client->download_file), host_client->download_name);
1385
1388 host_client->sendsignon = true; // make sure this message is sent
1389
1390 // the rest of the download process is handled in SV_SendClientDatagram
1391 // and other code dealing with svc_downloaddata and clc_ackdownloaddata
1392 //
1393 // no svc_downloaddata messages will be sent until sv_startdownload is
1394 // sent by the client
1395}
1396
1397/*
1398==============================================================================
1399
1400SERVER SPAWNING
1401
1402==============================================================================
1403*/
1404
1405/*
1406================
1407SV_ModelIndex
1408
1409================
1410*/
1411int SV_ModelIndex(const char *s, int precachemode)
1412{
1414 char filename[MAX_QPATH];
1415 if (!s || !*s)
1416 return 0;
1417 // testing
1418 //if (precachemode == 2)
1419 // return 0;
1420 dp_strlcpy(filename, s, sizeof(filename));
1421 for (i = 2;i < limit;i++)
1422 {
1423 if (!sv.model_precache[i][0])
1424 {
1425 if (precachemode)
1426 {
1428 {
1429 Con_Printf("SV_ModelIndex(\"%s\"): precache_model can only be done in spawn functions\n", filename);
1430 return 0;
1431 }
1432 if (precachemode == 1)
1433 Con_Printf("SV_ModelIndex(\"%s\"): not precached (fix your code), precaching anyway\n", filename);
1434 dp_strlcpy(sv.model_precache[i], filename, sizeof(sv.model_precache[i]));
1435 if (sv.state == ss_loading)
1436 {
1437 // running from SV_SpawnServer which is launched from the client console command interpreter
1438 sv.models[i] = Mod_ForName (sv.model_precache[i], true, false, s[0] == '*' ? sv.worldname : NULL);
1439 }
1440 else
1441 {
1442 if (svs.threaded)
1443 {
1444 // this is running on the server thread, we can't load a model here (it would crash on renderer calls), so only look it up, the svc_precache will cause it to be loaded when it reaches the client
1445 sv.models[i] = Mod_FindName (sv.model_precache[i], s[0] == '*' ? sv.worldname : NULL);
1446 }
1447 else
1448 {
1449 // running single threaded, so we can load the model here
1450 sv.models[i] = Mod_ForName (sv.model_precache[i], true, false, s[0] == '*' ? sv.worldname : NULL);
1451 }
1455 }
1456 return i;
1457 }
1458 Con_Printf("SV_ModelIndex(\"%s\"): not precached\n", filename);
1459 return 0;
1460 }
1461 if (!strcmp(sv.model_precache[i], filename))
1462 return i;
1463 }
1464 Con_Printf("SV_ModelIndex(\"%s\"): i (%i) == MAX_MODELS (%i)\n", filename, i, MAX_MODELS);
1465 return 0;
1466}
1467
1468/*
1469================
1470SV_SoundIndex
1471
1472================
1473*/
1474int SV_SoundIndex(const char *s, int precachemode)
1475{
1477 char filename[MAX_QPATH];
1478 if (!s || !*s)
1479 return 0;
1480 // testing
1481 //if (precachemode == 2)
1482 // return 0;
1483 dp_strlcpy(filename, s, sizeof(filename));
1484 for (i = 1;i < limit;i++)
1485 {
1486 if (!sv.sound_precache[i][0])
1487 {
1488 if (precachemode)
1489 {
1491 {
1492 Con_Printf("SV_SoundIndex(\"%s\"): precache_sound can only be done in spawn functions\n", filename);
1493 return 0;
1494 }
1495 if (precachemode == 1)
1496 Con_Printf("SV_SoundIndex(\"%s\"): not precached (fix your code), precaching anyway\n", filename);
1497 dp_strlcpy(sv.sound_precache[i], filename, sizeof(sv.sound_precache[i]));
1498 if (sv.state != ss_loading)
1499 {
1503 }
1504 return i;
1505 }
1506 Con_Printf("SV_SoundIndex(\"%s\"): not precached\n", filename);
1507 return 0;
1508 }
1509 if (!strcmp(sv.sound_precache[i], filename))
1510 return i;
1511 }
1512 Con_Printf("SV_SoundIndex(\"%s\"): i (%i) == MAX_SOUNDS (%i)\n", filename, i, MAX_SOUNDS);
1513 return 0;
1514}
1515
1516/*
1517================
1518SV_ParticleEffectIndex
1519
1520================
1521*/
1523{
1524 int i, argc, linenumber, effectnameindex;
1525 int filepass;
1526 fs_offset_t filesize;
1527 unsigned char *filedata;
1528 const char *text;
1529 const char *textstart;
1530 //const char *textend;
1531 char argv[16][1024];
1532 char filename[MAX_QPATH];
1534 {
1536 memset(sv.particleeffectname, 0, sizeof(sv.particleeffectname));
1537 for (i = 0;i < EFFECT_TOTAL;i++)
1539 for (filepass = 0;;filepass++)
1540 {
1541 if (filepass == 0)
1542 dpsnprintf(filename, sizeof(filename), "effectinfo.txt");
1543 else if (filepass == 1)
1544 dpsnprintf(filename, sizeof(filename), "%s_effectinfo.txt", sv.worldnamenoextension);
1545 else
1546 break;
1547 filedata = FS_LoadFile(filename, tempmempool, true, &filesize);
1548 if (!filedata)
1549 continue;
1550 textstart = (const char *)filedata;
1551 //textend = (const char *)filedata + filesize;
1552 text = textstart;
1553 for (linenumber = 1;;linenumber++)
1554 {
1555 argc = 0;
1556 for (;;)
1557 {
1558 if (!COM_ParseToken_Simple(&text, true, false, true) || !strcmp(com_token, "\n"))
1559 break;
1560 if (argc < 16)
1561 {
1562 dp_strlcpy(argv[argc], com_token, sizeof(argv[argc]));
1563 argc++;
1564 }
1565 }
1566 if (com_token[0] == 0)
1567 break; // if the loop exited and it's not a \n, it's EOF
1568 if (argc < 1)
1569 continue;
1570 if (!strcmp(argv[0], "effect"))
1571 {
1572 if (argc == 2)
1573 {
1574 for (effectnameindex = 1;effectnameindex < MAX_PARTICLEEFFECTNAME;effectnameindex++)
1575 {
1576 if (sv.particleeffectname[effectnameindex][0])
1577 {
1578 if (!strcmp(sv.particleeffectname[effectnameindex], argv[1]))
1579 break;
1580 }
1581 else
1582 {
1583 dp_strlcpy(sv.particleeffectname[effectnameindex], argv[1], sizeof(sv.particleeffectname[effectnameindex]));
1584 break;
1585 }
1586 }
1587 // if we run out of names, abort
1588 if (effectnameindex == MAX_PARTICLEEFFECTNAME)
1589 {
1590 Con_Printf("%s:%i: too many effects!\n", filename, linenumber);
1591 break;
1592 }
1593 }
1594 }
1595 }
1596 Mem_Free(filedata);
1597 }
1598 }
1599 // search for the name
1600 for (effectnameindex = 1;effectnameindex < MAX_PARTICLEEFFECTNAME && sv.particleeffectname[effectnameindex][0];effectnameindex++)
1601 if (!strcmp(sv.particleeffectname[effectnameindex], name))
1602 return effectnameindex;
1603 // return 0 if we couldn't find it
1604 return 0;
1605}
1606
1611
1613{
1614 prvm_prog_t *prog = SVVM_prog;
1615 int modelindex;
1616 if (!ed || ed->free)
1617 return NULL;
1619 return (modelindex > 0 && modelindex < MAX_MODELS) ? sv.models[modelindex] : NULL;
1620}
1621
1622/*
1623================
1624SV_CreateBaseline
1625
1626================
1627*/
1628static void SV_CreateBaseline (void)
1629{
1630 prvm_prog_t *prog = SVVM_prog;
1631 int i, entnum, large;
1632 prvm_edict_t *svent;
1633
1634 // LadyHavoc: clear *all* baselines (not just active ones)
1635 for (entnum = 0;entnum < prog->max_edicts;entnum++)
1636 {
1637 // get the current server version
1638 svent = PRVM_EDICT_NUM(entnum);
1639
1640 // LadyHavoc: always clear state values, whether the entity is in use or not
1641 svent->priv.server->baseline = defaultstate;
1642
1643 if (svent->free)
1644 continue;
1646 continue;
1647
1648 // create entity baseline
1649 VectorCopy (PRVM_serveredictvector(svent, origin), svent->priv.server->baseline.origin);
1650 VectorCopy (PRVM_serveredictvector(svent, angles), svent->priv.server->baseline.angles);
1651 svent->priv.server->baseline.frame = (int)PRVM_serveredictfloat(svent, frame);
1652 svent->priv.server->baseline.skin = (int)PRVM_serveredictfloat(svent, skin);
1653 if (entnum > 0 && entnum <= svs.maxclients)
1654 {
1655 svent->priv.server->baseline.colormap = entnum;
1656 svent->priv.server->baseline.modelindex = SV_ModelIndex("progs/player.mdl", 1);
1657 }
1658 else
1659 {
1660 svent->priv.server->baseline.colormap = 0;
1661 svent->priv.server->baseline.modelindex = (int)PRVM_serveredictfloat(svent, modelindex);
1662 }
1663
1664 large = false;
1665 if (svent->priv.server->baseline.modelindex & 0xFF00 || svent->priv.server->baseline.frame & 0xFF00)
1666 {
1667 large = true;
1669 large = false;
1670 }
1671
1672 // add to the message
1673 if (large)
1675 else
1678
1679 if (large)
1680 {
1681 MSG_WriteShort (&sv.signon, svent->priv.server->baseline.modelindex);
1682 MSG_WriteShort (&sv.signon, svent->priv.server->baseline.frame);
1683 }
1685 {
1686 MSG_WriteShort (&sv.signon, svent->priv.server->baseline.modelindex);
1687 MSG_WriteByte (&sv.signon, svent->priv.server->baseline.frame);
1688 }
1689 else
1690 {
1691 MSG_WriteByte (&sv.signon, svent->priv.server->baseline.modelindex);
1692 MSG_WriteByte (&sv.signon, svent->priv.server->baseline.frame);
1693 }
1694 MSG_WriteByte (&sv.signon, svent->priv.server->baseline.colormap);
1695 MSG_WriteByte (&sv.signon, svent->priv.server->baseline.skin);
1696 for (i=0 ; i<3 ; i++)
1697 {
1698 MSG_WriteCoord(&sv.signon, svent->priv.server->baseline.origin[i], sv.protocol);
1699 MSG_WriteAngle(&sv.signon, svent->priv.server->baseline.angles[i], sv.protocol);
1700 }
1701 }
1702}
1703
1704/*
1705================
1706SV_Prepare_CSQC
1707
1708Load csprogs.dat and comperss it so it doesn't need to be
1709reloaded on request.
1710================
1711*/
1712static void SV_Prepare_CSQC(void)
1713{
1714 fs_offset_t progsize;
1715
1716 if(svs.csqc_progdata)
1717 {
1718 Con_DPrintf("Unloading old CSQC data.\n");
1722 }
1723
1726
1727 sv.csqc_progname[0] = 0;
1729
1730 if(progsize > 0)
1731 {
1732 size_t deflated_size;
1733
1734 sv.csqc_progsize = (int)progsize;
1737 Con_DPrintf("server detected csqc progs file \"%s\" with size %i and crc %i\n", sv.csqc_progname, sv.csqc_progsize, sv.csqc_progcrc);
1738
1739 Con_DPrint("Compressing csprogs.dat\n");
1740 //unsigned char *FS_Deflate(const unsigned char *data, size_t size, size_t *deflated_size, int level, mempool_t *mempool);
1741 svs.csqc_progdata_deflated = FS_Deflate(svs.csqc_progdata, progsize, &deflated_size, -1, sv_mempool);
1742 svs.csqc_progsize_deflated = (int)deflated_size;
1744 {
1745 Con_DPrintf("Deflated: %g%%\n", 100.0 - 100.0 * (deflated_size / (float)progsize));
1746 Con_DPrintf("Uncompressed: %u\nCompressed: %u\n", (unsigned)sv.csqc_progsize, (unsigned)svs.csqc_progsize_deflated);
1747 }
1748 else
1749 Con_DPrintf("Cannot compress - need zlib for this. Using uncompressed progs only.\n");
1750 }
1751}
1752
1753/*
1754================
1755SV_SaveSpawnparms
1756
1757Grabs the current state of each client for saving across the
1758transition to another level
1759================
1760*/
1762{
1763 prvm_prog_t *prog = SVVM_prog;
1764 int i, j;
1765
1767
1768 for (i = 0, host_client = svs.clients;i < svs.maxclients;i++, host_client++)
1769 {
1770 if (!host_client->active)
1771 continue;
1772
1773 // call the progs to get default spawn parms for the new client
1776 prog->ExecuteProgram(prog, PRVM_serverfunction(SetChangeParms), "QC function SetChangeParms is missing");
1777 for (j=0 ; j<NUM_SPAWN_PARMS ; j++)
1779 }
1780}
1781
1782// Returns 1 if we're singleplayer, > 1 if we're a listen server
1784{
1785 return (host_isclient.integer && sv.active ? svs.maxclients : 0);
1786}
1787
1788static void SV_VM_Shutdown(qbool prog_reset)
1789{
1790 prvm_prog_t *prog = SVVM_prog;
1791
1793 {
1796 PRVM_serverfunction(SV_Shutdown) = 0; // prevent it from getting called again
1797 prog->ExecuteProgram(prog, s,"SV_Shutdown() required");
1798 }
1799 if (prog_reset)
1800 PRVM_Prog_Reset(prog);
1801}
1802
1803/*
1804================
1805SV_SpawnServer
1806
1807This is called at the start of each level
1808================
1809*/
1810
1811void SV_SpawnServer (const char *map)
1812{
1813 prvm_prog_t *prog = SVVM_prog;
1814 prvm_edict_t *ent;
1815 int i;
1816 char *entities;
1817 model_t *worldmodel;
1818 char modelname[sizeof(sv.worldname)];
1819 const char *canonicalname;
1820 char vabuf[1024];
1821
1822 Con_Printf("SpawnServer: %s\n", map);
1823
1824 dpsnprintf (modelname, sizeof(modelname), "maps/%s.bsp", map);
1825
1826 if (!(canonicalname = FS_FileExists(modelname)))
1827 {
1828 dpsnprintf (modelname, sizeof(modelname), "maps/%s", map);
1829 if (!(canonicalname = FS_FileExists(modelname)))
1830 {
1831 Con_Printf(CON_ERROR "SpawnServer: no map file named %s.bsp\n", modelname);
1832 return;
1833 }
1834 }
1835 // if it's not in a pak canonicalname will be the same pointer as modelname
1836 // if it's in a pak canonicalname may differ by case
1837 if (modelname != canonicalname)
1838 dp_strlcpy(modelname, canonicalname, sizeof(modelname));
1839
1840// SV_LockThreadMutex();
1841
1844 else
1845 {
1848 }
1849
1850 if(sv.active)
1851 SV_VM_Shutdown(false);
1852
1853 // free q3 shaders so that any newly downloaded shaders will be active
1855
1856 worldmodel = Mod_ForName(modelname, false, developer.integer > 0, NULL);
1857 if (!worldmodel || !worldmodel->TraceBox)
1858 {
1859 Con_Printf(CON_ERROR "Couldn't load map %s\n", modelname);
1860
1863
1864// SV_UnlockThreadMutex();
1865
1866 return;
1867 }
1868
1870
1871 // let's not have any servers with no name
1872 if (hostname.string[0] == 0)
1873 Cvar_SetQuick(&hostname, "UNNAMED");
1875
1876 svs.changelevel_issued = false; // now safe to issue another
1877
1878 // make the map a required file for clients
1880 Curl_RequireFile(modelname);
1881
1882//
1883// tell all connected clients that we are going to a new level
1884//
1885 if (sv.active)
1886 {
1887 client_t *client;
1888 for (i = 0, client = svs.clients;i < svs.maxclients;i++, client++)
1889 {
1890 if (client->netconnection)
1891 {
1893 MSG_WriteString(&client->netconnection->message, "reconnect\n");
1894 }
1895 }
1896 }
1897 else
1898 {
1899 // open server port
1901 }
1902
1903//
1904// make cvars consistant
1905//
1906 if (coop.integer)
1908 // LadyHavoc: it can be useful to have skills outside the range 0-3...
1909 //current_skill = bound(0, (int)(skill.value + 0.5), 3);
1910 //Cvar_SetValue ("skill", (float)current_skill);
1911 current_skill = (int)(skill.value + 0.5);
1912
1913//
1914// set up the new server
1915//
1916 memset (&sv, 0, sizeof(sv));
1917
1918 // tell SV_Frame() to reset its timers
1920
1921 // if running a local client, make sure it doesn't try to access the last
1922 // level's data which is no longer valiud
1923 cls.signon = 0;
1924
1928
1930 {
1931 srand(sv_random_seed.integer);
1932 Con_Printf(CON_WARN "NOTE: random seed is %d; use for debugging/benchmarking only!\nUnset sv_random_seed to get real random numbers again.\n", sv_random_seed.integer);
1933 }
1934
1935 SV_VM_Setup();
1936
1937 sv.active = true;
1938
1939 // set level base name variables for later use
1940 dp_strlcpy(sv.worldname, modelname, sizeof(sv.worldname));
1943// dp_strlcpy(sv.name, sv.worldbasename, sizeof (sv.name)); // TODO can we just remove this now?
1944 //Cvar_SetQuick(&sv_worldmessage, sv.worldmessage); // set later after QC is spawned
1948
1951 {
1952 char buffer[1024];
1953 Protocol_Names(buffer, sizeof(buffer));
1954 Con_Printf(CON_ERROR "Unknown sv_protocolname \"%s\", valid values are:\n%s\n", sv_protocolname.string, buffer);
1956 }
1957
1958// load progs to get entity field count
1959 //PR_LoadProgs ( sv_progs.string );
1960
1961 sv.datagram.maxsize = sizeof(sv.datagram_buf);
1962 sv.datagram.cursize = 0;
1964
1968
1969 sv.signon.maxsize = sizeof(sv.signon_buf);
1970 sv.signon.cursize = 0;
1972
1973// leave slots at start for clients only
1974 //prog->num_edicts = svs.maxclients+1;
1975
1977 prog->allowworldwrites = true;
1978 sv.paused = false;
1979
1980 sv.time = 1.0;
1981
1982 Mod_ClearUsed();
1983 worldmodel->used = true;
1984
1985 sv.worldmodel = worldmodel;
1986 sv.models[1] = sv.worldmodel;
1987
1988//
1989// clear world interaction links
1990//
1991 World_SetSize(&sv.world, sv.worldname, sv.worldmodel->normalmins, sv.worldmodel->normalmaxs, prog);
1993
1994 dp_strlcpy(sv.sound_precache[0], "", sizeof(sv.sound_precache[0]));
1995
1996 dp_strlcpy(sv.model_precache[0], "", sizeof(sv.model_precache[0]));
1998 for (i = 1;i < sv.worldmodel->brush.numsubmodels && i+1 < MAX_MODELS;i++)
1999 {
2000 dpsnprintf(sv.model_precache[i+1], sizeof(sv.model_precache[i+1]), "*%i", i);
2001 sv.models[i+1] = Mod_ForName (sv.model_precache[i+1], false, false, sv.worldname);
2002 }
2003 if(i < sv.worldmodel->brush.numsubmodels)
2004 Con_Printf(CON_WARN "Too many submodels (MAX_MODELS is %i)\n", MAX_MODELS);
2005
2006//
2007// load the rest of the entities
2008//
2009 // AK possible hack since num_edicts is still 0
2010 ent = PRVM_EDICT_NUM(0);
2011 memset (ent->fields.fp, 0, prog->entityfields * sizeof(prvm_vec_t));
2012 ent->free = false;
2014 PRVM_serveredictfloat(ent, modelindex) = 1; // world model
2021
2022 if (coop.value)
2024 else
2026
2028
2029// serverflags are for cross level information (sigils)
2031
2032 // we need to reset the spawned flag on all connected clients here so that
2033 // their thinks don't run during startup (before PutClientInServer)
2034 // we also need to set up the client entities now
2035 // and we need to set the ->edict pointers to point into the progs edicts
2036 for (i = 0, host_client = svs.clients;i < svs.maxclients;i++, host_client++)
2037 {
2038 host_client->begun = false;
2041 }
2042
2043 // load replacement entity file if found
2044 if (sv_entpatch.integer && (entities = (char *)FS_LoadFile(va(vabuf, sizeof(vabuf), "%s.ent", sv.worldnamenoextension), tempmempool, true, NULL)))
2045 {
2046 Con_Printf("Loaded %s.ent\n", sv.worldnamenoextension);
2047 PRVM_ED_LoadFromFile(prog, entities);
2048 Mem_Free(entities);
2049 }
2050 else
2051 PRVM_ED_LoadFromFile(prog, sv.worldmodel->brush.entities);
2052
2053
2054 // LadyHavoc: clear world angles (to fix e3m3.bsp)
2056
2057// all setup is completed, any further precache statements are errors
2058// sv.state = ss_active; // LadyHavoc: workaround for svc_precache bug
2059 prog->allowworldwrites = false;
2060
2061// run two frames to allow everything to settle
2062 sv.time = 1.0001;
2063 for (i = 0;i < sv_init_frame_count.integer;i++)
2064 {
2065 sv.frametime = 0.1;
2066 SV_Physics ();
2067 }
2068
2069 // Once all init frames have been run, we consider svqc code fully initialized.
2070 prog->inittime = host.realtime;
2071
2074
2075// create a baseline for more efficient communications
2078
2079 sv.state = ss_active; // LadyHavoc: workaround for svc_precache bug
2080
2081// send serverinfo to all connected clients, and set up botclients coming back from a level change
2082 for (i = 0, host_client = svs.clients;i < svs.maxclients;i++, host_client++)
2083 {
2084 host_client->clientconnectcalled = false; // do NOT call ClientDisconnect if he drops before ClientConnect!
2085 if (!host_client->active)
2086 continue;
2089 else
2090 {
2091 int j;
2092 // if client is a botclient coming from a level change, we need to
2093 // set up client info that normally requires networking
2094
2095 // copy spawn parms out of the client_t
2096 for (j=0 ; j< NUM_SPAWN_PARMS ; j++)
2098
2099 // call the spawn function
2103 prog->ExecuteProgram(prog, PRVM_serverfunction(ClientConnect), "QC function ClientConnect is missing");
2104 prog->ExecuteProgram(prog, PRVM_serverfunction(PutClientInServer), "QC function PutClientInServer is missing");
2105 host_client->begun = true;
2106 }
2107 }
2108
2109 // update the map title cvar (not related to filename)
2111
2112 Con_Printf("Server spawned.\n");
2114
2117
2118// SV_UnlockThreadMutex();
2119}
2120
2121/*
2122==================
2123SV_Shutdown
2124
2125This only happens at the end of a game, not between levels
2126==================
2127*/
2128void SV_Shutdown(void)
2129{
2130 int i;
2131
2133
2134 if (!sv.active)
2135 goto end;
2136
2137 Con_DPrintf("SV_Shutdown\n");
2138
2141
2142 // make sure all the clients know we're disconnecting
2143 for (i = 0, host_client = svs.clients;i < svs.maxclients;i++, host_client++)
2144 if (host_client->active)
2145 SV_DropClient(false, "Server shutting down"); // server shutdown
2146
2147 SV_VM_Shutdown(true);
2148
2150
2151 sv.active = false;
2152//
2153// clear structures
2154//
2155 memset(&sv, 0, sizeof(sv));
2156 memset(svs.clients, 0, svs.maxclients*sizeof(client_t));
2157end:
2159}
2160
2162// SV VM stuff
2163
2165{
2166 // links don't survive the transition, so unlink everything
2168}
2169
2171{
2172 int i;
2173 prvm_edict_t *ent;
2174
2175 // link every entity except world
2176 for (i = 1, ent = prog->edicts;i < prog->num_edicts;i++, ent++)
2177 if (!ent->free)
2178 SV_LinkEdict(ent);
2179}
2180
2182{
2183 // LadyHavoc: for consistency set these here
2184 int num = PRVM_NUM_FOR_EDICT(e) - 1;
2185
2186 e->priv.server->move = false; // don't move on first frame
2187
2188 if (num >= 0 && num < svs.maxclients)
2189 {
2190 // set colormap and team on newly created player entity
2191 PRVM_serveredictfloat(e, colormap) = num + 1;
2192 PRVM_serveredictfloat(e, team) = (svs.clients[num].colors & 15) + 1;
2193 // set netname/clientcolors back to client values so that
2194 // DP_SV_CLIENTNAME and DP_SV_CLIENTCOLORS will not immediately
2195 // reset them
2198 // NEXUIZ_PLAYERMODEL and NEXUIZ_PLAYERSKIN
2201 // Assign netaddress (IP Address, etc)
2202 if(svs.clients[num].netconnection != NULL)
2203 {
2204 // Acquire Readable Address
2205 LHNETADDRESS_ToString(&svs.clients[num].netconnection->peeraddress, svs.clients[num].netaddress, sizeof(svs.clients[num].netaddress), false);
2207 }
2208 else
2209 PRVM_serveredictstring(e, netaddress) = PRVM_SetEngineString(prog, "null/botclient");
2210 if(svs.clients[num].netconnection != NULL && svs.clients[num].netconnection->crypto.authenticated && svs.clients[num].netconnection->crypto.client_idfp[0])
2211 PRVM_serveredictstring(e, crypto_idfp) = PRVM_SetEngineString(prog, svs.clients[num].netconnection->crypto.client_idfp);
2212 else
2214 PRVM_serveredictfloat(e, crypto_idfp_signed) = (svs.clients[num].netconnection != NULL && svs.clients[num].netconnection->crypto.authenticated && svs.clients[num].netconnection->crypto.client_issigned);
2215 if(svs.clients[num].netconnection != NULL && svs.clients[num].netconnection->crypto.authenticated && svs.clients[num].netconnection->crypto.client_keyfp[0])
2216 PRVM_serveredictstring(e, crypto_keyfp) = PRVM_SetEngineString(prog, svs.clients[num].netconnection->crypto.client_keyfp);
2217 else
2219 if(svs.clients[num].netconnection != NULL && svs.clients[num].netconnection->crypto.authenticated && svs.clients[num].netconnection->crypto.server_keyfp[0])
2220 PRVM_serveredictstring(e, crypto_mykeyfp) = PRVM_SetEngineString(prog, svs.clients[num].netconnection->crypto.server_keyfp);
2221 else
2223 if(svs.clients[num].netconnection != NULL && svs.clients[num].netconnection->crypto.authenticated && svs.clients[num].netconnection->crypto.use_aes)
2225 else
2227 if(svs.clients[num].netconnection != NULL && svs.clients[num].netconnection->crypto.authenticated)
2229 else
2231 }
2232}
2233
2235{
2236 int i;
2237 int e;
2238
2239 World_UnlinkEdict(ed); // unlink from world bsp
2240
2245 PRVM_serveredictfloat(ed, skin) = 0;
2251
2252 VM_RemoveEdictSkeleton(prog, ed);
2253#ifdef USEODE
2256#endif
2257 // make sure csqc networking is aware of the removed entity
2258 e = PRVM_NUM_FOR_EDICT(ed);
2259 sv.csqcentityversion[e] = 0;
2260 for (i = 0;i < svs.maxclients;i++)
2261 svs.clients[i].csqcentitysendflags[e] = 0xFFFFFF;
2262}
2263
2265{
2266 int i;
2267 prvm_edict_t *ent;
2268 int active, models, solid, step;
2269
2270 active = models = solid = step = 0;
2271 for (i=0 ; i<prog->num_edicts ; i++)
2272 {
2273 ent = PRVM_EDICT_NUM(i);
2274 if (ent->free)
2275 continue;
2276 active++;
2277 if (PRVM_serveredictfloat(ent, solid))
2278 solid++;
2279 if (PRVM_serveredictstring(ent, model))
2280 models++;
2282 step++;
2283 }
2284
2285 Con_Printf("num_edicts:%3i\n", prog->num_edicts);
2286 Con_Printf("active :%3i\n", active);
2287 Con_Printf("view :%3i\n", models);
2288 Con_Printf("touch :%3i\n", solid);
2289 Con_Printf("step :%3i\n", step);
2290}
2291
2293{
2294 // remove things from different skill levels or deathmatch
2295 if (gamemode != GAME_TRANSFUSION) //Transfusion does this in QC
2296 {
2297 if (deathmatch.integer)
2298 {
2300 {
2301 return false;
2302 }
2303 }
2304 else if ((current_skill <= 0 && ((int)PRVM_serveredictfloat(ent, spawnflags) & SPAWNFLAG_NOT_EASY ))
2307 {
2308 return false;
2309 }
2310 }
2311 return true;
2312}
2313
2314static void SV_VM_Setup(void)
2315{
2316 prvm_prog_t *prog = SVVM_prog;
2318
2319 // allocate the mempools
2320 // TODO: move the magic numbers/constants into #defines [9/13/2006 Black]
2321 prog->progs_mempool = Mem_AllocPool("Server Progs", 0, NULL);
2322 prog->builtins = vm_sv_builtins;
2324 prog->max_edicts = 512;
2325 if (sv.protocol == PROTOCOL_QUAKE)
2326 prog->limit_edicts = 640; // before quake mission pack 1 this was 512
2327 else if (sv.protocol == PROTOCOL_QUAKEDP)
2328 prog->limit_edicts = 2048; // guessing
2329 else if (sv.protocol == PROTOCOL_NEHAHRAMOVIE)
2330 prog->limit_edicts = 2048; // guessing!
2332 prog->limit_edicts = 4096; // guessing!
2333 else
2334 prog->limit_edicts = MAX_EDICTS;
2337 prog->name = "server";
2339 prog->loadintoworld = true;
2340
2341 // all callbacks must be defined (pointers are not checked before calling)
2348 prog->init_cmd = SVVM_init_cmd;
2349 prog->reset_cmd = SVVM_reset_cmd;
2350 prog->error_cmd = Host_Error;
2352
2354
2355 // some mods compiled with scrambling compilers lack certain critical
2356 // global names and field names such as "self" and "time" and "nextthink"
2357 // so we have to set these offsets manually, matching the entvars_t
2358 // but we only do this if the prog header crc matches, otherwise it's totally freeform
2360 {
2482// PRVM_ED_FindGlobalOffset_FromStruct(globalvars_t, main);
2483// PRVM_ED_FindGlobalOffset_FromStruct(globalvars_t, StartFrame);
2484// PRVM_ED_FindGlobalOffset_FromStruct(globalvars_t, PlayerPreThink);
2485// PRVM_ED_FindGlobalOffset_FromStruct(globalvars_t, PlayerPostThink);
2486// PRVM_ED_FindGlobalOffset_FromStruct(globalvars_t, ClientKill);
2487// PRVM_ED_FindGlobalOffset_FromStruct(globalvars_t, ClientConnect);
2488// PRVM_ED_FindGlobalOffset_FromStruct(globalvars_t, PutClientInServer);
2489// PRVM_ED_FindGlobalOffset_FromStruct(globalvars_t, ClientDisconnect);
2490// PRVM_ED_FindGlobalOffset_FromStruct(globalvars_t, SetNewParms);
2491// PRVM_ED_FindGlobalOffset_FromStruct(globalvars_t, SetChangeParms);
2492 }
2493 else
2494 Con_DPrintf("%s: %s system vars have been modified (CRC %i != engine %i), will not load in other engines\n", prog->name, sv_progs.string, prog->progs_crc, PROGHEADER_CRC);
2495
2496 // OP_STATE is always supported on server because we add fields/globals for it
2497 prog->flag |= PRVM_OP_STATE;
2498
2499 VM_CustomStats_Clear();//[515]: csqc
2500
2502}
2503
2504static void SV_CheckTimeouts(void)
2505{
2506 int i;
2507
2508 // never timeout loopback connections
2509 for (i = (host_isclient.integer ? 1 : 0), host_client = &svs.clients[i]; i < svs.maxclients; i++, host_client++)
2511 SV_DropClient(false, "Timed out");
2512}
2513
2514/*
2515==================
2516SV_TimeReport
2517
2518Returns a time report string, for example for
2519==================
2520*/
2521const char *SV_TimingReport(char *buf, size_t buflen)
2522{
2523 return va(buf, buflen, "%.1f%% CPU, %.2f%% lost, offset avg %.1fms, max %.1fms, sdev %.1fms", sv.perf_cpuload * 100, sv.perf_lost * 100, sv.perf_offset_avg * 1000, sv.perf_offset_max * 1000, sv.perf_offset_sdev * 1000);
2524}
2525
2526extern cvar_t host_framerate;
2527double SV_Frame(double time)
2528{
2529 static double sv_timer;
2530 int i;
2531 char vabuf[1024];
2532 qbool reporting = false;
2533
2534 // reset timer after level change
2536 sv_timer = time = host.sleeptime = 0;
2537
2538 if (!svs.threaded)
2539 {
2540 prvm_prog_t *prog = SVVM_prog;
2541
2544
2546 reporting = true;
2547 // bones_was_here: intermission_running isn't declared in dpdefs, but it's used by
2548 // id1 Quake, all Quake mods (afaict), Nexuiz and Xonotic.
2549 else if (cls.state == ca_dedicated && !PRVM_serverglobalfloat(intermission_running))
2550 {
2551 // Report lag if there's players, so they know it wasn't the network or their machine
2552 for (i = 0; i < svs.maxclients; ++i)
2553 {
2554 if (svs.clients[i].begun && svs.clients[i].netconnection)
2555 {
2556 reporting = true;
2557 break;
2558 }
2559 }
2560 }
2561
2562 if(sv.perf_acc_realtime > 5)
2563 {
2566
2568 {
2573 }
2574
2575 if (sv.perf_lost > 0 && reporting)
2576 SV_BroadcastPrintf(CON_WARN "Server lag report: %s\n", SV_TimingReport(vabuf, sizeof(vabuf)));
2577
2582 }
2583
2584 /*
2585 * Receive packets on each main loop iteration, as the main loop may
2586 * be undersleeping due to select() detecting a new packet
2587 */
2588 if (sv.active)
2589 {
2592 }
2593 }
2594
2595 /*
2596 * If the accumulator hasn't become positive, don't
2597 * run the frame. Everything that happens before this
2598 * point will happen even if we're sleeping this frame.
2599 */
2600 if((sv_timer += time) < 0)
2601 return sv_timer;
2602
2603 // limit the frametime steps to no more than 100ms each
2604 if (sv_timer > 0.1)
2605 {
2606 if (!svs.threaded)
2607 sv.perf_acc_lost += (sv_timer - 0.1);
2608 sv_timer = 0.1;
2609 }
2610
2611 if (sv.active && sv_timer > 0 && !svs.threaded)
2612 {
2613 /*
2614 * Execute one or more server frames, with an upper limit on how much
2615 * execution time to spend on server frames to avoid freezing the game if
2616 * the server is overloaded. This execution time limit means the game will
2617 * slow down if the server is taking too long.
2618 */
2619 int framecount, framelimit = 1;
2620 double advancetime, aborttime = 0;
2621 float offset;
2622 prvm_prog_t *prog = SVVM_prog;
2623
2624 // run the world state
2625 // don't allow simulation to run too fast or too slow or logic glitches can occur
2626
2627 // stop running server frames if the wall time reaches this value
2628 if (sys_ticrate.value <= 0)
2629 advancetime = sv_timer;
2630 else
2631 {
2632 advancetime = sys_ticrate.value;
2633 // listen servers can run multiple server frames per client frame
2636 aborttime = Sys_DirtyTime() + 0.1;
2637 }
2638
2640 advancetime = min(advancetime, 0.1 / host_timescale.value);
2641 else
2642 advancetime = min(advancetime, 0.1);
2643
2644 if(advancetime > 0)
2645 {
2647 if (offset < 0 || offset >= 1800)
2648 offset = 0;
2649
2650 offset += sv_timer;
2654
2657 }
2658
2659 // only advance time if not paused
2660 // the game also pauses in singleplayer when menu or console is used
2661 sv.frametime = advancetime * host_timescale.value;
2664 if (sv.paused || host.paused)
2665 sv.frametime = 0;
2666
2667 for (framecount = 0; framecount < framelimit && sv_timer > 0; framecount++)
2668 {
2669 sv_timer -= advancetime;
2670
2671 // move things around and think unless paused
2672 if (sv.frametime)
2673 SV_Physics();
2674
2675 // if this server frame took too long, break out of the loop
2676 if (framelimit > 1 && Sys_DirtyTime() >= aborttime)
2677 break;
2678 }
2679
2680 if (framecount > 1 && sv_lagreporting_strict.integer && reporting)
2681 SV_BroadcastPrintf(CON_WARN "Server lag report: caught up %.1fms by running %d extra frames\n", advancetime * (framecount - 1) * 1000, framecount - 1);
2682
2683 R_TimeReport("serverphysics");
2684
2685 // send all messages to the clients
2687
2688 if (sv.paused == 1 && host.realtime > sv.pausedstart && sv.pausedstart > 0) {
2691 prog->ExecuteProgram(prog, PRVM_serverfunction(SV_PausedTic), "QC function SV_PausedTic is missing");
2692 }
2693
2694 // send an heartbeat if enough time has passed since the last one
2696 R_TimeReport("servernetwork");
2697 }
2698 else
2699 {
2700 // don't let r_speeds display jump around
2701 R_TimeReport("serverphysics");
2702 R_TimeReport("servernetwork");
2703 }
2704
2705 // if there is some time remaining from this frame, reset the timer
2706 if (sv_timer >= 0)
2707 {
2708 if (!svs.threaded)
2709 sv.perf_acc_lost += sv_timer;
2710 sv_timer = 0;
2711 }
2712
2713 return sv_timer;
2714}
2715
2716static int SV_ThreadFunc(void *voiddata)
2717{
2718 prvm_prog_t *prog = SVVM_prog;
2719 qbool playing = false;
2720 double sv_timer = 0;
2721 double sv_deltarealtime, sv_oldrealtime, sv_realtime;
2722 int i;
2723 char vabuf[1024];
2724 sv_realtime = Sys_DirtyTime();
2725 while (!svs.threadstop)
2726 {
2727 // FIXME: we need to handle Host_Error in the server thread somehow
2728// if (setjmp(sv_abortframe))
2729// continue; // something bad happened in the server game
2730
2731 sv_oldrealtime = sv_realtime;
2732 sv_realtime = Sys_DirtyTime();
2733 sv_deltarealtime = sv_realtime - sv_oldrealtime;
2734 if (sv_deltarealtime < 0 || sv_deltarealtime >= 1800) sv_deltarealtime = 0;
2735
2736 sv_timer += sv_deltarealtime;
2737
2738 sv.perf_acc_realtime += sv_deltarealtime;
2739
2740 // at this point we start doing real server work, and must block on any client activity pertaining to the server (such as executing SV_SpawnServer)
2742
2743 // Look for clients who have spawned
2744 playing = false;
2745 if (sv.active)
2746 for (i = 0, host_client = svs.clients;i < svs.maxclients;i++, host_client++)
2747 if(host_client->begun)
2749 playing = true;
2750 if(sv.time < 10)
2751 {
2752 // don't accumulate time for the first 10 seconds of a match
2753 // so things can settle
2755 }
2756 else if(sv.perf_acc_realtime > 5)
2757 {
2761 {
2765 }
2767 if(playing)
2768 Con_DPrintf("Server can't keep up: %s\n", SV_TimingReport(vabuf, sizeof(vabuf)));
2770 }
2771
2772 // get new packets
2773 if (sv.active)
2774 {
2777 }
2778
2779 // if the accumulators haven't become positive yet, wait a while
2780 if (sv_timer < 0)
2781 {
2782 SV_UnlockThreadMutex(); // don't keep mutex locked while sleeping
2783 sv.perf_acc_sleeptime += Sys_Sleep(-sv_timer);
2784 continue;
2785 }
2786
2787 if (sv.active && sv_timer > 0)
2788 {
2789 // execute one server frame
2790 double advancetime;
2791 float offset;
2792
2793 if (sys_ticrate.value <= 0)
2794 advancetime = min(sv_timer, 0.1); // don't step more than 100ms
2795 else
2796 advancetime = sys_ticrate.value;
2797
2798 if(advancetime > 0)
2799 {
2800 offset = sv_timer + (Sys_DirtyTime() - sv_realtime); // LadyHavoc: FIXME: I don't understand this line
2806 }
2807
2808 // only advance time if not paused
2809 // the game also pauses in singleplayer when menu or console is used
2810 sv.frametime = advancetime * host_timescale.value;
2813 if (sv.paused || host.paused)
2814 sv.frametime = 0;
2815
2816 sv_timer -= advancetime;
2817
2818 // move things around and think unless paused
2819 if (sv.frametime)
2820 SV_Physics();
2821
2822 // send all messages to the clients
2824
2825 if (sv.paused == 1 && sv_realtime > sv.pausedstart && sv.pausedstart > 0)
2826 {
2828 prog->globals.fp[OFS_PARM0] = sv_realtime - sv.pausedstart;
2829 prog->ExecuteProgram(prog, PRVM_serverfunction(SV_PausedTic), "QC function SV_PausedTic is missing");
2830 }
2831
2832 // send an heartbeat if enough time has passed since the last one
2834
2835 }
2836
2837 // we're back to safe code now
2839
2840 // if there is some time remaining from this frame, reset the timers
2841 if (sv_timer >= 0)
2842 {
2843 sv.perf_acc_lost += sv_timer;
2844 sv_timer = 0;
2845 }
2846 }
2847 return 0;
2848}
2849
2851{
2853 return;
2854 svs.threaded = true;
2855 svs.threadstop = false;
2858}
2859
2861{
2862 if (!svs.threaded)
2863 return;
2864 svs.threadstop = true;
2867 svs.threaded = false;
2868}
cvar_t csqc_progcrc
Definition cl_main.c:36
cvar_t csqc_usedemoprogs
Definition cl_main.c:38
cvar_t csqc_progsize
Definition cl_main.c:37
cvar_t csqc_progname
Definition cl_main.c:35
client_static_t cls
Definition cl_main.c:116
@ EFFECT_TOTAL
void SCR_BeginLoadingPlaque(qbool startup)
Definition cl_screen.c:1838
@ ca_dedicated
Definition client.h:530
@ ca_disconnected
Definition client.h:531
void Cmd_AddCommand(unsigned flags, const char *cmd_name, xcommand_t function, const char *description)
called by the init functions of other parts of the program to register commands and functions to call...
Definition cmd.c:1661
cmd_state_t * cmd_local
command interpreter for local commands injected by SVQC, CSQC, MQC, server or client engine code uses...
Definition cmd.c:25
#define CF_READONLY
cvar cannot be changed from the console or the command buffer, and is considered CF_PERSISTENT
Definition cmd.h:54
#define CF_SHARED
Definition cmd.h:67
#define CF_NOTIFY
cvar should trigger a chat notification to all connected clients when changed
Definition cmd.h:55
#define CF_SERVER
cvar/command that only the server can change/execute
Definition cmd.h:49
static int Cmd_Argc(cmd_state_t *cmd)
Definition cmd.h:249
static const char * Cmd_Argv(cmd_state_t *cmd, int arg)
Cmd_Argv(cmd, ) will return an empty string (not a NULL) if arg > argc, so string operations are alwa...
Definition cmd.h:254
#define CF_SERVER_FROM_CLIENT
command the client is allowed to execute on the server as a stringcmd
Definition cmd.h:51
#define CF_CLIENT
cvar/command that only the client can change/execute
Definition cmd.h:48
#define CF_ARCHIVE
cvar should have its set value saved to config.cfg and persist across sessions
Definition cmd.h:53
void Collision_Cache_Reset(qbool resetlimits)
Definition collision.c:1480
unsigned short CRC_Block(const unsigned char *data, size_t size)
Definition com_crc16.c:75
void EntityFrame4_FreeDatabase(entityframe4_database_t *d)
Definition com_ents4.c:13
entityframe4_database_t * EntityFrame4_AllocDatabase(mempool_t *pool)
Definition com_ents4.c:4
entityframe_database_t * EntityFrame_AllocDatabase(mempool_t *mempool)
Definition com_ents.c:5
void EntityFrame_FreeDatabase(entityframe_database_t *d)
Definition com_ents.c:11
gamemode_t gamemode
Definition com_game.c:26
#define IS_NEXUIZ_DERIVED(g)
Definition com_game.h:71
@ GAME_BATTLEMECH
Definition com_game.h:38
@ GAME_TRANSFUSION
Definition com_game.h:35
@ GAME_GOODVSBAD2
Definition com_game.h:36
void MSG_WriteShort(sizebuf_t *sb, int c)
Definition com_msg.c:138
void MSG_WriteString(sizebuf_t *sb, const char *s)
Definition com_msg.c:173
void MSG_WriteLong(sizebuf_t *sb, int c)
Definition com_msg.c:147
void MSG_WriteCoord(sizebuf_t *sb, float f, protocolversion_t protocol)
Definition com_msg.c:202
void MSG_WriteByte(sizebuf_t *sb, int c)
Definition com_msg.c:130
void MSG_WriteAngle(sizebuf_t *sb, float f, protocolversion_t protocol)
Definition com_msg.c:237
void SZ_Clear(sizebuf_t *buf)
Definition common.c:44
int dpvsnprintf(char *buffer, size_t buffersize, const char *format, va_list args)
Returns the number of printed characters, excluding the final '\0' or returns -1 if the buffer isn't ...
Definition common.c:1010
char com_token[MAX_INPUTLINE]
Definition common.c:39
char * va(char *buf, size_t buflen, const char *format,...)
Definition common.c:972
qbool COM_ParseToken_Simple(const char **datapointer, qbool returnnewline, qbool parsebackslash, qbool parsecomments)
Definition common.c:463
int dpsnprintf(char *buffer, size_t buffersize, const char *format,...)
Returns the number of printed characters, excluding the final '\0' or returns -1 if the buffer isn't ...
Definition common.c:997
@ PROTOCOL_DARKPLACES2
various changes
Definition common.h:140
@ PROTOCOL_DARKPLACES4
various changes
Definition common.h:138
@ PROTOCOL_NEHAHRABJP2
same as NEHAHRABJP but with 16bit soundindex
Definition common.h:147
@ PROTOCOL_DARKPLACES3
uses EntityFrame4 entity snapshot encoder/decoder which is broken, this attempted to do partial snaps...
Definition common.h:139
@ PROTOCOL_NEHAHRABJP
same as QUAKEDP but with 16bit modelindex
Definition common.h:146
@ PROTOCOL_DARKPLACES5
uses EntityFrame5 entity snapshot encoder/decoder which is based on a Tribes networking article at ht...
Definition common.h:137
@ PROTOCOL_QUAKEDP
darkplaces extended quake protocol (used by TomazQuake and others), backwards compatible as long as n...
Definition common.h:142
@ PROTOCOL_UNKNOWN
Definition common.h:133
@ PROTOCOL_QUAKE
quake (aka netquake/normalquake/nq) protocol
Definition common.h:144
@ PROTOCOL_DARKPLACES8
added parting messages. WIP
Definition common.h:134
@ PROTOCOL_NEHAHRABJP3
same as NEHAHRABJP2 but with some changes
Definition common.h:148
@ PROTOCOL_NEHAHRAMOVIE
Nehahra movie protocol, a big nasty hack dating back to early days of the Quake Standards Group (but ...
Definition common.h:143
@ PROTOCOL_DARKPLACES1
uses EntityFrame entity snapshot encoder/decoder which is a QuakeWorld-like entity snapshot delta com...
Definition common.h:141
#define dp_strlcat(dst, src, dsize)
Definition common.h:304
#define dp_strlcpy(dst, src, dsize)
Definition common.h:303
void Con_Print(const char *msg)
Prints to all appropriate console targets, and adds timestamps.
Definition console.c:1504
void Con_DPrintf(const char *fmt,...)
A Con_Printf that only shows up if the "developer" cvar is set.
Definition console.c:1544
void Con_Printf(const char *fmt,...)
Prints to all appropriate console targets.
Definition console.c:1514
void Con_DPrint(const char *msg)
A Con_Print that only shows up if the "developer" cvar is set.
Definition console.c:1531
#define CON_WARN
Definition console.h:101
#define CON_ERROR
Definition console.h:102
int crypto_keyfp_recommended_length
Definition crypto.c:41
qbool MakeDownloadPacket(const char *filename, unsigned char *data, size_t len, int crc, int cnt, sizebuf_t *buf, int protocol)
Definition csprogs.c:940
vector v_up
vector size
string classname
float movetype
float flags
entity trace_ent
entity other
float modelindex
entity self
string netname
vector avelocity
float frametime
entity owner
string mapname
vector mins
vector velocity
entity world
entity chain
float effects
float skin
float time
vector v_right
vector trace_endpos
float trace_startsolid
vector maxs
entity enemy
float nextthink
float trace_inopen
vector angles
float colormap
vector absmax
vector v_forward
float entnum
vector origin
string model
float trace_fraction
vector oldorigin
float solid
vector absmin
float frame
float trace_allsolid
vector trace_plane_normal
float trace_plane_dist
float trace_inwater
void Cvar_SetValueQuick(cvar_t *var, float value)
Definition cvar.c:473
void Cvar_SetQuick(cvar_t *var, const char *value)
Definition cvar.c:436
void Cvar_RegisterVariable(cvar_t *variable)
registers a cvar that already has the name, string, and optionally the archive elements set.
Definition cvar.c:599
void Cvar_RegisterVirtual(cvar_t *variable, const char *name)
Definition cvar.c:513
void Cvar_RegisterCallback(cvar_t *variable, void(*callback)(cvar_t *))
Definition cvar.c:495
void Cvar_Callback(cvar_t *var)
Definition cvar.c:372
char engineversion[128]
version string for the corner of the console, crash messages, status command, etc
Definition host.c:304
string crypto_keyfp
string playerskin
string crypto_encryptmethod
string netaddress
string crypto_idfp
float idealpitch
float crypto_idfp_signed
string crypto_mykeyfp
string crypto_signmethod
string playermodel
float clientcolors
const char * FS_FileExtension(const char *in)
Definition fs.c:1403
qfile_t * FS_OpenVirtualFile(const char *filepath, qbool quiet)
Definition fs.c:2928
qbool FS_WriteFile(const char *filename, const void *data, fs_offset_t len)
Definition fs.c:3592
unsigned char * FS_LoadFile(const char *path, mempool_t *pool, qbool quiet, fs_offset_t *filesizepointer)
Definition fs.c:3540
static int(ZEXPORT *qz_inflate)(z_stream *strm
void FS_StripExtension(const char *in, char *out, size_t size_out)
Definition fs.c:3611
fs_offset_t FS_FileSize(qfile_t *file)
Definition fs.c:3474
int FS_Close(qfile_t *file)
Definition fs.c:2970
const char * FS_WhichPack(const char *filename)
Definition fs.c:4091
unsigned char * FS_Deflate(const unsigned char *data, size_t size, size_t *deflated_size, int level, mempool_t *mempool)
Definition fs.c:4178
int FS_CheckNastyPath(const char *path, qbool isgamedir)
Definition fs.c:2618
const char * FS_FileExists(const char *filename)
Look for a file in the packages and in the filesystem Returns its canonical name (same case as used i...
Definition fs.c:3693
qfile_t * FS_FileFromData(const unsigned char *data, const size_t size, qbool quiet)
Definition fs.c:2951
qbool FS_IsRegisteredQuakePack(const char *name)
Definition fs.c:4112
int64_t fs_offset_t
Definition fs.h:37
GLuint buffer
Definition glquake.h:630
GLuint GLuint GLintptr offset
Definition glquake.h:632
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition glquake.h:657
const GLchar * name
Definition glquake.h:601
cvar_t developer
Definition host.c:48
host_static_t host
Definition host.c:41
cvar_t developer_extra
Definition host.c:49
void Host_Error(const char *error,...)
Definition host.c:85
cvar_t host_isclient
Definition host.c:61
int LHNETADDRESS_ToString(const lhnetaddress_t *vaddress, char *string, int stringbuffersize, int includeport)
Returns the number of bytes written to *string excluding the \0 terminator.
Definition lhnet.c:540
void Curl_SendRequirements(void)
Definition libcurl.c:1853
void Curl_ClearRequirements(void)
Definition libcurl.c:1795
void Curl_RequireFile(const char *filename)
Definition libcurl.c:1779
#define min(A, B)
Definition mathlib.h:37
#define VectorClear(a)
Definition mathlib.h:97
#define bound(min, num, max)
Definition mathlib.h:34
#define VectorCopy(in, out)
Definition mathlib.h:101
float strlen(string s)
float sqrt(float f)
void cmd(string command,...)
string argv(float n)
void Mod_ClearUsed(void)
model_t * Mod_ForName(const char *name, qbool crash, qbool checkdisk, const char *parentname)
void Mod_PurgeUnused(void)
static memexpandablearray_t models
model_t * Mod_FindName(const char *name, const char *parentname)
void Mod_FreeQ3Shaders(void)
void NetConn_Heartbeat(int priority)
Definition netconn.c:3984
cvar_t sv_public
Definition netconn.c:36
void NetConn_Close(netconn_t *conn)
Definition netconn.c:1240
void NetConn_ServerFrame(void)
Definition netconn.c:3861
void NetConn_OpenServerPorts(int opennetports)
Definition netconn.c:1168
void NetConn_CloseServerPorts(void)
Definition netconn.c:1121
int NetConn_SendUnreliableMessage(netconn_t *conn, sizebuf_t *data, protocolversion_t protocol, int rate, int burstsize, qbool quakesignon_suppressreliables)
Definition netconn.c:844
cvar_t hostname
Definition netconn.c:88
cvar_t sv_netport
Definition netconn.c:156
unsigned int func_t
Definition pr_comp.h:26
#define OFS_PARM0
Definition pr_comp.h:34
#define PROGHEADER_CRC_TENEBRAE
Definition progdefs.h:167
#define PROGHEADER_CRC
Definition progdefs.h:166
float parm6
Definition progsdefs.qc:45
float max_health
Definition progsdefs.qc:174
float parm1
Definition progsdefs.qc:45
string noise
Definition progsdefs.qc:209
float button2
Definition progsdefs.qc:156
float ammo_rockets
Definition progsdefs.qc:143
float ideal_yaw
Definition progsdefs.qc:184
float parm5
Definition progsdefs.qc:45
float frags
Definition progsdefs.qc:138
float serverflags
Definition progsdefs.qc:33
float parm4
Definition progsdefs.qc:45
string noise1
Definition progsdefs.qc:209
float killed_monsters
Definition progsdefs.qc:40
vector punchangle
Definition progsdefs.qc:117
float weapon
Definition progsdefs.qc:139
float ammo_shells
Definition progsdefs.qc:143
float team
Definition progsdefs.qc:172
float button0
Definition progsdefs.qc:154
float parm14
Definition progsdefs.qc:45
entity msg_entity
Definition progsdefs.qc:63
float parm11
Definition progsdefs.qc:45
float dmg_take
Definition progsdefs.qc:198
float total_secrets
Definition progsdefs.qc:36
vector v_angle
Definition progsdefs.qc:161
entity goalentity
Definition progsdefs.qc:189
float teleport_time
Definition progsdefs.qc:176
vector view_ofs
Definition progsdefs.qc:151
string targetname
Definition progsdefs.qc:194
float parm8
Definition progsdefs.qc:45
float yaw_speed
Definition progsdefs.qc:185
float health
Definition progsdefs.qc:137
float watertype
Definition progsdefs.qc:182
float waterlevel
Definition progsdefs.qc:181
float parm10
Definition progsdefs.qc:45
float force_retouch
Definition progsdefs.qc:19
float sounds
Definition progsdefs.qc:207
entity groundentity
Definition progsdefs.qc:134
float weaponframe
Definition progsdefs.qc:141
float items
Definition progsdefs.qc:145
float armorvalue
Definition progsdefs.qc:179
float parm2
Definition progsdefs.qc:45
float parm15
Definition progsdefs.qc:45
entity aiment
Definition progsdefs.qc:187
float fixangle
Definition progsdefs.qc:160
vector movedir
Definition progsdefs.qc:203
float total_monsters
Definition progsdefs.qc:37
float ammo_nails
Definition progsdefs.qc:143
float parm16
Definition progsdefs.qc:45
string noise3
Definition progsdefs.qc:209
float deadflag
Definition progsdefs.qc:149
float impulse
Definition progsdefs.qc:158
float currentammo
Definition progsdefs.qc:142
float parm9
Definition progsdefs.qc:45
float parm7
Definition progsdefs.qc:45
float spawnflags
Definition progsdefs.qc:191
string noise2
Definition progsdefs.qc:209
float parm12
Definition progsdefs.qc:45
float button1
Definition progsdefs.qc:155
float ammo_cells
Definition progsdefs.qc:143
float parm3
Definition progsdefs.qc:45
string weaponmodel
Definition progsdefs.qc:140
float dmg_save
Definition progsdefs.qc:199
string message
Definition progsdefs.qc:205
float parm13
Definition progsdefs.qc:45
float found_secrets
Definition progsdefs.qc:39
float armortype
Definition progsdefs.qc:178
float ltime
Definition progsdefs.qc:107
entity dmg_inflictor
Definition progsdefs.qc:200
string target
Definition progsdefs.qc:193
float takedamage
Definition progsdefs.qc:147
void PRVM_ED_LoadFromFile(prvm_prog_t *prog, const char *data)
#define PRVM_OP_STATE
Definition progsvm.h:238
#define PRVM_serveredictvector(ed, fieldname)
Definition progsvm.h:173
void PRVM_ED_ClearEdict(prvm_prog_t *prog, prvm_edict_t *e)
Definition prvm_edict.c:210
#define PRVM_serverglobaledict(fieldname)
Definition progsvm.h:180
void PRVM_Prog_Load(prvm_prog_t *prog, const char *filename, unsigned char *data, fs_offset_t size, void CheckRequiredFuncs(prvm_prog_t *prog, const char *filename), int numrequiredfields, prvm_required_field_t *required_field, int numrequiredglobals, prvm_required_field_t *required_global)
#define PRVM_ED_FindFieldOffset_FromStruct(st, field)
Definition progsvm.h:841
#define PRVM_EDICT_TO_PROG(e)
Definition progsvm.h:875
void PRVM_Prog_Init(prvm_prog_t *prog, struct cmd_state_s *cmd)
Initializing a vm: Call InitProg with the num Set up the fields marked with [INIT] in the prog struct...
int PRVM_SetEngineString(prvm_prog_t *prog, const char *s)
const char * vm_sv_extensions[]
client also uses this
Definition svvm_cmds.c:11
#define PRVM_EDICT_NUM(n)
Definition progsvm.h:867
prvm_builtin_t vm_sv_builtins[]
Definition svvm_cmds.c:3265
const char * PRVM_GetString(prvm_prog_t *prog, int num)
void PRVM_Prog_Reset(prvm_prog_t *prog)
void SVVM_ExecuteProgram(prvm_prog_t *prog, func_t fnum, const char *errormessage)
Definition prvm_exec.c:1183
#define PRVM_NUM_FOR_EDICT(e)
Definition progsvm.h:870
void SVVM_reset_cmd(prvm_prog_t *prog)
Definition svvm_cmds.c:3923
void VM_RemoveEdictSkeleton(prvm_prog_t *prog, prvm_edict_t *ed)
Definition prvm_cmds.c:261
void SVVM_init_cmd(prvm_prog_t *prog)
Definition svvm_cmds.c:3918
#define PRVM_serverglobalfloat(fieldname)
Definition progsvm.h:177
#define PRVM_serveredictfloat(ed, fieldname)
Definition progsvm.h:172
const int vm_sv_numbuiltins
Definition svvm_cmds.c:3916
#define PRVM_serverfunction(funcname)
Definition progsvm.h:182
#define PRVM_ED_FindGlobalOffset_FromStruct(st, field)
Definition progsvm.h:842
#define PRVM_serverglobalstring(fieldname)
Definition progsvm.h:179
#define PRVM_serveredictstring(ed, fieldname)
Definition progsvm.h:174
#define SVVM_prog
Definition progsvm.h:766
protocolversion_t Protocol_EnumForName(const char *s)
Definition protocol.c:68
int Protocol_NumberForEnum(protocolversion_t p)
Definition protocol.c:95
entity_state_t defaultstate
Definition protocol.c:4
void Protocol_Names(char *buffer, size_t buffersize)
Definition protocol.c:104
#define GAME_COOP
Definition protocol.h:203
#define svc_setview
Definition protocol.h:219
#define svc_print
Definition protocol.h:222
#define svc_disconnect
Definition protocol.h:216
#define svc_updatefrags
Definition protocol.h:233
#define GAME_DEATHMATCH
Definition protocol.h:204
void EntityFrame5_FreeDatabase(entityframe5_database_t *d)
Definition sv_ents5.c:29
#define svc_spawnbaseline2
Definition protocol.h:275
#define svc_stufftext
Definition protocol.h:223
#define svc_signonnum
Definition protocol.h:247
entityframe5_database_t * EntityFrame5_AllocDatabase(struct mempool_s *pool)
#define svc_serverinfo
Definition protocol.h:227
#define svc_precache
Definition protocol.h:274
#define svc_cdtrack
Definition protocol.h:259
#define svc_spawnbaseline
Definition protocol.h:242
#define svc_updatecolors
Definition protocol.h:236
#define svc_updatename
Definition protocol.h:232
int i
#define MAX_OSPATH
max length of a filesystem pathname
Definition qdefs.h:175
#define MAX_EDICTS
max number of objects in game world at once (32768 protocol limit)
Definition qdefs.h:105
#define NET_MAXMESSAGE
max reliable packet size (sent as multiple fragments of MAX_PACKETFRAGMENT)
Definition qdefs.h:103
#define MAX_SOUNDS
max number of sounds loaded at once
Definition qdefs.h:107
#define MAX_QPATH
max length of a quake game pathname
Definition qdefs.h:169
#define MAX_PARTICLEEFFECTNAME
maximum number of unique names of particle effects (for particleeffectnum)
Definition qdefs.h:135
#define MAX_SCOREBOARD
max number of players in game at once (255 protocol limit)
Definition qdefs.h:110
#define MAX_MODELS
max number of models loaded at once (including during level transitions)
Definition qdefs.h:106
#define NULL
Definition qtypes.h:12
bool qbool
Definition qtypes.h:9
float prvm_vec_t
Definition qtypes.h:55
int current_skill
skill level for currently loaded level (in case the user changes the cvar while the level is running,...
Definition sv_ccmds.c:27
void R_TimeReport(const char *desc)
Definition r_stats.c:193
#define SPAWNFLAG_NOT_EASY
Definition server.h:371
#define NUM_SPAWN_PARMS
Definition server.h:180
void SV_BroadcastPrintf(const char *fmt,...) DP_FUNC_PRINTF(1)
Definition sv_send.c:116
void VM_CustomStats_Clear(void)
Definition svvm_cmds.c:1717
#define SV_LockThreadMutex()
Definition server.h:606
void SV_InitOperatorCommands(void)
Definition sv_ccmds.c:1640
void SV_LinkEdict(prvm_edict_t *ent)
Definition sv_phys.c:804
@ ss_active
Definition server.h:52
@ ss_loading
Definition server.h:52
#define SV_UnlockThreadMutex()
Definition server.h:607
#define SPAWNFLAG_NOT_DEATHMATCH
Definition server.h:374
void SV_SendClientMessages(void)
Definition sv_send.c:1697
#define SPAWNFLAG_NOT_MEDIUM
Definition server.h:372
#define MOVETYPE_PUSH
no clip to world, push and crush
Definition server.h:319
#define MOVETYPE_STEP
gravity, special edge handling, special step based client side interpolation
Definition server.h:316
void SV_ClientCommands(const char *fmt,...) DP_FUNC_PRINTF(1)
Definition sv_send.c:135
#define SPAWNFLAG_NOT_HARD
Definition server.h:373
#define NUM_CSQCENTITYDB_FRAMES
Definition server.h:254
void SV_Physics(void)
Definition sv_phys.c:3013
#define SOLID_BSP
bsp clip, touch on edge, block
Definition server.h:336
void SV_ClientPrintf(const char *fmt,...) DP_FUNC_PRINTF(1)
Definition sv_send.c:72
void S_StopAllSounds(void)
Definition snd_main.c:1710
cactive_t state
Definition client.h:568
qbool active
false = empty client slot
Definition server.h:185
int colors
Definition server.h:236
signed char movement_count[NETGRAPH_PACKETS]
Definition server.h:213
qbool begun
false = don't send datagrams
Definition server.h:193
char download_name[MAX_QPATH]
Definition server.h:289
char weaponmodel[MAX_QPATH]
cache weaponmodel name lookups
Definition server.h:266
prvm_vec_t spawn_parms[NUM_SPAWN_PARMS]
spawn parms are carried from level to level
Definition server.h:232
entityframe_database_t * entitydatabase
Definition server.h:272
csqcentityframedb_t csqcentityframehistory[NUM_CSQCENTITYDB_FRAMES]
Definition server.h:255
unsigned int movesequence
Definition server.h:212
qbool clientconnectcalled
false = don't do ClientDisconnect on drop
Definition server.h:187
unsigned char csqcentityscope[MAX_EDICTS]
Definition server.h:251
int frags
Definition server.h:237
int csqcnumedicts
Definition server.h:250
int rate
requested rate in bytes per second
Definition server.h:198
int sendsignon
1 = send svc_serverinfo and advance to 2, 2 doesn't send, then advances to 0 (allowing unlimited send...
Definition server.h:195
entityframe5_database_t * entitydatabase5
Definition server.h:274
char old_name[MAX_SCOREBOARDNAME]
Definition server.h:235
qbool prespawned
false = don't allow spawn
Definition server.h:189
char name[MAX_SCOREBOARDNAME]
Definition server.h:235
unsigned int csqcentitysendflags[MAX_EDICTS]
Definition server.h:252
sizebuf_t unreliablemsg
Definition server.h:281
int weaponmodelindex
Definition server.h:267
entityframe4_database_t * entitydatabase4
Definition server.h:273
int latestframenum
latest received clc_ackframe (used to detect packet loss)
Definition server.h:263
int csqcentityframehistory_next
Definition server.h:256
int clientcamera
clientcamera (entity to use as camera)
Definition server.h:270
qfile_t * download_file
Definition server.h:286
netconn_t * netconnection
communications handle
Definition server.h:210
int download_expectedposition
next position the client should ack
Definition server.h:287
int stats[MAX_CL_STATS]
Definition server.h:278
unsigned char unreliablemsg_data[NET_MAXMESSAGE]
Definition server.h:280
qfile_t * sv_demo_file
demo recording
Definition server.h:297
qbool spawned
false = don't allow begin
Definition server.h:191
prvm_edict_t * edict
PRVM_EDICT_NUM(clientnum+1)
Definition server.h:221
double connecttime
realtime this client connected
Definition server.h:204
unsigned int movement_highestsequence_seen
Definition server.h:214
float ping
LadyHavoc: can be used for prediction or whatever...
Definition server.h:224
qbool download_deflate
Definition server.h:290
unsigned char statsdeltabits[(MAX_CL_STATS+7)/8]
Definition server.h:277
qbool download_started
Definition server.h:288
usercmd_t cmd
movement
Definition server.h:216
command interpreter state - the tokenizing and execution of commands, as well as pointers to which cv...
Definition cmd.h:127
char server_keyfp[FP64_SIZE+1]
Definition crypto.h:48
qbool server_issigned
Definition crypto.h:49
char client_idfp[FP64_SIZE+1]
Definition crypto.h:44
char client_keyfp[FP64_SIZE+1]
Definition crypto.h:45
qbool authenticated
Definition crypto.h:50
qbool client_issigned
Definition crypto.h:46
char server_idfp[FP64_SIZE+1]
Definition crypto.h:47
qbool use_aes
Definition crypto.h:51
Definition cvar.h:66
float value
Definition cvar.h:74
int integer
Definition cvar.h:73
const char * string
Definition cvar.h:71
double sleeptime
time spent sleeping after the last frame
Definition host.h:48
double dirtytime
the main loop wall time for this frame, equal to Sys_DirtyTime() at the start of this host frame
Definition host.h:47
void(* SV_Shutdown)(void)
Definition host.h:60
unsigned int framecount
incremented every frame, never reset, >0 means Host_AbortCurrentFrame() is possible
Definition host.h:45
double realtime
the accumulated mainloop time since application started (with filtering), without any slowmo or clamp...
Definition host.h:46
struct host_static_t::@12 hook
qbool paused
global paused state, pauses both client and server
Definition host.h:50
model_brush_t brush
void(* TraceBox)(struct model_s *model, const struct frameblend_s *frameblend, const struct skeleton_s *skeleton, struct trace_s *trace, const vec3_t start, const vec3_t boxmins, const vec3_t boxmaxs, const vec3_t end, int hitsupercontentsmask, int skipsupercontentsmask, int skipmaterialflagsmask)
qbool used
double timeout
Definition netconn.h:153
lhnetaddress_t peeraddress
Definition netconn.h:147
sizebuf_t message
writing buffer to send to peer as the next reliable message can be added to at any time,...
Definition netconn.h:161
char address[128]
Definition netconn.h:231
crypto_t crypto
Definition netconn.h:232
prvm_vec_t * fp
Definition progsvm.h:102
union prvm_edict_t::@30 fields
qbool free
true if this edict is unused
Definition progsvm.h:93
union prvm_edict_t::@29 priv
struct edict_engineprivate_s * server
FIXME: this server pointer really means world, not server (it is used by both server qc and client qc...
Definition progsvm.h:106
void(* reset_cmd)(struct prvm_prog_s *prog)
[INIT] used by PRVM_ResetProg
Definition progsvm.h:745
int numbuiltins
Definition progsvm.h:605
int entityfields
number of vec_t fields in progs (some variables are 3)
Definition progsvm.h:548
prvm_builtin_t * builtins
Definition progsvm.h:604
qbool loaded
used to indicate whether a prog is loaded
Definition progsvm.h:710
unsigned short filecrc
Definition progsvm.h:631
int edictprivate_size
size of the engine private struct
Definition progsvm.h:689
const char * name
name of the prog, e.g. "Server", "Client" or "Menu" (used for text output)
Definition progsvm.h:700
void(* begin_increase_edicts)(struct prvm_prog_s *prog)
[INIT] used by PRVM_MEM_Increase_Edicts
Definition progsvm.h:734
void(* free_edict)(struct prvm_prog_s *prog, prvm_edict_t *ed)
[INIT] used by PRVM_ED_Free
Definition progsvm.h:738
prvm_vec_t * fp
Definition progsvm.h:580
void(* error_cmd)(const char *format,...) DP_FUNC_PRINTF(1) DP_FUNC_NORETURN
[INIT]
Definition progsvm.h:747
int num_edicts
copies of some vars that were former read from sv
Definition progsvm.h:671
int progs_crc
Definition progsvm.h:553
void(* count_edicts)(struct prvm_prog_s *prog)
[INIT] used by PRVM_ED_Count_f
Definition progsvm.h:740
double inittime
system time when QC initialization code finished (any entity created before is not a leak)
Definition progsvm.h:539
qbool loadintoworld
Definition progsvm.h:707
int limit_edicts
used instead of the constant MAX_EDICTS
Definition progsvm.h:675
qbool allowworldwrites
allow writing to world entity fields, this is set by server init and cleared before first server fram...
Definition progsvm.h:697
unsigned flag
flag - used to store general flags like PRVM_GE_SELF, etc.
Definition progsvm.h:703
prvm_edict_t * edicts
Definition progsvm.h:680
void(* init_edict)(struct prvm_prog_s *prog, prvm_edict_t *edict)
[INIT] used by PRVM_ED_ClearEdict
Definition progsvm.h:737
mempool_t * progs_mempool
all memory allocations related to this vm_prog (code, edicts, strings)
Definition progsvm.h:602
int max_edicts
number of edicts for which space has been (should be) allocated
Definition progsvm.h:673
void(* ExecuteProgram)(struct prvm_prog_s *prog, func_t fnum, const char *errormessage)
pointer to one of the *VM_ExecuteProgram functions
Definition progsvm.h:749
qbool(* load_edict)(struct prvm_prog_s *prog, prvm_edict_t *ent)
[INIT] used by PRVM_ED_LoadFromFile
Definition progsvm.h:742
void(* init_cmd)(struct prvm_prog_s *prog)
[INIT] used by PRVM_InitProg
Definition progsvm.h:744
union prvm_prog_t::@31 globals
const char ** extensionstring
Definition progsvm.h:705
void(* end_increase_edicts)(struct prvm_prog_s *prog)
[INIT]
Definition progsvm.h:735
int reserved_edicts
number of reserved edicts (allocated from 1)
Definition progsvm.h:678
unsigned char * csqc_progdata_deflated
Definition server.h:41
void * threadmutex
Definition server.h:46
int maxclients_next
Definition server.h:28
struct client_s * clients
client slots
Definition server.h:30
unsigned char * csqc_progdata
Definition server.h:39
void * thread
Definition server.h:47
qbool threaded
Definition server.h:44
qbool changelevel_issued
cleared when at SV_SpawnServer
Definition server.h:34
qbool volatile threadstop
Definition server.h:45
int maxclients
number of svs.clients slots (updated by maxplayers command)
Definition server.h:28
int serverflags
episode completion information
Definition server.h:32
size_t csqc_progsize_deflated
Definition server.h:40
double pausedstart
Definition server.h:69
float perf_offset_sdev
Definition server.h:86
unsigned char reliable_datagram_buf[NET_MAXMESSAGE]
Definition server.h:131
double time
Definition server.h:76
float perf_acc_realtime
Definition server.h:88
char particleeffectname[MAX_PARTICLEEFFECTNAME][MAX_QPATH]
Definition server.h:144
char worldbasename[MAX_QPATH]
Definition server.h:109
double frametime
Definition server.h:77
qbool paused
Definition server.h:68
char sound_precache[MAX_SOUNDS][MAX_QPATH]
Definition server.h:121
world_t world
collision culling data
Definition server.h:106
float perf_acc_offset_max
Definition server.h:93
int perf_acc_offset_samples
Definition server.h:94
float perf_acc_lost
Definition server.h:90
qbool active
false if only a net client
Definition server.h:66
sizebuf_t signon
Definition server.h:133
char model_precache[MAX_MODELS][MAX_QPATH]
Definition server.h:116
sizebuf_t datagram
Definition server.h:126
unsigned char signon_buf[NET_MAXMESSAGE]
LadyHavoc: increased signon message buffer from 8192.
Definition server.h:135
int csqc_progsize
Definition server.h:102
char worldnamenoextension[MAX_QPATH]
Definition server.h:111
int csqc_progcrc
Definition server.h:101
server_state_t state
some actions are only valid during load
Definition server.h:124
sizebuf_t reliable_datagram
Definition server.h:130
float perf_lost
Definition server.h:83
unsigned int spawnframe
Definition server.h:79
qbool loadgame
handle connections specially
Definition server.h:71
float perf_acc_sleeptime
Definition server.h:89
char csqc_progname[MAX_QPATH]
Definition server.h:103
float perf_acc_offset_squared
Definition server.h:92
float perf_offset_avg
Definition server.h:84
float perf_cpuload
Definition server.h:82
float perf_acc_offset
Definition server.h:91
struct model_s * worldmodel
Definition server.h:112
qbool particleeffectnamesloaded
Definition server.h:143
unsigned char csqcentityversion[MAX_EDICTS]
legacy support for self.Version based csqc entity networking
Definition server.h:168
struct model_s * models[MAX_MODELS]
Definition server.h:117
float perf_offset_max
Definition server.h:85
unsigned char datagram_buf[NET_MAXMESSAGE]
Definition server.h:127
char worldname[MAX_QPATH]
Definition server.h:110
protocolversion_t protocol
one of the PROTOCOL_ values
Definition server.h:74
unsigned char * data
Definition common.h:52
int cursize
Definition common.h:54
qbool allowoverflow
if false, do a Sys_Error
Definition common.h:50
int maxsize
Definition common.h:53
int argc
Definition sys.h:146
const char ** argv
Definition sys.h:147
double time
Definition protocol.h:392
vec3_t maxs
Definition world.h:72
vec3_t mins
Definition world.h:71
void SV_StopDemoRecording(client_t *client)
Definition sv_demo.c:55
void SV_StartDemoRecording(client_t *client, const char *filename, int forcetrack)
Definition sv_demo.c:6
void SV_WriteDemoMessage(client_t *client, sizebuf_t *sendbuffer, qbool clienttoserver)
Definition sv_demo.c:32
cvar_t sv_autodemo_perclient_discardable
Definition sv_main.c:213
cvar_t sv_progs
Definition sv_main.c:146
cvar_t saved2
Definition sv_main.c:179
static void SV_AreaStats_f(cmd_state_t *cmd)
Definition sv_main.c:444
static void Host_Timescale_c(cvar_t *var)
Definition sv_main.c:436
cvar_t nehx11
Definition sv_main.c:200
cvar_t sv_cullentities_stats
Definition sv_main.c:83
void SV_StartThread(void)
Definition sv_main.c:2850
cvar_t sv_gameplayfix_swiminbmodels
Definition sv_main.c:126
static void SVVM_end_increase_edicts(prvm_prog_t *prog)
Definition sv_main.c:2170
cvar_t sv_waterfriction
Definition sv_main.c:157
server_t sv
local server
Definition sv_main.c:223
static void SVVM_init_edict(prvm_prog_t *prog, prvm_edict_t *e)
Definition sv_main.c:2181
cvar_t noexit
Definition sv_main.c:47
int SV_SoundIndex(const char *s, int precachemode)
Definition sv_main.c:1474
cvar_t sv_airaccel_qw
Definition sv_main.c:57
void SV_SaveSpawnparms(void)
Definition sv_main.c:1761
cvar_t sv_gameplayfix_nudgeoutofsolid_separation
Definition sv_main.c:118
cvar_t nehx05
Definition sv_main.c:194
cvar_t sv_rollangle
Definition sv_main.c:176
cvar_t sv_gameplayfix_delayprojectiles
Definition sv_main.c:106
cvar_t sv_gameplayfix_noairborncorpse_allowsuspendeditems
Definition sv_main.c:116
cvar_t sv_gameplayfix_droptofloorstartsolid_nudgetocorrect
Definition sv_main.c:108
cvar_t sv_allowdownloads_archive
Definition sv_main.c:70
cvar_t sv_gameplayfix_consistentplayerprethink
Definition sv_main.c:105
cvar_t host_framerate
Definition host.c:44
cvar_t nehx12
Definition sv_main.c:201
cvar_t deathmatch
Definition sv_main.c:44
cvar_t sv_maxairstrafespeed
Definition sv_main.c:64
cvar_t nehx00
Definition sv_main.c:189
cvar_t sv_areadebug
Definition sv_main.c:164
static void SV_VM_Shutdown(qbool prog_reset)
Definition sv_main.c:1788
cvar_t sv_random_seed
Definition sv_main.c:149
cvar_t scratch3
Definition sv_main.c:185
cvar_t coop
Definition sv_main.c:43
cvar_t nehx08
Definition sv_main.c:197
cvar_t pr_checkextension
Definition sv_main.c:50
static void SV_Prepare_CSQC(void)
Definition sv_main.c:1712
cvar_t sv_gameplayfix_easierwaterjump
Definition sv_main.c:109
cvar_t sv_airstopaccelerate
Definition sv_main.c:61
cvar_t sv_cullentities_trace_enlarge
Definition sv_main.c:87
cvar_t sv_maxairspeed
Definition sv_main.c:140
cvar_t saved4
Definition sv_main.c:181
cvar_t nehx16
Definition sv_main.c:205
cvar_t timelimit
Definition sv_main.c:173
cvar_t sv_debugmove
Definition sv_main.c:97
cvar_t gamecfg
Definition sv_main.c:46
cvar_t sv_clmovement_enable
Definition sv_main.c:77
cvar_t sv_areagrid_link_SOLID_NOT
Definition sv_main.c:74
cvar_t sv_gameplayfix_impactbeforeonground
Definition sv_main.c:113
static void SV_ServerOptions(void)
Definition sv_main.c:449
cvar_t sv_gameplayfix_unstickplayers
Definition sv_main.c:130
cvar_t nomonsters
Definition sv_main.c:48
cvar_t sv_sound_land
Definition sv_main.c:151
cvar_t net_connecttimeout
Definition netconn.c:82
static void SV_Download_f(cmd_state_t *cmd)
Definition sv_main.c:1209
cvar_t sv_cullentities_pvs
Definition sv_main.c:82
cvar_t sv_gameplayfix_nudgeoutofsolid
Definition sv_main.c:117
double SV_Frame(double time)
Definition sv_main.c:2527
cvar_t sv_lagreporting_strict
Definition sv_main.c:169
cvar_t sv_cullentities_trace_prediction
Definition sv_main.c:90
void SV_DropClient(qbool leaving, const char *fmt,...)
Definition sv_main.c:1018
cvar_t sv_freezenonclients
Definition sv_main.c:102
cvar_t sv_jumpvelocity
Definition sv_main.c:138
cvar_t sv_maxphysicsframesperserverframe
Definition sv_main.c:167
cvar_t sv_airspeedlimit_nonqw
Definition sv_main.c:62
cvar_t sv_airaccel_qw_stretchfactor
Definition sv_main.c:58
cvar_t sv_aircontrol
Definition sv_main.c:66
cvar_t sv_aim
Definition sv_main.c:56
cvar_t sv_warsowbunny_turnaccel
Definition sv_main.c:161
void SV_SpawnServer(const char *map)
Definition sv_main.c:1811
cvar_t sv_maxrate
Definition sv_main.c:141
cvar_t halflifebsp
Definition sv_main.c:215
int SV_ModelIndex(const char *s, int precachemode)
Definition sv_main.c:1411
cvar_t sv_gameplayfix_nogravityonground
Definition sv_main.c:120
cvar_t sv_wateraccelerate
Definition sv_main.c:156
cvar_t sv_init_frame_count
Definition sv_main.c:135
model_t * SV_GetModelByIndex(int modelindex)
Definition sv_main.c:1607
cvar_t sv_gameplayfix_findradiusdistancetobox
Definition sv_main.c:110
cvar_t sv_mapformat_is_quake2
Definition sv_main.c:216
cvar_t nehx13
Definition sv_main.c:202
cvar_t sv_jumpstep
Definition sv_main.c:137
mempool_t * sv_mempool
Definition sv_main.c:226
cvar_t sv_sendentities_csqc_randomize_order
Definition sv_main.c:221
static void SVVM_free_edict(prvm_prog_t *prog, prvm_edict_t *ed)
Definition sv_main.c:2234
cvar_t sv_aircontrol_penalty
Definition sv_main.c:68
cvar_t sv_wallfriction
Definition sv_main.c:155
cvar_t sv_threaded
Definition sv_main.c:170
cvar_t sv_cullentities_trace_expand
Definition sv_main.c:88
void SV_SendServerinfo(client_t *client)
Definition sv_main.c:749
cvar_t sv_cullentities_trace_eyejitter
Definition sv_main.c:89
cvar_t sv_allowdownloads_dlcache
Definition sv_main.c:72
cvar_t sv_cullentities_nevercullbmodels
Definition sv_main.c:81
cvar_t sv_legacy_bbox_expand
Definition sv_main.c:139
prvm_required_field_t sv_reqfields[]
Definition sv_main.c:280
cvar_t savedgamecfg
Definition sv_main.c:182
cvar_t sys_ticrate
Definition sv_main.c:166
#define SV_REQGLOBALS
Definition sv_main.c:357
cvar_t sv_maxspeed
Definition sv_main.c:142
cvar_t nehx02
Definition sv_main.c:191
cvar_t sv_sound_watersplash
Definition sv_main.c:152
cvar_t sv_worldmessage
Definition sv_main.c:37
const char * SV_TimingReport(char *buf, size_t buflen)
for output in SV_Status_f
Definition sv_main.c:2521
cvar_t nehx01
Definition sv_main.c:190
static void SV_VM_Setup(void)
Definition sv_main.c:2314
cvar_t sv_gameplayfix_noairborncorpse
Definition sv_main.c:115
cvar_t sv_airstrafeaccelerate
Definition sv_main.c:63
cvar_t sv_nostep
Definition sv_main.c:144
cvar_t sv_gameplayfix_nosquashentities
Definition sv_main.c:133
cvar_t sv_gameplayfix_gravityunaffectedbyticrate
Definition sv_main.c:111
cvar_t sv_autodemo_perclient_nameformat
Definition sv_main.c:212
cvar_t sv_gameplayfix_q2airaccelerate
Definition sv_main.c:119
cvar_t sv_aircontrol_power
Definition sv_main.c:67
static const char * standardeffectnames[EFFECT_TOTAL]
Definition sv_main.c:232
cvar_t sv_qcstats
Definition sv_main.c:148
#define SV_REQFIELDS
Definition sv_main.c:278
cvar_t sv_warsowbunny_airforwardaccel
Definition sv_main.c:158
static void SV_CreateBaseline(void)
Definition sv_main.c:1628
cvar_t sv_areagrid_mingridsize
Definition sv_main.c:75
cvar_t sv_gameplayfix_fixedcheckwatertransition
Definition sv_main.c:132
cvar_t sv_idealpitchscale
Definition sv_main.c:136
void SV_StopThread(void)
Definition sv_main.c:2860
cvar_t nehx07
Definition sv_main.c:196
cvar_t sv_rollspeed
Definition sv_main.c:175
cvar_t scratch4
Definition sv_main.c:186
cvar_t nehx04
Definition sv_main.c:193
cvar_t nehx19
Definition sv_main.c:208
cvar_t sv_gameplayfix_slidemoveprojectiles
Definition sv_main.c:122
int SV_IsLocalServer(void)
Definition sv_main.c:1783
cvar_t temp1
Definition sv_main.c:187
cvar_t pausable
Definition sv_main.c:49
cvar_t nehx17
Definition sv_main.c:206
cvar_t sv_airstrafeaccel_qw
Definition sv_main.c:65
cvar_t sv_edgefriction
Definition sv_main.c:100
cvar_t sv_gameplayfix_upwardvelocityclearsongroundflag
Definition sv_main.c:127
model_t * SV_GetModelFromEdict(prvm_edict_t *ed)
Definition sv_main.c:1612
cvar_t sv_stepheight
Definition sv_main.c:153
static qbool SVVM_load_edict(prvm_prog_t *prog, prvm_edict_t *ent)
Definition sv_main.c:2292
cvar_t sv_disablenotify
Definition sv_main.c:42
server_static_t svs
persistant server info
Definition sv_main.c:224
cvar_t host_limitlocal
Definition sv_main.c:150
cvar_t fraglimit
Definition sv_main.c:45
cvar_t sv_writepicture_quality
Definition sv_main.c:219
cvar_t nehx10
Definition sv_main.c:199
cvar_t sv_cullentities_trace_samples
Definition sv_main.c:93
cvar_t sv_worldname
Definition sv_main.c:38
cvar_t sv_gravity
Definition sv_main.c:134
static void SV_CheckTimeouts(void)
Definition sv_main.c:2504
cvar_t nehx18
Definition sv_main.c:207
cvar_t sv_gameplayfix_unstickentities
Definition sv_main.c:131
cvar_t sv_cullentities_trace
Definition sv_main.c:84
cvar_t sv_maxvelocity
Definition sv_main.c:143
cvar_t sv_entpatch
Definition sv_main.c:101
prvm_required_field_t sv_reqglobals[]
Definition sv_main.c:359
static void SVVM_begin_increase_edicts(prvm_prog_t *prog)
Definition sv_main.c:2164
cvar_t host_timescale
Definition sv_main.c:53
static void SVVM_count_edicts(prvm_prog_t *prog)
Definition sv_main.c:2264
cvar_t sv_dedicated
Definition sv_main.c:98
cvar_t sv_gameplayfix_droptofloorstartsolid
Definition sv_main.c:107
cvar_t sv_clmovement_inputtimeout
Definition sv_main.c:80
static int SV_ThreadFunc(void *voiddata)
Definition sv_main.c:2716
cvar_t sv_friction
Definition sv_main.c:103
cvar_t sv_worldnamenoextension
Definition sv_main.c:39
cvar_t sv_cullentities_trace_samples_extra
Definition sv_main.c:94
cvar_t cutscene
Definition sv_main.c:209
cvar_t scratch2
Definition sv_main.c:184
cvar_t samelevel
Definition sv_main.c:51
cvar_t scratch1
Definition sv_main.c:183
cvar_t sv_allowdownloads_config
Definition sv_main.c:71
cvar_t nehx09
Definition sv_main.c:198
static void SV_SaveEntFile_f(cmd_state_t *cmd)
Definition sv_main.c:722
cvar_t sv_checkforpacketsduringsleep
Definition sv_main.c:76
cvar_t nehx06
Definition sv_main.c:195
cvar_t sv_clmovement_minping
Definition sv_main.c:78
static void Download_CheckExtensions(cmd_state_t *cmd)
Definition sv_main.c:1191
cvar_t sv_protocolname
Definition sv_main.c:147
cvar_t sv_allowdownloads_inarchive
Definition sv_main.c:73
cvar_t sv_mapformat_is_quake3
Definition sv_main.c:217
cvar_t nehx14
Definition sv_main.c:203
void SV_Init(void)
Definition sv_main.c:504
cvar_t sv_gameplayfix_downtracesupportsongroundflag
Definition sv_main.c:128
cvar_t sv_lagreporting_always
Definition sv_main.c:168
int SV_ParticleEffectIndex(const char *name)
Definition sv_main.c:1522
void SV_Shutdown(void)
Definition sv_main.c:2128
cvar_t sv_gameplayfix_q1bsptracelinereportstexture
Definition sv_main.c:129
cvar_t sv_stopspeed
Definition sv_main.c:154
cvar_t sv_warsowbunny_accel
Definition sv_main.c:159
cvar_t sv_clmovement_minping_disabletime
Definition sv_main.c:79
cvar_t sv_worldbasename
Definition sv_main.c:40
cvar_t sv_airaccel_sideways_friction
Definition sv_main.c:59
cvar_t sv_cullentities_trace_entityocclusion
Definition sv_main.c:92
cvar_t sv_gameplayfix_nostepmoveonsteepslopes
Definition sv_main.c:125
cvar_t skill
Definition sv_main.c:52
client_t * host_client
Definition sv_main.c:29
cvar_t sv_airaccelerate
Definition sv_main.c:60
void SV_ConnectClient(int clientnum, netconn_t *netconnection)
Definition sv_main.c:936
cvar_t nehx03
Definition sv_main.c:192
cvar_t sv_warsowbunny_backtosideratio
Definition sv_main.c:162
cvar_t sv_accelerate
Definition sv_main.c:55
cvar_t sv_gameplayfix_stepmultipletimes
Definition sv_main.c:124
cvar_t sv_autodemo_perclient
Definition sv_main.c:211
cvar_t sv_allowdownloads
Definition sv_main.c:69
cvar_t saved1
Definition sv_main.c:178
static void SV_StartDownload_f(cmd_state_t *cmd)
Definition sv_main.c:1160
cvar_t sv_cullentities_trace_delay
Definition sv_main.c:85
cvar_t sv_playerphysicsqc
Definition sv_main.c:145
cvar_t sv_cullentities_trace_delay_players
Definition sv_main.c:86
cvar_t sv_cullentities_trace_samples_players
Definition sv_main.c:95
float scr_centertime_off
Definition cl_screen.c:129
cvar_t sv_cullentities_trace_prediction_time
Definition sv_main.c:91
cvar_t sv_cullentities_trace_spectators
Definition sv_main.c:96
cvar_t sv_onlycsqcnetworking
Definition sv_main.c:163
cvar_t sv_warsowbunny_topspeed
Definition sv_main.c:160
cvar_t sv_gameplayfix_blowupfallenzombies
Definition sv_main.c:104
cvar_t teamplay
Definition sv_main.c:172
cvar_t sv_gameplayfix_grenadebouncedownslopes
Definition sv_main.c:112
cvar_t sv_gameplayfix_setmodelrealbox
Definition sv_main.c:121
cvar_t saved3
Definition sv_main.c:180
cvar_t sv_echobprint
Definition sv_main.c:99
cvar_t sv_gameplayfix_stepdown
Definition sv_main.c:123
cvar_t sv_gameplayfix_multiplethinksperframe
Definition sv_main.c:114
cvar_t nehx15
Definition sv_main.c:204
static void SV_CheckRequiredFuncs(prvm_prog_t *prog, const char *filename)
Definition sv_main.c:273
size_t Sys_TimeString(char buf[], size_t bufsize, const char *timeformat)
Definition sys_shared.c:45
void Sys_MakeProcessNice(void)
Definition sys_shared.c:958
double Sys_DirtyTime(void)
Definition sys_shared.c:417
void Sys_MakeProcessMean(void)
Definition sys_shared.c:961
double Sys_Sleep(double time)
called to yield for a little bit so as not to hog cpu when paused or debugging
Definition sys_shared.c:500
sys_t sys
Definition sys_shared.c:42
int Sys_CheckParm(const char *parm)
Definition sys_shared.c:327
#define Thread_DestroyMutex(m)
Definition thread.h:16
qbool Thread_HasThreads(void)
Definition thread_null.c:13
#define Thread_CreateMutex()
Definition thread.h:15
#define Thread_WaitThread(thread, retval)
Definition thread.h:25
#define Thread_CreateThread(fn, data)
Definition thread.h:24
int cl_available
Definition vid_null.c:24
void World_PrintAreaStats(world_t *world, const char *worldname)
Definition world.c:104
void World_SetSize(world_t *world, const char *filename, const vec3_t mins, const vec3_t maxs, prvm_prog_t *prog)
Definition world.c:118
void World_UnlinkAll(world_t *world)
unlinks all entities (used before reallocation of edicts)
Definition world.c:159
void World_UnlinkEdict(prvm_edict_t *ent)
Definition world.c:178
void World_Start(world_t *world)
Definition world.c:59
void World_Physics_RemoveJointFromEntity(world_t *world, struct prvm_edict_s *ed)
void World_Physics_RemoveFromEntity(world_t *world, struct prvm_edict_s *ed)
mempool_t * tempmempool
Definition zone.c:794
#define Mem_Free(mem)
Definition zone.h:96
#define Mem_Alloc(pool, size)
Definition zone.h:92
#define Mem_AllocPool(name, flags, parent)
Definition zone.h:104