Spawn::Spawn(Spawn& s, uint16_t id) : Item(tSpawn, id) { setName(s.name()); setLastName(s.lastName()); Item::setPoint(s.x(), s.y(), s.z()); setPetOwnerID(s.petOwnerID()); setLight(s.light()); setGender(s.gender()); setDeity(s.deity()); setRace(s.race()); setClassVal(s.classVal()); setHP(s.HP()); setMaxHP(s.maxHP()); setGuildID(s.GuildID()); setLevel(s.level()); for (int i = 0; i <= tLastCoreWearSlot; i++) setEquipment(i, s.equipment(i)); setEquipment(tUnknown1, 0); setTypeflag(s.typeflag()); setNPC(s.NPC()); setAnimation(s.animation()); setDeltas(s.deltaX(), s.deltaY(), s.deltaZ()); setHeading(s.heading(), s.deltaHeading()); setConsidered(s.considered()); // the new copy will own the spawn track list m_spawnTrackList.setAutoDelete(false); m_spawnTrackList = s.m_spawnTrackList; s.m_spawnTrackList.setAutoDelete(false); m_spawnTrackList.setAutoDelete(true); }
void SpawnShell::newSpawn(const spawnStruct& s) { #ifdef SPAWNSHELL_DIAG printf("SpawnShell::newSpawn(spawnStruct *(name='%s'), bSelected=%s)\n", s.name, bSelected?"true":"false"); #endif // if this is the SPAWN_SELF it's the player if (s.NPC == SPAWN_SELF) return; // not the player, so check if it's a recently deleted spawn for (int i =0; i < m_cntDeadSpawnIDs; i++) { if ((m_deadSpawnID[i] != 0) && (m_deadSpawnID[i] == s.spawnId)) { // found a match, remove it from the deleted spawn list m_deadSpawnID[i] = 0; // let the user know what's going on printf("%s(%d) has already been removed from the zone before we processed it.\n", s.name, s.spawnId); // and stop the attempt to add the spawn. return; } } Item* item = m_spawns.find(s.spawnId); if (item != NULL) { Spawn* spawn = (Spawn*)item; spawn->update(&s); updateFilterFlags(spawn); updateRuntimeFilterFlags(spawn); item->updateLastChanged(); if (spawn->GuildID() < MAXGUILDS) spawn->setGuildTag(m_guildMgr->guildIdToName(spawn->GuildID())); if (!showeq_params->fast_machine) item->setDistanceToPlayer(m_player->calcDist2DInt(*item)); else item->setDistanceToPlayer(m_player->calcDist(*item)); emit changeItem(item, tSpawnChangedALL); } else { item = new Spawn(&s); Spawn* spawn = (Spawn*)item; updateFilterFlags(spawn); updateRuntimeFilterFlags(spawn); m_spawns.insert(s.spawnId, item); if (spawn->GuildID() < MAXGUILDS) spawn->setGuildTag(m_guildMgr->guildIdToName(spawn->GuildID())); if (!showeq_params->fast_machine) item->setDistanceToPlayer(m_player->calcDist2DInt(*item)); else item->setDistanceToPlayer(m_player->calcDist(*item)); emit addItem(item); // send notification of new spawn count emit numSpawns(m_spawns.count()); } if (item->filterFlags() & FILTER_FLAG_ALERT) emit handleAlert(item, tNewSpawn); }