Skip to content

Commit 4b9e402

Browse files
ilteroiRecursiveVision
ilteroi
authored andcommitted
remove dependencies to FString (except for ini file parsing)
1 parent 865d55b commit 4b9e402

29 files changed

+73
-101
lines changed

CvGameCoreDLLUtil/include/CvEnums.h

+6-6
Original file line numberDiff line numberDiff line change
@@ -781,9 +781,9 @@ enum CLOSED_ENUM InterfaceMessageTypes
781781

782782
// !!!!!!!!!!!!!!!!!!!!!!!
783783
// IMPORTANT - NotificationTypes enum contains hash values, not an index!
784-
// It is not required to add a new enum for a new notification, you can just use the hash (FString::Hash) of the name
784+
// It is not required to add a new enum for a new notification, you can just use the hash (FStringHash) of the name
785785
// as defined in the Notifications.xml or equivalent. The enum is just a helper so that the has generation is done
786-
// at compile time. e.g. the enum NOTIFICATION_TECH is equivalent to FString::Hash("NOTIFICATION_TECH")
786+
// at compile time. e.g. the enum NOTIFICATION_TECH is equivalent to FStringHash("NOTIFICATION_TECH")
787787
//
788788
// MODDERS:
789789
// If you add a new notification, you do NOT have to add it to this helper list, you can just make a define
@@ -1952,12 +1952,12 @@ enum CLOSED_ENUM AutomateTypes
19521952

19531953
// Do not add any more sequential enums, add explicit key values (hash of text key)
19541954

1955-
AUTOMATE_TRADE = 0x4bdc68d8, // FString::Hash("AUTOMATE_TRADE");
1955+
AUTOMATE_TRADE = 0x4bdc68d8, // FStringHash("AUTOMATE_TRADE");
19561956
#if defined(MOD_BALANCE_CORE)
1957-
AUTOMATE_MISSIONARY = 0x840842ea, //FString::Hash("AUTOMATE_MISSIONARY");
1958-
AUTOMATE_ARCHAEOLOGIST = 0x64f5468a, //FString::Hash("AUTOMATE_ARCHAEOLOGIST");
1957+
AUTOMATE_MISSIONARY = 0x840842ea, //FStringHash("AUTOMATE_MISSIONARY");
1958+
AUTOMATE_ARCHAEOLOGIST = 0x64f5468a, //FStringHash("AUTOMATE_ARCHAEOLOGIST");
19591959
#endif
1960-
AUTOMATE_DIPLOMAT = 0xd2d86d2d, //FString::Hash("AUTOMATE_DIPLOMAT");
1960+
AUTOMATE_DIPLOMAT = 0xd2d86d2d, //FStringHash("AUTOMATE_DIPLOMAT");
19611961

19621962
};
19631963

