From 717be50daf6e3a14f439ea5286b498739e6c5b32 Mon Sep 17 00:00:00 2001 From: Nord1cWarr1or Date: Sun, 31 Aug 2025 14:52:17 +0300 Subject: [PATCH 1/2] storage: add automatic creation of directories for box coordinate files --- addons/amxmodx/scripting/box_storage.sma | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/addons/amxmodx/scripting/box_storage.sma b/addons/amxmodx/scripting/box_storage.sma index 5c09c03..7d59476 100644 --- a/addons/amxmodx/scripting/box_storage.sma +++ b/addons/amxmodx/scripting/box_storage.sma @@ -120,17 +120,32 @@ public plugin_end() } save_boxes() { - new configsdir[256]; - get_configsdir(configsdir, charsmax(configsdir)); + new filepath[256]; + get_configsdir(filepath, charsmax(filepath)); + + add(filepath, charsmax(filepath), "/box_with_boxes"); + + if (!dir_exists(filepath)) { + mkdir(filepath); + } + + add(filepath, charsmax(filepath), "/maps"); + + if (!dir_exists(filepath)) { + mkdir(filepath); + } + new map[32]; get_mapname(map, charsmax(map)); + add(filepath, charsmax(filepath), fmt("/%s.ini", map)); + new f; new ent = -1; while((ent = find_ent_by_class(ent, BOX_CLASSNAME))) { if(!f) { - f = fopen(fmt("%s/box_with_boxes/maps/%s.ini", configsdir, map), "w"); + f = fopen(filepath, "w"); if(!f) { // TODO: warn? return; From 6f2352d1fd3f9960fc711ccc914b5472c0d4d5dd Mon Sep 17 00:00:00 2001 From: Nord1cWarr1or Date: Sun, 31 Aug 2025 14:56:36 +0300 Subject: [PATCH 2/2] storage: add logging for box coordinates file creation/open failure --- addons/amxmodx/scripting/box_storage.sma | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/amxmodx/scripting/box_storage.sma b/addons/amxmodx/scripting/box_storage.sma index 7d59476..36be075 100644 --- a/addons/amxmodx/scripting/box_storage.sma +++ b/addons/amxmodx/scripting/box_storage.sma @@ -147,7 +147,7 @@ save_boxes() if(!f) { f = fopen(filepath, "w"); if(!f) { - // TODO: warn? + log_amx("Error creating/opening coordinates file <%s>", filepath); return; } }