Skip to content

Commit 0b54a03

Browse files
committed
core: fix nextmap detection
update include description added load config
1 parent 4bf32ed commit 0b54a03

3 files changed

Lines changed: 96 additions & 38 deletions

File tree

include/map_manager.inc

Lines changed: 79 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -16,135 +16,183 @@
1616
#include <map_manager_stocks>
1717

1818
/**
19-
* TODO: write this.
20-
*
21-
* @return Map index
19+
* Get map index in mapslist array.
20+
*
21+
* @param map Map name
22+
*
23+
* @return Map index or INVALID_MAP_INDEX if map not exist in mapslist
2224
*/
2325
native mapm_get_map_index(map[]);
2426

2527
/**
26-
* TODO: write this.
28+
* Get prefix const from core.
2729
*
30+
* @param prefix Prefix string
31+
* @param len String lenght
32+
*
2833
* @noreturn
2934
*/
3035
native mapm_get_prefix(prefix[], len);
3136

3237
/**
33-
* TODO: write this.
38+
* Start vote.
3439
*
40+
* @param type Vote type, use const VOTE_BY_*
41+
*
3542
* @noreturn
3643
*/
3744
native mapm_start_vote(type);
3845

3946
/**
40-
* TODO: write this.
47+
* Stop vote.
4148
*
4249
* @noreturn
4350
*/
4451
native mapm_stop_vote();
4552

4653
/**
47-
* TODO: write this.
54+
* Get votelist size const from core.
4855
*
4956
* @return Votelist size
5057
*/
5158
native mapm_get_votelist_size();
5259

5360
/**
54-
* TODO: write this.
61+
* Set max items in vote.
62+
*
63+
* @param value Amount items in vote
5564
*
5665
* @noreturn
5766
*/
5867
native mapm_set_votelist_max_items(value);
5968

6069
/**
61-
* TODO: write this.
70+
* Push map in votelist.
71+
*
72+
* @note Use native in forward mapm_prepare_votelist().
73+
*
74+
* @param map Map name
75+
* @param type Type for addons
76+
* @param ignore_check Allow ignore some checks, bit sum, use const CHECK_*
6277
*
63-
* @noreturn
78+
* @return Result of pushing, const PUSH_*
6479
*/
6580
native mapm_push_map_to_votelist(map[], type = PUSH_BY_NATIVE, ignore_check = CHECK_NOT_IGNORED);
6681

6782
/**
68-
* TODO: write this.
69-
* Use in mapm_analysis_of_results()
83+
* Get amount maps in votelist.
84+
*
85+
* @note Use in mapm_analysis_of_results()
7086
*
7187
* @noreturn
7288
*/
7389
native mapm_get_count_maps_in_vote();
7490

7591
/**
76-
* TODO: write this.
77-
* Use in mapm_analysis_of_results()
92+
* Get info about votelist item.
93+
*
94+
* @note Use in mapm_analysis_of_results()
95+
*
96+
* @param item Index in votelist
97+
* @param map Map name
98+
* @param len Map name string lenght
7899
*
79-
* @return Votes
100+
* @return Votes
80101
*/
81102
native mapm_get_voteitem_info(item, map[], len);
82103

83104
/**
84-
* TODO: write this.
105+
* Returns if vote started.
85106
*
86-
* @return true/false
107+
* @return true/false
87108
*/
88109
native bool:is_vote_started();
89110

90111
/**
91-
* TODO: write this.
112+
* Returns if vote finished.
92113
*
93-
* @return true/false
114+
* @return true/false
94115
*/
95116
native bool:is_vote_finished();
96117

97118
/**
98-
* TODO: write this.
119+
* Called after load maps from file.
99120
*
121+
* @param maplist Array with loaded maps
122+
*
100123
* @noreturn
101124
*/
102125
forward mapm_maplist_loaded(Array:maplist);
103126

104127
/**
105-
* TODO: write this.
128+
* Called every second before vote or in vote.
129+
*
130+
* @param type Type of countdown, used const COUNTDOWN_*
131+
* @param time Current second of countdown
106132
*
107133
* @noreturn
108134
*/
109135
forward mapm_countdown(type, time);
110136

111137
/**
112-
* TODO: write this.
138+
* Called before vote.
139+
*
140+
* @param type Type of vote, used const VOTE_BY_*
113141
*
114142
* @noreturn
115143
*/
116144
forward mapm_prepare_votelist(type);
117145

