1 /*
2 * FeatureList.cpp
3 * OpenLieroX
4 *
5 * Created by Albert Zeyer on 22.12.08.
6 * code under LGPL
7 *
8 */
9
10
11 #include "FeatureList.h"
12 #include "Version.h"
13 #include "CServer.h"
14
15
16
17 // WARNING: Keep this always synchronised with FeatureIndex!
18 // Legend: Name in options, Human-readable-name, Long description,
19 // Unset, Default, Min client Version, Group, [Min,] [Max,] [server-side only] [optional for client] [switch to unset value on older clients] [is value unsigned] (Min and Max are only for Int and Float)
20 // Old clients are kicked if feature version is greater that client version, no matter if feature is server-sided or safe to ignore
21
22 Feature featureArray[] = {
23 Feature("GameSpeed", "Game-speed multiplicator", "Game simulation speed is multiplicated by the given value.",
24 1.0f, 1.0f, OLXBetaVersion(7), GIG_Advanced, ALT_Advanced, 0.1f, 10.0f ),
25 Feature("GameSpeedOnlyForProjs", "Speed multiplier only for projs", "Game-speed multiplicator applies only for projectiles and weapons, everything else will be normal speed",
26 false, false, OLXBetaVersion(0,58,1), GIG_Advanced, ALT_Advanced, false),
27 Feature("ScreenShaking", "Screen shaking", "Screen shaking when something explodes",
28 true, false, OLXBetaVersion(0,58,1), GIG_Other, ALT_VeryAdvanced, false, true, true ),
29 Feature("FullAimAngle", "Full aim angle", "Enables full aim angle, i.e. also allows to aim straight down",
30 false, false, OLXRcVersion(0,58,3), GIG_Other, ALT_VeryAdvanced, false, true, false ),
31 Feature("MiniMap", "Mini map", "Show mini map",
32 true, true, OLXBetaVersion(0,58,1), GIG_Other, ALT_Advanced, false, false ),
33 Feature("SuicideDecreasesScore", "Suicide decreases score", "The score descreases after a suicide.",
34 false, false, Version(), GIG_Score, ALT_Advanced, false, true ),
35 Feature("TeamkillDecreasesScore", "Teamkill decreases score", "The score descreases after a teamkill.",
36 false, false, Version(), GIG_Score, ALT_Advanced, false, true ),
37 Feature("DeathDecreasesScore", "Death decreases score", "The score decreases after each death by this factor",
38 0.0f, 0.0f, Version(), GIG_Score, ALT_Advanced, 0.0f, 5.0f, false, true ),
39 Feature("CountTeamkills", "Count teamkills", "When killing player from your team increase your score",
40 false, false, Version(), GIG_Score, ALT_VeryAdvanced, false, true ),
41 Feature("AllowNegativeScore", "Allow negative score", "Allow negative score, when this option is not selected death/suicide/teamkill are not counted if score is zero",
42 false, false, Version(), GIG_Score, ALT_VeryAdvanced, false, true ),
43 Feature("TeamInjure", "Damage team members", "If disabled, your bullets and projectiles don't damage other team members. It's like friendlyfire in other games.",
44 true, true, OLXBetaVersion(0,58,1), GIG_Weapons, ALT_Advanced ),
45 Feature("TeamHit", "Hit team members", "If disabled, your bullets and projectiles will fly through your team members.",
46 true, true, OLXBetaVersion(0,58,1), GIG_Weapons, ALT_Advanced ),
47 Feature("SelfInjure", "Damage yourself", "If disabled, your bullets and projectiles don't damage you.",
48 true, true, OLXBetaVersion(0,58,1), GIG_Weapons, ALT_Advanced ),
49 Feature("SelfHit", "Hit yourself", "If disabled, your bullets and projectiles will fly through yourself.",
50 true, true, OLXBetaVersion(0,58,1), GIG_Weapons, ALT_Advanced ),
51 Feature("AllowEmptyGames", "Allow empty games", "If enabled, games with one or zero worms will not quit. This is only possible if you have infinite lives set and also only for network games.",
52 false, false, Version(), GIG_Other, ALT_Advanced, true, true ),
53 Feature("HS_HideTime", "Hiding time", "AbsTime at the start of the game for hiders to hide",
54 20.0f, 20.0f, Version(), GIG_HideAndSeek, ALT_Basic, 0.0f, 100.0f, true, true ),
55 Feature("HS_AlertTime", "Alert time", "When player discovered but escapes the time for which it's still visible",
56 10.0f, 10.0f, Version(), GIG_HideAndSeek, ALT_Basic, 0.1f, 100.0f, true, true ),
57 Feature("HS_HiderVision", "Hider vision", "How far hider can see, in pixels (whole screen = 320 px)",
58 175, 175, Version(), GIG_HideAndSeek, ALT_Advanced, 0, 320, true, true ),
59 Feature("HS_HiderVisionThroughWalls", "Hider vision thorough walls", "How far hider can see through walls, in pixels (whole screen = 320 px)",
60 75, 75, Version(), GIG_HideAndSeek, ALT_Advanced, 0, 320, true, true ),
61 Feature("HS_SeekerVision", "Seeker vision", "How far seeker can see, in pixels (whole screen = 320 px)",
62 125, 125, Version(), GIG_HideAndSeek, ALT_Advanced, 0, 320, true, true ),
63 Feature("HS_SeekerVisionThroughWalls", "Seeker vision thorough walls", "How far seeker can see through walls, in pixels (whole screen = 320 px)",
64 0, 0, Version(), GIG_HideAndSeek, ALT_Advanced, 0, 320, true, true ),
65 Feature("HS_SeekerVisionAngle", "Seeker vision angle", "The angle of seeker vision (180 = half-circle, 360 = full circle)",
66 360, 360, Version(), GIG_HideAndSeek, ALT_Advanced, 0, 360, false, true ),
67 Feature("NewNetEngine", "New net engine (non-functional)", "This feature does not work, do not use it",
68 false, false, OLXBetaVersion(0,58,1), GIG_Advanced, ALT_DevKnownUnstable ),
69 Feature("FillWithBotsTo", "Fill with bots up to", "If too less players, it will get filled with bots",
70 0, 0, OLXBetaVersion(0,58,1), GIG_Other, ALT_Advanced, 0, MAX_PLAYERS, true, true),
71 Feature("WormSpeedFactor", "Worm speed factor", "Initial factor to worm speed",
72 1.0f, 1.0f, OLXBetaVersion(0,58,1), GIG_Other, ALT_Advanced, -2.0f, 10.0f, true),
73 Feature("WormDamageFactor", "Worm damage factor", "Initial factor to worm damage",
74 1.0f, 1.0f, OLXBetaVersion(0,58,1), GIG_Other, ALT_VeryAdvanced, -2.0f, 10.0f, true),
75 Feature("WormShieldFactor", "Worm shield factor", "Initial factor to worm shield",
76 1.0f, 1.0f, OLXBetaVersion(0,58,1), GIG_Other, ALT_VeryAdvanced, -2.0f, 10.0f, true),
77 Feature("InstantAirJump", "Instant air jump", "Worms can jump in air instantly, this allows floating in air",
78 false, false, OLXBetaVersion(0,58,1), GIG_Other, ALT_Advanced, true), // Server-side
79 Feature("RelativeAirJump", "Relative air jump", "Worms can jump in air in a given time interval",
80 false, false, OLXBetaVersion(0,58,1), GIG_Other, ALT_Advanced), // Client-side
81 Feature("RelativeAirJumpDelay", "Delay for relative air jumps", "How fast can you do air-jumps",
82 0.7f, 0.7f, Version(), GIG_Other, ALT_VeryAdvanced, 0.0f, 5.0f),
83 Feature("AllowWeaponsChange", "Allow weapons change", "Everybody can change its weapons at any time",
84 false, false, OLXBetaVersion(0,58,1), GIG_Weapons, ALT_Advanced, true, true),
85 Feature("ImmediateStart", "Immediate start", "Immediate start of game, don't wait for other players weapon selection",
86 true, true, OLXBetaVersion(8), GIG_Advanced, ALT_Advanced, true),
87 Feature("DisableWpnsWhenEmpty", "Disable weapons when empty", "When a weapon got uncharged, it got disabled and you have to catch a bonus (be sure that you have bonuses activated). This is usefull in games like Race.",
88 false, false, OLXBetaVersion(7) /* it needs wpninfo packet which is there since beta7 */, GIG_Weapons, ALT_VeryAdvanced, true),
89 Feature("WeaponCombos", "Weapon combos", "Enable/disable weapon combos, i.e. fast changing of weapons and shooting at the same time",
90 true, true, OLXBetaVersion(0,58,10), GIG_Weapons, ALT_Advanced, false, false),
91 Feature("InfiniteMap", "Infinite map", "Map has no borders and is tiled together",
92 false, false, OLXBetaVersion(0,58,1), GIG_Other, ALT_Advanced, false),
93 Feature("MirroredMap", "Mirrored map", "Extend the map by adding a mirrored version",
94 false, false, OLXRcVersion(0,58,4), GIG_Other, ALT_Advanced, false),
95 Feature("MirroredMapSide", "Mirrored map side", "0 = left side, 1 = right side",
96 0, 0, Version(), GIG_Other, ALT_Advanced, 0, 1, false),
97 Feature("MirroredMapTop", "Mirrored map on top", "Extend the map by adding a vertically mirrored version",
98 false, false, OLXRcVersion(0,58,4), GIG_Other, ALT_Advanced, false),
99 Feature("WormFriction", "Worm Friction", "Friction coefficient for worms (0 = disabled)",
100 0.0f, 0.0f, OLXBetaVersion(0,58,1), GIG_Other, ALT_VeryAdvanced, 0.0f, 2.0f, false),
101 Feature("WormGroundFriction", "Worm Ground Friction", "Friction coefficient when worms are on ground (0.1 = default; 1 = stucked; 0 = no friction)",
102 0.1f, 0.1f, OLXBetaVersion(0,58,9), GIG_Other, ALT_VeryAdvanced, 0.0f, 1.0f, false),
103 Feature("ProjFriction", "Projectile Friction", "Friction coefficient for projectiles (0 = disabled)",
104 0.0f, 0.0f, OLXBetaVersion(0,58,1), GIG_Other, ALT_VeryAdvanced, 0.0f, 2.0f, false),
105 Feature("TeamScoreLimit", "Team Score limit", "Team score limit",
106 -1, -1, OLXBetaVersion(0,58,1), GIG_General, ALT_Basic, -1, 100, true, true, false, true),
107 Feature("SizeFactor", "Size factor", "The size of everything in game will be changed by this factor (i.e. made bigger or smaller)",
108 1.0f, 1.0f, OLXBetaVersion(0,58,1), GIG_Advanced, ALT_Advanced, 0.5f, 4.0f, false),
109 Feature("CTF_AllowRopeForCarrier", "Allow rope for carrier", "The worm who is holding the flag can use ninja rope",
110 true, true, OLXBetaVersion(0,58,1), GIG_CaptureTheFlag, ALT_Basic, true),
111 Feature("CTF_SpeedFactorForCarrier", "Speed factor for carrier", "Changes the carrier speed by this factor. Perhaps you want to make the carrier slower so you can more easily get the flag again.",
112 1.0f, 1.0f, OLXBetaVersion(0,58,1), GIG_CaptureTheFlag, ALT_Basic, 0.1f, 3.0f, true),
113 Feature("Race_Rounds", "Rounds", "Amount of rounds",
114 5,5, Version(), GIG_Race, ALT_Basic, -1, 100, true, true),
115 Feature("Race_AllowWeapons", "Allow weapons", "If disabled, you cannot shoot",
116 false, false, Version(), GIG_Race, ALT_Advanced, false),
117 Feature("Race_CheckPointRadius", "Checkpoint radius", "The radius of the checkpoints (bigger value makes race easier)",
118 15.0f, 15.0f, Version(), GIG_Race, ALT_VeryAdvanced, 5.0f, 100.f, true, true),
119 Feature("IndestructibleBonuses", "Indestructible bonuses", "Bonuses will not be destroyed by explosions",
120 false, false, Version(), GIG_Bonus, ALT_VeryAdvanced, false, true),
121
122 Feature::Unset()
123 };
124
125 static_assert(__FTI_BOTTOM == sizeof(featureArray)/sizeof(Feature) - 1, "featureArray__sizecheck");
126
127
128
featureByName(const std::string & name)129 Feature* featureByName(const std::string& name) {
130 foreach( Feature*, f, Array(featureArray,featureArrayLen()) ) {
131 if( stringcaseequal(f->get()->name, name) )
132 return f->get();
133 }
134 return NULL;
135 }
136
FeatureSettings()137 FeatureSettings::FeatureSettings() {
138 settings = new ScriptVar_t[featureArrayLen()];
139 foreach( Feature*, f, Array(featureArray,featureArrayLen()) ) {
140 (*this)[f->get()] = f->get()->defaultValue;
141 }
142 }
143
~FeatureSettings()144 FeatureSettings::~FeatureSettings() {
145 if(settings) delete[] settings;
146 }
147
operator =(const FeatureSettings & r)148 FeatureSettings& FeatureSettings::operator=(const FeatureSettings& r) {
149 if(settings) delete[] settings;
150
151 settings = new ScriptVar_t[featureArrayLen()];
152 foreach( Feature*, f, Array(featureArray,featureArrayLen()) ) {
153 (*this)[f->get()] = r[f->get()];
154 }
155
156 return *this;
157 }
158
hostGet(FeatureIndex i)159 ScriptVar_t FeatureSettings::hostGet(FeatureIndex i) {
160 ScriptVar_t var = (*this)[i];
161 Feature* f = &featureArray[i];
162 if(f->getValueFct)
163 var = (cServer->*(f->getValueFct))( var );
164 else if(f->unsetIfOlderClients) {
165 if(cServer->clientsConnected_less(f->minVersion))
166 var = f->unsetValue;
167 }
168
169 return var;
170 }
171
olderClientsSupportSetting(Feature * f)172 bool FeatureSettings::olderClientsSupportSetting(Feature* f) {
173 if( f->optionalForClient ) return true;
174 return hostGet(f) == f->unsetValue;
175 }
176
177