| 1 | /* |
| 2 | * Descent 3 |
| 3 | * Copyright (C) 2024 Parallax Software |
| 4 | * |
| 5 | * This program is free software: you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation, either version 3 of the License, or |
| 8 | * (at your option) any later version. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 17 | |
| 18 | --- HISTORICAL COMMENTS FOLLOW --- |
| 19 | |
| 20 | * $Logfile: /DescentIII/Main/dmfc/dmfcinputcommand.cpp $ |
| 21 | * $Revision: 1.1.1.1 $ |
| 22 | * $Date: 2003/08/26 03:57:20 $ |
| 23 | * $Author: kevinb $ |
| 24 | * |
| 25 | * Functions for Input commands (function handlers) |
| 26 | * |
| 27 | * $Log: dmfcinputcommand.cpp,v $ |
| 28 | * Revision 1.1.1.1 2003/08/26 03:57:20 kevinb |
| 29 | * initial 1.5 import |
| 30 | * |
| 31 | * |
| 32 | * 26 2/08/00 4:33a Jason |
| 33 | * Fixed memory overwrite during string parse |
| 34 | * |
| 35 | * 25 7/14/99 11:47a Jeff |
| 36 | * localized text for patch fixes |
| 37 | * |
| 38 | * 24 7/09/99 6:18p Jeff |
| 39 | * added $remoteadminlogout and $wait commands |
| 40 | * |
| 41 | * 23 7/08/99 2:39a Jeff |
| 42 | * rough implementation of remote administration checked in. Still needs |
| 43 | * some polishing, but should work basically. |
| 44 | * |
| 45 | * 22 5/07/99 12:52p Jeff |
| 46 | * audio taunt icon is ppic if available. coop has hard max team set of 4 |
| 47 | * |
| 48 | * 21 4/30/99 10:53p Jeff |
| 49 | * added $warp command |
| 50 | * |
| 51 | * 20 3/17/99 12:24p Jeff |
| 52 | * converted DMFC to be COM interface |
| 53 | * |
| 54 | * 19 2/11/99 12:50a Jeff |
| 55 | * changed names of exported variables |
| 56 | * |
| 57 | * 18 1/31/99 7:26p Matt |
| 58 | * Renamed a bunch of functions to have HUD capitalized |
| 59 | * |
| 60 | * 17 1/19/99 3:55a Jeff |
| 61 | * all strings localized out |
| 62 | * |
| 63 | * 16 1/06/99 12:53a Jeff |
| 64 | * put in support for $piggyback and $observer |
| 65 | * |
| 66 | * 15 1/04/99 12:21p Jeff |
| 67 | * added support for hosts.allow/deny and updates stats manager a little |
| 68 | * |
| 69 | * 14 12/08/98 12:17p Jeff |
| 70 | * various changes that include an improved Team Control dialog (doesn't |
| 71 | * switch teams until exit..) and spew/respawn players that change teams |
| 72 | * |
| 73 | * 13 11/16/98 5:35p Jeff |
| 74 | * removed log functions, added support for changing team names, fixed ctf |
| 75 | * to work better with different team names |
| 76 | * |
| 77 | * 12 11/11/98 7:19p Jeff |
| 78 | * changes made so that a dedicated server's team is always -1 (team game |
| 79 | * or not) |
| 80 | * |
| 81 | * 11 11/02/98 11:41a Jeff |
| 82 | * use my parse routines, and display help if the format of the command |
| 83 | * was wrong |
| 84 | * |
| 85 | * 10 11/01/98 1:59a Jeff |
| 86 | * made a $help inputcommand for help in a dedicated server environment |
| 87 | * |
| 88 | * 9 10/24/98 2:35p Matt |
| 89 | * Changed "callsign" to "name" or "player name" in the multiplayer menus |
| 90 | * and commands. |
| 91 | * |
| 92 | * 8 10/20/98 12:16p Jeff |
| 93 | * added death message filter, hud callsign filter |
| 94 | * |
| 95 | * 7 10/15/98 1:34p Jeff |
| 96 | * added scrollable onscreen menu. Remove ban in dmfc. prejoin event |
| 97 | * |
| 98 | * 6 10/08/98 3:37p Jeff |
| 99 | * general improvements (Netgame info things, save to registry). Changes |
| 100 | * so it would send packets on NETSEQ_OBJECTS |
| 101 | * |
| 102 | * 5 10/05/98 2:50p Jeff |
| 103 | * |
| 104 | * 4 9/30/98 3:50p Jeff |
| 105 | * general improvements (many) |
| 106 | * |
| 107 | * 3 9/23/98 4:17p Jeff |
| 108 | * basic changes/improvements, started changing death messages |
| 109 | * |
| 110 | * 2 9/21/98 7:11p Jeff |
| 111 | * made InputCommand interface API and moved existing input commands to |
| 112 | * the interface. Changed mprintf/ASSERT so they are valid in DMFC |
| 113 | * |
| 114 | * $NoKeywords: $ |
| 115 | */ |
| 116 | |
| 117 | #include "gamedll_header.h" |
| 118 | #include "DMFC.h" |
| 119 | #include "dmfcinternal.h" |
| 120 | |
| 121 | #include <algorithm> |
| 122 | |
| 123 | extern DMFCBase *basethis; |
| 124 | |
| 125 | bool StringParseWord(const char *string, char *word, int size, const char **newpos) { |
| 126 | *newpos = string; |
| 127 | word[0] = '\0'; |
| 128 | |
| 129 | // get through all the whitespace |
| 130 | while (*string && *string == ' ') |
| 131 | string++; |
| 132 | if (!(*string)) { |
| 133 | // nothing is left in the string |
| 134 | *newpos = string; |
| 135 | return false; |
| 136 | } |
| 137 | |
| 138 | // we're at the beginning of a word |
| 139 | while (*string && *string != ' ') { |
| 140 | if (size > 1) { |
| 141 | *word = *string; |
| 142 | size--; |
| 143 | word++; |
| 144 | } |
| 145 | |
| 146 | string++; |
| 147 | } |
| 148 | |
| 149 | // tack on an ending \0 |
| 150 | *word = '\0'; |
| 151 | |
| 152 | *newpos = string; |
| 153 | return true; |
| 154 | } |
| 155 | |
| 156 | bool StringParseNumber(const char *string, int *number, const char **newpos) { |
| 157 | char temp[10]; |
| 158 | bool ret = StringParseWord(string, temp, 10, newpos); |
| 159 | if (!ret) { |
| 160 | *number = 0; |
| 161 | return false; |
| 162 | } |
| 163 | |
| 164 | *number = atoi(temp); |
| 165 | return true; |
| 166 | } |
| 167 | |
| 168 | // handle the client wishing to change teams |
| 169 | // Usage: "$team <string team_name>" where team_name is the name of the team you want to change to |
| 170 | void DMFCInputCommand_Team(const char *input_string) { |
| 171 | char team[100]; |
| 172 | |
| 173 | // parse "$team" |
| 174 | if (!StringParseWord(input_string, team, 100, &input_string)) { |
| 175 | basethis->DisplayInputCommandHelp(DTXT_IC_TEAM); |
| 176 | return; |
| 177 | } |
| 178 | |
| 179 | // parse team name |
| 180 | if (!StringParseWord(input_string, team, 100, &input_string)) { |
| 181 | basethis->DisplayInputCommandHelp(DTXT_IC_TEAM); |
| 182 | return; |
| 183 | } |
| 184 | |
| 185 | int t = basethis->GetTeamFromString(team); |
| 186 | |
| 187 | int curr_team = basethis->Players[basethis->GetPlayerNum()].team; |
| 188 | |
| 189 | if ((t == -1) || (t == curr_team) || (curr_team == -1)) |
| 190 | return; |
| 191 | |
| 192 | mprintf(0, "Attempting to change teams to %s team\n", team); |
| 193 | DLLAddHUDMessage(DTXT_TEAMCHANGEATTEMPT, team); |
| 194 | basethis->RequestTeamChange(t, basethis->GetPlayerNum(), true); |
| 195 | } |
| 196 | |
| 197 | // handle the server wanting to change the team for a player |
| 198 | // Usage: "$changeteam <int pnum> <string team_name>" where pnum is the playernum, and team_name is the name of the |
| 199 | // team |
| 200 | void DMFCInputCommand_ChangeTeam(const char *input_string) { |
| 201 | if (basethis->GetLocalRole() != LR_SERVER) |
| 202 | return; |
| 203 | char team[100]; |
| 204 | int p; |
| 205 | |
| 206 | // parse "$changeteam" |
| 207 | if (!StringParseWord(input_string, team, 100, &input_string)) { |
| 208 | basethis->DisplayInputCommandHelp(DTXT_IC_CHANGETEAM); |
| 209 | return; |
| 210 | } |
| 211 | |
| 212 | // parse the pnum |
| 213 | if (!StringParseNumber(input_string, &p, &input_string)) { |
| 214 | basethis->DisplayInputCommandHelp(DTXT_IC_CHANGETEAM); |
| 215 | return; |
| 216 | } |
| 217 | |
| 218 | // parse the newteam name |
| 219 | if (!StringParseWord(input_string, team, 100, &input_string)) { |
| 220 | basethis->DisplayInputCommandHelp(DTXT_IC_CHANGETEAM); |
| 221 | return; |
| 222 | } |
| 223 | |
| 224 | int t = basethis->GetTeamFromString(team); |
| 225 | |
| 226 | int curr_team = basethis->Players[p].team; |
| 227 | |
| 228 | if ((!basethis->CheckPlayerNum(p)) || (t == -1) || (t == curr_team) || (curr_team == -1)) |
| 229 | return; |
| 230 | |
| 231 | mprintf(0, "Attempting to change %s to %s team\n", basethis->Players[p].callsign, team); |
| 232 | DLLAddHUDMessage(DTXT_STEAMCHANGEATTEMPT, basethis->Players[p].callsign, team); |
| 233 | basethis->RequestTeamChange(t, p, true); |
| 234 | } |
| 235 | |
| 236 | // handle the client requesting playerinfo for a player |
| 237 | // Usage: "$playerinfo <int pnum>" where pnum is the playernum |
| 238 | void DMFCInputCommand_PlayerInfo(const char *input_string) { |
| 239 | int p; |
| 240 | char temp[20]; |
| 241 | |
| 242 | // parse "$playerinfo" |
| 243 | if (!StringParseWord(input_string, temp, 20, &input_string)) { |
| 244 | basethis->DisplayInputCommandHelp(DTXT_IC_PLAYERINFO); |
| 245 | return; |
| 246 | } |
| 247 | |
| 248 | // parse pnum |
| 249 | if (!StringParseNumber(input_string, &p, &input_string)) { |
| 250 | basethis->DisplayInputCommandHelp(DTXT_IC_PLAYERINFO); |
| 251 | return; |
| 252 | } |
| 253 | |
| 254 | SwitchPlayerInfo(p); |
| 255 | |
| 256 | if (basethis->CheckPlayerNum(p)) { |
| 257 | DLLAddHUDMessage(DTXT_GETPLAYERINFO, basethis->Players[p].callsign); |
| 258 | } |
| 259 | |
| 260 | if (basethis->IAmDedicatedServer()) { |
| 261 | basethis->DisplayPlayerInfo(BAD_BITMAP_HANDLE, true); |
| 262 | } |
| 263 | } |
| 264 | |
| 265 | // handle the server requesting an autobalance of teams |
| 266 | // Usage: "$balance" |
| 267 | void DMFCInputCommand_Balance(const char *input_string) { |
| 268 | if (basethis->GetLocalRole() != LR_SERVER) |
| 269 | return; |
| 270 | BalanceTeams(0); |
| 271 | DLLAddHUDMessage(DTXT_BALANCETEAMMSG); |
| 272 | } |
| 273 | |
| 274 | // handle turning off/on allowing the autobalancing of teams by the server |
| 275 | // Usage: "$autobalance <off/on>" if off/on is "off" (or equivalent) it will turn it off, else turn it on |
| 276 | void DMFCInputCommand_AutoBalance(const char *input_string) { |
| 277 | if (basethis->GetLocalRole() != LR_SERVER) |
| 278 | return; |
| 279 | char s[20]; |
| 280 | |
| 281 | // parse "$autobalance" |
| 282 | if (!StringParseWord(input_string, s, 20, &input_string)) { |
| 283 | basethis->DisplayInputCommandHelp(DTXT_IC_AUTOBALANCE); |
| 284 | return; |
| 285 | } |
| 286 | |
| 287 | // parse the off/on |
| 288 | if (!StringParseWord(input_string, s, 20, &input_string)) { |
| 289 | basethis->DisplayInputCommandHelp(DTXT_IC_AUTOBALANCE); |
| 290 | return; |
| 291 | } |
| 292 | |
| 293 | int on = 1; |
| 294 | |
| 295 | if (!strnicmp(s, DTXT_MNUOFF, strlen(DTXT_MNUOFF))) |
| 296 | on = 0; |
| 297 | SwitchAutoTeamSelect(on); |
| 298 | DLLAddHUDMessage(DTXT_AUTOTEAMBALANCEMSG, (on) ? DTXT_MNUON : DTXT_MNUOFF); |
| 299 | } |
| 300 | |
| 301 | // handle turning off/on allowing clients to change their team |
| 302 | // Usage: "$allowteamchange <off/on>" if off/on is "off" (or equivalent) it will turn it off, else turn it on |
| 303 | void DMFCInputCommand_AllowTeamChange(const char *input_string) { |
| 304 | if (basethis->GetLocalRole() != LR_SERVER) |
| 305 | return; |
| 306 | char s[20]; |
| 307 | |
| 308 | // parse "$allowteamchange" |
| 309 | if (!StringParseWord(input_string, s, 20, &input_string)) { |
| 310 | basethis->DisplayInputCommandHelp(DTXT_IC_ALLOWTEAMCHANGE); |
| 311 | return; |
| 312 | } |
| 313 | |
| 314 | // parse off/on |
| 315 | if (!StringParseWord(input_string, s, 20, &input_string)) { |
| 316 | basethis->DisplayInputCommandHelp(DTXT_IC_ALLOWTEAMCHANGE); |
| 317 | return; |
| 318 | } |
| 319 | |
| 320 | int on = 1; |
| 321 | if (!strnicmp(s, DTXT_MNUOFF, strlen(DTXT_MNUOFF))) |
| 322 | on = 0; |
| 323 | |
| 324 | SwitchTeamChange(on); |
| 325 | DLLAddHUDMessage(DTXT_ALLOWTEAMCHANGEMSG, (on) ? DTXT_MNUON : DTXT_MNUOFF); |
| 326 | } |
| 327 | |
| 328 | // handles kicking a player from the game |
| 329 | // Usage: "$kick <int pnum>" where pnum is the playernumber of the player you want to kick |
| 330 | void DMFCInputCommand_Kick(const char *input_string) { |
| 331 | if (basethis->GetLocalRole() != LR_SERVER) |
| 332 | return; |
| 333 | int p; |
| 334 | char temp[20]; |
| 335 | |
| 336 | // parse "$kick" |
| 337 | if (!StringParseWord(input_string, temp, 20, &input_string)) { |
| 338 | basethis->DisplayInputCommandHelp(DTXT_IC_KICK); |
| 339 | return; |
| 340 | } |
| 341 | |
| 342 | // parse pnum |
| 343 | if (!StringParseNumber(input_string, &p, &input_string)) { |
| 344 | basethis->DisplayInputCommandHelp(DTXT_IC_KICK); |
| 345 | return; |
| 346 | } |
| 347 | |
| 348 | if (!basethis->CheckPlayerNum(p)) |
| 349 | return; |
| 350 | KickPlayer(p); |
| 351 | if (p != *basethis->Player_num) |
| 352 | DLLAddHUDMessage(DTXT_KICKMSG, basethis->Players[p].callsign); |
| 353 | } |
| 354 | |
| 355 | // handles banning a player from the game |
| 356 | // Usage: "$ban <int pnum>" where pnum is the playernumber of the player to ban |
| 357 | void DMFCInputCommand_Ban(const char *input_string) { |
| 358 | if (basethis->GetLocalRole() != LR_SERVER) |
| 359 | return; |
| 360 | int p; |
| 361 | char temp[20]; |
| 362 | |
| 363 | // parse "$ban" |
| 364 | if (!StringParseWord(input_string, temp, 20, &input_string)) { |
| 365 | basethis->DisplayInputCommandHelp(DTXT_IC_BAN); |
| 366 | return; |
| 367 | } |
| 368 | |
| 369 | // parse pnum |
| 370 | if (!StringParseNumber(input_string, &p, &input_string)) { |
| 371 | basethis->DisplayInputCommandHelp(DTXT_IC_BAN); |
| 372 | return; |
| 373 | } |
| 374 | |
| 375 | if (!basethis->CheckPlayerNum(p)) |
| 376 | return; |
| 377 | |
| 378 | BanPlayer(p); |
| 379 | if (p != *basethis->Player_num) |
| 380 | DLLAddHUDMessage(DTXT_BANMSG, basethis->Players[p].callsign); |
| 381 | } |
| 382 | |
| 383 | // handles ending the level |
| 384 | // Usage: "$endlevel" |
| 385 | void DMFCInputCommand_EndLevel(const char *input_string) { |
| 386 | if (basethis->GetLocalRole() != LR_SERVER) |
| 387 | return; |
| 388 | EndMultiLevel(0); |
| 389 | DLLAddHUDMessage(DTXT_ENDLEVELMSG); |
| 390 | } |
| 391 | |
| 392 | // handles the request to see all the players in the game |
| 393 | // Usage: "$players" |
| 394 | void DMFCInputCommand_Players(const char *input_string) { |
| 395 | // Dedicated server print out of all the players and their player nums |
| 396 | DPrintf(DTXT_PLAYERLISTHEADER); |
| 397 | for (int i = 0; i < DLLMAX_PLAYERS; i++) { |
| 398 | if (basethis->CheckPlayerNum(i)) { |
| 399 | DPrintf("%02d: %s\n", i, basethis->Players[i].callsign); |
| 400 | } |
| 401 | } |
| 402 | } |
| 403 | |
| 404 | // handles a request to see the scores/stats of the game (up to the mod to display the scores on request) |
| 405 | // Usage: "$scores" |
| 406 | void DMFCInputCommand_Scores(const char *input_string) { |
| 407 | int level; |
| 408 | char temp[20]; |
| 409 | |
| 410 | // parse $scores |
| 411 | if (!StringParseWord(input_string, temp, 20, &input_string)) { |
| 412 | basethis->DisplayInputCommandHelp(DTXT_IC_SCORES); |
| 413 | return; |
| 414 | } |
| 415 | |
| 416 | // see if there is a level |
| 417 | if (!StringParseNumber(input_string, &level, &input_string)) |
| 418 | level = -1; |
| 419 | |
| 420 | // call the event that the user want to see the scores (dedicated server |
| 421 | basethis->CallOnPrintScores(level); |
| 422 | } |
| 423 | |
| 424 | // handles a request to turn on/off displaying callsigns on the HUD during the game. |
| 425 | // Usage: "$hudnames <full/team/none>" full = everyone team = only teammates none = noone |
| 426 | // NOTE: You can only set your HUD Callsign level up to the level that the server is |
| 427 | // So if the server is only allowing up to team, you won't be able to set to full |
| 428 | void DMFCInputCommand_HudCallsigns(const char *input_string) { |
| 429 | char s[20]; |
| 430 | |
| 431 | // parse "$hudnames" |
| 432 | if (!StringParseWord(input_string, s, 20, &input_string)) { |
| 433 | basethis->DisplayInputCommandHelp(DTXT_IC_HUDNAME); |
| 434 | return; |
| 435 | } |
| 436 | |
| 437 | // parse the level |
| 438 | if (!StringParseWord(input_string, s, 20, &input_string)) { |
| 439 | basethis->DisplayInputCommandHelp(DTXT_IC_HUDNAME); |
| 440 | return; |
| 441 | } |
| 442 | |
| 443 | uint8_t level = HUD_CALLSIGN_LEVEL_NONE; |
| 444 | if (!stricmp(s, DTXT_OSM_FULL)) |
| 445 | level = HUD_CALLSIGN_LEVEL_FULL; |
| 446 | else if (!stricmp(s, DTXT_IC_TEAM)) |
| 447 | level = HUD_CALLSIGN_LEVEL_TEAM; |
| 448 | |
| 449 | basethis->SwitchShowHudCallsignLevel(level); |
| 450 | } |
| 451 | |
| 452 | // handles a request from the server to set the max HUD Callsign level |
| 453 | // Usage: "$serverhudnames <full/team/none>" same as $hudname but sets the max level for the server |
| 454 | void DMFCInputCommand_ServerHudCallsigns(const char *input_string) { |
| 455 | if (basethis->GetLocalRole() != LR_SERVER) |
| 456 | return; |
| 457 | |
| 458 | char s[20]; |
| 459 | |
| 460 | // parse "$serverhudnames" |
| 461 | if (!StringParseWord(input_string, s, 20, &input_string)) { |
| 462 | basethis->DisplayInputCommandHelp(DTXT_IC_SERVERHUDNAMES); |
| 463 | return; |
| 464 | } |
| 465 | |
| 466 | // parse the level |
| 467 | if (!StringParseWord(input_string, s, 20, &input_string)) { |
| 468 | basethis->DisplayInputCommandHelp(DTXT_IC_SERVERHUDNAMES); |
| 469 | return; |
| 470 | } |
| 471 | |
| 472 | uint8_t level = HUD_CALLSIGN_LEVEL_NONE; |
| 473 | if (!stricmp(s, DTXT_OSM_FULL)) |
| 474 | level = HUD_CALLSIGN_LEVEL_FULL; |
| 475 | else if (!stricmp(s, DTXT_IC_TEAM)) |
| 476 | level = HUD_CALLSIGN_LEVEL_TEAM; |
| 477 | |
| 478 | basethis->SwitchServerHudCallsignLevel(level); |
| 479 | } |
| 480 | |
| 481 | // handles a request to save the game stats to file |
| 482 | // Usage: "$savestats" |
| 483 | void DMFCInputCommand_SaveStats(const char *input_string) { SaveStatsToFile(0); } |
| 484 | |
| 485 | // handles a request to enable/disable statistical messages |
| 486 | // Usage: "$statmsgs on/off" |
| 487 | void DMFCInputCommand_StatMsgs(const char *input_string) { |
| 488 | char s[20]; |
| 489 | |
| 490 | // parse "$statmsgs" |
| 491 | if (!StringParseWord(input_string, s, 20, &input_string)) { |
| 492 | basethis->DisplayInputCommandHelp(DTXT_IC_STATMSGS); |
| 493 | return; |
| 494 | } |
| 495 | |
| 496 | // parse the level |
| 497 | if (!StringParseWord(input_string, s, 20, &input_string)) { |
| 498 | basethis->DisplayInputCommandHelp(DTXT_IC_STATMSGS); |
| 499 | return; |
| 500 | } |
| 501 | |
| 502 | bool on = true; |
| 503 | if (!strnicmp(s, DTXT_MNUOFF, strlen(DTXT_MNUOFF))) |
| 504 | on = false; |
| 505 | basethis->EnableStatisticalMessages(on); |
| 506 | DLLAddHUDMessage(DTXT_STATSMSGSET, (on) ? DTXT_MNUON : DTXT_MNUOFF); |
| 507 | } |
| 508 | |
| 509 | // handles a request to enable/disable the autosaving of the game stats on level end |
| 510 | // Usage: "$autosavelevel on/off" |
| 511 | void DMFCInputCommand_AutoSaveLevel(const char *input_string) { |
| 512 | char s[20]; |
| 513 | |
| 514 | // parse "$autosavelevel" |
| 515 | if (!StringParseWord(input_string, s, 20, &input_string)) { |
| 516 | basethis->DisplayInputCommandHelp(DTXT_IC_AUTOSAVELEVEL); |
| 517 | return; |
| 518 | } |
| 519 | |
| 520 | // parse the on/off |
| 521 | if (!StringParseWord(input_string, s, 20, &input_string)) { |
| 522 | basethis->DisplayInputCommandHelp(DTXT_IC_AUTOSAVELEVEL); |
| 523 | return; |
| 524 | } |
| 525 | |
| 526 | bool on = true; |
| 527 | if (!strnicmp(s, DTXT_MNUOFF, strlen(DTXT_MNUOFF))) |
| 528 | on = false; |
| 529 | basethis->EnableAutoSaveLevelEnd(on); |
| 530 | DLLAddHUDMessage(DTXT_AUTOSAVELEVELMSG, (on) ? DTXT_MNUON : DTXT_MNUOFF); |
| 531 | } |
| 532 | |
| 533 | // handles a request to enable/disable the autosaving of the game stats if we disconnect |
| 534 | // Usage: "$autosavedisconnect on/off" |
| 535 | void DMFCInputCommand_AutoSaveDisconnect(const char *input_string) { |
| 536 | char s[20]; |
| 537 | |
| 538 | // parse the "$autosavedisconnect" |
| 539 | if (!StringParseWord(input_string, s, 20, &input_string)) { |
| 540 | basethis->DisplayInputCommandHelp(DTXT_IC_AUTOSAVEDISC); |
| 541 | return; |
| 542 | } |
| 543 | |
| 544 | if (!StringParseWord(input_string, s, 20, &input_string)) { |
| 545 | basethis->DisplayInputCommandHelp(DTXT_IC_AUTOSAVEDISC); |
| 546 | return; |
| 547 | } |
| 548 | |
| 549 | bool on = true; |
| 550 | if (!strnicmp(s, DTXT_MNUOFF, strlen(DTXT_MNUOFF))) |
| 551 | on = false; |
| 552 | basethis->EnableAutoSaveDisconnect(on); |
| 553 | DLLAddHUDMessage(DTXT_AUTOSAVEDISCMSG, (on) ? DTXT_MNUON : DTXT_MNUOFF); |
| 554 | } |
| 555 | |
| 556 | // handles changing the level time limit of a netgame on the fly |
| 557 | // Usage: "$settimelimit <int minutes>" where minutes is the number of minutes |
| 558 | void DMFCInputCommand_SetTimeLimit(const char *input_string) { |
| 559 | if (basethis->GetLocalRole() != LR_SERVER) |
| 560 | return; |
| 561 | int d; |
| 562 | char temp[20]; |
| 563 | |
| 564 | // parse "$settimelimit" |
| 565 | if (!StringParseWord(input_string, temp, 20, &input_string)) { |
| 566 | basethis->DisplayInputCommandHelp(DTXT_IC_SETTIMELIMIT); |
| 567 | return; |
| 568 | } |
| 569 | |
| 570 | // parse the amount |
| 571 | if (!StringParseNumber(input_string, &d, &input_string)) { |
| 572 | basethis->DisplayInputCommandHelp(DTXT_IC_SETTIMELIMIT); |
| 573 | return; |
| 574 | } |
| 575 | |
| 576 | if (d < 0) |
| 577 | d = 0; |
| 578 | |
| 579 | basethis->Netgame->timelimit = d; |
| 580 | |
| 581 | if (d == 0) { |
| 582 | basethis->Netgame->flags &= ~NF_TIMER; |
| 583 | } else { |
| 584 | basethis->Netgame->flags |= NF_TIMER; |
| 585 | } |
| 586 | |
| 587 | if (basethis->Netgame->flags & NF_TIMER) |
| 588 | DLLAddHUDMessage(DTXT_TIMELIMITSETMSG, d); |
| 589 | else |
| 590 | DLLAddHUDMessage(DTXT_TIMELIMITOFFMSG); |
| 591 | |
| 592 | basethis->SendNetGameInfoSync(); |
| 593 | } |
| 594 | |
| 595 | // handles changing the level goal limit of a netgame on the fly |
| 596 | // Usage: "$setgoallimit <int goal>" where goal is the number of points |
| 597 | void DMFCInputCommand_SetGoalLimit(const char *input_string) { |
| 598 | if (basethis->GetLocalRole() != LR_SERVER) |
| 599 | return; |
| 600 | int d; |
| 601 | char temp[20]; |
| 602 | |
| 603 | // parse "$setgoallimit" |
| 604 | if (!StringParseWord(input_string, temp, 20, &input_string)) { |
| 605 | basethis->DisplayInputCommandHelp(DTXT_IC_SETGOALLIMIT); |
| 606 | return; |
| 607 | } |
| 608 | |
| 609 | if (!StringParseNumber(input_string, &d, &input_string)) { |
| 610 | basethis->DisplayInputCommandHelp(DTXT_IC_SETGOALLIMIT); |
| 611 | return; |
| 612 | } |
| 613 | |
| 614 | if (d < 0) |
| 615 | d = 0; |
| 616 | basethis->Netgame->killgoal = d; |
| 617 | |
| 618 | if (d == 0) { |
| 619 | basethis->Netgame->flags &= ~NF_KILLGOAL; |
| 620 | } else { |
| 621 | basethis->Netgame->flags |= NF_KILLGOAL; |
| 622 | } |
| 623 | |
| 624 | if (basethis->Netgame->flags & NF_KILLGOAL) |
| 625 | DLLAddHUDMessage(DTXT_GOALLIMITSETMSG, d); |
| 626 | else |
| 627 | DLLAddHUDMessage(DTXT_GOALLIMITOFFMSG); |
| 628 | |
| 629 | basethis->SendNetGameInfoSync(); |
| 630 | } |
| 631 | |
| 632 | // handles changing the number of max players in a netgame |
| 633 | // Usage: "$setmaxplayers <int max>" where max is the maximum players |
| 634 | void DMFCInputCommand_SetMaxPlayers(const char *input_string) { |
| 635 | if (basethis->GetLocalRole() != LR_SERVER) |
| 636 | return; |
| 637 | int d; |
| 638 | char temp[20]; |
| 639 | |
| 640 | // parse "$setmaxplayers" |
| 641 | if (!StringParseWord(input_string, temp, 20, &input_string)) { |
| 642 | basethis->DisplayInputCommandHelp(DTXT_IC_SETMAXPLAYERS); |
| 643 | return; |
| 644 | } |
| 645 | |
| 646 | // parse the number |
| 647 | if (!StringParseNumber(input_string, &d, &input_string)) { |
| 648 | basethis->DisplayInputCommandHelp(DTXT_IC_SETMAXPLAYERS); |
| 649 | return; |
| 650 | } |
| 651 | |
| 652 | // get the number of players in the game currently |
| 653 | int curr_count = 0; |
| 654 | for (int i = 0; i < DLLMAX_PLAYERS; i++) { |
| 655 | if (basethis->CheckPlayerNum(i)) |
| 656 | curr_count++; |
| 657 | } |
| 658 | if (d < curr_count) |
| 659 | d = curr_count; |
| 660 | if (d > basethis->Hard_max_players) |
| 661 | d = basethis->Hard_max_players; |
| 662 | |
| 663 | basethis->Netgame->max_players = d; |
| 664 | |
| 665 | DLLAddHUDMessage(DTXT_MAXPLAYERSSETMSG, d); |
| 666 | |
| 667 | basethis->SendNetGameInfoSync(); |
| 668 | } |
| 669 | |
| 670 | // handles changing the respawn time of the powerups in a level of a netgame |
| 671 | // Usage: "$setrespawntime <int seconds>" where seconds is the time in seconds |
| 672 | void DMFCInputCommand_SetRespawnTime(const char *input_string) { |
| 673 | if (basethis->GetLocalRole() != LR_SERVER) |
| 674 | return; |
| 675 | int d; |
| 676 | char temp[20]; |
| 677 | |
| 678 | // parse "$setrespawntime" |
| 679 | if (!StringParseWord(input_string, temp, 20, &input_string)) { |
| 680 | basethis->DisplayInputCommandHelp(DTXT_IC_SETRESPAWNTIME); |
| 681 | return; |
| 682 | } |
| 683 | |
| 684 | // parse the value |
| 685 | if (!StringParseNumber(input_string, &d, &input_string)) { |
| 686 | basethis->DisplayInputCommandHelp(DTXT_IC_SETRESPAWNTIME); |
| 687 | return; |
| 688 | } |
| 689 | |
| 690 | if (d < 1) |
| 691 | d = 1; |
| 692 | |
| 693 | basethis->Netgame->respawn_time = d; |
| 694 | |
| 695 | DLLAddHUDMessage(DTXT_RESPAWNTIMEMSG, d); |
| 696 | |
| 697 | basethis->SendNetGameInfoSync(); |
| 698 | } |
| 699 | |
| 700 | // handle the client requesting netgame info |
| 701 | // Usage: "$netgameinfo" |
| 702 | void DMFCInputCommand_NetGameInfo(const char *input_string) { |
| 703 | bool display = !basethis->IsDisplayingNetGameInfo(); |
| 704 | basethis->SwitchNetGameInfoDisplay((display) ? 1 : 0); |
| 705 | |
| 706 | // always display this on this input command for the dedicated server |
| 707 | basethis->DisplayNetGameInfo(-1, true); |
| 708 | } |
| 709 | |
| 710 | // handle the server changing the pps threshold of the game |
| 711 | // Usage: "$setpps <int pps>" where pps is the Packets Per Second |
| 712 | void DMFCInputCommand_SetPPS(const char *input_string) { |
| 713 | if (basethis->GetLocalRole() != LR_SERVER) |
| 714 | return; |
| 715 | int d; |
| 716 | char temp[20]; |
| 717 | |
| 718 | //"$setpps" |
| 719 | if (!StringParseWord(input_string, temp, 20, &input_string)) { |
| 720 | basethis->DisplayInputCommandHelp(DTXT_IC_SETPPS); |
| 721 | return; |
| 722 | } |
| 723 | |
| 724 | // parse value |
| 725 | if (!StringParseNumber(input_string, &d, &input_string)) { |
| 726 | basethis->DisplayInputCommandHelp(DTXT_IC_SETPPS); |
| 727 | return; |
| 728 | } |
| 729 | |
| 730 | if (d < 1) |
| 731 | d = 1; |
| 732 | if (d > 20) |
| 733 | d = 20; |
| 734 | basethis->Netgame->packets_per_second = d; |
| 735 | |
| 736 | DLLAddHUDMessage(DTXT_PPSSETMSG, d); |
| 737 | |
| 738 | basethis->SendNetGameInfoSync(); |
| 739 | } |
| 740 | |
| 741 | // handles listing the ban list on a dedicated server (so if you want to remove a player from it) |
| 742 | // Usage: "$banlist" |
| 743 | void DMFCInputCommand_BanList(const char *input_string) { |
| 744 | if (basethis->GetLocalRole() != LR_SERVER) |
| 745 | return; |
| 746 | |
| 747 | int size = basethis->GetNumBannedPlayers(); |
| 748 | char buffer[100]; |
| 749 | |
| 750 | for (int i = 0; i < size; i++) { |
| 751 | char *ptr = basethis->GetBannedPlayerCallsign(i); |
| 752 | if (ptr) { |
| 753 | snprintf(buffer, sizeof(buffer), "[%d]%s\n", i, ptr); |
| 754 | DPrintf(buffer); |
| 755 | } |
| 756 | } |
| 757 | } |
| 758 | |
| 759 | // handles removing a ban from a player, given the ban index num (see $banlist) |
| 760 | // Usage: "$removeban <int bannum>" where bannum is the number corresponding to that given during a $banlist |
| 761 | void DMFCInputCommand_RemoveBan(const char *input_string) { |
| 762 | if (basethis->GetLocalRole() != LR_SERVER) |
| 763 | return; |
| 764 | |
| 765 | int d; |
| 766 | char temp[20]; |
| 767 | |
| 768 | //"$removeban" |
| 769 | if (!StringParseWord(input_string, temp, 20, &input_string)) { |
| 770 | basethis->DisplayInputCommandHelp(DTXT_IC_REMOVEBAN); |
| 771 | return; |
| 772 | } |
| 773 | |
| 774 | // value |
| 775 | if (!StringParseNumber(input_string, &d, &input_string)) { |
| 776 | basethis->DisplayInputCommandHelp(DTXT_IC_REMOVEBAN); |
| 777 | return; |
| 778 | } |
| 779 | |
| 780 | if (basethis->RemoveBan(d)) { |
| 781 | DLLAddHUDMessage(DTXT_BANREMOVEDMSG); |
| 782 | DPrintf(DTXT_BANREMOVEDMSG); |
| 783 | } else { |
| 784 | DLLAddHUDMessage(DTXT_BANNOTREMOVEDMSG); |
| 785 | DPrintf(DTXT_BANNOTREMOVEDMSG); |
| 786 | } |
| 787 | } |
| 788 | |
| 789 | // handles changing the filter for death messages |
| 790 | // Usage: "$killmsgfilter <full/simple/none>" |
| 791 | void DMFCInputCommand_KillMsgFilter(const char *input_string) { |
| 792 | char s[20]; |
| 793 | |
| 794 | //"$killmsgfilter" |
| 795 | if (!StringParseWord(input_string, s, 20, &input_string)) { |
| 796 | basethis->DisplayInputCommandHelp(DTXT_IC_KILLMSGFILTER); |
| 797 | return; |
| 798 | } |
| 799 | |
| 800 | // parse level |
| 801 | if (!StringParseWord(input_string, s, 20, &input_string)) { |
| 802 | basethis->DisplayInputCommandHelp(DTXT_IC_KILLMSGFILTER); |
| 803 | return; |
| 804 | } |
| 805 | |
| 806 | uint8_t level = DM_FILTER_FULL; |
| 807 | if (!stricmp(s, DTXT_PLAIN_NONE)) |
| 808 | level = DM_FILTER_NONE; |
| 809 | else if (!stricmp(s, DTXT_OSM_SIMPLE)) |
| 810 | level = DM_FILTER_SIMPLE; |
| 811 | |
| 812 | basethis->SetDeathMessageFilter(level); |
| 813 | } |
| 814 | |
| 815 | // handles the server changing a team's name |
| 816 | // Usage: "$setteamname <team_num> <new_team_name> |
| 817 | void DMFCInputCommand_SetTeamName(const char *input_string) { |
| 818 | char s[20]; |
| 819 | int team; |
| 820 | |
| 821 | // parse "$setteamname" |
| 822 | if (!StringParseWord(input_string, s, 20, &input_string)) { |
| 823 | basethis->DisplayInputCommandHelp(DTXT_IC_SETTEAMNAME); |
| 824 | return; |
| 825 | } |
| 826 | |
| 827 | // parse team_num |
| 828 | if (!StringParseNumber(input_string, &team, &input_string)) { |
| 829 | basethis->DisplayInputCommandHelp(DTXT_IC_SETTEAMNAME); |
| 830 | return; |
| 831 | } |
| 832 | |
| 833 | if (team < 0 || team > DLLMAX_TEAMS) { |
| 834 | DLLAddHUDMessage(DTXT_INVALIDTEAM, DLLMAX_TEAMS - 1); |
| 835 | basethis->DisplayInputCommandHelp(DTXT_IC_SETTEAMNAME); |
| 836 | return; |
| 837 | } |
| 838 | |
| 839 | // parse team_name |
| 840 | if (!StringParseWord(input_string, s, std::min(MAX_TEAMNAME_LEN, 20), &input_string)) { |
| 841 | basethis->DisplayInputCommandHelp(DTXT_IC_SETTEAMNAME); |
| 842 | return; |
| 843 | } |
| 844 | |
| 845 | basethis->SetTeamName(team, s, true); |
| 846 | } |
| 847 | |
| 848 | // handles a request for help to see a list of commands, dedicated server only |
| 849 | // Usage: "$help [command]" |
| 850 | void DMFCInputCommand_Help(const char *input_string) { |
| 851 | char s[20]; |
| 852 | |
| 853 | // parse "$help" |
| 854 | if (!StringParseWord(input_string, s, 20, &input_string)) { |
| 855 | basethis->DisplayInputCommandHelp(DTXT_IC_HELP); |
| 856 | return; |
| 857 | } |
| 858 | |
| 859 | // see if there is another command |
| 860 | if (!StringParseWord(input_string, s, 20, &input_string)) { |
| 861 | s[0] = '\0'; |
| 862 | } |
| 863 | |
| 864 | basethis->DisplayInputCommandHelp(s); |
| 865 | } |
| 866 | |
| 867 | // handles a request to rehash the hosts.allow/deny |
| 868 | // Usage: "$rehash" |
| 869 | void DMFCInputCommand_Rehash(const char *input_string) { |
| 870 | if (basethis->GetLocalRole() != LR_SERVER) |
| 871 | return; |
| 872 | |
| 873 | RehashAllowDenyLists(0); |
| 874 | } |
| 875 | |
| 876 | // handles a request to enter/leave observer mode |
| 877 | // Usage: "$observer <on/off>" |
| 878 | void DMFCInputCommand_Observer(const char *input_string) { |
| 879 | if (basethis->IAmDedicatedServer()) { |
| 880 | DPrintf(DTXT_NOTINDEDICATED); |
| 881 | return; |
| 882 | } |
| 883 | |
| 884 | char s[20]; |
| 885 | bool turn_on = true; |
| 886 | object *pobj; |
| 887 | int pnum = basethis->GetPlayerNum(); |
| 888 | pobj = &basethis->Objects[basethis->Players[pnum].objnum]; |
| 889 | |
| 890 | // parse "$observer" |
| 891 | StringParseWord(input_string, s, 20, &input_string); |
| 892 | |
| 893 | // see if there is another command |
| 894 | if (StringParseWord(input_string, s, 20, &input_string)) { |
| 895 | if (stricmp(s, DTXT_MNUON)) |
| 896 | turn_on = false; |
| 897 | } else { |
| 898 | if (pobj->type == OBJ_OBSERVER) { |
| 899 | turn_on = false; |
| 900 | } else { |
| 901 | turn_on = true; |
| 902 | } |
| 903 | } |
| 904 | |
| 905 | if (!basethis->CallOnAllowObserverChange(turn_on)) { |
| 906 | DLLAddHUDMessage(DTXT_OBSERVERDENIED); |
| 907 | return; |
| 908 | } |
| 909 | |
| 910 | mprintf(0, "SwitchObserverMode %s [%d]\n", (turn_on) ? "On" : "Off", pnum); |
| 911 | |
| 912 | DLLMultiSendRequestToObserve(OBSERVER_MODE_ROAM, (turn_on) ? 1 : 0, 0); |
| 913 | } |
| 914 | |
| 915 | // handles a request to piggyback a player |
| 916 | // Usage: "$piggyback <pnum>" |
| 917 | void DMFCInputCommand_Piggyback(const char *input_string) { |
| 918 | if (basethis->IAmDedicatedServer()) { |
| 919 | DPrintf(DTXT_NOTINDEDICATED); |
| 920 | return; |
| 921 | } |
| 922 | |
| 923 | char s[20]; |
| 924 | bool turn_on = true; |
| 925 | object *pobj; |
| 926 | int pnum = basethis->GetPlayerNum(); |
| 927 | pobj = &basethis->Objects[basethis->Players[pnum].objnum]; |
| 928 | int topnum = -1; |
| 929 | |
| 930 | // parse "$piggyback" |
| 931 | StringParseWord(input_string, s, 20, &input_string); |
| 932 | |
| 933 | if (!StringParseWord(input_string, s, 20, &input_string)) { |
| 934 | basethis->DisplayInputCommandHelp(DTXT_IC_PIGGYBACK); |
| 935 | return; |
| 936 | } |
| 937 | |
| 938 | char *ptr = s; |
| 939 | while (*ptr) { |
| 940 | if (!isdigit(*ptr)) { |
| 941 | basethis->DisplayInputCommandHelp(DTXT_IC_PIGGYBACK); |
| 942 | return; |
| 943 | } |
| 944 | ptr++; |
| 945 | } |
| 946 | |
| 947 | topnum = atoi(s); |
| 948 | if (!basethis->CheckPlayerNum(topnum)) { |
| 949 | DLLAddHUDMessage(DTXT_INVALIDPNUM); |
| 950 | return; |
| 951 | } |
| 952 | |
| 953 | if (pobj->type == OBJ_OBSERVER) { |
| 954 | if (basethis->CallOnAllowObserverChange(false)) |
| 955 | DLLMultiSendRequestToObserve(OBSERVER_MODE_ROAM, 0, 0); |
| 956 | } |
| 957 | if (pnum == basethis->GetPlayerNum()) { |
| 958 | mprintf(0, "Returning to self\n"); |
| 959 | return; |
| 960 | } |
| 961 | |
| 962 | if (basethis->CallOnAllowObserverChange(true)) { |
| 963 | mprintf(0, "Switching to piggyback for player %d\n", topnum); |
| 964 | DLLMultiSendRequestToObserve(OBSERVER_MODE_PIGGYBACK, 1, basethis->Players[topnum].objnum); |
| 965 | } |
| 966 | } |
| 967 | |
| 968 | // handles a request to warp to another level |
| 969 | // Usage: "$warp <level number>" |
| 970 | void DMFCInputCommand_Warp(const char *input_string) { |
| 971 | if (basethis->GetLocalRole() != LR_SERVER) |
| 972 | return; |
| 973 | |
| 974 | char s[20]; |
| 975 | int level; |
| 976 | |
| 977 | // parse "$warp" |
| 978 | if (!StringParseWord(input_string, s, 20, &input_string)) { |
| 979 | basethis->DisplayInputCommandHelp(DTXT_IC_WARP); |
| 980 | return; |
| 981 | } |
| 982 | |
| 983 | // parse levelnum |
| 984 | if (!StringParseNumber(input_string, &level, &input_string)) { |
| 985 | basethis->DisplayInputCommandHelp(DTXT_IC_WARP); |
| 986 | return; |
| 987 | } |
| 988 | |
| 989 | basethis->WarpToLevel(level); |
| 990 | } |
| 991 | |
| 992 | // handles enable/disable remote administration |
| 993 | // Usage: "$remoteadmin <on/off>" |
| 994 | extern bool Use_remote_admin; |
| 995 | void DMFCInputCommand_RemoteAdmin(const char *input_string) { |
| 996 | if (basethis->GetLocalRole() != LR_SERVER) |
| 997 | return; |
| 998 | char s[20]; |
| 999 | |
| 1000 | // parse "$remoteadmin" |
| 1001 | if (!StringParseWord(input_string, s, 20, &input_string)) { |
| 1002 | basethis->DisplayInputCommandHelp(DTXT_IC_REMOTEADMIN); |
| 1003 | return; |
| 1004 | } |
| 1005 | |
| 1006 | // parse the off/on |
| 1007 | if (!StringParseWord(input_string, s, 20, &input_string)) { |
| 1008 | basethis->DisplayInputCommandHelp(DTXT_IC_REMOTEADMIN); |
| 1009 | return; |
| 1010 | } |
| 1011 | |
| 1012 | int on = 1; |
| 1013 | |
| 1014 | if (!strnicmp(s, DTXT_MNUOFF, strlen(DTXT_MNUOFF))) |
| 1015 | on = 0; |
| 1016 | |
| 1017 | Remote_Enable((bool)(on != 0)); |
| 1018 | |
| 1019 | if (on && !Use_remote_admin) { |
| 1020 | // no password set |
| 1021 | DLLAddHUDMessage(DTXT_UNABLETOREMOTE); |
| 1022 | } else { |
| 1023 | DLLAddHUDMessage(DTXT_REMOTEADMINENABLE, (Use_remote_admin) ? DTXT_MNUON : DTXT_MNUOFF); |
| 1024 | } |
| 1025 | } |
| 1026 | |
| 1027 | // handles setting/changing the remote administration password |
| 1028 | // Usage: "$remoteadminpass <password>" |
| 1029 | void DMFCInputCommand_RemoteAdminPass(const char *input_string) { |
| 1030 | if (basethis->GetLocalRole() != LR_SERVER) |
| 1031 | return; |
| 1032 | char s[64]; |
| 1033 | |
| 1034 | // parse "$remoteadminpass" |
| 1035 | if (!StringParseWord(input_string, s, 20, &input_string)) { |
| 1036 | basethis->DisplayInputCommandHelp(DTXT_IC_REMOTEADMINPASS); |
| 1037 | return; |
| 1038 | } |
| 1039 | |
| 1040 | // parse the password |
| 1041 | if (!StringParseWord(input_string, s, 64, &input_string)) { |
| 1042 | basethis->DisplayInputCommandHelp(DTXT_IC_REMOTEADMINPASS); |
| 1043 | return; |
| 1044 | } |
| 1045 | |
| 1046 | Remote_SetPassword(s); |
| 1047 | DLLAddHUDMessage(DTXT_REMOTEADMINPASS); |
| 1048 | } |
| 1049 | |
| 1050 | // handles seeing who is logged in, and allows the server to log them out |
| 1051 | // If no parameter is given it lists all the players logged in. |
| 1052 | // To log out a player give the login-id as a parameter |
| 1053 | // Usage: "$remoteadminlogout [login-id]" |
| 1054 | void DMFCInputCommand_RemoteAdminLogout(const char *input_string) { |
| 1055 | if (basethis->GetLocalRole() != LR_SERVER) |
| 1056 | return; |
| 1057 | char s[64]; |
| 1058 | |
| 1059 | // parse "$remoteadminlogout" |
| 1060 | if (!StringParseWord(input_string, s, 64, &input_string)) { |
| 1061 | basethis->DisplayInputCommandHelp(DTXT_IC_REMOTEADMINLOGOUT); |
| 1062 | return; |
| 1063 | } |
| 1064 | |
| 1065 | // see if there is another command |
| 1066 | if (!StringParseWord(input_string, s, 64, &input_string)) { |
| 1067 | // list who is logged in |
| 1068 | Remote_ListLogins(); |
| 1069 | return; |
| 1070 | } |
| 1071 | |
| 1072 | // logout |
| 1073 | int prec = atoi(s); |
| 1074 | Remote_Logout(prec); |
| 1075 | } |
| 1076 | |
| 1077 | // handles a remote admin command |
| 1078 | // Usage: "$remote <command> <option parms> <...>" |
| 1079 | void DMFCInputCommand_Remote(const char *input_string) { |
| 1080 | if (basethis->GetLocalRole() == LR_SERVER) |
| 1081 | return; |
| 1082 | char s[20]; |
| 1083 | |
| 1084 | // parse "$remote" |
| 1085 | if (!StringParseWord(input_string, s, 20, &input_string)) { |
| 1086 | basethis->DisplayInputCommandHelp(DTXT_IC_REMOTE); |
| 1087 | return; |
| 1088 | } |
| 1089 | |
| 1090 | Remote_ClientProcess(input_string + 1 /*for space*/); |
| 1091 | } |
| 1092 | |
| 1093 | // handles a request to make all clients wait/or stop waiting |
| 1094 | // Usage: "$wait <on/off>" |
| 1095 | void DMFCInputCommand_Wait(const char *input_string) { |
| 1096 | if (basethis->GetLocalRole() != LR_SERVER) |
| 1097 | return; |
| 1098 | if (!basethis->IAmDedicatedServer()) |
| 1099 | return; |
| 1100 | |
| 1101 | char s[20]; |
| 1102 | |
| 1103 | // parse "$wait" |
| 1104 | if (!StringParseWord(input_string, s, 20, &input_string)) { |
| 1105 | return; |
| 1106 | } |
| 1107 | |
| 1108 | // parse the off/on |
| 1109 | if (!StringParseWord(input_string, s, 20, &input_string)) { |
| 1110 | basethis->DisplayInputCommandHelp(DTXT_IC_WAIT); |
| 1111 | return; |
| 1112 | } |
| 1113 | |
| 1114 | bool on = true; |
| 1115 | |
| 1116 | if (!stricmp(s, DTXT_MNUOFF)) |
| 1117 | on = false; |
| 1118 | else if (stricmp(s, DTXT_MNUON)) { |
| 1119 | // it's not ON of OFF |
| 1120 | float wait_time = atof(s); |
| 1121 | if (wait_time > 0) { |
| 1122 | DPrintf(DTXT_WAITSECS, wait_time); |
| 1123 | basethis->PauseRealGameTime(true); |
| 1124 | basethis->MakeClientsWait(true); |
| 1125 | basethis->SetDedicatedWait(wait_time); |
| 1126 | } else if (wait_time == 0) { |
| 1127 | DPrintf(DTXT_WAITOFF); |
| 1128 | basethis->PauseRealGameTime(false); |
| 1129 | basethis->MakeClientsWait(false); |
| 1130 | basethis->SetDedicatedWait(0); |
| 1131 | } |
| 1132 | return; |
| 1133 | } |
| 1134 | |
| 1135 | // turn on client waiting |
| 1136 | if (on) { |
| 1137 | DPrintf(DTXT_WAITON); |
| 1138 | } else { |
| 1139 | DPrintf(DTXT_WAITNOLONGER); |
| 1140 | } |
| 1141 | |
| 1142 | basethis->PauseRealGameTime(on); |
| 1143 | basethis->MakeClientsWait(on); |
| 1144 | } |