]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - sv_main.c
add new pseudo variable $# containing the number of arguments to the alias
[xonotic/darkplaces.git] / sv_main.c
index 30357e11eb452bd531cef714431486d0140112b4..c92b4a8a2d0a816949128ced37caac49b993264a 100644 (file)
--- a/sv_main.c
+++ b/sv_main.c
@@ -59,7 +59,7 @@ cvar_t sv_allowdownloads_archive = {0, "sv_allowdownloads_archive", "0", "whethe
 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)"};
@@ -75,7 +75,7 @@ cvar_t sv_cullentities_trace_enlarge = {0, "sv_cullentities_trace_enlarge", "0",
 cvar_t sv_cullentities_trace_prediction = {0, "sv_cullentities_trace_prediction", "1", "also trace from the predicted player position"};
 cvar_t sv_cullentities_trace_prediction_time = {0, "sv_cullentities_trace_prediction_time", "0.2", "how many seconds of prediction to use"};
 cvar_t sv_cullentities_trace_entityocclusion = {0, "sv_cullentities_trace_entityocclusion", "0", "also check if doors and other bsp models are in the way"};
-cvar_t sv_cullentities_trace_samples = {0, "sv_cullentities_trace_samples", "1", "number of samples to test for entity culling"};
+cvar_t sv_cullentities_trace_samples = {0, "sv_cullentities_trace_samples", "2", "number of samples to test for entity culling"};
 cvar_t sv_cullentities_trace_samples_extra = {0, "sv_cullentities_trace_samples_extra", "2", "number of samples to test for entity culling when the entity affects its surroundings by e.g. dlight"};
 cvar_t sv_cullentities_trace_samples_players = {0, "sv_cullentities_trace_samples_players", "8", "number of samples to test for entity culling when the entity is a player entity"};
 cvar_t sv_debugmove = {CVAR_NOTIFY, "sv_debugmove", "0", "disables collision detection optimizations for debugging purposes"};
@@ -823,7 +823,7 @@ 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
@@ -938,6 +938,8 @@ void SV_SendServerinfo (client_t *client)
        // clear movement info until client enters the new level properly
        memset(&client->cmd, 0, sizeof(client->cmd));
        client->movesequence = 0;
+       client->movement_highestsequence_seen = 0;
+       memset(&client->movement_count, 0, sizeof(client->movement_count));
 #ifdef NUM_PING_TIMES
        for (i = 0;i < NUM_PING_TIMES;i++)
                client->ping_times[i] = 0;
@@ -1354,7 +1356,7 @@ qboolean SV_CanSeeBox(int numtraces, vec_t enlarge, vec3_t eye, vec3_t entboxmin
        matrix4x4_t matrix, imatrix;
        dp_model_t *model;
        prvm_edict_t *touch;
-       prvm_edict_t *touchedicts[MAX_EDICTS];
+       static prvm_edict_t *touchedicts[MAX_EDICTS];
        vec3_t boxmins, boxmaxs;
        vec3_t clipboxmins, clipboxmaxs;
        vec3_t endpoints[MAX_LINEOFSIGHTTRACES];
@@ -1643,19 +1645,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);
                }
        }
 
@@ -2440,8 +2447,8 @@ static void SV_Download_f(void)
        extension = FS_FileExtension(host_client->download_name);
 
        // host_client is asking to download a specified file
-       if (developer.integer >= 100)
-               Con_Printf("Download request for %s by %s\n", host_client->download_name, host_client->name);
+       if (developer_extra.integer)
+               Con_DPrintf("Download request for %s by %s\n", host_client->download_name, host_client->name);
 
        if(is_csqc)
        {
@@ -2695,19 +2702,29 @@ SV_ParticleEffectIndex
 int SV_ParticleEffectIndex(const char *name)
 {
        int i, argc, linenumber, effectnameindex;
+       int filepass;
        fs_offset_t filesize;
        unsigned char *filedata;
        const char *text, *textstart, *textend;
        char argv[16][1024];
+       char filename[MAX_QPATH];
        if (!sv.particleeffectnamesloaded)
        {
                sv.particleeffectnamesloaded = true;
                memset(sv.particleeffectname, 0, sizeof(sv.particleeffectname));
                for (i = 0;i < EFFECT_TOTAL;i++)
                        strlcpy(sv.particleeffectname[i], standardeffectnames[i], sizeof(sv.particleeffectname[i]));
-               filedata = FS_LoadFile("effectinfo.txt", tempmempool, true, &filesize);
-               if (filedata)
+               for (filepass = 0;;filepass++)
                {
+                       if (filepass == 0)
+                               dpsnprintf(filename, sizeof(filename), "effectinfo.txt");
+                       else if (filepass == 1)
+                               dpsnprintf(filename, sizeof(filename), "maps/%s_effectinfo.txt", sv.name);
+                       else
+                               break;
+                       filedata = FS_LoadFile(filename, tempmempool, true, &filesize);
+                       if (!filedata)
+                               continue;
                        textstart = (const char *)filedata;
                        textend = (const char *)filedata + filesize;
                        text = textstart;
@@ -2748,7 +2765,7 @@ int SV_ParticleEffectIndex(const char *name)
                                                // if we run out of names, abort
                                                if (effectnameindex == SV_MAX_PARTICLEEFFECTNAME)
                                                {
-                                                       Con_Printf("effectinfo.txt:%i: too many effects!\n", linenumber);
+                                                       Con_Printf("%s:%i: too many effects!\n", filename, linenumber);
                                                        break;
                                                }
                                        }
@@ -2883,31 +2900,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");
        }
 }