]> de.git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
rearrange SV_VM_Begin/End again to fix crashes
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 23 Feb 2006 16:04:24 +0000 (16:04 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 23 Feb 2006 16:04:24 +0000 (16:04 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@6018 d7cf8633-e32d-0410-b094-e92efae38249

cl_input.c
host_cmd.c
netconn.c
sv_user.c

index 19441cc1533e9dc8b9f9d2812849591a8bc1f703..8e9d0ecb20040c8c671f57f084df557f124f5298 100644 (file)
@@ -857,7 +857,8 @@ void CL_SendMove(void)
        upmove = cl.cmd.upmove;
 #endif
 
-       CL_UpdatePrydonCursor();
+       if (cls.signon == SIGNONS)
+               CL_UpdatePrydonCursor();
 
        buf.maxsize = 128;
        buf.cursize = 0;
index 70572dab2d1783567803d7ec5fbe48cc91aa5527..2c5d185fd52a36350072d2289b91895e820de5fd 100644 (file)
@@ -280,11 +280,7 @@ void Host_Map_f (void)
        strcpy(level, Cmd_Argv(1));
        SV_SpawnServer(level);
        if (sv.active && cls.state == ca_disconnected)
-       {
-               SV_VM_Begin();
                CL_EstablishConnection("local:1");
-               SV_VM_End();
-       }
 }
 
 /*
@@ -327,11 +323,7 @@ void Host_Changelevel_f (void)
        strcpy(level, Cmd_Argv(1));
        SV_SpawnServer(level);
        if (sv.active && cls.state == ca_disconnected)
-       {
-               SV_VM_Begin();
                CL_EstablishConnection("local:1");
-               SV_VM_End();
-       }
 }
 
 /*
@@ -366,11 +358,7 @@ void Host_Restart_f (void)
        strcpy(mapname, sv.name);
        SV_SpawnServer(mapname);
        if (sv.active && cls.state == ca_disconnected)
-       {
-               SV_VM_Begin();
                CL_EstablishConnection("local:1");
-               SV_VM_End();
-       }
 }
 
 /*
@@ -415,13 +403,7 @@ void Host_Connect_f (void)
                Con_Print("connect <serveraddress> : connect to a multiplayer game\n");
                return;
        }
-       if( sv.active ) {
-               SV_VM_Begin();
-               CL_EstablishConnection(Cmd_Argv(1));
-               SV_VM_End();
-       } else {
-               CL_EstablishConnection(Cmd_Argv(1));
-       }
+       CL_EstablishConnection(Cmd_Argv(1));
 }
 
 
@@ -737,11 +719,11 @@ void Host_Loadgame_f (void)
        for (i = 0;i < NUM_SPAWN_PARMS;i++)
                svs.clients[0].spawn_parms[i] = spawn_parms[i];
 
+       SV_VM_End();
+
        // make sure we're connected to loopback
        if (cls.state == ca_disconnected || !(cls.state == ca_connected && cls.netcon != NULL && LHNETADDRESS_GetAddressType(&cls.netcon->peeraddress) == LHNETADDRESSTYPE_LOOP))
                CL_EstablishConnection("local:1");
-
-       SV_VM_End();
 }
 
 //============================================================================
@@ -790,7 +772,6 @@ void Host_Name_f (void)
        host_client->nametime = sv.time + 5;
 
        // point the string back at updateclient->name to keep it safe
-       SV_VM_Begin();
        strlcpy (host_client->name, newName, sizeof (host_client->name));
        host_client->edict->fields.server->netname = PRVM_SetEngineString(host_client->name);
        if (strcmp(host_client->old_name, host_client->name))
@@ -803,7 +784,6 @@ void Host_Name_f (void)
                MSG_WriteByte (&sv.reliable_datagram, host_client - svs.clients);
                MSG_WriteString (&sv.reliable_datagram, host_client->name);
        }
-       SV_VM_End();
 }
 
 /*
@@ -852,7 +832,6 @@ void Host_Playermodel_f (void)
        host_client->nametime = sv.time + 5;
        */
 
-       SV_VM_Begin();
        // point the string back at updateclient->name to keep it safe
        strlcpy (host_client->playermodel, newPath, sizeof (host_client->playermodel));
        if( eval_playermodel )
@@ -865,7 +844,6 @@ void Host_Playermodel_f (void)
                MSG_WriteByte (&sv.reliable_datagram, host_client - svs.clients);
                MSG_WriteString (&sv.reliable_datagram, host_client->playermodel);*/
        }
-       SV_VM_End();
 }
 
 /*
@@ -913,7 +891,6 @@ void Host_Playerskin_f (void)
        host_client->nametime = sv.time + 5;
        */
 
