]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - sv_main.c
more warning fixes
[xonotic/darkplaces.git] / sv_main.c
index ff2bfe56b94952eaad508740efb91192f0b06d52..7c3f7f1b021e225e773be951db209667a4dc12b2 100644 (file)
--- a/sv_main.c
+++ b/sv_main.c
@@ -25,7 +25,7 @@ void SV_VM_Init();
 void SV_VM_Setup();
 
 // select which protocol to host, this is fed to Protocol_EnumForName
-cvar_t sv_protocolname = {0, "sv_protocolname", "DP6"};
+cvar_t sv_protocolname = {0, "sv_protocolname", "DP7"};
 cvar_t sv_ratelimitlocalplayer = {0, "sv_ratelimitlocalplayer", "0"};
 cvar_t sv_maxrate = {CVAR_SAVE | CVAR_NOTIFY, "sv_maxrate", "10000"};
 
@@ -110,7 +110,7 @@ static void SV_SaveEntFile_f(void)
                return;
        }
        FS_StripExtension(sv.worldmodel->name, basename, sizeof(basename));
-       FS_WriteFile(va("%s.ent", basename), sv.worldmodel->brush.entities, strlen(sv.worldmodel->brush.entities));
+       FS_WriteFile(va("%s.ent", basename), sv.worldmodel->brush.entities, (fs_offset_t)strlen(sv.worldmodel->brush.entities));
 }
 
 
@@ -209,13 +209,22 @@ void SV_StartSound (prvm_edict_t *entity, int channel, const char *sample, int v
        int sound_num, field_mask, i, ent;
 
        if (volume < 0 || volume > 255)
-               Host_Error ("SV_StartSound: volume = %i", volume);
+       {
+               Con_Printf ("SV_StartSound: volume = %i", volume);
+               return;
+       }
 
        if (attenuation < 0 || attenuation > 4)
-               Host_Error ("SV_StartSound: attenuation = %f", attenuation);
+       {
+               Con_Printf ("SV_StartSound: attenuation = %f", attenuation);
+               return;
+       }
 
        if (channel < 0 || channel > 7)
-               Host_Error ("SV_StartSound: channel = %i", channel);
+       {
+               Con_Printf ("SV_StartSound: channel = %i", channel);
+               return;
+       }
 
        if (sv.datagram.cursize > MAX_PACKETFRAGMENT-21)
                return;
@@ -408,6 +417,8 @@ void SV_ConnectClient (int clientnum, netconn_t *netconnection)
        else
        {
                // call the progs to get default spawn parms for the new client
+               // set self to world to intentionally cause errors with broken SetNewParms code in some mods
+               prog->globals.server->self = 0;
                PRVM_ExecuteProgram (prog->globals.server->SetNewParms, "QC function SetNewParms is missing");
                for (i=0 ; i<NUM_SPAWN_PARMS ; i++)
                        client->spawn_parms[i] = (&prog->globals.server->parm1)[i];
@@ -1637,7 +1648,7 @@ void SV_SpawnServer (const char *server)
 //
 // tell all connected clients that we are going to a new level
 //
-       if (sv.active) 
+       if (sv.active)
        {
                SV_VM_Begin();
                SV_SendReconnect();
@@ -1725,6 +1736,7 @@ void SV_SpawnServer (const char *server)
        //prog->num_edicts = svs.maxclients+1;
 
        sv.state = ss_loading;
+       prog->allowworldwrites = true;
        sv.paused = false;
 
        *prog->time = sv.time = 1.0;
@@ -1755,7 +1767,7 @@ void SV_SpawnServer (const char *server)
 //
 // load the rest of the entities
 //
-       // AK possible hack since num_edicts is still 0 
+       // AK possible hack since num_edicts is still 0
        ent = PRVM_EDICT_NUM(0);
        memset (ent->fields.server, 0, prog->progs->entityfields * 4);
        ent->priv.server->free = false;
@@ -1795,6 +1807,7 @@ void SV_SpawnServer (const char *server)
 
 // all setup is completed, any further precache statements are errors
        sv.state = ss_active;
+       prog->allowworldwrites = false;
 
 // run two frames to allow everything to settle
        for (i = 0;i < 2;i++)
@@ -1867,7 +1880,7 @@ void SV_VM_CB_InitEdict(prvm_edict_t *e)
                e->fields.server->colormap = num + 1;
                e->fields.server->team = (svs.clients[num].colors & 15) + 1;
                // set netname/clientcolors back to client values so that
-               // DP_SV_CLIENTNAME and DPV_SV_CLIENTCOLORS will not immediately
+               // DP_SV_CLIENTNAME and DP_SV_CLIENTCOLORS will not immediately
                // reset them
                e->fields.server->netname = PRVM_SetEngineString(svs.clients[num].name);
                if ((val = PRVM_GETEDICTFIELDVALUE(e, eval_clientcolors)))
@@ -1924,7 +1937,7 @@ void SV_VM_CB_CountEdicts(void)
        Con_Printf("step      :%3i\n", step);
 }
 
-qboolean SV_VM_CB_LoadEdict(prvm_edict_t *ent) 
+qboolean SV_VM_CB_LoadEdict(prvm_edict_t *ent)
 {
        // remove things from different skill levels or deathmatch
        if (gamemode != GAME_TRANSFUSION) //Transfusion does this in QC
@@ -1946,6 +1959,7 @@ qboolean SV_VM_CB_LoadEdict(prvm_edict_t *ent)
        return true;
 }
 
+cvar_t pr_checkextension = {CVAR_READONLY, "pr_checkextension", "1"};
 cvar_t nomonsters = {0, "nomonsters", "0"};
 cvar_t gamecfg = {0, "gamecfg", "0"};
 cvar_t scratch1 = {0, "scratch1", "0"};
@@ -1972,6 +1986,7 @@ cvar_t    cutscene = {0, "cutscene", "1"};
 
 void SV_VM_Init(void)
 {
+       Cvar_RegisterVariable (&pr_checkextension);
        Cvar_RegisterVariable (&nomonsters);
        Cvar_RegisterVariable (&gamecfg);
        Cvar_RegisterVariable (&scratch1);
@@ -2205,7 +2220,7 @@ void SV_VM_Setup(void)
        prog->load_edict = SV_VM_CB_LoadEdict;
        prog->init_cmd = VM_SV_Cmd_Init;
        prog->reset_cmd = VM_SV_Cmd_Reset;
-       prog->error_cmd = NULL; // change this 
+       prog->error_cmd = Host_Error;
 
        // TODO: add a requiredfuncs list (ask LH if this is necessary at all)
        PRVM_LoadProgs( sv_progs.string, 0, NULL, REQFIELDS, reqfields );
@@ -2225,4 +2240,4 @@ void SV_VM_Begin(void)
 void SV_VM_End(void)
 {
        PRVM_End;
-}
\ No newline at end of file
+}