]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - sv_main.c
use dynamic eye position-centered bouncegrid when rendering in dynamic
[xonotic/darkplaces.git] / sv_main.c
index f25c85bddd2397a4978c68b6c927014da5cd1d70..a73bb657e0ab3c4974241b0b704bd0623eca1f73 100644 (file)
--- a/sv_main.c
+++ b/sv_main.c
@@ -33,6 +33,11 @@ extern cvar_t net_connecttimeout;
 void VM_CustomStats_Clear (void);
 void VM_SV_UpdateCustomStats (client_t *client, prvm_edict_t *ent, sizebuf_t *msg, int *stats);
 
+cvar_t sv_worldmessage = {CVAR_READONLY, "sv_worldmessage", "", "title of current level"};
+cvar_t sv_worldname = {CVAR_READONLY, "sv_worldname", "", "name of current worldmodel"};
+cvar_t sv_worldnamenoextension = {CVAR_READONLY, "sv_worldnamenoextension", "", "name of current worldmodel without extension"};
+cvar_t sv_worldbasename = {CVAR_READONLY, "sv_worldbasename", "", "name of current worldmodel without maps/ prefix or extension"};
+
 cvar_t coop = {0, "coop","0", "coop mode, 0 = no coop, 1 = coop mode, multiple players playing through the singleplayer game (coop mode also shuts off deathmatch)"};
 cvar_t deathmatch = {0, "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)"};
 cvar_t fraglimit = {CVAR_NOTIFY, "fraglimit","0", "ends level if this many frags is reached by any player"};
