Skip to content

Commit 65a2dc8

Browse files
authored
Merge branch 'master' into commandhandler-controlling
2 parents 457cbfd + 4d4d6c9 commit 65a2dc8

File tree

9 files changed

+110
-86
lines changed

9 files changed

+110
-86
lines changed

Client/mods/deathmatch/logic/CMapEventManager.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ bool CMapEventManager::Call(const char* szName, const CLuaArguments& Arguments,
222222
lua_pushresource(pState, pSourceResource);
223223
lua_setglobal(pState, "sourceResource");
224224

225-
lua_pushelement(pState, pSourceResource->GetResourceDynamicEntity());
225+
lua_pushelement(pState, pSourceResource->GetResourceEntity());
226226
lua_setglobal(pState, "sourceResourceRoot");
227227
}
228228
else
@@ -400,4 +400,4 @@ void CMapEventManager::GetHandles(CLuaMain* pLuaMain, const char* szName, lua_St
400400
}
401401
}
402402
}
403-
}
403+
}

Server/mods/deathmatch/logic/CMainConfig.cpp

Lines changed: 43 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#include "CHTTPD.h"
2323
#include "CStaticFunctionDefinitions.h"
2424

25-
#define MTA_SERVER_CONF_TEMPLATE "mtaserver.conf.template"
25+
#define SETTINGS_TEMPLATE_PATH "mtaserver.conf.template"
2626

2727
extern CGame* g_pGame;
2828

@@ -867,91 +867,90 @@ bool CMainConfig::AddMissingSettings()
867867
if (!g_pGame->IsUsingMtaServerConf())
868868
return false;
869869

870-
const SString templateFileName = PathJoin(g_pServerInterface->GetServerModPath(), "mtaserver.conf.template");
871-
870+
const std::string templateFileName = PathJoin(g_pServerInterface->GetServerModPath(), SETTINGS_TEMPLATE_PATH);
872871
if (!FileExists(templateFileName))
873872
return false;
874873

875-
CXMLFile* templateFile = g_pServerInterface->GetXML()->CreateXML(templateFileName);
876-
CXMLNode* templateRootNode = templateFile && templateFile->Parse() ? templateFile->GetRootNode() : nullptr;
874+
std::unique_ptr<CXMLFile> templateFile(g_pServerInterface->GetXML()->CreateXML(templateFileName.c_str()));
875+
if (!templateFile || !templateFile->Parse())
876+
{
877+
CLogger::ErrorPrintf("Failed to parse template file: '%s'\n", templateFileName.c_str());
878+
return false;
879+
}
880+
881+
CXMLNode* templateRootNode = templateFile->GetRootNode();
877882
if (!templateRootNode)
878883
{
879-
CLogger::ErrorPrintf("Can't parse '%s'\n", *templateFileName);
884+
CLogger::ErrorPrintf("Template file '%s' has no root node\n", templateFileName.c_str());
880885
return false;
881886
}
882887

