]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - sv_main.c
MAX_EDICTS has changed to 32768. Yes this is madness. Thanks to banshee for prompti...
[xonotic/darkplaces.git] / sv_main.c
index 82318441daac5cf10e03f76f22e761c92bedc615..3e0f6866a5353f3256d32c06d44efbe72ac269fd 100644 (file)
--- a/sv_main.c
+++ b/sv_main.c
@@ -195,30 +195,35 @@ void SV_StartSound (edict_t *entity, int channel, char *sample, int volume,
 
        ent = NUM_FOR_EDICT(entity);
 
-       channel = (ent<<3) | channel;
-
        field_mask = 0;
        if (volume != DEFAULT_SOUND_PACKET_VOLUME)
                field_mask |= SND_VOLUME;
        if (attenuation != DEFAULT_SOUND_PACKET_ATTENUATION)
                field_mask |= SND_ATTENUATION;
+       if (ent >= 8192)
+               field_mask |= SND_LARGEENTITY;
+       if (sound_num >= 256 || channel >= 8)
+               field_mask |= SND_LARGESOUND;
 
 // directed messages go only to the entity they are targeted on
-       if (sound_num >= 256)
-               MSG_WriteByte (&sv.datagram, svc_sound2);
-       else
-               MSG_WriteByte (&sv.datagram, svc_sound);
+       MSG_WriteByte (&sv.datagram, svc_sound);
        MSG_WriteByte (&sv.datagram, field_mask);
        if (field_mask & SND_VOLUME)
                MSG_WriteByte (&sv.datagram, volume);
        if (field_mask & SND_ATTENUATION)
                MSG_WriteByte (&sv.datagram, attenuation*64);
-       MSG_WriteShort (&sv.datagram, channel);
-       if (sound_num >= 256)
+       if (field_mask & SND_LARGEENTITY)
+       {
+               MSG_WriteShort (&sv.datagram, ent);
+               MSG_WriteByte (&sv.datagram, channel);
+       }
+       else
+               MSG_WriteShort (&sv.datagram, (ent<<3) | channel);
+       if (field_mask & SND_LARGESOUND)
                MSG_WriteShort (&sv.datagram, sound_num);
        else
                MSG_WriteByte (&sv.datagram, sound_num);
-       for (i=0 ; i<3 ; i++)
+       for (i = 0;i < 3;i++)
                MSG_WriteDPCoord (&sv.datagram, entity->v->origin[i]+0.5*(entity->v->mins[i]+entity->v->maxs[i]));
 }
 
@@ -260,7 +265,7 @@ void SV_SendServerinfo (client_t *client)
        else
                MSG_WriteByte (&client->message, GAME_COOP);
 
-       sprintf (message, pr_strings+sv.edicts->v->message);
+       sprintf (message, PR_GetString(sv.edicts->v->message));
 
        MSG_WriteString (&client->message,message);
 
@@ -586,7 +591,7 @@ void SV_WriteEntitiesToClient (client_t *client, edict_t *clent, sizebuf_t *msg)
                if (val->_float != 0)
                        bits |= U_GLOWTRAIL;
 
-               if (ent->v->modelindex >= 0 && ent->v->modelindex < MAX_MODELS && pr_strings[ent->v->model])
+               if (ent->v->modelindex >= 0 && ent->v->modelindex < MAX_MODELS && *PR_GetString(ent->v->model))
                {
                        model = sv.models[(int)ent->v->modelindex];
                        Mod_CheckLoaded(model);
@@ -907,6 +912,8 @@ void SV_WriteEntitiesToClient (client_t *client, edict_t *clent, sizebuf_t *msg)
        ent = NEXT_EDICT(sv.edicts);
        for (e = 1;e < sv.num_edicts;e++, ent = NEXT_EDICT(ent))
        {
+               if (ent->free)
+                       continue;
                flags = 0;
 
                if (ent != clent) // LordHavoc: always send player
@@ -968,7 +975,7 @@ void SV_WriteEntitiesToClient (client_t *client, edict_t *clent, sizebuf_t *msg)
                }
 
                modelindex = 0;
-               if (ent->v->modelindex >= 0 && ent->v->modelindex < MAX_MODELS && pr_strings[ent->v->model])
+               if (ent->v->modelindex >= 0 && ent->v->modelindex < MAX_MODELS && *PR_GetString(ent->v->model))
                {
                        modelindex = ent->v->modelindex;
                        model = sv.models[(int)ent->v->modelindex];
@@ -1344,7 +1351,7 @@ void SV_WriteClientdataToMessage (edict_t *ent, sizebuf_t *msg)
        if (bits & SU_ARMOR)
                MSG_WriteByte (msg, ent->v->armorvalue);
        if (bits & SU_WEAPON)
-               MSG_WriteByte (msg, SV_ModelIndex(pr_strings+ent->v->weaponmodel));
+               MSG_WriteByte (msg, SV_ModelIndex(PR_GetString(ent->v->weaponmodel)));
 
        MSG_WriteShort (msg, ent->v->health);
        MSG_WriteByte (msg, ent->v->currentammo);
@@ -1597,7 +1604,7 @@ void SV_CreateBaseline (void)
        edict_t *svent;
 
        // LordHavoc: clear *all* states (note just active ones)
-       for (entnum = 0; entnum < MAX_EDICTS ; entnum++)
+       for (entnum = 0;entnum < sv.max_edicts;entnum++)
        {
                // get the current server version
                svent = EDICT_NUM(entnum);
@@ -1818,9 +1825,9 @@ void SV_SpawnServer (const char *server)
 //
        SV_ClearWorld ();
 
-       sv.sound_precache[0] = pr_strings;
+       sv.sound_precache[0] = "";
 
-       sv.model_precache[0] = pr_strings;
+       sv.model_precache[0] = "";
        sv.model_precache[1] = sv.modelname;
        for (i = 1;i < sv.worldmodel->numsubmodels;i++)
        {
@@ -1834,7 +1841,7 @@ void SV_SpawnServer (const char *server)
        ent = EDICT_NUM(0);
        memset (ent->v, 0, progs->entityfields * 4);
        ent->free = false;
-       ent->v->model = sv.worldmodel->name - pr_strings;
+       ent->v->model = PR_SetString(sv.modelname);
        ent->v->modelindex = 1;         // world model
        ent->v->solid = SOLID_BSP;
        ent->v->movetype = MOVETYPE_PUSH;
@@ -1844,7 +1851,7 @@ void SV_SpawnServer (const char *server)
        else
                pr_global_struct->deathmatch = deathmatch.integer;
 
-       pr_global_struct->mapname = sv.name - pr_strings;
+       pr_global_struct->mapname = PR_SetString(sv.name);
 
 // serverflags are for cross level information (sigils)
        pr_global_struct->serverflags = svs.serverflags;