Skip to content

Fix organisation tech level never increasing (#1587) - #1657

Merged
FilmBoy84 merged 1 commit into
OpenApoc:masterfrom
andremmfaria:fix/1587-org-tech-level-progression
Sep 5, 2026
Merged

Fix organisation tech level never increasing (#1587)#1657
FilmBoy84 merged 1 commit into
OpenApoc:masterfrom
andremmfaria:fix/1587-org-tech-level-progression

Conversation

@andremmfaria

Copy link
Copy Markdown
Contributor

Fixes #1587.

Root cause: Organisation::tech_level is set once by the extractor and never changes at runtime. GameState::updateEndOfWeek has a per-organisation finance loop but nothing for tech level, so every organisation stays at its starting level for the whole game. The original game raises each organisation's tech level by 1 per week, capped at 12.

Fix: in updateEndOfWeek, when not gameStart, increment tech_level for every organisation except player, aliens, and civilian, capped at the highest min_score among Human EquipmentSets (12 with the shipped data) instead of a hardcoded constant. The separate "+3 on full infiltration" rule is not part of this change.

Verification

  • Pre-fix headless harness: all 25 non-exempt organisations unchanged after a week (ORG_CULT_OF_SIRIUS tech_level 2 -> 2, expected 3).
  • Post-fix: weekly +1 with exemptions, cap holds at and beyond the derived value, gameStart week leaves levels untouched.
  • Full ctest green (RelWithDebInfo, Linux); fork CI Lint + CMake green.

Harness core in the comment below.

Increment each non-player/alien/civilian organisation's tech_level by
1 in GameState::updateEndOfWeek, guarded by !gameStart, matching the
weekly upgrade rule described for the original game.

Cap derived from the loaded Human EquipmentSet data (highest
min_score) rather than a hardcoded constant, so it tracks the
extractor's equipment-set brackets.

Fixes OpenApoc#1587
@andremmfaria

andremmfaria commented Sep 3, 2026

Copy link
Copy Markdown
Contributor Author

Temporary harness used for the before/after check (not committed). Loads difficulty0 like test_lab_assignment and runs one real weekly tick:

int maxOrgTechLevel = 1;
for (auto &es : state->equipment_sets)
	if (es.second->type == EquipmentSet::Type::Human)
		maxOrgTechLevel = std::max(maxOrgTechLevel, es.second->min_score);

std::map<UString, int> before;
for (auto &org : state->organisations)
	before[org.first] = org.second->tech_level;
state->updateEndOfWeek(false);
for (auto &org : state->organisations)
{
	bool exempt = org.first == state->getPlayer().id || org.first == state->getAliens().id ||
	              org.first == state->getCivilian().id;
	int expected = exempt ? before[org.first] : std::min(before[org.first] + 1, maxOrgTechLevel);
	assert(org.second->tech_level == expected);
}
assert(EquipmentSet::getForType(*state, EquipmentSet::Type::Human, maxOrgTechLevel));
assert(EquipmentSet::getForType(*state, EquipmentSet::Type::Human, maxOrgTechLevel + 5));

for (auto &org : state->organisations) before[org.first] = org.second->tech_level;
state->updateEndOfWeek(true);
for (auto &org : state->organisations)
	assert(org.second->tech_level == before[org.first]);

Pre-fix (727cd974):

E Org 'ORG_CULT_OF_SIRIUS' tech_level 2 -> 2, expected 3
E Weekly increment test failed

Post-fix (b69d29a3): all checks pass, derived cap = 12.

@FilmBoy84

Copy link
Copy Markdown
Collaborator

Really nice catch!
Will be great to have organisation tech advancing once more
Thanks as always 🍻

@FilmBoy84
FilmBoy84 merged commit 9c8dc3b into OpenApoc:master Sep 5, 2026
3 checks passed
@andremmfaria
andremmfaria deleted the fix/1587-org-tech-level-progression branch September 5, 2026 21:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Org Tech level does not improve

2 participants