883888
// Check that each item in the template also exists in the server config
884-
bool hasConfigChanged = false;
889+
bool configChanged = false;
885890
CXMLNode* previousNode = nullptr;
891+
886892
for (auto it = templateRootNode->ChildrenBegin(); it != templateRootNode->ChildrenEnd(); ++it)
887893
{
888894
CXMLNode* templateNode = *it;
889-
SString templateNodeTagName = templateNode->GetTagName();
895+
const std::string& templateNodeName = templateNode->GetTagName();
890896

897+
// Skip certain optional nodes
898+
if (templateNodeName == "resource" || templateNodeName == "module")
899+
continue;
900+
891901
// Find node with exact same attributes
892902
CXMLAttributes& templateAttributes = templateNode->GetAttributes();
893903
CXMLNode* foundNode = nullptr;
894904
for (auto it2 = m_pRootNode->ChildrenBegin(); it2 != m_pRootNode->ChildrenEnd(); ++it2)
895905
{
896906
CXMLNode* tempNode = *it2;
897-
if (tempNode->GetTagName() != templateNodeTagName)
898-
{
907+
if (tempNode->GetTagName() != templateNodeName)
899908
continue;
900-
}
909+
901910
CXMLAttributes& attributes = tempNode->GetAttributes();
902-
bool attributesMatch = true;
903-
911+
bool attributesMatch = true;
912+
904913
for (auto it3 = templateAttributes.ListBegin(); it3 != templateAttributes.ListEnd(); ++it3)
905914
{
906915
CXMLAttribute* templateAttribute = *it3;
907-
const SString& strKey = templateAttribute->GetName();
908-
const SString& strValue = templateAttribute->GetValue();
909-
910-
CXMLAttribute* foundAttribute = attributes.Find(strKey);
911-
if (!foundAttribute || foundAttribute->GetValue() != strValue)
916+
const SString& attrName = templateAttribute->GetName();
917+
918+
// Don't check value attribute which is intended to be different
919+
if (attrName == "value")
920+
continue;
921+
922+
const SString& attrValue = templateAttribute->GetValue();
923+
924+
CXMLAttribute* foundAttribute = attributes.Find(attrName);
925+
if (!foundAttribute || foundAttribute->GetValue() != attrValue)
912926
{
913927
attributesMatch = false;
914928
break;
915929
}
916930
}
917-
931+
918932
if (attributesMatch)
919933
{
920934
foundNode = tempNode;
921935
break;
922936
}
923937
}
924-
// Create missing node if not found
938+
925939
if (!foundNode)
926940
{
927-
CLogger::LogPrintf("Adding missing '%s' to mtaserver.conf\n", *templateNodeTagName);
928-
SString value = templateNode->GetTagContent();
929-
SString commentText = templateNode->GetCommentText();
930-
foundNode = m_pRootNode->CreateSubNode(templateNodeTagName, previousNode);
931-
foundNode->SetTagContent(value);
932-
foundNode->SetCommentText(commentText, true);
933-
934-
// Copy attributes from template node
935-
CXMLAttributes& templateAttributes = templateNode->GetAttributes();
936-
for (auto it = templateAttributes.ListBegin(); it != templateAttributes.ListEnd(); ++it)
937-
{
938-
CXMLAttribute* templateAttribute = *it;
939-
const SString& attributeName = templateAttribute->GetName();
940-
const SString& attributeValue = templateAttribute->GetValue();
941+
const std::string templateNodeValue = templateNode->GetTagContent();
942+
const SString templateNodeComment = templateNode->GetCommentText();
941943

942-
CXMLAttribute* newAttribute = foundNode->GetAttributes().Create(attributeName);
943-
if (newAttribute)
944-
newAttribute->SetValue(attributeValue);
945-
}
946-
hasConfigChanged = true;
944+
foundNode = m_pRootNode->CreateSubNode(templateNodeName.c_str(), previousNode);
945+
foundNode->SetTagContent(templateNodeValue.c_str());
946+
foundNode->SetCommentText(templateNodeComment.c_str(), true);
947+
948+
CLogger::LogPrintf("Added missing '%s' setting to mtaserver.conf\n", templateNodeName.c_str());
949+
configChanged = true;
947950
}
948951
previousNode = foundNode;
949952
}
950-
951-
// Clean up
952-
g_pServerInterface->GetXML()->DeleteXML(templateFile);
953-
FileDelete(templateFileName);
954-
return hasConfigChanged;
953+
return configChanged;
955954
}
956955

957956
bool CMainConfig::IsValidPassword(const char* szPassword)

Shared/installer/locale/en_US.pot

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ msgid ""
33
msgstr ""
44
"Project-Id-Version: MTA San Andreas Installer 1.x\n"
55
"Report-Msgid-Bugs-To: \n"
6-
"POT-Creation-Date: 2025-04-08 22:41\n"
6+
"POT-Creation-Date: 2025-08-17 21:39\n"
77
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
88
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
99
"Language-Team: LANGUAGE <[email protected]>\n"
@@ -245,29 +245,29 @@ msgid "Editor"
245245
msgstr ""
246246

247247
#. INST_SEC_DEVELOPER
248-
#: Shared/installer/nightly.nsi:985
248+
#: Shared/installer/nightly.nsi:986
249249
msgid "Development"
250250
msgstr ""
251251

252252
#. UNINST_SUCCESS
253-
#: Shared/installer/nightly.nsi:1033
253+
#: Shared/installer/nightly.nsi:1034
254254
msgid "$(^Name) was successfully removed from your computer."
255255
msgstr ""
256256

