Skip to content

Commit

Permalink
Define mod version variable and store it in the game name (#63)
Browse files Browse the repository at this point in the history
  • Loading branch information
VDuchauffour authored Sep 8, 2024
1 parent 6f69230 commit a4e821b
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 8 deletions.
Binary file modified Assets/CvGameCoreDLL.dll
Binary file not shown.
7 changes: 7 additions & 0 deletions Assets/XML/GlobalDefinesVersion.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0"?>
<Civ4Defines xmlns="x-schema:CIV4GlobalDefinesSchema.xml">
<Define>
<DefineName>RFCE_MOD_VERSION</DefineName>
<DefineTextVal>1.6.5-1</DefineTextVal>
</Define>
</Civ4Defines>
27 changes: 27 additions & 0 deletions CvGameCoreDLL/CvInitCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1881,6 +1881,33 @@ void CvInitCore::resetAdvancedStartPoints()
setNumAdvancedStartPoints(iPoints);
}

const CvWString &CvInitCore::getGameName() const
{
return m_szGameName;
}

void CvInitCore::setGameName(const CvWString &szGameName)
{
static CvWString szAppliedGameName = szGameName;
static CvWString szModVersion = GC.getDefineSTRING("RFCE_MOD_VERSION");
static CvWString szLeft = " (v";
static CvWString szRight = ")";

if (szModVersion != NULL && !szModVersion.empty())
{
int iSuffixIndex = szAppliedGameName.find(szLeft);
if (iSuffixIndex != std::string::npos)
{
szAppliedGameName = szAppliedGameName.substr(0, iSuffixIndex);
}

m_szGameName = szAppliedGameName + szLeft + szModVersion + szRight;
return;
}

m_szGameName = szGameName;
}

void CvInitCore::read(FDataStreamBase *pStream)
{
uint uiSaveFlag = 0;
Expand Down
10 changes: 2 additions & 8 deletions CvGameCoreDLL/CvInitCore.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,8 @@ class CvInitCore
// **************************
// Member access
// **************************
DllExport const CvWString &getGameName() const
{
return m_szGameName;
}
DllExport void setGameName(const CvWString &szGameName)
{
m_szGameName = szGameName;
}
DllExport const CvWString &getGameName() const;
DllExport void setGameName(const CvWString &szGameName);

DllExport const CvWString &getGamePassword() const
{
Expand Down
5 changes: 5 additions & 0 deletions CvGameCoreDLL/CvXMLLoadUtilitySet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,11 @@ bool CvXMLLoadUtility::SetGlobalDefines()
return false;
}

if (!ReadGlobalDefines("xml\\GlobalDefinesVersion.xml", cache))
{
return false;
}

if (!ReadGlobalDefines("xml\\PythonCallbackDefines.xml", cache))
{
return false;
Expand Down

0 comments on commit a4e821b

Please sign in to comment.