mirror of
https://github.com/Sarjuuk/aowow.git
synced 2025-11-29 15:58:16 +08:00
Maps/Spawns
* Entities (Objects, NPCs, ect) can now easily be assigned to a different map to be displayed on by clicking their pip on the map * Entities with already assigned area (by TrinityCore) that were unable to be matched onto the map are no longer discarded. They'll now show up in appropriate listviews. * Entities without already assigned area that are also unable to be matched onto the map now get an area assigned as long as the relationship areaId <=> mapId is unique (read instanced areas)
This commit is contained in:
@@ -5,7 +5,7 @@ if (!defined('AOWOW_REVISION'))
|
||||
|
||||
class AjaxAdmin extends AjaxHandler
|
||||
{
|
||||
protected $validParams = ['screenshots', 'siteconfig', 'weight-presets'];
|
||||
protected $validParams = ['screenshots', 'siteconfig', 'weight-presets', 'spawn-override'];
|
||||
protected $_get = array(
|
||||
'action' => [FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW | FILTER_FLAG_STRIP_HIGH ],
|
||||
'id' => [FILTER_CALLBACK, ['options' => 'AjaxHandler::checkIdListUnsigned']],
|
||||
@@ -14,11 +14,14 @@ class AjaxAdmin extends AjaxHandler
|
||||
'type' => [FILTER_CALLBACK, ['options' => 'AjaxHandler::checkInt'] ],
|
||||
'typeid' => [FILTER_CALLBACK, ['options' => 'AjaxHandler::checkInt'] ],
|
||||
'user' => [FILTER_CALLBACK, ['options' => 'AjaxAdmin::checkUser'] ],
|
||||
'val' => [FILTER_CALLBACK, ['options' => 'AjaxHandler::checkFulltext'] ]
|
||||
'val' => [FILTER_CALLBACK, ['options' => 'AjaxHandler::checkFulltext'] ],
|
||||
'guid' => [FILTER_CALLBACK, ['options' => 'AjaxHandler::checkInt'] ],
|
||||
'area' => [FILTER_CALLBACK, ['options' => 'AjaxHandler::checkInt'] ],
|
||||
'floor' => [FILTER_CALLBACK, ['options' => 'AjaxHandler::checkInt'] ]
|
||||
);
|
||||
protected $_post = array(
|
||||
'alt' => [FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW ],
|
||||
'id' => [FILTER_SANITIZE_NUMBER_INT, null ],
|
||||
'id' => [FILTER_CALLBACK, ['options' => 'AjaxHandler::checkInt']],
|
||||
'scale' => [FILTER_CALLBACK, ['options' => 'AjaxAdmin::checkScale']],
|
||||
'__icon' => [FILTER_CALLBACK, ['options' => 'AjaxAdmin::checkKey'] ]
|
||||
);
|
||||
@@ -71,6 +74,13 @@ class AjaxAdmin extends AjaxHandler
|
||||
if ($this->_get['action'] == 'save')
|
||||
$this->handler = 'wtSave';
|
||||
}
|
||||
else if ($this->params[0] == 'spawn-override')
|
||||
{
|
||||
if (!User::isInGroup(U_GROUP_MODERATOR))
|
||||
return;
|
||||
|
||||
$this->handler = 'spawnPosFix';
|
||||
}
|
||||
}
|
||||
|
||||
// get all => null (optional)
|
||||
@@ -115,7 +125,7 @@ class AjaxAdmin extends AjaxHandler
|
||||
// resp: ''
|
||||
protected function ssApprove() : void
|
||||
{
|
||||
if (!$this->_get['id'])
|
||||
if (!$this->reqGET('id'))
|
||||
{
|
||||
trigger_error('AjaxAdmin::ssApprove - screenshotId empty', E_USER_ERROR);
|
||||
return;
|
||||
@@ -190,7 +200,7 @@ class AjaxAdmin extends AjaxHandler
|
||||
// resp: ''
|
||||
protected function ssSticky() : void
|
||||
{
|
||||
if (!$this->_get['id'])
|
||||
if (!$this->reqGET('id'))
|
||||
{
|
||||
trigger_error('AjaxAdmin::ssSticky - screenshotId empty', E_USER_ERROR);
|
||||
return;
|
||||
@@ -217,7 +227,7 @@ class AjaxAdmin extends AjaxHandler
|
||||
// 2 steps: 1) remove from sight, 2) remove from disk
|
||||
protected function ssDelete() : void
|
||||
{
|
||||
if (!$this->_get['id'])
|
||||
if (!$this->reqGET('id'))
|
||||
{
|
||||
trigger_error('AjaxAdmin::ssDelete - screenshotId empty', E_USER_ERROR);
|
||||
return;
|
||||
@@ -266,7 +276,7 @@ class AjaxAdmin extends AjaxHandler
|
||||
// resp: ''
|
||||
protected function ssRelocate() : void
|
||||
{
|
||||
if (!$this->_get['id'] || !$this->_get['typeid'])
|
||||
if (!$this->reqGET('id', 'typeid'))
|
||||
{
|
||||
trigger_error('AjaxAdmin::ssRelocate - screenshotId or typeId empty', E_USER_ERROR);
|
||||
return;
|
||||
@@ -317,7 +327,7 @@ class AjaxAdmin extends AjaxHandler
|
||||
|
||||
protected function confRemove() : string
|
||||
{
|
||||
if (!$this->_get['key'])
|
||||
if (!$this->reqGET('key'))
|
||||
return 'invalid configuration option given';
|
||||
|
||||
if (DB::Aowow()->query('DELETE FROM ?_config WHERE `key` = ? AND (`flags` & ?d) = 0', $this->_get['key'], CON_FLAG_PERSISTENT))
|
||||
@@ -357,7 +367,7 @@ class AjaxAdmin extends AjaxHandler
|
||||
|
||||
protected function wtSave() : string
|
||||
{
|
||||
if (!$this->_post['id'] || !$this->_post['__icon'])
|
||||
if (!$this->reqPOST('id', '__icon'))
|
||||
return '3';
|
||||
|
||||
// save to db
|
||||
@@ -385,6 +395,73 @@ class AjaxAdmin extends AjaxHandler
|
||||
return '0';
|
||||
}
|
||||
|
||||
protected function spawnPosFix() : string
|
||||
{
|
||||
if (!$this->reqGET('type', 'guid', 'area', 'floor'))
|
||||
return '-4';
|
||||
|
||||
$guid = $this->_get['guid'];
|
||||
$type = $this->_get['type'];
|
||||
$area = $this->_get['area'];
|
||||
$floor = $this->_get['floor'];
|
||||
|
||||
if (!in_array($type, [TYPE_NPC, TYPE_OBJECT, TYPE_SOUND, TYPE_AREATRIGGER]))
|
||||
return '-3';
|
||||
|
||||
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 ($point = Game::worldPosToZonePos($wPos[$guid]['mapId'], $wPos[$guid]['posX'], $wPos[$guid]['posY'], $area, $floor))
|
||||
{
|
||||
$p = array(
|
||||
'posX' => $point[0]['posX'],
|
||||
'posY' => $point[0]['posY'],
|
||||
'areaId' => $point[0]['areaId'],
|
||||
'floor' => $point[0]['floor']
|
||||
);
|
||||
|
||||
DB::Aowow()->query('UPDATE ?_spawns SET ?a WHERE `type` = ?d AND `guid` = ?d', $p, $type, $guid);
|
||||
|
||||
// if creature try for waypoints
|
||||
if ($type != TYPE_NPC)
|
||||
return '1';
|
||||
|
||||
$jobs = array(
|
||||
'SELECT -w.id AS `entry`, w.point AS `pointId`, w.position_y AS `posX`, w.position_x AS `posY` FROM creature_addon ca JOIN waypoint_data w ON w.id = ca.path_id WHERE ca.guid = ?d AND ca.path_id <> 0',
|
||||
'SELECT `entry`, `pointId`, `location_y` AS `posX`, `location_x` AS `posY` FROM `script_waypoint` WHERE `entry` = ?d',
|
||||
'SELECT `entry`, `pointId`, `position_y` AS `posX`, `position_x` AS `posY` FROM `waypoints` WHERE `entry` = ?d'
|
||||
);
|
||||
|
||||
foreach ($jobs as $idx => $job)
|
||||
{
|
||||
if ($swp = DB::World()->select($job, $idx ? $wPos['id'] : $guid))
|
||||
{
|
||||
foreach ($swp as $w)
|
||||
{
|
||||
if ($point = Game::worldPosToZonePos($wPos[$guid]['mapId'], $w['posX'], $w['posY'], $area, $floor))
|
||||
{
|
||||
$p = array(
|
||||
'posX' => $point[0]['posX'],
|
||||
'posY' => $point[0]['posY'],
|
||||
'areaId' => $point[0]['areaId'],
|
||||
'floor' => $point[0]['floor']
|
||||
);
|
||||
}
|
||||
DB::Aowow()->query('UPDATE ?_creature_waypoints SET ?a WHERE `creatureOrPath` = ?d AND `point` = ?d', $p, $w['entry'], $w['pointId']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return '1';
|
||||
}
|
||||
|
||||
return '-2';
|
||||
}
|
||||
|
||||
return '-1';
|
||||
}
|
||||
|
||||
protected function checkKey(string $val) : string
|
||||
{
|
||||
// expecting string
|
||||
|
||||
Reference in New Issue
Block a user