257257
#. UNINST_FAIL
258-
#: Shared/installer/nightly.nsi:1040
258+
#: Shared/installer/nightly.nsi:1041
259259
msgid "Uninstallation has failed!"
260260
msgstr ""
261261

262262
#. UNINST_REQUEST
263-
#: Shared/installer/nightly.nsi:1048
263+
#: Shared/installer/nightly.nsi:1049
264264
msgid ""
265265
"Are you sure you want to completely remove $(^Name) and all of its "
266266
"components?"
267267
msgstr ""
268268

269269
#. UNINST_REQUEST_NOTE
270-
#: Shared/installer/nightly.nsi:1049
270+
#: Shared/installer/nightly.nsi:1050
271271
msgid ""
272272
"Uninstalling before update?$\r"
273273
"$\n"
@@ -277,35 +277,35 @@ msgid ""
277277
msgstr ""
278278

279279
#. UNINST_DATA_REQUEST
280-
#: Shared/installer/nightly.nsi:1062
280+
#: Shared/installer/nightly.nsi:1063
281281
msgid ""
282282
"Would you like to keep your data files (such as resources, screenshots and "
283283
"server configuration)? If you click no, any resources, configurations or "
284284
"screenshots you have created will be lost."
285285
msgstr ""
286286

287287
#. UAC_RIGHTS1
288-
#: Shared/installer/nightly.nsi:1245
288+
#: Shared/installer/nightly.nsi:1246
289289
msgid "This installer requires admin access, try again"
290290
msgstr ""
291291

292292
#. UAC_RIGHTS_UN
293-
#: Shared/installer/nightly.nsi:1246
293+
#: Shared/installer/nightly.nsi:1247
294294
msgid "This uninstaller requires admin access, try again"
295295
msgstr ""
296296

297297
#. UAC_RIGHTS3
298-
#: Shared/installer/nightly.nsi:1247
298+
#: Shared/installer/nightly.nsi:1248
299299
msgid "Logon service not running, aborting!"
300300
msgstr ""
301301

302302
#. UAC_RIGHTS4
303-
#: Shared/installer/nightly.nsi:1248
303+
#: Shared/installer/nightly.nsi:1249
304304
msgid "Unable to elevate"
305305
msgstr ""
306306

307307
#. INST_MTA_CONFLICT
308-
#: Shared/installer/nightly.nsi:1844
308+
#: Shared/installer/nightly.nsi:1845
309309
msgid ""
310310
"A different major version of MTA ($1) already exists at that path.$\n"
311311
"$\n"
@@ -314,7 +314,7 @@ msgid ""
314314
msgstr ""
315315

316316
#. INST_GTA_CONFLICT
317-
#: Shared/installer/nightly.nsi:1848
317+
#: Shared/installer/nightly.nsi:1849
318318
msgid ""
319319
"MTA cannot be installed into the same directory as GTA:SA.$\n"
320320
"$\n"
@@ -323,35 +323,35 @@ msgid ""
323323
msgstr ""
324324

325325
#. INST_GTA_ERROR1
326-
#: Shared/installer/nightly.nsi:1851
326+
#: Shared/installer/nightly.nsi:1852
327327
msgid ""
328328
"The selected directory does not exist.$\n"
329329
"$\n"
330330
"Please select the GTA:SA install directory"
331331
msgstr ""
332332

333333
#. INST_GTA_ERROR2
334-
#: Shared/installer/nightly.nsi:1853
334+
#: Shared/installer/nightly.nsi:1854
335335
msgid ""
336336
"Could not find GTA:SA installed at $GTA_DIR $\n"
337337
"$\n"
338338
"Are you sure you want to continue ?"
339339
msgstr ""
340340

341341
#. INST_CHOOSE_LOC_TOP
342-
#: Shared/installer/nightly.nsi:1971
342+
#: Shared/installer/nightly.nsi:1972
343343
msgid "Choose Install Location"
344344
msgstr ""
345345

346346
#. INST_CHOOSE_LOC
347-
#: Shared/installer/nightly.nsi:1972
347+
#: Shared/installer/nightly.nsi:1973
348348
msgid ""
349349
"Choose the folder in which to install ${PRODUCT_NAME_NO_VER} "
350350
"${PRODUCT_VERSION}"
351351
msgstr ""
352352

