Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
101 commits
Select commit Hold shift + click to select a range
b5e17f3
Adding ware workflow, buildings and menus for leather addon
ottml Dec 1, 2024
88e1bd7
Add distribution tab for ham and make gui more general
ottml Dec 1, 2024
ec2096f
Add compatibilty code
ottml Dec 1, 2024
449b3fa
Add direct transport route
ottml Dec 1, 2024
822aa6e
Add fixed animations from leather_bobs.lst
ottml Dec 1, 2024
458618e
Skinner goes out to get skins from carcass if he has no pigs (natural…
ottml Dec 7, 2024
8c3e36e
LeatherAddon military (1): Add SetArmorAllowed game command
ottml Dec 8, 2024
b95015b
LeatherAddon military (2): Add logic for armor in military building a…
ottml Dec 8, 2024
c7715bf
LeatherAddon military (3): Add armor gui elements to military building
ottml Dec 8, 2024
f1b95b4
Add test for SetArmorAllowed
ottml Dec 8, 2024
ed1a46d
Add compatibility code for ChangeDistribution and increase game comma…
ottml Dec 8, 2024
1c4f1f2
Add new transportation type leatherworking and compatibility code for…
ottml Jan 19, 2025
4ae991e
Fix wrong default build order
ottml Jan 19, 2025
f5e35dc
Solider has 30 percent chance to not die if he has an armor and is hi…
ottml Jan 19, 2025
dd39167
Reduce search range for skinner to hunter distance
ottml May 21, 2025
698c44e
Do not show tabs for goods in distribution gui having only one entry
ottml May 21, 2025
0610145
Add correct default values
ottml May 21, 2025
f94a9db
Fix build after rebase
ottml Jun 2, 2025
41baf5b
Add new base class for armored people
ottml Jun 6, 2025
a1b2655
Use same render code for fighting and armored people
ottml Jun 6, 2025
3812224
Add armor base class to trade donkey too
ottml Jun 7, 2025
139279c
Add armored soldiers to inventory and add enums for it
ottml Jun 7, 2025
11070d4
Add logic for counting armored soldiers in inventory and compatibilit…
ottml Jun 7, 2025
29ea0fb
Add and remove armored soldiers to global inventory add missing adds …
ottml Jun 8, 2025
e8d49e8
Add tooltip to inventory to show number of armored soldiers
ottml Jun 8, 2025
4bbb0de
Show amored soldiers on ship (debug only)
ottml Jun 8, 2025
639dbea
Avoid crash in sorted container
ottml Jun 8, 2025
28b9fba
Adjust comperators to take armor into account
ottml Jun 8, 2025
7730abd
Avoid crash/inconsisent state due to new comperator including armor
ottml Jun 8, 2025
844bb74
Fix formatting
ottml Jun 8, 2025
f912e8b
Handle real inventory correct (Part 1)
ottml Jun 8, 2025
77c04f1
Fix formatting and constexpr
ottml Jun 8, 2025
31289fb
Handle real inventory correct (Part 1)
ottml Jun 8, 2025
d6e0c13
Add armored soldiers to reserve
ottml Jun 8, 2025
2131552
Add real for orderJob
ottml Jun 8, 2025
a30024b
Use correct lst file (seems to be broken due to fixup from git)
ottml Jun 8, 2025
76c44a8
Handle armor correct when building is destroyed or captured and when …
ottml Jun 9, 2025
5fa0f89
Add and remove armored figures correct to visual inventory
ottml Jun 9, 2025
ccee3a0
Remove code duplication and draw +1 only if HITPOINTS addon is activa…
ottml Jun 9, 2025
3568c7e
Add addons to disable armor by default and behaviour for armor delive…
ottml Jun 14, 2025
eea8103
Add function to avoid code duplication
ottml Jun 14, 2025
9896a6c
Fix clang-tidy warnings
ottml Jun 15, 2025
c23a3da
Add test for trading and warehouse
ottml Jun 15, 2025
af6ee4c
Add test for soldier losing armor in fight instead of hitpoint
ottml Jun 15, 2025
6da0aee
Add replay compatibility for ChangeBuildOrder and SetAllInventorySett…
ottml Jun 19, 2025
0d4892c
Add comment about GC changes
ottml Jun 19, 2025
2881baa
Fix circular dependency during deserialization
ottml Jun 22, 2025
6ee5628
Increase minor replay version to be able to set the correct initial d…
ottml Jul 27, 2025
d89f4a7
Code review
ottml Oct 14, 2025
57d433c
Code review: Improve unit test
ottml Oct 29, 2025
4d63bed
Code review: Move addon check functions for unused Ware/Jobs/Building…
ottml Oct 29, 2025
a1ce1b5
Code review: Inline functions
ottml Oct 29, 2025
cc14185
Code review: Use CamelCase and rename enum class
ottml Oct 30, 2025
6976123
Code review: Rename IsArmorDisabled to IsArmorAllowed
ottml Oct 30, 2025
5cc7877
Code review: Use consistent cast and parse argument as reference. Rem…
ottml Oct 30, 2025
07f90dc
Code review: Remove Invalid state from enum and throw exception when …
ottml Nov 4, 2025
f65a0ce
Code review: Rename functions, remove auto return type and capture ad…
ottml Nov 4, 2025
a27bdd6
Code review: Add named constants for deserialization code for better …
ottml Nov 4, 2025
af7a7ab
Code review: Use checkedCast
ottml Nov 5, 2025
2c57be8
Code review: Rewrite test and fold 4 cases into one
ottml Nov 5, 2025
614d5a7
Code review: Use switch
ottml Nov 5, 2025
6b83bbd
Code review: Rename variables and change type
ottml Nov 5, 2025
103bd80
Code review: Use constants and rewrite counting of traded soldiers
ottml Nov 5, 2025
31c6599
Code review
ottml Nov 5, 2025
eae56d2
Code review: Use clearer names for varibles
ottml Nov 6, 2025
f48d4d6
Code review: Optimize code
ottml Nov 6, 2025
8d9cd2a
Code review: Use better function names and remove german comment
ottml Dec 7, 2025
f812c3c
Code review: Check for production disabled and use radius instead of …
ottml Dec 7, 2025
e056a56
Code review: Use extra enum for armor icon above soldier
ottml Dec 7, 2025
6e21152
Code review: Use better function names and remove german comment
ottml Dec 7, 2025
76e51eb
Code review use operator instead of member
ottml Dec 10, 2025
ce21e2f
Code review: Add comment to explain scenario
ottml Dec 10, 2025
faa5840
Code review: Handle GoodType::Nothing in save games
ottml Dec 10, 2025
21095f1
Code review: Add comment to clarify no OBB write appears
ottml Dec 10, 2025
93a3aae
Code review: Fix wrong index
ottml Dec 10, 2025
40ebbd2
Code review: Split a PeopleArray from GoodsAndPeopleArray and let the…
ottml Dec 13, 2025
be50c50
Code review: Revert changed parameter name
ottml Dec 13, 2025
877a264
Code review: Cleanup header and remove using instead of direct type
ottml Dec 13, 2025
4fabff0
Code review: Hunter and skinner have same behaviour. Time for hunter …
ottml Dec 13, 2025
be875a5
Code review: Add check to avoid assert
ottml Dec 13, 2025
c58a180
Code review: Add comment about ownership of animal for skinner and hu…
ottml Dec 14, 2025
b683cc4
Code review: Apply patch to remove nofArmored base class not needed a…
ottml Feb 14, 2026
9941395
Code review add comment
ottml Feb 14, 2026
84c6218
Fix after rebase
ottml Feb 14, 2026
dbc0ad9
Code review: Fix formatting
ottml Feb 14, 2026
d5d0bfd
Code review:
ottml Feb 14, 2026
5656c38
Code review: Use access functions instead of direct member access
ottml Feb 15, 2026
e729256
Code review: Revert asserts for Add/Remove armored soldier
ottml Feb 15, 2026
243835f
Code review: Change info text
ottml Feb 15, 2026
27b05be
Code review: Inline function
ottml Feb 15, 2026
c9e213a
Code review: Use access functions instead of direct member access
ottml Feb 15, 2026
4d37057
Code review: Remove write operator[] for armoredSoldier and use direc…
ottml Feb 15, 2026
2013b39
Code review: Use container for Serialize/Deserialize
ottml Feb 15, 2026
b6655ec
Fix crash
ottml Feb 17, 2026
a275f15
Code review: style issues and nitpicks
ottml Feb 17, 2026
af34dd6
Update libs/s25main/buildings/nobMilitary.cpp
ottml Feb 19, 2026
2f74b46
Code review: Add path optimization. See #1785
ottml Feb 19, 2026
773f137
Unify `FindClientForCoin` with `FindClientForArmor`
Flamefire Feb 21, 2026
74e4563
Sort possible clients of coins/armor by estimated priority
Flamefire Feb 21, 2026
0495f38
Revert "Sort possible clients of coins/armor by estimated priority"
Flamefire Feb 21, 2026
3adeb1f
Merge branch 'master' into leather_addon
Flamefire Feb 21, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added data/RTTR/assets/addons/0x01000001/AFR_ICON.LST
Binary file not shown.
Binary file added data/RTTR/assets/addons/0x01000001/AFR_Z.LST
Binary file not shown.
Binary file added data/RTTR/assets/addons/0x01000001/JAP_ICON.LST
Binary file not shown.
Binary file added data/RTTR/assets/addons/0x01000001/JAP_Z.LST
Binary file not shown.
Binary file added data/RTTR/assets/addons/0x01000001/ROM_ICON.LST
Binary file not shown.
Binary file added data/RTTR/assets/addons/0x01000001/ROM_Z.LST
Binary file not shown.
Binary file added data/RTTR/assets/addons/0x01000001/VIK_ICON.LST
Binary file not shown.
Binary file added data/RTTR/assets/addons/0x01000001/VIK_Z.LST
Binary file not shown.
Binary file added data/RTTR/assets/addons/0x01000001/WAFR_Z.LST
Binary file not shown.
Binary file added data/RTTR/assets/addons/0x01000001/WJAP_Z.LST
Binary file not shown.
Binary file added data/RTTR/assets/addons/0x01000001/WROM_Z.LST
Binary file not shown.
Binary file added data/RTTR/assets/addons/0x01000001/WVIK_Z.LST
Binary file not shown.
Binary file added data/RTTR/assets/addons/0x01000001/bab_icon.lst
Binary file not shown.
Binary file added data/RTTR/assets/addons/0x01000001/bab_z.lst
Binary file not shown.
Binary file added data/RTTR/assets/addons/0x01000001/wbab_z.lst
Binary file not shown.
Binary file added data/RTTR/assets/base/leather_bobs.lst
Binary file not shown.
57 changes: 57 additions & 0 deletions libs/s25main/AddonHelperFunctions.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// Copyright (C) 2005 - 2025 Settlers Freaks (sf-team at siedler25.org)
//
// SPDX-License-Identifier: GPL-2.0-or-later

#include "AddonHelperFunctions.h"
#include "GlobalGameSettings.h"
#include <LeatherLoader.h>
#include <WineLoader.h>
#include <addons/Addon.h>

std::function<bool(const BuildingType type)> makeIsUnusedBuilding(const GlobalGameSettings& ggs)
{
const bool wineAddonActive = ggs.isEnabled(AddonId::WINE);
const bool charburnerAddonActive = ggs.isEnabled(AddonId::CHARBURNER);
const bool leatherAddonActive = ggs.isEnabled(AddonId::LEATHER);

return [wineAddonActive, charburnerAddonActive, leatherAddonActive](BuildingType const& bld) {
if(!wineAddonActive && wineaddon::isWineAddonBuildingType(bld))
return true;
if(!charburnerAddonActive && bld == BuildingType::Charburner)
return true;
if(!leatherAddonActive && leatheraddon::isLeatherAddonBuildingType(bld))
return true;
return false;
};
}

std::function<bool(const GoodType type)> makeIsUnusedWare(const GlobalGameSettings& ggs)
{
const bool wineAddonActive = ggs.isEnabled(AddonId::WINE);
const bool leatherAddonActive = ggs.isEnabled(AddonId::LEATHER);

return [wineAddonActive, leatherAddonActive](GoodType const& type) {
if(!wineAddonActive && wineaddon::isWineAddonGoodType(type))
return true;
if(!leatherAddonActive && leatheraddon::isLeatherAddonGoodType(type))
return true;
return false;
};
}

std::function<bool(const Job job)> makeIsUnusedJob(const GlobalGameSettings& ggs)
{
const bool wineAddonActive = ggs.isEnabled(AddonId::WINE);
const bool charburnerAddonActive = ggs.isEnabled(AddonId::CHARBURNER);
const bool leatherAddonActive = ggs.isEnabled(AddonId::LEATHER);

return [wineAddonActive, charburnerAddonActive, leatherAddonActive](Job const& job) {
if(!wineAddonActive && wineaddon::isWineAddonJobType(job))
return true;
if(!charburnerAddonActive && job == Job::CharBurner)
return true;
if(!leatherAddonActive && leatheraddon::isLeatherAddonJobType(job))
return true;
return false;
};
}
31 changes: 31 additions & 0 deletions libs/s25main/AddonHelperFunctions.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Copyright (C) 2005 - 2025 Settlers Freaks (sf-team at siedler25.org)
//
// SPDX-License-Identifier: GPL-2.0-or-later

#pragma once

#include "gameTypes/BuildingType.h"
#include "gameTypes/GoodTypes.h"
#include "gameTypes/JobTypes.h"
#include <functional>

class GlobalGameSettings;

std::function<bool(const BuildingType type)> makeIsUnusedBuilding(const GlobalGameSettings& ggs);
std::function<bool(const GoodType type)> makeIsUnusedWare(const GlobalGameSettings& ggs);
std::function<bool(const Job job)> makeIsUnusedJob(const GlobalGameSettings& ggs);

// Only used for deserialization, can be removed when breaking compatibility (GetGameDataVersion)
constexpr auto numLeatherAddonBuildings = 3u;
constexpr auto numWineAddonBuildings = 3u;
constexpr auto numWineAndLeatherAddonBuildings = numWineAddonBuildings + numLeatherAddonBuildings;

constexpr auto numLeatherAddonGoods = 3u;
constexpr auto numWineAddonGoods = 2u;
constexpr auto numWineAndLeatherAddonGoods = numWineAddonGoods + numLeatherAddonGoods;

constexpr auto numLeatherAddonJobs = 3u;
constexpr auto numWineAddonJobs = 3u;
constexpr auto numWineAndLeatherAddonJobs = numWineAddonJobs + numLeatherAddonJobs;

constexpr uint8_t transportPrioOfLeatherworks = 7;
4 changes: 4 additions & 0 deletions libs/s25main/BuildingRegister.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// SPDX-License-Identifier: GPL-2.0-or-later

#include "BuildingRegister.h"
#include "LeatherLoader.h"
#include "SerializedGameData.h"
#include "WineLoader.h"
#include "buildings/noBuildingSite.h"
Expand Down Expand Up @@ -41,6 +42,9 @@ void BuildingRegister::Deserialize(SerializedGameData& sgd)
if(sgd.GetGameDataVersion() < 11 && wineaddon::isWineAddonBuildingType(bld))
continue;

if(sgd.GetGameDataVersion() < 12 && leatheraddon::isLeatherAddonBuildingType(bld))
continue;

if(BuildingProperties::IsUsual(bld))
sgd.PopObjectContainer(buildings[bld], GO_Type::NobUsual);
}
Expand Down
5 changes: 4 additions & 1 deletion libs/s25main/GameCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ namespace gc {
unsigned Deserializer::getCurrentVersion()
{
// 1: Add wine addon --> 3 new values in distribution
return 1;
// 2: Add leather addon --> 3 new values in distribution, 1 new value in transport order and transport order default
// values changed, 3 new values in custom build order, 3 new jobs/wares in setAllInventory settings
return 2;
}

GameCommandPtr GameCommand::Deserialize(Deserializer& ser)
Expand All @@ -37,6 +39,7 @@ GameCommandPtr GameCommand::Deserialize(Deserializer& ser)
case GCType::Attack: gc = new Attack(ser); break;
case GCType::SeaAttack: gc = new SeaAttack(ser); break;
case GCType::SetCoinsAllowed: gc = new SetCoinsAllowed(ser); break;
case GCType::SetArmorAllowed: gc = new SetArmorAllowed(ser); break;
case GCType::SetProductionEnabled: gc = new SetProductionEnabled(ser); break;
case GCType::SetInventorySetting: gc = new SetInventorySetting(ser); break;
case GCType::SetAllInventorySettings: gc = new SetAllInventorySettings(ser); break;
Expand Down
3 changes: 2 additions & 1 deletion libs/s25main/GameCommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,11 @@ enum class GCType : uint8_t
SetTroopLimit,
NotifyAlliesOfLocation,
SetTempleProductionMode,
SetArmorAllowed,
};
constexpr auto maxEnumValue(GCType)
{
return GCType::SetTempleProductionMode;
return GCType::SetArmorAllowed;
}

