void SpawnShell::killSpawn(const newCorpseStruct* deadspawn) { #ifdef SPAWNSHELL_DIAG printf("SpawnShell::killSpawn(id=%d, kid=%d)\n", deadspawn->spawnId, deadspawn->killerId); #endif Item* item; Item* killer; item = m_spawns.find(deadspawn->spawnId); if (item != NULL) { Spawn* spawn = (Spawn*)item; killer = m_spawns.find(deadspawn->killerId); // ZBTEMP: This is temporary until we can find a better way // set the last kill info on the player (do this before changing name) m_player->setLastKill(spawn->name(), spawn->level()); spawn->killSpawn(); updateFilterFlags(item); updateRuntimeFilterFlags(item); emit killSpawn(item, killer, deadspawn->killerId); if (item->filterFlags() & FILTER_FLAG_ALERT) emit handleAlert(item, tKillSpawn); } }
void SpawnShell::backfillSpawn(const spawnStruct *spawn) { Item* item = m_spawns.find(spawn->spawnId); if (item == NULL) { // if it's not already in the list, then just add it. newSpawn(*spawn); return; } Spawn* spawnItem = (Spawn*)item; // if we got the self item, then somethings screwy, so only update if // not the self spawn if (!spawnItem->isSelf()) { spawnItem->backfill(spawn); updateFilterFlags(spawnItem); updateRuntimeFilterFlags(spawnItem); spawnItem->updateLastChanged(); emit changeItem(spawnItem, tSpawnChangedALL); if (spawnItem->filterFlags() & FILTER_FLAG_ALERT) emit handleAlert(spawnItem, tFilledSpawn); } }
void SpawnShell::newCoinsItem(const dropCoinsStruct *c) { #ifdef SPAWNSHELL_DIAG printf("SpawnShell::newCoinsItem(dropCoinsStruct*)\n"); #endif // if zoning, then don't do anything if (m_zoneMgr->isZoning()) return; if (!c) return; Item* item = m_coins.find(c->dropId); if (item != NULL) { Coin* coin = (Coin*)item; coin->update(c); updateFilterFlags(item); item->updateLastChanged(); emit changeItem(item, tSpawnChangedALL); } else { item = new Coin(c); updateFilterFlags(item); m_coins.insert(c->dropId, item); emit addItem(item); } if (item->filterFlags() & FILTER_FLAG_ALERT) emit handleAlert(item, tNewSpawn); }
void SpawnShell::newDoorSpawn(const doorStruct* d) { #ifdef SPAWNSHELL_DIAG printf("SpawnShell::newDoorSpawn(doorStruct*)\n"); #endif Item* item = m_doors.find(d->doorId); if (item != NULL) { Door* door = (Door*)item; door->update(d); updateFilterFlags(door); item->updateLastChanged(); emit changeItem(door, tSpawnChangedALL); } else { item = (Item*)new Door(d); updateFilterFlags(item); m_doors.insert(d->doorId, item); emit addItem(item); } if (item->filterFlags() & FILTER_FLAG_ALERT) emit handleAlert(item, tNewSpawn); }
void SpawnShell::newDoorSpawn(const doorStruct* d, uint32_t len, uint8_t dir) { #ifdef SPAWNSHELL_DIAG printf("SpawnShell::newDoorSpawn(doorStruct*)\n"); #endif Item* item = m_doors.find(d->doorId); if (item != NULL) { Door* door = (Door*)item; door->update(d); if (!showeq_params->fast_machine) item->setDistanceToPlayer(m_player->calcDist2DInt(*item)); else item->setDistanceToPlayer(m_player->calcDist(*item)); updateFilterFlags(door); item->updateLastChanged(); emit changeItem(door, tSpawnChangedALL); } else { item = (Item*)new Door(d); if (!showeq_params->fast_machine) item->setDistanceToPlayer(m_player->calcDist2DInt(*item)); else item->setDistanceToPlayer(m_player->calcDist(*item)); updateFilterFlags(item); m_doors.insert(d->doorId, item); emit addItem(item); } if (item->filterFlags() & FILTER_FLAG_ALERT) emit handleAlert(item, tNewSpawn); }
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(item); updateRuntimeFilterFlags(item); item->updateLastChanged(); emit changeItem(item, tSpawnChangedALL); } else { item = new Spawn(&s); updateFilterFlags(item); updateRuntimeFilterFlags(item); m_spawns.insert(s.spawnId, 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); }
// same-name slots, connecting to Packet signals void SpawnShell::newGroundItem(const makeDropStruct *d, uint32_t, uint8_t dir) { #ifdef SPAWNSHELL_DIAG printf("SpawnShell::newGroundItem(makeDropStruct *)\n"); #endif // if zoning, then don't do anything if (m_zoneMgr->isZoning()) return; if (dir != DIR_SERVER) return; if (!d) return; // attempt to get the item name QString name; if (m_itemDB != NULL) name = m_itemDB->GetItemLoreName(d->itemNr); Drop* item = (Drop*)m_drops.find(d->dropId); if (item != NULL) { item->update(d, name); if (!showeq_params->fast_machine) item->setDistanceToPlayer(m_player->calcDist2DInt(*item)); else item->setDistanceToPlayer(m_player->calcDist(*item)); updateFilterFlags(item); item->updateLastChanged(); emit changeItem(item, tSpawnChangedALL); } else { item = new Drop(d, name); if (!showeq_params->fast_machine) item->setDistanceToPlayer(m_player->calcDist2DInt(*item)); else item->setDistanceToPlayer(m_player->calcDist(*item)); updateFilterFlags(item); m_drops.insert(d->dropId, item); emit addItem(item); } if (item->filterFlags() & FILTER_FLAG_ALERT) emit handleAlert(item, tNewSpawn); }
void SpawnShell::deleteItem(itemType type, int id) { #ifdef SPAWNSHELL_DIAG printf ("SpawnShell::deleteItem()\n"); #endif ItemMap& theMap = getMap(type); Item* item = theMap.find(id); if (item != NULL) { if (item->filterFlags() & FILTER_FLAG_ALERT) emit handleAlert(item, tDelSpawn); emit delItem(item); theMap.remove(id); // send notifcation of new spawn count emit numSpawns(m_spawns.count()); } }
// same-name slots, connecting to Packet signals void SpawnShell::newGroundItem(const makeDropStruct *d) { #ifdef SPAWNSHELL_DIAG printf("SpawnShell::newGroundItem(makeDropStruct *)\n"); #endif // if zoning, then don't do anything if (m_zoneMgr->isZoning()) return; if (!d) return; // attempt to get the item name QString name; if (m_itemDB != NULL) name = m_itemDB->GetItemLoreName(d->itemNr); Drop* item = (Drop*)m_drops.find(d->dropId); if (item != NULL) { item->update(d, name); updateFilterFlags(item); item->updateLastChanged(); emit changeItem(item, tSpawnChangedALL); } else { item = new Drop(d, name); updateFilterFlags(item); m_drops.insert(d->dropId, item); emit addItem(item); } if (item->filterFlags() & FILTER_FLAG_ALERT) emit handleAlert(item, tNewSpawn); }