mirror of
https://github.com/Sarjuuk/aowow.git
synced 2025-11-29 15:58:16 +08:00
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:
@@ -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'],
|
||||
|
||||
71
includes/ajaxHandler/ajaxHandler.class.php
Normal file
71
includes/ajaxHandler/ajaxHandler.class.php
Normal 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;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user