コード例 #1
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);
}
コード例 #2
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);
  }
}
コード例 #3
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);
   }
}
コード例 #4
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());
  }
コード例 #5
0
void SpawnShell::refilterSpawnsRuntime(itemType type)
{
   ItemIterator it(getMap(type));

   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 (updateRuntimeFilterFlags(spawn))
       {
	 spawn->updateLastChanged();
	 emit changeItem(spawn, tSpawnChangedRuntimeFilter);
       }
     }
   }
   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 (updateRuntimeFilterFlags(item))
       {
	 item->updateLastChanged();
	 emit changeItem(item, tSpawnChangedRuntimeFilter);
       }
     }
   }
}
コード例 #6
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);
  }
}
コード例 #7
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());
   }
}
コード例 #8
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()
コード例 #9
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());
   }
}