Skip to content

Commit 3c61146

Browse files
committed
Set artifact site counters when loading OG saves
- site ID counter - mission run counter
1 parent 09082d6 commit 3c61146

3 files changed

Lines changed: 33 additions & 4 deletions

File tree

‎src/Savegame/AlienStrategy.cpp‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,12 +185,13 @@ int AlienStrategy::getMissionsRun(const std::string &varName)
185185
/**
186186
* Increments the number of missions run labelled as "varName".
187187
* @param varName the variable name that we want to use to keep track of this.
188+
* @param increment the value to increment by.
188189
*/
189-
void AlienStrategy::addMissionRun(const std::string &varName)
190+
void AlienStrategy::addMissionRun(const std::string &varName, int increment)
190191
{
191192
if (varName.empty())
192193
return;
193-
_missionRuns[varName]++;
194+
_missionRuns[varName] += increment;
194195
}
195196

196197
/**

‎src/Savegame/AlienStrategy.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class AlienStrategy
5050
/// Checks the number of missions run labelled as "varName".
5151
int getMissionsRun(const std::string &varName);
5252
/// Increments the number of missions run labelled as "varName".
53-
void addMissionRun(const std::string &varName);
53+
void addMissionRun(const std::string &varName, int increment = 1);
5454
/// Adds a mission location to our storage array.
5555
void addMissionLocation(const std::string &varName, const std::string &regionName, int zoneNumber, int maximum);
5656
/// Checks that a given mission location (city or whatever) isn't stored in our list of previously attacked locations.

‎src/Savegame/SaveConverter.cpp‎

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,6 @@ void SaveConverter::loadDatUIGlob()
341341
ids[_rules->getMarkers()[i]] = load<Uint16>(data + i * sizeof(Uint16));
342342
}
343343
ids["STR_CRASH_SITE"] = ids["STR_LANDING_SITE"] = ids["STR_UFO"];
344-
_save->setAllIds(ids);
345344

346345
_year = load<Uint16>(data + 0x16);
347346

@@ -351,6 +350,35 @@ void SaveConverter::loadDatUIGlob()
351350
int score = load<Sint16>(data + 0x18 + i * sizeof(Sint16));
352351
_save->getResearchScores().push_back(score);
353352
}
353+
354+
// Loads the SITE.DAT file (TFTD only).
355+
std::string s = _savePath + CrossPlatform::PATH_SEPARATOR + "SITE.DAT";
356+
if (CrossPlatform::fileExists(s))
357+
{
358+
std::vector<char> sitebuffer;
359+
char* sitedata = binaryBuffer("SITE.DAT", sitebuffer);
360+
int generatedArtifactSiteMissions = load<Uint16>(sitedata + 0x24);
361+
if (generatedArtifactSiteMissions > 0)
362+
{
363+
_save->getAlienStrategy().addMissionRun("artifacts", generatedArtifactSiteMissions);
364+
365+
int spawnedArtifactSites = generatedArtifactSiteMissions;
366+
char siteTypeToBeSpawned = load<char>(sitedata + 0x26);
367+
if (siteTypeToBeSpawned == 'T')
368+
{
369+
// before the first hour of the month, the mission was generated already, but the site has not spawned yet
370+
spawnedArtifactSites--;
371+
}
372+
else
373+
{
374+
// after the first hour of the month
375+
// or not an artifact site type
376+
}
377+
ids["STR_ARTIFACT_SITE"] = spawnedArtifactSites + 1; // OXC stores the ID of the next site, thus +1
378+
}
379+
}
380+
381+
_save->setAllIds(ids);
354382
}
355383

356384
/**

0 commit comments

Comments
 (0)