class GameCommand
Expand Down
143 changes: 136 additions & 7 deletions libs/s25main/GameCommands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
// SPDX-License-Identifier: GPL-2.0-or-later

#include "GameCommands.h"
#include "AddonHelperFunctions.h"
#include "GamePlayer.h"
#include "LeatherLoader.h"
#include "WineLoader.h"
#include "buildings/nobBaseWarehouse.h"
#include "buildings/nobHarborBuilding.h"
Expand All @@ -16,6 +18,7 @@
#include "world/GameWorld.h"
#include "nodeObjs/noFlag.h"
#include "nodeObjs/noShip.h"
#include "gameData/SettingTypeConv.h"
#include <algorithm>
#include <stdexcept>

Expand Down Expand Up @@ -90,19 +93,43 @@ void UpgradeRoad::Execute(GameWorld& world, uint8_t playerId)

ChangeDistribution::ChangeDistribution(Deserializer& ser) : GameCommand(GCType::ChangeDistribution)
{
if(ser.getDataVersion() >= 1)
if(ser.getDataVersion() >= 2)
helpers::popContainer(ser, data);
else
{
std::array<Distributions::value_type,
std::tuple_size_v<Distributions> - 3> tmpData; // 3 entries for wine addon
helpers::popContainer(ser, tmpData);
const unsigned wineAddonAdditionalDistributions = 3;
const unsigned leatherAddonAdditionalDistributions = 3;

auto const numNotSavedDistributions =
leatherAddonAdditionalDistributions + (ser.getDataVersion() < 1 ? wineAddonAdditionalDistributions : 0);

std::vector<Distributions::value_type> tmpData(std::tuple_size_v<Distributions> - numNotSavedDistributions);

auto getSkipBuildingAndDefault = [&](DistributionMapping const& mapping) {
// Skipped and standard distribution in skipped case
std::tuple<bool, unsigned int> result = {false, 0};
if(ser.getDataVersion() < 1)
{
// skip over wine buildings
std::get<0>(result) |= wineaddon::isWineAddonBuildingType(std::get<BuildingType>(mapping));
}

// skip over leather addon buildings and leather addon wares only
std::get<0>(result) |= leatheraddon::isLeatherAddonBuildingType(std::get<BuildingType>(mapping));

if(std::get<BuildingType>(mapping) == BuildingType::Slaughterhouse
&& (std::get<GoodType>(mapping) == GoodType::Ham))
result = {true, 8};
return result;
};

helpers::popContainer(ser, tmpData, true);
size_t srcIdx = 0, tgtIdx = 0;
for(const auto& mapping : distributionMap)
{
// skip over wine buildings in tmpData
const auto setting =
wineaddon::isWineAddonBuildingType(std::get<BuildingType>(mapping)) ? 0 : tmpData[srcIdx++];
// skip over not stored buildings in tmpData
const auto [skipped, defaultValue] = getSkipBuildingAndDefault(mapping);
const auto setting = skipped ? defaultValue : tmpData[srcIdx++];
data[tgtIdx++] = setting;
}
}
Expand All @@ -113,6 +140,35 @@ void ChangeDistribution::Execute(GameWorld& world, uint8_t playerId)
world.GetPlayer(playerId).ChangeDistribution(data);
}

