From 5a9316c3f0f885e36443ad8fce7e9314906230f3 Mon Sep 17 00:00:00 2001 From: FynnTW Date: Fri, 8 Nov 2024 17:14:18 +0200 Subject: [PATCH] localized name edb entry --- M2TWEOP Code/M2TWEOP library/types/battle.cpp | 2 +- M2TWEOP Code/M2TWEOP library/types/eopBuildings.cpp | 2 ++ M2TWEOP Code/M2TWEOP library/types/eopBuildings.h | 12 +++++++++++- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/M2TWEOP Code/M2TWEOP library/types/battle.cpp b/M2TWEOP Code/M2TWEOP library/types/battle.cpp index 7b48f64b..eea4b044 100644 --- a/M2TWEOP Code/M2TWEOP library/types/battle.cpp +++ b/M2TWEOP Code/M2TWEOP library/types/battle.cpp @@ -217,7 +217,7 @@ namespace battleHelpers const DWORD offset = reinterpret_cast(perimeters) + 0x48; battlePos pos{x,y}; const auto posPtr = &pos; - return GAME_FUNC(int(__thiscall*)(DWORD, battlePos*), getZoneID)(offset, posPtr); + return GAME_FUNC(int(__thiscall*)(DWORD, battlePos*), getZoneID)(offset, posPtr) & 0b111; } battlePerimeters* getBattlePerimeters() diff --git a/M2TWEOP Code/M2TWEOP library/types/eopBuildings.cpp b/M2TWEOP Code/M2TWEOP library/types/eopBuildings.cpp index 2b060614..473a9cc5 100644 --- a/M2TWEOP Code/M2TWEOP library/types/eopBuildings.cpp +++ b/M2TWEOP Code/M2TWEOP library/types/eopBuildings.cpp @@ -649,6 +649,7 @@ namespace buildingHelpers Basic edbEntry table. @tfield int buildingID + @tfield string localizedName @tfield int classification @tfield int isCoreBuilding @tfield int isPort @@ -673,6 +674,7 @@ namespace buildingHelpers types.edbEntry.set("religionID", &edbEntry::religionID); types.edbEntry.set("isHinterland", &edbEntry::isHinterland); types.edbEntry.set("isFarm", &edbEntry::isFarm); + types.edbEntry.set("localizedName", sol::property(&edbEntry::getLocalizedName, &edbEntry::setLocalizedName)); types.edbEntry.set("buildingLevelCount", &edbEntry::buildingLevelCount); /*** diff --git a/M2TWEOP Code/M2TWEOP library/types/eopBuildings.h b/M2TWEOP Code/M2TWEOP library/types/eopBuildings.h index d6e8f838..955d791c 100644 --- a/M2TWEOP Code/M2TWEOP library/types/eopBuildings.h +++ b/M2TWEOP Code/M2TWEOP library/types/eopBuildings.h @@ -339,7 +339,7 @@ struct edbEntry { /* SETTLEMENT_CONDITION_SETTLEMENT_FACTION */ int8_t isHinterland; //0x0068 int8_t isFarm; //0x0069 char pad_006A[2]; //0x006A - UNICODE_STRING** localizedName; + UNICODE_STRING*** localizedName; gameStdVector converts; char* type; /* type of building (core_building,barracks) */ int typeHash; @@ -355,6 +355,16 @@ struct edbEntry { /* SETTLEMENT_CONDITION_SETTLEMENT_FACTION */ return nullptr; return &levels[index]; } + std::string getLocalizedName() + { + return gameStringHelpers::uniStringToStr(*localizedName); + } + void setLocalizedName(const std::string& newName) + { + const auto nameMem = techFuncs::createGameClass(); + localizedName = nameMem; + gameStringHelpers::createUniString(*localizedName, newName.c_str()); + } }; struct hiddenResource