improved playerhandler

This commit is contained in:
kremsy 2013-11-09 21:35:43 +01:00
parent ced25e8ebe
commit 722e2fa695
5 changed files with 84 additions and 654 deletions

View File

@ -26,7 +26,7 @@
<file leaf-file-name="player.php" pinned="false" current="false" current-in-tab="false"> <file leaf-file-name="player.php" pinned="false" current="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/core/player.php"> <entry file="file://$PROJECT_DIR$/core/player.php">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state line="26" column="23" selection-start="417" selection-end="417" vertical-scroll-proportion="-17.0" vertical-offset="0" max-vertical-offset="11577"> <state line="83" column="27" selection-start="2805" selection-end="2805" vertical-scroll-proportion="-4.6578946" vertical-offset="1057" max-vertical-offset="1853">
<folding> <folding>
<element signature="e#6#85#0" expanded="true" /> <element signature="e#6#85#0" expanded="true" />
</folding> </folding>
@ -34,19 +34,19 @@
</provider> </provider>
</entry> </entry>
</file> </file>
<file leaf-file-name="playerHandler.php" pinned="false" current="false" current-in-tab="false"> <file leaf-file-name="playerHandler.php" pinned="false" current="true" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/core/playerHandler.php"> <entry file="file://$PROJECT_DIR$/core/playerHandler.php">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state line="28" column="0" selection-start="507" selection-end="507" vertical-scroll-proportion="-15.038462" vertical-offset="0" max-vertical-offset="1054"> <state line="46" column="50" selection-start="1102" selection-end="1102" vertical-scroll-proportion="0.53782505" vertical-offset="242" max-vertical-offset="1088">
<folding /> <folding />
</state> </state>
</provider> </provider>
</entry> </entry>
</file> </file>
<file leaf-file-name="chat.php" pinned="false" current="true" current-in-tab="true"> <file leaf-file-name="chat.php" pinned="false" current="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/core/chat.php"> <entry file="file://$PROJECT_DIR$/core/chat.php">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state line="31" column="45" selection-start="452" selection-end="452" vertical-scroll-proportion="0.536643" vertical-offset="73" max-vertical-offset="1547"> <state line="47" column="7" selection-start="976" selection-end="976" vertical-scroll-proportion="-9.653846" vertical-offset="548" max-vertical-offset="1547">
<folding /> <folding />
</state> </state>
</provider> </provider>
@ -64,7 +64,7 @@
<file leaf-file-name="core.php" pinned="false" current="false" current-in-tab="false"> <file leaf-file-name="core.php" pinned="false" current="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/core/core.php"> <entry file="file://$PROJECT_DIR$/core/core.php">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state line="38" column="16" selection-start="982" selection-end="982" vertical-scroll-proportion="-8.5" vertical-offset="0" max-vertical-offset="6817"> <state line="187" column="24" selection-start="4232" selection-end="4232" vertical-scroll-proportion="-5.5" vertical-offset="2761" max-vertical-offset="6817">
<folding /> <folding />
</state> </state>
</provider> </provider>
@ -100,11 +100,11 @@
<option value="$PROJECT_DIR$/ManiaControl.php" /> <option value="$PROJECT_DIR$/ManiaControl.php" />
<option value="$PROJECT_DIR$/core/commands.php" /> <option value="$PROJECT_DIR$/core/commands.php" />
<option value="$PROJECT_DIR$/core/stats.php" /> <option value="$PROJECT_DIR$/core/stats.php" />
<option value="$PROJECT_DIR$/core/chat.php" />
<option value="$PROJECT_DIR$/core/callbacks.php" /> <option value="$PROJECT_DIR$/core/callbacks.php" />
<option value="$PROJECT_DIR$/core/player.php" /> <option value="$PROJECT_DIR$/core/chat.php" />
<option value="$PROJECT_DIR$/core/playerHandler.php" />
<option value="$PROJECT_DIR$/core/core.php" /> <option value="$PROJECT_DIR$/core/core.php" />
<option value="$PROJECT_DIR$/core/playerHandler.php" />
<option value="$PROJECT_DIR$/core/player.php" />
</list> </list>
</option> </option>
</component> </component>
@ -350,13 +350,6 @@
</breakpoint-manager> </breakpoint-manager>
</component> </component>
<component name="editorHistoryManager"> <component name="editorHistoryManager">
<entry file="file://$PROJECT_DIR$/configs/database.ManiaControl.xml">
<provider selected="true" editor-type-id="text-editor">
<state line="0" column="0" selection-start="0" selection-end="0" vertical-scroll-proportion="0.0" vertical-offset="0" max-vertical-offset="777">
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/core/authentication.php"> <entry file="file://$PROJECT_DIR$/core/authentication.php">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state line="96" column="74" selection-start="2314" selection-end="2321" vertical-scroll-proportion="-6.3157897" vertical-offset="1152" max-vertical-offset="1853"> <state line="96" column="74" selection-start="2314" selection-end="2321" vertical-scroll-proportion="-6.3157897" vertical-offset="1152" max-vertical-offset="1853">
@ -420,13 +413,6 @@
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/core/database.php">
<provider selected="true" editor-type-id="text-editor">
<state line="21" column="0" selection-start="264" selection-end="296" vertical-scroll-proportion="-13.730769" vertical-offset="0" max-vertical-offset="6919">
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/plugins/oldstructure/chatlog.plugin.php"> <entry file="file://$PROJECT_DIR$/plugins/oldstructure/chatlog.plugin.php">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state line="40" column="118" selection-start="631" selection-end="741" vertical-scroll-proportion="-20.26923" vertical-offset="153" max-vertical-offset="1547"> <state line="40" column="118" selection-start="631" selection-end="741" vertical-scroll-proportion="-20.26923" vertical-offset="153" max-vertical-offset="1547">
@ -434,9 +420,37 @@
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/core/PhpRemote/GbxRemote.bem.php">
<provider selected="true" editor-type-id="text-editor">
<state line="0" column="0" selection-start="0" selection-end="0" vertical-scroll-proportion="-0.66312057" vertical-offset="561" max-vertical-offset="15266">
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/core/core.php">
<provider selected="true" editor-type-id="text-editor">
<state line="187" column="24" selection-start="4232" selection-end="4232" vertical-scroll-proportion="-5.5" vertical-offset="2761" max-vertical-offset="6817">
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/core/chat.php">
<provider selected="true" editor-type-id="text-editor">
<state line="47" column="7" selection-start="976" selection-end="976" vertical-scroll-proportion="-9.653846" vertical-offset="548" max-vertical-offset="1547">
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/core/database.php">
<provider selected="true" editor-type-id="text-editor">
<state line="21" column="0" selection-start="264" selection-end="296" vertical-scroll-proportion="-13.730769" vertical-offset="0" max-vertical-offset="6919">
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/core/player.php"> <entry file="file://$PROJECT_DIR$/core/player.php">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state line="26" column="23" selection-start="417" selection-end="417" vertical-scroll-proportion="-17.0" vertical-offset="0" max-vertical-offset="11577"> <state line="83" column="27" selection-start="2805" selection-end="2805" vertical-scroll-proportion="-4.6578946" vertical-offset="1057" max-vertical-offset="1853">
<folding> <folding>
<element signature="e#6#85#0" expanded="true" /> <element signature="e#6#85#0" expanded="true" />
</folding> </folding>
@ -445,21 +459,7 @@
</entry> </entry>
<entry file="file://$PROJECT_DIR$/core/playerHandler.php"> <entry file="file://$PROJECT_DIR$/core/playerHandler.php">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state line="28" column="0" selection-start="507" selection-end="507" vertical-scroll-proportion="-15.038462" vertical-offset="0" max-vertical-offset="1054"> <state line="46" column="50" selection-start="1102" selection-end="1102" vertical-scroll-proportion="0.53782505" vertical-offset="242" max-vertical-offset="1088">
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/core/core.php">
<provider selected="true" editor-type-id="text-editor">
<state line="38" column="16" selection-start="982" selection-end="982" vertical-scroll-proportion="-8.5" vertical-offset="0" max-vertical-offset="6817">
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/core/chat.php">
<provider selected="true" editor-type-id="text-editor">
<state line="31" column="45" selection-start="452" selection-end="452" vertical-scroll-proportion="0.536643" vertical-offset="73" max-vertical-offset="1547">
<folding /> <folding />
</state> </state>
</provider> </provider>