353353
#. INST_CHOOSE_LOC2
354-
#: Shared/installer/nightly.nsi:1973
354+
#: Shared/installer/nightly.nsi:1974
355355
msgid ""
356356
"${PRODUCT_NAME_NO_VER} ${PRODUCT_VERSION} will be installed in the following folder.$\n"
357357
"To install in a different folder, click Browse and select another folder.$\n"
@@ -360,63 +360,63 @@ msgid ""
360360
msgstr ""
361361

362362
#. INST_CHOOSE_LOC3
363-
#: Shared/installer/nightly.nsi:1975
363+
#: Shared/installer/nightly.nsi:1976
364364
msgid "Destination Folder"
365365
msgstr ""
366366

367367
#. INST_CHOOSE_LOC_BROWSE
368-
#: Shared/installer/nightly.nsi:1976
368+
#: Shared/installer/nightly.nsi:1977
369369
msgid "Browse..."
370370
msgstr ""
371371

372372
#. INST_CHOOSE_LOC_DEFAULT
373-
#: Shared/installer/nightly.nsi:1977
373+
#: Shared/installer/nightly.nsi:1978
374374
msgid "Default"
375375
msgstr ""
376376

377377
#. INST_CHOOSE_LOC_LAST_USED
378-
#: Shared/installer/nightly.nsi:1978
378+
#: Shared/installer/nightly.nsi:1979
379379
msgid "Last used"
380380
msgstr ""
381381

382382
#. INST_CHOOSE_LOC_CUSTOM
383-
#: Shared/installer/nightly.nsi:1979
383+
#: Shared/installer/nightly.nsi:1980
384384
msgid "Custom"
385385
msgstr ""
386386

387387
#. INST_CHOOSE_LOC4
388-
#: Shared/installer/nightly.nsi:2157
388+
#: Shared/installer/nightly.nsi:2158
389389
msgid ""
390390
"Select the folder to install ${PRODUCT_NAME_NO_VER} ${PRODUCT_VERSION} in:"
391391
msgstr ""
392392

393393
#. INST_LOC_OW
394-
#: Shared/installer/nightly.nsi:2175
394+
#: Shared/installer/nightly.nsi:2176
395395
msgid ""
396396
"Warning: A different major version of MTA ($1) already exists at that path."
397397
msgstr ""
398398

399399
#. INST_LOC_UPGRADE
400-
#: Shared/installer/nightly.nsi:2176
400+
#: Shared/installer/nightly.nsi:2177
401401
msgid "Installation type: Upgrade"
402402
msgstr ""
403403

404404
#. NETTEST_TITLE1
405-
#: Shared/installer/nightly.nsi:2410
405+
#: Shared/installer/nightly.nsi:2411
406406
msgid "Online update"
407407
msgstr ""
408408

409409
#. NETTEST_TITLE2
410-
#: Shared/installer/nightly.nsi:2411
410+
#: Shared/installer/nightly.nsi:2412
411411
msgid "Checking for update information"
412412
msgstr ""
413413

414414
#. NETTEST_STATUS1
415-
#: Shared/installer/nightly.nsi:2412
415+
#: Shared/installer/nightly.nsi:2413
416416
msgid "Checking for installer update information..."
417417
msgstr ""
418418

419419
#. NETTEST_STATUS2
420-
#: Shared/installer/nightly.nsi:2413
420+
#: Shared/installer/nightly.nsi:2414
421421
msgid "Please ensure your firewall is not blocking"
422422
msgstr ""

Shared/installer/nightly.nsi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -857,6 +857,7 @@ SectionGroup /e "$(INST_SEC_SERVER)" SECGSERVER
857857
File "${SERVER_FILES_ROOT}\mods\deathmatch\libcrypto-3.dll"
858858
File "${SERVER_FILES_ROOT}\mods\deathmatch\libssl-3.dll"
859859
!endif
860+
File "${SERVER_FILES_ROOT}\mods\deathmatch\mtaserver.conf.template"
860861

861862
;Only overwrite the following files if previous versions were bugged and explicitly need replacing
862863
!insertmacro FileIfMD5 "${SERVER_FILES_ROOT}\mods\deathmatch\editor_acl.xml" "711185d8f4ebb355542053ce408b82b3"

0 commit comments

Comments
 (0)