Framework problem : undoRestorePoint & getGameStateValue (FIXED)
Posted: 30 June 2021, 21:55
I have recently posted that on BGA dev Discord:
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 = []):
Problem is solved, I share with you a fix: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"));
and two dumped values are differents (of course : 'activeUnit' => 51 for initGameStateLabels).
- var_dump($this->getGameStateValue('activeUnit'));
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);
- $this->GAMEOPTIONS = ['Axis' => 10, 'Western' => 11, 'Soviet' => 12, 'cold' => 13, 'mild' => 14, 'warm' => 15, 'desert' => 16, ... ];
- $this->initGameStateLabels($this->GAMEOPTIONS);