View File

@ -38,10 +38,10 @@ class Chat {
public function sendChat($message, $login = null, $prefix = false) { public function sendChat($message, $login = null, $prefix = false) {
if (!$this->mc->client) return false; if (!$this->mc->client) return false;
if ($login === null) { if ($login === null) {
return $this->mc->client->query('ChatSendServerMessage', ($prefix ? $this->prefix : '') . $message); return $this->mc->client->query('ChatSendServerMessage', '$z' . ($prefix ? $this->prefix : '') . $message . '$z');
} }
else { else {
return $this->mc->client->query('ChatSendServerMessageToLogin', ($prefix ? $this->prefix : '') . $message, $login); return $this->mc->client->query('ChatSendServerMessageToLogin', '$z' . ($prefix ? $this->prefix : '') . $message . '$z', $login);
} }
} }

View File

@ -185,6 +185,10 @@ class ManiaControl {
trigger_error("Couldn't announce ManiaControl. " . $this->getClientErrorText()); trigger_error("Couldn't announce ManiaControl. " . $this->getClientErrorText());
} }
//get PlayerList
$this->client->query('GetPlayerList', 300, 0, 2);
$this->playerHandler->addPlayerList($this->client->getResponse());
// OnInit // OnInit
$this->callbacks->onInit(); $this->callbacks->onInit();
@ -307,10 +311,6 @@ class ManiaControl {
} }
} }
} }
$this->client->query('GetPlayerList', 300, 0, 2);
$this->playerHandler->addPlayerList($this->client->getResponse());
} }
/** /**

View File

@ -11,57 +11,46 @@ namespace ManiaControl;
class Player { class Player {
/** /**
* Private properties * public properties
*/ */
private $id; public $id; //Internal Id from ManiaControl
private $pid; public $pid; //Id from dedicated Server
private $login; public $login;
private $nickname; public $nickname;
private $teamname; public $teamname;
private $ip; public $ip;
private $client; public $client;
private $ipport; public $ipport;
private $zone; public $zone;
private $continent; public $continent;
private $nation; public $nation;
//private $prevstatus; //public $prevstatus;
private $isspectator; public $isSpectator;
private $isofficial; public $isOfficial;
private $language; public $language;
private $avatar; public $avatar;
private $teamid; public $teamid;
private $unlocked; public $unlocked;
private $ladderrank; public $ladderrank;
private $ladderscore; public $ladderscore;
private $created; public $created;
private $wins;
private $newwins;
private $timeplayed;
private $maplist;
private $playerlist;
private $msgs;
private $pmbuf;
private $mutelist;
private $mutebuf;
private $style;
private $panels;
private $panelbg;
private $speclogin;
private $dedirank;
private $disconnectionreason;
//TODO: usefull construct player without rpc info? //TODO: usefull construct player without rpc info?
//TODO: isBot properti //TODO: isBot properti
//TODO: add all attributes like, allies, clublink ... just make vardump on rpc infos
public function __construct($rpc_infos = null){ public function __construct($rpc_infos = null){
if ($rpc_infos) { if ($rpc_infos) {
$this->pid = $rpc_infos['PlayerId'];
$this->login = $rpc_infos['Login']; $this->login = $rpc_infos['Login'];
$this->nickname = $rpc_infos['NickName']; $this->nickname = $rpc_infos['NickName'];
$this->pid = $rpc_infos['PlayerId'];
$this->teamid = $rpc_infos['TeamId'];
$this->ipport = $rpc_infos['IPAddress']; $this->ipport = $rpc_infos['IPAddress'];
$this->ip = preg_replace('/:\d+/', '', $rpc_infos['IPAddress']); // strip port $this->ip = preg_replace('/:\d+/', '', $rpc_infos['IPAddress']); // strip port
//$this->prevstatus = false; //$this->prevstatus = false;
$this->isspectator = $rpc_infos['IsSpectator']; $this->isSpectator = $rpc_infos['IsSpectator'];
$this->isofficial = $rpc_infos['IsInOfficialMode']; $this->isOfficial = $rpc_infos['IsInOfficialMode'];
$this->teamname = $rpc_infos['LadderStats']['TeamName']; $this->teamname = $rpc_infos['LadderStats']['TeamName'];
$this->zone = substr($rpc_infos['Path'], 6); // strip 'World|' $this->zone = substr($rpc_infos['Path'], 6); // strip 'World|'
$zones = explode('|', $rpc_infos['Path']); $zones = explode('|', $rpc_infos['Path']);
@ -90,7 +79,6 @@ class Player {
$this->client = $rpc_infos['ClientVersion']; $this->client = $rpc_infos['ClientVersion'];
$this->language = $rpc_infos['Language']; $this->language = $rpc_infos['Language'];
$this->avatar = $rpc_infos['Avatar']['FileName']; $this->avatar = $rpc_infos['Avatar']['FileName'];
$this->teamid = $rpc_infos['TeamId'];
$this->created = time(); $this->created = time();
} else { } else {
// set defaults // set defaults
@ -100,8 +88,8 @@ class Player {
$this->ipport = ''; $this->ipport = '';
$this->ip = ''; $this->ip = '';
//$this->prevstatus = false; //$this->prevstatus = false;
$this->isspectator = false; $this->isSpectator = false;
$this->isofficial = false; $this->isOfficial = false;
$this->teamname = ''; $this->teamname = '';
$this->zone = ''; $this->zone = '';
$this->continent = ''; $this->continent = '';
@ -111,566 +99,6 @@ class Player {
$this->created = 0; $this->created = 0;
} }
} }
/**
* @param mixed $avatar
*/
public function setAvatar($avatar)
{
$this->avatar = $avatar;
}
/**
* @return mixed
*/
public function getAvatar()
{
return $this->avatar;
}
/**
* @param mixed $client
*/
public function setClient($client)
{
$this->client = $client;
}
/**
* @return mixed
*/
public function getClient()
{
return $this->client;
}
/**
* @param string $continent
*/
public function setContinent($continent)
{
$this->continent = $continent;
}
/**
* @return string
*/
public function getContinent()
{
return $this->continent;
}
/**
* @param int $created
*/
public function setCreated($created)
{
$this->created = $created;
}
/**
* @return int
*/
public function getCreated()
{
return $this->created;
}
/**
* @param mixed $dedirank
*/
public function setDedirank($dedirank)
{
$this->dedirank = $dedirank;
}
/**
* @return mixed
*/
public function getDedirank()
{
return $this->dedirank;
}
/**
* @param mixed $disconnectionreason
*/
public function setDisconnectionreason($disconnectionreason)
{
$this->disconnectionreason = $disconnectionreason;
}
/**
* @return mixed
*/
public function getDisconnectionreason()
{
return $this->disconnectionreason;
}
/**
* @param mixed $id
*/
public function setId($id)
{
$this->id = $id;
}
/**
* @return mixed
*/
public function getId()
{
return $this->id;
}
/**
* @param string $ip
*/
public function setIp($ip)
{
$this->ip = $ip;
}
/**
* @return string
*/
public function getIp()
{
return $this->ip;
}
/**
* @param string $ipport
*/
public function setIpport($ipport)
{
$this->ipport = $ipport;
}
/**
* @return string
*/
public function getIpport()
{
return $this->ipport;
}
/**
* @param boolean $isofficial
*/
public function setIsofficial($isofficial)
{
$this->isofficial = $isofficial;
}
/**
* @return boolean
*/
public function getIsofficial()
{
return $this->isofficial;
}
/**
* @param boolean $isspectator
*/
public function setIsspectator($isspectator)
{
$this->isspectator = $isspectator;
}
/**
* @return boolean
*/
public function getIsspectator()
{
return $this->isspectator;
}
/**
* @param int $ladderrank
*/
public function setLadderrank($ladderrank)
{
$this->ladderrank = $ladderrank;
}
/**
* @return int
*/
public function getLadderrank()
{
return $this->ladderrank;
}
/**
* @param int $ladderscore
*/
public function setLadderscore($ladderscore)
{
$this->ladderscore = $ladderscore;
}
/**
* @return int
*/
public function getLadderscore()
{
return $this->ladderscore;
}
/**
* @param mixed $language
*/
public function setLanguage($language)
{
$this->language = $language;
}
/**
* @return mixed
*/
public function getLanguage()
{
return $this->language;
}
/**
* @param string $login
*/
public function setLogin($login)
{
$this->login = $login;
}
/**
* @return string
*/
public function getLogin()
{
return $this->login;
}
/**
* @param mixed $maplist
*/
public function setMaplist($maplist)
{
$this->maplist = $maplist;
}
/**
* @return mixed
*/
public function getMaplist()
{
return $this->maplist;
}
/**
* @param mixed $msgs
*/
public function setMsgs($msgs)
{
$this->msgs = $msgs;
}
/**
* @return mixed
*/
public function getMsgs()
{
return $this->msgs;
}
/**
* @param mixed $mutebuf
*/
public function setMutebuf($mutebuf)
{
$this->mutebuf = $mutebuf;
}
/**
* @return mixed
*/
public function getMutebuf()
{
return $this->mutebuf;
}
/**
* @param mixed $mutelist
*/
public function setMutelist($mutelist)
{
$this->mutelist = $mutelist;
}
/**
* @return mixed
*/
public function getMutelist()
{
return $this->mutelist;
}
/**
* @param string $nation
*/
public function setNation($nation)
{
$this->nation = $nation;
}
/**
* @return string
*/
public function getNation()
{
return $this->nation;
}
/**
* @param mixed $newwins
*/
public function setNewwins($newwins)
{
$this->newwins = $newwins;
}
/**
* @return mixed
*/
public function getNewwins()
{
return $this->newwins;
}
/**
* @param string $nickname
*/
public function setNickname($nickname)
{
$this->nickname = $nickname;
}
/**
* @return string
*/
public function getNickname()
{
return $this->nickname;
}
/**
* @param mixed $panelbg
*/
public function setPanelbg($panelbg)
{
$this->panelbg = $panelbg;
}
/**
* @return mixed
*/
public function getPanelbg()
{
return $this->panelbg;
}
/**
* @param mixed $panels
*/
public function setPanels($panels)
{
$this->panels = $panels;
}
/**
* @return mixed
*/
public function getPanels()
{
return $this->panels;
}
/**
* @param int $pid
*/
public function setPid($pid)
{
$this->pid = $pid;
}
/**
* @return int
*/
public function getPid()
{
return $this->pid;
}
/**
* @param mixed $playerlist
*/
public function setPlayerlist($playerlist)
{
$this->playerlist = $playerlist;
}
/**
* @return mixed
*/
public function getPlayerlist()
{
return $this->playerlist;
}
/**
* @param mixed $pmbuf
*/
public function setPmbuf($pmbuf)
{
$this->pmbuf = $pmbuf;
}
/**
* @return mixed
*/
public function getPmbuf()
{
return $this->pmbuf;
}
/**
* @param mixed $speclogin
*/
public function setSpeclogin($speclogin)
{
$this->speclogin = $speclogin;
}
/**
* @return mixed
*/
public function getSpeclogin()
{
return $this->speclogin;
}
/**
* @param mixed $style
*/
public function setStyle($style)
{
$this->style = $style;
}
/**
* @return mixed
*/
public function getStyle()
{
return $this->style;
}
/**
* @param mixed $teamid
*/
public function setTeamid($teamid)
{
$this->teamid = $teamid;
}
/**
* @return mixed
*/
public function getTeamid()
{
return $this->teamid;
}
/**
* @param string $teamname
*/
public function setTeamname($teamname)
{
$this->teamname = $teamname;
}
/**
* @return string
*/
public function getTeamname()
{
return $this->teamname;
}
/**
* @param mixed $timeplayed
*/
public function setTimeplayed($timeplayed)
{
$this->timeplayed = $timeplayed;
}
/**
* @return mixed
*/
public function getTimeplayed()
{
return $this->timeplayed;
}
/**
* @param mixed $unlocked
*/
public function setUnlocked($unlocked)
{
$this->unlocked = $unlocked;
}
/**
* @return mixed
*/
public function getUnlocked()
{
return $this->unlocked;
}
/**
* @param mixed $wins
*/
public function setWins($wins)
{
$this->wins = $wins;
}
/**
* @return mixed
*/
public function getWins()
{
return $this->wins;
}
/**
* @param string $zone
*/
public function setZone($zone)
{
$this->zone = $zone;
}
/**
* @return string
*/
public function getZone()
{
return $this->zone;
}
} }
?> ?>

View File

@ -37,14 +37,16 @@ class playerHandler {
} }
} }
/** /**
* Handels a playerConnect * Handles a playerConnect
* @param $player * @param $player
*/ */
public function playerConnect($player){ public function playerConnect($player){
error_log("test");
$this->mc->client->query('GetDetailedPlayerInfo', $player[0]); $this->mc->client->query('GetDetailedPlayerInfo', $player[0]);
$this->addPlayer(new Player($this->mc->client->getResponse())); $this->addPlayer(new Player($this->mc->client->getResponse()));
$this->mc->chat->sendChat("test"); $player = $this->playerList[$player[0]];
if($player->pid != 0){ //Player 0 = server
$this->mc->chat->sendChat('$ff0New Player: '. $player->nickname . '$z $ff0Nation:$fff ' . $player->nation . ' $ff0Ladder: $fff' . $player->ladderrank);
}
} }
/** /**
* Adds a player to the PlayerList * Adds a player to the PlayerList
@ -53,7 +55,7 @@ class playerHandler {
*/ */
public function addPlayer(Player $player){ public function addPlayer(Player $player){
if($player != null){ if($player != null){
$this->playerList[$player->getLogin()] = $player; $this->playerList[$player->login] = $player;
return true; return true;
}else{ }else{
return false; return false;