]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - sv_main.c
added sv_gameplayfix_blowupfallenzombies and sv_gameplayfix_findradiusdistancetobox...
[xonotic/darkplaces.git] / sv_main.c
index ae0a38bc43c4b2188b5b266d521d88f95818a60b..2e2f18a6b8636410a57799dce1f1c3c551780e1f 100644 (file)
--- a/sv_main.c
+++ b/sv_main.c
@@ -40,13 +40,15 @@ cvar_t sv_gameplayfix_stepdown = {0, "sv_gameplayfix_stepdown", "1"};
 cvar_t sv_gameplayfix_stepwhilejumping = {0, "sv_gameplayfix_stepwhilejumping", "1"};
 cvar_t sv_gameplayfix_swiminbmodels = {0, "sv_gameplayfix_swiminbmodels", "1"};
 cvar_t sv_gameplayfix_setmodelrealbox = {0, "sv_gameplayfix_setmodelrealbox", "1"};
+cvar_t sv_gameplayfix_blowupfallenzombies = {0, "sv_gameplayfix_blowupfallenzombies", "1"};
+cvar_t sv_gameplayfix_findradiusdistancetobox = {0, "sv_gameplayfix_findradiusdistancetobox", "1"};
 
 cvar_t sv_progs = {0, "sv_progs", "progs.dat" };
 
 server_t sv;
 server_static_t svs;
 
-mempool_t *sv_edicts_mempool = NULL;
+mempool_t *sv_mempool = NULL;
 
 //============================================================================
 
@@ -83,6 +85,8 @@ void SV_Init (void)
        Cvar_RegisterVariable (&sv_gameplayfix_stepwhilejumping);
        Cvar_RegisterVariable (&sv_gameplayfix_swiminbmodels);
        Cvar_RegisterVariable (&sv_gameplayfix_setmodelrealbox);
+       Cvar_RegisterVariable (&sv_gameplayfix_blowupfallenzombies);
+       Cvar_RegisterVariable (&sv_gameplayfix_findradiusdistancetobox);
        Cvar_RegisterVariable (&sv_protocolname);
        Cvar_RegisterVariable (&sv_ratelimitlocalplayer);
        Cvar_RegisterVariable (&sv_maxrate);
@@ -91,7 +95,7 @@ void SV_Init (void)
        SV_Phys_Init();
        SV_World_Init();
 
-       sv_edicts_mempool = Mem_AllocPool("server edicts", 0, NULL);
+       sv_mempool = Mem_AllocPool("server", 0, NULL);
 }
 
 static void SV_SaveEntFile_f(void)
@@ -307,14 +311,14 @@ void SV_SendServerinfo (client_t *client)
                EntityFrame5_FreeDatabase(client->entitydatabase5);
 
        if (sv.protocol == PROTOCOL_DARKPLACES1 || sv.protocol == PROTOCOL_DARKPLACES2 || sv.protocol == PROTOCOL_DARKPLACES3)
-               client->entitydatabase = EntityFrame_AllocDatabase(sv_clients_mempool);
+               client->entitydatabase = EntityFrame_AllocDatabase(sv_mempool);
        if (sv.protocol == PROTOCOL_DARKPLACES4)
-               client->entitydatabase4 = EntityFrame4_AllocDatabase(sv_clients_mempool);
+               client->entitydatabase4 = EntityFrame4_AllocDatabase(sv_mempool);
        if (sv.protocol == PROTOCOL_DARKPLACES5 || sv.protocol == PROTOCOL_DARKPLACES6)
-               client->entitydatabase5 = EntityFrame5_AllocDatabase(sv_clients_mempool);
+               client->entitydatabase5 = EntityFrame5_AllocDatabase(sv_mempool);
 
        MSG_WriteByte (&client->message, svc_print);
