Settings of Legacy-Modes and client-functions have sometimes different names, calls could not be executed, fixed now

This commit is contained in:
Alexander Nell 2020-05-09 21:44:44 +02:00
parent 67c9180f9c
commit 5956bb292d
1 changed files with 16 additions and 1 deletions

View File

@ -162,12 +162,27 @@ class GameModeSettings implements ConfiguratorMenu, CallbackListener, Communicat
* @return bool
*/
public function setGameModeSettingsArray(array $settings) {
static $settingToMethodReplace = array(
'LapsNbLaps' => 'SetNbLaps',
'RoundsForcedLaps' => 'SetRoundForcedLaps',
'RoundsPointsLimit' => 'SetRoundPointsLimit',
'RoundsUseNewRules' => 'SetUseNewRulesRound',
'TeamMaxPoints' => 'SetMaxPointsTeam',
'TeamUseNewRules' => 'SetUseNewRulesTeam',
);
if ($this->maniaControl->getServer()->getScriptManager()->isScriptMode()) {
return $this->maniaControl->getClient()->setModeScriptSettings($settings);
} else {
$success = true;
foreach ($settings as $key => $value) {
$success &= $this->maniaControl->getClient()->execute('Set'.$key, array($value));
if (array_key_exists($key, $settingToMethodReplace)) {
$key = $settingToMethodReplace[$key];
} else {
$key = 'Set'.$key;
}
$success &= $this->maniaControl->getClient()->execute($key, array($value));
}
return $success;
}