1 //////////////////////////////////////////////////////////////////////////////// 2 // Scorched3D (c) 2000-2011 3 // 4 // This file is part of Scorched3D. 5 // 6 // Scorched3D is free software; you can redistribute it and/or modify 7 // it under the terms of the GNU General Public License as published by 8 // the Free Software Foundation; either version 2 of the License, or 9 // (at your option) any later version. 10 // 11 // Scorched3D is distributed in the hope that it will be useful, 12 // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 // GNU General Public License for more details. 15 // 16 // You should have received a copy of the GNU General Public License along 17 // with this program; if not, write to the Free Software Foundation, Inc., 18 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 19 //////////////////////////////////////////////////////////////////////////////// 20 21 #if !defined(__INCLUDE_OptionsScorchedh_INCLUDE__) 22 #define __INCLUDE_OptionsScorchedh_INCLUDE__ 23 24 #include <common/OptionsGame.h> 25 26 #define GENERIC_GETTER(x) \ 27 { \ 28 if (levelOptions_.get##x##Entry().isChangedValue()) return levelOptions_.get##x(); \ 29 else return mainOptions_.get##x(); \ 30 }; 31 32 #define OPTIONSTRING_GETTER(x) const char *get##x() GENERIC_GETTER(x) 33 #define OPTIONINT_GETTER(x) int get##x() GENERIC_GETTER(x) 34 #define OPTIONENUM_GETTER(x) OptionEntryEnum get##x() GENERIC_GETTER(x) 35 #define OPTIONSTRINGENUM_GETTER(x) const char *get##x() GENERIC_GETTER(x) 36 #define OPTIONBOOL_GETTER(x) bool get##x() GENERIC_GETTER(x) 37 #define OPTIONFLOAT_GETTER(x) bool get##x() GENERIC_GETTER(x) 38 #define OPTIONVECTOR_GETTER(x) bool get##x() GENERIC_GETTER(x) 39 40 class ScorchedContext; 41 class LandscapeDefinition; 42 class LandscapeInclude; 43 class OptionsScorched 44 { 45 public: 46 OptionsScorched(); 47 virtual ~OptionsScorched(); 48 49 OPTIONINT_GETTER(PortNo); 50 OPTIONINT_GETTER(ManagementPortNo); 51 52 OPTIONSTRING_GETTER(Tutorial); 53 OPTIONINT_GETTER(Teams); 54 OPTIONINT_GETTER(MinimumLandHeight); 55 OPTIONINT_GETTER(WeaponSpeed); 56 OPTIONINT_GETTER(StartArmsLevel); 57 OPTIONINT_GETTER(EndArmsLevel); 58 OPTIONINT_GETTER(MaxNumberWeapons); 59 OPTIONINT_GETTER(NoMaxPlayers); 60 OPTIONINT_GETTER(NoMinPlayers); 61 OPTIONINT_GETTER(NoRounds); 62 OPTIONINT_GETTER(NoTurns); 63 OPTIONINT_GETTER(RemoveBotsAtPlayers); 64 OPTIONINT_GETTER(MaxLandscapeSize); 65 OPTIONINT_GETTER(AllowedMissedMoves); 66 OPTIONINT_GETTER(MinFallingDistance); 67 OPTIONBOOL_GETTER(TankFallingDamage); 68 OPTIONINT_GETTER(MaxClimbingDistance); 69 OPTIONINT_GETTER(PlayerLives); 70 OPTIONINT_GETTER(Gravity); 71 72 OPTIONINT_GETTER(StartTime); 73 OPTIONINT_GETTER(ShotTime); 74 OPTIONINT_GETTER(AIShotTime); 75 OPTIONINT_GETTER(BuyingTime); 76 OPTIONINT_GETTER(RoundTime); 77 OPTIONINT_GETTER(RemoveTime); 78 OPTIONINT_GETTER(RoundScoreTime); 79 OPTIONINT_GETTER(ScoreTime); 80 OPTIONINT_GETTER(IdleCycleTime); 81 82 OPTIONENUM_GETTER(WindForce); 83 OPTIONENUM_GETTER(WindType); 84 OPTIONENUM_GETTER(WallType); 85 OPTIONENUM_GETTER(WeapScale); 86 OPTIONENUM_GETTER(TurnType); 87 OPTIONENUM_GETTER(TeamBallance); 88 OPTIONENUM_GETTER(MovementRestriction); 89 90 OPTIONINT_GETTER(ScorePerMoney); 91 OPTIONINT_GETTER(ScorePerAssist); 92 OPTIONINT_GETTER(ScorePerKill); 93 OPTIONINT_GETTER(ScorePerResign); 94 OPTIONINT_GETTER(ScorePerSpectate); 95 OPTIONINT_GETTER(ScoreWonForRound); 96 OPTIONINT_GETTER(ScoreWonForLives); 97 98 OPTIONINT_GETTER(SkillForRound); 99 OPTIONINT_GETTER(SkillForMatch); 100 OPTIONINT_GETTER(SkillForResign); 101 OPTIONINT_GETTER(MaxSkillLost); 102 OPTIONINT_GETTER(MaxSkillGained); 103 OPTIONINT_GETTER(SkillForSelfKill); 104 OPTIONINT_GETTER(SkillForTeamKill); 105 106 OPTIONINT_GETTER(StartMoney); 107 OPTIONINT_GETTER(Interest); 108 OPTIONINT_GETTER(FreeMarketAdjustment); 109 OPTIONINT_GETTER(FreeMarketLimits); 110 OPTIONINT_GETTER(BuyOnRound); 111 OPTIONINT_GETTER(MoneyPerRound); 112 OPTIONINT_GETTER(MoneyWonForRound); 113 OPTIONINT_GETTER(MoneyWonForLives); 114 OPTIONINT_GETTER(MoneyWonPerKillPoint); 115 OPTIONINT_GETTER(MoneyWonPerMultiKillPoint); 116 OPTIONINT_GETTER(MoneyWonPerAssistPoint); 117 OPTIONINT_GETTER(MoneyWonPerHitPoint); 118 OPTIONBOOL_GETTER(MoneyPerHealthPoint); 119 OPTIONBOOL_GETTER(LimitPowerByHealth); 120 OPTIONBOOL_GETTER(GiveAllWeapons); 121 OPTIONSTRINGENUM_GETTER(Economy); 122 OPTIONINT_GETTER(ResignMode); 123 124 OPTIONINT_GETTER(ComputersDeathTalk); 125 OPTIONINT_GETTER(ComputersAttackTalk); 126 OPTIONSTRING_GETTER(BotNamePrefix); 127 OPTIONBOOL_GETTER(RandomizeBotNames); 128 OPTIONBOOL_GETTER(WaitForShotsBeforeShowingScore); 129 130 OPTIONBOOL_GETTER(CycleMaps); 131 OPTIONSTRING_GETTER(Landscapes); 132 133 OPTIONSTRING_GETTER(StatsLogger); 134 OPTIONSTRING_GETTER(ServerFileLogger); 135 136 OPTIONSTRING_GETTER(Mod); 137 OPTIONSTRING_GETTER(MOTD); 138 OPTIONINT_GETTER(ModDownloadSpeed); 139 OPTIONINT_GETTER(MaxAvatarSize); 140 OPTIONSTRING_GETTER(ServerName); 141 OPTIONSTRING_GETTER(ServerPassword); 142 OPTIONSTRING_GETTER(PublishAddress); 143 144 OPTIONBOOL_GETTER(AllowMultiLingualChat); 145 OPTIONBOOL_GETTER(AllowMultiLingualNames); 146 OPTIONBOOL_GETTER(AllowSameIP); 147 OPTIONBOOL_GETTER(AllowSameUniqueId); 148 OPTIONBOOL_GETTER(PublishServer); 149 OPTIONBOOL_GETTER(UseUPnP); 150 OPTIONBOOL_GETTER(UseUPnPLogging); 151 OPTIONBOOL_GETTER(ResidualPlayers); 152 OPTIONBOOL_GETTER(DelayedDefenseActivation); 153 OPTIONBOOL_GETTER(AutoSendSyncCheck); 154 OPTIONBOOL_GETTER(ActionSyncCheck); 155 OPTIONBOOL_GETTER(WeaponSyncCheck); 156 OPTIONBOOL_GETTER(TargetPlacementSyncCheck); 157 OPTIONBOOL_GETTER(ActionMovementSyncCheck); 158 OPTIONBOOL_GETTER(ActionRandomSyncCheck); 159 OPTIONBOOL_GETTER(ActionCollisionSyncCheck); 160 161 OPTIONSTRING_GETTER(AuthHandler); 162 OPTIONSTRING_GETTER(AuthHandlerParam1); 163 OPTIONSTRING_GETTER(AuthHandlerParam2); 164 OPTIONBOOL_GETTER(RegisteredUserNames); 165 OPTIONBOOL_GETTER(DebugFeatures); 166 getPlayerType(int no)167 OptionEntryString &getPlayerType(int no) { DIALOG_ASSERT(no<24); return mainOptions_.getPlayerType(no); } 168 getChangedOptions()169 OptionsGame &getChangedOptions() { return changedOptions_; } getMainOptions()170 OptionsGame &getMainOptions() { return mainOptions_; } getLevelOptions()171 OptionsGame &getLevelOptions() { return levelOptions_; } 172 173 void updateLevelOptions(ScorchedContext &context, LandscapeDefinition &defn); 174 void updateChangeSet(); 175 bool commitChanges(); 176 177 protected: 178 OptionsGame mainOptions_; 179 OptionsGame changedOptions_; 180 OptionsGame levelOptions_; 181 182 void updateLevelOptions(std::vector<LandscapeInclude *> &options, 183 std::map<std::string, OptionEntry *> &values); 184 }; 185 186 #endif 187