]> 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 5a82ab16bf8e4d21ad62ad70dd3e1d3044036854..a73bb657e0ab3c4974241b0b704bd0623eca1f73 100644 (file)
--- a/sv_main.c
+++ b/sv_main.c
@@ -62,6 +62,7 @@ cvar_t sv_maxairstrafespeed = {0, "sv_maxairstrafespeed", "0", "when set, replac
 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)"};
@@ -94,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", "0", "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"};
@@ -108,12 +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", "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", "1", "applies step-up onto a ledge more than once in a single frame, when running quickly up stairs"};
+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)"};
@@ -385,6 +387,7 @@ void SV_Init (void)
        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);
@@ -437,6 +440,7 @@ void SV_Init (void)
        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);
@@ -539,6 +543,7 @@ void SV_Init (void)
        if (gamemode == GAME_NEXUIZ)
        {
                Cvar_SetValueQuick (&sv_gameplayfix_q2airaccelerate, 1);
+               Cvar_SetValueQuick (&sv_gameplayfix_stepmultipletimes, 1);
        }
 
        sv_mempool = Mem_AllocPool("server", 0, NULL);
@@ -976,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;
@@ -1005,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
@@ -1603,9 +1623,9 @@ void SV_AddCameraEyes(void)
 {
        int e, i, j, k;
        prvm_edict_t *ed;
-       int cameras[MAX_LEVELNETWORKEYES];
-       vec3_t camera_origins[MAX_LEVELNETWORKEYES];
-       int eye_levels[MAX_CLIENTNETWORKEYES];
+       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;
@@ -1633,11 +1653,13 @@ void SV_AddCameraEyes(void)
                                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;
+                                       cameras[n_cameras] = e;
+                                       ++n_cameras;
+                                       if(n_cameras >= MAX_LEVELNETWORKEYES)
+                                               break;
+                               }
                        }
                }
        }
@@ -1973,6 +1995,7 @@ void SV_WriteClientdataToMessage (client_t *client, prvm_edict_t *ent, sizebuf_t
        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;
@@ -2388,7 +2411,7 @@ static void SV_UpdateToReliableMessages (void)
 
                // 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)
@@ -3075,14 +3098,14 @@ void SV_SpawnServer (const char *server)
 
        Con_DPrintf("SpawnServer: %s\n", server);
 
-       dpsnprintf (modelname, sizeof(modelname), "maps/%s", server);
+       dpsnprintf (modelname, sizeof(modelname), "maps/%s.bsp", server);
 
        if (!FS_FileExists(modelname))
        {
-               dpsnprintf (modelname, sizeof(modelname), "maps/%s.bsp", server);
+               dpsnprintf (modelname, sizeof(modelname), "maps/%s", server);
                if (!FS_FileExists(modelname))
                {
-                       Con_Printf("SpawnServer: no map file named %s\n", modelname);
+                       Con_Printf("SpawnServer: no map file named maps/%s.bsp\n", server);
                        return;
                }
        }
@@ -3417,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;
+               }
        }
 }