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

View File

@ -162,12 +162,27 @@ class GameModeSettings implements ConfiguratorMenu, CallbackListener, Communicat
* @return bool * @return bool
*/ */
public function setGameModeSettingsArray(array $settings) { 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()) { if ($this->maniaControl->getServer()->getScriptManager()->isScriptMode()) {
return $this->maniaControl->getClient()->setModeScriptSettings($settings); return $this->maniaControl->getClient()->setModeScriptSettings($settings);
} else { } else {
$success = true; $success = true;
foreach ($settings as $key => $value) { 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; return $success;
} }