Skip to content

Commit 7dff7fb

Browse files
committed
core: rework for native mapm_load_maplist_to_array
1 parent 4f07e87 commit 7dff7fb

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

addons/amxmodx/scripting/include/map_manager.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ native mapm_load_maplist(filename[], clearlist = true);
3333
* @param array Array with item size MapStruct.
3434
* @param filename File name
3535
*
36-
* @noreturn
36+
* @return 1 if success load, 0 otherwise
3737
*/
3838
native mapm_load_maplist_to_array(Array:array, filename[]);
3939

addons/amxmodx/scripting/map_manager_core.sma

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ public native_load_maplist_to_array(plugin, params)
158158
new filename[256];
159159
get_string(arg_filename, filename, charsmax(filename));
160160

161-
load_maplist(Array:get_param(arg_array), filename, false);
161+
return load_maplist(Array:get_param(arg_array), filename, true);
162162
}
163163
public native_get_map_index(plugin, params)
164164
{
@@ -288,7 +288,7 @@ load_maplist(Array:array, const file[], bool:silent = false)
288288
new error[192]; formatex(error, charsmax(error), "File doesn't exist ^"%s^".", file_path);
289289
set_fail_state(error);
290290
}
291-
return;
291+
return 0;
292292
}
293293

294294
new f = fopen(file_path, "rt");
@@ -297,7 +297,7 @@ load_maplist(Array:array, const file[], bool:silent = false)
297297
if(!silent) {
298298
set_fail_state("Can't read maps file.");
299299
}
300-
return;
300+
return 0;
301301
}
302302

303303
new map_info[MapStruct], text[48], map[MAPNAME_LENGTH], first_map[MAPNAME_LENGTH], min[3], max[3], bool:nextmap, bool:found_nextmap;
@@ -330,9 +330,12 @@ load_maplist(Array:array, const file[], bool:silent = false)
330330
}
331331
fclose(f);
332332

333-
if(!ArraySize(array) && !silent) {
334-
new error[192]; formatex(error, charsmax(error), "Nothing loaded from ^"%s^".", file_path);
335-
set_fail_state(error);
333+
if(!ArraySize(array)) {
334+
if(!silent) {
335+
new error[192]; formatex(error, charsmax(error), "Nothing loaded from ^"%s^".", file_path);
336+
set_fail_state(error);
337+
}
338+
return 0;
336339
}
337340

338341
if(!silent) {
@@ -342,6 +345,8 @@ load_maplist(Array:array, const file[], bool:silent = false)
342345
new ret;
343346
ExecuteForward(g_hForwards[MAPLIST_LOADED], ret, array);
344347
}
348+
349+
return 1;
345350
}
346351
//-----------------------------------------------------//
347352
// Vote stuff

0 commit comments

Comments
 (0)