本文整理匯總了C++中Cmd_ForwardToServer函數的典型用法代碼示例。如果您正苦於以下問題:C++ Cmd_ForwardToServer函數的具體用法?C++ Cmd_ForwardToServer怎麽用?C++ Cmd_ForwardToServer使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了Cmd_ForwardToServer函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: Host_Tell_f
void Host_Tell_f(void)
{
client_t *client;
client_t *save;
int j;
char *p;
char text[64];
if (cmd_source == src_command)
{
Cmd_ForwardToServer ();
return;
}
if (Cmd_Argc () < 3)
return;
Q_strcpy(text, host_client->name);
Q_strcat(text, ": ");
p = Cmd_Args();
// remove quotes if present
if (*p == '"')
{
p++;
p[Q_strlen(p)-1] = 0;
}
// check length & truncate if necessary
j = sizeof(text) - 2 - Q_strlen(text); // -2 for /n and null terminator
if (Q_strlen(p) > j)
p[j] = 0;
strcat (text, p);
strcat (text, "\n");
save = host_client;
for (j = 0, client = svs.clients; j < svs.maxclients; j++, client++)
{
if (!client->active || !client->spawned)
continue;
if (Q_strcasecmp(client->name, Cmd_Argv(1)))
continue;
host_client = client;
SV_ClientPrintf("%s", text);
break;
}
host_client = save;
}
示例2: NET_Ban_f
void NET_Ban_f(void)
{
char addrStr [32];
char maskStr [32];
void (*print)(char *fmt, ...);
if (cmd_source == src_command) {
if (!sv.active) {
Cmd_ForwardToServer();
return;
}
print = Con_Printf;
} else {
if (pr_global_struct->deathmatch && !host_client->privileged) {
return;
}
print = SV_ClientPrintf;
}
switch (Cmd_Argc()) {
case 1:
if (((struct in_addr *)&banAddr)->s_addr) {
Q_strcpy(addrStr, inet_ntoa(*(struct in_addr *)&banAddr));
Q_strcpy(maskStr, inet_ntoa(*(struct in_addr *)&banMask));
print("Banning %s [%s]\n", addrStr, maskStr);
} else {
print("Banning not active\n");
}
break;
case 2:
if (Q_strcasecmp(Cmd_Argv(1), "off") == 0) {
banAddr = 0x00000000;
} else {
banAddr = inet_addr(Cmd_Argv(1));
}
banMask = 0xffffffff;
break;
case 3:
banAddr = inet_addr(Cmd_Argv(1));
banMask = inet_addr(Cmd_Argv(2));
break;
default:
print("BAN ip_address [mask]\n");
break;
}
}
示例3: Host_Status_f
/*
==================
Host_Status_f
==================
*/
void Host_Status_f (void)
{
client_t *client;
int seconds;
int minutes;
int hours = 0;
int j;
void (*print_fn) (const char *fmt, ...) __fp_attribute__((__format__(__printf__,1,2)));
if (cmd_source == src_command)
{
if (!sv.active)
{
Cmd_ForwardToServer ();
return;
}
print_fn = Con_Printf;
}
else
print_fn = SV_ClientPrintf;
print_fn ("host: %s\n", Cvar_VariableString ("hostname"));
print_fn ("version: %4.2f\n", VERSION);
if (tcpipAvailable)
print_fn ("tcp/ip: %s\n", my_tcpip_address);
if (ipxAvailable)
print_fn ("ipx: %s\n", my_ipx_address);
print_fn ("map: %s\n", sv.name);
print_fn ("players: %i active (%i max)\n\n", net_activeconnections, svs.maxclients);
for (j = 0, client = svs.clients; j < svs.maxclients; j++, client++)
{
if (!client->active)
continue;
seconds = (int)(net_time - NET_QSocketGetTime(client->netconnection));
minutes = seconds / 60;
if (minutes)
{
seconds -= (minutes * 60);
hours = minutes / 60;
if (hours)
minutes -= (hours * 60);
}
else
hours = 0;
print_fn ("#%-2u %-16.16s %3i %2i:%02i:%02i\n", j+1, client->name, (int)client->edict->v.frags, hours, minutes, seconds);
print_fn (" %s\n", NET_QSocketGetAddressString(client->netconnection));
}
}
示例4: Host_Noclip_f
/*
==================
Host_Noclip_f
==================
*/
void Host_Noclip_f (void)
{
if (cmd_source == src_command)
{
Cmd_ForwardToServer ();
return;
}
if (pr_global_struct->deathmatch)
return;
//johnfitz -- allow user to explicitly set noclip to on or off
switch (Cmd_Argc())
{
case 1:
if (sv_player->v.movetype != MOVETYPE_NOCLIP)
{
noclip_anglehack = true;
sv_player->v.movetype = MOVETYPE_NOCLIP;
SV_ClientPrintf ("noclip ON\n");
}
else
{
noclip_anglehack = false;
sv_player->v.movetype = MOVETYPE_WALK;
SV_ClientPrintf ("noclip OFF\n");
}
break;
case 2:
if (Q_atof(Cmd_Argv(1)))
{
noclip_anglehack = true;
sv_player->v.movetype = MOVETYPE_NOCLIP;
SV_ClientPrintf ("noclip ON\n");
}
else
{
noclip_anglehack = false;
sv_player->v.movetype = MOVETYPE_WALK;
SV_ClientPrintf ("noclip OFF\n");
}
break;
default:
Con_Printf("noclip [value] : toggle noclip mode. values: 0 = off, 1 = on\n");
break;
}
//johnfitz
}
示例5: Cmd_ExecuteString
/*
============
Cmd_ExecuteString
A complete command line has been parsed, so try to execute it
FIXME: lookupnoadd the token to speed search?
============
*/
void Cmd_ExecuteString (char *text)
{
cmd_function_t *cmd;
cmdalias_t *a;
Cmd_TokenizeString (text);
// execute the command line
if (!Cmd_Argc())
return; // no tokens
// check functions
for (cmd=cmd_functions ; cmd ; cmd=cmd->next)
{
if (!Q_strcasecmp (cmd_argv[0],cmd->name))
{
if (!strcmp(cmd->name, "kill"))
{
if ((trace_state == read_trace || trace_state == write_trace))
{
trace_state = stop_trace;
printf("GAJA: command = kill\n");
}
}
if (!cmd->function)
Cmd_ForwardToServer ();
else
cmd->function ();
return;
}
}
// check alias
for (a=cmd_alias ; a ; a=a->next)
{
if (!Q_strcasecmp (cmd_argv[0], a->name))
{
Cbuf_InsertText (a->value);
return;
}
}
// check cvars
if (!Cvar_Command () && (cl_warncmd.value || developer.value))
Con_Printf ("Unknown command \"%s\"\n", Cmd_Argv(0));
}
示例6: Cmd_ExecuteString
/*
============
Cmd_ExecuteString
A complete command line has been parsed, so try to execute it
FIXME: lookupnoadd the token to speed search?
============
*/
void Cmd_ExecuteString (char *text)
{
cmd_function_t *cmd;
cmdalias_t *a;
Cmd_TokenizeString (text, true);
// execute the command line
if (!Cmd_Argc())
return; // no tokens
// check functions
for (cmd=cmd_functions ; cmd ; cmd=cmd->next)
{
if (!Q_strcasecmp (cmd_argv[0],cmd->name))
{
if (!cmd->function)
{ // forward to server command
Cmd_ExecuteString (va("cmd %s", text));
}
else
cmd->function ();
return;
}
}
// check alias
for (a=cmd_alias ; a ; a=a->next)
{
if (!Q_strcasecmp (cmd_argv[0], a->name))
{
if (++alias_count == ALIAS_LOOP_COUNT)
{
Com_Printf ("ALIAS_LOOP_COUNT\n");
return;
}
Cbuf_InsertText (a->value);
return;
}
}
// check cvars
if (Cvar_Command ())
return;
// send it as a server command if we are connected
Cmd_ForwardToServer ();
}
示例7: NET_Ban_f
void
NET_Ban_f(void)
{
char addrStr[32];
char maskStr[32];
void (*print)(const char *fmt, ...) __attribute__((format(printf,1,2)));
if (cmd_source == src_command) {
if (!sv.active) {
Cmd_ForwardToServer();
return;
}
print = Con_Printf;
} else {
if (pr_global_struct->deathmatch)
return;
print = SV_ClientPrintf;
}
switch (Cmd_Argc()) {
case 1:
if (banAddr.s_addr != INADDR_ANY) {
strcpy(addrStr, inet_ntoa(banAddr));
strcpy(maskStr, inet_ntoa(banMask));
print("Banning %s [%s]\n", addrStr, maskStr);
} else
print("Banning not active\n");
break;
case 2:
if (strcasecmp(Cmd_Argv(1), "off") == 0)
banAddr.s_addr = INADDR_ANY;
else
banAddr.s_addr = inet_addr(Cmd_Argv(1));
banMask.s_addr = INADDR_NONE;
break;
case 3:
banAddr.s_addr = inet_addr(Cmd_Argv(1));
banMask.s_addr = inet_addr(Cmd_Argv(2));
break;
default:
print("BAN ip_address [mask]\n");
break;
}
}
示例8: Host_God_f
/*
==================
Host_God_f
Sets client to godmode
==================
*/
void Host_God_f (void)
{
if (cmd_source == src_command)
{
Cmd_ForwardToServer ();
return;
}
if (pr_global_struct->deathmatch && !host_client->privileged)
return;
sv_player->v.flags = (int)sv_player->v.flags ^ FL_GODMODE;
if (!((int)sv_player->v.flags & FL_GODMODE) )
SV_ClientPrintf ("godmode OFF\n");
else
SV_ClientPrintf ("godmode ON\n");
}
示例9: Host_Notarget_f
static void Host_Notarget_f (void)
{
if (cmd_source == src_command)
{
Cmd_ForwardToServer ();
return;
}
if (*sv_globals.deathmatch || skill.integer > 2)
return;
sv_player->v.flags = (int)sv_player->v.flags ^ FL_NOTARGET;
if (!((int)sv_player->v.flags & FL_NOTARGET) )
SV_ClientPrintf (0, "notarget OFF\n");
else
SV_ClientPrintf (0, "notarget ON\n");
}
示例10: Host_God_f
/*
==================
Host_God_f
Sets client to godmode
==================
*/
static void Host_God_f (void)
{
if (cmd_source == src_command)
{
Cmd_ForwardToServer ();
return;
}
if (*sv_globals.deathmatch || *sv_globals.coop || skill.integer > 2)
return;
sv_player->v.flags = (int)sv_player->v.flags ^ FL_GODMODE;
if (!((int)sv_player->v.flags & FL_GODMODE) )
SV_ClientPrintf (0, "godmode OFF\n");
else
SV_ClientPrintf (0, "godmode ON\n");
}
示例11: Host_Notarget_f
void Host_Notarget_f (void)
{
if (cmd_source == src_command)
{
Cmd_ForwardToServer ();
return;
}
if (pr_global_struct->deathmatch && !host_client->privileged)
return;
sv_player->v.flags = (int)sv_player->v.flags ^ FL_NOTARGET;
if (!((int)sv_player->v.flags & FL_NOTARGET) )
SV_ClientPrintf ("notarget OFF\n");
else
SV_ClientPrintf ("notarget ON\n");
}
示例12: Host_Name_f
/*
======================
Host_Name_f
======================
*/
static void Host_Name_f (void)
{
char newName[32];
char *pdest;
if (Cmd_Argc () == 1)
{
Con_Printf ("\"name\" is \"%s\"\n", cl_name.string);
return;
}
if (Cmd_Argc () == 2)
q_strlcpy (newName, Cmd_Argv(1), sizeof(newName));
else
q_strlcpy (newName, Cmd_Args(), sizeof(newName));
newName[15] = 0; // client_t structure actually says name[32].
//this is for the fuckers who put braces in the name causing loadgame to crash.
pdest = strchr(newName,'{');
if (pdest)
{
*pdest = 0; //zap the brace
Con_Printf ("Illegal char in name removed!\n");
}
if (cmd_source == src_command)
{
if (strcmp(cl_name.string, newName) == 0)
return;
Cvar_Set ("_cl_name", newName);
if (cls.state == ca_connected)
Cmd_ForwardToServer ();
return;
}
if (host_client->name[0] && strcmp(host_client->name, "unconnected") )
if (strcmp(host_client->name, newName) != 0)
Con_Printf ("%s renamed to %s\n", host_client->name, newName);
strcpy (host_client->name, newName);
host_client->edict->v.netname = PR_SetEngineString(host_client->name);
// send notification to all clients
MSG_WriteByte (&sv.reliable_datagram, svc_updatename);
MSG_WriteByte (&sv.reliable_datagram, host_client - svs.clients);
MSG_WriteString (&sv.reliable_datagram, host_client->name);
}
示例13: CL_Name_f
void
CL_Name_f(void)
{
char new_name[16];
const char *arg;
if (Cmd_Argc() == 1) {
Con_Printf("\"name\" is \"%s\"\n", cl_name.string);
return;
}
arg = (Cmd_Argc() == 2) ? Cmd_Argv(1) : Cmd_Args();
snprintf(new_name, sizeof(new_name), "%s", arg);
if (!strcmp(cl_name.string, new_name))
return;
Cvar_Set("_cl_name", new_name);
Cmd_ForwardToServer();
}
示例14: Host_QC_Exec
/*
==================
Host_QC_Exec
Execute QC commands from the console
==================
*/
void Host_QC_Exec (void)
{
dfunction_t *f;
if (cmd_source == src_command)
{
Cmd_ForwardToServer ();
return;
}
if (!developer.value)
return;
f = 0;
if ((f = ED_FindFunction(Cmd_Argv(1))) != NULL)
{
pr_global_struct->self = EDICT_TO_PROG(sv_player);
PR_ExecuteProgram ((func_t)(f - pr_functions));
}
else
Con_Printf("bad function\n");
}
示例15: Cmd_ExecuteString_internal
void EXT_FUNC Cmd_ExecuteString_internal(const char* cmdName, cmd_source_t src, IGameClient* client) {
// Search in functions
cmd_function_t *cmd = cmd_functions;
while (cmd)
{
if (!Q_stricmp(cmd_argv[0], cmd->name))
{
cmd->function();
if (g_pcls.demorecording && (cmd->flags & FCMD_HUD_COMMAND) && !g_pcls.spectator)
{
CL_RecordHUDCommand(cmd->name);
}
return;
}
cmd = cmd->next;
}
// Search in aliases
cmdalias_t *a = cmd_alias;
while (a)
{
if (!Q_stricmp(cmd_argv[0], a->name))
{
Cbuf_InsertText(a->value);
return;
}
a = a->next;
}
// Search in cvars
if (!Cvar_Command() && g_pcls.state >= ca_connected)
{
// Send to a server if nothing processed locally and connected
Cmd_ForwardToServer();
}
}