Skip to content

Commit 3ff87ec

Browse files
committed
Increase minor replay version to be able to set the correct initial distributions for old replays without leather addon
1 parent eea9991 commit 3ff87ec

2 files changed

Lines changed: 19 additions & 1 deletion

File tree

libs/s25main/Replay.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ static const uint8_t currentReplayDataVersion = 1;
3838
uint8_t Replay::GetLatestMinorVersion() const
3939
{
4040
// 8.1: Portraits support
41-
return 1;
41+
// 8.2: Set correct initial distributions if replay starts without savegame for leather addon
42+
return 2;
4243
}
4344

4445
uint8_t Replay::GetLatestMajorVersion() const

libs/s25main/network/GameClient.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include "GameManager.h"
1212
#include "GameMessage_GameCommand.h"
1313
#include "JoinPlayerInfo.h"
14+
#include "LeatherLoader.h"
1415
#include "Loader.h"
1516
#include "NWFInfo.h"
1617
#include "PlayerGameCommands.h"
@@ -1560,6 +1561,22 @@ bool GameClient::StartReplay(const boost::filesystem::path& path)
15601561
return false;
15611562
}
15621563

1564+
if(!mapinfo.savegame && replayinfo->replay.GetMinorVersion() < 2)
1565+
{
1566+
for(unsigned i = 0; i < game->world_.GetNumPlayers(); i++)
1567+
{
1568+
auto newDistributions = default_settings.distribution;
1569+
unsigned idx = 0;
1570+
for(const DistributionMapping& mapping : distributionMap)
1571+
{
1572+
if(leatheraddon::isLeatherAddonBuildingType(std::get<1>(mapping)))
1573+
newDistributions[idx] = 0;
1574+
idx++;
1575+
}
1576+
game->world_.GetPlayer(i).ChangeDistribution(newDistributions);
1577+
}
1578+
}
1579+
15631580
replayinfo->next_gf = replayinfo->replay.ReadGF();
15641581

15651582
return true;

0 commit comments

Comments
 (0)