mirror of
https://github.com/libretro/libretro-tyrquake.git
synced 2024-11-23 16:10:09 +00:00
command: split the NQ color command across client/server
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
This commit is contained in:
parent
fbaf680f27
commit
22c61cbe64
35
NQ/cl_main.c
35
NQ/cl_main.c
@ -336,6 +336,40 @@ CL_Name_f(void)
|
||||
Cmd_ForwardToServer();
|
||||
}
|
||||
|
||||
/*
|
||||
==================
|
||||
CL_Color_f
|
||||
==================
|
||||
*/
|
||||
static void
|
||||
CL_Color_f(void)
|
||||
{
|
||||
int top, bottom;
|
||||
|
||||
if (Cmd_Argc() == 1) {
|
||||
top = (int)cl_color.value >> 4;
|
||||
bottom = (int)cl_color.value & 15;
|
||||
Con_Printf("\"color\" is \"%i %i\"\n"
|
||||
"color <0-13> [0-13]\n", top, bottom);
|
||||
return;
|
||||
}
|
||||
|
||||
if (Cmd_Argc() == 2)
|
||||
top = bottom = atoi(Cmd_Argv(1)) & 15;
|
||||
else {
|
||||
top = atoi(Cmd_Argv(1)) & 15;
|
||||
bottom = atoi(Cmd_Argv(2)) & 15;
|
||||
}
|
||||
if (top > 13)
|
||||
top = 13;
|
||||
if (bottom > 13)
|
||||
bottom = 13;
|
||||
|
||||
Cvar_SetValue("_cl_color", top * 16 + bottom);
|
||||
if (cls.state >= ca_connected)
|
||||
Cmd_ForwardToServer();
|
||||
}
|
||||
|
||||
/*
|
||||
===============
|
||||
SetPal
|
||||
@ -813,6 +847,7 @@ CL_Init(void)
|
||||
Cmd_AddCommand("mcache", Mod_Print);
|
||||
|
||||
Cmd_AddCommand("name", CL_Name_f);
|
||||
Cmd_AddCommand("color", CL_Color_f);
|
||||
Cmd_AddCommand("status", NULL);
|
||||
Cmd_AddCommand("god", NULL);
|
||||
Cmd_AddCommand("fly", NULL);
|
||||
|
@ -655,56 +655,6 @@ Host_Tell_f(void)
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
==================
|
||||
Host_Color_f
|
||||
==================
|
||||
*/
|
||||
static void
|
||||
Host_Color_f(void)
|
||||
{
|
||||
int top, bottom;
|
||||
int playercolor;
|
||||
|
||||
if (Cmd_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));
|
||||
else {
|
||||
top = atoi(Cmd_Argv(1));
|
||||
bottom = atoi(Cmd_Argv(2));
|
||||
}
|
||||
|
||||
top &= 15;
|
||||
if (top > 13)
|
||||
top = 13;
|
||||
bottom &= 15;
|
||||
if (bottom > 13)
|
||||
bottom = 13;
|
||||
|
||||
playercolor = top * 16 + bottom;
|
||||
|
||||
if (cmd_source == src_command) {
|
||||
Cvar_SetValue("_cl_color", playercolor);
|
||||
if (cls.state >= ca_connected)
|
||||
Cmd_ForwardToServer();
|
||||
return;
|
||||
}
|
||||
|
||||
host_client->colors = playercolor;
|
||||
host_client->edict->v.team = bottom + 1;
|
||||
|
||||
// send notification to all clients
|
||||
MSG_WriteByte(&sv.reliable_datagram, svc_updatecolors);
|
||||
MSG_WriteByte(&sv.reliable_datagram, host_client - svs.clients);
|
||||
MSG_WriteByte(&sv.reliable_datagram, host_client->colors);
|
||||
}
|
||||
|
||||
/*
|
||||
==================
|
||||
Host_Kill_f
|
||||
@ -1379,7 +1329,6 @@ Host_InitCommands(void)
|
||||
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);
|
||||
|
43
NQ/sv_user.c
43
NQ/sv_user.c
@ -449,6 +449,46 @@ SV_Name_f(client_t *client)
|
||||
MSG_WriteString(&sv.reliable_datagram, client->name);
|
||||
}
|
||||
|
||||
/*
|
||||
==================
|
||||
SV_Color_f
|
||||
==================
|
||||
*/
|
||||
static void
|
||||
SV_Color_f(client_t *client)
|
||||
{
|
||||
int top, bottom;
|
||||
|
||||
if (Cmd_Argc() == 1) {
|
||||
top = client->colors >> 4;
|
||||
bottom = client->colors & 15;
|
||||
SV_ClientPrintf("\"color\" is \"%d %d\"\n"
|
||||
"color <0-13> [0-13]\n", top, bottom);
|
||||
return;
|
||||
}
|
||||
|
||||
if (Cmd_Argc() == 2)
|
||||
top = bottom = atoi(Cmd_Argv(1));
|
||||
else {
|
||||
top = atoi(Cmd_Argv(1));
|
||||
bottom = atoi(Cmd_Argv(2));
|
||||
}
|
||||
top &= 15;
|
||||
if (top > 13)
|
||||
top = 13;
|
||||
bottom &= 15;
|
||||
if (bottom > 13)
|
||||
bottom = 13;
|
||||
|
||||
client->colors = top * 16 + bottom;
|
||||
client->edict->v.team = bottom + 1;
|
||||
|
||||
/* send notification to all clients */
|
||||
MSG_WriteByte(&sv.reliable_datagram, svc_updatecolors);
|
||||
MSG_WriteByte(&sv.reliable_datagram, client - svs.clients);
|
||||
MSG_WriteByte(&sv.reliable_datagram, client->colors);
|
||||
}
|
||||
|
||||
/*
|
||||
==================
|
||||
SV_Status_f
|
||||
@ -596,6 +636,7 @@ typedef struct {
|
||||
|
||||
static client_command_t client_commands[] = {
|
||||
{ "name", SV_Name_f },
|
||||
{ "color", SV_Color_f },
|
||||
{ "status", SV_Status_f },
|
||||
{ "god", SV_God_f },
|
||||
{ "fly", SV_Fly_f },
|
||||
@ -685,8 +726,6 @@ SV_ReadClientMessage(client_t *client)
|
||||
ret = 1;
|
||||
else if (strncasecmp(message, "tell", 4) == 0)
|
||||
ret = 1;
|
||||
else if (strncasecmp(message, "color", 5) == 0)
|
||||
ret = 1;
|
||||
else if (strncasecmp(message, "kill", 4) == 0)
|
||||
ret = 1;
|
||||
else if (strncasecmp(message, "pause", 5) == 0)
|
||||
|
Loading…
Reference in New Issue
Block a user