CvGameCoreDLL_Expansion2/CvCity.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -3628,7 +3628,7 @@ void CvCity::DoStartEvent(CityEventTypes eChosenEvent, bool bSendMsg)
36283628
{
36293629
CvString strBuffer = GetLocalizedText("TXT_KEY_CHOOSE_EVENT_CHOICE_CITY");
36303630
CvString strSummary = GetLocalizedText("TXT_KEY_CHOOSE_EVENT_CHOICE_CITY_TT");
3631-
pNotifications->Add((NotificationTypes)FString::Hash("NOTIFICATION_EVENT_CHOICE_CITY"), strSummary.c_str(), strBuffer.c_str(), -1, -1, eChosenEvent, GetID());
3631+
pNotifications->Add((NotificationTypes)FStringHash("NOTIFICATION_EVENT_CHOICE_CITY"), strSummary.c_str(), strBuffer.c_str(), -1, -1, eChosenEvent, GetID());
36323632
}
36333633
}
36343634
else
@@ -7294,7 +7294,7 @@ void CvCity::DoEventChoice(CityEventChoiceTypes eEventChoice, CityEventTypes eCi
72947294
CvString strNotificationString = pkEventChoiceInfo->GetNotificationInfo(iI)->GetNotificationString();
72957295
if (strNotificationString != NULL && !strNotificationString.empty())
72967296
{
7297-
NotificationTypes eNotificationType = (NotificationTypes)FString::Hash(strNotificationString);
7297+
NotificationTypes eNotificationType = (NotificationTypes)FStringHash(strNotificationString);
72987298

72997299
if (eNotificationType != NO_NOTIFICATION_TYPE)
73007300
{
@@ -9716,7 +9716,7 @@ void CvCity::ChangeNumResourceLocal(ResourceTypes eResource, int iChange, bool b
97169716
CvNotifications* pNotifications = GET_PLAYER(getOwner()).GetNotifications();
97179717
if (pNotifications)
97189718
{
9719-
pNotifications->Add((NotificationTypes)FString::Hash("NOTIFICATION_PRODUCTION_COST_MODIFIERS_FROM_RESOURCES"), strText.toUTF8(), strSummary.toUTF8(), getX(), getY(), eResource);
9719+
pNotifications->Add((NotificationTypes)FStringHash("NOTIFICATION_PRODUCTION_COST_MODIFIERS_FROM_RESOURCES"), strText.toUTF8(), strSummary.toUTF8(), getX(), getY(), eResource);
97209720
}
97219721
}
97229722
}

CvGameCoreDLL_Expansion2/CvContractClasses.h

-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55

66
#if defined(MOD_BALANCE_CORE)
77

8-
#include "FAutoVariable.h"
9-
108
class CvContractEntry: public CvBaseInfo
119
{
1210
public:

CvGameCoreDLL_Expansion2/CvDangerPlots.cpp

-3
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,13 @@
1313
#include "CvDiplomacyAI.h"
1414
#include "CvMilitaryAI.h"
1515
#include "CvMinorCivAI.h"
16-
#include "FireWorks/FRemark.h"
1716

1817
// must be included after all other headers
1918
#include "LintFree.h"
2019
#ifdef _MSC_VER
2120
#pragma warning ( disable : 4505 ) // unreferenced local function has been removed.. needed by REMARK below
2221
#endif//_MSC_VER
2322

24-
REMARK_GROUP("CvDangerPlots");
25-
2623
//this adds up quickly if there multiple invisible tiles around ...
2724
#define FOG_DEFAULT_DANGER (1)
2825

CvGameCoreDLL_Expansion2/CvEnumMap.h

-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111

1212
#include "CvAssert.h"
1313
#include "CvAlignedStorage.h"
14-
#include "FDefNew.h"
15-
1614
#include "CvEnumsUtil.h"
1715

1816
#include <algorithm>

CvGameCoreDLL_Expansion2/CvEspionageClasses.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1562,7 +1562,7 @@ bool CvPlayerEspionage::TriggerSpyFocusSetup(CvCity* pCity, int uiSpyIndex)
15621562
strSummary << pSpy->GetSpyName(m_pPlayer);
15631563
strSummary << pCity->getNameKey();
15641564

1565-
pNotifications->Add((NotificationTypes)FString::Hash("NOTIFICATION_ESPIONAGE_AA"), strSummary.toUTF8(), strBuffer.toUTF8(), pCity->plot()->getX(), pCity->plot()->getY(), eSetupEvent, uiSpyIndex);
1565+
pNotifications->Add((NotificationTypes)FStringHash("NOTIFICATION_ESPIONAGE_AA"), strSummary.toUTF8(), strBuffer.toUTF8(), pCity->plot()->getX(), pCity->plot()->getY(), eSetupEvent, uiSpyIndex);
15661566
}
15671567
pCity->GetCityEspionage()->ChangePendingEvents(m_pPlayer->GetID(), 1);
15681568
}

CvGameCoreDLL_Expansion2/CvGame.cpp

+6-9
Original file line numberDiff line numberDiff line change
@@ -45,19 +45,16 @@
4545
#include "ICvDLLUserInterface.h"
4646
#include "CvEnumSerialization.h"
4747
#include "FStlContainerSerialization.h"
48-
#include "FAutoVariableBase.h"
4948
#include "CvStringUtils.h"
5049
#include "CvBarbarians.h"
5150
#include "CvGoodyHuts.h"
5251

5352
#include <sstream>
5453

55-
#include "FTempHeap.h"
5654
#include "CvDiplomacyRequests.h"
5755

5856
#include "CvDllPlot.h"
5957
#include "FFileSystem.h"
60-
6158
#include "CvInfosSerializationHelper.h"
6259
#include "CvCityManager.h"
6360
#include "CvPlayerManager.h"
@@ -6102,7 +6099,7 @@ void CvGame::sendPlayerOptions(bool bForce)
61026099
CvPlayerOptionInfo* pkInfo = GC.getPlayerOptionInfo(eOption);
61036100
if (pkInfo)
61046101
{
6105-
uint uiID = FString::Hash( pkInfo->GetType() );
6102+
uint uiID = FStringHash( pkInfo->GetType() );
61066103
gDLL->sendPlayerOption(static_cast<PlayerOptionTypes>(uiID), gDLL->getPlayerOption(static_cast<PlayerOptionTypes>(uiID)));
61076104
}
61086105
}
@@ -10427,7 +10424,7 @@ int CvGame::calculateOptionsChecksum()
1042710424
CvPlayerOptionInfo* pkInfo = GC.getPlayerOptionInfo((PlayerOptionTypes)iJ);
1042810425
if (pkInfo)
1042910426
{
10430-
uint uiID = FString::Hash( pkInfo->GetType() );
10427+
uint uiID = FStringHash( pkInfo->GetType() );
1043110428
if(kPlayer.isOption((PlayerOptionTypes)uiID))
1043210429
{
1043310430
iValue += (iI * 943097);
@@ -11140,7 +11137,7 @@ void CvGame::readSaveGameDB(FDataStream& kStream)
1114011137
FIFile* pkFile = FFILESYSTEM.Create(wstrDatabasePath.c_str(), FIFile::modeWrite);
1114111138
if (pkFile != NULL)
1114211139
{
11143-
byte* szBuffer = GetTempHeap()->Allocate(sizeof(char) * lSize);
11140+
byte* szBuffer = new byte[sizeof(char) * lSize];
1114411141
ZeroMemory((void*)szBuffer, lSize);
1114511142

1114611143
kStream.ReadIt(lSize, szBuffer);
@@ -11149,7 +11146,7 @@ void CvGame::readSaveGameDB(FDataStream& kStream)
1114911146

1115011147
pkFile->Close();
1115111148

11152-
GetTempHeap()->DeAllocate(szBuffer);
11149+
free(szBuffer);
1115311150
}
1115411151
else
1115511152
{
@@ -11174,7 +11171,7 @@ void CvGame::writeSaveGameDB(FDataStream& kStream) const
1117411171
DWORD dwSize = GetFileSize(hFile, NULL);
1117511172
if (dwSize != INVALID_FILE_SIZE)
1117611173
{
11177-
byte* szBuffer = GetTempHeap()->Allocate(sizeof(char) * dwSize);
11174+
byte* szBuffer = new byte[sizeof(char) * dwSize];
1117811175
ZeroMemory((void*)szBuffer, dwSize);
1117911176

1118011177
DWORD dwBytesRead = 0;
@@ -11185,7 +11182,7 @@ void CvGame::writeSaveGameDB(FDataStream& kStream) const
1118511182
kStream.WriteIt(dwBytesRead, szBuffer);
1118611183
}
1118711184

11188-
GetTempHeap()->DeAllocate(szBuffer);
11185+
free(szBuffer);
1118911186
}
1119011187
else
1119111188
{

CvGameCoreDLL_Expansion2/CvGlobals.cpp

+15-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
#include "CvTeam.h"
1919
#include "CvInfos.h"
2020
#include "ICvDLLUtility.h"
21-
#include "CvPlayerAI.h"
2221
#include "CvGameTextMgr.h"
2322
#include "CvDiplomacyAI.h"
2423
#include "CvEconomicAI.h"
@@ -31,6 +30,7 @@
3130
#include "cvStopWatch.h"
3231
#include "CvReplayInfo.h"
3332
#include "CvTypes.h"
33+
#include "FCrc32.h"
3434

3535
#include "CvDllDatabaseUtility.h"
3636
#include "CvDllScriptSystemUtility.h"
@@ -64,6 +64,18 @@ void deleteInfoArray(std::vector<T*>& array)
6464
array.clear();
6565
}
6666

67+
// Calculates a hash value for the string
68+
uint FStringHash(LPCWSTR pszStr)
69+
{
70+
int len = (pszStr ? (int)wcslen(pszStr) : 0);
71+
return (g_CRC32.Calc((void*)pszStr, len * sizeof(wchar)));
72+
}
73+
uint FStringHash(LPCSTR pszStr)
74+
{
75+
int len = (pszStr ? (int)strlen(pszStr) : 0);
76+
return (g_CRC32.Calc((void*)pszStr, len * sizeof(char)));
77+
}
78+
6779
//////////////////////////////////////////////////////////////////////////////////////////////////
6880
//////////////////////////////////////////////////////////////////////////////////////////////////
6981

@@ -4044,7 +4056,7 @@ static void HashGameDataCombine(CvGlobals::GameDataHash& seed, std::size_t& word
40444056
if (*it == 0)
40454057
infoHash = fnv_offset_basis;
40464058
else
4047-
infoHash = FString::Hash((*it)->GetType());
4059+
infoHash = FStringHash((*it)->GetType());
40484060
seed[word] ^= (infoHash ^ fnv_offset_basis) * fnv_prime;
40494061
if (++word >= 4)
40504062
word = 0;
@@ -7492,7 +7504,7 @@ int CvGlobals::getInfoTypeForString(const char* szType, bool hideAssert) const
74927504
void CvGlobals::setInfoTypeFromString(const char* szType, int idx)
74937505
{
74947506
ASSERT_DEBUG(szType, "null info type string");
7495-
uint uiHash = FString::Hash(szType);
7507+
uint uiHash = FStringHash(szType);
74967508
#ifdef _DEBUG
74977509
InfosMap::const_iterator it = m_infosMap.find(szType);
74987510
int iExisting = (it!=m_infosMap.end()) ? it->second : -1;

CvGameCoreDLL_Expansion2/CvGlobals.h

+4-1
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ class CvGlobals
172172
};
173173

174174
typedef stdext::hash_map<std::string /* type string */, int /* info index */> InfosMap;
175-
typedef std::map<uint /* FString::HashType */, int /* info index */> InfosHashMap;
175+
typedef std::map<uint /* FStringHashType */, int /* info index */> InfosHashMap;
176176
typedef tr1::array<uint32, 4> GameDataHash;
177177

178178
// singleton accessor
@@ -3212,6 +3212,9 @@ extern CvGlobals gGlobals;
32123212
#define DLLUI (GC.GetEngineUserInterface())
32133213
#define DLLUIClass CvDLLInterfaceIFaceBase
32143214

3215+
uint FStringHash(LPCWSTR pszStr);
3216+
uint FStringHash(LPCSTR pszStr);
3217+
32153218
inline Database::Connection* CvGlobals::GetGameDatabase()
32163219
{
32173220
return m_pGameDatabase;

CvGameCoreDLL_Expansion2/CvImprovementClasses.cpp

-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
#include "ICvDLLUserInterface.h"
1010
#include "CvGameCoreUtils.h"
1111
#include "CvImprovementClasses.h"
12-
#include "FireWorks/FRemark.h"
1312
#include "CvInfosSerializationHelper.h"
1413

1514
// must be included after all other headers
@@ -18,7 +17,6 @@
1817
#ifdef _MSC_VER
1918
#pragma warning ( disable : 4505 ) // unreferenced local function has been removed.. needed by REMARK below
2019
#endif//_MSC_VER
21-
REMARK_GROUP("CvImprovementClasses");
2220

2321

2422
//======================================================================================================
@@ -387,7 +385,6 @@ bool CvImprovementEntry::CacheResults(Database::Results& kResults, CvDatabaseUti
387385
else
388386
{
389387
m_iWorldSoundscapeScriptId = -1;
390-
Remark(1, "Warning: Missing soundscape definition in XML for feature: '%s'", GetType());
391388
}
392389

393390
const char* szImprovementPillage = kResults.GetText("ImprovementPillage");

CvGameCoreDLL_Expansion2/CvInfos.cpp

+1-5
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
#include "CvGameTextMgr.h"
2121
#include "CvGameCoreUtils.h"
2222
#include "CvImprovementClasses.h"
23-
#include "FireWorks/FRemark.h"
2423
#include "CvInfosSerializationHelper.h"
2524
#include <FireWorks/Win32/FKBInputDevice.h>
2625

@@ -29,7 +28,6 @@
2928
#ifdef _MSC_VER
3029
#pragma warning ( disable : 4505 ) // unreferenced local function has been removed.. needed by REMARK below
3130
#endif//_MSC_VER
32-
REMARK_GROUP("CvInfos");
3331

3432
//////////////////////////////////////////////////////////////////////////
3533
// CvBaseInfo Members
@@ -7223,7 +7221,6 @@ bool CvFeatureInfo::CacheResults(Database::Results& kResults, CvDatabaseUtility&
72237221
else
72247222
{
72257223
m_iWorldSoundscapeScriptId = -1;
7226-
Remark(1, "Warning: Missing soundscape definition in XML for feature: '%s'", GetType());
72277224
}
72287225

72297226
// Array properties
@@ -7664,7 +7661,6 @@ bool CvTerrainInfo::CacheResults(Database::Results& kResults, CvDatabaseUtility&
76647661
else
76657662
{
76667663
m_iWorldSoundscapeScriptId = -1;
7667-
Remark(1, "Warning: Missing soundscape definition in XML for feature: '%s'", GetType());
76687664
}
76697665
#if defined(MOD_BALANCE_CORE)
76707666
szTextVal = kResults.GetText("PassableTechTerrain");
@@ -9127,7 +9123,7 @@ bool CvEraInfo::CacheResults(Database::Results& kResults, CvDatabaseUtility& kUt
91279123
m_bVassalageEnabled = kResults.GetBool("VassalageEnabled");
91289124

91299125
m_strCityBombardEffectTag = kResults.GetText("CityBombardEffectTag");
9130-
m_uiCityBombardEffectTagHash = FString::Hash(m_strCityBombardEffectTag);
9126+
m_uiCityBombardEffectTagHash = FStringHash(m_strCityBombardEffectTag);
91319127

91329128
m_strAudioUnitVictoryScript = kResults.GetText("AudioUnitVictoryScript");
91339129
m_strAudioUnitDefeatScript = kResults.GetText("AudioUnitDefeatScript");

CvGameCoreDLL_Expansion2/CvInfosSerializationHelper.cpp

+5-6
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ const char* ms_V0PolicyBranchTags[10] =
137137
/// Helper function to read a single type ID as a string and convert it to an ID
138138
int Read(FDataStream& kStream, bool* bValid /*= NULL*/)
139139
{
140-
FStringFixedBuffer(sTemp, 256);
140+
CvString sTemp;
141141
kStream >> sTemp;
142142
if(bValid) *bValid = true;
143143
if(sTemp.GetLength() > 0 && sTemp != "NO_TYPE")
@@ -190,7 +190,7 @@ int ReadHashed(FDataStream& kStream, bool* bValid /*= NULL*/)
190190
/// Assumes the type is in the table's field "Type"
191191
int ReadDBLookup(FDataStream& kStream, const char* szTable, bool* bValid /*= NULL*/)
192192
{
193-
FStringFixedBuffer(sTemp, 256);
193+
CvString sTemp;
194194
kStream >> sTemp;
195195
if (bValid) *bValid = true;
196196
if(sTemp.GetLength() > 0 && sTemp != "NO_TYPE")
@@ -273,9 +273,8 @@ bool Write(FDataStream& kStream, const CvBaseInfo* pkInfo)
273273
{
274274
if(pkInfo)
275275
{
276-
FStringFixedBuffer(sTemp, 256);
277-
sTemp = pkInfo->GetType();
278-
kStream << sTemp;
276+
CvString temp = pkInfo->GetType();
277+
kStream << temp;
279278
return true;
280279
}
281280
else
@@ -293,7 +292,7 @@ bool WriteHashed(FDataStream& kStream, const CvBaseInfo* pkInfo)
293292
{
294293
if(pkInfo && pkInfo->GetType() && pkInfo->GetType()[0] != 0)
295294
{
296-
uint uiHash = FString::Hash(pkInfo->GetType());
295+
uint uiHash = FStringHash(pkInfo->GetType());
297296
kStream << uiHash;
298297
return true;
299298
}

CvGameCoreDLL_Expansion2/CvLoggerCSV.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#include "CvGameCoreDLLPCH.h"
22
#include "ICvDLLUserInterface.h"
33
#include "CvGameCoreUtils.h"
4-
#include "FireWorks/FVariableSystem.h"
54
#include "CvLoggerCSV.h"
65

76
// Include this after all other headers.

CvGameCoreDLL_Expansion2/CvNotificationClasses.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,6 @@ CvNotificationEntry* CvNotificationXMLEntries::GetByID(uint hHash)
9898
CvNotificationEntry* CvNotificationXMLEntries::GetByString(const char* pszName)
9999
{
100100
if (pszName && pszName[0] != 0)
101-
return GetByID(FString::Hash(pszName));
101+
return GetByID(FStringHash(pszName));
102102
return NULL;
103103
}

CvGameCoreDLL_Expansion2/CvNotifications.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ int CvNotifications::AddByName(const char* pszNotificationName, const char* strM
227227
{
228228
if (pszNotificationName && pszNotificationName[0] != 0)
229229
{
230-
return Add((NotificationTypes) FString::Hash(pszNotificationName), strMessage, strSummary, iX, iY, iGameDataIndex, iExtraGameData);
230+
return Add((NotificationTypes) FStringHash(pszNotificationName), strMessage, strSummary, iX, iY, iGameDataIndex, iExtraGameData);
231231
}
232232
return -1;
233233
}

0 commit comments

Comments
 (0)