-       SV_VM_Begin();
        // point the string back at updateclient->name to keep it safe
        strlcpy (host_client->playerskin, newPath, sizeof (host_client->playerskin));
        if( eval_playerskin )
@@ -928,7 +905,6 @@ void Host_Playerskin_f (void)
                MSG_WriteByte (&sv.reliable_datagram, host_client - svs.clients);
                MSG_WriteString (&sv.reliable_datagram, host_client->playerskin);*/
        }
-       SV_VM_End();
 }
 
 void Host_Version_f (void)
@@ -1122,7 +1098,6 @@ void Host_Color_f(void)
                return;
        }
 
-       SV_VM_Begin();
        if (host_client->edict && (f = PRVM_ED_FindFunction ("SV_ChangeTeam")) && (SV_ChangeTeam = (func_t)(f - prog->functions)))
        {
                Con_DPrint("Calling SV_ChangeTeam\n");
@@ -1150,7 +1125,6 @@ void Host_Color_f(void)
                        MSG_WriteByte (&sv.reliable_datagram, host_client->colors);
                }
        }
-       SV_VM_End();
 }
 
 cvar_t cl_rate = {CVAR_SAVE, "_cl_rate", "10000", "internal storage cvar for current rate (changed by rate command)"};
@@ -1197,11 +1171,9 @@ void Host_Kill_f (void)
                return;
        }
 
-       SV_VM_Begin();
        prog->globals.server->time = sv.time;
        prog->globals.server->self = PRVM_EDICT_TO_PROG(host_client->edict);
        PRVM_ExecuteProgram (prog->globals.server->ClientKill, "QC function ClientKill is missing");
-       SV_VM_End();
 }
 
 
@@ -1260,10 +1232,8 @@ static void Host_PModel_f (void)
                return;
        }
 
-       SV_VM_Begin();
        if (host_client->edict && (val = PRVM_GETEDICTFIELDVALUE(host_client->edict, eval_pmodel)))
                val->_float = i;
-       SV_VM_End();
 }
 
 //===========================================================================
@@ -1334,7 +1304,6 @@ void Host_Spawn_f (void)
        //      SZ_Clear (&host_client->netconnection->message);
 
        // run the entrance script
-       SV_VM_Begin();
        if (sv.loadgame)
        {
                // loaded games are fully initialized already
@@ -1369,12 +1338,10 @@ void Host_Spawn_f (void)
 
                PRVM_ExecuteProgram (prog->globals.server->PutClientInServer, "QC function PutClientInServer is missing");
        }
-       SV_VM_End();
 
        if (!host_client->netconnection)
                return;
 
-       SV_VM_Begin();
        // send time of update
        MSG_WriteByte (&host_client->netconnection->message, svc_time);
        MSG_WriteFloat (&host_client->netconnection->message, sv.time);
@@ -1437,7 +1404,6 @@ void Host_Spawn_f (void)
 
        MSG_WriteByte (&host_client->netconnection->message, svc_signonnum);
        MSG_WriteByte (&host_client->netconnection->message, 3);
-       SV_VM_End();
 }
 
 /*
@@ -1573,7 +1539,6 @@ void Host_Give_f (void)
        t = Cmd_Argv(1);
        v = atoi (Cmd_Argv(2));
 
-       SV_VM_Begin();
        switch (t[0])
        {
        case '0':
@@ -1703,7 +1668,6 @@ void Host_Give_f (void)
                }
                break;
        }
-       SV_VM_End();
 }
 
 prvm_edict_t   *FindViewthing (void)
index e912595378a964882d1602a9a7587218d0fe05a9..74ba01ba951e988b9d822be4e33f53530c4a2e7d 100755 (executable)
--- a/netconn.c
+++ b/netconn.c
@@ -1829,7 +1829,9 @@ static int NetConn_ServerParsePacket(lhnetsocket_t *mysocket, unsigned char *dat
                {
                        if ((ret = NetConn_ReceivedMessage(host_client->netconnection, data, length)) == 2)
                        {
+                               SV_VM_Begin();
                                SV_ReadClientMessage();
+                               SV_VM_End();
                                return ret;
                        }
                }
index cddaf7f708bf359ef55b4fc97a567c54defc0beb..966c0551366c965cbe14d2089912485f51449531 100644 (file)
--- a/sv_user.c
+++ b/sv_user.c
@@ -609,8 +609,6 @@ qboolean SV_ReadClientMove (void)
        double oldmovetime;
        usercmd_t *move = &host_client->cmd;
 
-       SV_VM_Begin();
-
        oldmovetime = move->time;
 
        // if this move has been applied, clear it, and start accumulating new data
@@ -714,7 +712,6 @@ qboolean SV_ReadClientMove (void)
                        prog->globals.server->frametime = oldframetime;
                }
        }
-       SV_VM_End();
        return kickplayer;
 }