Spectator mode broken in studio?

Game development with Board Game Arena Studio
Post Reply
User avatar
quietmint
Posts: 265
Joined: 31 July 2017, 00:28

Spectator mode broken in studio?

Post by quietmint »

I'm trying to test spectator mode in the studio and, as the spectator, I'm getting this PHP notice at the top of the screen (which breaks the game). 2305328 is the player ID of the spectator.
Notice: Undefined offset: 2305328 in /var/tournoi/release/tournoi-170825-1140-gs/www/view/common/game.view.php on line 1087
User avatar
Een
Posts: 3854
Joined: 16 June 2010, 19:52

Re: Spectator mode broken in studio?

Post by Een »

[quote="Een"]Hi,

That's probably because you get some info from the players array in the getAllDatas, such as:

Code: Select all

$result['saloon_left'] = ($result['players'][$current_player_id]['no'] == 1);
One solution is to identify the spectator to one of the players, for example by doing something like:

Code: Select all

$current_player_id = self::getCurrentPlayerId();    // !! We must only return informations visible by this player !!        
        
        // For spectator mode, we identify the viewer to the first player
        $spectator = false;
        if (! array_key_exists($current_player_id, $players)) {
            reset($players);
            $current_player_id = key($players);
            $spectator = true;
            $result['spectator_alias'] = $current_player_id;
        }
Then using the $spectator variable as a condition for not returning some informations if some information should be visible only by a player.
User avatar
quietmint
Posts: 265
Joined: 31 July 2017, 00:28

Re: Spectator mode broken in studio?

Post by quietmint »

That doesn't appear to be the case. Even this function has the problem:

Code: Select all

    protected function getAllDatas()
    {
        return array();
    }
User avatar
Victoria_La
Posts: 620
Joined: 28 December 2015, 20:55

Re: Spectator mode broken in studio?

Post by Victoria_La »

Check setup method
User avatar
quietmint
Posts: 265
Joined: 31 July 2017, 00:28

Re: Spectator mode broken in studio?

Post by quietmint »

I'm not using the current player in setupNewGame, either.
User avatar
fafa-fr
Posts: 383
Joined: 22 December 2013, 21:58

Re: Spectator mode broken in studio?

Post by fafa-fr »

She meant your setup method in your javascript file.
(edit : at least I think so)
User avatar
quietmint
Posts: 265
Joined: 31 July 2017, 00:28

Re: Spectator mode broken in studio?

Post by quietmint »

But the error is coming on PHP side (before JavaScript is even run)
User avatar
Een
Posts: 3854
Joined: 16 June 2010, 19:52

Re: Spectator mode broken in studio?

Post by Een »

Oh, yes. Sorry I looked at this too fast.

It's a collateral effect of a feature under development. I commented out the faulty line for now on the studio to remove that php notice.
Post Reply

Return to “Developers”