drastic speedup through multicalls
This commit is contained in:
parent
5d6f8d047c
commit
e5c7fdbf6b
@ -252,10 +252,19 @@ class CallbackManager implements UsageInformationAble {
|
||||
$timings[$key] = array($callback[0], microtime(true) - $time1);
|
||||
}
|
||||
|
||||
//Execute Multicalls
|
||||
$this->maniaControl->getClient()->executeMulticall();
|
||||
|
||||
$fullTime = microtime(true) - $startTime;
|
||||
|
||||
if ($fullTime > ErrorHandler::LONG_LOOP_REPORT_TIME) {
|
||||
$this->maniaControl->getErrorHandler()->triggerDebugNotice(json_encode(array("Long Loop Detected: " . $fullTime, $timings)));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -72,12 +72,11 @@ class Chat implements CallbackListener, CommunicationListener, UsageInformationA
|
||||
* @param string $message
|
||||
* @param string $login
|
||||
* @param string|bool $prefix
|
||||
* @param bool $multiCall
|
||||
* @return bool
|
||||
*/
|
||||
public function sendInformation($message, $login = null, $prefix = true, $multiCall = false) {
|
||||
public function sendInformation($message, $login = null, $prefix = true) {
|
||||
$format = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_FORMAT_INFORMATION);
|
||||
return $this->sendChat($format . $message, $login, $prefix, $multiCall);
|
||||
return $this->sendChat($format . $message, $login, $prefix);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -86,10 +85,9 @@ class Chat implements CallbackListener, CommunicationListener, UsageInformationA
|
||||
* @param string $message
|
||||
* @param string $login
|
||||
* @param string|bool $prefix
|
||||
* @param bool $multiCall
|
||||
* @return bool
|
||||
*/
|
||||
public function sendChat($message, $login = null, $prefix = true, $multiCall = false) {
|
||||
public function sendChat($message, $login = null, $prefix = true) {
|
||||
if (!$this->maniaControl->getClient()) {
|
||||
return false;
|
||||
}
|
||||
@ -102,13 +100,13 @@ class Chat implements CallbackListener, CommunicationListener, UsageInformationA
|
||||
$login = Player::parseLogin($login);
|
||||
}
|
||||
try {
|
||||
return $this->maniaControl->getClient()->chatSendServerMessage($chatMessage, $login, $multiCall);
|
||||
return $this->maniaControl->getClient()->chatSendServerMessage($chatMessage, $login, true);
|
||||
} catch (UnknownPlayerException $e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->maniaControl->getClient()->chatSendServerMessage($chatMessage, null, $multiCall);
|
||||
return $this->maniaControl->getClient()->chatSendServerMessage($chatMessage, null, true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -241,13 +241,13 @@ class ManialinkManager implements ManialinkPageAnswerListener, CallbackListener,
|
||||
|
||||
try {
|
||||
if (!$logins) {
|
||||
return $this->maniaControl->getClient()->sendDisplayManialinkPage(null, $manialinkText, $timeout, $hideOnClick);
|
||||
return $this->maniaControl->getClient()->sendDisplayManialinkPage(null, $manialinkText, $timeout, $hideOnClick, true);
|
||||
}
|
||||
if (is_string($logins)) {
|
||||
return $this->maniaControl->getClient()->sendDisplayManialinkPage($logins, $manialinkText, $timeout, $hideOnClick);
|
||||
return $this->maniaControl->getClient()->sendDisplayManialinkPage($logins, $manialinkText, $timeout, $hideOnClick, true);
|
||||
}
|
||||
if ($logins instanceof Player) {
|
||||
return $this->maniaControl->getClient()->sendDisplayManialinkPage($logins->login, $manialinkText, $timeout, $hideOnClick);
|
||||
return $this->maniaControl->getClient()->sendDisplayManialinkPage($logins->login, $manialinkText, $timeout, $hideOnClick, true);
|
||||
}
|
||||
if (is_array($logins)) {
|
||||
$loginList = array();
|
||||
@ -258,7 +258,7 @@ class ManialinkManager implements ManialinkPageAnswerListener, CallbackListener,
|
||||
$loginList[] = $login;
|
||||
}
|
||||
}
|
||||
return $this->maniaControl->getClient()->sendDisplayManialinkPage(implode(',', $loginList), $manialinkText, $timeout, $hideOnClick);
|
||||
return $this->maniaControl->getClient()->sendDisplayManialinkPage(implode(',', $loginList), $manialinkText, $timeout, $hideOnClick, true);
|
||||
}
|
||||
} catch (UnknownPlayerException $e) {
|
||||
return false;
|
||||
|
@ -410,7 +410,7 @@ class MapQueue implements CallbackListener, CommandListener, UsageInformationAbl
|
||||
}
|
||||
|
||||
try {
|
||||
$this->maniaControl->getClient()->setNextMapIdent($map->uid);
|
||||
$this->maniaControl->getClient()->setNextMapIdent($map->uid, true);
|
||||
} catch (NextMapException $e) {
|
||||
} catch (NotInListException $e) {
|
||||
}
|
||||
|
@ -533,14 +533,14 @@ class ModeScriptEventManager implements UsageInformationAble {
|
||||
* @param string $data
|
||||
*/
|
||||
public function triggerModeScriptEvent($eventName, $data = '') {
|
||||
try {
|
||||
$this->maniaControl->getClient()->triggerModeScriptEvent($eventName, $data);
|
||||
} catch (GameModeException $e) {
|
||||
if ($e->getMessage() != 'Not in script mode.') {
|
||||
throw $e;
|
||||
$this->maniaControl->getClient()->triggerModeScriptEvent($eventName, $data, function ($exception) use ($eventName) {
|
||||
if ($exception instanceof GameModeException) {
|
||||
if ($exception->getMessage() != 'Not in script mode.') {
|
||||
throw $exception;
|
||||
}
|
||||
Logger::logWarning($eventName . " can't be triggered because you are not in Scriptmode, start your server in Scriptmode!");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -185,7 +185,7 @@ class CustomVotesPlugin implements SidebarMenuEntryRenderable, CommandListener,
|
||||
$ratioArray[] = new VoteRatio(VoteRatio::COMMAND_TEAM_BALANCE, -1.);
|
||||
$ratioArray[] = new VoteRatio(VoteRatio::COMMAND_NEXT_MAP, -1.);
|
||||
|
||||
$this->maniaControl->getClient()->setCallVoteRatios($ratioArray, false);
|
||||
$this->maniaControl->getClient()->setCallVoteRatios($ratioArray, false, true);
|
||||
|
||||
$this->constructMenu();
|
||||
return true;
|
||||
|
@ -290,9 +290,8 @@ class ServerRankingPlugin implements Plugin, CallbackListener, CommandListener {
|
||||
* Shows the serverRank to a certain Player
|
||||
*
|
||||
* @param Player $player
|
||||
* @param $multiCall
|
||||
*/
|
||||
public function showRank(Player $player, $multiCall = false) {
|
||||
public function showRank(Player $player) {
|
||||
$rankObj = $this->getRank($player);
|
||||
|
||||
$type = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_RANKING_TYPE);
|
||||
@ -326,7 +325,7 @@ class ServerRankingPlugin implements Plugin, CallbackListener, CommandListener {
|
||||
$message = '$0f3 You need $<$fff' . $minRecords . '$> Records on this server before receiving a rank...';
|
||||
}
|
||||
}
|
||||
$this->maniaControl->getChat()->sendChat($message, $player, $multiCall);
|
||||
$this->maniaControl->getChat()->sendChat($message, $player);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -360,10 +359,9 @@ class ServerRankingPlugin implements Plugin, CallbackListener, CommandListener {
|
||||
* Show which Player is next ranked to you
|
||||
*
|
||||
* @param Player $player
|
||||
* @param bool $multiCall
|
||||
* @return bool
|
||||
*/
|
||||
public function showNextRank(Player $player, $multiCall = false) {
|
||||
public function showNextRank(Player $player) {
|
||||
$rankObject = $this->getRank($player);
|
||||
if (!$rankObject) {
|
||||
return false;
|
||||
@ -382,7 +380,7 @@ class ServerRankingPlugin implements Plugin, CallbackListener, CommandListener {
|
||||
} else {
|
||||
$message = '$0f3No better ranked player.';
|
||||
}
|
||||
$this->maniaControl->getChat()->sendChat($message, $player, $multiCall);
|
||||
$this->maniaControl->getChat()->sendChat($message, $player);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -429,13 +427,10 @@ class ServerRankingPlugin implements Plugin, CallbackListener, CommandListener {
|
||||
continue;
|
||||
}
|
||||
//TODO combine the following to message to one (saves half of calls)
|
||||
$this->showRank($player, true);
|
||||
$this->showNextRank($player, true);
|
||||
$this->showRank($player);
|
||||
$this->showNextRank($player);
|
||||
}
|
||||
|
||||
//Execute as a MultiCall
|
||||
$this->maniaControl->getClient()->executeMulticall();
|
||||
|
||||
// Trigger callback
|
||||
$this->maniaControl->getCallbackManager()->triggerCallback(self::CB_RANK_BUILT);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user