@@ -47,19 +52,23 @@ cvar_t slowmo = {0, "slowmo", "1.0", "controls game speed, 0.5 is half speed, 2
 
 cvar_t sv_accelerate = {0, "sv_accelerate", "10", "rate at which a player accelerates to sv_maxspeed"};
 cvar_t sv_aim = {CVAR_SAVE, "sv_aim", "2", "maximum cosine angle for quake's vertical autoaim, a value above 1 completely disables the autoaim, quake used 0.93"};
-cvar_t sv_airaccel_qw = {0, "sv_airaccel_qw", "1", "ratio of QW-style air control as opposed to simple acceleration"};
-cvar_t sv_airaccel_sideways_friction = {0, "sv_airaccel_sideways_friction", "", "anti-sideways movement stabilization (reduces speed gain when zigzagging)"};
+cvar_t sv_airaccel_qw = {0, "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"};
+cvar_t sv_airaccel_sideways_friction = {0, "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"};
 cvar_t sv_airaccelerate = {0, "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"};
 cvar_t sv_airstopaccelerate = {0, "sv_airstopaccelerate", "0", "when set, replacement for sv_airaccelerate when moving backwards"};
+cvar_t sv_airspeedlimit_nonqw = {0, "sv_airspeedlimit_nonqw", "0", "when set, this is a soft speed limit while in air when using airaccel_qw not equal to 1"};
 cvar_t sv_airstrafeaccelerate = {0, "sv_airstrafeaccelerate", "0", "when set, replacement for sv_airaccelerate when just strafing"};
 cvar_t sv_maxairstrafespeed = {0, "sv_maxairstrafespeed", "0", "when set, replacement for sv_maxairspeed when just strafing"};
+cvar_t sv_airstrafeaccel_qw = {0, "sv_airstrafeaccel_qw", "0", "when set, replacement for sv_airaccel_qw when just strafing"};
 cvar_t sv_aircontrol = {0, "sv_aircontrol", "0", "CPMA-style air control"};
+cvar_t sv_aircontrol_power = {0, "sv_aircontrol_power", "2", "CPMA-style air control exponent"};
+cvar_t sv_aircontrol_penalty = {0, "sv_aircontrol_penalty", "0", "deceleration while using CPMA-style air control"};
 cvar_t sv_allowdownloads = {0, "sv_allowdownloads", "1", "whether to allow clients to download files from the server (does not affect http downloads)"};
 cvar_t sv_allowdownloads_archive = {0, "sv_allowdownloads_archive", "0", "whether to allow downloads of archives (pak/pk3)"};
 cvar_t sv_allowdownloads_config = {0, "sv_allowdownloads_config", "0", "whether to allow downloads of config files (cfg)"};
 cvar_t sv_allowdownloads_dlcache = {0, "sv_allowdownloads_dlcache", "0", "whether to allow downloads of dlcache files (dlcache/)"};
 cvar_t sv_allowdownloads_inarchive = {0, "sv_allowdownloads_inarchive", "0", "whether to allow downloads from archives (pak/pk3)"};
-cvar_t sv_areagrid_mingridsize = {CVAR_NOTIFY, "sv_areagrid_mingridsize", "64", "minimum areagrid cell size, smaller values work better for lots of small objects, higher values for large objects"};
+cvar_t sv_areagrid_mingridsize = {CVAR_NOTIFY, "sv_areagrid_mingridsize", "128", "minimum areagrid cell size, smaller values work better for lots of small objects, higher values for large objects"};
 cvar_t sv_checkforpacketsduringsleep = {0, "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"};
 cvar_t sv_clmovement_enable = {0, "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"};
 cvar_t sv_clmovement_minping = {0, "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)"};
@@ -86,7 +95,7 @@ cvar_t sv_fixedframeratesingleplayer = {0, "sv_fixedframeratesingleplayer", "1",
 cvar_t sv_freezenonclients = {CVAR_NOTIFY, "sv_freezenonclients", "0", "freezes time, except for players, allowing you to walk around and take screenshots of explosions"};
 cvar_t sv_friction = {CVAR_NOTIFY, "sv_friction","4", "how fast you slow down"};
 cvar_t sv_gameplayfix_blowupfallenzombies = {0, "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"};
-cvar_t sv_gameplayfix_consistentplayerprethink = {0, "sv_gameplayfix_consistentplayerprethink", "1", "improves fairness in multiplayer by running all PlayerPreThink functions (which fire weapons) before performing physics, then runing all PlayerPostThink functions"};
+cvar_t sv_gameplayfix_consistentplayerprethink = {0, "sv_gameplayfix_consistentplayerprethink", "0", "improves fairness in multiplayer by running all PlayerPreThink functions (which fire weapons) before performing physics, then running all PlayerPostThink functions"};
 cvar_t sv_gameplayfix_delayprojectiles = {0, "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"};
 cvar_t sv_gameplayfix_droptofloorstartsolid = {0, "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)"};
 cvar_t sv_gameplayfix_droptofloorstartsolid_nudgetocorrect = {0, "sv_gameplayfix_droptofloorstartsolid_nudgetocorrect", "1", "tries to nudge stuck items and monsters out of walls before droptofloor is performed"};
@@ -100,10 +109,13 @@ cvar_t sv_gameplayfix_noairborncorpse_allowsuspendeditems = {0, "sv_gameplayfix_
 cvar_t sv_gameplayfix_nudgeoutofsolid = {0, "sv_gameplayfix_nudgeoutofsolid", "1", "attempts to fix physics errors (where an object ended up in solid for some reason)"};
 cvar_t sv_gameplayfix_nudgeoutofsolid_bias = {0, "sv_gameplayfix_nudgeoutofsolid_bias", "0", "over-correction on nudgeoutofsolid logic, to prevent constant contact"};
 cvar_t sv_gameplayfix_q2airaccelerate = {0, "sv_gameplayfix_q2airaccelerate", "0", "Quake2-style air acceleration"};
+cvar_t sv_gameplayfix_nogravityonground = {0, "sv_gameplayfix_nogravityonground", "0", "turn off gravity when on ground (to get rid of sliding)"};
 cvar_t sv_gameplayfix_setmodelrealbox = {0, "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"};
 cvar_t sv_gameplayfix_slidemoveprojectiles = {0, "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"};
 cvar_t sv_gameplayfix_stepdown = {0, "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)"};
 cvar_t sv_gameplayfix_stepwhilejumping = {0, "sv_gameplayfix_stepwhilejumping", "1", "applies step-up onto a ledge even while airborn, useful if you would otherwise just-miss the floor when running across small areas with gaps (for instance running across the moving platforms in dm2, or jumping to the megahealth and red armor in dm2 rather than using the bridge)"};
+cvar_t sv_gameplayfix_stepmultipletimes = {0, "sv_gameplayfix_stepmultipletimes", "0", "applies step-up onto a ledge more than once in a single frame, when running quickly up stairs"};
+cvar_t sv_gameplayfix_nostepmoveonsteepslopes = {0, "sv_gameplayfix_nostepmoveonsteepslopes", "0", "grude fix which prevents MOVETYPE_STEP (not swimming or flying) to move on slopes whose angle is bigger than 45 degree"};
 cvar_t sv_gameplayfix_swiminbmodels = {0, "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"};
 cvar_t sv_gameplayfix_upwardvelocityclearsongroundflag = {0, "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"};
 cvar_t sv_gameplayfix_downtracesupportsongroundflag = {0, "sv_gameplayfix_downtracesupportsongroundflag", "1", "prevents very short moves from clearing onground (which may make the player stick to the floor at high netfps)"};
@@ -115,7 +127,6 @@ cvar_t sv_maxairspeed = {0, "sv_maxairspeed", "30", "maximum speed a player can
 cvar_t sv_maxrate = {CVAR_SAVE | CVAR_NOTIFY, "sv_maxrate", "1000000", "upper limit on client rate cvar, should reflect your network connection quality"};
 cvar_t sv_maxspeed = {CVAR_NOTIFY, "sv_maxspeed", "320", "maximum speed a player can accelerate to when on ground (can be exceeded by tricks)"};
 cvar_t sv_maxvelocity = {CVAR_NOTIFY, "sv_maxvelocity","2000", "universal speed limit on all entities"};
-cvar_t sv_newflymove = {CVAR_NOTIFY, "sv_newflymove", "0", "enables simpler/buggier player physics (not recommended)"};
 cvar_t sv_nostep = {CVAR_NOTIFY, "sv_nostep","0", "prevents MOVETYPE_STEP entities (monsters) from moving"};
 cvar_t sv_playerphysicsqc = {CVAR_NOTIFY, "sv_playerphysicsqc", "1", "enables QuakeC function to override player physics"};
 cvar_t sv_progs = {0, "sv_progs", "progs.dat", "selects which quakec progs.dat file to run" };
@@ -174,6 +185,7 @@ cvar_t cutscene = {0, "cutscene", "1", "enables cutscenes in nehahra, can be use
 
 cvar_t sv_autodemo_perclient = {CVAR_SAVE, "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)"};
 cvar_t sv_autodemo_perclient_nameformat = {CVAR_SAVE, "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)" };
+cvar_t sv_autodemo_perclient_discardable = {CVAR_SAVE, "sv_autodemo_perclient_discardable", "0", "Allow game code to decide whether a demo should be kept or discarded."};
 
 cvar_t halflifebsp = {0, "halflifebsp", "0", "indicates the current map is hlbsp format (useful to know because of different bounding box sizes)"};
 
@@ -337,6 +349,12 @@ void SV_Init (void)
        extern cvar_t csqc_progname;    //[515]: csqc crc check and right csprogs name according to progs.dat
        extern cvar_t csqc_progcrc;
        extern cvar_t csqc_progsize;
+
+       Cvar_RegisterVariable(&sv_worldmessage);
+       Cvar_RegisterVariable(&sv_worldname);
+       Cvar_RegisterVariable(&sv_worldnamenoextension);
+       Cvar_RegisterVariable(&sv_worldbasename);
+
        Cvar_RegisterVariable (&csqc_progname);
        Cvar_RegisterVariable (&csqc_progcrc);
        Cvar_RegisterVariable (&csqc_progsize);
@@ -365,7 +383,11 @@ void SV_Init (void)
        Cvar_RegisterVariable (&sv_airstopaccelerate);
        Cvar_RegisterVariable (&sv_airstrafeaccelerate);
        Cvar_RegisterVariable (&sv_maxairstrafespeed);
+       Cvar_RegisterVariable (&sv_airstrafeaccel_qw);
+       Cvar_RegisterVariable (&sv_airspeedlimit_nonqw);
        Cvar_RegisterVariable (&sv_aircontrol);
+       Cvar_RegisterVariable (&sv_aircontrol_power);
+       Cvar_RegisterVariable (&sv_aircontrol_penalty);
        Cvar_RegisterVariable (&sv_allowdownloads);
        Cvar_RegisterVariable (&sv_allowdownloads_archive);
        Cvar_RegisterVariable (&sv_allowdownloads_config);
@@ -412,10 +434,13 @@ void SV_Init (void)
        Cvar_RegisterVariable (&sv_gameplayfix_nudgeoutofsolid);
        Cvar_RegisterVariable (&sv_gameplayfix_nudgeoutofsolid_bias);
        Cvar_RegisterVariable (&sv_gameplayfix_q2airaccelerate);
+       Cvar_RegisterVariable (&sv_gameplayfix_nogravityonground);
        Cvar_RegisterVariable (&sv_gameplayfix_setmodelrealbox);
        Cvar_RegisterVariable (&sv_gameplayfix_slidemoveprojectiles);
        Cvar_RegisterVariable (&sv_gameplayfix_stepdown);
        Cvar_RegisterVariable (&sv_gameplayfix_stepwhilejumping);
+       Cvar_RegisterVariable (&sv_gameplayfix_stepmultipletimes);
+       Cvar_RegisterVariable (&sv_gameplayfix_nostepmoveonsteepslopes);
        Cvar_RegisterVariable (&sv_gameplayfix_swiminbmodels);
        Cvar_RegisterVariable (&sv_gameplayfix_upwardvelocityclearsongroundflag);
        Cvar_RegisterVariable (&sv_gameplayfix_downtracesupportsongroundflag);
@@ -427,7 +452,6 @@ void SV_Init (void)
        Cvar_RegisterVariable (&sv_maxrate);
        Cvar_RegisterVariable (&sv_maxspeed);
        Cvar_RegisterVariable (&sv_maxvelocity);
-       Cvar_RegisterVariable (&sv_newflymove);
        Cvar_RegisterVariable (&sv_nostep);
        Cvar_RegisterVariable (&sv_playerphysicsqc);
        Cvar_RegisterVariable (&sv_progs);
@@ -490,6 +514,7 @@ void SV_Init (void)
 
        Cvar_RegisterVariable (&sv_autodemo_perclient);
        Cvar_RegisterVariable (&sv_autodemo_perclient_nameformat);
+       Cvar_RegisterVariable (&sv_autodemo_perclient_discardable);
 
        Cvar_RegisterVariable (&halflifebsp);
 
@@ -507,8 +532,8 @@ void SV_Init (void)
                Cvar_SetValueQuick (&sv_gameplayfix_blowupfallenzombies, 0);
                // hipnotic mission pack has issues with bobbing water entities 'jittering' between different heights on alternate frames at the default 0.0138889 ticrate, 0.02 avoids this issue
                Cvar_SetValueQuick (&sys_ticrate, 0.02);
-               // hipnotic mission pack has issues in their proximity mine sticking code, which causes them to bounce off.                                                                                     
-               Cvar_SetValueQuick (&sv_gameplayfix_slidemoveprojectiles, 0);                                                                                                                                   
+               // hipnotic mission pack has issues in their proximity mine sticking code, which causes them to bounce off.
+               Cvar_SetValueQuick (&sv_gameplayfix_slidemoveprojectiles, 0);
        }
        if (gamemode == GAME_ROGUE)
        {
@@ -517,8 +542,8 @@ void SV_Init (void)
        }
        if (gamemode == GAME_NEXUIZ)
        {
-               // rogue mission pack has a guardian boss that does not wake up if findradius returns one of the entities around its spawn area
                Cvar_SetValueQuick (&sv_gameplayfix_q2airaccelerate, 1);
+               Cvar_SetValueQuick (&sv_gameplayfix_stepmultipletimes, 1);
        }
 
        sv_mempool = Mem_AllocPool("server", 0, NULL);
@@ -526,14 +551,12 @@ void SV_Init (void)
 
 static void SV_SaveEntFile_f(void)
 {
-       char basename[MAX_QPATH];
        if (!sv.active || !sv.worldmodel)
        {
                Con_Print("Not running a server\n");
                return;
        }
-       FS_StripExtension(sv.worldmodel->name, basename, sizeof(basename));
-       FS_WriteFile(va("%s.ent", basename), sv.worldmodel->brush.entities, (fs_offset_t)strlen(sv.worldmodel->brush.entities));
+       FS_WriteFile(va("%s.ent", sv.worldnamenoextension), sv.worldmodel->brush.entities, (fs_offset_t)strlen(sv.worldmodel->brush.entities));
 }
 
 
@@ -823,27 +846,22 @@ void SV_SendServerinfo (client_t *client)
 
        SZ_Clear (&client->netconnection->message);
        MSG_WriteByte (&client->netconnection->message, svc_print);
-       dpsnprintf (message, sizeof (message), "\nServer: %s build %s (progs %i crc)", gamename, buildstring, prog->filecrc);
+       dpsnprintf (message, sizeof (message), "\nServer: %s build %s (progs %i crc)\n", gamename, buildstring, prog->filecrc);
        MSG_WriteString (&client->netconnection->message,message);
 
        SV_StopDemoRecording(client); // to split up demos into different files
        if(sv_autodemo_perclient.integer && client->netconnection)
        {
                char demofile[MAX_OSPATH];
-               char levelname[MAX_QPATH];
                char ipaddress[MAX_QPATH];
                size_t i;
 
                // start a new demo file
-               strlcpy(levelname, FS_FileWithoutPath(sv.worldmodel->name), sizeof(levelname));
-               if (strrchr(levelname, '.'))
-                       *(strrchr(levelname, '.')) = 0;
-
                LHNETADDRESS_ToString(&(client->netconnection->peeraddress), ipaddress, sizeof(ipaddress), true);
                for(i = 0; ipaddress[i]; ++i)
                        if(!isalnum(ipaddress[i]))
                                ipaddress[i] = '-';
-               dpsnprintf (demofile, sizeof(demofile), "%s_%s_%d_%s.dem", Sys_TimeString (sv_autodemo_perclient_nameformat.string), levelname, PRVM_NUM_FOR_EDICT(client->edict), ipaddress);
+               dpsnprintf (demofile, sizeof(demofile), "%s_%s_%d_%s.dem", Sys_TimeString (sv_autodemo_perclient_nameformat.string), sv.worldbasename, PRVM_NUM_FOR_EDICT(client->edict), ipaddress);
 
                SV_StartDemoRecording(client, demofile, -1);
        }
@@ -863,7 +881,7 @@ void SV_SendServerinfo (client_t *client)
                if(client->sv_demo_file != NULL)
                {
                        int i;
-                       char buf[NET_MAXMESSAGE];
+                       static char buf[NET_MAXMESSAGE];
                        sizebuf_t sb;
 
                        sb.data = (unsigned char *) buf;
@@ -963,19 +981,36 @@ void SV_ConnectClient (int clientnum, netconn_t *netconnection)
 {
        client_t                *client;
        int                             i;
-       float                   spawn_parms[NUM_SPAWN_PARMS];
 
        client = svs.clients + clientnum;
 
 // set up the client_t
        if (sv.loadgame)
-               memcpy (spawn_parms, client->spawn_parms, sizeof(spawn_parms));
-       memset (client, 0, sizeof(*client));
+       {
+               float backupparms[NUM_SPAWN_PARMS];
+               memcpy(backupparms, client->spawn_parms, sizeof(backupparms));
+               memset(client, 0, sizeof(*client));
+               memcpy(client->spawn_parms, backupparms, sizeof(backupparms));
+       }
+       else
+               memset(client, 0, sizeof(*client));
        client->active = true;
        client->netconnection = netconnection;
 
        Con_DPrintf("Client %s connected\n", client->netconnection ? client->netconnection->address : "botclient");
 
+       if(client->netconnection && client->netconnection->crypto.authenticated)
+       {
+               Con_Printf("%s connection to %s has been established: client is %s@%.*s, I am %.*s@%.*s\n",
+                               client->netconnection->crypto.use_aes ? "Encrypted" : "Authenticated",
+                               client->netconnection->address,
+                               client->netconnection->crypto.client_idfp[0] ? client->netconnection->crypto.client_idfp : "-",
+                               crypto_keyfp_recommended_length, client->netconnection->crypto.client_keyfp[0] ? client->netconnection->crypto.client_keyfp : "-",
+                               crypto_keyfp_recommended_length, client->netconnection->crypto.server_idfp[0] ? client->netconnection->crypto.server_idfp : "-",
+                               crypto_keyfp_recommended_length, client->netconnection->crypto.server_keyfp[0] ? client->netconnection->crypto.server_keyfp : "-"
+                               );
+       }
+
        strlcpy(client->name, "unconnected", sizeof(client->name));
        strlcpy(client->old_name, "unconnected", sizeof(client->old_name));
        client->spawned = false;
@@ -992,9 +1027,7 @@ void SV_ConnectClient (int clientnum, netconn_t *netconnection)
                client->rate = 1000000000;
        client->connecttime = realtime;
 
-       if (sv.loadgame)
-               memcpy (client->spawn_parms, spawn_parms, sizeof(spawn_parms));
-       else
+       if (!sv.loadgame)
        {
                // call the progs to get default spawn parms for the new client
                // set self to world to intentionally cause errors with broken SetNewParms code in some mods
@@ -1584,6 +1617,87 @@ void SV_MarkWriteEntityStateToClient(entity_state_t *s)
        sv.sententities[s->number] = sv.sententitiesmark;
 }
 
+#if MAX_LEVELNETWORKEYES > 0
+#define MAX_EYE_RECURSION 1 // increase if recursion gets supported by portals
+void SV_AddCameraEyes(void)
+{
+       int e, i, j, k;
+       prvm_edict_t *ed;
+       static int cameras[MAX_LEVELNETWORKEYES];
+       static vec3_t camera_origins[MAX_LEVELNETWORKEYES];
+       static int eye_levels[MAX_CLIENTNETWORKEYES];
+       int n_cameras = 0;
+       vec3_t mi, ma;
+       prvm_eval_t *valendpos, *val;
+
+       if(!prog->fieldoffsets.camera_transform)
+               return;
+       valendpos = PRVM_GLOBALFIELDVALUE(prog->globaloffsets.trace_endpos);
+       if(!valendpos)
+               return;
+
+       for(i = 0; i < sv.writeentitiestoclient_numeyes; ++i)
+               eye_levels[i] = 0;
+
+       // check line of sight to portal entities and add them to PVS
+       for (e = 1, ed = PRVM_NEXT_EDICT(prog->edicts);e < prog->num_edicts;e++, ed = PRVM_NEXT_EDICT(ed))
+       {
+               if (!ed->priv.server->free)
+               {
+                       if((val = PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.camera_transform)) && val->function)
+                       {
+                               prog->globals.server->self = e;
+                               prog->globals.server->other = sv.writeentitiestoclient_cliententitynumber;
+                               VectorCopy(sv.writeentitiestoclient_eyes[0], valendpos->vector);
+                               VectorCopy(sv.writeentitiestoclient_eyes[0], PRVM_G_VECTOR(OFS_PARM0));
+                               VectorClear(PRVM_G_VECTOR(OFS_PARM1));
+                               PRVM_ExecuteProgram(val->function, "QC function e.camera_transform is missing");
+                               if(!VectorCompare(valendpos->vector, sv.writeentitiestoclient_eyes[0]))
+                               {
+                                       VectorCopy(valendpos->vector, camera_origins[n_cameras]);
+                                       cameras[n_cameras] = e;
+                                       ++n_cameras;
+                                       if(n_cameras >= MAX_LEVELNETWORKEYES)
+                                               break;
+                               }
+                       }
+               }
+       }
+
+       if(!n_cameras)
+               return;
+
+       // i is loop counter, is reset to 0 when an eye got added
+       // j is camera index to check
+       for(i = 0, j = 0; sv.writeentitiestoclient_numeyes < MAX_CLIENTNETWORKEYES && i < n_cameras; ++i, ++j, j %= n_cameras)
+       {
+               if(!cameras[j])
+                       continue;
+               ed = PRVM_EDICT_NUM(cameras[j]);
+               VectorAdd(ed->fields.server->origin, ed->fields.server->mins, mi);
+               VectorAdd(ed->fields.server->origin, ed->fields.server->maxs, ma);
+               for(k = 0; k < sv.writeentitiestoclient_numeyes; ++k)
+               if(eye_levels[k] <= MAX_EYE_RECURSION)
+               {
+                       if(SV_CanSeeBox(sv_cullentities_trace_samples.integer, sv_cullentities_trace_enlarge.value, sv.writeentitiestoclient_eyes[k], mi, ma))
+                       {
+                               eye_levels[sv.writeentitiestoclient_numeyes] = eye_levels[k] + 1;
+                               VectorCopy(camera_origins[j], sv.writeentitiestoclient_eyes[sv.writeentitiestoclient_numeyes]);
+                               // Con_Printf("added eye %d: %f %f %f because we can see %f %f %f .. %f %f %f from eye %d\n", j, sv.writeentitiestoclient_eyes[sv.writeentitiestoclient_numeyes][0], sv.writeentitiestoclient_eyes[sv.writeentitiestoclient_numeyes][1], sv.writeentitiestoclient_eyes[sv.writeentitiestoclient_numeyes][2], mi[0], mi[1], mi[2], ma[0], ma[1], ma[2], k);
+                               sv.writeentitiestoclient_numeyes++;
+                               cameras[j] = 0;
+                               i = 0;
+                               break;
+                       }
+               }
+       }
+}
+#else
+void SV_AddCameraEyes(void)
+{
+}
+#endif
+
 void SV_WriteEntitiesToClient(client_t *client, prvm_edict_t *clent, sizebuf_t *msg, int maxsize)
 {
        qboolean need_empty = false;
@@ -1634,7 +1748,12 @@ void SV_WriteEntitiesToClient(client_t *client, prvm_edict_t *clent, sizebuf_t *
                //      Con_DPrintf("Trying to walk into solid in a pingtime... not predicting for culling\n");
        }
 
-       // TODO: check line of sight to portal entities and add them to PVS
+       SV_AddCameraEyes();
+
+       // build PVS from the new eyes
+       if (sv.worldmodel && sv.worldmodel->brush.FatPVS)
+               for(i = 1; i < sv.writeentitiestoclient_numeyes; ++i)
+                       sv.writeentitiestoclient_pvsbytes = sv.worldmodel->brush.FatPVS(sv.worldmodel, sv.writeentitiestoclient_eyes[i], 8, sv.writeentitiestoclient_pvs, sizeof(sv.writeentitiestoclient_pvs), sv.writeentitiestoclient_pvsbytes != 0);
 
        sv.sententitiesmark++;
 
@@ -1645,19 +1764,24 @@ void SV_WriteEntitiesToClient(client_t *client, prvm_edict_t *clent, sizebuf_t *
        numcsqcsendstates = 0;
        for (i = 0;i < sv.numsendentities;i++)
        {
-               if (sv.sententities[sv.sendentities[i].number] == sv.sententitiesmark)
+               s = &sv.sendentities[i];
+               if (sv.sententities[s->number] == sv.sententitiesmark)
                {
-                       if(sv.sendentities[i].active == ACTIVE_NETWORK)
+                       if(s->active == ACTIVE_NETWORK)
                        {
-                               s = &sv.writeentitiestoclient_sendstates[numsendstates++];
-                               *s = sv.sendentities[i];
-                               if (s->exteriormodelforclient && s->exteriormodelforclient == sv.writeentitiestoclient_cliententitynumber)
-                                       s->flags |= RENDER_EXTERIORMODEL;
+                               if (s->exteriormodelforclient)
+                               {
+                                       if (s->exteriormodelforclient == sv.writeentitiestoclient_cliententitynumber)
+                                               s->flags |= RENDER_EXTERIORMODEL;
+                                       else
+                                               s->flags &= ~RENDER_EXTERIORMODEL;
+                               }
+                               sv.writeentitiestoclient_sendstates[numsendstates++] = s;
                        }
                        else if(sv.sendentities[i].active == ACTIVE_SHARED)
-                               sv.writeentitiestoclient_csqcsendstates[numcsqcsendstates++] = sv.sendentities[i].number;
+                               sv.writeentitiestoclient_csqcsendstates[numcsqcsendstates++] = s->number;
                        else
-                               Con_Printf("entity %d is in sv.sendentities and marked, but not active, please breakpoint me\n", sv.sendentities[i].number);
+                               Con_Printf("entity %d is in sv.sendentities and marked, but not active, please breakpoint me\n", s->number);
                }
        }
 
@@ -1843,6 +1967,8 @@ void SV_WriteClientdataToMessage (client_t *client, prvm_edict_t *ent, sizebuf_t
        // note: these are not sent in protocols with lower MAX_CL_STATS limits
        stats[STAT_MOVEFLAGS] = MOVEFLAG_VALID
                | (sv_gameplayfix_q2airaccelerate.integer ? MOVEFLAG_Q2AIRACCELERATE : 0)
+               | (sv_gameplayfix_nogravityonground.integer ? MOVEFLAG_NOGRAVITYONGROUND : 0)
+               | (sv_gameplayfix_gravityunaffectedbyticrate.integer ? MOVEFLAG_GRAVITYUNAFFECTEDBYTICRATE : 0)
        ;
        statsf[STAT_MOVEVARS_TICRATE] = sys_ticrate.value;
        statsf[STAT_MOVEVARS_TIMESCALE] = slowmo.value;
@@ -1866,12 +1992,16 @@ void SV_WriteClientdataToMessage (client_t *client, prvm_edict_t *ent, sizebuf_t
        statsf[STAT_MOVEVARS_AIRSTOPACCELERATE] = sv_airstopaccelerate.value;
        statsf[STAT_MOVEVARS_AIRSTRAFEACCELERATE] = sv_airstrafeaccelerate.value;
        statsf[STAT_MOVEVARS_MAXAIRSTRAFESPEED] = sv_maxairstrafespeed.value;
+       statsf[STAT_MOVEVARS_AIRSTRAFEACCEL_QW] = sv_airstrafeaccel_qw.value;
        statsf[STAT_MOVEVARS_AIRCONTROL] = sv_aircontrol.value;
+       statsf[STAT_MOVEVARS_AIRCONTROL_POWER] = sv_aircontrol_power.value;
+       statsf[STAT_MOVEVARS_AIRCONTROL_PENALTY] = sv_aircontrol_penalty.value;
        statsf[STAT_MOVEVARS_WARSOWBUNNY_AIRFORWARDACCEL] = sv_warsowbunny_airforwardaccel.value;
        statsf[STAT_MOVEVARS_WARSOWBUNNY_ACCEL] = sv_warsowbunny_accel.value;
        statsf[STAT_MOVEVARS_WARSOWBUNNY_TOPSPEED] = sv_warsowbunny_topspeed.value;
        statsf[STAT_MOVEVARS_WARSOWBUNNY_TURNACCEL] = sv_warsowbunny_turnaccel.value;
        statsf[STAT_MOVEVARS_WARSOWBUNNY_BACKTOSIDERATIO] = sv_warsowbunny_backtosideratio.value;
+       statsf[STAT_MOVEVARS_AIRSPEEDLIMIT_NONQW] = sv_airspeedlimit_nonqw.value;
        statsf[STAT_FRAGLIMIT] = fraglimit.value;
        statsf[STAT_TIMELIMIT] = timelimit.value;
 
@@ -2050,7 +2180,7 @@ static void SV_SendClientDatagram (client_t *client)
        int clientrate, maxrate, maxsize, maxsize2, downloadsize;
        sizebuf_t msg;
        int stats[MAX_CL_STATS];
-       unsigned char sv_sendclientdatagram_buf[NET_MAXMESSAGE];
+       static unsigned char sv_sendclientdatagram_buf[NET_MAXMESSAGE];
 
        // obey rate limit by limiting packet frequency if the packet size
        // limiting fails
@@ -2274,14 +2404,14 @@ static void SV_UpdateToReliableMessages (void)
                        }
 
                        if( oldclientcamera != host_client->clientcamera ) {
-                               MSG_WriteByte (&sv.reliable_datagram, svc_setview );
+                               MSG_WriteByte (&host_client->netconnection->message, svc_setview );
                                MSG_WriteShort (&host_client->netconnection->message, host_client->clientcamera);
                        }
                }
 
                // frags
                host_client->frags = (int)host_client->edict->fields.server->frags;
-               if(gamemode == GAME_NEXUIZ)
+               if(gamemode == GAME_NEXUIZ || gamemode == GAME_XONOTIC)
                        if(!host_client->spawned && host_client->netconnection)
                                host_client->frags = -666;
                if (host_client->old_frags != host_client->frags)
@@ -2621,7 +2751,7 @@ int SV_ModelIndex(const char *s, int precachemode)
                                if (precachemode == 1)
                                        Con_Printf("SV_ModelIndex(\"%s\"): not precached (fix your code), precaching anyway\n", filename);
                                strlcpy(sv.model_precache[i], filename, sizeof(sv.model_precache[i]));
-                               sv.models[i] = Mod_ForName (sv.model_precache[i], true, false, s[0] == '*' ? sv.modelname : NULL);
+                               sv.models[i] = Mod_ForName (sv.model_precache[i], true, false, s[0] == '*' ? sv.worldname : NULL);
                                if (sv.state != ss_loading)
                                {
                                        MSG_WriteByte(&sv.reliable_datagram, svc_precache);
@@ -2700,7 +2830,9 @@ int SV_ParticleEffectIndex(const char *name)
        int filepass;
        fs_offset_t filesize;
        unsigned char *filedata;
-       const char *text, *textstart, *textend;
+       const char *text;
+       const char *textstart;
+       //const char *textend;
        char argv[16][1024];
        char filename[MAX_QPATH];
        if (!sv.particleeffectnamesloaded)
@@ -2714,14 +2846,14 @@ int SV_ParticleEffectIndex(const char *name)
                        if (filepass == 0)
                                dpsnprintf(filename, sizeof(filename), "effectinfo.txt");
                        else if (filepass == 1)
-                               dpsnprintf(filename, sizeof(filename), "maps/%s_effectinfo.txt", sv.name);
+                               dpsnprintf(filename, sizeof(filename), "%s_effectinfo.txt", sv.worldnamenoextension);
                        else
                                break;
                        filedata = FS_LoadFile(filename, tempmempool, true, &filesize);
                        if (!filedata)
                                continue;
                        textstart = (const char *)filedata;
-                       textend = (const char *)filedata + filesize;
+                       //textend = (const char *)filedata + filesize;
                        text = textstart;
                        for (linenumber = 1;;linenumber++)
                        {
@@ -2895,31 +3027,29 @@ void SV_Prepare_CSQC(void)
        svs.csqc_progdata = NULL;
        svs.csqc_progdata_deflated = NULL;
        
-       Con_Print("Loading csprogs.dat\n");
-
        sv.csqc_progname[0] = 0;
        svs.csqc_progdata = FS_LoadFile(csqc_progname.string, sv_mempool, false, &progsize);
 
        if(progsize > 0)
        {
                size_t deflated_size;
-               
+
                sv.csqc_progsize = (int)progsize;
                sv.csqc_progcrc = CRC_Block(svs.csqc_progdata, progsize);
                strlcpy(sv.csqc_progname, csqc_progname.string, sizeof(sv.csqc_progname));
-               Con_Printf("server detected csqc progs file \"%s\" with size %i and crc %i\n", sv.csqc_progname, sv.csqc_progsize, sv.csqc_progcrc);
+               Con_DPrintf("server detected csqc progs file \"%s\" with size %i and crc %i\n", sv.csqc_progname, sv.csqc_progsize, sv.csqc_progcrc);
 
-               Con_Print("Compressing csprogs.dat\n");
+               Con_DPrint("Compressing csprogs.dat\n");
                //unsigned char *FS_Deflate(const unsigned char *data, size_t size, size_t *deflated_size, int level, mempool_t *mempool);
                svs.csqc_progdata_deflated = FS_Deflate(svs.csqc_progdata, progsize, &deflated_size, -1, sv_mempool);
                svs.csqc_progsize_deflated = (int)deflated_size;
                if(svs.csqc_progdata_deflated)
                {
-                       Con_Printf("Deflated: %g%%\n", 100.0 - 100.0 * (deflated_size / (float)progsize));
+                       Con_DPrintf("Deflated: %g%%\n", 100.0 - 100.0 * (deflated_size / (float)progsize));
                        Con_DPrintf("Uncompressed: %u\nCompressed:   %u\n", (unsigned)sv.csqc_progsize, (unsigned)svs.csqc_progsize_deflated);
                }
                else
-                       Con_Printf("Cannot compress - need zlib for this. Using uncompressed progs only.\n");
+                       Con_DPrintf("Cannot compress - need zlib for this. Using uncompressed progs only.\n");
        }
 }
 
@@ -2964,7 +3094,7 @@ void SV_SpawnServer (const char *server)
        int i;
        char *entities;
        dp_model_t *worldmodel;
-       char modelname[sizeof(sv.modelname)];
+       char modelname[sizeof(sv.worldname)];
 
        Con_DPrintf("SpawnServer: %s\n", server);
 
@@ -2972,8 +3102,12 @@ void SV_SpawnServer (const char *server)
 
        if (!FS_FileExists(modelname))
        {
-               Con_Printf("SpawnServer: no map file named %s\n", modelname);
-               return;
+               dpsnprintf (modelname, sizeof(modelname), "maps/%s", server);
+               if (!FS_FileExists(modelname))
+               {
+                       Con_Printf("SpawnServer: no map file named maps/%s.bsp\n", server);
+                       return;
+               }
        }
 
        if (cls.state != ca_dedicated)
@@ -2998,7 +3132,7 @@ void SV_SpawnServer (const char *server)
        // free q3 shaders so that any newly downloaded shaders will be active
        Mod_FreeQ3Shaders();
 
-       worldmodel = Mod_ForName(modelname, false, true, NULL);
+       worldmodel = Mod_ForName(modelname, false, developer.integer > 0, NULL);
        if (!worldmodel || !worldmodel->TraceBox)
        {
                Con_Printf("Couldn't load map %s\n", modelname);
@@ -3067,7 +3201,15 @@ void SV_SpawnServer (const char *server)
 
        sv.active = true;
 
+       // set level base name variables for later use
        strlcpy (sv.name, server, sizeof (sv.name));
+       strlcpy(sv.worldname, modelname, sizeof(sv.worldname));
+       FS_StripExtension(sv.worldname, sv.worldnamenoextension, sizeof(sv.worldnamenoextension));
+       strlcpy(sv.worldbasename, !strncmp(sv.worldnamenoextension, "maps/", 5) ? sv.worldnamenoextension + 5 : sv.worldnamenoextension, sizeof(sv.worldbasename));
+       //Cvar_SetQuick(&sv_worldmessage, sv.worldmessage); // set later after QC is spawned
+       Cvar_SetQuick(&sv_worldname, sv.worldname);
+       Cvar_SetQuick(&sv_worldnamenoextension, sv.worldnamenoextension);
+       Cvar_SetQuick(&sv_worldbasename, sv.worldbasename);
 
        sv.protocol = Protocol_EnumForName(sv_protocolname.string);
        if (sv.protocol == PROTOCOL_UNKNOWN)
@@ -3107,25 +3249,23 @@ void SV_SpawnServer (const char *server)
        Mod_ClearUsed();
        worldmodel->used = true;
 
-       strlcpy (sv.name, server, sizeof (sv.name));
-       strlcpy(sv.modelname, modelname, sizeof(sv.modelname));
        sv.worldmodel = worldmodel;
        sv.models[1] = sv.worldmodel;
 
 //
 // clear world interaction links
 //
-       World_SetSize(&sv.world, sv.worldmodel->name, sv.worldmodel->normalmins, sv.worldmodel->normalmaxs);
+       World_SetSize(&sv.world, sv.worldname, sv.worldmodel->normalmins, sv.worldmodel->normalmaxs);
        World_Start(&sv.world);
 
        strlcpy(sv.sound_precache[0], "", sizeof(sv.sound_precache[0]));
 
        strlcpy(sv.model_precache[0], "", sizeof(sv.model_precache[0]));
-       strlcpy(sv.model_precache[1], sv.modelname, sizeof(sv.model_precache[1]));
+       strlcpy(sv.model_precache[1], sv.worldname, sizeof(sv.model_precache[1]));
        for (i = 1;i < sv.worldmodel->brush.numsubmodels && i+1 < MAX_MODELS;i++)
        {
                dpsnprintf(sv.model_precache[i+1], sizeof(sv.model_precache[i+1]), "*%i", i);
-               sv.models[i+1] = Mod_ForName (sv.model_precache[i+1], false, false, sv.modelname);
+               sv.models[i+1] = Mod_ForName (sv.model_precache[i+1], false, false, sv.worldname);
        }
        if(i < sv.worldmodel->brush.numsubmodels)
                Con_Printf("Too many submodels (MAX_MODELS is %i)\n", MAX_MODELS);
@@ -3137,7 +3277,7 @@ void SV_SpawnServer (const char *server)
        ent = PRVM_EDICT_NUM(0);
        memset (ent->fields.server, 0, prog->progs->entityfields * 4);
        ent->priv.server->free = false;
-       ent->fields.server->model = PRVM_SetEngineString(sv.modelname);
+       ent->fields.server->model = PRVM_SetEngineString(sv.worldname);
        ent->fields.server->modelindex = 1;             // world model
        ent->fields.server->solid = SOLID_BSP;
        ent->fields.server->movetype = MOVETYPE_PUSH;
@@ -3168,9 +3308,9 @@ void SV_SpawnServer (const char *server)
        }
 
        // load replacement entity file if found
-       if (sv_entpatch.integer && (entities = (char *)FS_LoadFile(va("maps/%s.ent", sv.name), tempmempool, true, NULL)))
+       if (sv_entpatch.integer && (entities = (char *)FS_LoadFile(va("%s.ent", sv.worldnamenoextension), tempmempool, true, NULL)))
        {
-               Con_Printf("Loaded maps/%s.ent\n", sv.name);
+               Con_Printf("Loaded %s.ent\n", sv.worldnamenoextension);
                PRVM_ED_LoadFromFile (entities);
                Mem_Free(entities);
        }
@@ -3233,6 +3373,10 @@ void SV_SpawnServer (const char *server)
                }
        }
 
+       // update the map title cvar
+       strlcpy(sv.worldmessage, PRVM_GetString(prog->edicts->fields.server->message), sizeof(sv.worldmessage)); // map title (not related to filename)
+       Cvar_SetQuick(&sv_worldmessage, sv.worldmessage);
+
        Con_DPrint("Server spawned.\n");
        NetConn_Heartbeat (2);
 
@@ -3254,7 +3398,7 @@ static void SV_VM_CB_EndIncreaseEdicts(void)
        prvm_edict_t *ent;
 
        // link every entity except world
-       for (i = 1, ent = prog->edicts;i < prog->max_edicts;i++, ent++)
+       for (i = 1, ent = prog->edicts;i < prog->num_edicts;i++, ent++)
                if (!ent->priv.server->free)
                        SV_LinkEdict(ent);
 }
@@ -3296,6 +3440,41 @@ static void SV_VM_CB_InitEdict(prvm_edict_t *e)
                                // Invalid / Bot
                                PRVM_EDICTFIELDVALUE(e, prog->fieldoffsets.netaddress)->string = PRVM_SetEngineString("null/botclient");
                }
+               if(prog->fieldoffsets.crypto_idfp >= 0)
+               { // Valid Field; Process
+                       if(svs.clients[num].netconnection != NULL && svs.clients[num].netconnection->crypto.authenticated && svs.clients[num].netconnection->crypto.client_idfp[0])
+                               PRVM_EDICTFIELDVALUE(e, prog->fieldoffsets.crypto_idfp)->string = PRVM_SetEngineString(svs.clients[num].netconnection->crypto.client_idfp);
+                       else
+                               PRVM_EDICTFIELDVALUE(e, prog->fieldoffsets.crypto_idfp)->string = 0;
+               }
+               if(prog->fieldoffsets.crypto_keyfp >= 0)
+               { // Valid Field; Process
+                       if(svs.clients[num].netconnection != NULL && svs.clients[num].netconnection->crypto.authenticated && svs.clients[num].netconnection->crypto.client_keyfp[0])
+                               PRVM_EDICTFIELDVALUE(e, prog->fieldoffsets.crypto_keyfp)->string = PRVM_SetEngineString(svs.clients[num].netconnection->crypto.client_keyfp);
+                       else
+                               PRVM_EDICTFIELDVALUE(e, prog->fieldoffsets.crypto_keyfp)->string = 0;
+               }
+               if(prog->fieldoffsets.crypto_mykeyfp >= 0)
+               { // Valid Field; Process
+                       if(svs.clients[num].netconnection != NULL && svs.clients[num].netconnection->crypto.authenticated && svs.clients[num].netconnection->crypto.server_keyfp[0])
+                               PRVM_EDICTFIELDVALUE(e, prog->fieldoffsets.crypto_mykeyfp)->string = PRVM_SetEngineString(svs.clients[num].netconnection->crypto.server_keyfp);
+                       else
+                               PRVM_EDICTFIELDVALUE(e, prog->fieldoffsets.crypto_mykeyfp)->string = 0;
+               }
+               if(prog->fieldoffsets.crypto_encryptmethod >= 0)
+               { // Valid Field; Process
+                       if(svs.clients[num].netconnection != NULL && svs.clients[num].netconnection->crypto.authenticated && svs.clients[num].netconnection->crypto.use_aes)
+                               PRVM_EDICTFIELDVALUE(e, prog->fieldoffsets.crypto_encryptmethod)->string = PRVM_SetEngineString("AES128");
+                       else
+                               PRVM_EDICTFIELDVALUE(e, prog->fieldoffsets.crypto_encryptmethod)->string = 0;
+               }
+               if(prog->fieldoffsets.crypto_signmethod >= 0)
+               { // Valid Field; Process
+                       if(svs.clients[num].netconnection != NULL && svs.clients[num].netconnection->crypto.authenticated)
+                               PRVM_EDICTFIELDVALUE(e, prog->fieldoffsets.crypto_signmethod)->string = PRVM_SetEngineString("HMAC-SHA256");
+                       else
+                               PRVM_EDICTFIELDVALUE(e, prog->fieldoffsets.crypto_signmethod)->string = 0;
+               }
        }
 }