ChangeBuildOrder::ChangeBuildOrder(Deserializer& ser)
: GameCommand(GCType::ChangeBuildOrder), useCustomBuildOrder(ser.PopBool())
{
if(ser.getDataVersion() >= 2)
{
for(BuildingType& i : data)
i = helpers::popEnum<BuildingType>(ser);
} else
{
auto countOfNotAvailableBuildingsInSaveGame =
ser.getDataVersion() < 1 ? numWineAndLeatherAddonBuildings : numLeatherAddonBuildings;
std::vector<BuildingType> buildOrder(data.size() - countOfNotAvailableBuildingsInSaveGame);

if(ser.getDataVersion() < 1)
buildOrder.insert(buildOrder.end(), {BuildingType::Vineyard, BuildingType::Winery, BuildingType::Temple});

if(ser.getDataVersion() < 2)
{
buildOrder.insert(buildOrder.end(),
{BuildingType::Skinner, BuildingType::Tannery, BuildingType::LeatherWorks});
Comment thread
ottml marked this conversation as resolved.
}

std::generate(buildOrder.begin(), buildOrder.end() - countOfNotAvailableBuildingsInSaveGame,
[&]() { return helpers::popEnum<BuildingType>(ser); });

std::copy(buildOrder.begin(), buildOrder.end(), data.begin());
}
}

