improved player data ram storage read & write

This commit is contained in:
Steffen Schröder 2014-07-29 00:05:27 +02:00
parent 8d7f6bc62b
commit 20f769c496

View File

@ -210,11 +210,9 @@ class PlayerDataManager {
$meta = $this->metaData[$className . $dataName]; $meta = $this->metaData[$className . $dataName];
// Check if data is already in the ram // Check if data is already in the ram
if (isset($this->storedData[$player->index])) { if (isset($this->storedData[$player->index]) && isset($this->storedData[$player->index][$meta->dataId])) {
if (isset($this->storedData[$player->index][$meta->dataId])) {
return $this->storedData[$player->index][$meta->dataId]; return $this->storedData[$player->index][$meta->dataId];
} }
}
$mysqli = $this->maniaControl->database->mysqli; $mysqli = $this->maniaControl->database->mysqli;
$dataQuery = "SELECT `value` FROM `" . self::TABLE_PLAYERDATA . "` $dataQuery = "SELECT `value` FROM `" . self::TABLE_PLAYERDATA . "`
@ -296,10 +294,11 @@ class PlayerDataManager {
} }
$statement->close(); $statement->close();
//FIXME store changed value // Store changed value
if (isset($this->storedData[$player->index]) && isset($this->storedData[$player->index][$dataId])) { if (!isset($this->storedData[$player->index])) {
unset($this->storedData[$player->index][$dataId]); $this->storedData[$player->index] = array();
} }
$this->storedData[$player->index][$dataId] = $value;
return true; return true;
} }