X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=sv_main.c;h=5551acb51b9660bf919465bf001445bad0bc9ef8;hb=92fe331d49472a9d956faded7f320204d88a020a;hp=f810e5b91a0a9fdf93e0af0736cfc549e2684fff;hpb=197da0b9148dfb2d1b16457df1ba1c08b86ff9c2;p=xonotic%2Fdarkplaces.git diff --git a/sv_main.c b/sv_main.c index f810e5b9..5551acb5 100644 --- a/sv_main.c +++ b/sv_main.c @@ -25,6 +25,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "csprogs.h" #include "thread.h" +// current client +client_t *host_client; + static void SV_SaveEntFile_f(cmd_state_t *cmd); static void SV_StartDownload_f(cmd_state_t *cmd); static void SV_Download_f(cmd_state_t *cmd); @@ -414,13 +417,10 @@ prvm_required_field_t sv_reqglobals[] = #undef PRVM_DECLARE_function }; -static void Host_Timescale_c(char *string) +static void Host_Timescale_c(cvar_t *var) { - double value; - value = atof(string); - - if(value < 0.00001 && value != 0) - string[0] = '0', string[1] = 0; + if(var->value < 0.00001 && var->value != 0) + Cvar_SetValueQuick(var, 0); } //============================================================================ @@ -3406,7 +3406,7 @@ This is called at the start of each level ================ */ -void SV_SpawnServer (const char *server) +void SV_SpawnServer (const char *map) { prvm_prog_t *prog = SVVM_prog; prvm_edict_t *ent; @@ -3416,16 +3416,16 @@ void SV_SpawnServer (const char *server) char modelname[sizeof(sv.worldname)]; char vabuf[1024]; - Con_DPrintf("SpawnServer: %s\n", server); + Con_DPrintf("SpawnServer: %s\n", map); - dpsnprintf (modelname, sizeof(modelname), "maps/%s.bsp", server); + dpsnprintf (modelname, sizeof(modelname), "maps/%s.bsp", map); if (!FS_FileExists(modelname)) { - dpsnprintf (modelname, sizeof(modelname), "maps/%s", server); + dpsnprintf (modelname, sizeof(modelname), "maps/%s", map); if (!FS_FileExists(modelname)) { - Con_Printf("SpawnServer: no map file named maps/%s.bsp\n", server); + Con_Printf("SpawnServer: no map file named maps/%s.bsp\n", map); return; } } @@ -3443,6 +3443,15 @@ void SV_SpawnServer (const char *server) 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)) { @@ -3485,23 +3494,8 @@ void SV_SpawnServer (const char *server) // // tell all connected clients that we are going to a new level // - 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 + if (!sv.active) NetConn_OpenServerPorts(true); - } // // make cvars consistant @@ -3536,7 +3530,7 @@ void SV_SpawnServer (const char *server) sv.active = true; // set level base name variables for later use - strlcpy (sv.name, server, sizeof (sv.name)); + strlcpy (sv.name, map, sizeof (sv.name)); strlcpy(sv.worldname, modelname, sizeof(sv.worldname)); FS_StripExtension(sv.worldname, sv.worldnamenoextension, sizeof(sv.worldnamenoextension)); strlcpy(sv.worldbasename, !strncmp(sv.worldnamenoextension, "maps/", 5) ? sv.worldnamenoextension + 5 : sv.worldnamenoextension, sizeof(sv.worldbasename));