RESOLVED - Incorrect error: Impossible to change active player during activeplayer type state

Game development with Board Game Arena Studio
Post Reply
User avatar
i_a_green
Posts: 7
Joined: 31 March 2020, 22:04

RESOLVED - Incorrect error: Impossible to change active player during activeplayer type state

Post by i_a_green »

Hi

I'm developing Templari, and it's all been going great, but I made a bunch of changes to add a variant and now I'm getting the following error:

Code: Select all

Impossible to change active player during activeplayer type state
But it isn't being thrown during an 'activeplayer' state!

Log snippet:

Code: Select all

25/09 21:50:40 [error] [T300095] [84.92.58.162] [2336003/HappyCuttlefish1] Unexpected exception: Impossible to change active player during activeplayer type state#
#0 /var/tournoi/release/games/templari/999999-9999/templari.game.php(751): Gamestate->changeActivePlayer('2336002')#
#1 /var/tournoi/release/tournoi-210922-1031-gs/www/game/module/table/gamestate.game.php(469): Templari->stCardSawpCleanUp()#
#2 /var/tournoi/release/tournoi-210922-1031-gs/www/game/module/table/gamestate.game.php(365): Gamestate->jumpToState(33)#
#3 /var/tournoi/release/games/templari/999999-9999/templari.game.php(558): Gamestate->nextState('cleanOrDraw')#
#4 /var/tournoi/release/tournoi-210922-1031-gs/www/game/module/table/gamestate.game.php(469): Templari->stPreAuctionChoiceNext()#
#5 /var/tournoi/release/tournoi-210922-1031-gs/www/game/module/table/gamestate.game.php(365): Gamestate->jumpToState(32)#
#6 /var/tournoi/release/games/templari/999999-9999/templari.game.php(413): Gamestate->nextState('cardSwapChoiceN...')#
#7 /var/tournoi/release/games/templari/999999-9999/templari.action.php(78): Templari->cardSwapSelect('4', '18')#
#8 /var/tournoi/release/tournoi-210922-1031-gs/www/include/webActionCore.inc.php(189): action_templari->cardSwapSelect()#
#9 /var/tournoi/release/tournoi-210922-1031-gs/www/index.php(259): launchWebAction('templari', 'action_templari', 'cardSwapSelect', false, false, NULL, true, false)#
#10 {main}h
Relevant states:

Code: Select all

    32 => array(
        "name" => "cardSawpChoiceNext",
        "description" => "",
        "type" => "game",
        "action" => "stPreAuctionChoiceNext",
        "transitions" => array( "preAuctionChoice" => 31, "cleanOrDraw" => 33 )
    ),
    33 => array(
        "name" => "cardSawpCleanUp",
        "description" => "",
        "type" => "game",
        "action" => "stCardSawpCleanUp",
        "transitions" => array( "cardSwapPrep" => 30, "mainAuctionDraw" => 50, "finalScoring" => 90 )
    ),

So as you can see:
state 33 (and 32) are 'game' states
stCardSawpCleanUp is the action of state 33

This is the only place stCardSawpCleanUp is called, and therefore the only way line 751 is used.

I'm obviously missing something, has anyone seen this before? any help would be appreciated.
Last edited by i_a_green on 26 September 2021, 00:22, edited 1 time in total.
User avatar
robinzig
Posts: 459
Joined: 11 February 2021, 18:23

Re: Incorrect error: Impossible to change active player during activeplayer type state

Post by robinzig »

Can you share the content of stCardSawpCleanUp? Or at least the relevant parts if it's long.

Are you sure you're not transitioning to the new activeplayer state before you call changeActivePlayer?
User avatar
JonChambers
Posts: 97
Joined: 03 July 2021, 11:40

Re: Incorrect error: Impossible to change active player during activeplayer type state

Post by JonChambers »

My go to is "Are you suuuuuuure you haven't visited an active state along the way?"

I had a similar issue pulling my hair out on the sheer impossibility of it executing outside of the correct state.

Turns out, I used the dojo connect method on the same object more than once. So clicking it had the effect of double clicking it. This made the game run as normal but then throw errors for every extra connection.

Just before the change, get it to throw an error reporting which state it's in. That should isolate the problem a fair way. Knowing WHICH active state it's in will help narrow it down.
User avatar
i_a_green
Posts: 7
Joined: 31 March 2020, 22:04

Re: Incorrect error: Impossible to change active player during activeplayer type state

Post by i_a_green »

So I went to copy the code, did a quick sanity check and spotted the problem. Always the way.

I was calling another method which changed the state, but then it returned back to stCardSawpCleanUp() and I tried to change the active player.

I was for some stupid reason assuming that changing state also functioned like a break.

I had something like this where resolveMainAuction() does a state change, I have now wrapped the trailing lines in an else block.

Code: Select all

        if (count($remaining_players) == 0 ) {
            ...
            $this->resolveMainAuction($currentPlayer);
        
        } else if (count($remaining_players) == 1 ) {
            ...
            $this->resolveMainAuction($currentPlayer);
        }

       ...

        $this->gamestate->changeActivePlayer( $currentPlayer );

        $this->gamestate->nextState( 'mainAuctionDraw' );

Thanks for the help, before you questioned it I was 100% sure I wasn't changing state before calling changeActivePlayer.
Post Reply

Return to “Developers”