1 /* bzflag 2 * Copyright (c) 1993-2021 Tim Riker 3 * 4 * This package is free software; you can redistribute it and/or 5 * modify it under the terms of the license found in the file 6 * named COPYING that should have accompanied this file. 7 * 8 * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 9 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 10 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 11 */ 12 13 #ifndef __CMDLINEOPTIONS_H__ 14 #define __CMDLINEOPTIONS_H__ 15 16 /* bzflag special common - 1st one */ 17 #include "common.h" 18 19 /* system headers */ 20 #include <string> 21 #include <map> 22 #include <vector> 23 24 /* bzflag common headers */ 25 #include "Protocol.h" 26 #include "Flag.h" 27 #include "WordFilter.h" 28 #include "TextChunkManager.h" 29 30 /* bzfs-specific headers */ 31 #include "AccessControlList.h" 32 33 // avoid dependencies 34 class EntryZones; 35 36 /* constants provided for general consumption */ 37 const int MaxPlayers = 200; 38 const int MaxShots = 20; 39 40 // rabbit selection algorithms 41 enum RabbitSelection 42 { 43 ScoreRabbitSelection, // default method based on score 44 KillerRabbitSelection, // anoint whoever manages to kill the rabbit 45 RandomRabbitSelection // pick the new rabbit out of a hat 46 }; 47 48 typedef std::map<FlagType*, int> FlagNumberMap; 49 typedef std::map<FlagType*,bool> FlagOptionMap; 50 51 #define _DEFAULT_LIN_ACCEL 0.0f 52 #define _DEFAULT_ANGLE_ACCELL 0.0f 53 54 /** CmdLineOptions is a container for any of the bzfs options that may 55 * be provided via the command line. 56 */ 57 struct CmdLineOptions 58 { CmdLineOptionsCmdLineOptions59 CmdLineOptions() 60 : wksPort(ServerPort), gameType(TeamFFA), gameOptions(0), 61 rabbitSelection(ScoreRabbitSelection), msgTimer(0), spamWarnMax(5), 62 servermsg(""), advertisemsg(""), worldFile(""), 63 pingInterface(""), password(""), 64 listServerOverridden(false), 65 publicizedTitle(""), publicizedAddress(""), publicizedKey(""), 66 advertiseGroups("EVERYONE"), 67 suppressMasterBanList(false), masterBanListOverridden(false), 68 maxShots(1), maxTeamScore(0), maxPlayerScore(0), 69 numExtraFlags(0), teamKillerKickRatio(0), 70 numAllowedFlags(0), shakeWins(0), shakeTimeout(0), 71 teamFlagTimeout(30), maxlagwarn(10000), maxjitterwarn(10000), maxpacketlosswarn(10000), 72 adminlagannounce(-1.0), lagannounce(-1.0), lagwarnthresh(-1.0), jitterwarnthresh(-1.0), 73 packetlosswarnthresh(-1.0), 74 idlekickthresh(-1.0), timeLimit(0.0f), timeElapsed(0.0f), addedTime(0.0f), 75 linearAcceleration(_DEFAULT_LIN_ACCEL), angularAcceleration(_DEFAULT_ANGLE_ACCELL), useGivenPort(false), 76 UPnP(false), randomBoxes(false), 77 randomCTF(false), flagsOnBuildings(false), respawnOnBuildings(false), 78 oneGameOnly(false), timeManualStart(false), randomHeights(false), 79 useTeleporters(false), teamKillerDies(true), printScore(false), 80 publicizeServer(false), replayServer(false), startRecording(false), 81 timestampLog(false), timestampMicros(false), timestampUTC(false), countdownPaused(false), 82 filterFilename(""), filterCallsigns(false), filterChat(false), filterSimple(false), 83 banTime(300), voteTime(60), vetoTime(2), votesRequired(2), 84 votePercentage(50.1f), voteRepeatTime(300), 85 autoTeam(false), citySize(5), cacheURL(""), cacheOut(""), tkAnnounce(false), wallSides(4) 86 { 87 int i; 88 for (FlagTypeMap::iterator it = FlagType::getFlagMap().begin(); 89 it != FlagType::getFlagMap().end(); ++it) 90 { 91 flagCount[it->second] = 0; 92 flagLimit[it->second] = -1; 93 flagDisallowed[it->second] = false; 94 } 95 96 for (i = 0; i < NumTeams; i++) 97 { 98 maxTeam[i] = MaxPlayers; 99 numTeamFlags[i] = 0; 100 } 101 102 listServerURL.push_back(DefaultListServerURL); 103 masterBanListURL.push_back(DefaultMasterBanURL); 104 } 105 106 int wksPort; 107 GameType gameType; 108 int gameOptions; 109 int rabbitSelection; 110 int msgTimer; 111 int spamWarnMax; 112 113 std::string servermsg; 114 std::string advertisemsg; 115 std::string worldFile; 116 std::string pingInterface; 117 std::string password; 118 119 bool listServerOverridden; 120 std::vector<std::string> listServerURL; 121 122 std::string publicizedTitle; 123 std::string publicizedAddress; 124 std::string publicizedKey; 125 std::string advertiseGroups; 126 127 bool suppressMasterBanList; 128 bool masterBanListOverridden; 129 std::vector<std::string> masterBanListURL; 130 131 uint16_t maxShots; 132 int maxTeamScore; 133 int maxPlayerScore; 134 int numExtraFlags; 135 int teamKillerKickRatio; // if players tk*100/wins > teamKillerKickRatio -> kicked 136 int numAllowedFlags; 137 uint16_t shakeWins; 138 uint16_t shakeTimeout; 139 int teamFlagTimeout; 140 int maxlagwarn; 141 int maxjitterwarn; 142 int maxpacketlosswarn; 143 int countdownStarter; 144 145 float adminlagannounce; 146 float lagannounce; 147 float lagwarnthresh; 148 float jitterwarnthresh; 149 float packetlosswarnthresh; 150 float idlekickthresh; 151 float timeLimit; 152 float timeElapsed; 153 float addedTime; 154 float linearAcceleration; 155 float angularAcceleration; 156 157 bool useGivenPort; 158 bool UPnP; 159 bool randomBoxes; 160 bool randomCTF; 161 bool flagsOnBuildings; 162 bool respawnOnBuildings; 163 bool oneGameOnly; 164 bool timeManualStart; 165 bool randomHeights; 166 bool useTeleporters; 167 bool teamKillerDies; 168 bool printScore; 169 bool publicizeServer; 170 bool replayServer; 171 bool startRecording; 172 bool timestampLog; 173 bool timestampMicros; 174 bool timestampUTC; 175 bool countdownPaused; 176 177 uint16_t maxTeam[NumTeams]; 178 FlagNumberMap flagCount; 179 FlagNumberMap flagLimit; // # shots allowed / flag 180 FlagOptionMap flagDisallowed; 181 182 AccessControlList acl; 183 TextChunkManager textChunker; 184 185 /* inappropriate language filter */ 186 std::string filterFilename; 187 bool filterCallsigns; 188 bool filterChat; 189 bool filterSimple; 190 WordFilter filter; 191 192 /* vote poll options */ 193 unsigned short int banTime; 194 unsigned short int voteTime; 195 unsigned short int vetoTime; 196 unsigned short int votesRequired; 197 float votePercentage; 198 unsigned short int voteRepeatTime; 199 200 std::string reportFile; 201 std::string reportPipe; 202 203 std::string bzdbVars; 204 205 /* team balancing options */ 206 bool autoTeam; 207 208 /* city options */ 209 int citySize; 210 int numTeamFlags[NumTeams]; 211 212 std::string cacheURL; 213 std::string cacheOut; 214 215 bool tkAnnounce; 216 int wallSides; 217 218 // plugins 219 typedef struct 220 { 221 std::string plugin; 222 std::string command; 223 } pluginDef; 224 225 std::vector<pluginDef> pluginList; 226 }; 227 228 229 void parse(int argc, char **argv, CmdLineOptions &options, bool fromWorldFile = false); 230 void finalizeParsing(int argc, char **argv, CmdLineOptions &options, EntryZones& ez); 231 bool checkCommaList (const char *list, int maxlen); 232 233 #else 234 struct CmdLineOptions; 235 #endif 236 237 // Local Variables: *** 238 // mode: C++ *** 239 // tab-width: 4 *** 240 // c-basic-offset: 4 *** 241 // indent-tabs-mode: nil *** 242 // End: *** 243 // ex: shiftwidth=4 tabstop=4 244