]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - sv_main.c
implemented QW gamedir switching and manual gamedir switching (via "gamedir" command...
[xonotic/darkplaces.git] / sv_main.c
index 0eaba842d06d120606ad102dad57aadb219884ee..1205fa0cb2596719b321d83bb12dad4b48aff09b 100644 (file)
--- a/sv_main.c
+++ b/sv_main.c
@@ -81,7 +81,7 @@ void SV_Init (void)
 {
        // init the csqc progs cvars, since they are updated/used by the server code
        // TODO: fix this since this is a quick hack to make some of [515]'s broken code run ;) [9/13/2006 Black]
-       extern cvar_t csqc_progname;
+       extern cvar_t csqc_progname;    //[515]: csqc crc check and right csprogs name according to progs.dat
        extern cvar_t csqc_progcrc;
        Cvar_RegisterVariable (&csqc_progname);
        Cvar_RegisterVariable (&csqc_progcrc);
@@ -299,8 +299,6 @@ CLIENT SPAWNING
 ==============================================================================
 */
 
-extern cvar_t csqc_progname;   //[515]: csqc crc check and right csprogs name according to progs.dat
-extern cvar_t csqc_progcrc;
 /*
 ================
 SV_SendServerinfo
@@ -349,16 +347,21 @@ void SV_SendServerinfo (client_t *client)
        MSG_WriteString (&client->netconnection->message,message);
 
        //[515]: init csprogs according to version of svprogs, check the crc, etc.
-       if (FS_FileExists(csqc_progname.string))
+       if (sv.csqc_progcrc >= 0)
        {
                prvm_eval_t *val;
-               MSG_WriteByte (&client->netconnection->message, svc_stufftext);
+               Con_DPrintf("sending csqc info to client (\"%s\" with crc %i)\n", sv.csqc_progname, sv.csqc_progcrc);
                //[515]: init stufftext string (it is sent before svc_serverinfo)
                val = PRVM_GETGLOBALFIELDVALUE(PRVM_ED_FindGlobalOffset("SV_InitCmd"));
+               MSG_WriteByte (&client->netconnection->message, svc_stufftext);
+               MSG_WriteString (&client->netconnection->message, va("csqc_progname %s\n", sv.csqc_progname));
+               MSG_WriteByte (&client->netconnection->message, svc_stufftext);
+               MSG_WriteString (&client->netconnection->message, va("csqc_progcrc %i\n", sv.csqc_progcrc));
                if (val)
-                       MSG_WriteString (&client->netconnection->message, va("csqc_progcrc %i\n%s\n", csqc_progcrc.integer, PRVM_GetString(val->string)));
-               else
-                       MSG_WriteString (&client->netconnection->message, va("csqc_progcrc %i\n", csqc_progcrc.integer));
+               {
+                       MSG_WriteByte (&client->netconnection->message, svc_stufftext);
+                       MSG_WriteString (&client->netconnection->message, va("%s\n", PRVM_GetString(val->string)));
+               }
        }
 
        MSG_WriteByte (&client->netconnection->message, svc_serverinfo);
@@ -1231,14 +1234,14 @@ void SV_SendClientDatagram (client_t *client)
        else
        {
                // PROTOCOL_DARKPLACES5 and later support packet size limiting of updates
-               maxrate = bound(NET_MINRATE, sv_maxrate.integer, NET_MAXRATE);
+               maxrate = max(NET_MINRATE, sv_maxrate.integer);
                if (sv_maxrate.integer != maxrate)
                        Cvar_SetValueQuick(&sv_maxrate, maxrate);
 
                // this rate limiting does not understand sys_ticrate 0
                // (but no one should be running that on a server!)
                rate = bound(NET_MINRATE, client->rate, maxrate);
-               rate = (int)(client->rate * sys_ticrate.value);
+               rate = (int)(rate * sys_ticrate.value);
                maxsize = bound(100, rate, 1400);
                maxsize2 = 1400;
        }
@@ -2191,6 +2194,8 @@ int eval_SendEntity;
 int eval_Version;
 int eval_customizeentityforclient;
 int eval_dphitcontentsmask;
+// DRESK - Support for Entity Contents Transition Event
+int eval_contentstransition;
 
 int gval_trace_dpstartcontents;
 int gval_trace_dphitcontents;
@@ -2267,6 +2272,8 @@ void SV_VM_FindEdictFieldOffsets(void)
        eval_Version = PRVM_ED_FindFieldOffset("Version");
        eval_customizeentityforclient = PRVM_ED_FindFieldOffset("customizeentityforclient");
        eval_dphitcontentsmask = PRVM_ED_FindFieldOffset("dphitcontentsmask");
+       // DRESK - Support for Entity Contents Transition Event
+       eval_contentstransition = PRVM_ED_FindFieldOffset("contentstransition");
 
        // LordHavoc: allowing QuakeC to override the player movement code
        SV_PlayerPhysicsQC = PRVM_ED_FindFunction ("SV_PlayerPhysics");
@@ -2346,13 +2353,16 @@ prvm_required_field_t reqfields[] =
        {ev_string, "playerskin"},
        {ev_function, "SendEntity"},
        {ev_function, "customizeentityforclient"},
+       // DRESK - Support for Entity Contents Transition Event
+       {ev_function, "contentstransition"},
 };
 
 void SV_VM_Setup(void)
 {
+       extern cvar_t csqc_progname;    //[515]: csqc crc check and right csprogs name according to progs.dat
+       extern cvar_t csqc_progcrc;
        unsigned char *csprogsdata;
        fs_offset_t csprogsdatasize;
-       unsigned int csprogsdatacrc;
        PRVM_Begin;
        PRVM_InitProg( PRVM_SERVERPROG );
 
@@ -2390,14 +2400,16 @@ void SV_VM_Setup(void)
        PRVM_End;
 
        // see if there is a csprogs.dat installed, and if so, set the csqc_progcrc accordingly, this will be sent to connecting clients to tell them to only load a matching csprogs.dat file
-       csprogsdatacrc = 0;
+       sv.csqc_progcrc = -1;
+       sv.csqc_progname[0] = 0;
        csprogsdata = FS_LoadFile(csqc_progname.string, tempmempool, true, &csprogsdatasize);
        if (csprogsdata)
        {
-               csprogsdatacrc = CRC_Block(csprogsdata, csprogsdatasize);
+               strlcpy(sv.csqc_progname, csqc_progname.string, sizeof(sv.csqc_progname));
+               sv.csqc_progcrc = CRC_Block(csprogsdata, csprogsdatasize);
                Mem_Free(csprogsdata);
+               Con_DPrintf("server detected csqc progs file \"%s\" with crc %i\n", sv.csqc_progname, sv.csqc_progcrc);
        }
-       Cvar_SetValueQuick(&csqc_progcrc, csprogsdatacrc);
 }
 
 void SV_VM_Begin(void)