Page 1 of 1
Spectator mode broken in studio?
Posted: 26 August 2017, 16:01
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
Re: Spectator mode broken in studio?
Posted: 28 August 2017, 08:31
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.
Re: Spectator mode broken in studio?
Posted: 28 August 2017, 15:03
by quietmint
That doesn't appear to be the case. Even this function has the problem:
Code: Select all
protected function getAllDatas()
{
return array();
}
Re: Spectator mode broken in studio?
Posted: 28 August 2017, 16:20
by Victoria_La
Check setup method
Re: Spectator mode broken in studio?
Posted: 28 August 2017, 19:43
by quietmint
I'm not using the current player in setupNewGame, either.
Re: Spectator mode broken in studio?
Posted: 28 August 2017, 21:48
by fafa-fr
She meant your setup method in your javascript file.
(edit : at least I think so)
Re: Spectator mode broken in studio?
Posted: 28 August 2017, 23:33
by quietmint
But the error is coming on PHP side (before JavaScript is even run)
Re: Spectator mode broken in studio?
Posted: 29 August 2017, 08:42
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.