Framework problem : undoRestorePoint & getGameStateValue (FIXED)

Game development with Board Game Arena Studio
Post Reply
User avatar
Lunalol
Posts: 584
Joined: 09 October 2016, 23:21

Framework problem : undoRestorePoint & getGameStateValue (FIXED)

Post by Lunalol »

I have recently posted that on BGA dev Discord:
Hi to all, I have a problem with BGA framework :
It seems that function like getGameStateValue($value_label) does not send a query to DB but use a cached version of global table.
After a undoRestorePoint(), it seems that cache is not actualised. Is it a framework bug or do I miss something?
I use this to debug:
  • var_dump($this->getObjectFromDB("SELECT * FROM global WHERE global_id = 51"));
  • var_dump($this->getGameStateValue('activeUnit'));
and two dumped values are differents (of course : 'activeUnit' => 51 for initGameStateLabels).
Problem is solved, I share with you a fix:

It seems that all globals that was NOT initialized with setGameStateInitialValue($value_label,$value_value) are not saved with undoSavepoint() and so, they are not restored with undoRestorePoint().

So, I have inserted that in setupNewGame($players, $options = []):
  • foreach ($this->GAMEOPTIONS as $key => $id) if ($id >= 10 && $id < 90) $this->setGameStateInitialValue($key, 0);
And that in __construct():
  • $this->GAMEOPTIONS = ['Axis' => 10, 'Western' => 11, 'Soviet' => 12, 'cold' => 13, 'mild' => 14, 'warm' => 15, 'desert' => 16, ... ];
  • $this->initGameStateLabels($this->GAMEOPTIONS);
Hope that could help someone.
Post Reply

Return to “Developers”