45 cgi->Com_Printf(
"Usage: %s <server> [<port>]\n",
cgi->Cmd_Argv(0));
51 if (
cgi->Cmd_Argc() == 2) {
54 }
else if (
cgi->Cmd_Argc() == 3) {
63 if (
cgi->GAME_IsTeamEmpty() && !
cgi->GAME_LoadDefaultTeam(
true)) {
64 cgi->UI_Popup(
_(
"Error"),
"%s",
_(
"Assemble a team first"));
68 if (
cgi->Cvar_GetInteger(
"mn_server_need_password")) {
69 cgi->UI_PushWindow(
"serverpassword");
74 cgi->SV_Shutdown(
"Server quit.",
false);
77 cgi->GAME_SetServerInfo(server, serverport);
81 cgi->HUD_InitUI(
"missionoptions");
88 cgi->NET_StreamFree(s);
91 const int cmd =
cgi->NET_ReadByte(
buf);
93 cgi->NET_StreamFree(s);
97 cgi->NET_ReadStringLine(
buf, commandBuf,
sizeof(commandBuf));
99 if (
Q_streq(commandBuf,
"print")) {
101 cgi->NET_ReadString(
buf, paramBuf,
sizeof(paramBuf));
102 cgi->Com_Printf(
"%s\n", paramBuf);
104 cgi->NET_StreamFree(s);
115 cgi->Com_Printf(
"You must set 'rcon_password' before issuing a rcon command.\n");
138 cgi->Com_Printf(
"You are not connected to any server\n");
148 if (
cgi->Cmd_Argc() < 2) {
149 cgi->Com_Printf(
"Usage: %s <command>\n",
cgi->Cmd_Argv(0));
154 cgi->Com_Printf(
"You must set 'rcon_password' before issuing a rcon command.\n");
159 Com_Printf(
"Could not send the rcon command\n");
164 if (
cgi->Com_ServerState())
165 cgi->Cmd_ExecuteString(
"startgame");
167 cgi->Cmd_ExecuteString(
"rcon startgame");
175 cgi->SV_ShutdownWhenEmpty();
184 if (
cgi->Com_ServerState())
188 cgi->Com_Printf(
"disconnecting...\n");
189 cgi->CL_Disconnect();
193 cgi->Com_Printf(
"reconnecting...\n");
206 if (
cgi->Com_ServerState())
207 cgi->Cvar_Set(
"cl_admin",
"1");
209 cgi->Cvar_Set(
"cl_admin",
"0");
219 cgi->Cvar_SetValue(
"cl_teamnum", teamnum);
226 cgi->Com_DPrintf(
DEBUG_CLIENT,
"team %i is already in use: %i (max: %i)\n",
237 int i =
cgi->Cvar_GetInteger(
"cl_teamnum");
244 if (
Q_streq(
cgi->Cmd_Argv(0),
"teamnum_dec")) {
268 char const*
const adrStr =
cgi->Cvar_GetString(
va(
"adr%i",
i));
269 if (adrStr[0] !=
'\0' &&
cgi->Cmd_GenericCompleteFunction(adrStr, partial, match)) {
270 cgi->Com_Printf(
"%s\n", adrStr);
280 for (
int i = 0;
i <
cgi->csi->numGTs;
i++) {
282 cgi->UI_AddOption(&gameTypes, gt->
id,
_(gt->
name), gt->
id);
288 {
"mp_selectteam_init",
GAME_MP_SelectTeam_Init_f,
"Function that gets all connected players and let you choose a free team"},
296 {
"rcon",
GAME_MP_Rcon_f,
"Execute a rcon command - see rcon_password"},
298 {
nullptr,
nullptr,
nullptr}
304 rcon_address =
cgi->Cvar_Get(
"rcon_address",
"", 0,
"Address of the host you would like to control via rcon");
322 cgi->Cvar_Delete(
"rcon_address");
Shared game type headers.
Share stuff between the different cgame implementations.
void Com_Printf(const char *const fmt,...)
const cgame_import_t * cgi
static const cmdList_t mpCallbacks[]
void GAME_MP_CallbacksInit(const cgame_import_t *import)
static void GAME_MP_RconCallback(struct net_stream *s)
bool GAME_MP_Rcon(const char *password, const char *command)
Sends an rcon command to the gameserver that the user is currently connected to, or if this is not th...
static void GAME_MP_Rcon_f(void)
static cvar_t * rcon_address
static void GAME_MP_Reconnect_f(void)
The server is changing levels.
static int GAME_MP_CompleteNetworkAddress(const char *partial, const char **match)
Autocomplete function for some network functions.
static void GAME_MP_SelectTeam_Init_f(void)
Send the SV_CMD_TEAMINFO command to server.
void GAME_MP_CallbacksShutdown(void)
static void GAME_MP_InitUI_f(void)
cvar_t * cl_roundtimelimit
static cvar_t * info_password
static void GAME_MP_TeamNum_f(void)
Increase or decrease the teamnum.
cvar_t * rcon_client_password
static void GAME_MP_Connect_f(void)
cvar_t * cl_maxsoldiersperteam
cvar_t * cl_maxsoldiersperplayer
static void GAME_MP_Disconnect_f(void)
Binding for disconnect console command.
static bool GAME_MP_SetTeamNum(int teamnum)
static void GAME_MP_StartGame_f(void)
Serverlist menu callbacks headers for multiplayer.
void GAME_MP_PingServers_f(void)
The first function called when entering the multiplayer menu, then CL_Frame takes over.
serverList_t * selectedServer
Serverlist management headers for multiplayer.
bool Q_strnull(const char *string)
void Q_strncpyz(char *dest, const char *src, size_t destsize)
Safe strncpy that ensures a trailing zero.
bool Com_sprintf(char *dest, size_t size, const char *fmt,...)
copies formatted string with buffer-size checking
const char * va(const char *format,...)
does a varargs printf into a temp buffer, so I don't need to have varargs versions of all text functi...
This is a cvar definition. Cvars can be user modified and used in our menus e.g.
Atomic structure used to define most of the UI.
Data and interface to share data.