Пример #1
0
void SpawnShell::newDoorSpawn(const doorStruct& d, size_t len, uint8_t dir)
{
#ifdef SPAWNSHELL_DIAG
   seqDebug("SpawnShell::newDoorSpawn(doorStruct*)");
#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);
   }
}
Пример #2
0
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);
}
Пример #3
0
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);
}
Пример #4
0
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);
}
Пример #5
0
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);
}
Пример #6
0
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);
  }
}
Пример #7
0
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);
   }
}
Пример #8
0
void SpawnShell::restoreSpawns(void)
{
  QString fileName = showeq_params->saveRestoreBaseFilename + "Spawns.dat";
  QFile keyFile(fileName);
  if (keyFile.open(IO_ReadOnly))
  {
    size_t i;
    size_t testVal;
    uint16_t id;
    Spawn* item;

    QDataStream d(&keyFile);

    // check the magic string
    uint32_t magicTest;
    d >> magicTest;

    if (magicTest != *magic)
    {
      fprintf(stderr, 
	      "Failure loading %s: Bad magic string!\n",
	      (const char*)fileName);
      return;
    }

    // check the test value at the top of the file
    d >> testVal;
    if (testVal != sizeof(spawnStruct))
    {
      fprintf(stderr, 
	      "Failure loading %s: Bad spawnStruct size!\n",
	      (const char*)fileName);
      return;
    }

    // read the expected number of elements
    d >> testVal;

    // read in the spawns
    for (i = 0; i < testVal; i++)
    {
      // get the spawn id
      d >> id;

      // re-create the spawn
      item = new Spawn(d, id);

      // filter and add it to the list
      updateFilterFlags(item);
      updateRuntimeFilterFlags(item);
      m_spawns.insert(id, item);
      emit addItem(item);
    }

    emit numSpawns(m_spawns.count());

    fprintf(stderr,
	    "Restored SPAWNS: count=%d!\n",
	    m_spawns.count());
  }
Пример #9
0
// 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);
}
Пример #10
0
// same-name slots, connecting to Packet signals
void SpawnShell::newGroundItem(const uint8_t* data, size_t, uint8_t dir)
{
  const makeDropStruct *d = (const makeDropStruct *)data;
#ifdef SPAWNSHELL_DIAG
   seqDebug("SpawnShell::newGroundItem(makeDropStruct *)");
#endif
  // if zoning, then don't do anything
  if (m_zoneMgr->isZoning())
    return;

  if (dir != DIR_Server)
    return;

  if (!d)
    return;
  
  QString name;
  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);
  }
}
Пример #11
0
void SpawnShell::refilterSpawns(itemType type)
{
   ItemMap& theMap = getMap(type);
   ItemIterator it(theMap);

   if (type == tSpawn)
   {
     Spawn* spawn;
     // iterate over all the items in the map
     for (; it.current(); ++it)
     {
       // get the item
       spawn = (Spawn*)it.current();
       
       // update the flags, if they changed, send a notification
       if (updateFilterFlags(spawn))
       {
	 spawn->updateLastChanged();
	 emit changeItem(spawn, tSpawnChangedFilter);
       }
     }
   }
   else
   {
     Item* item;
     // iterate over all the items in the map
     for (; it.current(); ++it)
     {
       // get the item
       item = it.current();
       
       // update the flags, if they changed, send a notification
       if (updateFilterFlags(item))
       {
	 item->updateLastChanged();
	 emit changeItem(item, tSpawnChangedFilter);
       }
     }
   }
}
Пример #12
0
// 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);
}
Пример #13
0
void SpawnShell::spawnWearingUpdate(const wearChangeStruct *wearing)
{
  Item* item = m_spawns.find(wearing->spawnId);
  if (item != NULL)
  {
    Spawn* spawn = (Spawn*)item;
    spawn->setEquipment(wearing->wearSlotId, wearing->newItemId);
    uint32_t changeType = tSpawnChangedWearing;
    if (updateFilterFlags(item))
      changeType |= tSpawnChangedFilter;
    if (updateRuntimeFilterFlags(item))
      changeType |= tSpawnChangedRuntimeFilter;
    item->updateLastChanged();
    emit changeItem(item, changeType);
  }
}
Пример #14
0
void SpawnShell::newSpawn(const spawnStruct& s)
{
#ifdef SPAWNSHELL_DIAG
   seqDebug("SpawnShell::newSpawn(spawnStruct *(name='%s'))", s.name);
#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
       seqInfo("%s(%d) has already been removed from the zone before we processed it.", 
	      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() < MAX_GUILDS)
        spawn->setGuildTag(m_guildMgr->guildIdToName(spawn->guildID()));
     else
        spawn->setGuildTag("");
     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() < MAX_GUILDS)
        spawn->setGuildTag(m_guildMgr->guildIdToName(spawn->guildID()));
     else
        spawn->setGuildTag("");
     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());
   }
}
Пример #15
0
void SpawnShell::consMessage(const considerStruct * con, uint32_t, uint8_t dir) 
{
  Item* item;
  Spawn* spawn;

  if (dir == DIR_CLIENT)
  {
    if (con->playerid != con->targetid) 
    {
      item = m_spawns.find(con->targetid);
      if (item != NULL)
      {
	spawn = (Spawn*)item;

	// note that this spawn has been considered
	spawn->setConsidered(true);
	
	emit spawnConsidered(item);
      }
    }
    return;
  }

  QString lvl("");
  QString hps("");
  QString cn("");

  QString msg("Faction: Your faction standing with ");

  //printf("%i, %i, %i, %i\n", con->unknown1[0], con->unknown1[1], con->unknown2[0], con->unknown2[1]);

  // is it you that you've conned?
  if (con->playerid == con->targetid) 
  {
    // print it's deity
    printf("Diety: %s\n", (const char*)m_player->deityName());
    
    // well, this is You
    msg += "YOU";
  }
  else 
  {
    // find the spawn if it exists
    item = m_spawns.find(con->targetid);
    
    // has the spawn been seen before?
    if (item != NULL)
    {
      Spawn* spawn = (Spawn*)item;
      // yes
      printf("Diety: %s\n", (const char*)spawn->deityName());

      int changed = tSpawnChangedNone;

      /* maxhp and curhp are available when considering players, */
      /* but not when considering mobs. */
      if (con->maxHp || con->curHp)
      {
         if (spawn->NPC() == SPAWN_NPC_UNKNOWN)
         {
	   spawn->setNPC(SPAWN_PLAYER);        // player
	   changed |= tSpawnChangedNPC;
         }
         spawn->setMaxHP(con->maxHp);
         spawn->setHP(con->curHp);
         changed |= tSpawnChangedHP;
      }
      else if (item->NPC() == SPAWN_NPC_UNKNOWN)
      {
         spawn->setNPC(SPAWN_NPC);
         changed |= tSpawnChangedNPC;
      }

      // note the updates if any
      if (changed != tSpawnChangedNone)
      {
        if (updateFilterFlags(item))
           changed |= tSpawnChangedFilter;
        if (updateRuntimeFilterFlags(item))
           changed |= tSpawnChangedRuntimeFilter;

	item->updateLastChanged();
        emit changeItem(item, changed);
      }

      // note that this spawn has been considered
      spawn->setConsidered(true);

      emit spawnConsidered(item);

      msg += item->name();
    } // end if spawn found
    else
      msg += "Spawn:" + QString::number(con->targetid, 16);
  } // else not yourself
  
  switch (con->level) 
  {
     case 0:
     {
        cn.sprintf(" (even)");
        break;
     }
     case 2:
     {
        cn.sprintf(" (green)");
        break;
     }
     case 4:
     {
        cn.sprintf(" (blue)");
        break;
     }
     case 13:
     {
        cn.sprintf(" (red)");
        break;
     }
     case 15:
     {
        cn.sprintf(" (yellow)");
        break;
     }
     case 18:
     {
        cn.sprintf(" (cyan)");
        break;
     }
     default:
     {
        cn.sprintf(" (unknown: %d)", con->level);
        break;
     }
  }

  msg += cn;

  if (con->maxHp || con->curHp)
  {
    lvl.sprintf(" (%i/%i HP)", con->curHp, con->maxHp);
    msg += lvl;
  }
  
  msg += QString(" is: ") + print_faction(con->faction) + " (" 
    + QString::number(con->faction) + ")!";
  
  emit msgReceived(msg);
} // end consMessage()
Пример #16
0
void SpawnShell::updateSpawn(uint16_t id, 
			     int16_t x, int16_t y, int16_t z,
			     int16_t xVel, int16_t yVel, int16_t zVel,
			     int8_t heading, int8_t deltaHeading,
			     uint8_t animation)
{
#ifdef SPAWNSHELL_DIAG
   printf("SpawnShell::updateSpawn(id=%d, x=%d, y=%d, z=%d, xVel=%d, yVel=%d, zVel=%d)\n", id, x, y, z, xVel, yVel, zVel);
#endif

   Item* item = m_spawns.find(id);

   if (item != NULL)
   {
     Spawn* spawn = (Spawn*)item;

     spawn->setPos(x, y, z,
		   showeq_params->walkpathrecord,
		   showeq_params->walkpathlength);
     spawn->setAnimation(animation);
     if ((animation != 0) && (animation != 66))
     {
       spawn->setDeltas(xVel, yVel, zVel);
       spawn->setHeading(heading, deltaHeading);
     } 
    else
     {
       spawn->setDeltas(0, 0, 0);
       spawn->setHeading(heading, 0);
     }

     spawn->updateLast();
     item->updateLastChanged();
     emit changeItem(item, tSpawnChangedPosition);
   }
   else if (showeq_params->createUnknownSpawns)
   {
     // not the player, so check if it's a recently deleted spawn
     for (int i =0; i < m_cntDeadSpawnIDs; i++)
     {
       // check dead spawn list for spawnID, if it was deleted, shouldn't
       // see new position updates, so therefore this is probably 
       // for a new spawn (spawn ID being reused)
       if ((m_deadSpawnID[i] != 0) && (m_deadSpawnID[i] == id))
       {
	 // found a match, ignore it
	 m_deadSpawnID[i] = 0;

	 printf("\a(%d) had been removed from the zone, but saw a position update on it, so assuming bogus update.\n", 
		id);

	 return;
       }
     }

     item = new Spawn(id, x, y, z, xVel, yVel, zVel, 
		      heading, deltaHeading, animation);
     updateFilterFlags(item);
     updateRuntimeFilterFlags(item);
     m_spawns.insert(id, item);
     emit addItem(item);

     // send notification of new spawn count
     emit numSpawns(m_spawns.count());
   }
}
Пример #17
0
// same-name slots, connecting to Packet signals
// this packet is variable in length.  everything is dwords except the "idFile" field
// which can be variable
void SpawnShell::newGroundItem(const uint8_t* data, size_t len, uint8_t dir)
{
   if (m_zoneMgr->isZoning())
      return;

   if (dir != DIR_Server)
      return;

   if (!data)
      return;

   NetStream netStream(data, len);
   makeDropStruct ds;
   QString name;
   union { uint32_t n; float f; } x;
   memset(&ds, 0, sizeof(makeDropStruct));

   // read drop id
   ds.dropId = netStream.readUInt32NC();

   // read name
   name = netStream.readText();
   if(name.length())
   {
      strcpy(ds.idFile, name.latin1());
   }

   // read past zone id
   netStream.readUInt32NC();

   // read past zone instance
   netStream.readUInt32NC();

   // read past unknown dword field
   netStream.readUInt32NC();

   // read heading
   x.n = netStream.readUInt32NC();
   ds.heading = x.f;

   // read past unknown dword field
   netStream.readUInt32NC();

   // read past unknown dword field
   netStream.readUInt32NC();

   // read past unknown dword field
   netStream.readUInt32NC();

   // read y pos
   x.n = netStream.readUInt32NC();
   ds.y = x.f;

   // read x pos
   x.n = netStream.readUInt32NC();
   ds.x = x.f;

   // read z pos
   x.n = netStream.readUInt32NC();
   ds.z = x.f;

#ifdef SPAWNSHELL_DIAG
   seqDebug("SpawnShell::newGroundItem(makeDropStruct *)");
#endif

  Drop* item = (Drop*)m_drops.find(ds.dropId);
  if (item != NULL)
  {
    item->update(&ds, 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(&ds, name);
    if (!showeq_params->fast_machine)
       item->setDistanceToPlayer(m_player->calcDist2DInt(*item));
     else
       item->setDistanceToPlayer(m_player->calcDist(*item));
    updateFilterFlags(item);
    m_drops.insert(ds.dropId, item);
    emit addItem(item);
  }
}