118146
/**
119-
* TODO: write this.
147+
* Called when core or addons are trying add map in votelist.
148+
*
149+
* @param map Map name
150+
* @param type Type of vote, used const VOTE_BY_*
151+
* @param index Index in mapslist array
120152
*
121-
* @noreturn
153+
* @return MAP_ALLOWED
154+
* MAP_BLOCKED
122155
*/
123156
forward mapm_can_be_in_votelist(map[], type, index);
124157

125158
/**
126-
* TODO: write this.
127-
*
128-
* @noreturn
159+
* Called for permission to extend current map.
160+
*
161+
* @param type Type of vote, used const VOTE_BY_*
162+
*
163+
* @return EXTEND_ALLOWED to allow extend current map
164+
* EXTEND_BLOCKED to block extend current map
129165
*/
130166
forward mapm_can_be_extended(type);
131167

132168
/**
133-
* TODO: write this.
169+
* Called when core start show menu with vote.
170+
*
171+
* @param type Type of vote, used const VOTE_BY_*
134172
*
135173
* @noreturn
136174
*/
137175
forward mapm_vote_started(type);
138176

139177
/**
140-
* TODO: write this.
178+
* Called before vote finish.
179+
*
180+
* @param type Type of vote, used const VOTE_BY_*
181+
* @param total_votes Type of vote, used const VOTE_BY_*
141182
*
142-
* @noreturn
183+
* @return ALLOW_VOTE to allow finish vote
184+
* ABORT_VOTE to block finish vote, forward mapm_vote_finished() will not be called
143185
*/
144186
forward mapm_analysis_of_results(type, total_votes);
145187

146188
/**
147-
* TODO: write this.
189+
* Called when vote finished.
190+
*
191+
* @note Can be blocked in forward mapm_analysis_of_results()
192+
*
193+
* @param map Type of vote, used const VOTE_BY_*
194+
* @param type Type of vote, used const VOTE_BY_*
195+
* @param total_votes Type of vote, used const VOTE_BY_*
148196
*
149197
* @noreturn
150198
*/

include/map_manager_consts.inc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ enum {
5252
ABORT_VOTE
5353
};
5454

55+
enum {
56+
EXTEND_MINUTES,
57+
EXTEND_ROUNDS
58+
};
59+
5560
enum {
5661
EXTEND_ALLOWED,
5762
EXTEND_BLOCKED

map_manager_core.sma

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
/*
2-
Core functions:
3-
- load maplist
4-
- start vote by time ? or do with addon
5-
- start/stop vote
6-
*/
71
#include <amxmodx>
82
#include <map_manager_consts>
93
#include <map_manager_stocks>
@@ -232,6 +226,9 @@ public plugin_cfg()
232226
{
233227
g_aMapsList = ArrayCreate(MapStruct, 1);
234228

229+
new configsdir[256]; get_localinfo("amxx_configsdir", configsdir, charsmax(configsdir));
230+
server_cmd("exec %s/map_manager.cfg", configsdir);
231+
235232
// add forward for change file?
236233
load_maplist(FILE_MAPS);
237234
}
@@ -250,7 +247,7 @@ load_maplist(const file[])
250247
set_fail_state("Can't read maps file.");
251248
}
252249

253-
new map_info[MapStruct], text[48], map[MAPNAME_LENGTH], min[3], max[3], bool:nextmap;
250+
new map_info[MapStruct], text[48], map[MAPNAME_LENGTH], first_map[MAPNAME_LENGTH], min[3], max[3], bool:nextmap, bool:found_nextmap;
254251
new cur_map[MAPNAME_LENGTH]; get_mapname(cur_map, charsmax(cur_map));
255252

256253
while(!feof(f)) {
@@ -259,12 +256,16 @@ load_maplist(const file[])
259256

260257
if(!map[0] || map[0] == ';' || !valid_map(map) || get_map_index(map) != INVALID_MAP_INDEX) continue;
261258

259+
if(!first_map[0]) {
260+
copy(first_map, charsmax(first_map), map);
261+
}
262262
if(equali(map, cur_map)) {
263263
nextmap = true;
264264
continue;
265265
}
266266
if(nextmap) {
267267
nextmap = false;
268+
found_nextmap = true;
268269
set_cvar_string("amx_nextmap", map);
269270
}
270271

@@ -283,6 +284,10 @@ load_maplist(const file[])
283284
set_fail_state(error);
284285
}
285286

287+
if(!found_nextmap) {
288+
set_cvar_string("amx_nextmap", first_map);
289+
}
290+
286291
new ret;
287292
ExecuteForward(g_hForwards[MAPLIST_LOADED], ret, g_aMapsList);
288293
}

0 commit comments

Comments
 (0)