Load the author nickname of a map when the author is known

This commit is contained in:
Beu 2022-03-12 19:34:39 +01:00
parent b4228a19c8
commit d5faaf57ff
2 changed files with 17 additions and 3 deletions

View File

@ -8,6 +8,8 @@ use ManiaControl\General\UsageInformationAble;
use ManiaControl\General\UsageInformationTrait; use ManiaControl\General\UsageInformationTrait;
use ManiaControl\ManiaExchange\MXMapInfo; use ManiaControl\ManiaExchange\MXMapInfo;
use ManiaControl\Utils\Formatter; use ManiaControl\Utils\Formatter;
use ManiaControl\ManiaControl;
use ManiaControl\Players\Player;
/** /**
* ManiaControl Map Model Class * ManiaControl Map Model Class
@ -52,12 +54,19 @@ class Map implements Dumpable, UsageInformationAble {
public $lastUpdate = 0; public $lastUpdate = 0;
public $karma = null; public $karma = null;
/*
* Private properties
*/
/** @var ManiaControl $maniaControl */
private $maniaControl = null;
/** /**
* Construct a new map instance from xmlrpc data * Construct a new map instance from xmlrpc data
* *
* @param \Maniaplanet\DedicatedServer\Structures\Map $mpMap * @param \Maniaplanet\DedicatedServer\Structures\Map $mpMap
*/ */
public function __construct($mpMap = null) { public function __construct(ManiaControl $maniaControl, $mpMap = null) {
$this->maniaControl = $maniaControl;
$this->startTime = time(); $this->startTime = time();
if (!$mpMap) { if (!$mpMap) {
@ -79,8 +88,13 @@ class Map implements Dumpable, UsageInformationAble {
$this->nbCheckpoints = $mpMap->nbCheckpoints; $this->nbCheckpoints = $mpMap->nbCheckpoints;
$this->nbLaps = $mpMap->nbLaps; $this->nbLaps = $mpMap->nbLaps;
$player = $this->maniaControl->getPlayerManager()->getPlayer($this->authorLogin);
if ($player) {
$this->authorNick = $player->nickname;
} else {
$this->authorNick = $this->authorLogin; $this->authorNick = $this->authorLogin;
} }
}
/** /**
* Get the escaped map name * Get the escaped map name

View File

@ -595,7 +595,7 @@ class MapManager implements CallbackListener, CommunicationListener, UsageInform
* @return Map * @return Map
*/ */
public function initializeMap($rpcMap) { public function initializeMap($rpcMap) {
$map = new Map($rpcMap); $map = new Map($this->maniaControl, $rpcMap);
$this->saveMap($map); $this->saveMap($map);
return $map; return $map;
} }