[Résolu] Crash sur le FindUnit...
AH ben voilà c'est ce que je cherchais.. en fait c’est tout con au final Rirer...

Un grand merci à vous deux.
Édition :
Erf après test ac crash a cause de Map.h j'ai une assertion qui se déclenche.
Map.h ligne 571 ...

Code :
/home/main/src/trunk/src/server/game/Maps/Map.h:471 in getNGrid ASSERTION FAILED:
  x < MAX_NUMBER_OF_GRIDS
./worldserver(_ZN3Map7GetGridEff+0x64) [0xa86984]
./worldserver(_ZNK3Map11GetAreaFlagEfffPb+0x87) [0xa7a877]
./worldserver(_ZN20aurora_commandscript21HandleZoneMobsCommand​EP11ChatHandlerPKc+0x48a) [0xd5321a]
./worldserver(_ZN11ChatHandler21ExecuteCommandInTableEP11ChatC​ommandPKcRKSs+0x36e) [0x7f057e]
./worldserver(_ZN11ChatHandler21ExecuteCommandInTableEP11ChatC​ommandPKcRKSs+0x614) [0x7f0824]
./worldserver(_ZN11ChatHandler13ParseCommandsEPKc+0x96) [0x7f09a6]
./worldserver(_ZN12WorldSession23HandleMessagechatOpcodeER11Wo​rldPacket+0x1430) [0xcaa6a0]
./worldserver(_ZN12WorldSession6UpdateEjR12PacketFilter+0x5f9)​ [0xb16759]
./worldserver(_ZN5World14UpdateSessionsEj+0x11c) [0xbba45c]
./worldserver(_ZN5World6UpdateEj+0x1dd) [0xbbc43d]
./worldserver(_ZN13WorldRunnable3runEv+0x1ca) [0x79715a]
./worldserver(_ZN9ACE_Based6Thread10ThreadTaskEPv+0xa) [0xcebc7a]
/lib/libpthread.so.0(+0x68ba) [0x7fbe242f98ba]
/lib/libc.so.6(clone+0x6d) [0x7fbe2406102d]


Erreur de segmentation

Source du map.h
[code=cpp]
NGridType* getNGrid(uint32 x, uint32 y) const
{
ASSERT(x < MAX_NUMBER_OF_GRIDS);
ASSERT(y < MAX_NUMBER_OF_GRIDS);
return i_grids[x][y];
}
[/code]

Mon code :
[code=cpp]
// On séléctionne TOUS les mobs
QueryResult resultset = WorldDatabase.Query("SELECT guid, id, map, position_x, position_y, position_z FROM creature");

// Si table vide on retourne une erreur.
if (!resultset)
{
handler->PSendSysMessage("ERREUR : La table creature est VIDE");
return true;
}
// Sinon on traite les résultats
else
{
// On crée une "map" de Maps (il y en aura 83 environ répartie pour les 138313 créatures).
// a ne pas confontre l'objet "map" de la STL C++ et l'objet Map* qui correspond à l'objet "Map" du jeu Clin
typedef map <uint32, Map*> WorldMapListType ;

WorldMapListType WorldMaps; // On crée notre liste temporaire.

do
{
Map *tmp_MAP; // Objet Map du jeu.
Map *inserted_MAP;
// On récupère nos champs de la requête SQL
Field* RSFIELDS = resultset->Fetch();

uint32 tmp_NPCGUID = RSFIELDS[0].GetUInt32();
uint32 tmp_NPCENTRY = RSFIELDS[1].GetUInt32();
uint32 tmp_MAPID = RSFIELDS[2].GetUInt32();
uint32 tmp_X = RSFIELDS[3].GetUInt32();
uint32 tmp_Y = RSFIELDS[4].GetUInt32();
uint32 tmp_Z = RSFIELDS[5].GetUInt32();

// On vérifie si la Map d'ID tmp_MAPID est déjà dans notre liste
WorldMapListType::iterator MapListIterator = WorldMaps.begin(); // On se place au début de la liste
MapListIterator = WorldMaps.find(tmp_MAPID);

// Si la Map est déjà dans la liste, on la retourne.
if( MapListIterator != WorldMaps.end() )
{
tmp_MAP = MapListIterator->second;
}
// Sinon on l'ajoute à la liste et on retourne l'objet correspondant.
else
{
WorldMaps.insert(pair <uint32, Map*> (tmp_MAPID, const_cast<Map*>(sMapMgr->CreateBaseMap(tmp_MAPID))) );
tmp_MAP = WorldMaps[tmp_MAPID];
}

if (!tmp_MAP)
{
sLog->outString("Map %u not found or cannot be created.", tmp_MAPID);
// on passe au suivant :
continue;
}
else
{

uint32 tmp_ZONEID = tmp_MAP->GetAreaId( tmp_X, tmp_Y, tmp_Z );
uint32 tmp_AREAID = tmp_MAP->GetZoneId( tmp_X, tmp_Y, tmp_Z );


WorldDatabase.PQuery("INSERT INTO aurora_creature_zones (guid, zone, area) VALUES(%u,%u,%u)", tmp_NPCENTRY, tmp_ZONEID, tmp_AREAID);

sLog->outString("NPC %u , Zone : %u, Area : %u - Inserted.", tmp_NPCGUID, tmp_ZONEID, tmp_AREAID);
count++;
}

}
while(resultset->NextRow());

WorldMaps.clear();
}

