More conversion
This commit is contained in:
+182
-176
@@ -21,12 +21,14 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
*/
|
||||
|
||||
#include <sstream>
|
||||
|
||||
#include "quakedef.hpp"
|
||||
#ifndef _WIN32
|
||||
#include <dirent.h>
|
||||
#endif
|
||||
|
||||
extern cvar_t pausable;
|
||||
extern convar pausable;
|
||||
|
||||
int current_skill;
|
||||
|
||||
@@ -425,11 +427,11 @@ static void Host_Status_f (void)
|
||||
int hours = 0;
|
||||
int j;
|
||||
|
||||
if (cmd_source == src_command)
|
||||
if (command::last_source == command::source::command)
|
||||
{
|
||||
if (!sv.active)
|
||||
{
|
||||
Cmd_ForwardToServer ();
|
||||
command::forward_to_server ();
|
||||
return;
|
||||
}
|
||||
print_fn = Con_Printf;
|
||||
@@ -437,7 +439,7 @@ static void Host_Status_f (void)
|
||||
else
|
||||
print_fn = SV_ClientPrintf;
|
||||
|
||||
print_fn ("host: %s\n", Cvar_VariableString ("hostname"));
|
||||
print_fn ("host: %s\n", convar::variable_string("hostname").value_or("").c_str());
|
||||
print_fn ("version: %4.2f\n", VERSION);
|
||||
if (tcpipAvailable)
|
||||
print_fn ("tcp/ip: %s\n", my_tcpip_address);
|
||||
@@ -474,9 +476,9 @@ Sets client to godmode
|
||||
*/
|
||||
static void Host_God_f (void)
|
||||
{
|
||||
if (cmd_source == src_command)
|
||||
if (command::last_source == command::source::command)
|
||||
{
|
||||
Cmd_ForwardToServer ();
|
||||
command::forward_to_server();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -484,7 +486,7 @@ static void Host_God_f (void)
|
||||
return;
|
||||
|
||||
//johnfitz -- allow user to explicitly set god mode to on or off
|
||||
switch (Cmd_Argc())
|
||||
switch (command::argc())
|
||||
{
|
||||
case 1:
|
||||
sv_player->v.flags = (int)sv_player->v.flags ^ FL_GODMODE;
|
||||
@@ -493,8 +495,8 @@ static void Host_God_f (void)
|
||||
else
|
||||
SV_ClientPrintf ("godmode ON\n");
|
||||
break;
|
||||
case 2:
|
||||
if (Q_atof(Cmd_Argv(1)))
|
||||
case 2:
|
||||
if (Q_atof(command::argv(1)->c_str()))
|
||||
{
|
||||
sv_player->v.flags = (int)sv_player->v.flags | FL_GODMODE;
|
||||
SV_ClientPrintf ("godmode ON\n");
|
||||
@@ -513,9 +515,9 @@ static void Host_God_f (void)
|
||||
}
|
||||
|
||||
static void Host_Buddha_f (void) {
|
||||
if (cmd_source == src_command)
|
||||
if (command::last_source == command::source::command)
|
||||
{
|
||||
Cmd_ForwardToServer ();
|
||||
command::forward_to_server();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -536,9 +538,9 @@ Host_Notarget_f
|
||||
*/
|
||||
static void Host_Notarget_f (void)
|
||||
{
|
||||
if (cmd_source == src_command)
|
||||
if (command::last_source == command::source::command)
|
||||
{
|
||||
Cmd_ForwardToServer ();
|
||||
command::forward_to_server();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -546,7 +548,7 @@ static void Host_Notarget_f (void)
|
||||
return;
|
||||
|
||||
//johnfitz -- allow user to explicitly set notarget to on or off
|
||||
switch (Cmd_Argc())
|
||||
switch (command::argc())
|
||||
{
|
||||
case 1:
|
||||
sv_player->v.flags = (int)sv_player->v.flags ^ FL_NOTARGET;
|
||||
@@ -555,8 +557,8 @@ static void Host_Notarget_f (void)
|
||||
else
|
||||
SV_ClientPrintf ("notarget ON\n");
|
||||
break;
|
||||
case 2:
|
||||
if (Q_atof(Cmd_Argv(1)))
|
||||
case 2:
|
||||
if (Q_atof(command::argv(1)->c_str()))
|
||||
{
|
||||
sv_player->v.flags = (int)sv_player->v.flags | FL_NOTARGET;
|
||||
SV_ClientPrintf ("notarget ON\n");
|
||||
@@ -583,9 +585,9 @@ Host_Noclip_f
|
||||
*/
|
||||
static void Host_Noclip_f (void)
|
||||
{
|
||||
if (cmd_source == src_command)
|
||||
if (command::last_source == command::source::command)
|
||||
{
|
||||
Cmd_ForwardToServer ();
|
||||
command::forward_to_server();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -593,7 +595,7 @@ static void Host_Noclip_f (void)
|
||||
return;
|
||||
|
||||
//johnfitz -- allow user to explicitly set noclip to on or off
|
||||
switch (Cmd_Argc())
|
||||
switch (command::argc())
|
||||
{
|
||||
case 1:
|
||||
if (sv_player->v.movetype != MOVETYPE_NOCLIP)
|
||||
@@ -609,8 +611,8 @@ static void Host_Noclip_f (void)
|
||||
SV_ClientPrintf ("noclip OFF\n");
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if (Q_atof(Cmd_Argv(1)))
|
||||
case 2:
|
||||
if (Q_atof(command::argv(1)->c_str()))
|
||||
{
|
||||
noclip_anglehack = true;
|
||||
sv_player->v.movetype = MOVETYPE_NOCLIP;
|
||||
@@ -639,16 +641,15 @@ adapted from fteqw, originally by Alex Shadowalker
|
||||
*/
|
||||
static void Host_SetPos_f(void)
|
||||
{
|
||||
if (cmd_source == src_command)
|
||||
if (command::last_source == command::source::command)
|
||||
{
|
||||
Cmd_ForwardToServer ();
|
||||
command::forward_to_server();
|
||||
return;
|
||||
}
|
||||
|
||||
if (pr_global_struct->deathmatch)
|
||||
return;
|
||||
|
||||
if (Cmd_Argc() != 7 && Cmd_Argc() != 4)
|
||||
if (command::argc() != 7 && command::argc() != 4)
|
||||
{
|
||||
SV_ClientPrintf("usage:\n");
|
||||
SV_ClientPrintf(" setpos <x> <y> <z>\n");
|
||||
@@ -676,15 +677,15 @@ static void Host_SetPos_f(void)
|
||||
sv_player->v.velocity[1] = 0;
|
||||
sv_player->v.velocity[2] = 0;
|
||||
|
||||
sv_player->v.origin[0] = atof(Cmd_Argv(1));
|
||||
sv_player->v.origin[1] = atof(Cmd_Argv(2));
|
||||
sv_player->v.origin[2] = atof(Cmd_Argv(3));
|
||||
sv_player->v.origin[0] = atof(command::argv(1)->c_str());
|
||||
sv_player->v.origin[1] = atof(command::argv(2)->c_str());
|
||||
sv_player->v.origin[2] = atof(command::argv(3)->c_str());
|
||||
|
||||
if (Cmd_Argc() == 7)
|
||||
if (command::argc() == 7)
|
||||
{
|
||||
sv_player->v.angles[0] = atof(Cmd_Argv(4));
|
||||
sv_player->v.angles[1] = atof(Cmd_Argv(5));
|
||||
sv_player->v.angles[2] = atof(Cmd_Argv(6));
|
||||
sv_player->v.angles[0] = atof(command::argv(4)->c_str());
|
||||
sv_player->v.angles[1] = atof(command::argv(5)->c_str());
|
||||
sv_player->v.angles[2] = atof(command::argv(6)->c_str());
|
||||
sv_player->v.fixangle = 1;
|
||||
}
|
||||
|
||||
@@ -700,9 +701,9 @@ Sets client to flymode
|
||||
*/
|
||||
static void Host_Fly_f (void)
|
||||
{
|
||||
if (cmd_source == src_command)
|
||||
if (command::last_source == command::source::command)
|
||||
{
|
||||
Cmd_ForwardToServer ();
|
||||
command::forward_to_server();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -710,7 +711,7 @@ static void Host_Fly_f (void)
|
||||
return;
|
||||
|
||||
//johnfitz -- allow user to explicitly set noclip to on or off
|
||||
switch (Cmd_Argc())
|
||||
switch (command::argc())
|
||||
{
|
||||
case 1:
|
||||
if (sv_player->v.movetype != MOVETYPE_FLY)
|
||||
@@ -724,8 +725,8 @@ static void Host_Fly_f (void)
|
||||
SV_ClientPrintf ("flymode OFF\n");
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if (Q_atof(Cmd_Argv(1)))
|
||||
case 2:
|
||||
if (Q_atof(command::argv(1)->c_str()))
|
||||
{
|
||||
sv_player->v.movetype = MOVETYPE_FLY;
|
||||
SV_ClientPrintf ("flymode ON\n");
|
||||
@@ -755,9 +756,9 @@ static void Host_Ping_f (void)
|
||||
float total;
|
||||
client_t *client;
|
||||
|
||||
if (cmd_source == src_command)
|
||||
if (command::last_source == command::source::command)
|
||||
{
|
||||
Cmd_ForwardToServer ();
|
||||
command::forward_to_server();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -796,7 +797,7 @@ static void Host_Map_f (void)
|
||||
int i;
|
||||
char name[MAX_QPATH], *p;
|
||||
|
||||
if (Cmd_Argc() < 2) //no map name given
|
||||
if (command::argc() < 2) //no map name given
|
||||
{
|
||||
if (cls.state == ca_dedicated)
|
||||
{
|
||||
@@ -816,8 +817,10 @@ static void Host_Map_f (void)
|
||||
return;
|
||||
}
|
||||
|
||||
if (cmd_source != src_command)
|
||||
if (command::last_source != command::source::command)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
cls.demonum = -1; // stop demo loop in case this fails
|
||||
|
||||
@@ -830,7 +833,7 @@ static void Host_Map_f (void)
|
||||
SCR_BeginLoadingPlaque ();
|
||||
|
||||
svs.serverflags = 0; // haven't completed an episode yet
|
||||
q_strlcpy (name, Cmd_Argv(1), sizeof(name));
|
||||
q_strlcpy (name, command::argv(1)->c_str(), sizeof(name));
|
||||
// remove (any) trailing ".bsp" from mapname -- S.A.
|
||||
p = strstr(name, ".bsp");
|
||||
if (p && p[4] == '\0')
|
||||
@@ -842,13 +845,13 @@ static void Host_Map_f (void)
|
||||
if (cls.state != ca_dedicated)
|
||||
{
|
||||
memset (cls.spawnparms, 0, MAX_MAPSTRING);
|
||||
for (i = 2; i < Cmd_Argc(); i++)
|
||||
for (i = 2; i < command::argc(); i++)
|
||||
{
|
||||
q_strlcat (cls.spawnparms, Cmd_Argv(i), MAX_MAPSTRING);
|
||||
q_strlcat (cls.spawnparms, command::argv(i)->c_str(), MAX_MAPSTRING);
|
||||
q_strlcat (cls.spawnparms, " ", MAX_MAPSTRING);
|
||||
}
|
||||
|
||||
Cmd_ExecuteString ("connect local", src_command);
|
||||
command::execute_string ("connect local", command::source::command);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -864,7 +867,7 @@ static void Host_Randmap_f (void)
|
||||
int i, randlevel, numlevels;
|
||||
filelist_item_t *level;
|
||||
|
||||
if (cmd_source != src_command)
|
||||
if (command::last_source != command::source::command)
|
||||
return;
|
||||
|
||||
for (level = extralevels, numlevels = 0; level; level = level->next)
|
||||
@@ -900,7 +903,7 @@ static void Host_Changelevel_f (void)
|
||||
{
|
||||
char level[MAX_QPATH];
|
||||
|
||||
if (Cmd_Argc() != 2)
|
||||
if (command::argc() != 2)
|
||||
{
|
||||
Con_Printf ("changelevel <levelname> : continue game on a new level\n");
|
||||
return;
|
||||
@@ -912,7 +915,7 @@ static void Host_Changelevel_f (void)
|
||||
}
|
||||
|
||||
//johnfitz -- check for client having map before anything else
|
||||
q_snprintf (level, sizeof(level), "maps/%s.bsp", Cmd_Argv(1));
|
||||
q_snprintf (level, sizeof(level), "maps/%s.bsp", command::argv(1)->c_str());
|
||||
if (!COM_FileExists(level, NULL))
|
||||
Host_Error ("cannot find map %s", level);
|
||||
//johnfitz
|
||||
@@ -921,7 +924,7 @@ static void Host_Changelevel_f (void)
|
||||
IN_Activate(); // -- S.A.
|
||||
key_dest = key_game; // remove console or menu
|
||||
SV_SaveSpawnparms ();
|
||||
q_strlcpy (level, Cmd_Argv(1), sizeof(level));
|
||||
q_strlcpy (level, command::argv(1)->c_str(), sizeof(level));
|
||||
SV_SpawnServer (level);
|
||||
// also issue an error if spawn failed -- O.S.
|
||||
if (!sv.active)
|
||||
@@ -942,7 +945,7 @@ static void Host_Restart_f (void)
|
||||
if (cls.demoplayback || !sv.active)
|
||||
return;
|
||||
|
||||
if (cmd_source != src_command)
|
||||
if (command::last_source != command::source::command)
|
||||
return;
|
||||
q_strlcpy (mapname, sv.name, sizeof(mapname)); // mapname gets cleared in spawnserver
|
||||
SV_SpawnServer (mapname);
|
||||
@@ -984,7 +987,7 @@ static void Host_Connect_f (void)
|
||||
CL_StopPlayback ();
|
||||
CL_Disconnect ();
|
||||
}
|
||||
q_strlcpy (name, Cmd_Argv(1), sizeof(name));
|
||||
q_strlcpy (name, command::argv(1).value_or("").c_str(), sizeof(name));
|
||||
CL_EstablishConnection (name);
|
||||
Host_Reconnect_f ();
|
||||
}
|
||||
@@ -1051,7 +1054,7 @@ static void Host_Savegame_f (void)
|
||||
int i;
|
||||
char comment[SAVEGAME_COMMENT_LENGTH+1];
|
||||
|
||||
if (cmd_source != src_command)
|
||||
if (command::last_source != command::source::command)
|
||||
return;
|
||||
|
||||
if (!sv.active)
|
||||
@@ -1072,13 +1075,13 @@ static void Host_Savegame_f (void)
|
||||
return;
|
||||
}
|
||||
|
||||
if (Cmd_Argc() != 2)
|
||||
if (command::argc() != 2)
|
||||
{
|
||||
Con_Printf ("save <savename> : save a game\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (strstr(Cmd_Argv(1), ".."))
|
||||
if (strstr(command::argv(1)->c_str(), ".."))
|
||||
{
|
||||
Con_Printf ("Relative pathnames are not allowed.\n");
|
||||
return;
|
||||
@@ -1093,7 +1096,7 @@ static void Host_Savegame_f (void)
|
||||
}
|
||||
}
|
||||
|
||||
q_snprintf (name, sizeof(name), "%s/%s", com_gamedir, Cmd_Argv(1));
|
||||
q_snprintf (name, sizeof(name), "%s/%s", com_gamedir, command::argv(1)->c_str());
|
||||
COM_AddExtension (name, ".sav", sizeof(name));
|
||||
|
||||
Con_Printf ("Saving game to %s...\n", name);
|
||||
@@ -1143,24 +1146,22 @@ static void Host_Loadgame_f (void)
|
||||
|
||||
char name[MAX_OSPATH];
|
||||
char mapname[MAX_QPATH];
|
||||
float time, tfloat;
|
||||
const char *data;
|
||||
int i;
|
||||
edict_t *ent;
|
||||
int entnum;
|
||||
int version;
|
||||
float spawn_parms[NUM_SPAWN_PARMS];
|
||||
|
||||
if (cmd_source != src_command)
|
||||
if (command::last_source != command::source::command)
|
||||
return;
|
||||
|
||||
if (Cmd_Argc() != 2)
|
||||
if (command::argc() != 2)
|
||||
{
|
||||
Con_Printf ("load <savename> : load a game\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (strstr(Cmd_Argv(1), ".."))
|
||||
if (strstr(command::argv(1)->c_str(), ".."))
|
||||
{
|
||||
Con_Printf ("Relative pathnames are not allowed.\n");
|
||||
return;
|
||||
@@ -1168,7 +1169,7 @@ static void Host_Loadgame_f (void)
|
||||
|
||||
cls.demonum = -1; // stop demo loop in case this fails
|
||||
|
||||
q_snprintf (name, sizeof(name), "%s/%s", com_gamedir, Cmd_Argv(1));
|
||||
q_snprintf (name, sizeof(name), "%s/%s", com_gamedir, command::argv(1)->c_str());
|
||||
COM_AddExtension (name, ".sav", sizeof(name));
|
||||
|
||||
// we can't call SCR_BeginLoadingPlaque, because too much stack space has
|
||||
@@ -1188,8 +1189,8 @@ static void Host_Loadgame_f (void)
|
||||
return;
|
||||
}
|
||||
|
||||
data = start;
|
||||
data = COM_ParseIntNewline (data, &version);
|
||||
std::istringstream ss{start};
|
||||
version = common::parse_int_newline(ss);
|
||||
if (version != SAVEGAME_VERSION)
|
||||
{
|
||||
free (start);
|
||||
@@ -1197,17 +1198,17 @@ static void Host_Loadgame_f (void)
|
||||
Host_Error ("Savegame is version %i, not %i", version, SAVEGAME_VERSION);
|
||||
return;
|
||||
}
|
||||
data = COM_ParseStringNewline (data);
|
||||
auto strr = common::parse_string_newline (ss);
|
||||
for (i = 0; i < NUM_SPAWN_PARMS; i++)
|
||||
data = COM_ParseFloatNewline (data, &spawn_parms[i]);
|
||||
spawn_parms[i] = common::parse_float_newline(ss);
|
||||
// this silliness is so we can load 1.06 save files, which have float skill values
|
||||
data = COM_ParseFloatNewline(data, &tfloat);
|
||||
const float tfloat = common::parse_float_newline(ss);
|
||||
current_skill = (int)(tfloat + 0.1);
|
||||
Cvar_SetValue ("skill", (float)current_skill);
|
||||
convar::set_value ("skill", (float)current_skill);
|
||||
|
||||
data = COM_ParseStringNewline (data);
|
||||
q_strlcpy (mapname, com_token, sizeof(mapname));
|
||||
data = COM_ParseFloatNewline (data, &time);
|
||||
strr = common::parse_string_newline(ss);
|
||||
q_strlcpy (mapname, strr.c_str(), sizeof(mapname));
|
||||
const float time = common::parse_float_newline(ss);
|
||||
|
||||
CL_Disconnect_f ();
|
||||
|
||||
@@ -1227,25 +1228,25 @@ static void Host_Loadgame_f (void)
|
||||
// load the light styles
|
||||
for (i = 0; i < MAX_LIGHTSTYLES; i++)
|
||||
{
|
||||
data = COM_ParseStringNewline (data);
|
||||
sv.lightstyles[i] = (const char *)Hunk_Strdup (com_token, "lightstyles");
|
||||
strr = common::parse_string_newline(ss);
|
||||
sv.lightstyles[i] = (const char *)Hunk_Strdup (strr.c_str(), "lightstyles");
|
||||
}
|
||||
|
||||
// load the edicts out of the savegame file
|
||||
entnum = -1; // -1 is the globals
|
||||
while (*data)
|
||||
while (!ss.eof())
|
||||
{
|
||||
data = COM_Parse (data);
|
||||
if (!com_token[0])
|
||||
auto token = common::parse_token(ss);
|
||||
if (!token.has_value())
|
||||
break; // end of file
|
||||
if (strcmp(com_token,"{"))
|
||||
if (token->front() != '{')
|
||||
{
|
||||
Host_Error ("First token isn't a brace");
|
||||
}
|
||||
|
||||
if (entnum == -1)
|
||||
{ // parse the global vars
|
||||
data = ED_ParseGlobals (data);
|
||||
ED_ParseGlobals (ss);
|
||||
}
|
||||
else
|
||||
{ // parse an edict
|
||||
@@ -1258,7 +1259,7 @@ static void Host_Loadgame_f (void)
|
||||
memset (ent, 0, pr_edict_size);
|
||||
ent->baseline.scale = ENTSCALE_DEFAULT;
|
||||
}
|
||||
data = ED_ParseEdict (data, ent);
|
||||
ED_ParseEdict (ss, ent);
|
||||
|
||||
// link it into the bsp tree
|
||||
if (!ent->free)
|
||||
@@ -1302,24 +1303,24 @@ static void Host_Name_f (void)
|
||||
{
|
||||
char newName[32];
|
||||
|
||||
if (Cmd_Argc () == 1)
|
||||
if (command::argc () == 1)
|
||||
{
|
||||
Con_Printf ("\"name\" is \"%s\"\n", cl_name.string);
|
||||
return;
|
||||
}
|
||||
if (Cmd_Argc () == 2)
|
||||
q_strlcpy(newName, Cmd_Argv(1), sizeof(newName));
|
||||
if (command::argc () == 2)
|
||||
q_strlcpy(newName, command::argv(1)->c_str(), sizeof(newName));
|
||||
else
|
||||
q_strlcpy(newName, Cmd_Args(), sizeof(newName));
|
||||
q_strlcpy(newName, command::args().c_str(), sizeof(newName));
|
||||
newName[15] = 0; // client_t structure actually says name[32].
|
||||
|
||||
if (cmd_source == src_command)
|
||||
if (command::last_source == command::source::command)
|
||||
{
|
||||
if (Q_strcmp(cl_name.string, newName) == 0)
|
||||
return;
|
||||
Cvar_Set ("_cl_name", newName);
|
||||
convar::set("_cl_name", newName);
|
||||
if (cls.state == ca_connected)
|
||||
Cmd_ForwardToServer ();
|
||||
command::forward_to_server ();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1342,28 +1343,28 @@ static void Host_Say(qboolean teamonly)
|
||||
int j;
|
||||
client_t *client;
|
||||
client_t *save;
|
||||
const char *p;
|
||||
char text[MAXCMDLINE], *p2;
|
||||
qboolean quoted;
|
||||
qboolean fromServer = false;
|
||||
|
||||
if (cmd_source == src_command)
|
||||
if (command::last_source == command::source::command)
|
||||
{
|
||||
if (cls.state != ca_dedicated)
|
||||
{
|
||||
Cmd_ForwardToServer ();
|
||||
command::forward_to_server ();
|
||||
return;
|
||||
}
|
||||
fromServer = true;
|
||||
teamonly = false;
|
||||
}
|
||||
|
||||
if (Cmd_Argc () < 2)
|
||||
if (command::argc () < 2)
|
||||
return;
|
||||
|
||||
save = host_client;
|
||||
|
||||
p = Cmd_Args();
|
||||
auto args = command::args();
|
||||
auto p = args.c_str();
|
||||
// remove quotes if present
|
||||
quoted = false;
|
||||
if (*p == '\"')
|
||||
@@ -1433,16 +1434,17 @@ static void Host_Tell_f(void)
|
||||
char text[MAXCMDLINE], *p2;
|
||||
qboolean quoted;
|
||||
|
||||
if (cmd_source == src_command)
|
||||
if (command::last_source == command::source::command)
|
||||
{
|
||||
Cmd_ForwardToServer ();
|
||||
command::forward_to_server();
|
||||
return;
|
||||
}
|
||||
|
||||
if (Cmd_Argc () < 3)
|
||||
if (command::argc () < 3)
|
||||
return;
|
||||
|
||||
p = Cmd_Args();
|
||||
auto args = command::args();
|
||||
p = args.c_str();
|
||||
// remove quotes if present
|
||||
quoted = false;
|
||||
if (*p == '\"')
|
||||
@@ -1479,7 +1481,7 @@ static void Host_Tell_f(void)
|
||||
{
|
||||
if (!client->active || !client->spawned)
|
||||
continue;
|
||||
if (q_strcasecmp(client->name, Cmd_Argv(1)))
|
||||
if (q_strcasecmp(client->name, command::argv(1)->c_str()))
|
||||
continue;
|
||||
host_client = client;
|
||||
SV_ClientPrintf("%s", text);
|
||||
@@ -1498,19 +1500,19 @@ static void Host_Color_f(void)
|
||||
int top, bottom;
|
||||
int playercolor;
|
||||
|
||||
if (Cmd_Argc() == 1)
|
||||
if (command::argc() == 1)
|
||||
{
|
||||
Con_Printf ("\"color\" is \"%i %i\"\n", ((int)cl_color.value) >> 4, ((int)cl_color.value) & 0x0f);
|
||||
Con_Printf ("color <0-13> [0-13]\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (Cmd_Argc() == 2)
|
||||
top = bottom = atoi(Cmd_Argv(1));
|
||||
if (command::argc() == 2)
|
||||
top = bottom = atoi(command::argv(1)->c_str());
|
||||
else
|
||||
{
|
||||
top = atoi(Cmd_Argv(1));
|
||||
bottom = atoi(Cmd_Argv(2));
|
||||
top = atoi(command::argv(1)->c_str());
|
||||
bottom = atoi(command::argv(2)->c_str());
|
||||
}
|
||||
|
||||
top &= 15;
|
||||
@@ -1522,11 +1524,11 @@ static void Host_Color_f(void)
|
||||
|
||||
playercolor = top*16 + bottom;
|
||||
|
||||
if (cmd_source == src_command)
|
||||
if (command::last_source == command::source::command)
|
||||
{
|
||||
Cvar_SetValue ("_cl_color", playercolor);
|
||||
convar::set_value ("_cl_color", playercolor);
|
||||
if (cls.state == ca_connected)
|
||||
Cmd_ForwardToServer ();
|
||||
command::forward_to_server ();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1546,9 +1548,9 @@ Host_Kill_f
|
||||
*/
|
||||
static void Host_Kill_f (void)
|
||||
{
|
||||
if (cmd_source == src_command)
|
||||
if (command::last_source == command::source::command)
|
||||
{
|
||||
Cmd_ForwardToServer ();
|
||||
command::forward_to_server();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1578,9 +1580,9 @@ static void Host_Pause_f (void)
|
||||
return;
|
||||
}
|
||||
|
||||
if (cmd_source == src_command)
|
||||
if (command::last_source == command::source::command)
|
||||
{
|
||||
Cmd_ForwardToServer ();
|
||||
command::forward_to_server();
|
||||
return;
|
||||
}
|
||||
if (!pausable.value)
|
||||
@@ -1613,7 +1615,7 @@ Host_PreSpawn_f
|
||||
*/
|
||||
static void Host_PreSpawn_f (void)
|
||||
{
|
||||
if (cmd_source == src_command)
|
||||
if (command::last_source == command::source::command)
|
||||
{
|
||||
Con_Printf ("prespawn is not valid from the console\n");
|
||||
return;
|
||||
@@ -1640,7 +1642,7 @@ static void Host_Spawn_f (void)
|
||||
client_t *client;
|
||||
edict_t *ent;
|
||||
|
||||
if (cmd_source == src_command)
|
||||
if (command::last_source == command::source::command)
|
||||
{
|
||||
Con_Printf ("spawn is not valid from the console\n");
|
||||
return;
|
||||
@@ -1755,7 +1757,7 @@ Host_Begin_f
|
||||
*/
|
||||
static void Host_Begin_f (void)
|
||||
{
|
||||
if (cmd_source == src_command)
|
||||
if (command::last_source == command::source::command)
|
||||
{
|
||||
Con_Printf ("begin is not valid from the console\n");
|
||||
return;
|
||||
@@ -1776,16 +1778,15 @@ Kicks a user off of the server
|
||||
static void Host_Kick_f (void)
|
||||
{
|
||||
const char *who;
|
||||
const char *message = NULL;
|
||||
client_t *save;
|
||||
int i;
|
||||
qboolean byNumber = false;
|
||||
|
||||
if (cmd_source == src_command)
|
||||
if (command::last_source == command::source::command)
|
||||
{
|
||||
if (!sv.active)
|
||||
{
|
||||
Cmd_ForwardToServer ();
|
||||
command::forward_to_server ();
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -1794,9 +1795,9 @@ static void Host_Kick_f (void)
|
||||
|
||||
save = host_client;
|
||||
|
||||
if (Cmd_Argc() > 2 && Q_strcmp(Cmd_Argv(1), "#") == 0)
|
||||
if (command::argc() > 2 && Q_strcmp(command::argv(1)->c_str(), "#") == 0)
|
||||
{
|
||||
i = Q_atof(Cmd_Argv(2)) - 1;
|
||||
i = Q_atof(command::argv(2)->c_str()) - 1;
|
||||
if (i < 0 || i >= svs.maxclients)
|
||||
return;
|
||||
if (!svs.clients[i].active)
|
||||
@@ -1810,14 +1811,14 @@ static void Host_Kick_f (void)
|
||||
{
|
||||
if (!host_client->active)
|
||||
continue;
|
||||
if (q_strcasecmp(host_client->name, Cmd_Argv(1)) == 0)
|
||||
if (q_strcasecmp(host_client->name, command::argv(1).value_or("").c_str()) == 0)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (i < svs.maxclients)
|
||||
{
|
||||
if (cmd_source == src_command)
|
||||
if (command::last_source == command::source::command)
|
||||
if (cls.state == ca_dedicated)
|
||||
who = "Console";
|
||||
else
|
||||
@@ -1829,21 +1830,25 @@ static void Host_Kick_f (void)
|
||||
if (host_client == save)
|
||||
return;
|
||||
|
||||
if (Cmd_Argc() > 2)
|
||||
std::string message{};
|
||||
if (command::argc() > 2)
|
||||
{
|
||||
message = COM_Parse(Cmd_Args());
|
||||
std::istringstream ss{command::args()};
|
||||
auto token = common::parse_token(ss);
|
||||
if (byNumber)
|
||||
{
|
||||
message++; // skip the #
|
||||
while (*message == ' ') // skip white space
|
||||
message++;
|
||||
message += strlen(Cmd_Argv(2)); // skip the number
|
||||
ss.get();
|
||||
while (ss.peek() == ' ') // skip white space
|
||||
ss.get();
|
||||
ss.seekg(command::argv(2)->length(), std::ios_base::seekdir::_S_cur); // skip the number
|
||||
}
|
||||
while (*message && *message == ' ')
|
||||
message++;
|
||||
while (!ss.eof() && ss.peek() == ' ')
|
||||
ss.get();
|
||||
|
||||
message += ss.str().substr(ss.tellg());
|
||||
}
|
||||
if (message)
|
||||
SV_ClientPrintf ("Kicked by %s: %s\n", who, message);
|
||||
if (!message.empty())
|
||||
SV_ClientPrintf ("Kicked by %s: %s\n", who, message.c_str());
|
||||
else
|
||||
SV_ClientPrintf ("Kicked by %s\n", who);
|
||||
SV_DropClient (false);
|
||||
@@ -1871,17 +1876,18 @@ static void Host_Give_f (void)
|
||||
int v;
|
||||
eval_t *val;
|
||||
|
||||
if (cmd_source == src_command)
|
||||
if (command::last_source == command::source::command)
|
||||
{
|
||||
Cmd_ForwardToServer ();
|
||||
command::forward_to_server();
|
||||
return;
|
||||
}
|
||||
|
||||
if (pr_global_struct->deathmatch)
|
||||
return;
|
||||
|
||||
t = Cmd_Argv(1);
|
||||
v = atoi (Cmd_Argv(2));
|
||||
auto arg1 = command::argv(1).value_or("");
|
||||
t = arg1.c_str();
|
||||
v = atoi (command::argv(2).value_or("").c_str());
|
||||
|
||||
switch (t[0])
|
||||
{
|
||||
@@ -2119,10 +2125,10 @@ static void Host_Viewmodel_f (void)
|
||||
if (!e)
|
||||
return;
|
||||
|
||||
m = Mod_ForName (Cmd_Argv(1), false);
|
||||
m = Mod_ForName (command::argv(1).value_or("").c_str(), false);
|
||||
if (!m)
|
||||
{
|
||||
Con_Printf ("Can't load %s\n", Cmd_Argv(1));
|
||||
Con_Printf ("Can't load %s\n", command::argv(1).value_or("").c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2146,7 +2152,7 @@ static void Host_Viewframe_f (void)
|
||||
return;
|
||||
m = cl.model_precache[(int)e->v.modelindex];
|
||||
|
||||
f = atoi(Cmd_Argv(1));
|
||||
f = atoi(command::argv(1).value_or("").c_str());
|
||||
if (f >= m->numframes)
|
||||
f = m->numframes - 1;
|
||||
|
||||
@@ -2231,7 +2237,7 @@ static void Host_Startdemos_f (void)
|
||||
if (cls.state == ca_dedicated)
|
||||
return;
|
||||
|
||||
c = Cmd_Argc() - 1;
|
||||
c = command::argc() - 1;
|
||||
if (c > MAX_DEMOS)
|
||||
{
|
||||
Con_Printf ("Max %i demos in demoloop\n", MAX_DEMOS);
|
||||
@@ -2240,7 +2246,7 @@ static void Host_Startdemos_f (void)
|
||||
Con_Printf ("%i demo(s) in loop\n", c);
|
||||
|
||||
for (i = 1; i < c + 1; i++)
|
||||
q_strlcpy (cls.demos[i-1], Cmd_Argv(i), sizeof(cls.demos[0]));
|
||||
q_strlcpy (cls.demos[i-1], command::argv(i)->c_str(), sizeof(cls.demos[0]));
|
||||
|
||||
if (!sv.active && cls.demonum != -1 && !cls.demoplayback)
|
||||
{
|
||||
@@ -2316,49 +2322,49 @@ Host_InitCommands
|
||||
*/
|
||||
void Host_InitCommands (void)
|
||||
{
|
||||
Cmd_AddCommand ("maps", Host_Maps_f); //johnfitz
|
||||
Cmd_AddCommand ("mods", Host_Mods_f); //johnfitz
|
||||
Cmd_AddCommand ("games", Host_Mods_f); // as an alias to "mods" -- S.A. / QuakeSpasm
|
||||
Cmd_AddCommand ("mapname", Host_Mapname_f); //johnfitz
|
||||
Cmd_AddCommand ("randmap", Host_Randmap_f); //ericw
|
||||
command::add ("maps", Host_Maps_f); //johnfitz
|
||||
command::add ("mods", Host_Mods_f); //johnfitz
|
||||
command::add ("games", Host_Mods_f); // as an alias to "mods" -- S.A. / QuakeSpasm
|
||||
command::add ("mapname", Host_Mapname_f); //johnfitz
|
||||
command::add ("randmap", Host_Randmap_f); //ericw
|
||||
|
||||
Cmd_AddCommand ("status", Host_Status_f);
|
||||
Cmd_AddCommand ("quit", Host_Quit_f);
|
||||
Cmd_AddCommand ("god", Host_God_f);
|
||||
Cmd_AddCommand("buddha", Host_Buddha_f);
|
||||
Cmd_AddCommand ("notarget", Host_Notarget_f);
|
||||
Cmd_AddCommand ("fly", Host_Fly_f);
|
||||
Cmd_AddCommand ("map", Host_Map_f);
|
||||
Cmd_AddCommand ("restart", Host_Restart_f);
|
||||
Cmd_AddCommand ("changelevel", Host_Changelevel_f);
|
||||
Cmd_AddCommand ("connect", Host_Connect_f);
|
||||
Cmd_AddCommand ("reconnect", Host_Reconnect_f);
|
||||
Cmd_AddCommand ("name", Host_Name_f);
|
||||
Cmd_AddCommand ("noclip", Host_Noclip_f);
|
||||
Cmd_AddCommand ("setpos", Host_SetPos_f); //QuakeSpasm
|
||||
command::add ("status", Host_Status_f);
|
||||
command::add ("quit", Host_Quit_f);
|
||||
command::add ("god", Host_God_f);
|
||||
command::add("buddha", Host_Buddha_f);
|
||||
command::add ("notarget", Host_Notarget_f);
|
||||
command::add ("fly", Host_Fly_f);
|
||||
command::add ("map", Host_Map_f);
|
||||
command::add ("restart", Host_Restart_f);
|
||||
command::add ("changelevel", Host_Changelevel_f);
|
||||
command::add ("connect", Host_Connect_f);
|
||||
command::add ("reconnect", Host_Reconnect_f);
|
||||
command::add ("name", Host_Name_f);
|
||||
command::add ("noclip", Host_Noclip_f);
|
||||
command::add ("setpos", Host_SetPos_f); //QuakeSpasm
|
||||
|
||||
Cmd_AddCommand ("say", Host_Say_f);
|
||||
Cmd_AddCommand ("say_team", Host_Say_Team_f);
|
||||
Cmd_AddCommand ("tell", Host_Tell_f);
|
||||
Cmd_AddCommand ("color", Host_Color_f);
|
||||
Cmd_AddCommand ("kill", Host_Kill_f);
|
||||
Cmd_AddCommand ("pause", Host_Pause_f);
|
||||
Cmd_AddCommand ("spawn", Host_Spawn_f);
|
||||
Cmd_AddCommand ("begin", Host_Begin_f);
|
||||
Cmd_AddCommand ("prespawn", Host_PreSpawn_f);
|
||||
Cmd_AddCommand ("kick", Host_Kick_f);
|
||||
Cmd_AddCommand ("ping", Host_Ping_f);
|
||||
Cmd_AddCommand ("load", Host_Loadgame_f);
|
||||
Cmd_AddCommand ("save", Host_Savegame_f);
|
||||
Cmd_AddCommand ("give", Host_Give_f);
|
||||
command::add ("say", Host_Say_f);
|
||||
command::add ("say_team", Host_Say_Team_f);
|
||||
command::add ("tell", Host_Tell_f);
|
||||
command::add ("color", Host_Color_f);
|
||||
command::add ("kill", Host_Kill_f);
|
||||
command::add ("pause", Host_Pause_f);
|
||||
command::add ("spawn", Host_Spawn_f);
|
||||
command::add ("begin", Host_Begin_f);
|
||||
command::add ("prespawn", Host_PreSpawn_f);
|
||||
command::add ("kick", Host_Kick_f);
|
||||
command::add ("ping", Host_Ping_f);
|
||||
command::add ("load", Host_Loadgame_f);
|
||||
command::add ("save", Host_Savegame_f);
|
||||
command::add ("give", Host_Give_f);
|
||||
|
||||
Cmd_AddCommand ("startdemos", Host_Startdemos_f);
|
||||
Cmd_AddCommand ("demos", Host_Demos_f);
|
||||
Cmd_AddCommand ("stopdemo", Host_Stopdemo_f);
|
||||
command::add ("startdemos", Host_Startdemos_f);
|
||||
command::add ("demos", Host_Demos_f);
|
||||
command::add ("stopdemo", Host_Stopdemo_f);
|
||||
|
||||
Cmd_AddCommand ("viewmodel", Host_Viewmodel_f);
|
||||
Cmd_AddCommand ("viewframe", Host_Viewframe_f);
|
||||
Cmd_AddCommand ("viewnext", Host_Viewnext_f);
|
||||
Cmd_AddCommand ("viewprev", Host_Viewprev_f);
|
||||
command::add ("viewmodel", Host_Viewmodel_f);
|
||||
command::add ("viewframe", Host_Viewframe_f);
|
||||
command::add ("viewnext", Host_Viewnext_f);
|
||||
command::add ("viewprev", Host_Viewprev_f);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user