void ChangeBuildOrder::Execute(GameWorld& world, uint8_t playerId)
{
world.GetPlayer(playerId).ChangeBuildOrder(useCustomBuildOrder, data);
Expand All @@ -128,6 +184,27 @@ void DestroyBuilding::Execute(GameWorld& world, uint8_t playerId)
world.DestroyBuilding(pt_, playerId);
}

ChangeTransport::ChangeTransport(Deserializer& ser) : GameCommand(GCType::ChangeTransport)
{
if(ser.getDataVersion() >= 2)
helpers::popContainer(ser, data);
else
{
const unsigned leatherAddonAdditionalTransportOrders = 1;
std::vector<TransportOrders::value_type> tmpData(std::tuple_size<TransportOrders>::value
- leatherAddonAdditionalTransportOrders);

helpers::popContainer(ser, tmpData, true);
std::copy(tmpData.begin(), tmpData.end(), data.begin());
// all transport prios greater equal transportPrioOfLeatherworks are increased by one because the new
// leatherwork uses prio transportPrioOfLeatherworks
std::transform(data.begin(), data.end() - leatherAddonAdditionalTransportOrders, data.begin(),
[](uint8_t& prio) { return prio < transportPrioOfLeatherworks ? prio : prio + 1; });
data[std::tuple_size<TransportOrders>::value - leatherAddonAdditionalTransportOrders] =
STD_TRANSPORT_PRIO[GoodType::Leather];
}
}

