*/
static void SV_Map_f(cmd_state_t *cmd)
{
- char level[MAX_QPATH];
-
if (Cmd_Argc(cmd) != 2)
{
Con_Print("map <levelname> : start a new game (kicks off all players)\n");
Cvar_Set(&cvars_all, "warpmark", "");
if(host.hook.Disconnect)
- host.hook.Disconnect();
+ host.hook.Disconnect(false, NULL);
SV_Shutdown();
host.hook.ToggleMenu();
svs.serverflags = 0; // haven't completed an episode yet
- strlcpy(level, Cmd_Argv(cmd, 1), sizeof(level));
- SV_SpawnServer(level);
+ SV_SpawnServer(Cmd_Argv(cmd, 1));
if(sv.active && host.hook.ConnectLocal != NULL)
host.hook.ConnectLocal();
*/
static void SV_Changelevel_f(cmd_state_t *cmd)
{
- char level[MAX_QPATH];
-
if (Cmd_Argc(cmd) != 2)
{
Con_Print("changelevel <levelname> : continue game on a new level\n");
if (!sv.active)
{
- Con_Printf("You must be running a server to changelevel. Use 'map %s' instead\n", Cmd_Argv(cmd, 1));
+ SV_Map_f(cmd);
return;
}
host.hook.ToggleMenu();
SV_SaveSpawnparms ();
- strlcpy(level, Cmd_Argv(cmd, 1), sizeof(level));
- SV_SpawnServer(level);
+ SV_SpawnServer(Cmd_Argv(cmd, 1));
if(sv.active && host.hook.ConnectLocal != NULL)
host.hook.ConnectLocal();
*/
static void SV_Restart_f(cmd_state_t *cmd)
{
- char mapname[MAX_QPATH];
-
if (Cmd_Argc(cmd) != 1)
{
Con_Print("restart : restart current level\n");
if(host.hook.ToggleMenu)
host.hook.ToggleMenu();
- strlcpy(mapname, sv.name, sizeof(mapname));
- SV_SpawnServer(mapname);
+ SV_SpawnServer(sv.worldbasename);
if(sv.active && host.hook.ConnectLocal != NULL)
host.hook.ConnectLocal();
static void SV_DisableCheats_c(cvar_t *var)
{
prvm_prog_t *prog = SVVM_prog;
- int i = 0;
+ int i;
- if (var->value == 0)
+ if (prog->loaded && var->value == 0)
{
- while (svs.clients[i].edict)
+ for (i = 0; i < svs.maxclients; ++i)
{
if (((int)PRVM_serveredictfloat(svs.clients[i].edict, flags) & FL_GODMODE))
PRVM_serveredictfloat(svs.clients[i].edict, flags) = (int)PRVM_serveredictfloat(svs.clients[i].edict, flags) ^ FL_GODMODE;
noclip_anglehack = false;
PRVM_serveredictfloat(svs.clients[i].edict, movetype) = MOVETYPE_WALK;
}
- i++;
}
}
}
p2[-1] = 0;
p2--;
}
- strlcat(text, "\n", sizeof(text));
+ dp_strlcat(text, "\n", sizeof(text));
// note: save is not a valid edict if fromServer is true
save = host_client;
for (players = 0, i = 0;i < svs.maxclients;i++)
if (svs.clients[i].active)
players++;
+
print ("host: %s\n", Cvar_VariableString (&cvars_all, "hostname", CF_SERVER));
- print ("version: %s build %s (gamename %s)\n", gamename, buildstring, gamenetworkfiltername);
+ print ("version: %s\n", engineversion);
print ("protocol: %i (%s)\n", Protocol_NumberForEnum(sv.protocol), Protocol_NameForEnum(sv.protocol));
- print ("map: %s\n", sv.name);
- print ("timing: %s\n", Host_TimingReport(vabuf, sizeof(vabuf)));
+ print ("map: %s\n", sv.worldbasename);
+ print ("timing: %s\n", SV_TimingReport(vabuf, sizeof(vabuf)));
print ("players: %i active (%i max)\n\n", players, svs.maxclients);
if (in == 1)
}
if(sv_status_privacy.integer && cmd->source != src_local && LHNETADDRESS_GetAddressType(&host_client->netconnection->peeraddress) != LHNETADDRESSTYPE_LOOP)
- strlcpy(ip, client->netconnection ? "hidden" : "botclient", 48);
+ dp_strlcpy(ip, client->netconnection ? "hidden" : "botclient", 48);
else
- strlcpy(ip, (client->netconnection && *client->netconnection->address) ? client->netconnection->address : "botclient", 48);
+ dp_strlcpy(ip, (client->netconnection && *client->netconnection->address) ? client->netconnection->address : "botclient", 48);
frags = client->frags;
{
if (host_client->begun)
SV_BroadcastPrintf("\003%s ^7changed name to ^3%s\n", host_client->old_name, host_client->name);
- strlcpy(host_client->old_name, host_client->name, sizeof(host_client->old_name));
+ dp_strlcpy(host_client->old_name, host_client->name, sizeof(host_client->old_name));
// send notification to all clients
MSG_WriteByte (&sv.reliable_datagram, svc_updatename);
MSG_WriteByte (&sv.reliable_datagram, clientnum);
else
newNameSource = Cmd_Args(cmd);
- strlcpy(newName, newNameSource, sizeof(newName));
+ dp_strlcpy(newName, newNameSource, sizeof(newName));
if (cmd->source == src_local)
return;
host_client->nametime = host.realtime + max(0.0f, sv_namechangetimer.value);
// point the string back at updateclient->name to keep it safe
- strlcpy (host_client->name, newName, sizeof (host_client->name));
+ dp_strlcpy (host_client->name, newName, sizeof (host_client->name));
for (i = 0, j = 0;host_client->name[i];i++)
if (host_client->name[i] != '\r' && host_client->name[i] != '\n')
{
const char *who;
const char *message = NULL;
+ char reason[512];
client_t *save;
int i;
qbool byNumber = false;
message++;
}
if (message)
- SV_ClientPrintf("Kicked by %s: %s\n", who, message);
+ SV_DropClient (false, va(reason, sizeof(reason), "Kicked by %s: %s", who, message)); // kicked
+ //SV_ClientPrintf("Kicked by %s: %s\n", who, message);
else
- SV_ClientPrintf("Kicked by %s\n", who);
- SV_DropClient (false); // kicked
+ //SV_ClientPrintf("Kicked by %s\n", who);
+ SV_DropClient (false, va(reason, sizeof(reason), "Kicked by %s", who)); // kicked
}
host_client = save;
return;
if (Cmd_Argc (cmd) == 2)
- strlcpy (newPath, Cmd_Argv(cmd, 1), sizeof (newPath));
+ dp_strlcpy (newPath, Cmd_Argv(cmd, 1), sizeof (newPath));
else
- strlcpy (newPath, Cmd_Args(cmd), sizeof (newPath));
+ dp_strlcpy (newPath, Cmd_Args(cmd), sizeof (newPath));
for (i = 0, j = 0;newPath[i];i++)
if (newPath[i] != '\r' && newPath[i] != '\n')
*/
// point the string back at updateclient->name to keep it safe
- strlcpy (host_client->playermodel, newPath, sizeof (host_client->playermodel));
+ dp_strlcpy (host_client->playermodel, newPath, sizeof (host_client->playermodel));
PRVM_serveredictstring(host_client->edict, playermodel) = PRVM_SetEngineString(prog, host_client->playermodel);
if (strcmp(host_client->old_model, host_client->playermodel))
{
- strlcpy(host_client->old_model, host_client->playermodel, sizeof(host_client->old_model));
+ dp_strlcpy(host_client->old_model, host_client->playermodel, sizeof(host_client->old_model));
/*// send notification to all clients
MSG_WriteByte (&sv.reliable_datagram, svc_updatepmodel);
MSG_WriteByte (&sv.reliable_datagram, host_client - svs.clients);
return;
if (Cmd_Argc (cmd) == 2)
- strlcpy (newPath, Cmd_Argv(cmd, 1), sizeof (newPath));
+ dp_strlcpy (newPath, Cmd_Argv(cmd, 1), sizeof (newPath));
else
- strlcpy (newPath, Cmd_Args(cmd), sizeof (newPath));
+ dp_strlcpy (newPath, Cmd_Args(cmd), sizeof (newPath));
for (i = 0, j = 0;newPath[i];i++)
if (newPath[i] != '\r' && newPath[i] != '\n')
*/
// point the string back at updateclient->name to keep it safe
- strlcpy (host_client->playerskin, newPath, sizeof (host_client->playerskin));
+ dp_strlcpy (host_client->playerskin, newPath, sizeof (host_client->playerskin));
PRVM_serveredictstring(host_client->edict, playerskin) = PRVM_SetEngineString(prog, host_client->playerskin);
if (strcmp(host_client->old_skin, host_client->playerskin))
{
//if (host_client->begun)
// SV_BroadcastPrintf("%s changed skin to %s\n", host_client->name, host_client->playerskin);
- strlcpy(host_client->old_skin, host_client->playerskin, sizeof(host_client->old_skin));
+ dp_strlcpy(host_client->old_skin, host_client->playerskin, sizeof(host_client->old_skin));
/*// send notification to all clients
MSG_WriteByte (&sv.reliable_datagram, svc_updatepskin);
MSG_WriteByte (&sv.reliable_datagram, host_client - svs.clients);
int i;
qbool haveorigin;
- qbool expectval = false;
void (*print)(const char *, ...) = (cmd->source == src_client ? SV_ClientPrintf : Con_Printf);
if(!Cmd_Argc(cmd))
}
// Allow more than one key/value pair by cycling between expecting either one.
- for(i = 2; i < Cmd_Argc(cmd); i++)
+ for(i = 2; i < Cmd_Argc(cmd); i += 2)
{
- if(!expectval)
+ if(!(key = PRVM_ED_FindField(prog, Cmd_Argv(cmd, i))))
{
- if(!(key = PRVM_ED_FindField(prog, Cmd_Argv(cmd, i))))
- {
- print("Key %s not found!\n", Cmd_Argv(cmd, i));
- PRVM_ED_Free(prog, ed);
- return;
- }
+ print("Key %s not found!\n", Cmd_Argv(cmd, i));
+ PRVM_ED_Free(prog, ed);
+ return;
+ }
- /*
- * This is mostly for dedicated server console, but if the
- * player gave a custom origin, we can ignore the traceline.
- */
- if(!strcmp(Cmd_Argv(cmd, i), "origin"))
- haveorigin = true;
+ /*
+ * This is mostly for dedicated server console, but if the
+ * player gave a custom origin, we can ignore the traceline.
+ */
+ if(!strcmp(Cmd_Argv(cmd, i), "origin"))
+ haveorigin = true;
- expectval = true;
- }
- else
- {
- PRVM_ED_ParseEpair(prog, ed, key, Cmd_Argv(cmd, i), false);
- expectval = false;
- }
+ if (i + 1 < Cmd_Argc(cmd))
+ PRVM_ED_ParseEpair(prog, ed, key, Cmd_Argv(cmd, i+1), false);
}
if(!haveorigin)
{
prvm_prog_t *prog = SVVM_prog;
prvm_edict_t *ed;
- int i, ednum;
+ int i, ednum = 0;
void (*print)(const char *, ...) = (cmd->source == src_client ? SV_ClientPrintf : Con_Printf);
if(!Cmd_Argc(cmd))
return;
}
- if(!ed->priv.required->free)
+ if(!ed->free)
{
print("Removed a \"%s\"\n", PRVM_GetString(prog, PRVM_serveredictstring(ed, classname)));
PRVM_ED_ClearEdict(prog, ed);
for (i = 0, rmcount = 0, ed = PRVM_EDICT_NUM(i); i < prog->num_edicts; i++, ed = PRVM_NEXT_EDICT(ed))
{
- if(!ed->priv.required->free && !strcmp(PRVM_GetString(prog, PRVM_serveredictstring(ed, classname)), Cmd_Argv(cmd, 1)))
+ if(!ed->free && !strcmp(PRVM_GetString(prog, PRVM_serveredictstring(ed, classname)), Cmd_Argv(cmd, 1)))
{
if(!i)
{
Cmd_AddCommand(CF_SERVER | CF_SERVER_FROM_CLIENT, "status", SV_Status_f, "print server status information");
Cmd_AddCommand(CF_SHARED, "map", SV_Map_f, "kick everyone off the server and start a new level");
Cmd_AddCommand(CF_SHARED, "restart", SV_Restart_f, "restart current level");
- Cmd_AddCommand(CF_SHARED, "changelevel", SV_Changelevel_f, "change to another level, bringing along all connected clients");
+ Cmd_AddCommand(CF_SHARED, "changelevel", SV_Changelevel_f, "change to another level, bringing along all connected clients (or start a new level if none is loaded)");
Cmd_AddCommand(CF_SHARED | CF_SERVER_FROM_CLIENT, "say", SV_Say_f, "send a chat message to everyone on the server");
Cmd_AddCommand(CF_SERVER_FROM_CLIENT, "say_team", SV_Say_Team_f, "send a chat message to your team on the server");
Cmd_AddCommand(CF_SHARED | CF_SERVER_FROM_CLIENT, "tell", SV_Tell_f, "send a chat message to only one person on the server");
Cmd_AddCommand(CF_SHARED, "viewnext", SV_Viewnext_f, "change to next animation frame of viewthing entity in current level");
Cmd_AddCommand(CF_SHARED, "viewprev", SV_Viewprev_f, "change to previous animation frame of viewthing entity in current level");
Cmd_AddCommand(CF_SHARED, "maxplayers", SV_MaxPlayers_f, "sets limit on how many players (or bots) may be connected to the server at once");
- Cmd_AddCommand(CF_SERVER, "sendcvar", SV_SendCvar_f, "sends the value of a cvar to the server as a sentcvar command, for use by QuakeC");
+ host.hook.SV_SendCvar = SV_SendCvar_f;
- // commands that do not have automatic forwarding from cmd_client, these are internal details of the network protocol and not of interest to users (if they know what they are doing they can still use a generic "cmd prespawn" or similar)
+ // commands that do not have automatic forwarding from cmd_local, these are internal details of the network protocol and not of interest to users (if they know what they are doing they can still use a generic "cmd prespawn" or similar)
Cmd_AddCommand(CF_SERVER_FROM_CLIENT, "prespawn", SV_PreSpawn_f, "internal use - signon 1 (client acknowledges that server information has been received)");
Cmd_AddCommand(CF_SERVER_FROM_CLIENT, "spawn", SV_Spawn_f, "internal use - signon 2 (client has sent player information, and is asking server to send scoreboard rankings)");
Cmd_AddCommand(CF_SERVER_FROM_CLIENT, "begin", SV_Begin_f, "internal use - signon 3 (client asks server to start sending entities, and will go to signon 4 (playing) when the first entity update is received)");