]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - sv_main.c
added DP_CON_SET and DP_CON_SETA extensions
[xonotic/darkplaces.git] / sv_main.c
index c79ee24d2be0429fd1337d2aa41b28f5dcc8498c..e884eaec71af154292cc324d2e6f036759a60cf5 100644 (file)
--- a/sv_main.c
+++ b/sv_main.c
@@ -32,6 +32,8 @@ static cvar_t sv_cullentities_trace = {0, "sv_cullentities_trace", "0"}; // tend
 static cvar_t sv_cullentities_stats = {0, "sv_cullentities_stats", "0"};
 static cvar_t sv_entpatch = {0, "sv_entpatch", "1"};
 
+extern cvar_t sys_ticrate;
+
 cvar_t sv_gameplayfix_grenadebouncedownslopes = {0, "sv_gameplayfix_grenadebouncedownslopes", "1"};
 cvar_t sv_gameplayfix_noairborncorpse = {0, "sv_gameplayfix_noairborncorpse", "1"};
 cvar_t sv_gameplayfix_stepdown = {0, "sv_gameplayfix_stepdown", "1"};
@@ -279,7 +281,7 @@ void SV_SendServerinfo (client_t *client)
        char                    message[128];
 
        // edicts get reallocated on level changes, so we need to update it here
-       client->edict = EDICT_NUM(client->number + 1);
+       client->edict = EDICT_NUM((client - svs.clients) + 1);
 
 
        // LordHavoc: clear entityframe tracking
@@ -364,7 +366,6 @@ void SV_ConnectClient (int clientnum, netconn_t *netconnection)
 
        strcpy(client->name, "unconnected");
        strcpy(client->old_name, "unconnected");
-       client->number = clientnum;
        client->spawned = false;
        client->edict = EDICT_NUM(clientnum+1);
        client->message.data = client->msgbuf;
@@ -624,7 +625,7 @@ void SV_MarkWriteEntityStateToClient(entity_state_t *s)
                }
                // always send world submodels, they don't generate much traffic
                // except in PROTOCOL_QUAKE where they hog bandwidth like crazy
-               else if (!(isbmodel = (model = sv.models[s->modelindex]) != NULL && model->name[0] == '*') || sv.protocol == PROTOCOL_QUAKE)
+               else if ((!(isbmodel = (model = sv.models[s->modelindex]) != NULL && model->name[0] == '*') && !(s->effects & EF_NODEPTHTEST)) || sv.protocol == PROTOCOL_QUAKE)
                {
                        Mod_CheckLoaded(model);
                        // entity has survived every check so far, check if visible
@@ -1115,65 +1116,54 @@ void SV_UpdateToReliableMessages (void)
        int i, j;
        client_t *client;
        eval_t *val;
-       char *s;
+       char *name;
 
 // check for changes to be sent over the reliable streams
        for (i = 0, host_client = svs.clients;i < svs.maxclients;i++, host_client++)
        {
                // update the host_client fields we care about according to the entity fields
                sv_player = EDICT_NUM(i+1);
-               s = PR_GetString(sv_player->v->netname);
-               if (s != host_client->name)
-               {
-                       if (s == NULL)
-                               s = "";
-                       // point the string back at host_client->name to keep it safe
-                       strlcpy (host_client->name, s, sizeof (host_client->name));
-                       sv_player->v->netname = PR_SetString(host_client->name);
-               }
-               if ((val = GETEDICTFIELDVALUE(sv_player, eval_clientcolors)) && host_client->colors != val->_float)
-                       host_client->colors = val->_float;
-               host_client->frags = sv_player->v->frags;
-               if (gamemode == GAME_NEHAHRA)
-                       if ((val = GETEDICTFIELDVALUE(sv_player, eval_pmodel)) && host_client->pmodel != val->_float)
-                               host_client->pmodel = val->_float;
-
-               // if the fields changed, send messages about the changes
+
+               // DP_SV_CLIENTNAME
+               name = PR_GetString(sv_player->v->netname);
+               if (name == NULL)
+                       name = "";
+               // always point the string back at host_client->name to keep it safe
+               strlcpy (host_client->name, name, sizeof (host_client->name));
+               sv_player->v->netname = PR_SetString(host_client->name);
                if (strcmp(host_client->old_name, host_client->name))
                {
+                       if (host_client->spawned)
+                               SV_BroadcastPrintf("%s changed name to %s\n", host_client->old_name, host_client->name);
                        strcpy(host_client->old_name, host_client->name);
-                       for (j = 0, client = svs.clients;j < svs.maxclients;j++, client++)
-                       {
-                               if (!client->spawned || !client->netconnection)
-                                       continue;
-                               MSG_WriteByte (&client->message, svc_updatename);
-                               MSG_WriteByte (&client->message, i);
-                               MSG_WriteString (&client->message, host_client->name);
-                       }
+                       // send notification to all clients
+                       MSG_WriteByte (&sv.reliable_datagram, svc_updatename);
+                       MSG_WriteByte (&sv.reliable_datagram, i);
+                       MSG_WriteString (&sv.reliable_datagram, host_client->name);
                }
+
+               // DP_SV_CLIENTCOLORS
+               // this is always found (since it's added by the progs loader)
+               if ((val = GETEDICTFIELDVALUE(sv_player, eval_clientcolors)))
+                       host_client->colors = (int)val->_float;
                if (host_client->old_colors != host_client->colors)
                {
                        host_client->old_colors = host_client->colors;
-                       for (j = 0, client = svs.clients;j < svs.maxclients;j++, client++)
-                       {
-                               if (!client->spawned || !client->netconnection)
-                                       continue;
-                               MSG_WriteByte (&client->message, svc_updatecolors);
-                               MSG_WriteByte (&client->message, i);
-                               MSG_WriteByte (&client->message, host_client->colors);
-                       }
+                       // send notification to all clients
+                       MSG_WriteByte (&sv.reliable_datagram, svc_updatecolors);
+                       MSG_WriteByte (&sv.reliable_datagram, i);
+                       MSG_WriteByte (&sv.reliable_datagram, host_client->colors);
                }
+
+               // frags
+               host_client->frags = (int)sv_player->v->frags;
                if (host_client->old_frags != host_client->frags)
                {
                        host_client->old_frags = host_client->frags;
-                       for (j = 0, client = svs.clients;j < svs.maxclients;j++, client++)
-                       {
-                               if (!client->spawned || !client->netconnection)
-                                       continue;
-                               MSG_WriteByte (&client->message, svc_updatefrags);
-                               MSG_WriteByte (&client->message, i);
-                               MSG_WriteShort (&client->message, host_client->frags);
-                       }
+                       // send notification to all clients
+                       MSG_WriteByte (&sv.reliable_datagram, svc_updatefrags);
+                       MSG_WriteByte (&sv.reliable_datagram, i);
+                       MSG_WriteShort (&sv.reliable_datagram, host_client->frags);
                }
        }