1
0
mirror of https://github.com/rwengine/openrw.git synced 2024-11-07 11:22:45 +01:00

Load game zones from save file block

This commit is contained in:
Daniel Evans 2017-01-18 23:15:09 +00:00
parent bb6698e373
commit 3247fafa90

View File

@ -371,9 +371,11 @@ struct Block11Zone {
}; };
struct Block11ZoneInfo { struct Block11ZoneInfo {
BlockWord density; BlockWord density;
// This will likely be the gang BlockWord unknown1[16];
// car and ped densities +more BlockWord peddensity;
uint8_t unknown1[56]; BlockWord copdensity;
BlockWord gangpeddensity[9];
BlockWord pedgroup;
}; };
struct Block11AudioZone { struct Block11AudioZone {
BlockWord zoneId; BlockWord zoneId;
@ -890,6 +892,10 @@ bool SaveGame::loadGame(GameState& state, const std::string& file) {
Block11ZoneInfo& info = zoneData.dayNightInfo[z]; Block11ZoneInfo& info = zoneData.dayNightInfo[z];
READ_VALUE(info.density) READ_VALUE(info.density)
READ_VALUE(info.unknown1) READ_VALUE(info.unknown1)
READ_VALUE(info.peddensity)
READ_VALUE(info.copdensity)
READ_VALUE(info.gangpeddensity)
READ_VALUE(info.pedgroup);
} }
READ_VALUE(zoneData.numNavZones); READ_VALUE(zoneData.numNavZones);
READ_VALUE(zoneData.numZoneInfos); READ_VALUE(zoneData.numZoneInfos);
@ -919,6 +925,31 @@ bool SaveGame::loadGame(GameState& state, const std::string& file) {
for (int z = 0; z < zoneData.numNavZones; ++z) { for (int z = 0; z < zoneData.numNavZones; ++z) {
Block11Zone& zone = zoneData.navZones[z]; Block11Zone& zone = zoneData.navZones[z];
std::cout << " " << zone.name << std::endl; std::cout << " " << zone.name << std::endl;
auto& dayinfo = zoneData.dayNightInfo[zone.dayZoneInfo];
std::cout << " DAY " << dayinfo.density << " " << dayinfo.peddensity
<< " " << dayinfo.copdensity << " "
<< " [";
for (BlockDword gang : dayinfo.gangpeddensity) {
std::cout << " " << gang;
}
std::cout << "] " << dayinfo.pedgroup << std::endl;
for (BlockDword dw : dayinfo.unknown1) {
std::cout << " " << dw;
}
std::cout << std::endl;
auto& nightinfo = zoneData.dayNightInfo[zone.nightZoneInfo];
std::cout << " NIGHT " << nightinfo.density << " "
<< nightinfo.peddensity << " " << nightinfo.copdensity << " "
<< " [";
for (BlockDword gang : nightinfo.gangpeddensity) {
std::cout << " " << gang;
}
std::cout << "] " << nightinfo.pedgroup << std::endl;
for (BlockDword dw : nightinfo.unknown1) {
std::cout << " " << dw;
}
std::cout << std::endl;
} }
for (int z = 0; z < zoneData.numMapZones; ++z) { for (int z = 0; z < zoneData.numMapZones; ++z) {
Block11Zone& zone = zoneData.mapZones[z]; Block11Zone& zone = zoneData.mapZones[z];
@ -926,6 +957,33 @@ bool SaveGame::loadGame(GameState& state, const std::string& file) {
} }
#endif #endif
// Clear existing zone data
auto& gamezones = state.world->data->gamezones;
gamezones.clear();
for (int z = 0; z < zoneData.numNavZones; ++z) {
Block11Zone& zone = zoneData.navZones[z];
Block11ZoneInfo& day = zoneData.dayNightInfo[zone.dayZoneInfo];
Block11ZoneInfo& night = zoneData.dayNightInfo[zone.nightZoneInfo];
ZoneData zd;
zd.name = zone.name;
zd.type = zone.type;
zd.min = zone.coordA;
zd.max = zone.coordB;
zd.island = zone.level;
// @toodo restore gang density
zd.pedGroupDay = day.pedgroup;
zd.pedGroupNight = night.pedgroup;
gamezones.push_back(zd);
}
// Re-build zone hierarchy
for (ZoneData& zone : gamezones) {
if (&zone == &gamezones[0]) {
continue;
}
gamezones[0].insertZone(zone);
}
// Block 12 // Block 12
BlockSize gangBlockSize; BlockSize gangBlockSize;
BLOCK_HEADER(gangBlockSize) BLOCK_HEADER(gangBlockSize)