Fix TC build

This commit is contained in:
Rochet2
2015-09-24 11:48:07 +03:00
parent 7ec215b2d7
commit 8daaf04994
8 changed files with 97 additions and 24 deletions

View File

@@ -860,7 +860,7 @@ namespace LuaCreature
int GetDBTableGUIDLow(Eluna* /*E*/, lua_State* L, Creature* creature) int GetDBTableGUIDLow(Eluna* /*E*/, lua_State* L, Creature* creature)
{ {
#ifdef TRINITY #ifdef TRINITY
Eluna::Push(L, creature->GetDBTableGUIDLow()); Eluna::Push(L, creature->GetSpawnId());
#else #else
// on mangos based this is same as lowguid // on mangos based this is same as lowguid
Eluna::Push(L, creature->GetGUIDLow()); Eluna::Push(L, creature->GetGUIDLow());

View File

@@ -50,6 +50,45 @@ typedef QueryNamedResult ElunaQuery;
#define GetTemplate GetProto #define GetTemplate GetProto
#endif #endif
#ifndef HIGHGUID_PLAYER
#define HIGHGUID_PLAYER HighGuid::Player
#endif
#ifndef HIGHGUID_UNIT
#define HIGHGUID_UNIT HighGuid::Unit
#endif
#ifndef HIGHGUID_GAMEOBJECT
#define HIGHGUID_GAMEOBJECT HighGuid::GameObject
#endif
#ifndef HIGHGUID_TRANSPORT
#define HIGHGUID_TRANSPORT HighGuid::Transport
#endif
#ifndef HIGHGUID_MO_TRANSPORT
#define HIGHGUID_MO_TRANSPORT HighGuid::Mo_Transport
#endif
#ifndef HIGHGUID_VEHICLE
#define HIGHGUID_VEHICLE HighGuid::Vehicle
#endif
#ifndef HIGHGUID_PET
#define HIGHGUID_PET HighGuid::Pet
#endif
#ifndef HIGHGUID_DYNAMICOBJECT
#define HIGHGUID_DYNAMICOBJECT HighGuid::DynamicObject
#endif
#ifndef HIGHGUID_CORPSE
#define HIGHGUID_CORPSE HighGuid::Corpse
#endif
#ifndef HIGHGUID_ITEM
#define HIGHGUID_ITEM HighGuid::Item
#endif
#ifndef HIGHGUID_INSTANCE
#define HIGHGUID_INSTANCE HighGuid::Instance
#endif
#ifndef HIGHGUID_GROUP
#define HIGHGUID_GROUP HighGuid::Group
#endif
#ifndef HIGHGUID_CONTAINER
#define HIGHGUID_CONTAINER HighGuid::Container
#endif
#ifndef MAKE_NEW_GUID #ifndef MAKE_NEW_GUID
#define MAKE_NEW_GUID(l, e, h) ObjectGuid(h, e, l) #define MAKE_NEW_GUID(l, e, h) ObjectGuid(h, e, l)
#endif #endif

View File

@@ -157,7 +157,7 @@ namespace LuaGameObject
int GetDBTableGUIDLow(Eluna* /*E*/, lua_State* L, GameObject* go) int GetDBTableGUIDLow(Eluna* /*E*/, lua_State* L, GameObject* go)
{ {
#ifdef TRINITY #ifdef TRINITY
Eluna::Push(L, go->GetDBTableGUIDLow()); Eluna::Push(L, go->GetSpawnId());
#else #else
// on mangos based this is same as lowguid // on mangos based this is same as lowguid
Eluna::Push(L, go->GetGUIDLow()); Eluna::Push(L, go->GetGUIDLow());

View File

@@ -438,12 +438,12 @@ namespace LuaGlobalFunctions
* GUID consist of entry ID, low GUID, and type ID. * GUID consist of entry ID, low GUID, and type ID.
* *
* @param uint64 guid : GUID of an [Object] * @param uint64 guid : GUID of an [Object]
* @return uint32 typeId : type ID of the [Object] * @return int32 typeId : type ID of the [Object]
*/ */
int GetGUIDType(Eluna* /*E*/, lua_State* L) int GetGUIDType(Eluna* /*E*/, lua_State* L)
{ {
uint64 guid = Eluna::CHECKVAL<uint64>(L, 1); uint64 guid = Eluna::CHECKVAL<uint64>(L, 1);
Eluna::Push(L, GUID_HIPART(guid)); Eluna::Push(L, static_cast<int>(GUID_HIPART(guid)));
return 1; return 1;
} }
@@ -1632,7 +1632,7 @@ namespace LuaGlobalFunctions
if (save) if (save)
{ {
Creature* creature = new Creature(); Creature* creature = new Creature();
if (!creature->Create(eObjectMgr->GenerateLowGuid(HIGHGUID_UNIT), map, phase, entry, x, y, z, o)) if (!creature->Create(map->GenerateLowGuid<HighGuid::Unit>(), map, phase, entry, x, y, z, o))
{ {
delete creature; delete creature;
Eluna::Push(L); Eluna::Push(L);
@@ -1641,15 +1641,21 @@ namespace LuaGlobalFunctions
creature->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), phase); creature->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), phase);
uint32 db_lowguid = creature->GetDBTableGUIDLow(); uint32 db_guid = creature->GetSpawnId();
if (!creature->LoadCreatureFromDB(db_lowguid, map))
// To call _LoadGoods(); _LoadQuests(); CreateTrainerSpells()
// current "creature" variable is deleted and created fresh new, otherwise old values might trigger asserts or cause undefined behavior
creature->CleanupsBeforeDelete();
delete creature;
creature = new Creature();
if (!creature->LoadCreatureFromDB(db_guid, map))
{ {
delete creature; delete creature;
Eluna::Push(L); Eluna::Push(L);
return 1; return 1;
} }
eObjectMgr->AddCreatureToGrid(db_lowguid, eObjectMgr->GetCreatureData(db_lowguid)); eObjectMgr->AddCreatureToGrid(db_guid, eObjectMgr->GetCreatureData(db_guid));
Eluna::Push(L, creature); Eluna::Push(L, creature);
} }
else else
@@ -1688,9 +1694,9 @@ namespace LuaGlobalFunctions
} }
GameObject* object = new GameObject; GameObject* object = new GameObject;
uint32 lowguid = eObjectMgr->GenerateLowGuid(HIGHGUID_GAMEOBJECT); uint32 guidLow = map->GenerateLowGuid<HighGuid::GameObject>();
if (!object->Create(lowguid, objectInfo->entry, map, phase, x, y, z, o, 0.0f, 0.0f, 0.0f, 0.0f, 0, GO_STATE_READY)) if (!object->Create(guidLow, objectInfo->entry, map, phase, x, y, z, o, 0.0f, 0.0f, 0.0f, 0.0f, 0, GO_STATE_READY))
{ {
delete object; delete object;
Eluna::Push(L); Eluna::Push(L);
@@ -1706,14 +1712,14 @@ namespace LuaGlobalFunctions
object->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), phase); object->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), phase);
// this will generate a new lowguid if the object is in an instance // this will generate a new lowguid if the object is in an instance
if (!object->LoadGameObjectFromDB(lowguid, map)) if (!object->LoadGameObjectFromDB(guidLow, map))
{ {
delete object; delete object;
Eluna::Push(L); Eluna::Push(L);
return 1; return 1;
} }
eObjectMgr->AddGameobjectToGrid(lowguid, eObjectMgr->GetGOData(lowguid)); eObjectMgr->AddGameobjectToGrid(guidLow, eObjectMgr->GetGOData(guidLow));
} }
else else
map->AddToMap(object); map->AddToMap(object);

