-
-
Notifications
You must be signed in to change notification settings - Fork 18
/
galileo.sma
7297 lines (6038 loc) · 245 KB
/
galileo.sma
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*********************** Licensing *******************************************************
*
* Copyright 2008-2010 @ Brad Jones
* Copyright 2015-2016 @ Addons zz
* Copyright 2004-2016 @ AMX Mod X Development Team
*
* Plugin Thread: https://forums.alliedmods.net/showthread.php?t=273019
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 3 of the License, or ( at
* your option ) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*****************************************************************************************
*/
/**
* This version number must be synced with "githooks/GALILEO_VERSION.txt" for manual edition.
* To update them automatically, use: ./githooks/updateVersion.sh [major | minor | patch | build]
*/
new const PLUGIN_VERSION[] = "v2.6.1-95";
/** This is to view internal program data while execution. See the function 'debugMesssageLogger(...)'
* and the variable 'g_debug_level' for more information. Default value: 0
*
* 0 - Disables this feature.
*
* 1 - Normal/basic debugging/depuration.
*
* 2 - a) To skip the 'pendingVoteCountdown()'.
* b) Set the vote runoff time to 5 seconds.
* c) Run the Unit Tests and print their out put results.
*
* 4 - a) To create fake votes. See the function 'create_fakeVotes()'.
* b) To create fake players count. See the function 'get_realplayersnum()'.
*
* 8 - Enable DEBUG_LEVEL 1 and all its debugging/depuration available.
*
* 15 - Levels 1, 2, 4 and 8.
*/
#define DEBUG_LEVEL 8
#define DEBUG_LEVEL_NORMAL 1
#define DEBUG_LEVEL_UNIT_TEST 2
#define DEBUG_LEVEL_FAKE_VOTES 4
#define DEBUG_LEVEL_CRITICAL_MODE 8
#include <amxmodx>
#include <amxmisc>
#pragma semicolon 1
#if DEBUG_LEVEL & ( DEBUG_LEVEL_NORMAL | DEBUG_LEVEL_CRITICAL_MODE )
#define DEBUG
#define LOGGER(%1) debugMesssageLogger( %1 )
/**
* 0 - Disabled all debug.
*
* 1 - Displays basic debug messages.
*
* 2 - a) Players disconnecting and total number.
* b) Multiple time limits changes and restores.
*
* 4 - a) Maps events.
* b) Vote choices.
* c) Nominations.
* d) Calls to map_populateList(4).
*
* 8 - a) Loaded vote choices.
* b) Minplayers-whitelist debugging.
* c) Actions at vote_startDirector(1).
*
* 16 - Runoff voting.
* 32 - Rounds end map voting.
* 64 - Debug for the color_print(...) function.
* 128 - Functions entrances messages.
* 255 - Enables all debug logging levels.
*/
new g_debug_level = 1 + 4 + 8 + 16;
/**
* Write debug messages to server's console accordantly with cvar gal_debug.
* If gal_debug 1 or more higher, the voting and runoff times are set to 5 seconds.
*
* @param mode the debug mode level, see the variable 'g_debug_level' for the levels.
* @param text the debug message, if omitted its default value is ""
* @param any the variable number of formatting parameters
*/
stock debugMesssageLogger( mode, message[] = "", any: ... )
{
if( mode & g_debug_level )
{
static formated_message[ 384 ];
vformat( formated_message, charsmax( formated_message ), message, 3 );
writeToTheDebugFile( formated_message );
}
}
#else
#define LOGGER(%1) allowToUseSemicolonOnMacrosEnd()
#endif
#if DEBUG_LEVEL & DEBUG_LEVEL_UNIT_TEST
/**
* Contains all unit tests to execute.
*/
#define ALL_TESTS_TO_EXECUTE() \
do \
{ \
test_register_test(); \
test_gal_in_empty_cycle_case1(); \
test_gal_in_empty_cycle_case2(); \
test_gal_in_empty_cycle_case3(); \
test_gal_in_empty_cycle_case4(); \
test_is_map_extension_allowed(); \
test_loadCurrentBlackList_case1(); \
test_loadCurrentBlackList_case2(); \
test_loadCurrentBlackList_case3(); \
} while( g_dummy_value )
/**
* Call the internal function to perform its task and stop the current test execution to avoid
* double failure at the test control system.
*/
#define SET_TEST_FAILURE(%1) \
do \
{ \
set_test_failure_private( %1 ); \
if( g_current_test_evaluation ) \
{ \
return; \
} \
} while( g_dummy_value )
/**
* Write debug messages to server's console accordantly with cvar gal_debug.
*
* @param text the debug message, if omitted its default value is ""
* @param any the variable number of formatting parameters
*/
stock print_logger( message[] = "", any: ... )
{
static formated_message[ 384 ];
vformat( formated_message, charsmax( formated_message ), message, 2 );
writeToTheDebugFile( formated_message );
}
/**
* Test unit variables related to the DEBUG_LEVEL_UNIT_TEST 2.
*/
new g_max_delay_result;
new g_totalSuccessfulTests;
new g_totalFailureTests;
new Array: g_tests_idsAndNames;
new Array: g_tests_failure_ids;
new Array: g_tests_failure_reasons;
new bool: g_is_test_changed_cvars;
new bool: g_current_test_evaluation;
new bool: g_areTheUnitTestsRunning;
new g_test_current_time;
new g_test_whiteListFilePath[ 128 ];
#endif
/**
* Write messages to the debug log file '_galileo.log' on 'addons/amxmodx/logs'.
*
* @param formated_message the formatted message to write down to the debug log file.
*/
#if DEBUG_LEVEL >= DEBUG_LEVEL_NORMAL
stock writeToTheDebugFile( formated_message[] )
{
static Float:gameTime;
gameTime = get_gametime();
log_to_file( "_galileo.log", "{%3.4f} %s", gameTime, formated_message );
}
#endif
#if AMXX_VERSION_NUM < 183
new g_user_msgid;
#endif
#if !defined MAX_PLAYERS
#define MAX_PLAYERS 32
#endif
/**
* Dummy value used to use the do...while() statements to allow the semicolon ';' use at macros endings.
*/
new g_dummy_value = 0;
stock allowToUseSemicolonOnMacrosEnd()
{
}
#define TASKID_REMINDER 52691153
#define TASKID_SHOW_LAST_ROUND_HUD 52691052
#define TASKID_DELETE_USERS_MENUS 72748052
#define TASKID_PREVENT_INFITY_GAME 82448699
#define TASKID_EMPTYSERVER 98176977
#define TASKID_START_VOTING_BY_ROUNDS 52691160
#define TASKID_START_VOTING_BY_TIMER 72681180
#define TASKID_PROCESS_LAST_ROUND 42691173
#define TASKID_VOTE_HANDLEDISPLAY 52691264
#define TASKID_VOTE_DISPLAY 52691165
#define TASKID_VOTE_EXPIRE 52691166
#define TASKID_PENDING_VOTE_COUNTDOWN 13464364
#define TASKID_DBG_FAKEVOTES 52691167
#define TASKID_VOTE_STARTDIRECTOR 52691168
#define TASKID_MAP_CHANGE 52691169
#define RTV_CMD_STANDARD 1
#define RTV_CMD_SHORTHAND 2
#define RTV_CMD_DYNAMIC 4
#define MAX_LONG_STRING 256
#define MAX_COLOR_MESSAGE 192
#define MAX_SHORT_STRING 64
#define MAX_NOMINATION_TRIE_KEY_SIZE 48
#define SOUND_GETREADYTOCHOOSE 1
#define SOUND_COUNTDOWN 2
#define SOUND_TIMETOCHOOSE 4
#define SOUND_RUNOFFREQUIRED 8
#define MAPFILETYPE_SINGLE 1
#define MAPFILETYPE_GROUPS 2
#define SHOW_STATUS_NEVER 0
#define SHOW_STATUS_AFTER_VOTE 1
#define SHOW_STATUS_AT_END 2
#define SHOW_STATUS_ALWAYS 3
#define STATUS_TYPE_COUNT 1
#define STATUS_TYPE_PERCENTAGE 2
#define HIDE_AFTER_USER_VOTE 0
#define ALWAYS_KEEP_SHOWING 1
#define CONVERT_IT_TO_CANCEL_LAST_VOTE 2
#define ANNOUNCE_CHOICE_PLAYERS 1
#define ANNOUNCE_CHOICE_ADMINS 2
#define MAX_PREFIX_COUNT 32
#define MAX_RECENT_MAP_COUNT 16
#define MAX_MAPS_IN_VOTE 8
#define MAX_NOMINATION_COUNT 8
#define MAX_OPTIONS_IN_VOTE 9
#define MAX_STANDARD_MAP_COUNT 25
#define MAX_SERVER_RESTART_ACCEPTABLE 10
#define MAX_MAPNAME_LENGHT 64
#define MAX_FILE_PATH_LENGHT 128
#define MAX_PLAYER_NAME_LENGHT 48
#define MAX_NOM_MATCH_COUNT 1000
#define MAX_PLAYERS_COUNT MAX_PLAYERS + 1
#define VOTE_IS_IN_PROGRESS 1
#define VOTE_IS_FORCED 2
#define VOTE_IS_RUNOFF 4
#define VOTE_IS_OVER 8
#define VOTE_IS_EARLY 16
#define VOTE_IS_EXPIRED 32
#define SERVER_START_CURRENTMAP 1
#define SERVER_START_NEXTMAP 2
#define SERVER_START_MAPVOTE 3
#define SERVER_START_RANDOMMAP 4
#define LISTMAPS_USERID 0
#define LISTMAPS_LAST 1
#define START_VOTEMAP_MIN_TIME 151
#define START_VOTEMAP_MAX_TIME 129
#define VOTE_ROUND_START_MIN_DELAY 500
#define VOTE_ROUND_START_MAX_DELAY START_VOTEMAP_MIN_TIME
/**
* Give a 4 minutes range to try detecting the round start, to avoid buy old buy weapons menu
* override.
*
* @param seconds how many seconds are reaming to the map end.
*/
#define VOTE_ROUND_START_DETECTION_DELAYED(%1) \
( %1 < VOTE_ROUND_START_MIN_DELAY \
&& %1 > VOTE_ROUND_START_MAX_DELAY )
/**
* To start the end map voting near the map time limit expiration.
*/
#define IS_TIME_TO_START_THE_END_OF_MAP_VOTING(%1) \
( %1 < START_VOTEMAP_MIN_TIME \
&& %1 > START_VOTEMAP_MAX_TIME )
/**
* The rounds number before the mp_maxrounds/mp_winlimit to be reached to start the map voting.
*/
#define VOTE_START_ROUNDS 4
/**
* The frags/kills number before the mp_fraglimit to be reached and to start the map voting.
*/
#define VOTE_START_FRAGS 15
/**
* Specifies how much time to delay the voting start after the round start.
*/
#define VOTE_ROUND_START_SECONDS_DELAY() ( get_pcvar_num( cvar_mp_freezetime ) + 20.0 )
/**
* Start a map voting delayed after the mp_maxrounds or mp_winlimit minimum to be reached.
*/
#define VOTE_START_ROUND_DELAY() \
do \
{ \
set_task( VOTE_ROUND_START_SECONDS_DELAY(), "start_voting_by_rounds", TASKID_START_VOTING_BY_ROUNDS ); \
} while( g_dummy_value )
/**
* Verifies if a voting is or was already processed.
*/
#define IS_END_OF_MAP_VOTING_GOING_ON() \
( g_voteStatus & VOTE_IS_IN_PROGRESS \
|| g_voteStatus & VOTE_IS_OVER )
/**
* Boolean check for the whitelist feature.
*/
#define IS_WHITELIST_ENABLED() \
( get_pcvar_num( cvar_whitelistMinPlayers ) == 1 \
|| get_realplayersnum() < get_pcvar_num( cvar_whitelistMinPlayers ) )
/**
* Boolean check for the nominations minimum players controlling feature.
*/
#define IS_NOMINATION_MININUM_PLAYERS_CONTROL_ENABLED() \
( get_realplayersnum() < get_pcvar_num( cvar_voteMinPlayers ) \
&& get_pcvar_num( cvar_NomMinPlayersControl ) )
/**
* Convert colored strings codes '!g for green', '!y for yellow', '!t for team'.
*
* @param string[] a string pointer to be converted.
*/
#define INSERT_COLOR_TAGS(%1) \
do \
{ \
replace_all( %1, charsmax( %1 ), "!g", "^4" ); \
replace_all( %1, charsmax( %1 ), "!t", "^3" ); \
replace_all( %1, charsmax( %1 ), "!n", "^1" ); \
replace_all( %1, charsmax( %1 ), "!y", "^1" ); \
} while( g_dummy_value )
/**
* Remove the colored strings codes '^4 for green', '^1 for yellow', '^3 for team' and
* '^2 for unknown'.
*
* @param string[] a string pointer to be formatted.
*/
#define REMOVE_COLOR_TAGS(%1) \
do \
{ \
replace_all( %1, charsmax( %1 ), "^1", "" ); \
replace_all( %1, charsmax( %1 ), "^2", "" ); \
replace_all( %1, charsmax( %1 ), "^3", "" ); \
replace_all( %1, charsmax( %1 ), "^4", "" ); \
} while( g_dummy_value )
/**
* Print to the users chat, a colored chat message.
*
* @param player_id a player id from 1 to MAX_PLAYERS
* @param message a colored formatted string message. At the AMXX 182 it must start within
* one color code as found on REMOVE_COLOR_TAGS(1) above macro. Example:
* "^1Hi! I am a ^3 colored message".
*/
#define PRINT_COLORED_MESSAGE(%1,%2) \
do \
{ \
message_begin( MSG_ONE_UNRELIABLE, g_user_msgid, _, %1 ); \
write_byte( %1 ); \
write_string( %2 ); \
message_end(); \
} while( g_dummy_value )
/**
* Get the player name. If the player is not connected, uses "Unknown Dude" as its name.
*
* @param player_id the player id
* @param name_string a string pointer to hold the player name.
*/
#define GET_USER_NAME(%1,%2) \
do \
{ \
if( is_user_connected( %1 ) ) \
{ \
get_user_name( %1, %2, charsmax( %2 ) ); \
} \
else \
{ \
copy( %2, charsmax( %2 ), "Unknown Dude" ); \
} \
} while( g_dummy_value )
/**
* Game cvars.
*/
new cvar_mp_freezetime;
new cvar_mp_winlimit;
new cvar_mp_fraglimit;
new cvar_mp_maxrounds;
new cvar_mp_timelimit;
new cvar_mp_roundtime;
new cvar_mp_chattime;
new cvar_sv_maxspeed;
/**
* Server cvars
*/
new cvar_extendmapAllowStayType;
new cvar_nextMapChangeAnnounce;
new cvar_disabledValuePointer;
new cvar_isToShowVoteCounter;
new cvar_isToShowNoneOption;
new cvar_voteShowNoneOptionType;
new cvar_isExtendmapOrderAllowed;
new cvar_coloredChatEnabled;
new cvar_isToStopEmptyCycle;
new cvar_unnominateDisconnected;
new cvar_endOnRound;
new cvar_endOfMapVoteStart;
new cvar_endOnRoundRtv;
new cvar_endOnRound_msg;
new cvar_voteWeight;
new cvar_voteWeightFlags;
new cvar_maxMapExtendTime;
new cvar_extendmapStepMinutes;
new cvar_extendmapStepRounds;
new cvar_extendmapAllowStay;
new cvar_endOfMapVote;
new cvar_isToAskForEndOfTheMapVote;
new cvar_emptyWait;
new cvar_isEmptyCycleServerChange;
new cvar_emptyMapFilePath;
new cvar_rtvMinutesWait;
new cvar_rtvWaitRounds;
new cvar_rtvWaitAdmin;
new cvar_rtvRatio;
new cvar_rtvCommands;
new cvar_cmdVotemap;
new cvar_cmdListmaps;
new cvar_listmapsPaginate;
new cvar_recentMapsBannedNumber;
new cvar_banRecentStyle;
new cvar_voteDuration;
new cvar_nomMapFilePath;
new cvar_nomPrefixes;
new cvar_nomQtyUsed;
new cvar_nomPlayerAllowance;
new cvar_isToShowExpCountdown;
new cvar_isEndMapCountdown;
new cvar_voteMapChoiceCount;
new cvar_voteAnnounceChoice;
new cvar_voteUniquePrefixes;
new cvar_rtvReminder;
new cvar_serverStartAction;
new cvar_serverTimeLimitRestart;
new cvar_serverMaxroundsRestart;
new cvar_serverWinlimitRestart;
new cvar_runoffEnabled;
new cvar_runoffDuration;
new cvar_showVoteStatus;
new cvar_showVoteStatusType;
new cvar_isToReplaceByVoteMenu;
new cvar_soundsMute;
new cvar_voteMapFilePath;
new cvar_voteMinPlayers;
new cvar_NomMinPlayersControl;
new cvar_voteMinPlayersMapFilePath;
new cvar_whitelistMinPlayers;
new cvar_voteWhiteListMapFilePath;
/**
* Various Artists
*/
new const LAST_EMPTY_CYCLE_FILE_NAME[] = "lastEmptyCycleMapName.dat";
new const CURRENT_AND_NEXTMAP_FILE_NAME[] = "currentAndNextmapNames.dat";
new const LAST_CHANGE_MAP_FILE_NAME[] = "lastChangedMapName.dat";
new const CHOOSE_MAP_MENU_NAME[] = "gal_menuChooseMap";
new const CHOOSE_MAP_MENU_QUESTION[] = "chooseMapQuestion";
new bool:g_isVotingByTimer;
new bool:g_isTimeToResetGame;
new bool:g_isTimeToResetRounds;
new bool:g_isUsingEmptyCycle;
new bool:g_isRunOffNeedingKeepCurrentMap;
new bool:g_isExtendmapAllowStay;
new bool:g_isToShowNoneOption;
new bool:g_isToShowExpCountdown;
new bool:g_isToShowVoteCounter;
new bool:g_isToRefreshVoteStatus;
new bool:g_isEmptyCycleMapConfigured;
new bool:g_isColoredChatEnabled;
new bool:g_isMaxfragsExtend;
new bool:g_isMaxroundsExtend;
new bool:g_isVotingByRounds;
new bool:g_isRtvLastRound;
new bool:g_isLastGameRound;
new bool:g_isTimeToChangeLevel;
new bool:g_isTimeToRestart;
new bool:g_isTimeLimitChanged;
new bool:g_isMapExtensionAllowed;
new bool:g_isColorChatSupported;
new bool:g_isGameFinalVoting;
new Float:g_rtvMinutesWait;
new Float:g_originalTimelimit;
new Float:g_original_sv_maxspeed;
/**
* Holds the Empty Cycle Map List feature maps used when the server is empty for some time to
* change the map to a popular one.
*/
new Array:g_emptyCycleMapsList;
/**
* Stores the players nominations until MAX_NOMINATION_COUNT for each player.
*/
new Trie:g_playersNominations;
/**
* Stores the nominators id by a given map index. It is to find out the player id given the nominated
* map index.
*/
new Trie:g_nominationMapsTrie;
/**
* Enumeration used to create access the "g_nominationMapsTrie" values. It is untagged to be able to
* pass it throw an TrieSetArray.
*/
enum _:MapNominationsType
{
MapNominationsPlayerId,
MapNominationsNominationIndex
}
new Array:g_fillerMaps;
new Array:g_nominationMapsArray;
new g_originalMaxRounds;
new g_originalWinLimit;
new g_showVoteStatusType;
new g_extendmapStepRounds;
new g_extendmapStepMinutes;
new g_extendmapAllowStayType;
new g_showVoteStatus;
new g_voteShowNoneOptionType;
new g_pendingVoteCountdown;
new g_lastRroundCountdown;
new g_rtvWaitAdminNumber;
new g_emptyCycleMapsNumber;
new g_recentMapCount;
new g_nominationMapCount;
new g_rtvCommands;
new g_rtvWaitRounds;
new g_rockedVoteCount;
new g_totalRoundsPlayed;
new g_totalTerroristsWins;
new g_totalCtWins;
new g_totalVoteOptions;
new g_totalVoteOptionsTemp;
new g_maxVotingChoices;
new g_voteStatus;
new g_voteDuration;
new g_totalVotesCounted;
new COLOR_RED [ 3 ]; // \r
new COLOR_WHITE [ 3 ]; // \w
new COLOR_YELLOW[ 3 ]; // \y
new COLOR_GREY [ 3 ]; // \d
new g_mapPrefixCount = 1;
/**
* Nextmap sub-plugin global variables.
*/
new g_cvar_mp_chattime;
new g_cvar_amx_nextmap;
new g_cvar_mp_friendlyfire;
new g_nextMapCyclePosition;
new g_arrayOfRunOffChoices[ 2 ];
new g_voteStatus_symbol [ 3 ];
new g_voteWeightFlags [ 32 ];
new g_voteStatusClean [ 512 ];
new g_configsDirPath [ MAX_FILE_PATH_LENGHT ];
new g_dataDirPath [ MAX_FILE_PATH_LENGHT ];
/**
* Nextmap sub-plugin global variables.
*/
new g_nextMapName [ MAX_MAPNAME_LENGHT ];
new g_currentMapName [ MAX_MAPNAME_LENGHT ];
new g_mapCycleFilePath [ MAX_FILE_PATH_LENGHT ];
new g_nextMap [ MAX_MAPNAME_LENGHT ];
new g_currentMap [ MAX_MAPNAME_LENGHT ];
new g_playerVotedOption [ MAX_PLAYERS_COUNT ];
new g_playerVotedWeight [ MAX_PLAYERS_COUNT ];
new g_generalUsePlayersMenuId [ MAX_PLAYERS_COUNT ];
new g_playersKills [ MAX_PLAYERS_COUNT ];
new g_arrayOfMapsWithVotesNumber[ MAX_OPTIONS_IN_VOTE ];
new Array:g_currentMenuMapIndexForPlayers[ MAX_PLAYERS_COUNT ];
new bool:g_isPlayerVoted [ MAX_PLAYERS_COUNT ] = { true, ... };
new bool:g_isPlayerParticipating [ MAX_PLAYERS_COUNT ] = { true, ... };
new bool:g_isPlayerSeeingTheVoteMenu[ MAX_PLAYERS_COUNT ];
new bool:g_isPlayerCancelledVote [ MAX_PLAYERS_COUNT ];
new bool:g_answeredForEndOfMapVote [ MAX_PLAYERS_COUNT ];
new bool:g_rockedVote [ MAX_PLAYERS_COUNT ];
new g_mapPrefixes [ MAX_PREFIX_COUNT ][ 16 ];
new g_recentMaps [ MAX_RECENT_MAP_COUNT ][ MAX_MAPNAME_LENGHT ];
new g_votingMapNames [ MAX_OPTIONS_IN_VOTE ][ MAX_MAPNAME_LENGHT ];
new g_nominationCount;
new g_chooseMapMenuId;
new g_chooseMapQuestionMenuId;
public plugin_init()
{
#if DEBUG_LEVEL & DEBUG_LEVEL_CRITICAL_MODE
g_debug_level = 1048575;
#endif
register_plugin( "Galileo", PLUGIN_VERSION, "Brad Jones/Addons zz" );
LOGGER( 1, "^n^n^n^nGALILEO PLUGIN VERSION %s INITIATING...", PLUGIN_VERSION );
cvar_maxMapExtendTime = register_cvar( "amx_extendmap_max", "90" );
cvar_extendmapStepMinutes = register_cvar( "amx_extendmap_step", "15" );
cvar_extendmapStepRounds = register_cvar( "amx_extendmap_step_rounds", "30" );
cvar_extendmapAllowStay = register_cvar( "amx_extendmap_allow_stay", "0" );
cvar_isExtendmapOrderAllowed = register_cvar( "amx_extendmap_allow_order", "0" );
cvar_extendmapAllowStayType = register_cvar( "amx_extendmap_allow_stay_type", "0" );
register_cvar( "gal_server_starting", "1", FCVAR_SPONLY );
register_cvar( "gal_version", PLUGIN_VERSION, FCVAR_SERVER | FCVAR_SPONLY );
#if DEBUG_LEVEL >= DEBUG_LEVEL_NORMAL
new debug_level[ 128 ];
formatex( debug_level, charsmax( debug_level ), "%d | %d", g_debug_level, DEBUG_LEVEL );
LOGGER( 1, "gal_debug_level: %s", debug_level );
register_cvar( "gal_debug_level", debug_level, FCVAR_SERVER | FCVAR_SPONLY );
#endif
cvar_disabledValuePointer = register_cvar( "gal_disabled_value_pointer", "0", FCVAR_SPONLY );
cvar_nextMapChangeAnnounce = register_cvar( "gal_nextmap_change", "1" );
cvar_isToShowVoteCounter = register_cvar( "gal_vote_show_counter", "0" );
cvar_isToShowNoneOption = register_cvar( "gal_vote_show_none", "0" );
cvar_voteShowNoneOptionType = register_cvar( "gal_vote_show_none_type", "0" );
cvar_coloredChatEnabled = register_cvar( "gal_colored_chat_enabled", "0", FCVAR_SPONLY );
cvar_isToStopEmptyCycle = register_cvar( "gal_in_empty_cycle", "0", FCVAR_SPONLY );
cvar_unnominateDisconnected = register_cvar( "gal_unnominate_disconnected", "0" );
cvar_endOnRound = register_cvar( "gal_endonround", "1" );
cvar_endOfMapVoteStart = register_cvar( "gal_endofmapvote_start", "0" );
cvar_endOnRoundRtv = register_cvar( "gal_endonround_rtv", "0" );
cvar_endOnRound_msg = register_cvar( "gal_endonround_msg", "0" );
cvar_voteWeight = register_cvar( "gal_vote_weight", "1" );
cvar_voteWeightFlags = register_cvar( "gal_vote_weightflags", "y" );
cvar_cmdVotemap = register_cvar( "gal_cmd_votemap", "0" );
cvar_cmdListmaps = register_cvar( "gal_cmd_listmaps", "2" );
cvar_listmapsPaginate = register_cvar( "gal_listmaps_paginate", "10" );
cvar_recentMapsBannedNumber = register_cvar( "gal_banrecent", "3" );
cvar_banRecentStyle = register_cvar( "gal_banrecentstyle", "1" );
cvar_endOfMapVote = register_cvar( "gal_endofmapvote", "1" );
cvar_isToAskForEndOfTheMapVote = register_cvar( "gal_endofmapvote_ask", "0" );
cvar_emptyWait = register_cvar( "gal_emptyserver_wait", "0" );
cvar_isEmptyCycleServerChange = register_cvar( "gal_emptyserver_change", "0" );
cvar_emptyMapFilePath = register_cvar( "gal_emptyserver_mapfile", "" );
cvar_serverStartAction = register_cvar( "gal_srv_start", "0" );
cvar_serverTimeLimitRestart = register_cvar( "gal_srv_timelimit_restart", "0" );
cvar_serverMaxroundsRestart = register_cvar( "gal_srv_maxrounds_restart", "0" );
cvar_serverWinlimitRestart = register_cvar( "gal_srv_winlimit_restart", "0" );
cvar_rtvCommands = register_cvar( "gal_rtv_commands", "3" );
cvar_rtvMinutesWait = register_cvar( "gal_rtv_wait", "10" );
cvar_rtvWaitRounds = register_cvar( "gal_rtv_wait_rounds", "5" );
cvar_rtvWaitAdmin = register_cvar( "gal_rtv_wait_admin", "0" );
cvar_rtvRatio = register_cvar( "gal_rtv_ratio", "0.60" );
cvar_rtvReminder = register_cvar( "gal_rtv_reminder", "2" );
cvar_nomPlayerAllowance = register_cvar( "gal_nom_playerallowance", "2" );
cvar_nomMapFilePath = register_cvar( "gal_nom_mapfile", "*" );
cvar_nomPrefixes = register_cvar( "gal_nom_prefixes", "1" );
cvar_nomQtyUsed = register_cvar( "gal_nom_qtyused", "0" );
cvar_voteDuration = register_cvar( "gal_vote_duration", "15" );
cvar_isToShowExpCountdown = register_cvar( "gal_vote_expirationcountdown", "1" );
cvar_isEndMapCountdown = register_cvar( "gal_endonround_countdown", "0" );
cvar_voteMapChoiceCount = register_cvar( "gal_vote_mapchoices", "5" );
cvar_voteAnnounceChoice = register_cvar( "gal_vote_announcechoice", "1" );
cvar_showVoteStatus = register_cvar( "gal_vote_showstatus", "1" );
cvar_isToReplaceByVoteMenu = register_cvar( "gal_vote_replace_menu", "0" );
cvar_showVoteStatusType = register_cvar( "gal_vote_showstatustype", "3" );
cvar_voteUniquePrefixes = register_cvar( "gal_vote_uniqueprefixes", "0" );
cvar_runoffEnabled = register_cvar( "gal_runoff_enabled", "0" );
cvar_runoffDuration = register_cvar( "gal_runoff_duration", "10" );
cvar_soundsMute = register_cvar( "gal_sounds_mute", "0" );
cvar_voteMapFilePath = register_cvar( "gal_vote_mapfile", "*" );
cvar_voteMinPlayers = register_cvar( "gal_vote_minplayers", "0" );
cvar_NomMinPlayersControl = register_cvar( "gal_nom_minplayers_control", "0" );
cvar_voteMinPlayersMapFilePath = register_cvar( "gal_vote_minplayers_mapfile", "" );
cvar_whitelistMinPlayers = register_cvar( "gal_whitelist_minplayers", "0" );
cvar_voteWhiteListMapFilePath = register_cvar( "gal_vote_whitelist_mapfile", "" );
nextmap_plugin_init();
configureEndGameCvars();
configureTheVotingMenus();
register_dictionary( "common.txt" );
register_dictionary_colored( "galileo.txt" );
register_logevent( "game_commencing_event", 2, "0=World triggered", "1=Game_Commencing" );
register_logevent( "team_win_event", 6, "0=Team" );
register_logevent( "round_restart_event", 2, "0=World triggered", "1&Restart_Round_" );
register_logevent( "round_start_event", 2, "1=Round_Start" );
register_logevent( "round_end_event", 2, "1=Round_End" );
register_clcmd( "say", "cmd_say", -1 );
register_clcmd( "say_team", "cmd_say", -1 );
register_clcmd( "votemap", "cmd_HL1_votemap" );
register_clcmd( "listmaps", "cmd_HL1_listmaps" );
register_concmd( "gal_startvote", "cmd_startVote", ADMIN_MAP );
register_concmd( "gal_cancelvote", "cmd_cancelVote", ADMIN_MAP );
register_concmd( "gal_createmapfile", "cmd_createMapFile", ADMIN_RCON );
LOGGER( 1, "I AM EXITING PLUGIN_INIT(0)..." );
LOGGER( 1, "" );
}
stock configureEndGameCvars()
{
LOGGER( 128, "I AM ENTERING ON configureEndGameCvars(0)" );
// mp_maxrounds
if( !( cvar_mp_maxrounds = get_cvar_pointer( "mp_maxrounds" ) ) )
{
cvar_mp_maxrounds = cvar_disabledValuePointer;
}
// mp_fraglimit
if( !( cvar_mp_fraglimit = get_cvar_pointer( "mp_fraglimit" ) ) )
{
cvar_mp_fraglimit = cvar_disabledValuePointer;
}
else
{
register_event( "DeathMsg", "client_death_event", "a" );
}
// mp_winlimit
if( !( cvar_mp_winlimit = get_cvar_pointer( "mp_winlimit" ) ) )
{
cvar_mp_winlimit = cvar_disabledValuePointer;
}
// mp_freezetime
if( !( cvar_mp_freezetime = get_cvar_pointer( "mp_freezetime" ) ) )
{
cvar_mp_freezetime = cvar_disabledValuePointer;
}
// mp_timelimit
if( !( cvar_mp_timelimit = get_cvar_pointer( "mp_timelimit" ) ) )
{
cvar_mp_timelimit = cvar_disabledValuePointer;
}
// mp_roundtime
if( !( cvar_mp_roundtime = get_cvar_pointer( "mp_roundtime" ) ) )
{
cvar_mp_roundtime = cvar_disabledValuePointer;
}
// mp_chattime
if( !( cvar_mp_chattime = get_cvar_pointer( "mp_chattime" ) ) )
{
cvar_mp_chattime = cvar_disabledValuePointer;
}
// sv_maxspeed
if( !( cvar_sv_maxspeed = get_cvar_pointer( "sv_maxspeed" ) ) )
{
cvar_sv_maxspeed = cvar_disabledValuePointer;
}
}
stock configureTheVotingMenus()
{
LOGGER( 128, "I AM ENTERING ON configureTheVotingMenus(0)" );
g_chooseMapMenuId = register_menuid( CHOOSE_MAP_MENU_NAME );
g_chooseMapQuestionMenuId = register_menuid( CHOOSE_MAP_MENU_QUESTION );
register_menucmd( g_chooseMapMenuId, MENU_KEY_1 | MENU_KEY_2 |
MENU_KEY_3 | MENU_KEY_4 | MENU_KEY_5 | MENU_KEY_6 |
MENU_KEY_7 | MENU_KEY_8 | MENU_KEY_9 | MENU_KEY_0,
"vote_handleChoice" );
register_menucmd( g_chooseMapQuestionMenuId, MENU_KEY_6 | MENU_KEY_0, "handleEndOfTheMapVoteChoice" );
}
/**
* Called when all plugins went through plugin_init(). When this forward is called, most plugins
* should have registered their cvars and commands already.
*/
public plugin_cfg()
{
LOGGER( 128, "I AM ENTERING ON plugin_cfg(0)" );
#if AMXX_VERSION_NUM < 183
// If some exception happened before this, all color_print(...) messages will cause native
// error 10, on the AMXX 182. It is because, the execution flow will not reach here, then
// the player "g_user_msgid" will be be initialized.
g_user_msgid = get_user_msgid( "SayText" );
#endif
resetRoundsScores();
loadPluginSetttings();
initializeGlobalArrays();
LOGGER( 4, "" );
LOGGER( 4, " The current map is [%s].", g_currentMap );
LOGGER( 4, " The next map is [%s]", g_nextMap );
LOGGER( 4, "" );
cacheCvarsValues();
configureRTV();
configureServerStart();
configureServerMapChange();
#if DEBUG_LEVEL & DEBUG_LEVEL_UNIT_TEST
configureTheUnitTests();
#endif
LOGGER( 1, "I AM EXITING PLUGIN_CFG(0)..." );
LOGGER( 1, "" );
}
stock loadPluginSetttings()
{
LOGGER( 128, "I AM ENTERING ON loadPluginSetttings(0)" );
new writtenSize;
g_isColorChatSupported = ( is_running( "czero" )
|| is_running( "cstrike" ) );
if( colored_menus() )
{
copy( COLOR_RED, 2, "\r" );
copy( COLOR_WHITE, 2, "\w" );
copy( COLOR_YELLOW, 2, "\y" );
copy( COLOR_GREY, 2, "\d" );
}
writtenSize = get_configsdir( g_configsDirPath, charsmax( g_configsDirPath ) );
copy( g_configsDirPath[ writtenSize ], charsmax( g_configsDirPath ) - writtenSize, "/galileo" );
writtenSize = get_datadir( g_dataDirPath, charsmax( g_dataDirPath ) );
copy( g_dataDirPath[ writtenSize ], charsmax( g_dataDirPath ) - writtenSize, "/galileo" );
if( !dir_exists( g_dataDirPath )
&& mkdir( g_dataDirPath ) )
{
LOGGER( 1, "AMX_ERR_NOTFOUND, %L", LANG_SERVER, "GAL_CREATIONFAILED", g_dataDirPath );
log_error( AMX_ERR_NOTFOUND, "%L", LANG_SERVER, "GAL_CREATIONFAILED", g_dataDirPath );
}
LOGGER( 1, "( loadPluginSetttings ) g_configsDirPath: %s, g_dataDirPath: %s,", \
g_configsDirPath, g_dataDirPath );
server_cmd( "exec %s/galileo.cfg", g_configsDirPath );
server_exec();
}
stock initializeGlobalArrays()
{
LOGGER( 128, "I AM ENTERING ON initializeGlobalArrays(0)" );
get_pcvar_string( cvar_voteWeightFlags, g_voteWeightFlags, charsmax( g_voteWeightFlags ) );
get_cvar_string( "amx_nextmap", g_nextMap, charsmax( g_nextMap ) );
get_mapname( g_currentMap, charsmax( g_currentMap ) );
g_nominationMapsTrie = TrieCreate();
g_playersNominations = TrieCreate();
g_fillerMaps = ArrayCreate( MAX_MAPNAME_LENGHT );
g_nominationMapsArray = ArrayCreate( MAX_MAPNAME_LENGHT );
// initialize nominations table
nomination_clearAll();
if( get_pcvar_num( cvar_recentMapsBannedNumber ) )
{
register_clcmd( "say recentmaps", "cmd_listrecent", 0 );
map_loadRecentList();
if( !( get_cvar_num( "gal_server_starting" )
&& get_pcvar_num( cvar_serverStartAction ) ) )
{
map_writeRecentList();
}
}
}
stock cacheCvarsValues()
{
LOGGER( 128, "I AM ENTERING ON cacheCvarsValues(0)" );
g_rtvCommands = get_pcvar_num( cvar_rtvCommands );
g_extendmapStepRounds = get_pcvar_num( cvar_extendmapStepRounds );
g_extendmapStepMinutes = get_pcvar_num( cvar_extendmapStepMinutes );
g_extendmapAllowStayType = get_pcvar_num( cvar_extendmapAllowStayType );
g_showVoteStatus = get_pcvar_num( cvar_showVoteStatus );
g_voteShowNoneOptionType = get_pcvar_num( cvar_voteShowNoneOptionType );
g_showVoteStatusType = get_pcvar_num( cvar_showVoteStatusType );
g_isColoredChatEnabled = get_pcvar_num( cvar_coloredChatEnabled ) != 0;
g_isExtendmapAllowStay = get_pcvar_num( cvar_extendmapAllowStay ) != 0;
g_isToShowNoneOption = get_pcvar_num( cvar_isToShowNoneOption ) != 0;
g_isToShowVoteCounter = get_pcvar_num( cvar_isToShowVoteCounter ) != 0;
g_isToShowExpCountdown = get_pcvar_num( cvar_isToShowExpCountdown ) != 0;
g_maxVotingChoices = max( min( MAX_OPTIONS_IN_VOTE, get_pcvar_num( cvar_voteMapChoiceCount ) ), 2 );
}
stock configureRTV()
{
LOGGER( 128, "I AM ENTERING ON configureRTV(0)" );
g_rtvMinutesWait = get_pcvar_float( cvar_rtvMinutesWait );
g_rtvWaitRounds = get_pcvar_num( cvar_rtvWaitRounds );
if( g_rtvCommands & RTV_CMD_STANDARD )
{
register_clcmd( "say rockthevote", "cmd_rockthevote", 0 );
}
if( get_pcvar_num( cvar_nomPlayerAllowance ) )
{
register_concmd( "gal_listmaps", "map_listAll" );
register_clcmd( "say nominations", "cmd_nominations", 0, "- displays current nominations for next map" );
if( get_pcvar_num( cvar_nomPrefixes ) )
{
map_loadPrefixList();
}
map_loadNominationList();
}
}