diff options
author | n0n4m3 <none@none> | 2009-12-17 11:06:50 +0100 |
---|---|---|
committer | n0n4m3 <none@none> | 2009-12-17 11:06:50 +0100 |
commit | 40255a660b3f3a16f5f5884ad0e04b8cec8ce25e (patch) | |
tree | 6ed77083d13bbd0bef3858d575e1cfeba3c77fca /src | |
parent | a7c0f6beb3635a28f8200828a8a1f96c1a17967a (diff) |
Some fixes for GameObject, Chat, Creature, update DuelHandler for 322a
--HG--
branch : trunk
Diffstat (limited to 'src')
-rw-r--r-- | src/game/Chat.cpp | 83 | ||||
-rw-r--r-- | src/game/Chat.h | 3 | ||||
-rw-r--r-- | src/game/Creature.cpp | 26 | ||||
-rw-r--r-- | src/game/Creature.h | 5 | ||||
-rw-r--r-- | src/game/CreatureEventAI.cpp | 5 | ||||
-rw-r--r-- | src/game/CreatureEventAI.h | 10 | ||||
-rw-r--r-- | src/game/CreatureEventAIMgr.cpp | 8 | ||||
-rw-r--r-- | src/game/DuelHandler.cpp | 7 | ||||
-rw-r--r-- | src/game/DynamicObject.cpp | 6 | ||||
-rw-r--r-- | src/game/DynamicObject.h | 2 | ||||
-rw-r--r-- | src/game/GameObject.h | 1 |
11 files changed, 103 insertions, 53 deletions
diff --git a/src/game/Chat.cpp b/src/game/Chat.cpp index 80f75ccffa6..a96086bdba0 100644 --- a/src/game/Chat.cpp +++ b/src/game/Chat.cpp @@ -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 + + // position relative after itemEntry + const uint8 randomPropertyPosition = 6; - // ignore enchants etc. + 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) { - ItemLocale const *il = objmgr.GetItemLocale(linkedItem->ItemId); + expectedName += " "; + expectedName += suffix[LOCALE_enUS]; + } - if (!il) - { -#ifdef MANGOS_DEBUG - sLog.outBasic("ChatHandler::isValidChatMessage linked item name doesn't is wrong and there is no localization"); -#endif - return false; - } + if (expectedName != buffer) + { + ItemLocale const *il = objmgr.GetItemLocale(linkedItem->ItemId); 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; diff --git a/src/game/Chat.h b/src/game/Chat.h index d0d9a6112fc..c799252f4b0 100644 --- a/src/game/Chat.h +++ b/src/game/Chat.h @@ -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); diff --git a/src/game/Creature.cpp b/src/game/Creature.cpp index 03068041f23..de1f3e76fa9 100644 --- a/src/game/Creature.cpp +++ b/src/game/Creature.cpp @@ -261,19 +261,24 @@ 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) { - //we already have valid Map pointer for current creature! - if(GetMap()->IsHeroic()) + if (normalInfo->DifficultyEntry[diff]) { - cinfo = objmgr.GetCreatureTemplate(normalInfo->HeroicEntry); - if(!cinfo) + // we already have valid Map pointer for current creature! + if (GetMap()->GetSpawnMode() > diff) { - sLog.outErrorDb("Creature::UpdateEntry creature heroic entry %u does not exist.", actualEntry); - return false; + cinfo = objmgr.GetCreatureTemplate(normalInfo->DifficultyEntry[diff]); + if (!cinfo) + { + // maybe check such things already at startup + sLog.outErrorDb("Creature::UpdateEntry creature difficulty %u entry %u does not exist.", diff + 1, actualEntry); + return false; + } } } } @@ -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; } - diff --git a/src/game/Creature.h b/src/game/Creature.h index ab9915c0bda..d1c08bb13e2 100644 --- a/src/game/Creature.h +++ b/src/game/Creature.h @@ -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 - diff --git a/src/game/CreatureEventAI.cpp b/src/game/CreatureEventAI.cpp index f50f7e4128b..07de3fa0efc 100644 --- a/src/game/CreatureEventAI.cpp +++ b/src/game/CreatureEventAI.cpp @@ -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)); diff --git a/src/game/CreatureEventAI.h b/src/game/CreatureEventAI.h index 55ae1e20bf3..e51b74a9602 100644 --- a/src/game/CreatureEventAI.h +++ b/src/game/CreatureEventAI.h @@ -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 diff --git a/src/game/CreatureEventAIMgr.cpp b/src/game/CreatureEventAIMgr.cpp index 462a284a17d..2d4c92ad7bf 100644 --- a/src/game/CreatureEventAIMgr.cpp +++ b/src/game/CreatureEventAIMgr.cpp @@ -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; diff --git a/src/game/DuelHandler.cpp b/src/game/DuelHandler.cpp index c35b9dbdc07..d9854d900c8 100644 --- a/src/game/DuelHandler.cpp +++ b/src/game/DuelHandler.cpp @@ -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); } - diff --git a/src/game/DynamicObject.cpp b/src/game/DynamicObject.cpp index db0a4a7f2ef..be56b9f5069 100644 --- a/src/game/DynamicObject.cpp +++ b/src/game/DynamicObject.cpp @@ -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)); } - diff --git a/src/game/DynamicObject.h b/src/game/DynamicObject.h index 13747891964..89b227e64ff 100644 --- a/src/game/DynamicObject.h +++ b/src/game/DynamicObject.h @@ -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 - diff --git a/src/game/GameObject.h b/src/game/GameObject.h index a915b81fc78..7d55afb7e60 100644 --- a/src/game/GameObject.h +++ b/src/game/GameObject.h @@ -754,4 +754,3 @@ class TRINITY_DLL_SPEC GameObject : public WorldObject GridReference<GameObject> m_gridRef; }; #endif - |