Repository navigation
Conversation
Replace the single delegated BAI pointer with a per-BattleID map so simultaneous neutral battles each keep their own BAI instance. - Add getBattleAI() with explicit errors for unknown BattleIDs - Reject duplicate battleStart for the same BattleID - Erase only the ended battle in battleEnd() - Extract createDelegatedBAI() to preserve fallback and NN paths Co-authored-by: Dmitry Starkov <starkdmi@users.noreply.github.com>
Introduce MMAI_router_test with mock BAI instances verifying that callbacks are routed by BattleID, battleEnd cleanup is isolated, and invalid/duplicate BattleIDs fail with clear errors. Co-authored-by: Dmitry Starkov <starkdmi@users.noreply.github.com>
Resolve Router conflicts by keeping per-BattleID routing while adopting develop's logging (logtag/basetag), siege model keys, and BAI factory. Store logtag per battle so concurrent model versions do not overwrite each other. Adjust MMAI_router_test for the OBJECT-library layout. Co-authored-by: Dmitry Starkov <starkdmi@users.noreply.github.com>
MMAI is an OBJECT library on develop, so the router test cannot link MMAI/vcmiMain objects directly. Defer creating MMAI_router_test until the facade exists and link libvcmi instead. Co-authored-by: Dmitry Starkov <starkdmi@users.noreply.github.com>
Stop throwing on unknown BattleIDs in callback paths so a post-battleEnd event cannot abort the host; log the missing ID and leave other battles alone. Keep duplicate battleStart as an invariant failure. Use per-battle log tags locally instead of mutating Router-wide logtag. Strengthen routing tests to assert full event traces, no cross-talk after end, and empty Router state when both battles finish. Co-authored-by: Dmitry Starkov <starkdmi@users.noreply.github.com>
The test factory member was gated on ENABLE_MMAI_TEST only in MMAI,
so AIFactory's make_shared<Router>() allocated a smaller object than the
MMAI constructor wrote. Always declare the factory hook on Router and
stop defining ENABLE_MMAI_TEST on the MMAI target.
Add a factory construction regression test via createBattleAI("MMAI").
Co-authored-by: Dmitry Starkov <starkdmi@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes a host crash when multiple human players fight separate neutral armies concurrently during simultaneous turns with MMAI as the neutral combat AI.
This branch includes
origin/developwith the Router fix forward-ported.Root cause:
MMAI::BAI::Routerstored a singlebaipointer. Starting battle B overwrote battle A's delegated BAI, so later callbacks for battle A were delivered to BAI(B).Fix
BattleIDmap of delegated BAI instances.withBattle().battleEnd(bid)delegates, then erases only that battle.battleStart(bid)is an invariant failure.battleEndpaths log the requested and active IDs and return.Routerclass layout is identical in every TU (test factory hook is always present).ENABLE_MMAI_TESTis no longer a compile definition on the MMAI library, soAIFactory::createBattleAI("MMAI")cannot allocate the wrong size.Tests
MMAI_router_test(8 cases): sequential traces, concurrent isolation, both end orders, unknown ID isolation, post-end isolation, duplicatebattleStart, and factory construction viaAIFactory::createBattleAI("MMAI").cmake --build build --target MMAI_router_test ./build/MMAI_router_test # 8/8 passedCompatibility
Host-only MMAI Router change. No network/save/protocol changes.