Merge lp:~epsy/armagetronad/trunk-referee into lp:~armagetronad-dev/armagetronad/trunk-armagetronad-work
- trunk-referee
- Merge into trunk-armagetronad-work
Proposed by
Yann Kaiser
Status: | Merged |
---|---|
Merged at revision: | not available |
Proposed branch: | lp:~epsy/armagetronad/trunk-referee |
Merge into: | lp:~armagetronad-dev/armagetronad/trunk-armagetronad-work |
Diff against target: | None lines |
To merge this branch: | bzr merge lp:~epsy/armagetronad/trunk-referee |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Armagetron Advanced Developers | Pending | ||
Review via email: mp+9459@code.launchpad.net |
Commit message
Description of the change
To post a comment you must log in.
Revision history for this message
Yann Kaiser (epsy) wrote : | # |
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'NEWS' |
2 | --- NEWS 2009-04-30 12:36:02 +0000 |
3 | +++ NEWS 2009-07-30 01:34:06 +0000 |
4 | @@ -7,6 +7,8 @@ |
5 | - New setting SILENCE_ENEMIES (boolean). When enabled, chat sent from enemies |
6 | is not displayed on your client if you are alive. If you are dead all chat |
7 | is displayed. |
8 | +- New console commands OP and DEOP replicate the functionnality of chat commands /op and /deop |
9 | +- New vote: /callvote referee <player>: Elevates <player> to access level 6. /callvote demotereferee reverts. |
10 | |
11 | Changes since 0.3.0 |
12 | =================== |
13 | |
14 | === modified file 'config/settings_authentication.cfg' |
15 | --- config/settings_authentication.cfg 2008-04-25 18:00:53 +0000 |
16 | +++ config/settings_authentication.cfg 2009-07-30 01:30:54 +0000 |
17 | @@ -140,6 +140,8 @@ |
18 | # powerful as the owner himself. |
19 | # 2 Moderator A server moderator. Is still allowed to use /admin, |
20 | # but is restricted to player management commands. |
21 | +# 6 Referee For organized matches, can be elected to use team and |
22 | +# match management commands. |
23 | # 7 Team Leader Leader of a team. By default, no admin rights at all. |
24 | # 8 Team Member Member of a team. Local team accounts get this level. |
25 | # 12 Local User Players with local accounts get this level. |
26 | |
27 | === modified file 'language/english_base.txt' |
28 | --- language/english_base.txt 2009-04-30 12:36:02 +0000 |
29 | +++ language/english_base.txt 2009-07-30 01:30:54 +0000 |
30 | @@ -1653,6 +1653,11 @@ |
31 | suspend_player_details_text If accepted, \1 will be suspended for some rounds. |
32 | suspend_player_text Suspend \1 |
33 | |
34 | +referee_player_details_text If accepted, \1 will be made referee: He will be able to administrate teams. |
35 | +referee_player_text Make \1 referee |
36 | +demotereferee_player_details_text If accepted, \1 won't be referee anymore: He will not be able to administrate teams. |
37 | +demotereferee_player_text Demote \1 as referee |
38 | + |
39 | vote_include_details_text If accepted, the file \1 will be included as a configuration file. |
40 | vote_include_text Include \1 |
41 | vote_include_error Include file \1 not found or not readable.\n |
42 | @@ -2429,6 +2434,11 @@ |
43 | player_noshuffle Your shuffling wish has no effect.\n |
44 | player_shuffle_error /shuffle expects a number as argument; an explicit sign (+/-) will change your position by the indicated number of steps, no sign will shuffle you to the given position.\n |
45 | |
46 | +player_referee 0x7fff7fBy order of \10x7fff7f, \20x7fff7f is now a referee.\n |
47 | +player_referee_anon \10x7fff7f is now a referee.\n |
48 | +player_referee_nomore 0xff7f7fBy order of \10xff7f7f, \20xff7f7f is no longer a referee.\n |
49 | +player_referee_nomore_anon \1 0xff7f7fis no longer a referee.\n |
50 | + |
51 | player_message_help Sends a message to a specified player. |
52 | player_message_usage Usage: PLAYER_MESSAGE <user ID or name> "<Message>"\n |
53 | kick_usage Usage: KICK <user ID or name> <Reason>\n |
54 | @@ -2659,6 +2669,8 @@ |
55 | vote_vote_against \1 voted against Poll "\2".\n |
56 | vote_unknown_command Unknown /vote command \1, available are: \2\n |
57 | vote_kick_local Can't vote against local player/AI \1.\n |
58 | +vote_referee_already \10xRESETT is already a referee.\n |
59 | +vote_demotereferee_notref \10xRESETT is not a referee.\n |
60 | |
61 | #******************************************** |
62 | #******************************************** |
63 | @@ -2810,6 +2822,7 @@ |
64 | config_accesslevel_1 Administrator |
65 | config_accesslevel_2 Moderator |
66 | config_accesslevel_5 Armatrator |
67 | +config_accesslevel_6 Referee |
68 | config_accesslevel_7 Team Leader |
69 | config_accesslevel_8 Team Member |
70 | config_accesslevel_12 Local User |
71 | @@ -2932,7 +2945,9 @@ |
72 | access_level_op_unclear \1: User is already logged in, please explicitly set an access level.\n |
73 | |
74 | access_level_demote \1 has been demoted to "\2" by order of \3.\n |
75 | +access_level_demote_anon \1 has been demoted to "\2".\n |
76 | access_level_promote \1 has been promoted to "\2" by order of \3.\n |
77 | +access_level_promote_anon \1 has been promoted to "\2".\n |
78 | |
79 | access_level_admin_denied 0xff7f7f/admin denied,0xffffff insufficient access level.\n |
80 | access_level_shuffle_up_denied Required access level to shuffle up is "\1", you only have "\2".\n |
81 | |
82 | === modified file 'language/english_base_notranslate.txt' |
83 | --- language/english_base_notranslate.txt 2009-03-02 13:40:05 +0000 |
84 | +++ language/english_base_notranslate.txt 2009-07-30 01:30:54 +0000 |
85 | @@ -253,7 +253,6 @@ |
86 | |
87 | config_accesslevel_3 Moderator-2 |
88 | config_accesslevel_4 Moderator-3 |
89 | -config_accesslevel_6 Armatrator-2 |
90 | config_accesslevel_9 Recruit |
91 | config_accesslevel_10 Recruit-1 |
92 | config_accesslevel_11 Recruit-2 |
93 | |
94 | === modified file 'src/engine/ePlayer.cpp' |
95 | --- src/engine/ePlayer.cpp 2009-04-30 12:36:02 +0000 |
96 | +++ src/engine/ePlayer.cpp 2009-07-30 01:30:54 +0000 |
97 | @@ -2282,6 +2282,7 @@ |
98 | if ( !victim->IsHuman() ) |
99 | { |
100 | sn_ConsoleOut( tOutput( "$access_level_op_denied_ai", command ), admin->Owner() ); |
101 | + return; |
102 | } |
103 | |
104 | victim->Authenticate( authName, accessLevel, admin ); |
105 | @@ -2325,6 +2326,170 @@ |
106 | } |
107 | } |
108 | |
109 | +// Changes the access level of a player, from console or other anonymous sources |
110 | +// and which is not to be called when you can call an OPFUNC |
111 | +// This isn't meant to be an user command, rather a simple switch between promoting and logging in, so make necessary checks yourself |
112 | +void se_AnonOp( ePlayerNetID * victim, tAccessLevel accessLevel, bool messages=true ) |
113 | +{ |
114 | + if ( !victim->IsHuman() ) |
115 | + { |
116 | + return; |
117 | + } |
118 | + |
119 | + if ( victim->IsAuthenticated() ) |
120 | + { |
121 | + if ( accessLevel > tAccessLevel_Authenticated ) |
122 | + { |
123 | + accessLevel = tAccessLevel_Authenticated; |
124 | + } |
125 | + |
126 | + tAccessLevel oldAccessLevel = victim->GetAccessLevel(); |
127 | + victim->SetAccessLevel( accessLevel ); |
128 | + |
129 | + |
130 | + if ( accessLevel < oldAccessLevel && messages ) |
131 | + { |
132 | + se_SecretConsoleOut( tOutput( "$access_level_promote_anon", |
133 | + victim->GetLogName(), |
134 | + tCurrentAccessLevel::GetName( accessLevel ) |
135 | + ), victim, &se_Hide, 0, 0, &se_CanHide ); |
136 | + } |
137 | + else if ( accessLevel > oldAccessLevel && messages ) |
138 | + { |
139 | + se_SecretConsoleOut( tOutput( "$access_level_demote_anon", |
140 | + victim->GetLogName(), |
141 | + tCurrentAccessLevel::GetName( accessLevel ) |
142 | + ), victim, &se_Hide, 0, 0, &se_CanHide ); |
143 | + } |
144 | + } |
145 | + else |
146 | + { |
147 | + tString authName = victim->GetUserName() + "@L_OP"; |
148 | + if ( victim->IsAuthenticated() ) |
149 | + { |
150 | + authName = victim->GetRawAuthenticatedName(); |
151 | + } |
152 | + |
153 | + victim->Authenticate( authName, accessLevel, 0, messages ); |
154 | + } |
155 | +} |
156 | + |
157 | +// Console command for it |
158 | +void se_OpConf( std::istream &s ) |
159 | +{ |
160 | + if ( se_NeedsServer( "OP", s ) ) |
161 | + { |
162 | + return; |
163 | + } |
164 | + |
165 | + ePlayerNetID * victim = se_FindPlayerInChatCommand( 0, "OP", s ); |
166 | + bool isexplicit = false; |
167 | + |
168 | + if ( victim ) |
169 | + { |
170 | + // read optional access level, this part is merly a copypaste from the /shuffle code |
171 | + int level = se_opAccessLevelMax; |
172 | + if ( victim->IsAuthenticated() ) |
173 | + { |
174 | + level = victim->GetAccessLevel(); |
175 | + } |
176 | + char first; |
177 | + s >> first; |
178 | + if ( !s.eof() && !s.fail() ) |
179 | + { |
180 | + isexplicit = true; |
181 | + s.unget(); |
182 | + int newLevel = 0; |
183 | + s >> newLevel; |
184 | + |
185 | + if ( first == '+' || first == '-' ) |
186 | + { |
187 | + level += newLevel; |
188 | + } |
189 | + else |
190 | + { |
191 | + level = newLevel; |
192 | + } |
193 | + } |
194 | + |
195 | + s >> level; |
196 | + |
197 | + tAccessLevel accessLevel; |
198 | + accessLevel = static_cast< tAccessLevel >( level ); |
199 | + |
200 | + if ( accessLevel == victim->GetAccessLevel() ) |
201 | + { |
202 | + if ( isexplicit ) |
203 | + { |
204 | + sn_ConsoleOut( tOutput( "$access_level_op_same", "OP" ), 0 ); |
205 | + } |
206 | + else |
207 | + { |
208 | + sn_ConsoleOut( tOutput( "$access_level_op_unclear", "OP" ), 0 ); |
209 | + } |
210 | + } |
211 | + else |
212 | + { |
213 | + se_AnonOp( victim, accessLevel ); |
214 | + } |
215 | + } |
216 | + |
217 | +} |
218 | + |
219 | +static tConfItemFunc se_opConf( "OP", &se_OpConf ); |
220 | +static tAccessLevelSetter se_opConfLevel( se_opConf, tAccessLevel_Owner ); |
221 | + |
222 | +void se_AnonDeOp( ePlayerNetID * victim, bool messages=true ) |
223 | +{ |
224 | + if ( victim->IsAuthenticated() ) |
225 | + { |
226 | + victim->DeAuthenticate( 0, messages ); |
227 | + } |
228 | +} |
229 | +void se_DeOpConf( std::istream &s ) |
230 | +{ |
231 | + if ( se_NeedsServer( "DEOP", s ) ) |
232 | + { |
233 | + return; |
234 | + } |
235 | + |
236 | + ePlayerNetID * victim = se_FindPlayerInChatCommand( 0, "DEOP", s ); |
237 | + |
238 | + if ( victim ) |
239 | + { |
240 | + se_AnonDeOp( victim, true ); |
241 | + } |
242 | +} |
243 | + |
244 | +static tConfItemFunc se_deOpConf( "DEOP", &se_DeOpConf ); |
245 | +static tAccessLevelSetter se_deOpConfLevel( se_deOpConf, tAccessLevel_Owner ); |
246 | + |
247 | +void se_MakeReferee( ePlayerNetID * victim, ePlayerNetID * admin ) |
248 | +{ |
249 | + se_AnonOp( victim, tAccessLevel_Referee, false ); |
250 | + if ( admin ) |
251 | + { |
252 | + sn_ConsoleOut( tOutput( "$player_referee", admin->GetColoredName(), victim->GetColoredName() ) ); |
253 | + } |
254 | + else |
255 | + { |
256 | + sn_ConsoleOut( tOutput( "$player_referee_anon", victim->GetColoredName() ) ); |
257 | + } |
258 | +} |
259 | + |
260 | +void se_CancelReferee( ePlayerNetID * victim, ePlayerNetID * admin ) |
261 | +{ |
262 | + se_AnonDeOp( victim, false ); |
263 | + if ( admin ) |
264 | + { |
265 | + sn_ConsoleOut( tOutput( "$player_referee_nomore", admin->GetColoredName(), victim->GetColoredName() ) ); |
266 | + } |
267 | + else |
268 | + { |
269 | + sn_ConsoleOut( tOutput( "$player_referee_nomore_anon", victim->GetColoredName() ) ); |
270 | + } |
271 | +} |
272 | + |
273 | // minimal access level for /team management |
274 | static tAccessLevel se_teamAccessLevel = tAccessLevel_TeamLeader; |
275 | static tSettingItem< tAccessLevel > se_teamAccessLevelConf( "ACCESS_LEVEL_TEAM", se_teamAccessLevel ); |
276 | @@ -5116,7 +5281,7 @@ |
277 | } |
278 | } |
279 | |
280 | -void ePlayerNetID::Authenticate( tString const & authName, tAccessLevel accessLevel_, ePlayerNetID const * admin ) |
281 | +void ePlayerNetID::Authenticate( tString const & authName, tAccessLevel accessLevel_, ePlayerNetID const * admin, bool messages ) |
282 | { |
283 | tString newAuthenticatedName( se_EscapeName( authName ).c_str() ); |
284 | |
285 | @@ -5162,28 +5327,30 @@ |
286 | SetAccessLevel( accessLevel_ ); |
287 | } |
288 | |
289 | - tString order( "" ); |
290 | - if ( admin ) |
291 | - { |
292 | - order = tOutput( "$login_message_byorder", |
293 | - admin->GetLogName() ); |
294 | - } |
295 | - |
296 | - if ( IsHuman() ) |
297 | - { |
298 | - if ( GetAccessLevel() != tAccessLevel_Default ) |
299 | - { |
300 | - se_SecretConsoleOut( tOutput( "$login_message_special", |
301 | - GetName(), |
302 | - newAuthenticatedName, |
303 | - tCurrentAccessLevel::GetName( GetAccessLevel() ), |
304 | - order ), this, &se_Hide, admin, 0, &se_CanHide ); |
305 | - } |
306 | - else |
307 | - { |
308 | - se_SecretConsoleOut( tOutput( "$login_message", GetName(), newAuthenticatedName, order ), this, &se_Hide, admin, 0, &se_CanHide ); |
309 | - } |
310 | - |
311 | + if ( messages ) |
312 | + { |
313 | + tString order( "" ); |
314 | + if ( admin ) |
315 | + { |
316 | + order = tOutput( "$login_message_byorder", |
317 | + admin->GetLogName() ); |
318 | + } |
319 | + |
320 | + if ( IsHuman() ) |
321 | + { |
322 | + if ( GetAccessLevel() != tAccessLevel_Remote ) |
323 | + { |
324 | + se_SecretConsoleOut( tOutput( "$login_message_special", |
325 | + GetName(), |
326 | + newAuthenticatedName, |
327 | + tCurrentAccessLevel::GetName( GetAccessLevel() ), |
328 | + order ), this, &se_Hide, admin, 0, &se_CanHide ); |
329 | + } |
330 | + else |
331 | + { |
332 | + se_SecretConsoleOut( tOutput( "$login_message", GetName(), newAuthenticatedName, order ), this, &se_Hide, admin, 0, &se_CanHide ); |
333 | + } |
334 | + } |
335 | } |
336 | } |
337 | |
338 | @@ -5193,14 +5360,14 @@ |
339 | UpdateName(); |
340 | } |
341 | |
342 | -void ePlayerNetID::DeAuthenticate( ePlayerNetID const * admin ){ |
343 | +void ePlayerNetID::DeAuthenticate( ePlayerNetID const * admin, bool messages ){ |
344 | if ( IsAuthenticated() ) |
345 | { |
346 | - if ( admin ) |
347 | + if ( admin && messages ) |
348 | { |
349 | se_SecretConsoleOut( tOutput( "$logout_message_deop", GetName(), GetFilteredAuthenticatedName(), admin->GetLogName() ), this, &se_Hide, admin, 0, &se_CanHide ); |
350 | } |
351 | - else |
352 | + else if ( messages ) |
353 | { |
354 | se_SecretConsoleOut( tOutput( "$logout_message", GetName(), GetFilteredAuthenticatedName() ), this, &se_Hide, 0, 0, &se_CanHide ); |
355 | } |
356 | |
357 | === modified file 'src/engine/ePlayer.h' |
358 | --- src/engine/ePlayer.h 2009-04-03 22:40:46 +0000 |
359 | +++ src/engine/ePlayer.h 2009-07-30 01:30:54 +0000 |
360 | @@ -319,8 +319,9 @@ |
361 | #ifdef KRAWALL_SERVER |
362 | void Authenticate( tString const & authName, |
363 | tAccessLevel accessLevel = tAccessLevel_Authenticated, |
364 | - ePlayerNetID const * admin = 0 ); //!< make the authentification valid |
365 | - void DeAuthenticate( ePlayerNetID const * admin = 0 ); //!< make the authentification invalid |
366 | + ePlayerNetID const * admin = 0, |
367 | + bool messages = true ); //!< make the authentification valid |
368 | + void DeAuthenticate( ePlayerNetID const * admin = 0, bool messages = true ); //!< make the authentification invalid |
369 | bool IsAuthenticated() const; //!< is the authentification valid? |
370 | #endif |
371 | |
372 | @@ -534,6 +535,9 @@ |
373 | |
374 | void ForceName ( std::istream & s ); |
375 | |
376 | +void se_MakeReferee( ePlayerNetID * victim, ePlayerNetID * admin = 0 ); |
377 | +void se_CancelReferee( ePlayerNetID * victim, ePlayerNetID * admin = 0 ); |
378 | + |
379 | // ****************************************************************************************** |
380 | // * |
381 | // * GetNameFromClient |
382 | |
383 | === modified file 'src/engine/eVoter.cpp' |
384 | --- src/engine/eVoter.cpp 2009-04-03 22:40:46 +0000 |
385 | +++ src/engine/eVoter.cpp 2009-07-30 01:30:54 +0000 |
386 | @@ -100,7 +100,15 @@ |
387 | static int se_votingBiasSuspend = 0; |
388 | static tSettingItem< int > se_vbSuspend( "VOTING_BIAS_SUSPEND", se_votingBiasSuspend ); |
389 | |
390 | -// the number set here always acts as additional votes against a suspend vote. |
391 | +// the number set here always acts as additional votes against a referee vote. |
392 | +static int se_votingBiasReferee = 0; |
393 | +static tSettingItem< int > se_vbReferee( "VOTING_BIAS_REFEREE", se_votingBiasReferee ); |
394 | + |
395 | +// the number set here always acts as additional votes against a demotereferee vote. |
396 | +static int se_votingBiasCancelReferee = 0; |
397 | +static tSettingItem< int > se_vbCancelReferee( "VOTING_BIAS_DEMOTEREFEREE", se_votingBiasCancelReferee ); |
398 | + |
399 | +// the number set here always acts as additional votes against a include vote. |
400 | static int se_votingBiasInclude = 0; |
401 | static tSettingItem< int > se_vbInclude( "VOTING_BIAS_INCLUDE", se_votingBiasInclude ); |
402 | |
403 | @@ -143,6 +151,17 @@ |
404 | static tSettingItem< tAccessLevel > se_accessLevelVoteSuspendSI( "ACCESS_LEVEL_VOTE_SUSPEND", se_accessLevelVoteSuspend ); |
405 | static tAccessLevelSetter se_accessLevelVoteSuspendSILevel( se_accessLevelVoteSuspendSI, tAccessLevel_Owner ); |
406 | |
407 | +// minimal access level for referee votes |
408 | +static tAccessLevel se_accessLevelVoteReferee = tAccessLevel_Moderator; |
409 | +static tSettingItem< tAccessLevel > se_accessLevelVoteRefereeSI( "ACCESS_LEVEL_VOTE_REFEREE", se_accessLevelVoteReferee ); |
410 | +static tAccessLevelSetter se_accessLevelVoteRefereeSILevel( se_accessLevelVoteRefereeSI, tAccessLevel_Owner ); |
411 | + |
412 | +// minimal access level for demotereferee votes |
413 | +static tAccessLevel se_accessLevelVoteCancelReferee = tAccessLevel_Moderator; |
414 | +static tSettingItem< tAccessLevel > se_accessLevelVoteCancelRefereeSI( "ACCESS_LEVEL_VOTE_DEMOTEREFEREE", se_accessLevelVoteCancelReferee ); |
415 | +static tAccessLevelSetter se_accessLevelVoteCancelRefereeSILevel( se_accessLevelVoteCancelRefereeSI, tAccessLevel_Owner ); |
416 | + |
417 | + |
418 | // minimal access level for include votes |
419 | static tAccessLevel se_accessLevelVoteInclude = tAccessLevel_Moderator; |
420 | static tSettingItem< tAccessLevel > se_accessLevelVoteIncludeSI( "ACCESS_LEVEL_VOTE_INCLUDE", se_accessLevelVoteInclude ); |
421 | @@ -363,7 +382,7 @@ |
422 | } |
423 | |
424 | // enough voters online? |
425 | - if ( eVoter::voters_.Len() < se_minVoters ) |
426 | + if ( eVoter::voters_.Len() < se_minVoters || eVoter::voters_.Len() < 2 ) |
427 | { |
428 | tOutput message("$vote_toofew"); |
429 | sn_ConsoleOut( message, senderID ); |
430 | @@ -519,7 +538,7 @@ |
431 | if ( sn_GetNetState() == nSERVER ) |
432 | { |
433 | // see if there are enough voters |
434 | - if ( total <= se_minVoters ) |
435 | + if ( total < se_minVoters || total < 2 ) |
436 | { |
437 | this->BroadcastMessage( tOutput("$vote_toofew") ); |
438 | delete this; |
439 | @@ -553,9 +572,9 @@ |
440 | |
441 | tOutput voteMessage; |
442 | voteMessage.SetTemplateParameter( 1, GetDescription() ); |
443 | - voteMessage.SetTemplateParameter( 2, pro-1 ); |
444 | - voteMessage.SetTemplateParameter( 3, con-se_votingBias ); |
445 | - voteMessage.SetTemplateParameter( 4, total-se_votingBias); |
446 | + voteMessage.SetTemplateParameter( 2, pro ); |
447 | + voteMessage.SetTemplateParameter( 3, con-bias ); |
448 | + voteMessage.SetTemplateParameter( 4, total-pro-con+bias ); |
449 | voteMessage << "$vote_rejected"; |
450 | this->BroadcastMessage( voteMessage ); |
451 | delete this; |
452 | @@ -565,14 +584,14 @@ |
453 | // see if the vote has been accepted |
454 | if ( pro >= con && pro * 2 > total ) |
455 | { |
456 | + tOutput voteMessage; |
457 | + voteMessage.SetTemplateParameter( 1, GetDescription() ); |
458 | + voteMessage.SetTemplateParameter( 2, pro ); |
459 | + voteMessage.SetTemplateParameter( 3, con-bias ); |
460 | + voteMessage.SetTemplateParameter( 4, total-pro-con+bias ); |
461 | + voteMessage << "$vote_accepted"; |
462 | + this->BroadcastMessage( voteMessage ); |
463 | this->DoExecute(); |
464 | - tOutput voteMessage; |
465 | - voteMessage.SetTemplateParameter( 1, GetDescription() ); |
466 | - voteMessage.SetTemplateParameter( 2, pro-1 ); |
467 | - voteMessage.SetTemplateParameter( 3, con-se_votingBias ); |
468 | - voteMessage.SetTemplateParameter( 4, total-se_votingBias); |
469 | - voteMessage << "$vote_accepted"; |
470 | - this->BroadcastMessage( voteMessage ); |
471 | delete this; |
472 | return; |
473 | } |
474 | @@ -1681,8 +1700,110 @@ |
475 | tAccessLevel level_; //!< the level to execute the file with |
476 | }; |
477 | |
478 | +class eVoteItemReferee: public eVoteItemHarmServerControlled |
479 | +{ |
480 | +public: |
481 | + eVoteItemReferee( ePlayerNetID* player = 0 ) |
482 | + : eVoteItemHarm( player ) |
483 | + {} |
484 | + |
485 | + ~eVoteItemReferee() |
486 | + {} |
487 | +protected: |
488 | + // get the language string prefix |
489 | + virtual char const * DoGetPrefix() const{ return "referee"; } |
490 | + |
491 | + // access level required for this kind of vote |
492 | + virtual tAccessLevel DoGetAccessLevel() const |
493 | + { |
494 | + return se_accessLevelVoteReferee; |
495 | + } |
496 | + |
497 | + virtual bool DoCheckValid( int senderID ) |
498 | + { |
499 | + if ( !eVoteItemHarm::DoCheckValid( senderID ) ) |
500 | + return false; |
501 | + |
502 | + ePlayerNetID * victim = GetPlayer(); |
503 | + if ( victim->GetAccessLevel() <= tAccessLevel_Referee ) |
504 | + { |
505 | + sn_ConsoleOut( tOutput("$vote_referee_already", victim->GetColoredName() ), senderID ); |
506 | + return false; |
507 | + } |
508 | + |
509 | + return true; |
510 | + } |
511 | + |
512 | + // return vote-specific extra bias |
513 | + virtual int DoGetExtraBias() const |
514 | + { |
515 | + return se_votingBiasReferee; |
516 | + } |
517 | + virtual void DoExecute() // called when the voting was successful |
518 | + { |
519 | + ePlayerNetID * player = GetPlayer(); |
520 | + if ( player ) |
521 | + { |
522 | + se_MakeReferee ( player ); |
523 | + } |
524 | + } |
525 | + |
526 | +}; |
527 | + |
528 | +class eVoteItemCancelReferee: public eVoteItemHarmServerControlled |
529 | +{ |
530 | +public: |
531 | + eVoteItemCancelReferee( ePlayerNetID* player = 0 ) |
532 | + : eVoteItemHarm( player ) |
533 | + {} |
534 | + |
535 | + ~eVoteItemCancelReferee() |
536 | + {} |
537 | +protected: |
538 | + // get the language string prefix |
539 | + virtual char const * DoGetPrefix() const{ return "demotereferee"; } |
540 | + |
541 | + // access level required for this kind of vote |
542 | + virtual tAccessLevel DoGetAccessLevel() const |
543 | + { |
544 | + return se_accessLevelVoteReferee; |
545 | + } |
546 | + |
547 | + virtual bool DoCheckValid( int senderID ) |
548 | + { |
549 | + if ( !eVoteItemHarm::DoCheckValid( senderID ) ) |
550 | + return false; |
551 | + |
552 | + ePlayerNetID * victim = GetPlayer(); |
553 | + if ( victim->GetAccessLevel() != tAccessLevel_Referee ) |
554 | + { |
555 | + sn_ConsoleOut( tOutput("$vote_demotereferee_notref", victim->GetColoredName() ), senderID ); |
556 | + return false; |
557 | + } |
558 | + |
559 | + return true; |
560 | + } |
561 | + |
562 | + // return vote-specific extra bias |
563 | + virtual int DoGetExtraBias() const |
564 | + { |
565 | + return se_votingBiasCancelReferee; |
566 | + } |
567 | + virtual void DoExecute() // called when the voting was successful |
568 | + { |
569 | + ePlayerNetID * player = GetPlayer(); |
570 | + if ( player ) |
571 | + { |
572 | + se_CancelReferee ( player ); |
573 | + } |
574 | + } |
575 | + |
576 | +}; |
577 | + |
578 | #endif |
579 | |
580 | + |
581 | + |
582 | // ************************************************************************************** |
583 | // ************************************************************************************** |
584 | |
585 | @@ -2168,6 +2289,30 @@ |
586 | item = tNEW( eVoteItemInclude )( file, p->GetAccessLevel() ); |
587 | } |
588 | } |
589 | + else if ( command == "referee" ) |
590 | + { |
591 | + tString name; |
592 | + name.ReadLine( message ); |
593 | + ePlayerNetID * toMakeReferee = ePlayerNetID::FindPlayerByName( name, p ); |
594 | + |
595 | + if ( toMakeReferee ) |
596 | + { |
597 | + // accept message |
598 | + item = tNEW( eVoteItemReferee )( toMakeReferee ); |
599 | + } |
600 | + } |
601 | + else if ( command == "demotereferee" ) |
602 | + { |
603 | + tString name; |
604 | + name.ReadLine( message ); |
605 | + ePlayerNetID * toDemoteReferee = ePlayerNetID::FindPlayerByName( name, p ); |
606 | + |
607 | + if ( toDemoteReferee ) |
608 | + { |
609 | + // accept message |
610 | + item = tNEW( eVoteItemCancelReferee )( toDemoteReferee ); |
611 | + } |
612 | + } |
613 | else if ( command == "command" ) |
614 | { |
615 | tString console; |
616 | @@ -2181,9 +2326,9 @@ |
617 | else |
618 | { |
619 | #ifdef KRAWALL_SERVER |
620 | - sn_ConsoleOut( tOutput("$vote_unknown_command", command, "suspend, kick, include, command" ), p->Owner() ); |
621 | + sn_ConsoleOut( tOutput("$vote_unknown_command", command, "command, demotereferee, include, kick, referee, suspend" ), p->Owner() ); |
622 | #else |
623 | - sn_ConsoleOut( tOutput("$vote_unknown_command", command, "suspend, kick" ), p->Owner() ); |
624 | + sn_ConsoleOut( tOutput("$vote_unknown_command", command, "kick, suspend" ), p->Owner() ); |
625 | #endif |
626 | } |
627 | |
628 | |
629 | === modified file 'src/tools/tConfiguration.h' |
630 | --- src/tools/tConfiguration.h 2009-04-01 23:32:45 +0000 |
631 | +++ src/tools/tConfiguration.h 2009-07-30 01:30:54 +0000 |
632 | @@ -50,7 +50,7 @@ |
633 | tAccessLevel_3 = 3, // reserved |
634 | tAccessLevel_4 = 4, // reserved |
635 | tAccessLevel_Armatrator = 5, // reserved |
636 | - tAccessLevel_6 = 6, // reserved |
637 | + tAccessLevel_Referee = 6, // a referee elected by players |
638 | tAccessLevel_TeamLeader = 7, // a team leader |
639 | tAccessLevel_TeamMember = 8, // a team member |
640 | tAccessLevel_9 = 9, // reserved |
This branch sets two new vote types: referee and demotereferee
The first one will promote someone to access level 6 (one access level better than team leader, one worse than Armatrator), the other will cancel it.
Also:
* Added OP/DEOP as console commands. Use with care.
* Fixed voter/nonvoter counts being wrong after a vote.
* Fixed a MIN_VOTERS check requiring MIN_VOTERS + 1 voters.
* Fixed the fact a vote could be started with less than 2 voters present.
* Fixed the "vote accepted" message being shown after executing the vote instead of the opposite.