]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - sv_main.c
increase MAX_PARTICLEEFFECTNAME and MAX_PARTICLEEFFECTINFO limits
[xonotic/darkplaces.git] / sv_main.c
index bd61ccc5ec0639d93e9bb1c1a5b0921e6e8ed2c6..5fcbae2efa79981bdc3fcbd6ed012a280daf54c3 100644 (file)
--- a/sv_main.c
+++ b/sv_main.c
@@ -114,7 +114,7 @@ cvar_t sv_gameplayfix_setmodelrealbox = {0, "sv_gameplayfix_setmodelrealbox", "1
 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_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_nostepmoveonsteepslopes = {0, "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"};
 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)"};
@@ -914,7 +914,6 @@ void SV_SendServerinfo (client_t *client)
        {
                client->csqcentityscope[i] = 0;
                client->csqcentitysendflags[i] = 0xFFFFFF;
-               client->csqcentityglobalhistory[i] = 0;
        }
        for (i = 0;i < NUM_CSQCENTITYDB_FRAMES;i++)
        {
@@ -1105,9 +1104,6 @@ void SV_ConnectClient (int clientnum, netconn_t *netconnection)
        client->unreliablemsg.maxsize = sizeof(client->unreliablemsg_data);
        // updated by receiving "rate" command from client, this is also the default if not using a DP client
        client->rate = 1000000000;
-       // no limits for local player
-       if (client->netconnection && LHNETADDRESS_GetAddressType(&client->netconnection->peeraddress) == LHNETADDRESSTYPE_LOOP)
-               client->rate = 1000000000;
        client->connecttime = realtime;
 
        if (!sv.loadgame)
@@ -2212,7 +2208,7 @@ void SV_WriteClientdataToMessage (client_t *client, prvm_edict_t *ent, sizebuf_t
                MSG_WriteByte (msg, stats[STAT_NAILS]);
                MSG_WriteByte (msg, stats[STAT_ROCKETS]);
                MSG_WriteByte (msg, stats[STAT_CELLS]);
-               if (gamemode == GAME_HIPNOTIC || gamemode == GAME_ROGUE || gamemode == GAME_QUOTH || gamemode == GAME_NEXUIZ)
+               if (gamemode == GAME_HIPNOTIC || gamemode == GAME_ROGUE || gamemode == GAME_QUOTH || IS_OLDNEXUIZ_DERIVED(gamemode))
                {
                        for (i = 0;i < 32;i++)
                                if (stats[STAT_ACTIVEWEAPON] & (1<<i))
@@ -2291,6 +2287,7 @@ static void SV_SendClientDatagram (client_t *client)
        sizebuf_t msg;
        int stats[MAX_CL_STATS];
        static unsigned char sv_sendclientdatagram_buf[NET_MAXMESSAGE];
+       double timedelta;
 
        // obey rate limit by limiting packet frequency if the packet size
        // limiting fails
@@ -2338,13 +2335,31 @@ static void SV_SendClientDatagram (client_t *client)
                //
                // at very low rates (or very small sys_ticrate) the packet size is
                // not reduced below 128, but packets may be sent less often
-               maxsize = (int)(clientrate * sys_ticrate.value);
+
+               // how long are bursts?
+               timedelta = host_client->rate_burstsize / (double)client->rate;
+
+               // how much of the burst do we keep reserved?
+               timedelta *= 1 - net_burstreserve.value;
+
+               // only try to use excess time
+               timedelta = bound(0, realtime - host_client->netconnection->cleartime, timedelta);
+
+               // but we know next packet will be in sys_ticrate, so we can use up THAT bandwidth
+               timedelta += sys_ticrate.value;
+
+               // note: packet overhead (not counted in maxsize) is 28 bytes
+               maxsize = (int)(clientrate * timedelta) - 28;
+
+               // put it in sound bounds
                maxsize = bound(128, maxsize, 1400);
                maxsize2 = 1400;
+
                // csqc entities can easily exceed 128 bytes, so disable throttling in
                // mods that use csqc (they are likely to use less bandwidth anyway)
-               if (sv.csqc_progsize > 0)
+               if((net_usesizelimit.integer == 1) ? (sv.csqc_progsize > 0) : (net_usesizelimit.integer < 1))
                        maxsize = maxsize2;
+
                break;
        }
 
@@ -2427,7 +2442,7 @@ static void SV_SendClientDatagram (client_t *client)
        SV_WriteDemoMessage(client, &msg, false);
 
 // send the datagram
-       NetConn_SendUnreliableMessage (client->netconnection, &msg, sv.protocol, clientrate, client->sendsignon == 2);
+       NetConn_SendUnreliableMessage (client->netconnection, &msg, sv.protocol, clientrate, client->rate_burstsize, client->sendsignon == 2);
        if (client->sendsignon == 1 && !client->netconnection->message.cursize)
                client->sendsignon = 2; // prevent reliable until client sends prespawn (this is the keepalive phase)
 }
@@ -2517,7 +2532,7 @@ static void SV_UpdateToReliableMessages (void)
 
                // frags
                host_client->frags = (int)PRVM_serveredictfloat(host_client->edict, frags);
-               if(gamemode == GAME_NEXUIZ || gamemode == GAME_XONOTIC)
+               if(IS_OLDNEXUIZ_DERIVED(gamemode))
                        if(!host_client->begun && host_client->netconnection)
                                host_client->frags = -666;
                if (host_client->old_frags != host_client->frags)
@@ -2996,7 +3011,7 @@ int SV_ParticleEffectIndex(const char *name)
                                {
                                        if (argc == 2)
                                        {
-                                               for (effectnameindex = 1;effectnameindex < SV_MAX_PARTICLEEFFECTNAME;effectnameindex++)
+                                               for (effectnameindex = 1;effectnameindex < MAX_PARTICLEEFFECTNAME;effectnameindex++)
                                                {
                                                        if (sv.particleeffectname[effectnameindex][0])
                                                        {
@@ -3010,7 +3025,7 @@ int SV_ParticleEffectIndex(const char *name)
                                                        }
                                                }
                                                // if we run out of names, abort
-                                               if (effectnameindex == SV_MAX_PARTICLEEFFECTNAME)
+                                               if (effectnameindex == MAX_PARTICLEEFFECTNAME)
                                                {
                                                        Con_Printf("%s:%i: too many effects!\n", filename, linenumber);
                                                        break;
@@ -3022,7 +3037,7 @@ int SV_ParticleEffectIndex(const char *name)
                }
        }
        // search for the name
-       for (effectnameindex = 1;effectnameindex < SV_MAX_PARTICLEEFFECTNAME && sv.particleeffectname[effectnameindex][0];effectnameindex++)
+       for (effectnameindex = 1;effectnameindex < MAX_PARTICLEEFFECTNAME && sv.particleeffectname[effectnameindex][0];effectnameindex++)
                if (!strcmp(sv.particleeffectname[effectnameindex], name))
                        return effectnameindex;
        // return 0 if we couldn't find it
@@ -3056,7 +3071,7 @@ static void SV_CreateBaseline (void)
        int i, entnum, large;
        prvm_edict_t *svent;
 
-       // LordHavoc: clear *all* states (note just active ones)
+       // LordHavoc: clear *all* baselines (not just active ones)
        for (entnum = 0;entnum < prog->max_edicts;entnum++)
        {
                // get the current server version
@@ -3617,11 +3632,7 @@ static void SVVM_free_edict(prvm_prog_t *prog, prvm_edict_t *ed)
        e = PRVM_NUM_FOR_EDICT(ed);
        sv.csqcentityversion[e] = 0;
        for (i = 0;i < svs.maxclients;i++)
-       {
-               if (svs.clients[i].csqcentityscope[e])
-                       svs.clients[i].csqcentityscope[e] = 1; // removed, awaiting send
                svs.clients[i].csqcentitysendflags[e] = 0xFFFFFF;
-       }
 }
 
 static void SVVM_count_edicts(prvm_prog_t *prog)