-       snprintf (message, sizeof (message), "\002\nServer: %s build %s (progs %i crc)", gamename, buildstring, pr_crc);
+       dpsnprintf (message, sizeof (message), "\002\nServer: %s build %s (progs %i crc)", gamename, buildstring, pr_crc);
        MSG_WriteString (&client->message,message);
 
        MSG_WriteByte (&client->message, svc_serverinfo);
@@ -469,10 +473,10 @@ void SV_PrepareEntitiesForSending(void)
                VectorCopy(ent->v->origin, cs.origin);
                VectorCopy(ent->v->angles, cs.angles);
                cs.flags = 0;
-               cs.effects = (int)ent->v->effects;
-               cs.colormap = (qbyte)ent->v->colormap;
-               cs.skin = (qbyte)ent->v->skin;
-               cs.frame = (qbyte)ent->v->frame;
+               cs.effects = (unsigned)ent->v->effects;
+               cs.colormap = (unsigned)ent->v->colormap;
+               cs.skin = (unsigned)ent->v->skin;
+               cs.frame = (unsigned)ent->v->frame;
                cs.viewmodelforclient = GETEDICTFIELDVALUE(ent, eval_viewmodelforclient)->edict;
                cs.exteriormodelforclient = GETEDICTFIELDVALUE(ent, eval_exteriormodeltoclient)->edict;
                cs.nodrawtoclient = GETEDICTFIELDVALUE(ent, eval_nodrawtoclient)->edict;
@@ -756,7 +760,7 @@ void SV_MarkWriteEntityStateToClient(entity_state_t *s)
        sententities[s->number] = sententitiesmark;
 }
 
-entity_state_t sendstates[MAX_EDICTS]; 
+entity_state_t sendstates[MAX_EDICTS];
 
 void SV_WriteEntitiesToClient(client_t *client, edict_t *clent, sizebuf_t *msg, int *stats)
 {
@@ -1354,7 +1358,7 @@ int SV_ModelIndex(char *s, int precachemode)
                                        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, false);