[/code]
je vois pas d'où il me sort que x > MAX_NUMBER_OF_GRIDS
Édition :
Ha solution trouvée :

[code=cpp]
static bool HandleZoneMobsCommand(ChatHandler* handler, const char* args)
{
// Objet pointant sur le joueur courant.
Player * pPlayer = handler->GetSession()->GetPlayer();

// Sert à compter nos itérations (on aura le nombre de créatures traitées comme ça).
uint32 count = 0;

// on VIDE la table "aurora_creature_zones"
WorldDatabase.Execute("TRUNCATE TABLE aurora_creature_zones");

// On séléctionne TOUS les mobs
QueryResult resultset = WorldDatabase.Query("SELECT guid, id, map, position_x, position_y, position_z FROM creature");

// Si table vide on retourne une erreur.
if (!resultset)
{
handler->PSendSysMessage("ERREUR : La table creature est VIDE");
return true;
}
// Sinon on traite les résultats
else
{

do
{
const Map *tmp_MAP = NULL; // Objet Map du jeu.
//Map* objMap;
// On récupère nos champs de la requête SQL
Field* RSFIELDS = resultset->Fetch();

uint32 tmp_NPCGUID = RSFIELDS[0].GetUInt32();
uint32 tmp_NPCENTRY = RSFIELDS[1].GetUInt32();
uint32 tmp_MAPID = RSFIELDS[2].GetUInt32();
float tmp_X = RSFIELDS[3].GetFloat();
float tmp_Y = RSFIELDS[4].GetFloat();
float tmp_Z = RSFIELDS[5].GetFloat();

// On vérifie si la Map d'ID tmp_MAPID est déjà dans notre liste
sLog->outString("Finding Map %u ...", tmp_MAPID);


tmp_MAP = sMapMgr->FindMap(tmp_MAPID);
if (tmp_MAP == NULL)
{
sLog->outString("Map %u not found or cannot be created.", tmp_MAPID);
// on passe au suivant :
continue;
}
else
{

uint32 tmp_ZONEID = tmp_MAP->GetAreaId( tmp_X, tmp_Y, tmp_Z );
uint32 tmp_AREAID = tmp_MAP->GetZoneId( tmp_X, tmp_Y, tmp_Z );


WorldDatabase.PQuery("INSERT INTO aurora_creature_zones (guid, zone, area) VALUES(%u,%u,%u)", tmp_NPCGUID, tmp_ZONEID, tmp_AREAID);

sLog->outString("NPC %u , Zone : %u, Area : %u - Inserted.", tmp_NPCGUID, tmp_ZONEID, tmp_AREAID);
count++;
}

}
while(resultset->NextRow());


}

handler->PSendSysMessage("%d creatures ont ete mises a jour dans la table aurora_creature_zones", count);



return true;
}
[/code]

Retourner en haut Accueil