]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - sv_main.c
Fix a possible divide by zero in Mod_PSKMODEL_Load.
[xonotic/darkplaces.git] / sv_main.c
index 1a48d15bacf79e2e959692ad98044fd3380c70b0..ea6cce396b6cec932f255446b12e5c926fb9ff8b 100644 (file)
--- a/sv_main.c
+++ b/sv_main.c
@@ -711,6 +711,7 @@ void SV_Init (void)
        sv_mempool = Mem_AllocPool("server", 0, NULL);
 
        SV_ServerOptions();
+       Cvar_Callback(&sv_netport);
 }
 
 static void SV_SaveEntFile_f(cmd_state_t *cmd)
@@ -1791,15 +1792,6 @@ void SV_SpawnServer (const char *map)
 
        if(sv.active)
        {
-               client_t *client;
-               for (i = 0, client = svs.clients;i < svs.maxclients;i++, client++)
-               {
-                       if (client->netconnection)
-                       {
-                               MSG_WriteByte(&client->netconnection->message, svc_stufftext);
-                               MSG_WriteString(&client->netconnection->message, "reconnect\n");
-                       }
-               }
                World_End(&sv.world);
                if(PRVM_serverfunction(SV_Shutdown))
                {
@@ -1842,8 +1834,23 @@ void SV_SpawnServer (const char *map)
 //
 // tell all connected clients that we are going to a new level
 //
-       if (!sv.active)
+       if (sv.active)
+       {
+               client_t *client;
+               for (i = 0, client = svs.clients;i < svs.maxclients;i++, client++)
+               {
+                       if (client->netconnection)
+                       {
+                               MSG_WriteByte(&client->netconnection->message, svc_stufftext);
+                               MSG_WriteString(&client->netconnection->message, "reconnect\n");
+                       }
+               }
+       }
+       else
+       {
+               // open server port
                NetConn_OpenServerPorts(true);
+       }
 
 //
 // make cvars consistant
@@ -2263,7 +2270,7 @@ static qbool SVVM_load_edict(prvm_prog_t *prog, prvm_edict_t *ent)
 static void SV_VM_Setup(void)
 {
        prvm_prog_t *prog = SVVM_prog;
-       PRVM_Prog_Init(prog, cmd_server);
+       PRVM_Prog_Init(prog, cmd_local);
 
        // allocate the mempools
        // TODO: move the magic numbers/constants into #defines [9/13/2006 Black]
@@ -2459,7 +2466,11 @@ static void SV_CheckTimeouts(void)
        {
                if (host_client->netconnection && host.realtime > host_client->netconnection->timeout)
                {
-                       Con_Printf("Client \"%s\" connection timed out\n", host_client->name);
+                       if (host_client->begun)
+                               SV_BroadcastPrintf("Client \"%s\" connection timed out\n", host_client->name);
+                       else
+                               Con_Printf("Client \"%s\" connection timed out\n", host_client->name);
+
                        SV_DropClient(false);
                }
        }