-                               if (sv.protocol == PROTOCOL_DARKPLACES6)
+                               if (sv.protocol == PROTOCOL_DARKPLACES6 && sv.state != ss_loading)
                                {
                                        MSG_WriteByte(&sv.reliable_datagram, svc_precache);
                                        MSG_WriteShort(&sv.reliable_datagram, i);
@@ -1402,7 +1406,7 @@ int SV_SoundIndex(char *s, int precachemode)
                                if (precachemode == 1)
                                        Con_Printf("SV_SoundIndex(\"%s\"): not precached (fix your code), precaching anyway\n", filename);
                                strlcpy(sv.sound_precache[i], filename, sizeof(sv.sound_precache[i]));
-                               if (sv.protocol == PROTOCOL_DARKPLACES6)
+                               if (sv.protocol == PROTOCOL_DARKPLACES6 && sv.state != ss_loading)
                                {
                                        MSG_WriteByte(&sv.reliable_datagram, svc_precache);
                                        MSG_WriteShort(&sv.reliable_datagram, i + 32768);
@@ -1567,9 +1571,9 @@ void SV_IncreaseEdicts(void)
        SV_ClearWorld();
 
        sv.max_edicts   = min(sv.max_edicts + 256, MAX_EDICTS);
-       sv.edictsengineprivate = Mem_Alloc(sv_edicts_mempool, sv.max_edicts * sizeof(edict_engineprivate_t));
-       sv.edictsfields = Mem_Alloc(sv_edicts_mempool, sv.max_edicts * pr_edict_size);
-       sv.moved_edicts = Mem_Alloc(sv_edicts_mempool, sv.max_edicts * sizeof(edict_t *));
+       sv.edictsengineprivate = PR_Alloc(sv.max_edicts * sizeof(edict_engineprivate_t));
+       sv.edictsfields = PR_Alloc(sv.max_edicts * pr_edict_size);
+       sv.moved_edicts = PR_Alloc(sv.max_edicts * sizeof(edict_t *));
 
        memcpy(sv.edictsengineprivate, oldedictsengineprivate, oldmax_edicts * sizeof(edict_engineprivate_t));
        memcpy(sv.edictsfields, oldedictsfields, oldmax_edicts * pr_edict_size);
@@ -1583,9 +1587,9 @@ void SV_IncreaseEdicts(void)
                        SV_LinkEdict(ent, false);
        }
 
-       Mem_Free(oldedictsengineprivate);
-       Mem_Free(oldedictsfields);
-       Mem_Free(oldmoved_edicts);
+       PR_Free(oldedictsengineprivate);
+       PR_Free(oldedictsfields);
+       PR_Free(oldmoved_edicts);
 }
 
 /*
@@ -1607,7 +1611,10 @@ void SV_SpawnServer (const char *server)
 
        Con_DPrintf("SpawnServer: %s\n", server);
 
-       snprintf (modelname, sizeof(modelname), "maps/%s.bsp", server);
+       if (cls.state != ca_dedicated)
+               SCR_BeginLoadingPlaque();
+
+       dpsnprintf (modelname, sizeof(modelname), "maps/%s.bsp", server);
        worldmodel = Mod_ForName(modelname, false, true, true);
        if (!worldmodel || !worldmodel->TraceBox)
        {
@@ -1639,9 +1646,10 @@ void SV_SpawnServer (const char *server)
 //
        if (coop.integer)
                Cvar_SetValue ("deathmatch", 0);
-       current_skill = bound(0, (int)(skill.value + 0.5), 3);
-
-       Cvar_SetValue ("skill", (float)current_skill);
+       // LordHavoc: it can be useful to have skills outside the range 0-3...
+       //current_skill = bound(0, (int)(skill.value + 0.5), 3);
+       //Cvar_SetValue ("skill", (float)current_skill);
+       current_skill = (int)(skill.value + 0.5);
 
 //
 // set up the new server
@@ -1686,16 +1694,14 @@ void SV_SpawnServer (const char *server)
        sv.max_edicts = max(svs.maxclients + 1, 512);
        sv.max_edicts = min(sv.max_edicts, MAX_EDICTS);
 
-       // clear the edict memory pool
-       Mem_EmptyPool(sv_edicts_mempool);
        // edict_t structures (hidden from progs)
-       sv.edicts = Mem_Alloc(sv_edicts_mempool, MAX_EDICTS * sizeof(edict_t));
+       sv.edicts = PR_Alloc(MAX_EDICTS * sizeof(edict_t));
        // engine private structures (hidden from progs)
-       sv.edictsengineprivate = Mem_Alloc(sv_edicts_mempool, sv.max_edicts * sizeof(edict_engineprivate_t));
+       sv.edictsengineprivate = PR_Alloc(sv.max_edicts * sizeof(edict_engineprivate_t));
        // progs fields, often accessed by server
-       sv.edictsfields = Mem_Alloc(sv_edicts_mempool, sv.max_edicts * pr_edict_size);
+       sv.edictsfields = PR_Alloc(sv.max_edicts * pr_edict_size);
        // used by PushMove to move back pushed entities
-       sv.moved_edicts = Mem_Alloc(sv_edicts_mempool, sv.max_edicts * sizeof(edict_t *));
+       sv.moved_edicts = PR_Alloc(sv.max_edicts * sizeof(edict_t *));
        for (i = 0;i < sv.max_edicts;i++)
        {
                ent = sv.edicts + i;
@@ -1746,7 +1752,7 @@ void SV_SpawnServer (const char *server)
        strlcpy(sv.model_precache[1], sv.modelname, sizeof(sv.model_precache[1]));
        for (i = 1;i < sv.worldmodel->brush.numsubmodels;i++)
        {
-               snprintf(sv.model_precache[i+1], sizeof(sv.model_precache[i+1]), "*%i", 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, false);
        }