From 966e008c0a9e71b35859a83007bc3f21add92642 Mon Sep 17 00:00:00 2001 From: Neloreck Date: Mon, 17 Jul 2023 05:00:41 +0300 Subject: [PATCH 1/3] Adding ini_file luabind override. --- src/xrServerEntities/script_ini_file.cpp | 10 +++++++--- src/xrServerEntities/script_ini_file.h | 3 ++- src/xrServerEntities/script_ini_file_script.cpp | 1 + 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/xrServerEntities/script_ini_file.cpp b/src/xrServerEntities/script_ini_file.cpp index 29727bebe2a..72c759aa387 100644 --- a/src/xrServerEntities/script_ini_file.cpp +++ b/src/xrServerEntities/script_ini_file.cpp @@ -15,13 +15,17 @@ CScriptIniFile::CScriptIniFile(IReader* F, LPCSTR path) : inherited(F, path) {} CScriptIniFile::CScriptIniFile(LPCSTR szFileName, BOOL ReadOnly, BOOL bLoadAtStart, BOOL SaveAtEnd) - : inherited(update(szFileName), ReadOnly, bLoadAtStart, SaveAtEnd) + : inherited(update("$game_config$", szFileName), ReadOnly, bLoadAtStart, SaveAtEnd) {} +CScriptIniFile::CScriptIniFile(LPCSTR initial, LPCSTR szFileName, BOOL ReadOnly, BOOL bLoadAtStart, BOOL SaveAtEnd) + : inherited(update(initial, szFileName), ReadOnly, bLoadAtStart, SaveAtEnd) +{ +} -LPCSTR CScriptIniFile::update(LPCSTR file_name) +LPCSTR CScriptIniFile::update(LPCSTR initial, LPCSTR file_name) { string_path S1; - FS.update_path(S1, "$game_config$", file_name); + FS.update_path(S1, initial, file_name); return *shared_str(S1); } diff --git a/src/xrServerEntities/script_ini_file.h b/src/xrServerEntities/script_ini_file.h index 93ba5cfd262..94d0c183cb9 100644 --- a/src/xrServerEntities/script_ini_file.h +++ b/src/xrServerEntities/script_ini_file.h @@ -18,10 +18,11 @@ class CScriptIniFile : public CInifile public: CScriptIniFile(IReader* F, LPCSTR path = nullptr); CScriptIniFile(LPCSTR szFileName, BOOL ReadOnly = TRUE, BOOL bLoadAtStart = TRUE, BOOL SaveAtEnd = TRUE); + CScriptIniFile(LPCSTR initial, LPCSTR szFileName, BOOL ReadOnly = TRUE, BOOL bLoadAtStart = TRUE, BOOL SaveAtEnd = TRUE); int r_clsid(LPCSTR S, LPCSTR L); int r_token(LPCSTR S, LPCSTR L, const CScriptTokenList& token_list); - LPCSTR update(LPCSTR file_name); + LPCSTR update(LPCSTR initial, LPCSTR file_name); u32 line_count(LPCSTR S); LPCSTR r_string(LPCSTR S, LPCSTR L); u32 r_u32(LPCSTR S, LPCSTR L); diff --git a/src/xrServerEntities/script_ini_file_script.cpp b/src/xrServerEntities/script_ini_file_script.cpp index 941fe6a23c9..3af373bd30e 100644 --- a/src/xrServerEntities/script_ini_file_script.cpp +++ b/src/xrServerEntities/script_ini_file_script.cpp @@ -80,6 +80,7 @@ static void CScriptIniFile_Export(lua_State* luaState) [ class_("ini_file") .def(constructor()) + .def(constructor()) //Alundaio: Extend script ini file .def("w_bool", &CScriptIniFile::w_bool) .def("w_color", &CScriptIniFile::w_color) From 06fa7d03cdc06381f8173852f92c4467b9639dda Mon Sep 17 00:00:00 2001 From: Neloreck Date: Sun, 23 Jul 2023 21:28:30 +0300 Subject: [PATCH 2/3] Add anomaly matching CScriptIniFile constructor signature. --- src/xrServerEntities/script_ini_file.cpp | 4 ++-- src/xrServerEntities/script_ini_file.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/xrServerEntities/script_ini_file.cpp b/src/xrServerEntities/script_ini_file.cpp index 72c759aa387..faacc0c3d22 100644 --- a/src/xrServerEntities/script_ini_file.cpp +++ b/src/xrServerEntities/script_ini_file.cpp @@ -14,8 +14,8 @@ #include "xrCore/xrDebug.h" CScriptIniFile::CScriptIniFile(IReader* F, LPCSTR path) : inherited(F, path) {} -CScriptIniFile::CScriptIniFile(LPCSTR szFileName, BOOL ReadOnly, BOOL bLoadAtStart, BOOL SaveAtEnd) - : inherited(update("$game_config$", szFileName), ReadOnly, bLoadAtStart, SaveAtEnd) +CScriptIniFile::CScriptIniFile(LPCSTR szFileName, BOOL ReadOnly, BOOL bLoadAtStart, BOOL SaveAtEnd, LPCSTR path) + : inherited(path ? path : update("$game_config$", szFileName), ReadOnly, bLoadAtStart, SaveAtEnd) {} CScriptIniFile::CScriptIniFile(LPCSTR initial, LPCSTR szFileName, BOOL ReadOnly, BOOL bLoadAtStart, BOOL SaveAtEnd) : inherited(update(initial, szFileName), ReadOnly, bLoadAtStart, SaveAtEnd) diff --git a/src/xrServerEntities/script_ini_file.h b/src/xrServerEntities/script_ini_file.h index 94d0c183cb9..3c5384f30df 100644 --- a/src/xrServerEntities/script_ini_file.h +++ b/src/xrServerEntities/script_ini_file.h @@ -17,7 +17,7 @@ class CScriptIniFile : public CInifile public: CScriptIniFile(IReader* F, LPCSTR path = nullptr); - CScriptIniFile(LPCSTR szFileName, BOOL ReadOnly = TRUE, BOOL bLoadAtStart = TRUE, BOOL SaveAtEnd = TRUE); + CScriptIniFile(LPCSTR szFileName, BOOL ReadOnly = TRUE, BOOL bLoadAtStart = TRUE, BOOL SaveAtEnd = TRUE, LPCSTR path = NULL); CScriptIniFile(LPCSTR initial, LPCSTR szFileName, BOOL ReadOnly = TRUE, BOOL bLoadAtStart = TRUE, BOOL SaveAtEnd = TRUE); int r_clsid(LPCSTR S, LPCSTR L); From 6cc5e5785438346eeb96074c61e0f5b7190ec895 Mon Sep 17 00:00:00 2001 From: Xottab_DUTY Date: Wed, 18 Oct 2023 16:17:06 +0500 Subject: [PATCH 3/3] Apply suggestions from code review --- src/xrServerEntities/script_ini_file.cpp | 9 +++------ src/xrServerEntities/script_ini_file.h | 2 +- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/xrServerEntities/script_ini_file.cpp b/src/xrServerEntities/script_ini_file.cpp index faacc0c3d22..4b876d50bb9 100644 --- a/src/xrServerEntities/script_ini_file.cpp +++ b/src/xrServerEntities/script_ini_file.cpp @@ -14,13 +14,10 @@ #include "xrCore/xrDebug.h" CScriptIniFile::CScriptIniFile(IReader* F, LPCSTR path) : inherited(F, path) {} -CScriptIniFile::CScriptIniFile(LPCSTR szFileName, BOOL ReadOnly, BOOL bLoadAtStart, BOOL SaveAtEnd, LPCSTR path) - : inherited(path ? path : update("$game_config$", szFileName), ReadOnly, bLoadAtStart, SaveAtEnd) -{} +CScriptIniFile::CScriptIniFile(LPCSTR szFileName, BOOL ReadOnly, BOOL bLoadAtStart, BOOL SaveAtEnd) + : inherited(update("$game_config$", szFileName), ReadOnly, bLoadAtStart, SaveAtEnd) {} CScriptIniFile::CScriptIniFile(LPCSTR initial, LPCSTR szFileName, BOOL ReadOnly, BOOL bLoadAtStart, BOOL SaveAtEnd) - : inherited(update(initial, szFileName), ReadOnly, bLoadAtStart, SaveAtEnd) -{ -} + : inherited(update(initial, szFileName), ReadOnly, bLoadAtStart, SaveAtEnd) {} LPCSTR CScriptIniFile::update(LPCSTR initial, LPCSTR file_name) { diff --git a/src/xrServerEntities/script_ini_file.h b/src/xrServerEntities/script_ini_file.h index 3c5384f30df..94d0c183cb9 100644 --- a/src/xrServerEntities/script_ini_file.h +++ b/src/xrServerEntities/script_ini_file.h @@ -17,7 +17,7 @@ class CScriptIniFile : public CInifile public: CScriptIniFile(IReader* F, LPCSTR path = nullptr); - CScriptIniFile(LPCSTR szFileName, BOOL ReadOnly = TRUE, BOOL bLoadAtStart = TRUE, BOOL SaveAtEnd = TRUE, LPCSTR path = NULL); + CScriptIniFile(LPCSTR szFileName, BOOL ReadOnly = TRUE, BOOL bLoadAtStart = TRUE, BOOL SaveAtEnd = TRUE); CScriptIniFile(LPCSTR initial, LPCSTR szFileName, BOOL ReadOnly = TRUE, BOOL bLoadAtStart = TRUE, BOOL SaveAtEnd = TRUE); int r_clsid(LPCSTR S, LPCSTR L);