void ChangeTransport::Execute(GameWorld& world, uint8_t playerId)
{
world.GetPlayer(playerId).ConvertTransportData(data);
Expand Down Expand Up @@ -172,6 +249,13 @@ void SetCoinsAllowed::Execute(GameWorld& world, uint8_t playerId)
bld->SetCoinsAllowed(enabled);
}

void SetArmorAllowed::Execute(GameWorld& world, uint8_t playerId)
{
auto* const bld = world.GetSpecObj<nobMilitary>(pt_);
if(bld && bld->GetPlayer() == playerId)
bld->SetArmorAllowed(enabled);
}

void SetTroopLimit::Execute(GameWorld& world, uint8_t playerId)
{
auto* const bld = world.GetSpecObj<nobMilitary>(pt_);
Expand All @@ -193,6 +277,51 @@ void SetInventorySetting::Execute(GameWorld& world, uint8_t playerId)
bld->SetInventorySetting(what, state);
}

SetAllInventorySettings::SetAllInventorySettings(Deserializer& ser)
: Coords(GCType::SetAllInventorySettings, ser), isJob(ser.PopBool())
{
const uint32_t numStates = (isJob ? helpers::NumEnumValues_v<Job> : helpers::NumEnumValues_v<GoodType>);
if(ser.getDataVersion() >= 2)
{
for(unsigned i = 0; i < numStates; i++)
states.push_back(InventorySetting(ser.PopUnsignedChar()));
} else
{
states.resize(numStates);
if(isJob)
{
auto isJobSkipped = [&](Job const& job) {
return (ser.getDataVersion() < 1 && wineaddon::isWineAddonJobType(job))
|| leatheraddon::isLeatherAddonJobType(job);
};

size_t tgtIdx = 0;
for(const auto job : helpers::enumRange<Job>())
{
// skip over not stored jobs
if(!isJobSkipped(job))
states[tgtIdx] = InventorySetting(ser.PopUnsignedChar());
tgtIdx++;
}
} else
{
auto isWareSkipped = [&](GoodType const& ware) {
return (ser.getDataVersion() < 1 && wineaddon::isWineAddonGoodType(ware))
|| leatheraddon::isLeatherAddonGoodType(ware);
};

size_t tgtIdx = 0;
for(const auto ware : helpers::enumRange<GoodType>())
{
// skip over not stored wares
if(!isWareSkipped(ware))
states[tgtIdx] = InventorySetting(ser.PopUnsignedChar());
tgtIdx++;
}
}
}
}

void SetAllInventorySettings::Execute(GameWorld& world, uint8_t playerId)
{
auto* const bld = world.GetSpecObj<nobBaseWarehouse>(pt_);
Expand Down
Loading
Loading