77#endif
88
99# define PLUGIN " Map Manager: Core"
10- # define VERSION " 3.0.0-Beta-3 "
10+ # define VERSION " 3.0.0-Beta-4 "
1111# define AUTHOR " Mistrick"
1212
1313#pragma semicolon 1
@@ -67,7 +67,6 @@ new g_iVoted[33];
6767new g_hForwards[Forwards];
6868
6969new Array: g_aMapsList;
70- new g_iMapsListSize;
7170
7271new g_iShowType;
7372new g_bShowSelects;
@@ -115,6 +114,7 @@ public plugin_natives()
115114{
116115 register_library (" map_manager_core" );
117116
117+ register_native (" mapm_load_maplist" , " native_load_maplist" );
118118 register_native (" mapm_get_map_index" , " native_get_map_index" );
119119 register_native (" mapm_get_prefix" , " native_get_prefix" );
120120 register_native (" mapm_set_vote_finished" , " native_set_vote_finished" );
@@ -128,6 +128,21 @@ public plugin_natives()
128128 register_native (" is_vote_started" , " native_is_vote_started" );
129129 register_native (" is_vote_finished" , " native_is_vote_finished" );
130130}
131+ public native_load_maplist (plugin, params)
132+ {
133+ enum {
134+ arg_filename = 1 ,
135+ arg_clearlist
136+ };
137+
138+ if (get_param (arg_clearlist)) {
139+ ArrayClear (g_aMapsList);
140+ }
141+
142+ new filename[256 ];
143+ get_string (arg_filename, filename, charsmax (filename));
144+ load_maplist (filename);
145+ }
131146public native_get_map_index (plugin, params)
132147{
133148 enum { arg_map = 1 };
@@ -173,7 +188,7 @@ public native_push_map_to_votelist(plugin, params)
173188 arg_ignore_check
174189 };
175190
176- if (g_iVoteItems >= min (VOTELIST_SIZE, g_iMapsListSize )) {
191+ if (g_iVoteItems >= min (VOTELIST_SIZE, ArraySize (g_aMapsList) )) {
177192 return PUSH_CANCELED;
178193 }
179194
@@ -246,7 +261,7 @@ public plugin_cfg()
246261}
247262load_maplist (const file[])
248263{
249- new file_path[128 ]; get_localinfo (" amxx_configsdir" , file_path, charsmax (file_path));
264+ new file_path[256 ]; get_localinfo (" amxx_configsdir" , file_path, charsmax (file_path));
250265 format (file_path, charsmax (file_path), " %s /%s " , file_path, file);
251266
252267 if (! file_exists (file_path)) {
@@ -287,11 +302,10 @@ load_maplist(const file[])
287302
288303 ArrayPushArray (g_aMapsList, map_info);
289304 min = " " ; max = " " ;
290- g_iMapsListSize++ ;
291305 }
292306 fclose (f);
293307
294- if (g_iMapsListSize == 0 ) {
308+ if (! ArraySize (g_aMapsList) ) {
295309 new error[192 ]; formatex (error, charsmax (error), " Nothing loaded from ^" % s^ " ." , file_path);
296310 set_fail_state (error);
297311 }
@@ -324,7 +338,8 @@ prepare_vote(type)
324338 arrayset (g_iVoted, NOT_VOTED, sizeof (g_iVoted));
325339 arrayset (g_iVotes, 0 , sizeof (g_iVotes));
326340
327- new vote_max_items = min (VOTELIST_SIZE, g_iMapsListSize);
341+ new array_size = ArraySize (g_aMapsList);
342+ new vote_max_items = min (VOTELIST_SIZE, array_size);
328343
329344 new ret;
330345 ExecuteForward (g_hForwards[PREPARE_VOTELIST], ret, type);
@@ -334,26 +349,18 @@ prepare_vote(type)
334349 g_iMaxItems = 0 ;
335350 }
336351
337- // TODO : add min/max sort
338352 if (g_iVoteItems < vote_max_items) {
339353 new map_info[MapStruct];
340354 for (new random_map; g_iVoteItems < vote_max_items; g_iVoteItems++ ) {
341355 do {
342- random_map = random (g_iMapsListSize );
356+ random_map = random (array_size );
343357 ArrayGetArray (g_aMapsList, random_map, map_info);
344358 } while (is_map_in_vote (map_info[MapName]) || ! is_map_allowed (map_info[MapName], PUSH_BY_CORE, random_map));
345359
346360 copy (g_sVoteList[g_iVoteItems], charsmax (g_sVoteList[]), map_info[MapName]);
347361 }
348362 }
349363
350- /* server_print("Votelist:");
351- for(new i; i < g_iVoteItems; i++) {
352- if(g_sVoteList[i][0]) {
353- server_print("%d - %s", i + 1, g_sVoteList[i]);
354- }
355- } */
356-
357364 ExecuteForward (g_hForwards[CAN_BE_EXTENDED], ret, type);
358365 g_bCanExtend = ! ret;
359366
@@ -374,7 +381,6 @@ prepare_vote(type)
374381 for (new i; i < g_iVoteItems + g_bCanExtend; i++ ) {
375382 do {
376383 g_iRandomNums[i] = random (g_iVoteItems + g_bCanExtend);
377- // g_iRandomNums[i] = random_num(0, 9);
378384 } while (in_array (i, g_iRandomNums[i]));
379385 }
380386 } else {
@@ -581,7 +587,7 @@ stop_vote()
581587// -----------------------------------------------------//
582588get_map_index (map[])
583589{
584- for (new i = 0 , map_info[MapStruct]; i < g_iMapsListSize ; i++ ) {
590+ for (new i = 0 , map_info[MapStruct], size = ArraySize (g_aMapsList) ; i < size ; i++ ) {
585591 ArrayGetArray (g_aMapsList, i, map_info);
586592 if (equali (map, map_info[MapName])) return i;
587593 }
0 commit comments