mirror of
https://github.com/mangosfour/server.git
synced 2025-12-13 22:37:03 +00:00
[10752] Convert to objetguids map scripts and finally drop IS_PLAYER_GUID.
This commit is contained in:
parent
2601022b9f
commit
c2096380cf
4 changed files with 49 additions and 52 deletions
|
|
@ -40,9 +40,9 @@
|
||||||
|
|
||||||
struct ScriptAction
|
struct ScriptAction
|
||||||
{
|
{
|
||||||
uint64 sourceGUID;
|
ObjectGuid sourceGuid;
|
||||||
uint64 targetGUID;
|
ObjectGuid targetGuid;
|
||||||
uint64 ownerGUID; // owner of source if source is item
|
ObjectGuid ownerGuid; // owner of source if source is item
|
||||||
ScriptInfo const* script; // pointer to static script data
|
ScriptInfo const* script; // pointer to static script data
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -1681,8 +1681,8 @@ void Map::ScriptsStart(ScriptMapMap const& scripts, uint32 id, Object* source, O
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// prepare static data
|
// prepare static data
|
||||||
uint64 sourceGUID = source->GetGUID();
|
ObjectGuid sourceGuid = source->GetObjectGuid();
|
||||||
uint64 targetGUID = target ? target->GetGUID() : (uint64)0;
|
ObjectGuid targetGuid = target ? target->GetObjectGuid() : ObjectGuid();
|
||||||
ObjectGuid ownerGuid = (source->GetTypeId()==TYPEID_ITEM) ? ((Item*)source)->GetOwnerGuid() : ObjectGuid();
|
ObjectGuid ownerGuid = (source->GetTypeId()==TYPEID_ITEM) ? ((Item*)source)->GetOwnerGuid() : ObjectGuid();
|
||||||
|
|
||||||
///- Schedule script execution for all scripts in the script map
|
///- Schedule script execution for all scripts in the script map
|
||||||
|
|
@ -1691,9 +1691,9 @@ void Map::ScriptsStart(ScriptMapMap const& scripts, uint32 id, Object* source, O
|
||||||
for (ScriptMap::const_iterator iter = s2->begin(); iter != s2->end(); ++iter)
|
for (ScriptMap::const_iterator iter = s2->begin(); iter != s2->end(); ++iter)
|
||||||
{
|
{
|
||||||
ScriptAction sa;
|
ScriptAction sa;
|
||||||
sa.sourceGUID = sourceGUID;
|
sa.sourceGuid = sourceGuid;
|
||||||
sa.targetGUID = targetGUID;
|
sa.targetGuid = targetGuid;
|
||||||
sa.ownerGUID = ownerGuid.GetRawValue();
|
sa.ownerGuid = ownerGuid;
|
||||||
|
|
||||||
sa.script = &iter->second;
|
sa.script = &iter->second;
|
||||||
m_scriptSchedule.insert(std::pair<time_t, ScriptAction>(time_t(sWorld.GetGameTime() + iter->first), sa));
|
m_scriptSchedule.insert(std::pair<time_t, ScriptAction>(time_t(sWorld.GetGameTime() + iter->first), sa));
|
||||||
|
|
@ -1712,14 +1712,14 @@ void Map::ScriptCommandStart(ScriptInfo const& script, uint32 delay, Object* sou
|
||||||
// NOTE: script record _must_ exist until command executed
|
// NOTE: script record _must_ exist until command executed
|
||||||
|
|
||||||
// prepare static data
|
// prepare static data
|
||||||
uint64 sourceGUID = source->GetGUID();
|
ObjectGuid sourceGuid = source->GetObjectGuid();
|
||||||
uint64 targetGUID = target ? target->GetGUID() : (uint64)0;
|
ObjectGuid targetGuid = target ? target->GetObjectGuid() : ObjectGuid();
|
||||||
ObjectGuid ownerGuid = (source->GetTypeId()==TYPEID_ITEM) ? ((Item*)source)->GetOwnerGuid() : ObjectGuid();
|
ObjectGuid ownerGuid = (source->GetTypeId()==TYPEID_ITEM) ? ((Item*)source)->GetOwnerGuid() : ObjectGuid();
|
||||||
|
|
||||||
ScriptAction sa;
|
ScriptAction sa;
|
||||||
sa.sourceGUID = sourceGUID;
|
sa.sourceGuid = sourceGuid;
|
||||||
sa.targetGUID = targetGUID;
|
sa.targetGuid = targetGuid;
|
||||||
sa.ownerGUID = ownerGuid.GetRawValue();
|
sa.ownerGuid = ownerGuid;
|
||||||
|
|
||||||
sa.script = &script;
|
sa.script = &script;
|
||||||
m_scriptSchedule.insert(std::pair<time_t, ScriptAction>(time_t(sWorld.GetGameTime() + delay), sa));
|
m_scriptSchedule.insert(std::pair<time_t, ScriptAction>(time_t(sWorld.GetGameTime() + delay), sa));
|
||||||
|
|
@ -1746,38 +1746,37 @@ void Map::ScriptsProcess()
|
||||||
|
|
||||||
Object* source = NULL;
|
Object* source = NULL;
|
||||||
|
|
||||||
if (step.sourceGUID)
|
if (!step.sourceGuid.IsEmpty())
|
||||||
{
|
{
|
||||||
switch(GUID_HIPART(step.sourceGUID))
|
switch(step.sourceGuid.GetHigh())
|
||||||
{
|
{
|
||||||
case HIGHGUID_ITEM:
|
case HIGHGUID_ITEM:
|
||||||
// case HIGHGUID_CONTAINER: ==HIGHGUID_ITEM
|
// case HIGHGUID_CONTAINER: ==HIGHGUID_ITEM
|
||||||
{
|
{
|
||||||
Player* player = HashMapHolder<Player>::Find(step.ownerGUID);
|
if (Player* player = HashMapHolder<Player>::Find(step.ownerGuid))
|
||||||
if(player)
|
source = player->GetItemByGuid(step.sourceGuid);
|
||||||
source = player->GetItemByGuid(step.sourceGUID);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case HIGHGUID_UNIT:
|
case HIGHGUID_UNIT:
|
||||||
source = GetCreature(step.sourceGUID);
|
source = GetCreature(step.sourceGuid);
|
||||||
break;
|
break;
|
||||||
case HIGHGUID_PET:
|
case HIGHGUID_PET:
|
||||||
source = GetPet(step.sourceGUID);
|
source = GetPet(step.sourceGuid);
|
||||||
break;
|
break;
|
||||||
case HIGHGUID_VEHICLE:
|
case HIGHGUID_VEHICLE:
|
||||||
source = GetVehicle(step.sourceGUID);
|
source = GetVehicle(step.sourceGuid);
|
||||||
break;
|
break;
|
||||||
case HIGHGUID_PLAYER:
|
case HIGHGUID_PLAYER:
|
||||||
source = HashMapHolder<Player>::Find(step.sourceGUID);
|
source = HashMapHolder<Player>::Find(step.sourceGuid);
|
||||||
break;
|
break;
|
||||||
case HIGHGUID_GAMEOBJECT:
|
case HIGHGUID_GAMEOBJECT:
|
||||||
source = GetGameObject(step.sourceGUID);
|
source = GetGameObject(step.sourceGuid);
|
||||||
break;
|
break;
|
||||||
case HIGHGUID_CORPSE:
|
case HIGHGUID_CORPSE:
|
||||||
source = HashMapHolder<Corpse>::Find(step.sourceGUID);
|
source = HashMapHolder<Corpse>::Find(step.sourceGuid);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
sLog.outError("*_script source with unsupported high guid value %u",GUID_HIPART(step.sourceGUID));
|
sLog.outError("*_script source with unsupported guid %s", step.sourceGuid.GetString().c_str());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1787,30 +1786,30 @@ void Map::ScriptsProcess()
|
||||||
|
|
||||||
Object* target = NULL;
|
Object* target = NULL;
|
||||||
|
|
||||||
if (step.targetGUID)
|
if (!step.targetGuid.IsEmpty())
|
||||||
{
|
{
|
||||||
switch(GUID_HIPART(step.targetGUID))
|
switch(step.targetGuid.GetHigh())
|
||||||
{
|
{
|
||||||
case HIGHGUID_UNIT:
|
case HIGHGUID_UNIT:
|
||||||
target = GetCreature(step.targetGUID);
|
target = GetCreature(step.targetGuid);
|
||||||
break;
|
break;
|
||||||
case HIGHGUID_PET:
|
case HIGHGUID_PET:
|
||||||
target = GetPet(step.targetGUID);
|
target = GetPet(step.targetGuid);
|
||||||
break;
|
break;
|
||||||
case HIGHGUID_VEHICLE:
|
case HIGHGUID_VEHICLE:
|
||||||
target = GetVehicle(step.targetGUID);
|
target = GetVehicle(step.targetGuid);
|
||||||
break;
|
break;
|
||||||
case HIGHGUID_PLAYER: // empty GUID case also
|
case HIGHGUID_PLAYER:
|
||||||
target = HashMapHolder<Player>::Find(step.targetGUID);
|
target = HashMapHolder<Player>::Find(step.targetGuid);
|
||||||
break;
|
break;
|
||||||
case HIGHGUID_GAMEOBJECT:
|
case HIGHGUID_GAMEOBJECT:
|
||||||
target = GetGameObject(step.targetGUID);
|
target = GetGameObject(step.targetGuid);
|
||||||
break;
|
break;
|
||||||
case HIGHGUID_CORPSE:
|
case HIGHGUID_CORPSE:
|
||||||
target = HashMapHolder<Corpse>::Find(step.targetGUID);
|
target = HashMapHolder<Corpse>::Find(step.targetGuid);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
sLog.outError("*_script source with unsupported high guid value %u",GUID_HIPART(step.targetGUID));
|
sLog.outError("*_script target with unsupported guid %s", step.targetGuid.GetString().c_str());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1878,7 +1877,7 @@ void Map::ScriptsProcess()
|
||||||
if (step.script->talk.flags & 0x02)
|
if (step.script->talk.flags & 0x02)
|
||||||
target = source;
|
target = source;
|
||||||
|
|
||||||
uint64 unit_target = target ? target->GetGUID() : 0;
|
ObjectGuid unitTargetGuid = target ? target->GetObjectGuid() : ObjectGuid();
|
||||||
int32 textId = step.script->talk.textId[0];
|
int32 textId = step.script->talk.textId[0];
|
||||||
|
|
||||||
// May have text for random
|
// May have text for random
|
||||||
|
|
@ -1898,35 +1897,35 @@ void Map::ScriptsProcess()
|
||||||
switch(step.script->talk.chatType)
|
switch(step.script->talk.chatType)
|
||||||
{
|
{
|
||||||
case CHAT_TYPE_SAY:
|
case CHAT_TYPE_SAY:
|
||||||
pSource->MonsterSay(textId, step.script->talk.language, unit_target);
|
pSource->MonsterSay(textId, step.script->talk.language, unitTargetGuid);
|
||||||
break;
|
break;
|
||||||
case CHAT_TYPE_YELL:
|
case CHAT_TYPE_YELL:
|
||||||
pSource->MonsterYell(textId, step.script->talk.language, unit_target);
|
pSource->MonsterYell(textId, step.script->talk.language, unitTargetGuid);
|
||||||
break;
|
break;
|
||||||
case CHAT_TYPE_TEXT_EMOTE:
|
case CHAT_TYPE_TEXT_EMOTE:
|
||||||
pSource->MonsterTextEmote(textId, unit_target);
|
pSource->MonsterTextEmote(textId, unitTargetGuid);
|
||||||
break;
|
break;
|
||||||
case CHAT_TYPE_BOSS_EMOTE:
|
case CHAT_TYPE_BOSS_EMOTE:
|
||||||
pSource->MonsterTextEmote(textId, unit_target, true);
|
pSource->MonsterTextEmote(textId, unitTargetGuid, true);
|
||||||
break;
|
break;
|
||||||
case CHAT_TYPE_WHISPER:
|
case CHAT_TYPE_WHISPER:
|
||||||
if (!unit_target || !IS_PLAYER_GUID(unit_target))
|
if (!unitTargetGuid.IsPlayer())
|
||||||
{
|
{
|
||||||
sLog.outError("SCRIPT_COMMAND_TALK (script id %u) attempt to whisper (%u) 0-guid or non-player, skipping.", step.script->id, step.script->talk.chatType);
|
sLog.outError("SCRIPT_COMMAND_TALK (script id %u) attempt to whisper (%u) to %s, skipping.", step.script->id, step.script->talk.chatType, unitTargetGuid.GetString().c_str());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
pSource->MonsterWhisper(textId, unit_target);
|
pSource->MonsterWhisper(textId, unitTargetGuid);
|
||||||
break;
|
break;
|
||||||
case CHAT_TYPE_BOSS_WHISPER:
|
case CHAT_TYPE_BOSS_WHISPER:
|
||||||
if (!unit_target || !IS_PLAYER_GUID(unit_target))
|
if (!unitTargetGuid.IsPlayer())
|
||||||
{
|
{
|
||||||
sLog.outError("SCRIPT_COMMAND_TALK (script id %u) attempt to whisper (%u) 0-guid or non-player, skipping.", step.script->id, step.script->talk.chatType);
|
sLog.outError("SCRIPT_COMMAND_TALK (script id %u) attempt to whisper (%u) to %s, skipping.", step.script->id, step.script->talk.chatType, unitTargetGuid.GetString().c_str());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
pSource->MonsterWhisper(textId, unit_target, true);
|
pSource->MonsterWhisper(textId, unitTargetGuid, true);
|
||||||
break;
|
break;
|
||||||
case CHAT_TYPE_ZONE_YELL:
|
case CHAT_TYPE_ZONE_YELL:
|
||||||
pSource->MonsterYellToZone(textId, step.script->talk.language, unit_target);
|
pSource->MonsterYellToZone(textId, step.script->talk.language, unitTargetGuid);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break; // must be already checked at load
|
break; // must be already checked at load
|
||||||
|
|
|
||||||
|
|
@ -76,8 +76,6 @@ enum HighGuid
|
||||||
};
|
};
|
||||||
|
|
||||||
//*** Must be replaced by ObjectGuid use ***
|
//*** Must be replaced by ObjectGuid use ***
|
||||||
#define IS_PLAYER_GUID(Guid) ( GUID_HIPART(Guid) == HIGHGUID_PLAYER && Guid!=0 )
|
|
||||||
// special case for empty guid need check
|
|
||||||
#define GUID_HIPART(x) (uint32)((uint64(x) >> 48) & 0x0000FFFF)
|
#define GUID_HIPART(x) (uint32)((uint64(x) >> 48) & 0x0000FFFF)
|
||||||
|
|
||||||
// We have different low and middle part size for different guid types
|
// We have different low and middle part size for different guid types
|
||||||
|
|
|
||||||
|
|
@ -7518,7 +7518,7 @@ void ObjectMgr::DeleteRespawnTimeForInstance(uint32 instance)
|
||||||
next = itr;
|
next = itr;
|
||||||
++next;
|
++next;
|
||||||
|
|
||||||
if(GUID_HIPART(itr->first)==instance)
|
if (PAIR64_HIPART(itr->first)==instance)
|
||||||
mGORespawnTimes.erase(itr);
|
mGORespawnTimes.erase(itr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -7527,7 +7527,7 @@ void ObjectMgr::DeleteRespawnTimeForInstance(uint32 instance)
|
||||||
next = itr;
|
next = itr;
|
||||||
++next;
|
++next;
|
||||||
|
|
||||||
if(GUID_HIPART(itr->first)==instance)
|
if (PAIR64_HIPART(itr->first)==instance)
|
||||||
mCreatureRespawnTimes.erase(itr);
|
mCreatureRespawnTimes.erase(itr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#ifndef __REVISION_NR_H__
|
#ifndef __REVISION_NR_H__
|
||||||
#define __REVISION_NR_H__
|
#define __REVISION_NR_H__
|
||||||
#define REVISION_NR "10751"
|
#define REVISION_NR "10752"
|
||||||
#endif // __REVISION_NR_H__
|
#endif // __REVISION_NR_H__
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue