Mapper/Spawns

* do not try to place spawns assigned by instanced map <=> zoneId association. They have (0,0) as coordinates
This commit is contained in:
Sarjuuk
2024-06-17 13:36:45 +02:00
parent 8fe18ed41c
commit 7b924a197e
2 changed files with 8 additions and 8 deletions

View File

@@ -566,10 +566,10 @@ trait spawnHelper
$this->spawnResult[SPAWNINFO_SHORT] = new StdClass; $this->spawnResult[SPAWNINFO_SHORT] = new StdClass;
// first get zone/floor with the most spawns // first get zone/floor with the most spawns
if ($res = DB::Aowow()->selectRow('SELECT areaId, floor FROM ?_spawns WHERE type = ?d AND typeId = ?d AND posX > 0 AND posY > 0 GROUP BY areaId, floor ORDER BY count(1) DESC LIMIT 1', self::$type, $this->id)) if ($res = DB::Aowow()->selectRow('SELECT `areaId`, `floor` FROM ?_spawns WHERE `type` = ?d AND `typeId` = ?d AND `posX` > 0 AND `posY` > 0 GROUP BY `areaId`, `floor` ORDER BY COUNT(1) DESC LIMIT 1', self::$type, $this->id))
{ {
// get relevant spawn points // get relevant spawn points
$points = DB::Aowow()->select('SELECT posX, posY FROM ?_spawns WHERE type = ?d AND typeId = ?d AND areaId = ?d AND floor = ?d AND posX > 0 AND posY > 0', self::$type, $this->id, $res['areaId'], $res['floor']); $points = DB::Aowow()->select('SELECT `posX`, `posY` FROM ?_spawns WHERE `type` = ?d AND `typeId` = ?d AND `areaId` = ?d AND `floor` = ?d AND `posX` > 0 AND `posY` > 0', self::$type, $this->id, $res['areaId'], $res['floor']);
$spawns = []; $spawns = [];
foreach ($points as $p) foreach ($points as $p)
$spawns[] = [$p['posX'], $p['posY']]; $spawns[] = [$p['posX'], $p['posY']];
@@ -585,7 +585,7 @@ trait spawnHelper
$wpSum = []; $wpSum = [];
$wpIdx = 0; $wpIdx = 0;
$worldPos = []; $worldPos = [];
$spawns = DB::Aowow()->select("SELECT * FROM ?_spawns WHERE type = ?d AND typeId = ?d AND posX > 0 AND posY > 0", self::$type, $this->id); $spawns = DB::Aowow()->select("SELECT * FROM ?_spawns WHERE `type` = ?d AND `typeId` = ?d AND `posX` > 0 AND `posY` > 0", self::$type, $this->id);
if (!$spawns) if (!$spawns)
return; return;
@@ -751,7 +751,7 @@ trait spawnHelper
private function createZoneSpawns() // [zoneId1, zoneId2, ..] for locations-column in listview private function createZoneSpawns() // [zoneId1, zoneId2, ..] for locations-column in listview
{ {
$res = DB::Aowow()->selectCol("SELECT typeId AS ARRAY_KEY, GROUP_CONCAT(DISTINCT areaId) FROM ?_spawns WHERE type = ?d AND typeId IN (?a) GROUP BY typeId", self::$type, $this->getfoundIDs()); $res = DB::Aowow()->selectCol("SELECT `typeId` AS ARRAY_KEY, GROUP_CONCAT(DISTINCT `areaId`) FROM ?_spawns WHERE `type` = ?d AND `typeId` IN (?a) AND `posX` > 0 AND `posY` > 0 GROUP BY `typeId`", self::$type, $this->getfoundIDs());
foreach ($res as &$r) foreach ($res as &$r)
{ {
$r = explode(',', $r); $r = explode(',', $r);
@@ -767,7 +767,7 @@ trait spawnHelper
if (self::$type == Type::SOUND) if (self::$type == Type::SOUND)
return; return;
$res = DB::Aowow()->select('SELECT areaId, floor, typeId, posX, posY FROM ?_spawns WHERE type = ?d AND typeId IN (?a) AND posX > 0 AND posY > 0', self::$type, $this->getFoundIDs()); $res = DB::Aowow()->select('SELECT `areaId`, `floor`, `typeId`, `posX`, `posY` FROM ?_spawns WHERE `type` = ?d AND `typeId` IN (?a) AND `posX` > 0 AND `posY` > 0', self::$type, $this->getFoundIDs());
$spawns = []; $spawns = [];
foreach ($res as $data) foreach ($res as $data)
{ {

View File

@@ -173,9 +173,9 @@ class ZonePage extends GenericPage
} }
// we cannot fetch spawns via lists. lists are grouped by entry // we cannot fetch spawns via lists. lists are grouped by entry
$oSpawns = DB::Aowow()->select('SELECT * FROM ?_spawns WHERE areaId = ?d AND type = ?d', $this->typeId, Type::OBJECT); $oSpawns = DB::Aowow()->select('SELECT * FROM ?_spawns WHERE `areaId` = ?d AND `type` = ?d AND `posX` > 0 AND `posY` > 0', $this->typeId, Type::OBJECT);
$cSpawns = DB::Aowow()->select('SELECT * FROM ?_spawns WHERE areaId = ?d AND type = ?d', $this->typeId, Type::NPC); $cSpawns = DB::Aowow()->select('SELECT * FROM ?_spawns WHERE areaId = ?d AND `type` = ?d AND `posX` > 0 AND `posY` > 0', $this->typeId, Type::NPC);
$aSpawns = User::isInGroup(U_GROUP_STAFF) ? DB::Aowow()->select('SELECT * FROM ?_spawns WHERE areaId = ?d AND type = ?d', $this->typeId, Type::AREATRIGGER) : []; $aSpawns = User::isInGroup(U_GROUP_STAFF) ? DB::Aowow()->select('SELECT * FROM ?_spawns WHERE `areaId` = ?d AND `type` = ?d AND `posX` > 0 AND `posY` > 0', $this->typeId, Type::AREATRIGGER) : [];
$conditions = [Cfg::get('SQL_LIMIT_NONE'), ['s.areaId', $this->typeId]]; $conditions = [Cfg::get('SQL_LIMIT_NONE'), ['s.areaId', $this->typeId]];
if (!User::isInGroup(U_GROUP_STAFF)) if (!User::isInGroup(U_GROUP_STAFF))