Skip to content

Commit

Permalink
core: rework for native mapm_load_maplist_to_array
Browse files Browse the repository at this point in the history
  • Loading branch information
Mistrick committed May 15, 2018
1 parent 4f07e87 commit 7dff7fb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion addons/amxmodx/scripting/include/map_manager.inc
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ native mapm_load_maplist(filename[], clearlist = true);
* @param array Array with item size MapStruct.
* @param filename File name
*
* @noreturn
* @return 1 if success load, 0 otherwise
*/
native mapm_load_maplist_to_array(Array:array, filename[]);

Expand Down
17 changes: 11 additions & 6 deletions addons/amxmodx/scripting/map_manager_core.sma
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public native_load_maplist_to_array(plugin, params)
new filename[256];
get_string(arg_filename, filename, charsmax(filename));

load_maplist(Array:get_param(arg_array), filename, false);
return load_maplist(Array:get_param(arg_array), filename, true);
}
public native_get_map_index(plugin, params)
{
Expand Down Expand Up @@ -288,7 +288,7 @@ load_maplist(Array:array, const file[], bool:silent = false)
new error[192]; formatex(error, charsmax(error), "File doesn't exist ^"%s^".", file_path);
set_fail_state(error);
}
return;
return 0;
}

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

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

if(!ArraySize(array) && !silent) {
new error[192]; formatex(error, charsmax(error), "Nothing loaded from ^"%s^".", file_path);
set_fail_state(error);
if(!ArraySize(array)) {
if(!silent) {
new error[192]; formatex(error, charsmax(error), "Nothing loaded from ^"%s^".", file_path);
set_fail_state(error);
}
return 0;
}

if(!silent) {
Expand All @@ -342,6 +345,8 @@ load_maplist(Array:array, const file[], bool:silent = false)
new ret;
ExecuteForward(g_hForwards[MAPLIST_LOADED], ret, array);
}

return 1;
}
//-----------------------------------------------------//
// Vote stuff
Expand Down

0 comments on commit 7dff7fb

Please sign in to comment.