Some fixes for GameObject, Chat, Creature, update DuelHandler for 322a

--HG--
branch : trunk
This commit is contained in:
n0n4m3
2009-12-17 11:06:50 +01:00
parent a7c0f6beb3
commit 40255a660b
11 changed files with 103 additions and 53 deletions
+69 -14
View File
@@ -165,11 +165,12 @@ ChatCommand * ChatHandler::getCommandTable()
{ "getitemstate", SEC_ADMINISTRATOR, false, &ChatHandler::HandleDebugGetItemStateCommand, "", NULL },
{ "lootrecipient", SEC_GAMEMASTER, false, &ChatHandler::HandleDebugGetLootRecipientCommand, "", NULL },
{ "getvalue", SEC_ADMINISTRATOR, false, &ChatHandler::HandleDebugGetValueCommand, "", NULL },
{ "getitemvalue", SEC_ADMINISTRATOR, false, &ChatHandler::HandleDebugGetItemValueCommand, "", NULL },
{ "Mod32Value", SEC_ADMINISTRATOR, false, &ChatHandler::HandleDebugMod32ValueCommand, "", NULL },
{ "play", SEC_MODERATOR, false, NULL, "", debugPlayCommandTable },
{ "send", SEC_ADMINISTRATOR, false, NULL, "", debugSendCommandTable },
{ "setaurastate", SEC_ADMINISTRATOR, false, &ChatHandler::HandleDebugSetAuraStateCommand, "", NULL },
{ "setitemflag", SEC_ADMINISTRATOR, false, &ChatHandler::HandleDebugSetItemFlagCommand, "", NULL },
{ "setitemvalue", SEC_ADMINISTRATOR, false, &ChatHandler::HandleDebugSetItemValueCommand, "", NULL },
{ "setvalue", SEC_ADMINISTRATOR, false, &ChatHandler::HandleDebugSetValueCommand, "", NULL },
{ "spawnvehicle", SEC_ADMINISTRATOR, false, &ChatHandler::HandleDebugSpawnVehicle, "", NULL },
{ "setvid", SEC_ADMINISTRATOR, false, &ChatHandler::HandleDebugSetVehicleId, "", NULL },
@@ -1164,6 +1165,8 @@ valid examples:
Quest const* linkedQuest;
SpellEntry const *linkedSpell;
AchievementEntry const* linkedAchievement;
ItemRandomPropertiesEntry const* itemProperty;
ItemRandomSuffixEntry const* itemSuffix;
while(!reader.eof())
{
@@ -1173,6 +1176,8 @@ valid examples:
linkedQuest = NULL;
linkedSpell = NULL;
linkedAchievement = NULL;
itemProperty = NULL;
itemSuffix = NULL;
reader.ignore(255, '|');
}
@@ -1289,9 +1294,47 @@ valid examples:
return false;
}
char c = reader.peek();
// the itementry is followed by several integers which describe an instance of this item
// ignore enchants etc.
// position relative after itemEntry
const uint8 randomPropertyPosition = 6;
int32 propertyId = 0;
bool negativeNumber = false;
char c;
for(uint8 i=0; i<randomPropertyPosition; ++i)
{
propertyId = 0;
negativeNumber = false;
while((c = reader.get())!=':')
{
if(c >='0' && c<='9')
{
propertyId*=10;
propertyId += c-'0';
} else if(c == '-')
negativeNumber = true;
else
return false;
}
}
if (negativeNumber)
propertyId *= -1;
if (propertyId > 0)
{
itemProperty = sItemRandomPropertiesStore.LookupEntry(propertyId);
if (!itemProperty)
return false;
}
else if(propertyId < 0)
{
itemSuffix = sItemRandomSuffixStore.LookupEntry(-propertyId);
if (!itemSuffix)
return false;
}
// ignore other integers
while((c >='0' && c <='9') || c==':')
{
reader.ignore(1);
@@ -1560,22 +1603,34 @@ valid examples:
}
else if (linkedItem)
{
if (strcmp(linkedItem->Name1, buffer) != 0)
char* const* suffix = itemSuffix?itemSuffix->nameSuffix:(itemProperty?itemProperty->nameSuffix:NULL);
std::string expectedName = std::string(linkedItem->Name1);
if (suffix)
{
expectedName += " ";
expectedName += suffix[LOCALE_enUS];
}
if (expectedName != buffer)
{
ItemLocale const *il = objmgr.GetItemLocale(linkedItem->ItemId);
if (!il)
{
#ifdef MANGOS_DEBUG
sLog.outBasic("ChatHandler::isValidChatMessage linked item name doesn't is wrong and there is no localization");
#endif
return false;
}
bool foundName = false;
for (uint8 i=0; i<il->Name.size(); ++i)
for(uint8 i=LOCALE_koKR; i<MAX_LOCALE; ++i)
{
if (il->Name[i] == buffer)
int8 dbIndex = objmgr.GetIndexForLocale(LocaleConstant(i));
if (dbIndex == -1 || il == NULL || dbIndex >= il->Name.size())
// using strange database/client combinations can lead to this case
expectedName = linkedItem->Name1;
else
expectedName = il->Name[dbIndex];
if (suffix)
{
expectedName += " ";
expectedName += suffix[i];
}
if ( expectedName == buffer)
{
foundName = true;
break;
+2 -1
View File
@@ -144,9 +144,10 @@ class TRINITY_DLL_SPEC ChatHandler
bool HandleDebugGetItemStateCommand(const char * args);
bool HandleDebugGetLootRecipientCommand(const char * args);
bool HandleDebugGetValueCommand(const char* args);
bool HandleDebugGetItemValueCommand(const char* args);
bool HandleDebugMod32ValueCommand(const char* args);
bool HandleDebugSetAuraStateCommand(const char * args);
bool HandleDebugSetItemFlagCommand(const char * args);
bool HandleDebugSetItemValueCommand(const char * args);
bool HandleDebugItemExpireCommand(const char * args);
bool HandleDebugSetVehicleId(const char * args);
bool HandleDebugEnterVehicle(const char * args);
+12 -8
View File
@@ -261,22 +261,27 @@ bool Creature::InitEntry(uint32 Entry, uint32 team, const CreatureData *data )
return false;
}
// get heroic mode entry
// get difficulty 1 mode entry
uint32 actualEntry = Entry;
CreatureInfo const *cinfo = normalInfo;
if(normalInfo->HeroicEntry)
// TODO correctly implement spawnmodes for non-bg maps
for (uint32 diff = 0; diff < MAX_DIFFICULTY - 1; ++diff)
{
if (normalInfo->DifficultyEntry[diff])
{
// we already have valid Map pointer for current creature!
if(GetMap()->IsHeroic())
if (GetMap()->GetSpawnMode() > diff)
{
cinfo = objmgr.GetCreatureTemplate(normalInfo->HeroicEntry);
cinfo = objmgr.GetCreatureTemplate(normalInfo->DifficultyEntry[diff]);
if (!cinfo)
{
sLog.outErrorDb("Creature::UpdateEntry creature heroic entry %u does not exist.", actualEntry);
// maybe check such things already at startup
sLog.outErrorDb("Creature::UpdateEntry creature difficulty %u entry %u does not exist.", diff + 1, actualEntry);
return false;
}
}
}
}
SetEntry(Entry); // normal entry always
m_creatureInfo = cinfo; // map mode related always
@@ -1565,7 +1570,7 @@ bool Creature::LoadFromDB(uint32 guid, Map *map)
m_deathState = DEAD;
if(canFly())
{
float tz = GetMap()->GetHeight(data->posX,data->posY,data->posZ,false);
float tz = map->GetHeight(data->posX,data->posY,data->posZ,false);
if(data->posZ - tz > 0.1)
Relocate(data->posX,data->posY,tz);
}
@@ -2265,7 +2270,7 @@ CreatureDataAddon const* Creature::GetCreatureAddon() const
return addon;
}
// dependent from heroic mode entry
// dependent from difficulty mode entry
return ObjectMgr::GetCreatureTemplateAddon(GetCreatureInfo()->Entry);
}
@@ -2671,4 +2676,3 @@ time_t Creature::GetLinkedCreatureRespawnTime() const
return 0;
}
+2 -3
View File
@@ -167,7 +167,7 @@ enum CreatureFlagsExtra
struct CreatureInfo
{
uint32 Entry;
uint32 HeroicEntry;
uint32 DifficultyEntry[MAX_DIFFICULTY - 1];
uint32 KillCredit[MAX_KILL_CREDIT];
uint32 Modelid1;
uint32 Modelid2;
@@ -783,7 +783,7 @@ class TRINITY_DLL_SPEC Creature : public Unit
bool DisableReputationGain;
CreatureInfo const* m_creatureInfo; // in heroic mode can different from ObjMgr::GetCreatureTemplate(GetEntry())
CreatureInfo const* m_creatureInfo; // in difficulty mode > 0 can different from ObjMgr::GetCreatureTemplate(GetEntry())
CreatureData const* m_creatureData;
uint16 m_LootMode; // bitmask, default DEFAULT_LOOT_MODE, determines what loot will be lootable
@@ -814,4 +814,3 @@ class AssistDelayEvent : public BasicEvent
};
#endif
+2 -3
View File
@@ -71,10 +71,9 @@ CreatureEventAI::CreatureEventAI(Creature *c ) : CreatureAI(c)
if ((*i).event_flags & EFLAG_DEBUG_ONLY)
continue;
#endif
if(((*i).event_flags & (EFLAG_HEROIC | EFLAG_NORMAL)) && m_creature->GetMap()->IsDungeon() )
if(m_creature->GetMap()->IsDungeon())
{
if( (m_creature->GetMap()->IsHeroic() && (*i).event_flags & EFLAG_HEROIC) ||
(!m_creature->GetMap()->IsHeroic() && (*i).event_flags & EFLAG_NORMAL))
if ((1 << (m_creature->GetMap()->GetSpawnMode()+1)) & (*i).event_flags)
{
//event flagged for instance mode
CreatureEventAIList.push_back(CreatureEventAIHolder(*i));
+6 -4
View File
@@ -160,13 +160,15 @@ enum CastFlags
enum EventFlags
{
EFLAG_REPEATABLE = 0x01, //Event repeats
EFLAG_NORMAL = 0x02, //Event only occurs in Normal instance difficulty
EFLAG_HEROIC = 0x04, //Event only occurs in Heroic instance difficulty
EFLAG_RESERVED_3 = 0x08,
EFLAG_RESERVED_4 = 0x10,
EFLAG_DIFFICULTY_0 = 0x02, //Event only occurs in instance difficulty 0
EFLAG_DIFFICULTY_1 = 0x04, //Event only occurs in instance difficulty 1
EFLAG_DIFFICULTY_2 = 0x08, //Event only occurs in instance difficulty 2
EFLAG_DIFFICULTY_3 = 0x10, //Event only occurs in instance difficulty 3
EFLAG_RESERVED_5 = 0x20,
EFLAG_RESERVED_6 = 0x40,
EFLAG_DEBUG_ONLY = 0x80, //Event only occurs in debug build
EFLAG_DIFFICULTY_ALL = (EFLAG_DIFFICULTY_0|EFLAG_DIFFICULTY_1|EFLAG_DIFFICULTY_2|EFLAG_DIFFICULTY_3)
};
enum SpawnedEventMode
+4 -4
View File
@@ -640,14 +640,14 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts()
sLog.outErrorDb("CreatureEventAI: Event %u Action %u uses incorrect Target type", i, j+1);
break;
case ACTION_T_SET_INST_DATA:
if (!(temp.event_flags & EFLAG_NORMAL) && !(temp.event_flags & EFLAG_HEROIC))
sLog.outErrorDb("CreatureEventAI: Event %u Action %u. Cannot set instance data without event flags (normal/heroic).", i, j+1);
if (!(temp.event_flags & EFLAG_DIFFICULTY_ALL))
sLog.outErrorDb("CreatureEventAI: Event %u Action %u. Cannot set instance data without difficulty event flags.", i, j+1);
if (action.set_inst_data.value > 4/*SPECIAL*/)
sLog.outErrorDb("CreatureEventAI: Event %u Action %u attempts to set instance data above encounter state 4. Custom case?", i, j+1);
break;
case ACTION_T_SET_INST_DATA64:
if (!(temp.event_flags & EFLAG_NORMAL) && !(temp.event_flags & EFLAG_HEROIC))
sLog.outErrorDb("CreatureEventAI: Event %u Action %u. Cannot set instance data without event flags (normal/heroic).", i, j+1);
if (!(temp.event_flags & EFLAG_DIFFICULTY_ALL))
sLog.outErrorDb("CreatureEventAI: Event %u Action %u. Cannot set instance data without difficulty event flags.", i, j+1);
if (action.set_inst_data64.target >= TARGET_T_END)
sLog.outErrorDb("CreatureEventAI: Event %u Action %u uses incorrect Target type", i, j+1);
break;
+2 -5
View File
@@ -51,10 +51,8 @@ void WorldSession::HandleDuelAcceptedOpcode(WorldPacket& recvPacket)
pl->duel->startTimer = now;
plTarget->duel->startTimer = now;
WorldPacket data(SMSG_DUEL_COUNTDOWN, 4);
data << (uint32)3000; // 3 seconds
pl->GetSession()->SendPacket(&data);
plTarget->GetSession()->SendPacket(&data);
pl->SendDuelCountdown(3000);
plTarget->SendDuelCountdown(3000);
}
void WorldSession::HandleDuelCancelledOpcode(WorldPacket& recvPacket)
@@ -84,4 +82,3 @@ void WorldSession::HandleDuelCancelledOpcode(WorldPacket& recvPacket)
GetPlayer()->DuelComplete(DUEL_INTERUPTED);
}
+1 -5
View File
@@ -33,7 +33,7 @@ DynamicObject::DynamicObject() : WorldObject()
m_objectType |= TYPEMASK_DYNAMICOBJECT;
m_objectTypeId = TYPEID_DYNAMICOBJECT;
m_updateFlag = (UPDATEFLAG_HIGHGUID | UPDATEFLAG_HAS_POSITION);
m_updateFlag = (UPDATEFLAG_HIGHGUID | UPDATEFLAG_HAS_POSITION | UPDATEFLAG_POSITION);
m_valuesCount = DYNAMICOBJECT_END;
}
@@ -88,9 +88,6 @@ bool DynamicObject::Create(uint32 guidlow, Unit *caster, uint32 spellId, uint32
SetUInt32Value( DYNAMICOBJECT_BYTES, 0x00000001 );
SetUInt32Value( DYNAMICOBJECT_SPELLID, spellId );
SetFloatValue( DYNAMICOBJECT_RADIUS, radius);
SetFloatValue( DYNAMICOBJECT_POS_X, pos.m_positionX );
SetFloatValue( DYNAMICOBJECT_POS_Y, pos.m_positionY );
SetFloatValue( DYNAMICOBJECT_POS_Z, pos.m_positionZ );
SetUInt32Value( DYNAMICOBJECT_CASTTIME, getMSTime() ); // new 2.4.0
m_aliveDuration = duration;
@@ -184,4 +181,3 @@ bool DynamicObject::isVisibleForInState(Player const* u, bool inVisibleList) con
return IsInWorld() && u->IsInWorld()
&& (IsWithinDistInMap(u->m_seer,World::GetMaxVisibleDistanceForObject()+(inVisibleList ? World::GetVisibleObjectGreyDistance() : 0.0f), false));
}
-2
View File
@@ -64,11 +64,9 @@ class DynamicObject : public WorldObject
uint32 m_effMask;
int32 m_aliveDuration;
uint32 m_updateTimer;
time_t m_nextThinkTime;
float m_radius;
AffectedSet m_affected;
private:
GridReference<DynamicObject> m_gridRef;
};
#endif
-1
View File
@@ -754,4 +754,3 @@ class TRINITY_DLL_SPEC GameObject : public WorldObject
GridReference<GameObject> m_gridRef;
};
#endif