]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
set csqc world.mins and world.maxs (reworked World_SetSize to make this
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Fri, 22 Feb 2008 05:30:33 +0000 (05:30 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Fri, 22 Feb 2008 05:30:33 +0000 (05:30 +0000)
easier)
moved the qc SV_Shutdown in Host_ShutdownServer to before clients are
kicked off
added qc SV_Shutdown call in SV_SpawnServer (before the progs reset)
fixed a bug with failed changelevel (which was unloading world)

git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@8122 d7cf8633-e32d-0410-b094-e92efae38249

cl_parse.c
csprogs.c
host.c
sv_main.c
world.c
world.h

index 7fd83d30c2de5c29a39b5b3fe548b1adec3ed69e..46c3c64b40c1eae393e79c8043ac978b3c970ed4 100644 (file)
@@ -397,9 +397,9 @@ static void CL_SetupWorldModel(void)
 
        // set up csqc world for collision culling
        if (cl.worldmodel)
-               World_SetSize(&cl.world, cl.worldmodel->normalmins, cl.worldmodel->normalmaxs);
+               World_SetSize(&cl.world, cl.worldmodel->name, cl.worldmodel->normalmins, cl.worldmodel->normalmaxs);
        else
-               World_SetSize(&cl.world, defaultmins, defaultmaxs);
+               World_SetSize(&cl.world, "", defaultmins, defaultmaxs);
 
        // load or reload .loc file for team chat messages
        CL_Locs_Reload_f();
index 7748ccf0d2b9f4552b7d7e9d60df223780bf1d14..670ec099b19ae26743eb7c1bb95607e99d3d88aa 100644 (file)
--- a/csprogs.c
+++ b/csprogs.c
@@ -756,13 +756,15 @@ void CL_VM_Init (void)
        // set time
        prog->globals.client->time = cl.time;
 
-       prog->globals.client->mapname = PRVM_SetEngineString(cl.worldmodel->name);
+       prog->globals.client->mapname = cl.worldmodel ? PRVM_SetEngineString(cl.worldmodel->name) : PRVM_SetEngineString("");
        prog->globals.client->player_localentnum = cl.playerentity;
 
        // set map description (use world entity 0)
        val = PRVM_EDICTFIELDVALUE(prog->edicts, prog->fieldoffsets.message);
        if(val)
                val->string = PRVM_SetEngineString(cl.levelname);
+       VectorCopy(cl.world.mins, prog->edicts->fields.client->mins);
+       VectorCopy(cl.world.maxs, prog->edicts->fields.client->maxs);
 
        // call the prog init
        PRVM_ExecuteProgram(prog->funcoffsets.CSQC_Init, "QC function CSQC_Init is missing");
diff --git a/host.c b/host.c
index c3c0b64ad77f3e318b38ab5442b16da02798ef79..0bafb91ad6076e4d898bd50d1966b92d399afdd5 100644 (file)
--- a/host.c
+++ b/host.c
@@ -528,9 +528,6 @@ void Host_ShutdownServer(void)
 
 // make sure all the clients know we're disconnecting
        SV_VM_Begin();
-       for (i = 0, host_client = svs.clients;i < svs.maxclients;i++, host_client++)
-               if (host_client->active)
-                       SV_DropClient(false); // server shutdown
        if(prog->loaded)
                if(prog->funcoffsets.SV_Shutdown)
                {
@@ -538,6 +535,9 @@ void Host_ShutdownServer(void)
                        prog->funcoffsets.SV_Shutdown = 0; // prevent it from getting called again
                        PRVM_ExecuteProgram(s,"SV_Shutdown() required");
                }
+       for (i = 0, host_client = svs.clients;i < svs.maxclients;i++, host_client++)
+               if (host_client->active)
+                       SV_DropClient(false); // server shutdown
        SV_VM_End();
 
        NetConn_CloseServerPorts();
index 08a362665455b5f028fc08493b021600897adb48..99096341c397974dfad8a572a6173266ea5e9060 100644 (file)
--- a/sv_main.c
+++ b/sv_main.c
@@ -798,7 +798,7 @@ void SV_SendServerinfo (client_t *client)
        client->clientcamera = PRVM_NUM_FOR_EDICT(client->edict);
        MSG_WriteByte (&client->netconnection->message, svc_setview);
        MSG_WriteShort (&client->netconnection->message, client->clientcamera);
-       
+
        MSG_WriteByte (&client->netconnection->message, svc_signonnum);
        MSG_WriteByte (&client->netconnection->message, 1);
 
@@ -2484,13 +2484,32 @@ void SV_SpawnServer (const char *server)
 
        Con_DPrintf("SpawnServer: %s\n", server);
 
+       dpsnprintf (modelname, sizeof(modelname), "maps/%s.bsp", server);
+
+       if (!FS_FileExists(modelname))
+       {
+               Con_Printf("SpawnServer: no map file named %s\n", modelname);
+               return;
+       }
+
        if (cls.state != ca_dedicated)
        {
                SCR_BeginLoadingPlaque();
                S_StopAllSounds();
        }
 
-       dpsnprintf (modelname, sizeof(modelname), "maps/%s.bsp", server);
+       if(sv.active)
+       {
+               SV_VM_Begin();
+               if(prog->funcoffsets.SV_Shutdown)
+               {
+                       func_t s = prog->funcoffsets.SV_Shutdown;
+                       prog->funcoffsets.SV_Shutdown = 0; // prevent it from getting called again
+                       PRVM_ExecuteProgram(s,"SV_Shutdown() required");
+               }
+               SV_VM_End();
+       }
+
        worldmodel = Mod_ForName(modelname, false, true, true);
        if (!worldmodel || !worldmodel->TraceBox)
        {
@@ -2606,7 +2625,7 @@ void SV_SpawnServer (const char *server)
 //
 // clear world interaction links
 //
-       World_SetSize(&sv.world, sv.worldmodel->normalmins, sv.worldmodel->normalmaxs);
+       World_SetSize(&sv.world, sv.worldmodel->name, sv.worldmodel->normalmins, sv.worldmodel->normalmaxs);
 
        strlcpy(sv.sound_precache[0], "", sizeof(sv.sound_precache[0]));
 
@@ -2629,10 +2648,10 @@ void SV_SpawnServer (const char *server)
        ent->fields.server->modelindex = 1;             // world model
        ent->fields.server->solid = SOLID_BSP;
        ent->fields.server->movetype = MOVETYPE_PUSH;
-       VectorCopy(sv.worldmodel->normalmins, ent->fields.server->mins);
-       VectorCopy(sv.worldmodel->normalmaxs, ent->fields.server->maxs);
-       VectorCopy(sv.worldmodel->normalmins, ent->fields.server->absmin);
-       VectorCopy(sv.worldmodel->normalmaxs, ent->fields.server->absmax);
+       VectorCopy(sv.world.mins, ent->fields.server->mins);
+       VectorCopy(sv.world.maxs, ent->fields.server->maxs);
+       VectorCopy(sv.world.mins, ent->fields.server->absmin);
+       VectorCopy(sv.world.maxs, ent->fields.server->absmax);
 
        if (coop.value)
                prog->globals.server->coop = coop.integer;
diff --git a/world.c b/world.c
index f332f0399c52ea5f221237d4c383708bae3ae2fa..a9192494a5535e31cb2b25fc5668aa2dd846cbd5 100644 (file)
--- a/world.c
+++ b/world.c
@@ -80,9 +80,14 @@ World_SetSize
 
 ===============
 */
-void World_SetSize(world_t *world, const vec3_t mins, const vec3_t maxs)
+void World_SetSize(world_t *world, const char *filename, const vec3_t mins, const vec3_t maxs)
 {
        int i;
+
+       strlcpy(world->filename, filename, sizeof(world->filename));
+       VectorCopy(mins, world->mins);
+       VectorCopy(maxs, world->maxs);
+
        // the areagrid_marknumber is not allowed to be 0
        if (world->areagrid_marknumber < 1)
                world->areagrid_marknumber = 1;
diff --git a/world.h b/world.h
index 1d16b74882c553172ce165d7f308eb185b43b36f..216e67c9c4e7e9a90d587319dec910b7035ed3a4 100644 (file)
--- a/world.h
+++ b/world.h
@@ -41,6 +41,11 @@ typedef struct link_s
 
 typedef struct world_s
 {
+       // convenient fields
+       char filename[MAX_QPATH];
+       vec3_t mins;
+       vec3_t maxs;
+
        int areagrid_stats_calls;
        int areagrid_stats_nodechecks;
        int areagrid_stats_entitychecks;
@@ -66,7 +71,7 @@ void World_InsertLinkBefore(link_t *l, link_t *before, int entitynumber);
 void World_Init(void);
 
 // called after the world model has been loaded, before linking any entities
-void World_SetSize(world_t *world, const vec3_t mins, const vec3_t maxs);
+void World_SetSize(world_t *world, const char *filename, const vec3_t mins, const vec3_t maxs);
 // unlinks all entities (used before reallocation of edicts)
 void World_UnlinkAll(world_t *world);