View File

@@ -101,6 +101,22 @@ void Eluna::LoadScriptPaths()
ELUNA_LOG_DEBUG("[Eluna]: Loaded %u scripts in %u ms", uint32(lua_scripts.size() + lua_extensions.size()), ElunaUtil::GetTimeDiff(oldMSTime)); ELUNA_LOG_DEBUG("[Eluna]: Loaded %u scripts in %u ms", uint32(lua_scripts.size() + lua_extensions.size()), ElunaUtil::GetTimeDiff(oldMSTime));
} }
#ifdef TRINITY
class ElunaAIUpdateWorker
{
public:
void Visit(std::unordered_map<ObjectGuid, Creature*>& creatureMap)
{
for (auto const& p : creatureMap)
if (p.second->IsInWorld())
p.second->AIM_Initialize();
}
template<class T>
void Visit(std::unordered_map<ObjectGuid, T*>&) { }
};
#endif
void Eluna::_ReloadEluna() void Eluna::_ReloadEluna()
{ {
LOCK_ELUNA; LOCK_ELUNA;
@@ -125,12 +141,12 @@ void Eluna::_ReloadEluna()
#ifdef TRINITY #ifdef TRINITY
// Re initialize creature AI restoring C++ AI or applying lua AI // Re initialize creature AI restoring C++ AI or applying lua AI
sMapMgr->DoForAllMaps([](Map* map)
{ {
HashMapHolder<Creature>::MapType const m = ObjectAccessor::GetCreatures(); ElunaAIUpdateWorker worker;
for (HashMapHolder<Creature>::MapType::const_iterator iter = m.begin(); iter != m.end(); ++iter) TypeContainerVisitor<ElunaAIUpdateWorker, MapStoredObjectTypesContainer> visitor(worker);
if (iter->second->IsInWorld()) visitor.Visit(map->GetObjectsStore());
iter->second->AIM_Initialize(); });
}
#endif #endif
reload = false; reload = false;

View File

@@ -213,25 +213,25 @@ namespace LuaMap
switch (GUID_HIPART(guid)) switch (GUID_HIPART(guid))
{ {
case HIGHGUID_PLAYER: case HIGHGUID_PLAYER:
Eluna::Push(L, sObjectAccessor->GetObjectInMap(ObjectGuid(guid), map, (Player*)NULL)); Eluna::Push(L, sObjectAccessor->GetPlayer(map, ObjectGuid(guid)));
break; break;
case HIGHGUID_TRANSPORT: case HIGHGUID_TRANSPORT:
case HIGHGUID_MO_TRANSPORT: case HIGHGUID_MO_TRANSPORT:
case HIGHGUID_GAMEOBJECT: case HIGHGUID_GAMEOBJECT:
Eluna::Push(L, sObjectAccessor->GetObjectInMap(ObjectGuid(guid), map, (GameObject*)NULL)); Eluna::Push(L, map->GetGameObject(ObjectGuid(guid)));
break; break;
case HIGHGUID_VEHICLE: case HIGHGUID_VEHICLE:
case HIGHGUID_UNIT: case HIGHGUID_UNIT:
Eluna::Push(L, sObjectAccessor->GetObjectInMap(ObjectGuid(guid), map, (Creature*)NULL)); Eluna::Push(L, map->GetCreature(ObjectGuid(guid)));
break; break;
case HIGHGUID_PET: case HIGHGUID_PET:
Eluna::Push(L, sObjectAccessor->GetObjectInMap(ObjectGuid(guid), map, (Pet*)NULL)); Eluna::Push(L, map->GetPet(ObjectGuid(guid)));
break; break;
case HIGHGUID_DYNAMICOBJECT: case HIGHGUID_DYNAMICOBJECT:
Eluna::Push(L, sObjectAccessor->GetObjectInMap(ObjectGuid(guid), map, (DynamicObject*)NULL)); Eluna::Push(L, map->GetDynamicObject(ObjectGuid(guid)));
break; break;
case HIGHGUID_CORPSE: case HIGHGUID_CORPSE:
Eluna::Push(L, sObjectAccessor->GetObjectInMap(ObjectGuid(guid), map, (Corpse*)NULL)); Eluna::Push(L, map->GetCorpse(ObjectGuid(guid)));
break; break;
default: default:
break; break;

View File

@@ -182,7 +182,11 @@ namespace LuaObject
*/ */
int GetGUIDLow(Eluna* /*E*/, lua_State* L, Object* obj) int GetGUIDLow(Eluna* /*E*/, lua_State* L, Object* obj)
{ {
#ifdef TRINITY
Eluna::Push(L, obj->GetGUID().GetCounter());
#else
Eluna::Push(L, obj->GetGUIDLow()); Eluna::Push(L, obj->GetGUIDLow());
#endif
return 1; return 1;
} }

View File

@@ -2157,7 +2157,11 @@ namespace LuaPlayer
target->SetSummonPoint(map, x, y, z); target->SetSummonPoint(map, x, y, z);
WorldPacket data(SMSG_SUMMON_REQUEST, 8 + 4 + 4); WorldPacket data(SMSG_SUMMON_REQUEST, 8 + 4 + 4);
#ifdef TRINITY
data << uint64(player->GetGUID().GetCounter());
#else
data << uint64(player->GetGUIDLow()); data << uint64(player->GetGUIDLow());
#endif
data << uint32(zoneId); data << uint32(zoneId);
data << uint32(delay); data << uint32(delay);
target->GetSession()->SendPacket(&data); target->GetSession()->SendPacket(&data);
@@ -2228,7 +2232,11 @@ namespace LuaPlayer
return 0; return 0;
WorldPacket data(MSG_AUCTION_HELLO, 12); WorldPacket data(MSG_AUCTION_HELLO, 12);
#ifdef TRINITY
data << uint64(unit->GetGUID().GetCounter());
#else
data << uint64(unit->GetGUIDLow()); data << uint64(unit->GetGUIDLow());
#endif
data << uint32(ahEntry->houseId); data << uint32(ahEntry->houseId);
data << uint8(1); data << uint8(1);
player->GetSession()->SendPacket(&data); player->GetSession()->SendPacket(&data);
@@ -2846,7 +2854,7 @@ namespace LuaPlayer
// prepare Quest Tracker datas // prepare Quest Tracker datas
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_QUEST_TRACK_GM_COMPLETE); PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_QUEST_TRACK_GM_COMPLETE);
stmt->setUInt32(0, quest->GetQuestId()); stmt->setUInt32(0, quest->GetQuestId());
stmt->setUInt32(1, player->GetGUIDLow()); stmt->setUInt32(1, player->GetGUID().GetCounter());
// add to Quest Tracker // add to Quest Tracker
CharacterDatabase.Execute(stmt); CharacterDatabase.Execute(stmt);