Core/Cleanup

* try to give included files a logical structure
 * move objects from Util and Game to their own files
 * make non-essential files auto-loaded
This commit is contained in:
Sarjuuk
2025-04-01 19:46:19 +02:00
parent 3a6c86092b
commit db1d3ccace
32 changed files with 1440 additions and 1323 deletions

View File

@@ -390,9 +390,9 @@ class AjaxAdmin extends AjaxHandler
DB::Aowow()->query('REPLACE INTO ?_spawns_override VALUES (?d, ?d, ?d, ?d, ?d)', $type, $guid, $area, $floor, AOWOW_REVISION);
if ($wPos = Game::getWorldPosForGUID($type, $guid))
if ($wPos = WorldPosition::getForGUID($type, $guid))
{
if ($point = Game::worldPosToZonePos($wPos[$guid]['mapId'], $wPos[$guid]['posX'], $wPos[$guid]['posY'], $area, $floor))
if ($point = WorldPosition::toZonePos($wPos[$guid]['mapId'], $wPos[$guid]['posX'], $wPos[$guid]['posY'], $area, $floor))
{
$updGUIDs = [$guid];
$newPos = array(
@@ -417,7 +417,7 @@ class AjaxAdmin extends AjaxHandler
{
foreach ($swp as $w)
{
if ($point = Game::worldPosToZonePos($wPos[$guid]['mapId'], $w['posX'], $w['posY'], $area, $floor))
if ($point = WorldPosition::toZonePos($wPos[$guid]['mapId'], $w['posX'], $w['posY'], $area, $floor))
{
$p = array(
'posX' => $point[0]['posX'],

View File

@@ -0,0 +1,71 @@
<?php
namespace Aowow;
if (!defined('AOWOW_REVISION'))
die('illegal access');
class AjaxHandler
{
use TrRequestData;
protected $validParams = [];
protected $params = [];
protected $handler;
protected $contentType = MIME_TYPE_JSON;
public $doRedirect = false;
public function __construct(array $params)
{
$this->params = $params;
$this->initRequestData();
}
public function handle(string &$out) : bool
{
if (!$this->handler)
return false;
if ($this->validParams)
{
if (count($this->params) != 1)
return false;
if (!in_array($this->params[0], $this->validParams))
return false;
}
$out = $this->{$this->handler}() ?? '';
return true;
}
public function getContentType() : string
{
return $this->contentType;
}
protected function reqPOST(string ...$keys) : bool
{
foreach ($keys as $k)
if (!isset($this->_post[$k]) || $this->_post[$k] === null || $this->_post[$k] === '')
return false;
return true;
}
protected function reqGET(string ...$keys) : bool
{
foreach ($keys as $k)
if (!isset($this->_get[$k]) || $this->_get[$k] === null || $this->_get[$k] === '')
return false;
return true;
}
}
?>