diff --git a/Engine/Source/Base/CDataStore.cpp b/Engine/Source/Base/CDataStore.cpp index bfd14d1..bf08903 100644 --- a/Engine/Source/Base/CDataStore.cpp +++ b/Engine/Source/Base/CDataStore.cpp @@ -517,3 +517,12 @@ void* CDataStore::ReAlloc(void* ptr, uint32_t bytes, const char* fileName, int32 return SMemReAlloc(ptr, bytes, __FILE__, __LINE__, 0); } + +// VERIFY: 8b1ed662 auto +// OFFSET: 0x00401140 +CDataStore& CDataStore::GetInt8(uint32_t& val) { + uint8_t value = 0; + this->Get(value); + val = value; + return *this; +} diff --git a/Engine/Source/Base/CDataStore.h b/Engine/Source/Base/CDataStore.h index 1bb6f31..05edea5 100644 --- a/Engine/Source/Base/CDataStore.h +++ b/Engine/Source/Base/CDataStore.h @@ -37,6 +37,7 @@ class CDataStore { CDataStore& Get(uint32_t& val); CDataStore& Get(uint64_t& val); CDataStore& Get(float& val); + CDataStore& GetInt8(uint32_t& val); CDataStore& GetArray(uint8_t* pval, uint32_t count); CDataStore& GetArray(uint32_t* pval, uint32_t count); CDataStore& GetData(void* data, uint32_t bytes); diff --git a/Engine/Source/Storm/H/storm.h b/Engine/Source/Storm/H/storm.h index 1760202..6ae14c4 100644 --- a/Engine/Source/Storm/H/storm.h +++ b/Engine/Source/Storm/H/storm.h @@ -210,7 +210,7 @@ void SSignatureVerifyStream_ProvideData(SSignatureData* token, const uint8_t* da const char* STORMAPI SStrAdvanceCharsUTF8(const char* string, size_t chars); char* SStrChr(const char* string, char search); -char* SStrChrR(char* string, char search); +char* SStrChrR(const char* string, char search); int32_t STORMAPI SStrCmp(const char* string1, const char* string2, size_t maxchars); int32_t STORMAPI SStrCmpI(const char* string1, const char* string2, size_t maxchars); int32_t STORMAPI SStrCmpUTF8I(const char* string1, const char* string2, size_t maxchars); diff --git a/Engine/Source/Storm/Source/SStr.cpp b/Engine/Source/Storm/Source/SStr.cpp index 05e9936..61011a1 100644 --- a/Engine/Source/Storm/Source/SStr.cpp +++ b/Engine/Source/Storm/Source/SStr.cpp @@ -61,15 +61,15 @@ char* SStrChr(const char* string, char search) { return nullptr; } -// VERIFY: 263abdbd auto +// VERIFY: c2203f65 auto // OFFSET: 0x0076E720 -char* SStrChrR(char* string, char search) { +char* SStrChrR(const char* string, char search) { if (!string) { SErrSetLastError(STORM_ERROR_INVALID_PARAMETER); return nullptr; } - char* result = nullptr; + const char* result = nullptr; for (; *string; string++) { if (*string == search) { @@ -77,7 +77,7 @@ char* SStrChrR(char* string, char search) { } } - return result; + return const_cast(result); } // VERIFY: 8e9003dc auto diff --git a/Engine/Source/Tempest/C44Matrix.cpp b/Engine/Source/Tempest/C44Matrix.cpp index 9d9e5fe..0e05034 100644 --- a/Engine/Source/Tempest/C44Matrix.cpp +++ b/Engine/Source/Tempest/C44Matrix.cpp @@ -695,3 +695,24 @@ C44Matrix::C44Matrix(const C34Matrix& m) { this->d2 = m.d2; this->d3 = 1.0f; } + +// VERIFY: d0f80fc6 auto +// OFFSET: 0x0078FBD0 +C44Matrix::C44Matrix(const C3Vector& x, const C3Vector& y, const C3Vector& z, const C3Vector& w) { + this->a0 = x.x; + this->a1 = x.y; + this->a2 = x.z; + this->a3 = 0.0f; + this->b0 = y.x; + this->b1 = y.y; + this->b2 = y.z; + this->b3 = 0.0f; + this->c0 = z.x; + this->c1 = z.y; + this->c2 = z.z; + this->c3 = 0.0f; + this->d0 = w.x; + this->d1 = w.y; + this->d2 = w.z; + this->d3 = 1.0f; +} diff --git a/Engine/Source/Tempest/C44Matrix.h b/Engine/Source/Tempest/C44Matrix.h index 498130f..891d7ed 100644 --- a/Engine/Source/Tempest/C44Matrix.h +++ b/Engine/Source/Tempest/C44Matrix.h @@ -40,6 +40,7 @@ class C44Matrix { C44Matrix(float a0, float a1, float a2, float a3, float b0, float b1, float b2, float b3, float c0, float c1, float c2, float c3, float d0, float d1, float d2, float d3); C44Matrix(const C33Matrix& m); C44Matrix(const C34Matrix& m); + C44Matrix(const C3Vector& x, const C3Vector& y, const C3Vector& z, const C3Vector& w); C44Matrix(const C4Quaternion& q); C44Matrix Adjoint() const; C44Matrix AffineInverse() const; diff --git a/Engine/Source/Tempest/CiRect.h b/Engine/Source/Tempest/CiRect.h index 6a3d9d6..7cf2b6b 100644 --- a/Engine/Source/Tempest/CiRect.h +++ b/Engine/Source/Tempest/CiRect.h @@ -12,6 +12,7 @@ class CiRect { /* 000C */ int32_t maxX; CiRect(); + CiRect(int32_t minY, int32_t minX, int32_t maxY, int32_t maxX); CiRect operator&=(const CiRect& r); }; @@ -25,4 +26,12 @@ inline CiRect::CiRect() { this->maxX = 0; } +// INLINED +inline CiRect::CiRect(int32_t minY, int32_t minX, int32_t maxY, int32_t maxX) { + this->minY = minY; + this->minX = minX; + this->maxY = maxY; + this->maxX = maxX; +} + #endif diff --git a/WoW/Common/ComponentCore/CharacterComponent.cpp b/WoW/Common/ComponentCore/CharacterComponent.cpp index b769d22..0864109 100644 --- a/WoW/Common/ComponentCore/CharacterComponent.cpp +++ b/WoW/Common/ComponentCore/CharacterComponent.cpp @@ -1194,9 +1194,9 @@ void CCharacterComponent::PasteOpaqueScale(void* texture, MipBits* dstMips, C2iV CCharacterComponent::PasteOpaque(texture, pal, dstMips, dstPos, dstStride >> 1, srcPos, srcSize, srcInfo, 0, 1); } -// VERIFY: 6b5f02b6 auto +// VERIFY: 049c43f4 auto // OFFSET: 0x004E8D30 -static CTexture* CreateTexture(const char* fileName, CStatus* status) { +CTexture* CreateTexture(const char* fileName, CStatus* status) { CGxTexFlags flags(GxTex_LinearMipNearest, 0, 0, 0, 0, 0, 1); return TextureCreate(fileName, flags, status, 0); diff --git a/WoW/Common/ComponentCore/CharacterComponent.h b/WoW/Common/ComponentCore/CharacterComponent.h index 0b75db3..6c8935e 100644 --- a/WoW/Common/ComponentCore/CharacterComponent.h +++ b/WoW/Common/ComponentCore/CharacterComponent.h @@ -66,6 +66,7 @@ class CComponentRequest { void DestroyCachedTextures(); }; +class CStatus; class CCharacterComponent { public: static CVar* g_componentCompressVar; @@ -266,4 +267,6 @@ class CCharacterComponent { bool ComponentVarHandler(CVar* var, const char* oldValue, const char* value, void* arg); +CTexture* CreateTexture(const char* fileName, CStatus* status); + #endif diff --git a/WoW/Source/Client.cpp b/WoW/Source/Client.cpp index e254b53..d7a30e6 100644 --- a/WoW/Source/Client.cpp +++ b/WoW/Source/Client.cpp @@ -306,13 +306,16 @@ static uint32_t s_clientTaxiBenchDelayTime; static uint64_t s_clientTaxiTimestamp; // STATIC: 0x00B2F9E0 -static uint8_t s_botCheckEnabled; +uint8_t s_botCheckEnabled; // STATIC: 0x00B2F9E4 static uint32_t s_botCheckStartTime; // STATIC: 0x00B2F9E8 -static int32_t s_botCheckDelay; +int32_t s_botCheckDelay; + +// STATIC: 0x00B2FA0C +volatile long s_additionalCheckArmed; // STATIC: 0x00B2FA1C static C3Vector s_spawnPosition; @@ -2116,3 +2119,25 @@ int32_t Packet_SMSG_PLAYED_TIME(void* param, NETMESSAGE msgId, uint32_t time, CD void ClientKillTimer(uint32_t id, EVENTHANDLERFUNC handler, const char* name) { EventKillTimer(id, handler, name); } + +// VERIFY: ba8cfe2c manual +// OFFSET: 0x00402720 +void* Client_MemAlloc(uint32_t bytes) { + return SMemAlloc(bytes, __FILE__, __LINE__, 0); +} + +// VERIFY: 8c344a50 manual +// OFFSET: 0x00402740 +void Client_MemFree(void* ptr) { + SMemFree(ptr, __FILE__, __LINE__, 0); +} + +// VERIFY: af0e97c3 manual +// OFFSET: 0x00404610 +void SendBotDetected2(uint32_t msgId, uint32_t code) { + WDataStore msg; + msg.Put(msgId); + msg.Put(code); + msg.Finalize(); + ClientServices::Send2(&msg); +} diff --git a/WoW/Source/Client.h b/WoW/Source/Client.h index 06827c6..0924aae 100644 --- a/WoW/Source/Client.h +++ b/WoW/Source/Client.h @@ -112,8 +112,24 @@ struct ARCHIVELISTPARAMS { /* 000C */ void* m_param; }; +struct AdditionalCheckInterface { + /* 0000 */ void* (*m_memAlloc)(uint32_t bytes); + /* 0004 */ void (*m_memFree)(void* ptr); + /* 0008 */ void* (*m_loadLibrary)(const char* fileName); + /* 000C */ void* (*m_getLibraryEntryPoint)(void* module, const char* name); + /* 0010 */ void (*m_freeLibrary)(void* module); +}; + +extern uint8_t s_botCheckEnabled; +extern int32_t s_botCheckDelay; +extern volatile long s_additionalCheckArmed; + void CheckAndSendBotDetected(); void AdditionalCheck1(); +uint8_t AdditionalCheck1Scan(const AdditionalCheckInterface* iface, int32_t a2); +void* Client_MemAlloc(uint32_t bytes); +void Client_MemFree(void* ptr); +void SendBotDetected2(uint32_t msgId, uint32_t code); int32_t GatherAdditionalChecks(uint8_t* check1, uint8_t* check2, uint8_t* check3); void ClientUpdateTaxiBenchmarkMode(); void ClientKillTimer(uint32_t id, EVENTHANDLERFUNC handler, const char* name); diff --git a/WoW/Source/DB/DBClient/CreatureStats_C.cpp b/WoW/Source/DB/DBClient/CreatureStats_C.cpp index da48ad1..53ea2f0 100644 --- a/WoW/Source/DB/DBClient/CreatureStats_C.cpp +++ b/WoW/Source/DB/DBClient/CreatureStats_C.cpp @@ -1 +1,6 @@ #include "CreatureStats_C.h" + +// VERIFY: 54ac2c6d manual +// OFFSET: 0x00667F40 +CreatureStats_C::~CreatureStats_C() { +} diff --git a/WoW/Source/DB/DBClient/DBCacheInstances.cpp b/WoW/Source/DB/DBClient/DBCacheInstances.cpp index fc00e97..63b4c14 100644 --- a/WoW/Source/DB/DBClient/DBCacheInstances.cpp +++ b/WoW/Source/DB/DBClient/DBCacheInstances.cpp @@ -644,3 +644,22 @@ void DBCache_Idle() { g_wardenCache.Idle(); g_arenaTeamCache.Idle(); } + +// VERIFY: 2a9b337b auto +// OFFSET: 0x00635680 +void DBCache_ClearPending() { + g_creatureDBCache.ClearPending(); + g_gameObjectDBCache.ClearPending(); + g_itemDBCache.ClearPending(); + g_itemNameDBCache.ClearPending(); + g_npcTextDBCache.ClearPending(); + g_nameDBCache.ClearPending(); + g_guildInfoCache.ClearPending(); + g_questDBCache.ClearPending(); + g_pageTextCache.ClearPending(); + g_petNameCache.ClearPending(); + g_petitionCache.ClearPending(); + g_itemTextDBCache.ClearPending(); + g_arenaTeamCache.ClearPending(); + g_danceCache.ClearPending(); +} diff --git a/WoW/Source/DB/DBClient/DBCacheInstances.h b/WoW/Source/DB/DBClient/DBCacheInstances.h index 476deb5..289864e 100644 --- a/WoW/Source/DB/DBClient/DBCacheInstances.h +++ b/WoW/Source/DB/DBClient/DBCacheInstances.h @@ -56,6 +56,7 @@ template <> void DBCache::AddItem(NameCache* item, uint64_t key); void DBCache_ClearHandlers(); +void DBCache_ClearPending(); void DBCache_Destroy(); void DBCache_Idle(); void DBCache_Initialize(); diff --git a/WoW/Source/Game/GameClient/ComSatClient.cpp b/WoW/Source/Game/GameClient/ComSatClient.cpp index 37e9897..33d78e8 100644 --- a/WoW/Source/Game/GameClient/ComSatClient.cpp +++ b/WoW/Source/Game/GameClient/ComSatClient.cpp @@ -94,6 +94,9 @@ int32_t s_comsatDisabledByClient; // STATIC: 0x00D37D5C SCritSect s_comsatDeviceLock; +// STATIC: 0x00D37DD8 +static int32_t s_lastFoundSession; + // STATIC: 0x00AF29B4 int32_t s_currentSession = -1; @@ -447,3 +450,40 @@ const char* ComSatClient_GetCurrentSessionName() { return nullptr; } + +// VERIFY: b9f375ed manual +// OFFSET: 0x007DB560 +int32_t ComSatClient_HasSession(int32_t type, const char* name) { + return ComSatClient_FindSessionByTypeAndName(type, name) >= 0; +} + +// VERIFY: 1f2e0bf3 manual +// OFFSET: 0x007DB400 +int32_t ComSatClient_FindSessionByTypeAndName(int32_t type, const char* name) { + int32_t cached = s_lastFoundSession; + + if (s_comsatData[cached].m_type == type) { + if (type) { + return cached; + } + + if (!SStrCmpUTF8I(s_comsatData[cached].m_name, name, 0x7FFFFFFF)) { + return s_lastFoundSession; + } + } + + if (!type && !name) { + return -1; + } + + for (int32_t i = 0; i < 32; i++) { + COMSATDATA* data = &s_comsatData[i]; + + if (data->m_sessionID && data->m_type == type && (type || !SStrCmpUTF8I(data->m_name, name, 0x7FFFFFFF))) { + s_lastFoundSession = i; + return i; + } + } + + return -1; +} diff --git a/WoW/Source/Game/GameClient/ComSatClient.h b/WoW/Source/Game/GameClient/ComSatClient.h index 6e42f8f..d34ee33 100644 --- a/WoW/Source/Game/GameClient/ComSatClient.h +++ b/WoW/Source/Game/GameClient/ComSatClient.h @@ -3,6 +3,7 @@ #include #include +#include "WoW/Source/Object/WGUID.h" #include "Engine/Source/ComSat/ComSatInterface.h" #include "Engine/Source/Storm/H/stpl.h" #include "WoW/Source/Object/ObjectClient/Object_C.h" @@ -41,6 +42,11 @@ class ComSatClientAllocator : public ComSat::Allocator { }; int32_t ComSatClient_HasSession(int32_t type, const char* name); +int32_t ComSatClient_FindSessionByTypeAndName(int32_t type, const char* name); +int32_t ComSatClient_IsMemberInVoiceSession(WOWGUID guid, int32_t type, const char* name); +int32_t ComSatClient_Unk7DB830(WOWGUID guid, int32_t type, const char* name); +bool ComSatClient_IsPlayerMuted(WOWGUID guid); +int32_t ComSatClient_IsTalkerSquelchedInChannel(WOWGUID guid, int32_t type, const char* name); int32_t ComSatClient_GetCurrentSessionType(); const char* ComSatClient_GetCurrentSessionName(); diff --git a/WoW/Source/Game/GameClient/ProjectTex.h b/WoW/Source/Game/GameClient/ProjectTex.h index f1b79b2..2295a55 100644 --- a/WoW/Source/Game/GameClient/ProjectTex.h +++ b/WoW/Source/Game/GameClient/ProjectTex.h @@ -14,6 +14,7 @@ namespace ProjectTex { } CGxTex* ProjectTex2dGetAddFadeTex(); +void ProjectTex2dDrawShaderEffect(const CAaBox& box, const CImVector& color, uint32_t triFlags, uint32_t flags, float polygonOffset); void ProjectTex2dMakeMatrices(C44Matrix& texMatrix, C44Matrix& fadeMatrix, const CAaBox& box, const C44Matrix* rotation, float fade, int32_t local); #endif diff --git a/WoW/Source/Game/GameClient/WTOBJECT.cpp b/WoW/Source/Game/GameClient/WTOBJECT.cpp index 1a7a775..a41dc65 100644 --- a/WoW/Source/Game/GameClient/WTOBJECT.cpp +++ b/WoW/Source/Game/GameClient/WTOBJECT.cpp @@ -1 +1,15 @@ #include "WTOBJECT.h" +#include "Engine/Source/Base/CDataAllocator.h" + +// STATIC: 0x00D38078 +static CDataAllocator s_freeSwings(sizeof(SWING), 8); + +// STATIC: 0x00D3808C +static CDataAllocator s_freeTrails(sizeof(WTOBJECT), 128); + +// VERIFY: c3c7b136 auto +// OFFSET: 0x007E4BC0 +void WeaponTrailsShutdown() { + s_freeTrails.Clear(typeid(WTOBJECT).raw_name(), SLOG_OBJECT, 1); + s_freeSwings.Clear(typeid(SWING).raw_name(), SLOG_OBJECT, 1); +} diff --git a/WoW/Source/Game/GameClient/WTOBJECT.h b/WoW/Source/Game/GameClient/WTOBJECT.h index def44c8..de3ee0c 100644 --- a/WoW/Source/Game/GameClient/WTOBJECT.h +++ b/WoW/Source/Game/GameClient/WTOBJECT.h @@ -5,7 +5,9 @@ #include class CM2Model; -struct SWING; +struct SWING { + /* 0000 */ uint8_t unk_0000[1560]; +}; class WTOBJECT { public: @@ -15,6 +17,7 @@ class WTOBJECT { WTOBJECT* WeaponTrailCreate(CM2Model* model); void WeaponTrailClose(WTOBJECT* trail); +void WeaponTrailsShutdown(); void WeaponTrailSetDrawTrail(WTOBJECT* trail, const uint32_t* a2, uint32_t a3); void WorldTextInitialize(); diff --git a/WoW/Source/Game/ShipPath.cpp b/WoW/Source/Game/ShipPath.cpp index 11250db..b1841dc 100644 --- a/WoW/Source/Game/ShipPath.cpp +++ b/WoW/Source/Game/ShipPath.cpp @@ -1,23 +1,681 @@ #include "ShipPath.h" +#include +#include +#include "Engine/Source/Tempest/C3Vector.h" +#include "WoW/Source/DB/DBClient/DBClient.h" +#include "WoW/Source/DB/Rec/TaxiPathNodeRec.h" +#include +#include "Engine/Source/Tempest/C44Matrix.h" +#include "WoW/Source/DB/Rec/TransportPhysicsRec.h" +#include "WoW/Source/Object/ObjectClient/Types.h" // INLINED ShipPath::ShipPath() { - this->unk_0000 = 0; - this->unk_0004 = 0xFFFFFFFF; - this->unk_0008 = 0; - this->unk_000C = 0; - this->unk_0010 = 0; - this->unk_0014 = 0; - this->unk_0018 = 0; - this->unk_001C = 0; - this->unk_0020 = 0; - this->unk_0024 = 0; - this->unk_0028 = 0.0f; - this->unk_002C = 0; - this->unk_0030 = 0.0f; - this->unk_0034 = 0; - this->unk_0038 = 0; - this->unk_003C = 0; - this->unk_003D = 0; + this->m_physics = nullptr; + this->m_taxiPathId = 0xFFFFFFFF; + this->m_moveSpeed = 0.0f; + this->m_totalPathTime = 0; + this->m_accelRate = 0.0f; + this->m_waitTime = 0; + this->m_timeOffset = 0; + this->m_waiting = 0; + this->m_waitReached = 0; this->unk_003E = 0; } + +// VERIFY: 09b64bdb auto +// OFFSET: 0x007F92F0 +void ShipPath::Init(uint32_t taxiPathId, float moveSpeed, float accelRate, const TransportPhysicsRec* physics) { + this->m_moveSpeed = moveSpeed; + this->m_taxiPathId = taxiPathId; + this->m_totalPathTime = 0; + this->m_accelRate = accelRate; + this->BuildLegs(); + this->m_physics = physics; +} + +// VERIFY: 41a1523f manual +// OFFSET: 0x007F7FC0 +void ShipPath::SetTotalPathTime(uint32_t time) { + this->m_totalPathTime = time; + + if (this->m_legs.Count() > 0) { + this->m_legs.Top()->m_endTime = time; + } +} + +// VERIFY: b2be9152 auto +// OFFSET: 0x007F7AD0 +static int32_t FindFirstPathNode(uint32_t pathId) { + int32_t high = g_taxiPathNodeDB.m_numRecords; + int32_t low = 0; + + if (high <= 0) { + return -1; + } + + do { + int32_t mid = (high + low) / 2; + TaxiPathNodeRec* records = g_taxiPathNodeDB.m_numRecords <= 0 ? nullptr : g_taxiPathNodeDB.m_records; + + if (records[mid].m_pathID >= static_cast(pathId)) { + high = mid; + } else { + low = mid + 1; + } + } while (low < high); + + if (low < g_taxiPathNodeDB.m_numRecords) { + TaxiPathNodeRec* records = g_taxiPathNodeDB.m_numRecords <= 0 ? nullptr : g_taxiPathNodeDB.m_records; + + if (records[low].m_pathID == static_cast(pathId)) { + return low; + } + } + + return -1; +} + +// VERIFY: 3e217ff8 manual +// OFFSET: 0x007F8180 +template <> +void ShipPathArray::SetCount(uint32_t count) { + if (count == this->m_count) { + return; + } + + for (uint32_t i = this->m_count; i < count; i++) { + new (&this->m_data[i]) C3Vector(); + } + + this->m_count = count; +} + +// VERIFY: 7897cce3 manual +// OFFSET: 0x007F90F0 +void ShipPath::BuildLegs() { + ShipPathArray points; + points.m_data = static_cast(alloca(0x3000)); + points.m_count = 0; + ShipPathArray pauses; + pauses.m_data = static_cast(alloca(0x2000)); + pauses.m_count = 0; + ShipPathArray events; + events.m_data = static_cast(alloca(0x3000)); + this->m_totalPathTime = 0; + this->m_events.m_count = 0; + events.m_count = 0; + int32_t leg = -1; + int32_t index = FindFirstPathNode(this->m_taxiPathId); + + if (index == -1) { + return; + } + + TaxiPathNodeRec* node = nullptr; + + if (index >= 0 && index < g_taxiPathNodeDB.m_numRecords) { + node = &g_taxiPathNodeDB.m_records[index]; + } + + int32_t teleport = 0; + + while (true) { + if (leg < 0 || node->m_continentID != this->m_legs.m_data[leg].m_mapId || teleport) { + if (leg >= 0) { + this->BuildLeg(&points, &pauses, &events, leg); + } + + leg++; + this->m_legs.SetCount(leg + 1); + this->m_legs.m_data[leg].m_mapId = node->m_continentID; + points.SetCount(0); + + if (pauses.m_count) { + pauses.m_count = 0; + } + + if (events.m_count) { + events.m_count = 0; + } + } + + if ((node->m_flags & 0x2) && points.m_count) { + ShipPathPause* pause = &pauses.m_data[pauses.m_count++]; + + if (pause) { + pause->m_point = points.m_count; + pause->m_delay = node->m_delay * 1000; + } + } + + if (node->m_arrivalEventID || node->m_departureEventID) { + ShipPathEvent* event = &events.m_data[events.m_count++]; + + if (event) { + event->m_point = points.m_count; + event->m_arrivalEvent = node->m_arrivalEventID; + event->m_departureEvent = node->m_departureEventID; + } + } + + C3Vector* point = &points.m_data[points.m_count++]; + + if (point) { + point->x = node->m_loc[0]; + point->y = node->m_loc[1]; + point->z = node->m_loc[2]; + } + + teleport = node->m_flags & 0x1; + index++; + + if (index < 0 || index >= g_taxiPathNodeDB.m_numRecords) { + break; + } + + node = &g_taxiPathNodeDB.m_records[index]; + + if (node->m_pathID != static_cast(this->m_taxiPathId)) { + break; + } + } + + if (points.m_count) { + this->BuildLeg(&points, &pauses, &events, leg); + } +} + +// VERIFY: b35e3ee1 manual +// OFFSET: 0x007F7A60 +uint32_t ShipPath::LegTimeAccel(float distance) { + float invAccel = 1.0f / this->m_accelRate; + float accelTime = invAccel * this->m_moveSpeed; + float accelDistance = this->m_moveSpeed * 0.5f * accelTime; + float time; + + if (0.5f * distance <= accelDistance) { + float root = sqrtf(invAccel * distance); + time = root + root; + } else { + time = 2.0f * accelTime + (distance - accelDistance * 2.0f) / this->m_moveSpeed; + } + + return static_cast(time * 1000.0f); +} + +// VERIFY: db975c72 manual +// OFFSET: 0x007F8660 +void ShipPath::BuildLeg(ShipPathArray* points, ShipPathArray* pauses, ShipPathArray* events, int32_t legIndex) { + ShipPathLeg* leg = &this->m_legs.m_data[legIndex]; + leg->m_spline.SetPoints(points->m_data, points->m_count); + leg = &this->m_legs.m_data[legIndex]; + leg->m_segments.SetCount(pauses->m_count + 1); + float prevDistance = 0.0f; + this->m_legs.m_data[legIndex].m_duration = 0; + uint32_t eventCount = this->m_events.m_count; + uint32_t accumDelay = 0; + uint32_t eventIndex = 0; + this->m_events.SetCount(eventCount + 2 * events->m_count); + uint32_t i; + + for (i = 0; i < pauses->m_count; i++) { + if (pauses->m_data[i].m_point >= points->m_count - 1) { + break; + } + + for (; eventIndex < events->m_count; eventIndex++) { + ShipPathEvent* event = &events->m_data[eventIndex]; + + if (event->m_point > pauses->m_data[i].m_point) { + break; + } + + float distance = this->m_legs.m_data[legIndex].m_spline.LengthBeforePoint(event->m_point) - prevDistance; + float invAccel = 1.0f / this->m_accelRate; + float accelTime = this->m_moveSpeed * invAccel; + float time; + + if (i) { + float accelDistance = this->m_moveSpeed * 0.5f * accelTime; + + if (accelDistance >= 0.5f * distance) { + float root = sqrtf(distance * invAccel); + time = root + root; + } else { + time = 2.0f * accelTime + (distance - accelDistance * 2.0f) / this->m_moveSpeed; + } + } else { + float accelDistance = this->m_moveSpeed * 0.5f * accelTime; + + if (accelDistance >= distance) { + time = sqrtf(distance * invAccel + distance * invAccel); + } else { + time = accelTime + (distance - accelDistance) / this->m_moveSpeed; + } + } + + uint32_t eventTime = static_cast(time * 1000.0f); + uint32_t delay = event->m_point == pauses->m_data[i].m_point ? pauses->m_data[i].m_delay : 0; + uint32_t base = accumDelay + eventTime + this->m_legs.m_data[legIndex].m_duration; + + if (event->m_arrivalEvent) { + this->m_events.m_data[eventCount].m_time = base + this->m_totalPathTime; + this->m_events.m_data[eventCount].m_eventId = event->m_arrivalEvent; + eventCount++; + } + + if (event->m_departureEvent) { + this->m_events.m_data[eventCount].m_time = delay + base + this->m_totalPathTime; + this->m_events.m_data[eventCount].m_eventId = event->m_departureEvent; + eventCount++; + } + } + + float pauseDistance = this->m_legs.m_data[legIndex].m_spline.LengthBeforePoint(pauses->m_data[i].m_point); + float distance = pauseDistance - prevDistance; + uint32_t segmentTime; + + if (i) { + segmentTime = this->LegTimeAccel(distance); + } else { + float invAccel = 1.0f / this->m_accelRate; + float accelTime = this->m_moveSpeed * invAccel; + float accelDistance = this->m_moveSpeed * 0.5f * accelTime; + float time = accelDistance >= distance ? sqrtf(distance * invAccel + distance * invAccel) : accelTime + (distance - accelDistance) / this->m_moveSpeed; + segmentTime = static_cast(time * 1000.0f); + } + + this->m_legs.m_data[legIndex].m_duration += segmentTime; + prevDistance = pauseDistance; + ShipPathSegment* segment = &this->m_legs.m_data[legIndex].m_segments.m_data[i]; + segment->m_time = accumDelay + this->m_legs.m_data[legIndex].m_duration; + segment->m_distance = pauseDistance; + segment->m_delay = pauses->m_data[i].m_delay; + accumDelay += pauses->m_data[i].m_delay; + } + + for (; eventIndex < events->m_count; eventIndex++) { + ShipPathEvent* event = &events->m_data[eventIndex]; + float distance = this->m_legs.m_data[legIndex].m_spline.LengthBeforePoint(event->m_point) - prevDistance; + uint32_t eventTime; + + if (i) { + float invAccel = 1.0f / this->m_accelRate; + float accelTime = this->m_moveSpeed * invAccel; + float accelDistance = this->m_moveSpeed * 0.5f * accelTime; + float time = accelDistance >= distance ? sqrtf(distance * invAccel + distance * invAccel) : accelTime + (distance - accelDistance) / this->m_moveSpeed; + eventTime = static_cast(time * 1000.0f); + } else { + eventTime = static_cast(distance / this->m_moveSpeed * 1000.0f); + } + + uint32_t base = accumDelay + eventTime + this->m_legs.m_data[legIndex].m_duration; + + if (event->m_arrivalEvent) { + this->m_events.m_data[eventCount].m_time = base + this->m_totalPathTime; + this->m_events.m_data[eventCount].m_eventId = event->m_arrivalEvent; + eventCount++; + } + + if (event->m_departureEvent) { + this->m_events.m_data[eventCount].m_time = base + this->m_totalPathTime; + this->m_events.m_data[eventCount].m_eventId = event->m_departureEvent; + eventCount++; + } + } + + this->m_events.SetCount(eventCount); + float length = this->m_legs.m_data[legIndex].m_spline.m_length; + float distance = length - prevDistance; + uint32_t lastTime; + + if (i) { + float invAccel = 1.0f / this->m_accelRate; + float accelTime = this->m_moveSpeed * invAccel; + float accelDistance = this->m_moveSpeed * 0.5f * accelTime; + float time = accelDistance >= distance ? sqrtf(distance * invAccel + distance * invAccel) : accelTime + (distance - accelDistance) / this->m_moveSpeed; + lastTime = static_cast(time * 1000.0f); + } else { + lastTime = static_cast(distance / this->m_moveSpeed * 1000.0f); + } + + leg = &this->m_legs.m_data[legIndex]; + leg->m_duration += lastTime; + ShipPathSegment* last = &leg->m_segments.m_data[i]; + last->m_time = accumDelay + leg->m_duration; + last->m_distance = length; + last->m_delay = 0; + leg->m_startTime = this->m_totalPathTime; + this->m_totalPathTime += leg->m_segments.m_data[i].m_time; + + for (uint32_t j = 0; j < leg->m_segments.m_count; j++) { + leg->m_segments.m_data[j].m_time += leg->m_startTime; + } + + leg->m_endTime = this->m_totalPathTime; +} + +// VERIFY: c8996cba manual +// OFFSET: 0x007F77D0 +bool ShipPath::TimeInRange(uint32_t start, uint32_t end, uint32_t time) { + if (end == start) { + return end == time; + } + + if (end <= start) { + if (time > end && time <= start) { + return false; + } + } else if (time <= start || time > end) { + return false; + } + + return true; +} + +// VERIFY: 0ba77058 auto +// OFFSET: 0x007F7840 +uint32_t ShipPath::GetPathTime(uint32_t time, uint32_t elapsed, int32_t absolute) { + uint32_t total = this->m_totalPathTime; + + if (!total) { + return 0; + } + + if (absolute) { + return time % total; + } + + uint32_t pathTime = (time + this->m_timeOffset) % total; + + if (this->m_waiting) { + if (this->m_waitReached) { + return this->m_waitTime; + } + + uint32_t waitTime = this->m_waitTime; + + if (this->TimeInRange(waitTime, (waitTime + elapsed) % total, pathTime)) { + pathTime = waitTime; + this->m_waitReached = 1; + } + } + + return pathTime; +} + +// VERIFY: 316a0013 manual +// OFFSET: 0x007F7660 +float ShipPath::GetDecelDistance(float t, float segTime, uint32_t* sequence, float* speed) { + float accelTime = this->m_moveSpeed / this->m_accelRate; + float decelTime = segTime >= accelTime ? accelTime : segTime; + float cruiseTime = segTime - decelTime; + + if (t <= cruiseTime) { + *sequence = ANIM_SHIP_MOVING; + *speed = this->m_moveSpeed; + return t * this->m_moveSpeed; + } + + float startSpeed = decelTime * this->m_accelRate; + float dt = t - cruiseTime; + *speed = startSpeed - this->m_accelRate * dt; + *sequence = ANIM_SHIP_STOP; + return dt * ((startSpeed + startSpeed - this->m_accelRate * dt) * 0.5f) + cruiseTime * this->m_moveSpeed; +} + +// VERIFY: b5ad35a3 manual +// OFFSET: 0x007F76F0 +float ShipPath::GetAccelDecelDistance(float t, float segTime, uint32_t* sequence, float* speed) { + float accelTime = this->m_moveSpeed / this->m_accelRate; + float rampTime = segTime * 0.5f; + + if (rampTime >= accelTime) { + rampTime = accelTime; + } + + if (t <= segTime - rampTime) { + if (rampTime >= t) { + float current = this->m_accelRate * t; + *speed = current; + *sequence = ANIM_SHIP_START; + return 0.5f * current * t; + } + + *sequence = ANIM_SHIP_MOVING; + *speed = this->m_moveSpeed; + return accelTime * (0.5f * this->m_moveSpeed) + (t - accelTime) * this->m_moveSpeed; + } + + float peak = this->m_accelRate * rampTime; + float dt = t - (segTime - rampTime); + *speed = peak - this->m_accelRate * dt; + *sequence = ANIM_SHIP_STOP; + return rampTime * (0.5f * peak) + dt * ((peak * 2.0f - this->m_accelRate * dt) * 0.5f) + (segTime - 2.0f * rampTime) * this->m_moveSpeed; +} + +// VERIFY: 5639ad48 manual +// OFFSET: 0x007F7B30 +void ShipPath::GetRollAndPitch(uint32_t time, float speed, float turn, C3Vector* position, float* roll, float* pitch) { + const TransportPhysicsRec* physics = this->m_physics; + float damp; + + if (speed >= physics->m_speedDampThresh) { + damp = 1.0f; + } else { + float scale = sqrtf(speed * (1.0f / physics->m_speedDampThresh)); + damp = scale * ((1.0f - physics->m_speedDamp) * scale) + physics->m_speedDamp; + } + + if (fabsf(physics->m_waveTimeScale) >= 0.00000023841858f) { + uint32_t period = static_cast(6283.1855f / physics->m_waveTimeScale); + position->z = sinf(static_cast(time % period) * 6.2831855f / static_cast(period)) * physics->m_waveAmp * damp + position->z; + } + + float bankTurn; + + if (physics->m_maxBankTurnSpeed >= turn) { + bankTurn = -physics->m_maxBankTurnSpeed <= turn ? turn : -physics->m_maxBankTurnSpeed; + } else { + bankTurn = physics->m_maxBankTurnSpeed; + } + + float bank = bankTurn * (physics->m_maxBank / physics->m_maxBankTurnSpeed); + + if (fabsf(physics->m_rollTimeScale) < 0.00000023841858f) { + *roll = 0.0f; + } else { + uint32_t period = static_cast(6283.1855f / physics->m_rollTimeScale); + *roll = (bank + sinf(static_cast(time % period) * 6.2831855f / static_cast(period) + 0.5f) * physics->m_rollAmp) * damp; + } + + if (fabsf(physics->m_pitchTimeScale) < 0.00000023841858f) { + *pitch = 0.0f; + } else { + uint32_t period = static_cast(6283.1855f / physics->m_pitchTimeScale); + *pitch = damp * (sinf(6.2831855f * static_cast(time % period) / static_cast(period) + 0.2f) * physics->m_pitchAmp); + } +} + +// VERIFY: 0f888a8c auto +// OFFSET: 0x007F7DD0 +void ShipPath::ComputeRollAndPitch(float speed, float facing, float distance, uint32_t leg, float turn, uint32_t time, C3Vector* position, float* roll, float* pitch) { + if (speed > 0.0f) { + float low = this->m_physics->m_speedDampThresh * 0.15000001f; + float high = this->m_physics->m_speedDampThresh * 0.30000001f; + + if (speed < low) { + speed = 0.0f; + } else if (speed < high) { + float scale = (speed - low) / (high - low); + speed = speed * (scale * scale); + } + + C3Vector vel(0.0f, 0.0f, 0.0f); + + for (int32_t i = 1; i < 5; i++) { + float ahead = distance - speed * static_cast(i) * 0.44999999f; + + if (ahead < 0.0f) { + ahead = 0.0f; + } + + ShipPathLeg* pathLeg = &this->m_legs.m_data[leg]; + float u = ahead / pathLeg->m_spline.m_length; + + if (u < 0.0f) { + u = 0.0f; + } else if (u >= 1.0f) { + u = 1.0f; + } + + pathLeg->m_spline.Vel(u, vel, C3Spline::EVAL_ARCLENGTH); + float lengthSq = vel.z * vel.z + vel.y * vel.y + vel.x * vel.x; + + if (lengthSq > 0.00000023841858f) { + float inv = 1.0f / sqrtf(lengthSq); + vel.x *= inv; + vel.y *= inv; + vel.z *= inv; + } + + float heading = atan2f(-vel.y, -vel.x); + float delta = facing - heading; + + if (delta > 3.1415927f) { + delta -= 6.2831855f; + } else if (delta < -3.1415927f) { + delta += 6.2831855f; + } + + turn = delta * 2.2222223f + turn; + facing = heading; + } + + turn *= 0.2f; + } + + this->GetRollAndPitch(time, speed, turn, position, roll, pitch); +} + +// VERIFY: 6b846269 manual +// OFFSET: 0x007F82B0 +void ShipPath::GetPosition(uint32_t time, uint32_t elapsed, int32_t* mapId, uint32_t* sequence, C3Vector* position, float* facing, uint32_t* leg, float* roll, float* pitch, int32_t absolute) { + C44Matrix frame; + uint32_t pathTime = this->GetPathTime(time, elapsed, absolute); + *sequence = ANIM_STAND; + float speed = 0.0f; + position->x = 0.0f; + position->y = 0.0f; + position->z = 0.0f; + *facing = 0.0f; + + if (roll && pitch) { + *pitch = 0.0f; + *roll = 0.0f; + } + + *leg = 0; + + if (!this->m_legs.m_count) { + return; + } + + while (pathTime >= this->m_legs.m_data[*leg].m_endTime) { + if (++*leg >= this->m_legs.m_count) { + return; + } + } + + float prevDistance = 0.0f; + ShipPathLeg* pathLeg = &this->m_legs.m_data[*leg]; + uint32_t startTime = pathLeg->m_startTime; + uint32_t seg = 0; + float distance; + + if (pathLeg->m_segments.m_count != 1) { + ShipPathSegment* segments = pathLeg->m_segments.m_data; + + while (pathTime >= segments[seg].m_time) { + if (pathTime - segments[seg].m_time < segments[seg].m_delay) { + distance = segments[seg].m_distance; + *sequence = ANIM_STAND; + goto frame; + } + + prevDistance = segments[seg].m_distance; + startTime = segments[seg].m_time + segments[seg].m_delay; + + if (++seg >= this->m_legs.m_data[*leg].m_segments.m_count - 1) { + break; + } + } + } + + { + float t = static_cast(pathTime - startTime) * 0.001f; + float segTime = 0.001f * static_cast(pathLeg->m_segments.m_data[seg].m_time - startTime); + bool last = seg == pathLeg->m_segments.m_count - 1; + float moved; + + if (seg == 0) { + if (!last) { + moved = this->GetDecelDistance(t, segTime, sequence, &speed); + } else { + *sequence = ANIM_SHIP_MOVING; + speed = this->m_moveSpeed; + moved = t * this->m_moveSpeed; + } + } else if (!last) { + moved = this->GetAccelDecelDistance(t, segTime, sequence, &speed); + } else { + float accelTime = this->m_moveSpeed / this->m_accelRate; + float rampTime = accelTime <= segTime ? accelTime : segTime; + + if (rampTime >= t) { + *sequence = ANIM_SHIP_START; + speed = this->m_accelRate * t; + moved = t * (speed * 0.5f); + } else { + *sequence = ANIM_SHIP_MOVING; + moved = accelTime * (this->m_moveSpeed * 0.5f) + (t - accelTime) * this->m_moveSpeed; + speed = this->m_moveSpeed; + } + } + + distance = moved + prevDistance; + } + +frame: + pathLeg = &this->m_legs.m_data[*leg]; + float u = distance / pathLeg->m_spline.m_length; + + if (u < 0.0f) { + u = 0.0f; + } else if (u >= 1.0f) { + u = 1.0f; + } + + pathLeg->m_spline.Frame(u, frame, C3Spline::EVAL_ARCLENGTH); + float x = -frame.a0; + float y = -frame.a1; + float lengthSq = y * y + x * x; + + if (lengthSq > 0.00000023841858f) { + float inv = 1.0f / sqrtf(lengthSq); + x *= inv; + y *= inv; + } + + *facing = atan2f(y, x); + position->x = frame.d0; + position->y = frame.d1; + position->z = frame.d2; + + if (this->m_physics && roll && pitch) { + this->ComputeRollAndPitch(speed, *facing, distance, *leg, 0.0f, pathTime, position, roll, pitch); + } + + *mapId = this->m_legs.m_data[*leg].m_mapId; +} diff --git a/WoW/Source/Game/ShipPath.h b/WoW/Source/Game/ShipPath.h index 9bb420b..a661fbe 100644 --- a/WoW/Source/Game/ShipPath.h +++ b/WoW/Source/Game/ShipPath.h @@ -3,34 +3,83 @@ #include #include +#include "Engine/Source/Storm/H/stpl.h" +#include "Engine/Source/Tempest/C3Spline_CatmullRom.h" +class C3Vector; class TransportPhysicsRec; +struct ShipPathSegment { + /* 0000 */ uint32_t m_time; + /* 0004 */ float m_distance; + /* 0008 */ uint32_t m_delay; +}; + +struct ShipPathTimeEvent { + /* 0000 */ uint32_t m_time; + /* 0004 */ int32_t m_eventId; +}; + +struct ShipPathLeg { + /* 0000 */ int32_t m_mapId; + /* 0004 */ C3Spline_CatmullRom m_spline; + /* 01C8 */ uint32_t m_startTime; + /* 01CC */ uint32_t m_duration; + /* 01D0 */ uint32_t m_endTime; + /* 01D4 */ TSGrowableArray m_segments; +}; + +struct ShipPathPause { + /* 0000 */ uint32_t m_point; + /* 0004 */ uint32_t m_delay; +}; + +struct ShipPathEvent { + /* 0000 */ uint32_t m_point; + /* 0004 */ int32_t m_arrivalEvent; + /* 0008 */ int32_t m_departureEvent; +}; + +template +class ShipPathArray { + public: + /* 0000 */ uint32_t m_count; + /* 0004 */ T* m_data; + + void SetCount(uint32_t count); +}; + class ShipPath { public: - /* 0000 */ uint32_t unk_0000; - /* 0004 */ uint32_t unk_0004; - /* 0008 */ uint32_t unk_0008; - /* 000C */ uint32_t unk_000C; - /* 0010 */ uint32_t unk_0010; - /* 0014 */ uint32_t unk_0014; - /* 0018 */ uint32_t unk_0018; - /* 001C */ uint32_t unk_001C; - /* 0020 */ uint32_t unk_0020; - /* 0024 */ uint32_t unk_0024; - /* 0028 */ float unk_0028; - /* 002C */ uint32_t unk_002C; - /* 0030 */ float unk_0030; - /* 0034 */ uint32_t unk_0034; - /* 0038 */ uint32_t unk_0038; - /* 003C */ uint8_t unk_003C; - /* 003D */ uint8_t unk_003D; + /* 0000 */ const TransportPhysicsRec* m_physics; + /* 0004 */ uint32_t m_taxiPathId; + /* 0008 */ TSGrowableArray m_legs; + /* 0018 */ TSGrowableArray m_events; + /* 0028 */ float m_moveSpeed; + /* 002C */ uint32_t m_totalPathTime; + /* 0030 */ float m_accelRate; + /* 0034 */ uint32_t m_waitTime; + /* 0038 */ uint32_t m_timeOffset; + /* 003C */ uint8_t m_waiting; + /* 003D */ uint8_t m_waitReached; /* 003E */ uint8_t unk_003E; ShipPath(); void WaitAtNextPausePoint(uint32_t time, bool pause); void Init(uint32_t taxiPathId, float moveSpeed, float accelRate, const TransportPhysicsRec* physics); void SetTotalPathTime(uint32_t time); + void BuildLegs(); + uint32_t LegTimeAccel(float distance); + void BuildLeg(ShipPathArray* points, ShipPathArray* pauses, ShipPathArray* events, int32_t leg); + void SetTimeOffset(uint32_t time, float progress); + void WaitAtCurrentLocation(uint32_t time); + bool TimeInRange(uint32_t start, uint32_t end, uint32_t time); + uint32_t GetPathTime(uint32_t time, uint32_t elapsed, int32_t absolute); + float GetDecelDistance(float t, float segTime, uint32_t* sequence, float* speed); + float GetAccelDecelDistance(float t, float segTime, uint32_t* sequence, float* speed); + void GetRollAndPitch(uint32_t time, float speed, float turn, C3Vector* position, float* roll, float* pitch); + void ComputeRollAndPitch(float speed, float facing, float distance, uint32_t leg, float turn, uint32_t time, C3Vector* position, float* roll, float* pitch); + void GetPosition(uint32_t time, uint32_t elapsed, int32_t* mapId, uint32_t* sequence, C3Vector* position, float* facing, uint32_t* leg, float* roll, float* pitch, int32_t absolute); }; #endif diff --git a/WoW/Source/Game/ValidateName.cpp b/WoW/Source/Game/ValidateName.cpp index 4934844..1664af5 100644 --- a/WoW/Source/Game/ValidateName.cpp +++ b/WoW/Source/Game/ValidateName.cpp @@ -768,3 +768,77 @@ bool StripHyperlinks(const char* text, char* buffer, uint32_t size) { *dest = 0; return stripped; } + +// VERIFY: ab213c53 auto +// OFFSET: 0x0076DD20 +int32_t NameNeedsDeclensions(int32_t locale, const char* name) { + return locale == 8 && RussianNameNeedsDeclensions(name); +} + +// VERIFY: a66e9458 auto +// OFFSET: 0x0076E270 +int32_t RussianNameNeedsDeclensions(const char* name) { + uint16_t c = 0; + SUniConvertUTF8to16(&c, 1, name, 0x7FFFFFFF, nullptr, nullptr); + return IsRussian(c); +} + +// VERIFY: febf9d45 auto +// OFFSET: 0x007E1030 +bool IsRussian(uint16_t c) { + return static_cast(c - 0x400) <= 0xFF; +} + +// VERIFY: 52f9f8af manual +// OFFSET: 0x007E17F0 +static void StripPipes(const char* source, char* dest, uint32_t destSize) { + char* out = dest; + + for (; *source; source++) { + if (out >= &dest[destSize - 1]) { + break; + } + + if (*source != '|') { + *out++ = *source; + } + } + + *out = '\0'; +} + +// VERIFY: d19b42ca manual +// OFFSET: 0x007E1830 +bool ScrubString(const char* source, char* dest, int32_t maxChars, uint32_t destSize, int32_t flags) { + if (!dest) { + return false; + } + + *dest = '\0'; + + if (!source) { + return true; + } + + bool valid = ValidateStringIsUTF8(source); + StripPipes(source, dest, destSize); + + if ((flags & 1) && TruncateNewLines(dest)) { + valid = false; + } + + int32_t chars = 0; + + for (char* c = dest; *c; c++) { + if ((*c & 0xC0) != 0x80) { + chars++; + } + + if (chars == maxChars) { + *c = '\0'; + return false; + } + } + + return valid; +} diff --git a/WoW/Source/Game/ValidateName.h b/WoW/Source/Game/ValidateName.h index 19d2032..2e5bedd 100644 --- a/WoW/Source/Game/ValidateName.h +++ b/WoW/Source/Game/ValidateName.h @@ -19,6 +19,8 @@ bool IsAlphaRussian(uint16_t c); int32_t ValidateCharacterNameConst(uint32_t language, const char* name, bool profanity, bool chatProfanity, bool reserved, bool english, int32_t extraLength); int32_t ValidateName(uint32_t language, const uint16_t* allowed, const char* name, uint32_t* length, int32_t* charset, bool profanity, bool chatProfanity, bool reserved, bool relaxed, bool english, int32_t charsetMask); int32_t NameNeedsDeclensions(int32_t locale, const char* name); +int32_t RussianNameNeedsDeclensions(const char* name); +bool IsRussian(uint16_t c); void ValidateNameDestroy(); void ValidateNameInitialize(int32_t localeMask, int32_t charsetMask); @@ -31,4 +33,6 @@ uint16_t ToUpper(uint16_t c); uint16_t ToLower(uint16_t c); bool StripHyperlinks(const char* text, char* buffer, uint32_t size); +bool ScrubString(const char* source, char* dest, int32_t maxChars, uint32_t destSize, int32_t flags); + #endif diff --git a/WoW/Source/LiquidSystem/Liquid.cpp b/WoW/Source/LiquidSystem/Liquid.cpp index 6d1e265..e3223c9 100644 --- a/WoW/Source/LiquidSystem/Liquid.cpp +++ b/WoW/Source/LiquidSystem/Liquid.cpp @@ -39,6 +39,14 @@ Liquid::IEnvironment::~IEnvironment() { Liquid::IGeomFactory::~IGeomFactory() { } +// INLINED +Liquid::IWaveManager::~IWaveManager() { +} + +// INLINED +Liquid::IMaterial::~IMaterial() { +} + // VERIFY: 4b95827e auto // OFFSET: 0x008A1770 int32_t Liquid::Initialize(int32_t a1, float a2, int32_t a3, const char* a4, IDatabase* liquidTypeDB, IDatabase* liquidMaterialDB) { diff --git a/WoW/Source/LoadingScreen.h b/WoW/Source/LoadingScreen.h index 6e3cc32..8599820 100644 --- a/WoW/Source/LoadingScreen.h +++ b/WoW/Source/LoadingScreen.h @@ -49,6 +49,7 @@ int32_t IsStillLoading(); void LoadingScreenAsyncCallback(float progress, void* param); bool LoadingScreenDrawing(); void LoadingScreenDisable(); +void LoadingScreenEnableShipLeg(int32_t entryId, uint32_t leg); void LoadingScreenEnable(int32_t mapID, bool loadingWorld); void LoadingScreenEnableShip(uint32_t transportEntry, int32_t transportMap, int32_t mapID); void LoadingScreenInitialize(); diff --git a/WoW/Source/Magic/MagicClient/SpellTable.cpp b/WoW/Source/Magic/MagicClient/SpellTable.cpp index 1d13b3a..7d02834 100644 --- a/WoW/Source/Magic/MagicClient/SpellTable.cpp +++ b/WoW/Source/Magic/MagicClient/SpellTable.cpp @@ -3,6 +3,7 @@ #include "WoW/Source/Object/ObjectClient/Player_C.h" #include "WoW/Source/Object/Types.h" #include "WoW/Source/ObjectMgrClient/ObjectMgrClient.h" +#include "Engine/Source/Base/CDataAllocator.h" // STATIC: 0x00D3F60C static bool s_skillLineLinkInfoDirty; @@ -19,6 +20,9 @@ static TSHashTable s_skillLineRecs; // STATIC: 0x00D3F688 static TSGrowableArray s_skillLineLinkInfo; +// STATIC: 0x00D3F698 +static CDataAllocator s_skillLineRecAllocator(sizeof(SKILLLINEREC), 0x1000); + // VERIFY: 87b0816a manual // OFFSET: 0x00810320 bool SpellTableMatchRaceClass(int32_t race, int32_t classId, int32_t raceMask, int32_t classMask, int32_t excludeRace, int32_t excludeClass) { @@ -250,3 +254,14 @@ int32_t GetSkillTierCost(const SkillRaceClassInfoRec* info, uint32_t step) { return tier->m_cost[step]; } + +// VERIFY: e9c3aee4 auto +// OFFSET: 0x00810920 +void SpellTableDestroy() { + s_skillLineRecs.Clear(); + s_skillLineLinkInfoDirty = true; + s_raceClassInfo.Clear(); + s_skillCostsInfo.Clear(); + s_skillLineRecAllocator.Clear(typeid(SKILLLINEREC).raw_name(), SLOG_OBJECT, 1); + s_skillLineLinkInfo.m_count = 0; +} diff --git a/WoW/Source/Magic/MagicClient/SpellVisuals.cpp b/WoW/Source/Magic/MagicClient/SpellVisuals.cpp index 2c06dc1..fa0089b 100644 --- a/WoW/Source/Magic/MagicClient/SpellVisuals.cpp +++ b/WoW/Source/Magic/MagicClient/SpellVisuals.cpp @@ -306,3 +306,58 @@ void SpellVisualsGetMountTransitionTransform(const MountTransitionObject* transi *up = transition->m_groundNormal; *facing = transition->m_facing; } + +// VERIFY: 77642498 manual +// OFFSET: 0x007FCA30 +void SpellVisualsTick() { + uint32_t time = OsGetAsyncTimeMs(); + LightningObject* lightning = s_lightningObjects.Head(); + + while (!s_lightningObjects.IsEnd(lightning)) { + LightningObject* next = s_lightningObjects.RawNext(lightning); + + if (!lightning->Tick(time)) { + s_lightningObjects.UnlinkNode(lightning); + + if (--lightning->m_refCount == 0) { + delete lightning; + } + } + + lightning = next; + } + + float elapsed = 0.0f; + + if (s_unk_AF5090 != -1) { + elapsed = static_cast((time - s_unk_AF5090) * 0.001); + } + + s_unk_AF5090 = time; + s_lightningManager->Update(elapsed); + s_eclipse.Update(time); + BlizzardObject* blizzard = s_blizzardObjects.Head(); + + while (!s_blizzardObjects.IsEnd(blizzard)) { + BlizzardObject* next = s_blizzardObjects.RawNext(blizzard); + + if (!blizzard->Update()) { + blizzard->~BlizzardObject(); + s_blizzardObjectHeap.PutData(blizzard, nullptr, 0); + } + + blizzard = next; + } + + MountTransitionObject* transition = s_mountTransitions.Head(); + + while (!s_mountTransitions.IsEnd(transition)) { + MountTransitionObject* next = s_mountTransitions.RawNext(transition); + + if (!transition->Tick()) { + s_mountTransitions.DeleteNode(transition); + } + + transition = next; + } +} diff --git a/WoW/Source/Magic/MagicClient/SpellVisuals.h b/WoW/Source/Magic/MagicClient/SpellVisuals.h index 6646f7f..2105c64 100644 --- a/WoW/Source/Magic/MagicClient/SpellVisuals.h +++ b/WoW/Source/Magic/MagicClient/SpellVisuals.h @@ -36,6 +36,7 @@ class BlizzardObject : public TSLinkedNode { ~BlizzardObject(); void SetFrameOfReference(const C44Matrix* matrix); + bool Update(); }; class EclipseState { @@ -77,8 +78,10 @@ class LightningObject : public TSLinkedNode { /* 0050 */ uint32_t unk_0050; /* 0054 */ uint8_t unk_0054[4]; /* 0058 */ uint32_t unk_0058; + /* 005C */ int32_t m_refCount; ~LightningObject(); + bool Tick(uint32_t time); }; void LightningObjectReleaseRef(LightningObject* object); @@ -109,6 +112,8 @@ class MountTransitionObject : public TSLinkedNode { /* 0078 */ uint32_t unk_0078; /* 007C */ float m_alpha; /* 0080 */ uint32_t unk_0080; + + bool Tick(); }; extern CVar* s_spellEffectLevelVar; diff --git a/WoW/Source/Magic/MagicClient/Spell_C.h b/WoW/Source/Magic/MagicClient/Spell_C.h index b36206b..b8e6d57 100644 --- a/WoW/Source/Magic/MagicClient/Spell_C.h +++ b/WoW/Source/Magic/MagicClient/Spell_C.h @@ -293,7 +293,6 @@ void Spell_C_SpellFailed(PendingSpellCast* cast, const SpellRec* spell, int32_t bool Spell_C_CastSpell(CGUnit_C* caster, int32_t spellId, const CGItem_C* item, WOWGUID target, PendingSpellCast* cast, bool confirmed); void UnitCombatLogCastStart(const WOWGUID& caster, const WOWGUID& target, int32_t spellId); void Spell_C_StopTargeting(); -void SpellTableDestroy(); void SpellTableInitialize(); int32_t Script_CancelUnitBuff(lua_State* L); diff --git a/WoW/Source/Object/CreatureStats.h b/WoW/Source/Object/CreatureStats.h index a63a688..1016b53 100644 --- a/WoW/Source/Object/CreatureStats.h +++ b/WoW/Source/Object/CreatureStats.h @@ -3,6 +3,7 @@ #include #include +#include "Engine/Source/Storm/H/storm.h" class CDataStore; @@ -30,4 +31,21 @@ class CreatureStats { void Unpack(CDataStore* msg); }; +// INLINED +inline CreatureStats::~CreatureStats() { + for (uint32_t i = 0; i < 4; i++) { + if (this->m_name[i]) { + SMemFree(this->m_name[i], __FILE__, __LINE__, 0); + } + } + + if (this->m_subName) { + SMemFree(this->m_subName, __FILE__, __LINE__, 0); + } + + if (this->m_iconName) { + SMemFree(this->m_iconName, __FILE__, __LINE__, 0); + } +} + #endif diff --git a/WoW/Source/Object/Movement.cpp b/WoW/Source/Object/Movement.cpp index e0b3f06..3a42da1 100644 --- a/WoW/Source/Object/Movement.cpp +++ b/WoW/Source/Object/Movement.cpp @@ -6684,3 +6684,79 @@ void CMovement_C::OnSetRawFacingLocal(uint32_t eventTime, float facing) { int32_t CMovement_C::UpdateTransportStatus(const CClientObjCreate& create) { return this->UpdateTransportStatus(WOWGUID{ CMovementShared::UpdateTransportStatus(create.m_move.m_status) }, create.m_move.m_status.m_transportSeat); } + +// VERIFY: 81c65e19 auto +// OFFSET: 0x006EC390 +void CMovement_C::Disable() { + CMovementShared::Disable(); + this->m_moveQueue.FreeAll(); +} + +// VERIFY: ba2b58d3 manual +// OFFSET: 0x00760720 +void CMovement_C::CollideWithTransport(uint32_t time, uint32_t elapsed, float distance, const C3Vector& direction, const C44Matrix& transportMatrix) { + C3Vector position = this->m_position * transportMatrix; + World::IsValidPosition(position.x, position.y, position.z, 0.0f); + CAaBox box; + box.b = C3Vector(0.0f, 0.0f, 0.0f); + box.t = C3Vector(0.0f, 0.0f, 0.0f); + this->BuildCollisionBox(position, box); + s_queryBox = box; + CAaBox moved; + moved.b.x = box.b.x + direction.x * distance; + moved.b.y = box.b.y + direction.y * distance; + moved.b.z = box.b.z + direction.z * distance; + moved.t.x = box.t.x + direction.x * distance; + moved.t.y = box.t.y + direction.y * distance; + moved.t.z = box.t.z + direction.z * distance; + s_queryBox |= moved; + uint32_t flags = this->m_unit->IsClientControlled() ? 0x111 : 0x2111; + CGUnit_C* unit = this->m_unit; + + if ((unit->m_obj->m_type & TYPEMASK_PLAYER) && (static_cast(unit)->m_player->m_playerFlags & 0x10)) { + flags |= 0x8000; + } + + if (!World::GetFacets(&box, &s_queryBox, &s_moveFacets, flags, nullptr)) { + return; + } + + C4Plane planes[7]; + + for (uint32_t i = 0; i < 7; i++) { + planes[i].n = C3Vector(0.0f, 0.0f, 1.0f); + planes[i].d = 0.0f; + } + + uint32_t facetIndex; + uint32_t planeCount; + float moveDist; + this->DistanceToMove(&s_moveFacets, direction, distance, &facetIndex, planes, &planeCount, &moveDist, &position); + + if (facetIndex == s_moveFacets.facets.m_count) { + return; + } + + if (this->m_spline && !(this->m_spline->m_flags & SPLINEFLAG_NO_SPLINE)) { + return; + } + + CGGameObject_C* transport = static_cast(ClntObjMgrObjectPtr(this->m_transportGuid, TYPEMASK_GAMEOBJECT, __FILE__, __LINE__)); + uint32_t eventTime = static_cast(static_cast(moveDist / distance * static_cast(elapsed) + 0.5f)) + transport->unk_0200 - elapsed + time; + uint32_t transportTime = transport->m_typeData->GetSequenceTimeFromRealTime(eventTime); + CMovementGlobals* globals = MovementGetGlobals(); + uint32_t savedTime = globals->m_transportTime; + globals->m_transportTime2 = savedTime; + globals->m_transportTime = transportTime; + C44Matrix inverse = transportMatrix.AffineInverse(); + C3Vector localDir = TransformDirection(direction, inverse); + C3Vector move(localDir.x * moveDist, localDir.y * moveDist, localDir.z * moveDist); + this->m_position.x = move.x + this->m_position.x; + this->m_position.y = move.y + this->m_position.y; + this->m_position.z = move.z + this->m_position.z; + this->m_fallStartZ = move.z + this->m_fallStartZ; + this->ForceSetTransport(WOWGUID(), 0xFF, 0); + this->QueueFallEvent(eventTime); + globals->m_transportTime2 = globals->m_transportTime; + globals->m_transportTime = savedTime; +} diff --git a/WoW/Source/Object/Movement.h b/WoW/Source/Object/Movement.h index 9791285..dd7dd17 100644 --- a/WoW/Source/Object/Movement.h +++ b/WoW/Source/Object/Movement.h @@ -175,6 +175,7 @@ class CMovement_C : public CMovementShared { void SendTimeSyncResp(uint32_t clientTime, uint32_t counter); void SetCollisionBox(float width, float height, float scale, float referenceScale, int32_t force); int32_t CollisionBoxDoesntFit(float width, float height, float scale); + int32_t CollisionBoxDoesntFit(const CAaBox& box); void SetInterpolation(uint32_t time); void SetSplineFaceAngle(float facing); void SetSplineFacePoint(const C3Vector& point); @@ -258,6 +259,7 @@ class CMovement_C : public CMovementShared { void MoveSplineMoverWithoutCollision(const C3Vector& position, uint32_t time, uint32_t elapsed); int32_t ValidateTestVsFacetQuery(C3Vector move) const; int32_t GetCurrentHoverHeight(float* height, int32_t* noGround, uint64_t* facetId) const; + void CollideWithTransport(uint32_t time, uint32_t elapsed, float distance, const C3Vector& direction, const C44Matrix& transportMatrix); int32_t DistanceToMove(World::FacetData* facets, const C3Vector& direction, float distance, uint32_t* facetIndex, C4Plane* planes, uint32_t* planeCount, float* moveDistance, const C3Vector* position) const; void CallMoveEventHandlers(uint32_t time, uint32_t remaining, uint32_t oldFlags, uint32_t oldFlags2, int32_t jumping, int32_t transportChanged); int32_t GetMoveFacets(float distance, uint32_t elapsed, C3Vector direction); diff --git a/WoW/Source/Object/MovementShared.cpp b/WoW/Source/Object/MovementShared.cpp index 5ec033c..6be12fe 100644 --- a/WoW/Source/Object/MovementShared.cpp +++ b/WoW/Source/Object/MovementShared.cpp @@ -2287,3 +2287,29 @@ void CMovementShared::ResetFallOnControlLoss() { this->m_currentSpeed = this->GetBaseSpeed(0); } } + +// VERIFY: 6c0feab8 manual +// OFFSET: 0x0098C670 +void CMovementShared::Disable() { + this->m_flags2 &= ~0x80; + + if (this->m_spline) { + MovementDelSpline(this->m_spline); + this->m_spline = nullptr; + + if (!(this->m_flags & 0x1000)) { + this->m_currentSpeed = this->GetBaseSpeed(0); + } + } + + this->m_globalUnitsLink.Unlink(); + WOWGUID transport = this->m_link.m_next ? this->m_transportGuid : WOWGUID(); + this->m_link.Unlink(); + this->m_transportGuid = WOWGUID(); + + if (transport != WOWGUID()) { + MovementNotifyTransportUnitRemoved(*this->m_ownerGuid, transport, this->m_transportSeat); + } + + this->m_flags &= 0x77FFFFFF; +} diff --git a/WoW/Source/Object/MovementShared.h b/WoW/Source/Object/MovementShared.h index a2d5269..33c549f 100644 --- a/WoW/Source/Object/MovementShared.h +++ b/WoW/Source/Object/MovementShared.h @@ -17,6 +17,7 @@ class CMovementStatus; class CMovementShared : public CPassenger { public: void ResetFallOnControlLoss(); + void Disable(); using CPassenger::GetPosition; static float s_terminalVelocity; diff --git a/WoW/Source/Object/ObjectClient/CGGameObject_C_Type_Chair.cpp b/WoW/Source/Object/ObjectClient/CGGameObject_C_Type_Chair.cpp index ea4535e..ee5d14d 100644 --- a/WoW/Source/Object/ObjectClient/CGGameObject_C_Type_Chair.cpp +++ b/WoW/Source/Object/ObjectClient/CGGameObject_C_Type_Chair.cpp @@ -69,3 +69,18 @@ bool CGGameObject_C_Type_Chair::CanUse() const { return true; } + +// VERIFY: 9259c9d2 manual +// OFFSET: 0x004F55F0 +void GenerateChairPoints(const C44Matrix& matrix, uint32_t count, C3Vector* points, float offset) { + C3Vector point; + point.x = 0.0f; + point.y = -((static_cast(count) - 1.0f) * 0.5f); + point.z = offset; + + for (; count; count--) { + *points = point * matrix; + point.y += 1.0f; + points++; + } +} diff --git a/WoW/Source/Object/ObjectClient/CGGameObject_C_Type_Chair.h b/WoW/Source/Object/ObjectClient/CGGameObject_C_Type_Chair.h index cdc1030..e786024 100644 --- a/WoW/Source/Object/ObjectClient/CGGameObject_C_Type_Chair.h +++ b/WoW/Source/Object/ObjectClient/CGGameObject_C_Type_Chair.h @@ -5,7 +5,7 @@ #include #include "WoW/Source/Object/ObjectClient/GameObject_C.h" -int32_t GenerateChairPoints(const C44Matrix& matrix, uint32_t count, C3Vector* points, float offset); +void GenerateChairPoints(const C44Matrix& matrix, uint32_t count, C3Vector* points, float offset); class CGGameObject_C_Type_Chair : public CGGameObject_C_TypeBase { public: diff --git a/WoW/Source/Object/ObjectClient/CGGameObject_C_Type_Transport.cpp b/WoW/Source/Object/ObjectClient/CGGameObject_C_Type_Transport.cpp index 235b4a2..52a904c 100644 --- a/WoW/Source/Object/ObjectClient/CGGameObject_C_Type_Transport.cpp +++ b/WoW/Source/Object/ObjectClient/CGGameObject_C_Type_Transport.cpp @@ -4,6 +4,14 @@ #include "WoW/Source/DB/DBClient/DBClient.h" #include "WoW/Source/DB/Rec/TransportAnimationRec.h" #include "WoW/Source/DB/Rec/TransportRotationRec.h" +#include "Engine/Source/Tempest/C4Quaternion.h" +#include "Engine/Source/Tempest/C44Matrix.h" +#include "Engine/Source/Os/TimeManager.h" +#include "Engine/Source/Tempest/C33Matrix.h" +#include "WoW/Source/Object/Movement.h" +#include "WoW/Source/Object/GameObject.h" +#include +#include "WoW/Source/WorldClient/MapEntity.h" // VERIFY: 0bbb79ee manual // OFFSET: 0x0070C8C0 @@ -187,3 +195,295 @@ void CGGameObject_C_Type_Transport::PostReenable() { World::ObjectSetSequenceFinishedCallback(this->m_worldObject, &CGGameObject_C_Type_WorldObj::SequenceFinishedHandler, 0, 0); } } + +// VERIFY: f1474ba1 manual +// OFFSET: 0x00711F20 +void CGGameObject_C_Type_Transport::InitializeMovement() { + CGGameObject_C* owner = this->m_owner; + this->unk_0038 = owner->m_gameObject->m_state; + uint32_t time = owner->unk_0200 + OsGetAsyncTimeMs(); + this->InitializeStateChangeTime(time); + C3Vector offset(0.0f, 0.0f, 0.0f); + C4Quaternion rotation; + rotation.x = 0.0f; + rotation.y = 0.0f; + rotation.z = 0.0f; + rotation.w = 1.0f; + this->unk_0030 = time; + this->Interpolate(time, &offset, &rotation); + C3Vector position = this->m_owner->m_passenger.GetPosition(this->m_owner->m_passenger.m_position); + this->m_position.x = position.x + offset.x; + this->m_position.y = position.y + offset.y; + this->m_position.z = position.z + offset.z; + CPassenger& passenger = this->m_owner->m_passenger; + reinterpret_cast(passenger.m_facing) = rotation; + passenger.unk_002C |= 0x2; + C44Matrix& matrix = this->m_owner->m_matrix; + matrix = this->m_owner->GetRotation(); + matrix.d0 = this->m_position.x; + matrix.d1 = this->m_position.y; + matrix.d2 = this->m_position.z; +} + +// VERIFY: 89bf86e6 auto +// OFFSET: 0x00710570 +uint32_t CGGameObject_C_Type_Transport::GetStateDuration(int32_t state) { + uint32_t count = this->m_frameCount; + + if (!count) { + return 0; + } + + uint32_t period = this->m_owner->m_gameObject->m_level; + + if (!period) { + return this->m_frames[count - 1].m_time; + } + + if (state) { + return this->m_frames[count - 1].m_time - period; + } + + return period; +} + +// VERIFY: 5df80093 manual +// OFFSET: 0x007105D0 +void CGGameObject_C_Type_Transport::InitializeStateChangeTime(uint32_t time) { + CGGameObjectData* gameObject = this->m_owner->m_gameObject; + + if (gameObject->m_level && this->m_frameCount) { + float elapsed = this->GetStateDuration(gameObject->m_state) * (gameObject->m_pathProgress * 0.000015259022f); + this->m_stateChangeTime = time - static_cast(elapsed); + } +} + +// VERIFY: 823a6baf manual +// OFFSET: 0x0070DA40 +uint32_t CGGameObject_C_Type_Transport::ResetStateChange(uint32_t time) { + CGGameObjectData* gameObject = this->m_owner->m_gameObject; + int32_t state = gameObject->m_state; + this->unk_0038 = state; + this->m_stateChangeSequenceTime = 0; + uint32_t period = gameObject->m_level; + + if (state) { + this->m_stateChangeTime = time + period - this->m_frames[this->m_frameCount - 1].m_time; + return 0; + } + + this->m_stateChangeTime = time - period; + return period; +} + +// VERIFY: 0fdff1cd manual +// OFFSET: 0x0070DAA0 +C3Vector CGGameObject_C_Type_Transport::GetMovement(uint32_t time) { + if (this->m_frameCount <= 1) { + return C3Vector(0.0f, 0.0f, 0.0f); + } + + uint32_t next = this->m_frameCount != this->unk_0048 + 1 ? this->unk_0048 + 1 : 0; + TransportFrame* current; + TransportFrame* following; + + while (true) { + following = &this->m_frames[next]; + current = &this->m_frames[this->unk_0048]; + + if (time >= current->m_time && time < following->m_time) { + break; + } + + this->unk_0048 = next; + next = this->m_frameCount != next + 1 ? next + 1 : 0; + } + + float t = static_cast(time - current->m_time) / static_cast(following->m_time - current->m_time); + + if (this->m_worldObject) { + uint32_t sequence = current->m_sequenceId; + + if (sequence != this->unk_0058) { + CGGameObject_C* owner = this->m_owner; + this->unk_0058 = sequence; + World::ObjectSetSequence(this->m_worldObject, sequence, 0, 0); + owner->UpdateObjectEffectAnimationStates(sequence); + } + } + + C33Matrix rotation(reinterpret_cast(this->m_owner->m_gameObject->m_parentRotation)); + float inverse = 1.0f - t; + float x = t * following->m_pos[0] + current->m_pos[0] * inverse; + float y = following->m_pos[1] * t + current->m_pos[1] * inverse; + float z = inverse * current->m_pos[2] + following->m_pos[2] * t; + C3Vector result; + result.x = rotation.c0 * z + rotation.b0 * y + x * rotation.a0; + result.y = rotation.c1 * z + rotation.b1 * y + rotation.a1 * x; + result.z = z * rotation.c2 + y * rotation.b2 + x * rotation.a2; + return result; +} + +// VERIFY: 06adb4af manual +// OFFSET: 0x0070DC10 +C4Quaternion CGGameObject_C_Type_Transport::GetRotation(uint32_t time) { + uint32_t count = this->m_rotationCount; + + if (count <= 1) { + return this->m_owner->GetRotation(); + } + + uint32_t next = this->unk_0054 + 1 != count ? this->unk_0054 + 1 : 0; + TransportRotationRec* current = &this->m_rotations[this->unk_0054]; + TransportRotationRec* following = &this->m_rotations[next]; + uint32_t endTime = following->m_timeIndex; + + if (!endTime && this->m_frames) { + endTime = this->m_frames[this->m_frameCount - 1].m_time; + } + + while (!(time >= static_cast(current->m_timeIndex) && time < endTime)) { + this->unk_0054 = next; + next = this->m_rotationCount != next + 1 ? next + 1 : 0; + current = &this->m_rotations[this->unk_0054]; + following = &this->m_rotations[next]; + endTime = following->m_timeIndex; + + if (!endTime && this->m_frames) { + endTime = this->m_frames[this->m_frameCount - 1].m_time; + } + } + + float t = static_cast(time - current->m_timeIndex) / static_cast(following->m_timeIndex - current->m_timeIndex); + C4Quaternion rotation = C4Quaternion::Slerp(t, reinterpret_cast(current->m_rot), reinterpret_cast(following->m_rot)); + return rotation * reinterpret_cast(this->m_owner->m_gameObject->m_parentRotation); +} + +// VERIFY: 007eb5fe auto +// OFFSET: 0x007106D0 +void CGGameObject_C_Type_Transport::Interpolate(uint32_t time, C3Vector* offset, C4Quaternion* rotation) { + int32_t state = this->m_owner->m_gameObject->m_state; + uint32_t sequenceTime = this->GetSequenceTimeFromRealTime(state, time); + + if (this->m_stateChangeSequenceTime) { + int32_t current = this->unk_0038; + + if (current != state || current) { + if (!sequenceTime) { + sequenceTime = this->ResetStateChange(time); + } + } else if (sequenceTime == this->m_owner->m_gameObject->m_level) { + sequenceTime = this->ResetStateChange(time); + } + } + + *offset = this->GetMovement(sequenceTime); + *rotation = this->GetRotation(sequenceTime); +} + +// VERIFY: 6f1084da manual +// OFFSET: 0x0070C650 +C44Matrix& CGGameObject_C_Type_Transport::UpdateOwnerMatrix() { + C44Matrix& matrix = this->m_owner->m_matrix; + matrix = this->m_owner->GetRotation(); + matrix.d0 = this->m_position.x; + matrix.d1 = this->m_position.y; + matrix.d2 = this->m_position.z; + return matrix; +} + +// VERIFY: fc8ecef3 manual +// OFFSET: 0x007139E0 +void CGGameObject_C_Type_Transport::UpdateMovement(uint32_t time, uint32_t elapsed) { + if (!this->unk_0034 && this->m_worldObject && World::ObjectIsLoaded(this->m_worldObject)) { + this->unk_0034 = 1; + + if (!this->m_frameCount && !this->m_rotationCount) { + World::ObjectUpdate(this->m_worldObject, this->m_owner->GetMatrix()); + return; + } + } + + uint32_t step = elapsed; + + if (elapsed > 250) { + CGGameObject_C* owner = this->m_owner; + uint32_t pathTime = owner->unk_0200 + time - 250; + this->unk_0030 = pathTime; + + if (owner->m_gameObject->m_level && static_cast(this->m_stateChangeTime - pathTime) >= 0) { + this->unk_0030 = this->m_stateChangeTime; + } + + C3Vector offset(0.0f, 0.0f, 0.0f); + C4Quaternion rotation; + rotation.x = 0.0f; + rotation.y = 0.0f; + rotation.z = 0.0f; + rotation.w = 1.0f; + this->Interpolate(this->unk_0030, &offset, &rotation); + CPassenger& passenger = this->m_owner->m_passenger; + reinterpret_cast(passenger.m_facing) = rotation; + passenger.unk_002C |= 0x2; + C3Vector position = this->m_owner->m_passenger.GetPosition(this->m_owner->m_passenger.m_position); + step = 250; + this->m_position.x = position.x + offset.x; + this->m_position.y = position.y + offset.y; + this->m_position.z = position.z + offset.z; + } + + this->unk_0030 = this->m_owner->unk_0200 + time; + this->m_transportUpdateTime = this->GetSequenceTimeFromRealTime(this->unk_0038, this->unk_0030); + C3Vector offset(0.0f, 0.0f, 0.0f); + C4Quaternion rotation; + rotation.x = 0.0f; + rotation.y = 0.0f; + rotation.z = 0.0f; + rotation.w = 1.0f; + this->Interpolate(this->unk_0030, &offset, &rotation); + C3Vector base = this->m_owner->m_passenger.GetPosition(this->m_owner->m_passenger.m_position); + C3Vector position(base.x + offset.x, base.y + offset.y, base.z + offset.z); + C3Vector direction(0.0f, 0.0f, 0.0f); + float speed = this->UpdateCurrentVelocity(step, position, &direction); + + if (this->m_passengers.Head()) { + if (fabs(speed) >= 0.00000095367432f) { + if (this->m_worldObject && !World::ObjectIsWMO(this->m_worldObject)) { + C44Matrix& matrix = this->UpdateOwnerMatrix(); + + for (CPassenger* passenger = this->m_passengers.Head(); passenger; passenger = this->m_passengers.Next(passenger)) { + if (passenger->unk_002C & 0x1) { + static_cast(passenger)->CollideWithTransport(time, step, speed, direction, matrix); + } + } + } + + this->m_position = position; + } + + CPassenger& passenger = this->m_owner->m_passenger; + reinterpret_cast(passenger.m_facing) = rotation; + passenger.unk_002C |= 0x2; + C44Matrix& matrix = this->m_owner->m_matrix; + matrix = this->m_owner->GetRotation(); + matrix.d0 = this->m_position.x; + matrix.d1 = this->m_position.y; + matrix.d2 = this->m_position.z; + int32_t moved = time; + this->MovePassengers(&moved); + } else { + this->m_position = position; + CPassenger& passenger = this->m_owner->m_passenger; + reinterpret_cast(passenger.m_facing) = rotation; + passenger.unk_002C |= 0x2; + C44Matrix& matrix = this->m_owner->m_matrix; + matrix = this->m_owner->GetRotation(); + matrix.d0 = this->m_position.x; + matrix.d1 = this->m_position.y; + matrix.d2 = this->m_position.z; + + if (this->m_worldObject) { + World::ObjectUpdate(this->m_worldObject, matrix); + } + } +} diff --git a/WoW/Source/Object/ObjectClient/CGGameObject_C_Type_Transport.h b/WoW/Source/Object/ObjectClient/CGGameObject_C_Type_Transport.h index d333605..ba8c95d 100644 --- a/WoW/Source/Object/ObjectClient/CGGameObject_C_Type_Transport.h +++ b/WoW/Source/Object/ObjectClient/CGGameObject_C_Type_Transport.h @@ -11,10 +11,8 @@ struct TransportFrame { /* 0000 */ uint32_t unk_0000; /* 0004 */ uint32_t unk_0004; /* 0008 */ uint32_t m_time; - /* 000C */ uint32_t unk_000C; - /* 0010 */ uint32_t unk_0010; - /* 0014 */ uint32_t unk_0014; - /* 0018 */ uint32_t unk_0018; + /* 000C */ float m_pos[3]; + /* 0018 */ uint32_t m_sequenceId; }; class CGGameObject_C_Type_Transport : public CGGameObject_C_Type_TransportBase { @@ -39,6 +37,13 @@ class CGGameObject_C_Type_Transport : public CGGameObject_C_Type_TransportBase { CGGameObject_C_Type_Transport(CGGameObject_C* owner); uint32_t GetSequenceTimeFromRealTime(int32_t state, uint32_t time) const; void InitializeMovement(); + void InitializeStateChangeTime(uint32_t time); + void Interpolate(uint32_t time, C3Vector* offset, C4Quaternion* rotation); + uint32_t GetStateDuration(int32_t state); + uint32_t ResetStateChange(uint32_t time); + C3Vector GetMovement(uint32_t time); + C4Quaternion GetRotation(uint32_t time); + C44Matrix& UpdateOwnerMatrix(); }; #endif diff --git a/WoW/Source/Object/ObjectClient/GameObject_C.cpp b/WoW/Source/Object/ObjectClient/GameObject_C.cpp index 7524a0c..9673a42 100644 --- a/WoW/Source/Object/ObjectClient/GameObject_C.cpp +++ b/WoW/Source/Object/ObjectClient/GameObject_C.cpp @@ -73,6 +73,13 @@ #include "Engine/Source/ConsoleBase/ConsoleVar.h" #include "WoW/Source/DB/Rec/GameObjectDisplayInfoRec.h" #include "WoW/Source/Ui/PartyFrame.h" +#include "WoW/Source/DB/Rec/SpellEffectCameraShakesRec.h" +#include "WoW/Source/Ui/WorldFrame.h" +#include "WoW/Source/UIUtil/Camera.h" +#include "Engine/Source/Os/TimeManager.h" +#include "WoW/Source/LoadingScreen.h" +#include "Engine/Source/Services/AsyncFile.h" +#include "Engine/Source/Tempest/C4Quaternion.h" // STATIC: 0x00A335E8 static const uint32_t s_oneShotAnims[7] = { 0xFFFFFFFF, 0, 8, 9, 10, 11, 12 }; @@ -2443,3 +2450,327 @@ bool CGGameObject_C_TypeBase::CanUse() const { void CGGameObject_C_TypeAnimated::HandleAnimEvent(uint32_t eventId, uint32_t data, const C3Vector& position, uint32_t time) { GameObject_C_ProcessAnimEvent(eventId, this->m_owner->m_gameObject->m_displayID, data, position, &this->m_sound); } + +// VERIFY: c5be7d0b manual +// OFFSET: 0x007110B0 +CMapEntity* CGGameObject_C::CreateWorldObject(uint64_t guid, int32_t a4, uint32_t doodadSetCount, const int16_t* doodadSets) { + const char* name = this->GetModelFileNameInternal(); + + if (!name) { + return nullptr; + } + + C3Vector position = this->m_passenger.GetPosition(this->m_passenger.m_position); + CMapBaseObj* object = CWorld::ObjectCreate(name, position, this->GetFacing(), a4, 0, guid, doodadSetCount, doodadSets, nullptr, 0); + + if (!object) { + SysMsgPrintf(STATUS_ERROR, 2, "Game object (%d): failed to load: \"%s\"", this->m_obj->m_entryID, name); + } + + return static_cast(object); +} + +// VERIFY: b54abd63 auto +// OFFSET: 0x00711A10 +void CGGameObject_C_Type_WorldObj::CreateWorldObj() { + switch (this->m_owner->m_gameObject->m_typeID) { + case 11: + case 15: + case 35: + this->m_worldObject = this->m_owner->CreateWorldObject(this->m_owner->m_obj->m_guid.m_guid, 0, 0, nullptr); + + if (this->m_worldObject && this->m_owner->m_gameObject->m_typeID == 11) { + World::ObjectSetMoveable(this->m_worldObject, 1); + } + + break; + + case 33: + return; + + default: + this->m_worldObject = this->m_owner->CreateWorldObject(0, 0, 0, nullptr); + break; + } +} + +// VERIFY: 9c0b3858 auto +// OFFSET: 0x007100D0 +void CGGameObject_C_Type_MapObjTransport::InitializeMovement() { + uint32_t time = OsGetAsyncTimeMs(); + CGGameObject_C* owner = this->m_owner; + uint32_t index = CGameObjectDef::GetPropNum(owner->m_gameObject->m_typeID, 128); + GameObjectStats* stats = owner->m_stats; + + if (stats && index < 24 && stats->m_propValue[index]) { + uint32_t offsetTime = time + this->m_owner->unk_0200; + this->m_shipPath.SetTimeOffset(offsetTime, this->m_owner->m_gameObject->m_pathProgress * 0.000015259022f); + CGGameObjectData* gameObject = this->m_owner->m_gameObject; + + if (gameObject->m_dynamicFlags & 0x10) { + this->m_shipPath.WaitAtCurrentLocation(offsetTime); + } else { + this->m_shipPath.WaitAtNextPausePoint(offsetTime, gameObject->m_state == 1); + } + } + + this->UpdateMovement(time, 0); +} + +// VERIFY: ccfc2763 manual +// OFFSET: 0x0070D7E0 +void CGGameObject_C_TypeAnimated::HandleAnimFinished() { + int32_t state = this->m_animState; + int32_t pending = this->unk_0014; + this->unk_0014 = -1; + + switch (state) { + case 0: + case 8: + case 9: + case 10: + case 11: + if (!(this->m_owner->m_modelFlags & 0x100000)) { + this->UpdateState(this->m_owner->m_displayState, this->m_owner->m_displayState); + } + + break; + + case 1: + case 3: + case 6: + this->SetSequence(this->m_owner->m_worldModel); + break; + + case 2: + this->UpdateAnimState(3); + break; + + case 4: + case 7: + this->UpdateAnimState(1); + break; + + case 5: + this->UpdateAnimState(6); + break; + } + + if (pending != -1 && pending != 3 && pending != 1 && pending != 6) { + ClntObjMgrUnlockObject(this->m_owner->m_obj->m_guid, __FILE__, __LINE__); + } +} + +// VERIFY: 96d91adb auto +// OFFSET: 0x0070BF70 +static void GameObject_C_PlayAnimatedSound(uint32_t displayId, int32_t index, const C3Vector& position, SE2SoundKitObject* sound) { + if (index == -1) { + return; + } + + GameObjectDisplayInfoRec* displayInfo = g_gameObjectDisplayInfoDB.GetRecord(displayId); + + if (!displayInfo) { + return; + } + + int32_t soundKitId = displayInfo->m_sound[index]; + SE2SoundKitProperties properties; + + if (!SI2::IsSoundKitLooping(soundKitId)) { + properties.ResetToDefaults(); + properties.m_maxAudibleBehavior = 0; + SI2::PlaySoundKit(soundKitId, &position, nullptr, &properties, 0, nullptr, 1, 0); + return; + } + + if (!sound || SI2::IsPlaying(sound) || SI2::IsTooCloseToExistingSoundKit(soundKitId, &position)) { + return; + } + + properties.ResetToDefaults(); + properties.m_loopMode = 1; + properties.m_streaming = true; + properties.m_software = 1; + properties.m_maxAudibleBehavior = 0; + SI2::PlaySoundKit(soundKitId, &position, sound, &properties, 0, nullptr, 1, 0); +} + +// VERIFY: cfabb88c auto +// OFFSET: 0x0070C050 +void GameObject_C_ProcessAnimEvent(uint32_t eventId, uint32_t displayId, uint32_t data, const C3Vector& position, SE2SoundKitObject* sound) { + switch (eventId) { + case '0OG$': + GameObject_C_PlayAnimatedSound(displayId, 0, position, sound); + break; + + case '1OG$': + GameObject_C_PlayAnimatedSound(displayId, 1, position, sound); + break; + + case '2OG$': + GameObject_C_PlayAnimatedSound(displayId, 2, position, sound); + break; + + case '3OG$': + GameObject_C_PlayAnimatedSound(displayId, 3, position, sound); + break; + + case '4OG$': + GameObject_C_PlayAnimatedSound(displayId, 4, position, sound); + break; + + case '5OG$': + GameObject_C_PlayAnimatedSound(displayId, 5, position, sound); + break; + + case '0CG$': + GameObject_C_PlayAnimatedSound(displayId, 6, position, sound); + break; + + case '1CG$': + GameObject_C_PlayAnimatedSound(displayId, 7, position, sound); + break; + + case '2CG$': + GameObject_C_PlayAnimatedSound(displayId, 8, position, sound); + break; + + case '3CG$': + GameObject_C_PlayAnimatedSound(displayId, 9, position, sound); + break; + + case 'DNS$': + case 'OSD$': + SI2::PlaySoundKit(data, &position, nullptr, nullptr, 0, nullptr, 1, 0); + break; + + case 'LSD$': + if (sound && !SI2::IsPlaying(sound) && !SI2::IsTooCloseToExistingSoundKit(data, &position)) { + SE2SoundKitProperties properties; + properties.ResetToDefaults(); + properties.m_fadeInTime = 1.0f; + properties.m_fadeOutTime = 1.0f; + properties.m_loopMode = 1; + properties.m_maxAudibleBehavior = 0; + properties.m_streaming = true; + properties.m_software = 1; + SI2::PlaySoundKit(data, &position, sound, &properties, 0, nullptr, 1, 0); + } + + break; + + case 'KHS$': { + SpellEffectCameraShakesRec* shakes = g_spellEffectCameraShakesDB.GetRecord(data); + + if (shakes) { + for (int32_t i = 0; i < 3; i++) { + CGWorldFrame::GetActiveCamera()->AddShakeById(shakes->m_cameraShake[i], &position); + } + } + + break; + } + } +} + +// VERIFY: 11b423bd manual +// OFFSET: 0x007134A0 +void CGGameObject_C_Type_MapObjTransport::UpdateMovement(uint32_t time, uint32_t elapsed) { + C3Vector position(0.0f, 0.0f, 0.0f); + int32_t mapId = -1; + int32_t initial = this->unk_0038 == -1; + uint32_t pathTime = this->m_owner->unk_0200 + time; + uint32_t sequence; + float facing; + uint32_t leg; + float roll; + float pitch; + this->m_shipPath.GetPosition(pathTime, elapsed, &mapId, &sequence, &position, &facing, &leg, &roll, &pitch, 0); + + if (mapId != static_cast(ClntObjMgrGetMapID())) { + CGUnit_C* mover = static_cast(ClntObjMgrObjectPtr(CGUnit_C::s_activeMover, TYPEMASK_UNIT, __FILE__, __LINE__)); + + if (mover && mover->GetTransportGUID() == this->m_owner->m_obj->m_guid.m_guid) { + MovementSetTransportUpdateTime(this->m_transportUpdateTime); + } + + return; + } + + this->unk_0030 = pathTime; + this->m_transportUpdateTime = this->GetSequenceTimeFromRealTime(pathTime); + this->UpdateCurrentVelocity(elapsed, position, nullptr); + this->m_position = position; + C44Matrix& matrix = this->m_owner->m_matrix; + matrix.d3 = 1.0f; + matrix.c2 = 1.0f; + matrix.b1 = 1.0f; + matrix.a0 = 1.0f; + matrix.d2 = 0.0f; + matrix.d1 = 0.0f; + matrix.d0 = 0.0f; + matrix.c3 = 0.0f; + matrix.c1 = 0.0f; + matrix.c0 = 0.0f; + matrix.b3 = 0.0f; + matrix.b2 = 0.0f; + matrix.b0 = 0.0f; + matrix.a3 = 0.0f; + matrix.a2 = 0.0f; + matrix.a1 = 0.0f; + matrix.d0 = this->m_position.x; + matrix.d1 = this->m_position.y; + matrix.d2 = this->m_position.z; + matrix.RotateAroundZ(facing); + matrix.RotateAroundY(pitch); + matrix.RotateAroundX(roll); + CGGameObject_C* owner = this->m_owner; + C4Quaternion rotation; + rotation.x = 0.0f; + rotation.y = 0.0f; + rotation.z = 0.0f; + rotation.w = 0.0f; + rotation.FromRotationMatrix(owner->m_matrix); + reinterpret_cast(owner->m_passenger.m_facing) = rotation; + owner->m_passenger.unk_002C |= 0x2; + + if (this->m_worldObject) { + World::ObjectUpdate(this->m_worldObject, matrix); + + if (!this->unk_0034 && World::ObjectIsLoaded(this->m_worldObject)) { + World::ObjectSetSequenceFinishedCallback(this->m_worldObject, CGGameObject_C_Type_WorldObj::SequenceFinishedHandler, 0, 0); + this->unk_0034 = 1; + } + + if (this->unk_0034 && this->unk_0038 != static_cast(sequence)) { + World::ObjectSetSequence(this->m_worldObject, sequence, 0, 0); + this->unk_0038 = sequence; + this->UpdateObjectEffectState(sequence); + } + } + + int32_t moved; + this->MovePassengers(&moved); + uint32_t previousLeg = this->unk_0080; + + if (previousLeg == leg) { + return; + } + + this->unk_0080 = leg; + + if (!moved || initial) { + return; + } + + CGUnit_C* target = static_cast(ClntObjMgrObjectPtr(CGWorldFrame::GetActiveCamera()->m_targetGUID, TYPEMASK_UNIT, __FILE__, __LINE__)); + AsyncFileReadSetProgressCallback(LoadingScreenAsyncCallback, nullptr); + World::SetLoadProgressCallback(LoadingScreenWorldCallback, nullptr); + LoadingScreenEnableShipLeg(this->m_owner->m_obj->m_entryID, previousLeg); + World::Preload(target->GetPosition(), 0); + CGObject_C::UpdateAllWorldObjects(); + LoadingScreenDisable(); + AsyncFileReadSetProgressCallback(nullptr, nullptr); + World::SetLoadProgressCallback(nullptr, nullptr); +} diff --git a/WoW/Source/Object/ObjectClient/GameObject_C.h b/WoW/Source/Object/ObjectClient/GameObject_C.h index 9c73114..a45f0c9 100644 --- a/WoW/Source/Object/ObjectClient/GameObject_C.h +++ b/WoW/Source/Object/ObjectClient/GameObject_C.h @@ -323,6 +323,8 @@ class CGGameObject_C : public CGObject_C, public CGGameObject { int32_t CanUseNow() const; int32_t CheckRange() const; void CloseInteraction(); + void UseObject(); + CMapEntity* CreateWorldObject(uint64_t guid, int32_t a4, uint32_t doodadSetCount, const int16_t* doodadSets); void AddWorldDamageText(int32_t amount); void AddWorldHealingText(int32_t amount, int32_t overheal); const char* GetCloseText() const; diff --git a/WoW/Source/Object/ObjectClient/Item_C.cpp b/WoW/Source/Object/ObjectClient/Item_C.cpp index 08c996a..a033c0a 100644 --- a/WoW/Source/Object/ObjectClient/Item_C.cpp +++ b/WoW/Source/Object/ObjectClient/Item_C.cpp @@ -1844,3 +1844,21 @@ int32_t CGItem_C::CanGoInSlot(int32_t itemId, uint32_t slot, int32_t bypass) { int32_t CGItem_C::CanGoInSlot(uint32_t slot, int32_t bypass) { return CGItem_C::CanGoInSlot(this->m_obj->m_entryID, slot, bypass); } + +// VERIFY: f2b21d47 auto +// OFFSET: 0x00709DE0 +int32_t GetItemIDByName(const char* name) { + const char* link = SStrStr(name, "item:"); + + if (link) { + return SStrToInt(link + 5); + } + + ITEMBYNAME* entry = s_itemByName.Ptr(name); + + if (entry) { + return entry->m_itemId; + } + + return 0; +} diff --git a/WoW/Source/Object/ObjectClient/Missile_C.cpp b/WoW/Source/Object/ObjectClient/Missile_C.cpp index 48131ff..06c8b23 100644 --- a/WoW/Source/Object/ObjectClient/Missile_C.cpp +++ b/WoW/Source/Object/ObjectClient/Missile_C.cpp @@ -44,8 +44,11 @@ CMissile* CMissile::s_inFlightMissileList; // STATIC: 0x00CA0B5C CMissile* CMissile::s_missileDestroyList; +// STATIC: 0x00CA0AF8 +static double s_msfNumbers[12]; + // STATIC: 0x00ADA828 -static SimpleScriptIO s_msfIO; +static SimpleScriptIO s_msfIO(s_msfNumbers, 12); // STATIC: 0x00ADA7C0 static const char* s_msfArgs[] = { "progress", "time", "missileIndex", "missileCount", "distanceToFirePos", "distanceToImpactPos", "startDistance", "totalDistance", "rand1", "rand2", "rand3", "spellID", nullptr }; diff --git a/WoW/Source/Object/ObjectClient/Player_C.cpp b/WoW/Source/Object/ObjectClient/Player_C.cpp index 84ca81f..7cec576 100644 --- a/WoW/Source/Object/ObjectClient/Player_C.cpp +++ b/WoW/Source/Object/ObjectClient/Player_C.cpp @@ -112,6 +112,11 @@ #include "WoW/Source/Client.h" #include #include "WoW/Source/Ui/ScriptEvents.h" +#include "WoW/Source/Game/GameClient/CDrawBowString.h" +#include "WoW/Source/DB/Rec/ItemDisplayInfoRec.h" +#include "WoW/Source/Game/ValidateName.h" +#include +#include struct GUILDUPDATETIMESTAMP { /* 0000 */ uint32_t m_guildId; @@ -9177,6 +9182,42 @@ int32_t AreaTriggerCheck(const void* data, void* param) { return 1; } +// VERIFY: 6fcd5d9e auto +// OFFSET: 0x006D7720 +int32_t CGPlayer_C::UpdateMountedCollisionBox(float mountHeight, int32_t force) { + CreatureDisplayInfoRec* displayInfo = g_creatureDisplayInfoDB.GetRecord(this->m_unit->m_unitFieldNativedisplayid); + CreatureModelDataRec* modelData = displayInfo ? g_creatureModelDataDB.GetRecord(displayInfo->m_modelID) : nullptr; + + if (!modelData) { + SErrDisplayAppFatalMessage("", "", 0); + } + + float modelScale; + float scale = this->GetScaledModelScale(displayInfo, modelData, &modelScale); + float height = this->m_mountScale * mountHeight + modelData->m_collisionHeight * 0.5f; + + if (height <= modelData->m_collisionHeight) { + height = modelData->m_collisionHeight; + } else if (!force && this->IsActivePlayer()) { + C3Vector position = this->GetPosition(); + CAaBox box(position, position); + box.b.z = this->m_movementData.m_collisionHeight + box.b.z; + box.t.z = height * scale + box.t.z; + box.b.x = box.b.x - this->m_movementData.m_collisionRadius; + box.t.x = box.t.x + this->m_movementData.m_collisionRadius; + box.b.y = box.b.y - this->m_movementData.m_collisionRadius; + box.t.y = box.t.y + this->m_movementData.m_collisionRadius; + + if (this->m_movementData.CollisionBoxDoesntFit(box)) { + return 0; + } + } + + this->m_movementData.SetCollisionBox(this->m_movementData.m_collisionRadius + this->m_movementData.m_collisionRadius, height, scale, modelScale, force); + + return 1; +} + // VERIFY: 5cad3e09 auto // OFFSET: 0x006D78C0 int32_t CGPlayer_C::UpdateUnitCollisionBox(int32_t a2, int32_t a3) { @@ -9262,3 +9303,438 @@ uint32_t GetVisibleAuraEffectDisplay() { uint32_t GetVisibleAuraEffectFlags() { return s_unk_C9EAB4; } + +// VERIFY: 07b73796 auto +// OFFSET: 0x005EEB70 +void PlayerShutdownSounds() { +} + +// VERIFY: 71adbe9a auto +// OFFSET: 0x006E0300 +void PlayerClientShutdown() { + CGPlayer_C::PlayerShutdownMessageHandlers(); + PlayerShutdownSounds(); + + if (s_areaTriggerTimer) { + ClientKillTimer(s_areaTriggerTimer, AreaTriggerCheck, "AreaTriggerCheck"); + s_areaTriggerTimer = 0; + } +} + +// VERIFY: 8cf14677 auto +// OFFSET: 0x006CE480 +void CGPlayer_C::PlayerShutdownMessageHandlers() { + ClientServices::ClearMessageHandler(SMSG_MOUNT_RESULT); + ClientServices::ClearMessageHandler(SMSG_DISMOUNT_RESULT); + ClientServices::ClearMessageHandler(SMSG_INVENTORY_CHANGE_FAILURE); + ClientServices::ClearMessageHandler(SMSG_OPEN_CONTAINER); + ClientServices::ClearMessageHandler(SMSG_ITEM_PUSH_RESULT); + ClientServices::ClearMessageHandler(SMSG_VENDOR_INVENTORY); + ClientServices::ClearMessageHandler(SMSG_BUY_FAILED); + ClientServices::ClearMessageHandler(SMSG_BUY_SUCCEEDED); + ClientServices::ClearMessageHandler(SMSG_SELL_ITEM); + ClientServices::ClearMessageHandler(SMSG_ITEM_REFUND_INFO_RESPONSE); + ClientServices::ClearMessageHandler(SMSG_ITEM_PURCHASE_REFUND_RESULT); + ClientServices::ClearMessageHandler(SMSG_LOOT_RESPONSE); + ClientServices::ClearMessageHandler(SMSG_LOOT_RELEASE); + ClientServices::ClearMessageHandler(SMSG_LOOT_REMOVED); + ClientServices::ClearMessageHandler(SMSG_LOOT_SLOT_CHANGED); + ClientServices::ClearMessageHandler(SMSG_LOOT_MONEY_NOTIFY); + ClientServices::ClearMessageHandler(SMSG_LOOT_ITEM_NOTIFY); + ClientServices::ClearMessageHandler(SMSG_LOOT_CLEAR_MONEY); + ClientServices::ClearMessageHandler(SMSG_LEARNED_SPELL); + ClientServices::ClearMessageHandler(SMSG_UNLEARNED_SPELLS); + ClientServices::ClearMessageHandler(SMSG_SUPERCEDED_SPELLS); + ClientServices::ClearMessageHandler(SMSG_SEND_KNOWN_SPELLS); + ClientServices::ClearMessageHandler(SMSG_UPDATE_ACTION_BUTTONS); + ClientServices::ClearMessageHandler(SMSG_GROUP_INVITE); + ClientServices::ClearMessageHandler(SMSG_GROUP_CANCEL); + ClientServices::ClearMessageHandler(SMSG_GROUP_DECLINE); + ClientServices::ClearMessageHandler(SMSG_GROUP_UNINVITE); + ClientServices::ClearMessageHandler(SMSG_GROUP_SET_LEADER); + ClientServices::ClearMessageHandler(SMSG_GROUP_DESTROYED); + ClientServices::ClearMessageHandler(SMSG_PARTY_COMMAND_RESULT); + ClientServices::ClearMessageHandler(SMSG_GROUP_LIST); + ClientServices::ClearMessageHandler(SMSG_REAL_GROUP_UPDATE); + ClientServices::ClearMessageHandler(SMSG_QUEST_GIVER_QUEST_LIST_MESSAGE); + ClientServices::ClearMessageHandler(SMSG_QUEST_GIVER_INVALID_QUEST); + ClientServices::ClearMessageHandler(SMSG_QUEST_GIVER_QUEST_DETAILS); + ClientServices::ClearMessageHandler(SMSG_QUEST_GIVER_REQUEST_ITEMS); + ClientServices::ClearMessageHandler(SMSG_QUEST_GIVER_OFFER_REWARD_MESSAGE); + ClientServices::ClearMessageHandler(SMSG_QUEST_GIVER_QUEST_COMPLETE); + ClientServices::ClearMessageHandler(SMSG_QUEST_GIVER_QUEST_FAILED); + ClientServices::ClearMessageHandler(SMSG_QUEST_GIVER_STATUS); + ClientServices::ClearMessageHandler(SMSG_QUEST_GIVER_STATUS_MULTIPLE); + ClientServices::ClearMessageHandler(SMSG_QUEST_LOG_FULL); + ClientServices::ClearMessageHandler(SMSG_TRAINER_LIST); + ClientServices::ClearMessageHandler(SMSG_TRAINER_BUY_FAILED); + ClientServices::ClearMessageHandler(SMSG_SET_PROFICIENCY); + ClientServices::ClearMessageHandler(SMSG_RESURRECT_REQUEST); + ClientServices::ClearMessageHandler(SMSG_PLAYER_SKINNED); + ClientServices::ClearMessageHandler(SMSG_INSPECT_RESULTS_UPDATE); + ClientServices::ClearMessageHandler(SMSG_INSPECT_TALENT); + ClientServices::ClearMessageHandler(SMSG_READ_ITEM_RESULT_OK); + ClientServices::ClearMessageHandler(SMSG_READ_ITEM_RESULT_FAILED); + ClientServices::ClearMessageHandler(SMSG_CANCEL_COMBAT); + ClientServices::ClearMessageHandler(SMSG_TAXI_NODE_STATUS); + ClientServices::ClearMessageHandler(SMSG_SHOW_TAXI_NODES); + ClientServices::ClearMessageHandler(SMSG_ACTIVATE_TAXI_REPLY); + ClientServices::ClearMessageHandler(SMSG_GUILD_INVITE); + ClientServices::ClearMessageHandler(SMSG_GUILD_DECLINE); + ClientServices::ClearMessageHandler(SMSG_GUILD_INFO); + ClientServices::ClearMessageHandler(SMSG_GUILD_EVENT); + ClientServices::ClearMessageHandler(SMSG_GUILD_COMMAND_RESULT); + ClientServices::ClearMessageHandler(MSG_SAVE_GUILD_EMBLEM); + ClientServices::ClearMessageHandler(MSG_TABARDVENDOR_ACTIVATE); + ClientServices::ClearMessageHandler(SMSG_PETITION_SHOW_LIST); + ClientServices::ClearMessageHandler(SMSG_PETITION_SHOW_SIGNATURES); + ClientServices::ClearMessageHandler(SMSG_PETITION_SIGN_RESULTS); + ClientServices::ClearMessageHandler(MSG_PETITION_DECLINE); + ClientServices::ClearMessageHandler(SMSG_TURN_IN_PETITION_RESULT); + ClientServices::ClearMessageHandler(MSG_PETITION_RENAME); + ClientServices::ClearMessageHandler(SMSG_BIND_POINT_UPDATE); + ClientServices::ClearMessageHandler(SMSG_BINDZONEREPLY); + ClientServices::ClearMessageHandler(SMSG_EMOTE); + ClientServices::ClearMessageHandler(SMSG_PLAYER_BOUND); + ClientServices::ClearMessageHandler(SMSG_PLAYERBINDERROR); + ClientServices::ClearMessageHandler(SMSG_NEW_TAXI_PATH); + ClientServices::ClearMessageHandler(SMSG_PET_NAME_INVALID); + ClientServices::ClearMessageHandler(SMSG_EXPLORATION_EXPERIENCE); + ClientServices::ClearMessageHandler(SMSG_PARTY_MEMBER_STATS); + ClientServices::ClearMessageHandler(SMSG_PARTY_MEMBER_STATS_FULL); + ClientServices::ClearMessageHandler(SMSG_QUEST_UPDATE_FAILED); + ClientServices::ClearMessageHandler(SMSG_QUEST_UPDATE_FAILED_TIMER); + ClientServices::ClearMessageHandler(SMSG_QUEST_UPDATE_COMPLETE); + ClientServices::ClearMessageHandler(SMSG_QUEST_UPDATE_ADD_KILL); + ClientServices::ClearMessageHandler(SMSG_QUEST_UPDATE_ADD_PVP_CREDIT); + ClientServices::ClearMessageHandler(SMSG_QUEST_CONFIRM_ACCEPT); + ClientServices::ClearMessageHandler(SMSG_SHOW_BANK); + ClientServices::ClearMessageHandler(SMSG_BUY_BANK_SLOT_RESULT); + ClientServices::ClearMessageHandler(SMSG_LEVEL_UP_INFO); + ClientServices::ClearMessageHandler(MSG_MINIMAP_PING); + ClientServices::ClearMessageHandler(SMSG_TRIGGER_CINEMATIC); + ClientServices::ClearMessageHandler(SMSG_ITEM_TIME_UPDATE); + ClientServices::ClearMessageHandler(SMSG_ITEM_ENCHANT_TIME_UPDATE); + ClientServices::ClearMessageHandler(MSG_RANDOM_ROLL); + ClientServices::ClearMessageHandler(SMSG_FISH_NOT_HOOKED); + ClientServices::ClearMessageHandler(SMSG_FISH_ESCAPED); + ClientServices::ClearMessageHandler(SMSG_FORCEACTIONSHOW); + ClientServices::ClearMessageHandler(SMSG_GOD_MODE); + ClientServices::ClearMessageHandler(SMSG_PETGODMODE); + ClientServices::ClearMessageHandler(SMSG_IGNORE_REQUIREMENTS_CHEAT); + ClientServices::ClearMessageHandler(SMSG_IGNORE_DIMINISHING_RETURNS_CHEAT); + ClientServices::ClearMessageHandler(SMSG_CLEAR_FAR_SIGHT_IMMEDIATE); + ClientServices::ClearMessageHandler(SMSG_CHAT_WRONG_FACTION); + ClientServices::ClearMessageHandler(SMSG_CHAT_PLAYER_NOTFOUND); + ClientServices::ClearMessageHandler(SMSG_CHAT_RESTRICTED); + ClientServices::ClearMessageHandler(SMSG_CHAT_NOT_IN_PARTY); + ClientServices::ClearMessageHandler(SMSG_GM_TICKET_GET_SYSTEM_STATUS); + ClientServices::ClearMessageHandler(SMSG_SPIRIT_HEALER_CONFIRM); + ClientServices::ClearMessageHandler(MSG_TALENT_WIPE_CONFIRM); + ClientServices::ClearMessageHandler(SMSG_BINDER_CONFIRM); + ClientServices::ClearMessageHandler(SMSG_SPELL_EXECUTE_LOG); + ClientServices::ClearMessageHandler(SMSG_SPELL_MISS_LOG); + ClientServices::ClearMessageHandler(SMSG_SPELL_DAMAGE_SHIELD); + ClientServices::ClearMessageHandler(SMSG_SPELL_INSTAKILL_LOG); + ClientServices::ClearMessageHandler(SMSG_SPELL_NON_MELEE_DAMAGE_LOG); + ClientServices::ClearMessageHandler(SMSG_SPELL_HEAL_LOG); + ClientServices::ClearMessageHandler(SMSG_SPELL_ENERGIZE_LOG); + ClientServices::ClearMessageHandler(SMSG_SPELL_DISPELL_LOG); + ClientServices::ClearMessageHandler(SMSG_SPELL_STEAL_LOG); + ClientServices::ClearMessageHandler(SMSG_SPELL_BREAK_LOG); + ClientServices::ClearMessageHandler(SMSG_RESURRECT_FAILED); + ClientServices::ClearMessageHandler(SMSG_SPELL_OR_DAMAGE_IMMUNE); + ClientServices::ClearMessageHandler(MSG_QUEST_PUSH_RESULT); + ClientServices::ClearMessageHandler(SMSG_DAMAGE_CALC_LOG); + ClientServices::ClearMessageHandler(SMSG_RAID_GROUP_ONLY); + ClientServices::ClearMessageHandler(SMSG_INSTANCE_LOCK_WARNING_QUERY); + ClientServices::ClearMessageHandler(SMSG_LOOT_START_ROLL); + ClientServices::ClearMessageHandler(SMSG_LOOT_ALL_PASSED); + ClientServices::ClearMessageHandler(SMSG_LOOT_ROLL_WON); + ClientServices::ClearMessageHandler(SMSG_LOOT_ROLL); + ClientServices::ClearMessageHandler(SMSG_LOOT_MASTER_LIST); + ClientServices::ClearMessageHandler(SMSG_TEST_DROP_RATE_RESULT); + ClientServices::ClearMessageHandler(SMSG_SUMMON_REQUEST); + ClientServices::ClearMessageHandler(SMSG_SUMMON_CANCEL); + ClientServices::ClearMessageHandler(SMSG_PLAY_TIME_WARNING); + ClientServices::ClearMessageHandler(SMSG_ARENA_TEAM_INVITE); + ClientServices::ClearMessageHandler(SMSG_ARENA_TEAM_EVENT); + ClientServices::ClearMessageHandler(SMSG_ARENA_TEAM_COMMAND_RESULT); + ClientServices::ClearMessageHandler(SMSG_ARENA_ERROR); + ClientServices::ClearMessageHandler(SMSG_DEATH_RELEASE_LOC); + ClientServices::ClearMessageHandler(SMSG_FORCED_DEATH_UPDATE); + ClientServices::ClearMessageHandler(SMSG_TIME_SYNC_REQUEST); + ClientServices::ClearMessageHandler(SMSG_VOICE_SESSION_ROSTER_UPDATE); + ClientServices::ClearMessageHandler(SMSG_VOICE_SESSION_LEAVE); + ClientServices::ClearMessageHandler(SMSG_VOICE_SET_TALKER_MUTED); + ClientServices::ClearMessageHandler(SMSG_VOICE_PARENTAL_CONTROLS); + ClientServices::ClearMessageHandler(SMSG_CROSSED_INEBRIATION_THRESHOLD); + ClientServices::ClearMessageHandler(SMSG_COMPLAINT_RESULT); + ClientServices::ClearMessageHandler(SMSG_FEATURE_SYSTEM_STATUS); + ClientServices::ClearMessageHandler(SMSG_AVAILABLE_VOICE_CHANNEL); + ClientServices::ClearMessageHandler(SMSG_CALENDAR_COMMAND_RESULT); + ClientServices::ClearMessageHandler(SMSG_REPORT_PVP_AFK_RESULT); + ClientServices::ClearMessageHandler(SMSG_GROUP_ACTION_THROTTLED); + ClientServices::ClearMessageHandler(SMSG_SEND_UNLEARN_SPELLS); + ClientServices::ClearMessageHandler(SMSG_CONVERT_RUNE); + ClientServices::ClearMessageHandler(SMSG_RESYNC_RUNES); + ClientServices::ClearMessageHandler(SMSG_ADD_RUNE_POWER); + ClientServices::ClearMessageHandler(SMSG_BATTLEGROUND_INFO_THROTTLED); + ClientServices::ClearMessageHandler(SMSG_UPDATE_TALENT_DATA); + ClientServices::ClearMessageHandler(SMSG_ARENA_TEAM_CHANGE_FAILED_QUEUED); + ClientServices::ClearMessageHandler(SMSG_QUEST_POI_QUERY_RESPONSE); + ClientServices::ClearMessageHandler(SMSG_TOGGLE_XP_GAIN); + ClientServices::ClearMessageHandler(SMSG_DEBUG_SERVER_GEO); + ClientServices::ClearMessageHandler(SMSG_QUEST_FORCE_REMOVED); + ClientServices::ClearMessageHandler(SMSG_CAMERA_SHAKE); + ClientServices::ClearMessageHandler(SMSG_SOCKET_GEMS); + ClientServices::ClearMessageHandler(SMSG_COMBAT_LOG_MULTIPLE); +} + +// VERIFY: d10a2943 auto +// OFFSET: 0x006DB510 +bool CGPlayer_C::LoadGuildTextures(int32_t displayId) { + ItemDisplayInfoRec rec; + + if (!this->m_characterComponent || !g_itemDisplayInfoDB.GetRecordByIndex(displayId, &rec) || (this->m_characterComponent->m_flags & 0x40)) { + return false; + } + + this->m_characterComponent->AddItemBySlot(INVSLOT_TABARD, displayId, 0); + + if (rec.m_flags & 0x1) { + int32_t emblemStyle; + int32_t emblemColor; + int32_t borderStyle; + int32_t borderColor; + int32_t background; + + if (!GuildGetGuildTabard(this->m_obj->m_guid, this->m_player->m_playerGuildid, CGPlayer_C::TabardDrawCallback, this, emblemStyle, emblemColor, borderStyle, borderColor, background)) { + return false; + } + + this->m_characterComponent->ApplyGuildColor(emblemStyle, emblemColor, borderStyle, borderColor, background); + } + + return true; +} + +// VERIFY: e750e015 manual +// OFFSET: 0x006D92D0 +int32_t Packet_SMSG_GUILD_EVENT(void* param, NETMESSAGE msgId, uint32_t time, CDataStore* msg) { + uint8_t event = 0; + uint8_t numStrings; + char strings[3][1024]; + msg->Get(event); + msg->Get(numStrings); + + for (uint8_t i = 0; i < numStrings; i++) { + msg->GetString(strings[i], sizeof(strings[i])); + TruncateNewLines(strings[i]); + } + + UIErrors error; + WOWGUID guid; + + switch (event) { + case 0: + error = ERR_GUILD_PROMOTE_SSS; + break; + + case 1: + error = ERR_GUILD_DEMOTE_SSS; + break; + + case 2: + FrameScript_SignalEvent(SCRIPT_EVENT_GUILD_MOTD, "%s", strings[0]); + CGGuildInfo::SetMOTD(strings[0]); + UpdateGuildRoster(1); + return 1; + + case 3: + error = ERR_GUILD_JOIN_S; + msg->Get(guid.m_guid); + CGAutoCompleteName::AddFlags(guid, 34, 0, strings[0]); + break; + + case 4: + error = ERR_GUILD_LEAVE_S; + msg->Get(guid.m_guid); + CGAutoCompleteName::RemoveFlags(guid, 2); + break; + + case 5: + error = ERR_GUILD_REMOVE_SS; + CGAutoCompleteName::RemoveFlagsByName(strings[0], 2, 1, 0); + + if (!SStrCmpUTF8I(ClientServices::GetCharacterName(), strings[0], STORM_MAX_STR)) { + CGAutoCompleteName::RemoveFlagsFromAllNodes(2); + } + + break; + + case 6: + error = ERR_GUILD_LEADER_IS_S; + break; + + case 7: + error = ERR_GUILD_LEADER_CHANGED_SS; + break; + + case 8: + error = ERR_GUILD_DISBANDED; + CGAutoCompleteName::RemoveFlagsFromAllNodes(2); + CGGuildBankInfo::SetGuildBanker(WOWGUID()); + memset(CGGuildBankInfo::m_guildBankTabInfo, 0, sizeof(CGGuildBankInfo::m_guildBankTabInfo)); + break; + + case 10: { + CGPlayer_C* player = static_cast(ClntObjMgrObjectPtr(ClntObjMgrGetActivePlayer(), TYPEMASK_PLAYER, __FILE__, __LINE__)); + + if (!player) { + return 1; + } + + WOWGUID none = WOWGUID(); + GuildStats_C* stats = g_guildInfoCache.GetRecord(player->m_player->m_playerGuildid, none, nullptr, nullptr, false); + + if (!stats) { + return 1; + } + + uint32_t rank = SStrToInt(strings[0]); + char name[64]; + SStrCopy(name, strings[1], sizeof(name)); + ScrubString(name, stats->m_rankNames[rank], 16, sizeof(stats->m_rankNames[rank]), 1); + stats->m_numRanks = SStrToInt(strings[2]); + UpdateGuildRoster(1); + + if (player->m_player->m_playerGuildrank != rank) { + return 1; + } + + CGGuildInfo::QueryPermissions(); + + if (CGGuildBankInfo::m_banker == WOWGUID()) { + return 1; + } + + SendGuildBankQueryTabOpcode(CGGuildBankInfo::m_currentTab); + return 1; + } + + case 11: { + CGPlayer_C* player = static_cast(ClntObjMgrObjectPtr(ClntObjMgrGetActivePlayer(), TYPEMASK_PLAYER, __FILE__, __LINE__)); + + if (!player) { + return 1; + } + + WOWGUID none = WOWGUID(); + GuildStats_C* stats = g_guildInfoCache.GetRecord(player->m_player->m_playerGuildid, none, nullptr, nullptr, false); + + if (!stats) { + return 1; + } + + stats->m_numRanks = SStrToInt(strings[0]); + UpdateGuildRoster(1); + return 1; + } + + case 12: + msg->Get(guid.m_guid); + CGAutoCompleteName::AddFlags(guid, 32, 0, strings[0]); + + if (!g_guildMemberNotifyCVar->m_intValue || !SStrCmp(ClientServices::GetCharacterName(), strings[0], STORM_MAX_STR) || FriendList::s_friendList->IsFriend(guid)) { + return 1; + } + + CGGameUI::DisplayError(ERR_FRIEND_ONLINE_SS, strings[0], strings[0]); + return 1; + + case 13: + msg->Get(guid.m_guid); + CGAutoCompleteName::RemoveFlags(guid, 32); + + if (!g_guildMemberNotifyCVar->m_intValue || !SStrCmp(ClientServices::GetCharacterName(), strings[0], STORM_MAX_STR) || FriendList::s_friendList->IsFriend(guid)) { + return 1; + } + + CGGameUI::DisplayError(ERR_FRIEND_OFFLINE_S, strings[0]); + return 1; + + case 14: + SendGuildBankQueryTabOpcode(CGGuildBankInfo::m_currentTab); + FrameScript_SignalEvent(SCRIPT_EVENT_GUILDBANKBAGSLOTS_CHANGED, nullptr); + return 1; + + case 15: + CGGuildBankInfo::m_numTabs++; + FrameScript_SignalEvent(SCRIPT_EVENT_GUILDBANK_UPDATE_TABS, nullptr); + return 1; + + case 16: + CGGuildBankInfo::UpdateTabInfo(static_cast(SStrToInt(strings[0])), strings[1], strings[2]); + return 1; + + case 17: { + uint64_t money; + sscanf(strings[0], "%016I64X", &money); + CGGuildBankInfo::m_money = money; + CDataStore query; + query.Put(static_cast(MSG_GUILD_BANK_MONEY_WITHDRAWN)); + query.Finalize(); + ClientServices::Send2(&query); + FrameScript_SignalEvent(SCRIPT_EVENT_GUILDBANK_UPDATE_MONEY, nullptr); + return 1; + } + + case 18: { + SendGuildBankQueryTabOpcode(CGGuildBankInfo::m_currentTab); + CDataStore query; + query.Put(static_cast(MSG_GUILD_BANK_MONEY_WITHDRAWN)); + query.Finalize(); + ClientServices::Send2(&query); + return 1; + } + + case 19: { + int32_t tab = atol(strings[0]); + CGGuildBankInfo::SetTextUpdate(tab, 1); + FrameScript_SignalEvent(SCRIPT_EVENT_GUILDBANK_TEXT_CHANGED, "%d", tab + 1); + return 1; + } + + default: + error = ERR_GUILD_INTERNAL; + break; + } + + switch (numStrings) { + case 1: + CGGameUI::DisplayError(error, strings[0]); + break; + + case 2: + CGGameUI::DisplayError(error, strings[0], strings[1]); + break; + + case 3: + CGGameUI::DisplayError(error, strings[0], strings[1], strings[2]); + break; + + default: + CGGameUI::DisplayError(error); + break; + } + + UpdateGuildRoster(1); + return 1; +} + +// VERIFY: 4f7b81f9 manual +// OFFSET: 0x007261B0 +bool CGPlayer_C::IsInFlyableZone(int32_t checkContinent) { + return IsInFlyableArea() && (!(this->m_obj->m_type & TYPEMASK_PLAYER) || !checkContinent || CGGameUI::m_iCurrentMapID != 571 || HasSpell(static_cast(54197))); +} diff --git a/WoW/Source/Object/ObjectClient/Player_C.h b/WoW/Source/Object/ObjectClient/Player_C.h index 29a5553..e33d852 100644 --- a/WoW/Source/Object/ObjectClient/Player_C.h +++ b/WoW/Source/Object/ObjectClient/Player_C.h @@ -173,6 +173,7 @@ class CGPlayer_C : public CGUnit_C, public CGPlayer { static void __stdcall StartTaxiExpress(WOWGUID guid, const uint32_t* nodes, int32_t count); static void TalkToMailbox(WOWGUID guid); static void PlayerInitializeMessageHandlers(); + static void PlayerShutdownMessageHandlers(); static void __stdcall TalkToAuctioneer(const WOWGUID& guid); static void __stdcall TalkToBanker(const WOWGUID& guid); static void __stdcall TalkToBattleMaster(const WOWGUID& guid); @@ -287,6 +288,7 @@ class CGPlayer_C : public CGUnit_C, public CGPlayer { const CGItem_C* EquippedItemMeetSpellRequirements(const SpellRec* spell, uint32_t slotMask); int32_t HasZoneExplored(int32_t zone); int32_t UpdateUnitCollisionBox(int32_t a2, int32_t a3); + int32_t UpdateMountedCollisionBox(float mountHeight, int32_t force); int32_t IsCommentatorUberOrInArena() const; int32_t IsInMelee() const; void OnLootGameObject(const WOWGUID& guid); @@ -355,7 +357,7 @@ class CGPlayer_C : public CGUnit_C, public CGPlayer { void ExitAutoCombatMode(); void OnLevelChange(); void CTMClickTerrain(const C3Vector& position); - bool IsInFlyableZone(int32_t a1); + bool IsInFlyableZone(int32_t checkContinent); int32_t SpellUsesWeaponSkill(const SpellRec* spell); CGPlayer_C(uint32_t time, const CClientObjCreate& create); void PostInit(uint32_t time, const CClientObjCreate& create, bool reenable); @@ -373,7 +375,8 @@ class CGPlayer_C : public CGUnit_C, public CGPlayer { uint32_t GetEquippedItemDisplayId(); int32_t GetAttackPowerContributionFromStat(int32_t stat, int32_t value); float GetCombatRatingPct(int32_t rating); - void LoadGuildTextures(int32_t displayId); + bool LoadGuildTextures(int32_t displayId); + static void TabardDrawCallback(int32_t guildID, const WOWGUID& guid, void* param, bool success); void UpdateHandItemVisual(GEOCOMPONENTLINKS link, int32_t hand); void UpdateObjComponentVisuals(const VisibleItem_C* item, GEOCOMPONENTLINKS link); void UpdateObjComponentVisualsSlot(const VisibleItem_C* item, int32_t slot); @@ -531,6 +534,7 @@ void PlayerInitializeSounds(); void AreaTriggersInitialize(uint32_t mapId); int32_t AreaTriggerCheck(const void* data, void* param); void PlayerClientShutdown(); +void PlayerShutdownSounds(); int32_t Player_C_ZoneUpdateHandler(const void* data, void* param); int32_t GetModalNextSpell(); diff --git a/WoW/Source/Object/ObjectClient/SimpleScript.h b/WoW/Source/Object/ObjectClient/SimpleScript.h index 8616a4d..28c6c7e 100644 --- a/WoW/Source/Object/ObjectClient/SimpleScript.h +++ b/WoW/Source/Object/ObjectClient/SimpleScript.h @@ -28,6 +28,8 @@ struct SimpleScriptIO { /* 0010 */ uint32_t m_stringSize; /* 0014 */ uint32_t m_stringCount; /* 0018 */ char* m_strings; + + SimpleScriptIO(double* numbers, uint32_t count); }; class CSimpleScriptManager { @@ -56,4 +58,13 @@ class CSimpleScriptManager { void Uninit(); }; +// INLINED +inline SimpleScriptIO::SimpleScriptIO(double* numbers, uint32_t count) { + this->m_numbers.m_alloc = count; + this->m_numbers.m_data = numbers; + this->m_stringSize = 0; + this->m_stringCount = 0; + this->m_strings = nullptr; +} + #endif diff --git a/WoW/Source/Object/ObjectClient/UnitCombatLog_C.cpp b/WoW/Source/Object/ObjectClient/UnitCombatLog_C.cpp index d8b9467..ca8ad2d 100644 --- a/WoW/Source/Object/ObjectClient/UnitCombatLog_C.cpp +++ b/WoW/Source/Object/ObjectClient/UnitCombatLog_C.cpp @@ -2782,3 +2782,90 @@ void UnitCombatLogUnitDead(CGUnit_C* unit) { CombatLogEntry* entry = GetCombatLogEntry(source, dest, event, nullptr); QueueCombatLogEntry(entry, 0); } + +// VERIFY: a10e0f3b manual +// OFFSET: 0x0074D1A0 +static bool CombatLogFlagsMatch(uint32_t filterFlags, uint32_t flags) { + uint32_t matched = filterFlags & flags; + + if (matched & 0xFFFF0000) { + return true; + } + + if (!(matched & 0xF) || !(matched & 0xF0) || !(matched & 0x300)) { + return false; + } + + return (matched & 0xFC00) != 0; +} + +// VERIFY: e3b2fb68 manual +// OFFSET: 0x0074E1A0 +bool CombatLogFilter::MatchesFilter(int32_t event, const WOWGUID& sourceGuid, uint32_t sourceFlags, const WOWGUID& destGuid, uint32_t destFlags, int32_t spellId, const char* spellName) { + uint32_t index = static_cast(event); + + if (!(this->m_events.m_bits.m_data[index >> 5] & (1 << (index & 0x1F)))) { + return false; + } + + if (this->m_sourceGuid) { + if (sourceGuid != this->m_sourceGuid) { + return false; + } + } else { + uint32_t matched = this->m_sourceFlags & sourceFlags; + + if (!(matched & 0xFFFF0000) && (!(matched & 0xF) || !(matched & 0xF0) || !(matched & 0x300) || !(matched & 0xFC00))) { + return false; + } + } + + if (this->m_destGuid) { + if (destGuid != this->m_destGuid) { + return false; + } + } else if (!CombatLogFlagsMatch(this->m_destFlags, destFlags)) { + return false; + } + + if (this->m_spellId) { + return spellId == this->m_spellId; + } + + const char* name = this->m_spellName.m_str; + return !name || (spellName && !SStrCmpUTF8I(spellName, name, 0x7FFFFFFF)); +} + +// OFFSET: 0x00753980 +static void UnitCombatLogShutdown() { + s_entries.Clear(); + s_freeEntries.Clear(); + s_pendingEntries = nullptr; + s_currentEntry = nullptr; + s_filters.Clear(); + s_pendingData.Clear(); + s_freePendingData.Clear(); + s_invalidatedNames.Clear(); + ClientServices::ClearMessageHandler(SMSG_SPELL_PERIODIC_AURA_LOG); + ClientServices::ClearMessageHandler(SMSG_ENCHANTMENT_LOG); + ClientServices::ClearMessageHandler(SMSG_PARTY_KILL_LOG); + ClientServices::ClearMessageHandler(SMSG_PROC_RESIST); + ClientServices::ClearMessageHandler(SMSG_DISPEL_FAILED); + ClientServices::ClearMessageHandler(SMSG_DESTRUCTIBLE_BUILDING_DAMAGE); +} + +// VERIFY: 5d930252 auto +// OFFSET: 0x00754F60 +void UnitCombatClientShutdown() { + ClientServices::ClearMessageHandler(SMSG_ATTACK_START); + ClientServices::ClearMessageHandler(SMSG_ATTACK_STOP); + ClientServices::ClearMessageHandler(SMSG_ATTACKER_STATE_UPDATE); + ClientServices::ClearMessageHandler(SMSG_ATTACKSWING_NOTINRANGE); + ClientServices::ClearMessageHandler(SMSG_ATTACKSWING_BADFACING); + ClientServices::ClearMessageHandler(SMSG_ATTACKSWING_DEADTARGET); + ClientServices::ClearMessageHandler(SMSG_ATTACKSWING_CANT_ATTACK); + ClientServices::ClearMessageHandler(SMSG_ENVIRONMENTAL_DAMAGE_LOG); + ClientServices::ClearMessageHandler(SMSG_CLEAR_TARGET); + ClientServices::ClearMessageHandler(SMSG_COMBAT_EVENT_FAILED); + UnitCombatLogShutdown(); +} diff --git a/WoW/Source/Object/ObjectClient/UnitMissileTrajectory_C.cpp b/WoW/Source/Object/ObjectClient/UnitMissileTrajectory_C.cpp index 3804a4a..114011a 100644 --- a/WoW/Source/Object/ObjectClient/UnitMissileTrajectory_C.cpp +++ b/WoW/Source/Object/ObjectClient/UnitMissileTrajectory_C.cpp @@ -21,6 +21,15 @@ #include "Engine/Source/Tempest/CMath.h" #include "Engine/Source/Tempest/CAaSphere.h" #include "WoW/Source/ObjectMgrClient/ObjectMgrClient.h" +#include +#include +#include "Engine/Source/Gx/Gx.h" +#include "Engine/Source/Gx/CGxMatrixStack.h" +#include "Engine/Source/Tempest/CAaBox.h" +#include "WoW/Source/Game/GameClient/ProjectTex.h" +#include "WoW/Source/Ui/WorldFrame.h" +#include "WoW/Source/UIUtil/Camera.h" +#include "Engine/Source/Gx/CGxDevice/CGxDevice.h" // STATIC: 0x00CA0A98 CMapEntity* CGUnit_C::s_trajectoryWorldObjects[2]; @@ -34,6 +43,9 @@ static WOWGUID s_trajectoryTargetGuid; // STATIC: 0x00CA0AB8 static float s_trajectoryAlpha; +// STATIC: 0x00CA0ABC +static uint32_t s_trajectoryStartTime; + // STATIC: 0x00CA0AC0 static uint32_t s_trajectoryFadeStart; @@ -53,7 +65,7 @@ static CTexture* s_trajectoryTexture0; static CTexture* s_trajectoryTexture1; // STATIC: 0x00CA0AEC -static float s_trajectoryPitch; +static C3Vector s_trajectoryLaunchPosition; // STATIC: 0x00CA0AD8 CMissileCollisionHeap* CMissileCollision::s_pool; @@ -268,7 +280,7 @@ void CGUnit_C::UpdateMissileTrajectory() { } } -// VERIFY: 6a558a39 manual +// VERIFY: 890fca3b manual // OFFSET: 0x006FDA20 void CGUnit_C::UpdateMissileTrajectoryTargeting() { s_trajectoryAlpha = 0.0f; @@ -455,7 +467,7 @@ void CGUnit_C::UpdateMissileTrajectoryTargeting() { CGUnit_C* target = unit; float facing; - if (!unit->ComputeMissileTrajectory(&spell, &pitchArg, &target, &s_trajectoryPitch, &position, &facing, CGUnit_C::s_trajectoryPoints, &s_trajectoryPointCount, 1)) { + if (!unit->ComputeMissileTrajectory(&spell, &pitchArg, &target, &s_trajectoryLaunchPosition, &position, &facing, CGUnit_C::s_trajectoryPoints, &s_trajectoryPointCount, 1)) { s_trajectoryAlpha = 0.0f; return; } @@ -489,3 +501,167 @@ void CGUnit_C::UpdateMissileTrajectoryTargeting() { CGUnit_C::s_missileTrajectoryTargetingSpell = spellId; } + +// OFFSET: 0x006FC190 +void CGUnit_C::ShutdownMissileTrajectorySystem() { + SMemFree(CGUnit_C::s_trajectoryPoints, __FILE__, __LINE__, 0); + CGUnit_C::StopMissileTrajectoryTargeting(); + delete CMissileCollision::s_pool; + CMissileCollision::s_pool = nullptr; + CMissileCollision::s_tail = nullptr; + CMissileCollision::s_head = nullptr; +} + +// VERIFY: 2d5a7665 manual +// OFFSET: 0x006FDFB0 +void CGUnit_C::RenderMissileTrajectoryTargetingTexture() { + if (!(s_trajectoryAlpha > 0.0f) || !s_trajectoryTargetGuid) { + return; + } + + CGUnit_C* unit = static_cast(ClntObjMgrObjectPtr(s_trajectoryTargetGuid, TYPEMASK_UNIT, __FILE__, __LINE__)); + + if (!unit) { + s_trajectoryTargetGuid = WOWGUID(); + return; + } + + float facing = unit->GetFacing(); + VehicleRec* vehicle = unit->m_vehicle ? unit->m_vehicle->m_vehicleRec : nullptr; + + if (!vehicle) { + return; + } + + CGxTex* arcTex; + + if (s_trajectoryTexture0 && (arcTex = TextureGetGxTex(s_trajectoryTexture0, 0, nullptr)) != nullptr) { + g_theGxDevicePtr->RsPush(); + GxXformPush(GxXform_World); + GxXformPush(GxXform_Tex0); + GxXformTranslate(GxXform_World, -CGWorldFrame::GetActiveCamera()->m_position); + GxRsSet(GxRs_Culling, 0); + GxRsSet(GxRs_Fog, 0); + GxRsSet(GxRs_ColorOp0, 0); + GxRsSet(GxRs_AlphaOp0, 0); + GxRsSet(GxRs_ColorWrite, 15); + GxRsSet(GxRs_Lighting, 0); + GxRsSet(GxRs_DepthWrite, 0); + GxRsSet(GxRs_BlendingMode, 3); + int32_t vertexCount = 2 * s_trajectoryPointCount + 2; + C3Vector* positions = static_cast(alloca(sizeof(C3Vector) * vertexCount)); + CImVector* colors = static_cast(alloca(sizeof(CImVector) * vertexCount)); + C2Vector* texCoords = static_cast(alloca(sizeof(C2Vector) * vertexCount)); + uint16_t* indices = static_cast(alloca(sizeof(uint16_t) * vertexCount)); + + for (int32_t i = 0; i < vertexCount; i++) { + indices[i] = i; + } + + float halfWidth = vehicle->m_msslTrgtArcWidth * 0.5f; + C3Vector side; + side.x = -(CMath::sin_(facing) * halfWidth); + side.y = CMath::cos_(facing) * halfWidth; + uint32_t elapsed = FrameTime::s_curTimeMs - s_trajectoryStartTime; + float alpha = s_trajectoryAlpha * 255.0f; + float alphaStep = (255.0f * (s_trajectoryAlpha * vehicle->m_msslTrgtEndOpacity) - alpha) * (1.0f / s_trajectoryPointCount); + float texStart = 1.0f - fmodf(static_cast(elapsed) * 0.001f * vehicle->m_msslTrgtArcSpeed, 1.0f); + positions[0].x = s_trajectoryLaunchPosition.x + side.x; + positions[0].y = s_trajectoryLaunchPosition.y + side.y; + positions[0].z = s_trajectoryLaunchPosition.z; + positions[1].x = s_trajectoryLaunchPosition.x - side.x; + positions[1].y = s_trajectoryLaunchPosition.y - side.y; + positions[1].z = s_trajectoryLaunchPosition.z; + colors[0].a = 0; + colors[0].r = 0xFF; + colors[0].g = 0xFF; + colors[0].b = 0xFF; + colors[1] = colors[0]; + texCoords[0].x = texStart; + texCoords[0].y = 0.0f; + texCoords[1].x = texStart; + texCoords[1].y = 1.0f; + float pointAlpha = alphaStep + alpha; + float texCoord = texStart + vehicle->m_msslTrgtArcRepeat; + + for (uint32_t i = 0; i < s_trajectoryPointCount; i++) { + const C3Vector& point = CGUnit_C::s_trajectoryPoints[i]; + positions[2 * i + 2].x = point.x + side.x; + positions[2 * i + 2].y = point.y + side.y; + positions[2 * i + 2].z = point.z; + positions[2 * i + 3].x = point.x - side.x; + positions[2 * i + 3].y = point.y - side.y; + positions[2 * i + 3].z = point.z; + + if (pointAlpha < 0.0f) { + pointAlpha = 0.0f; + } + + colors[2 * i + 2].b = 0xFF; + colors[2 * i + 2].g = 0xFF; + colors[2 * i + 2].r = 0xFF; + colors[2 * i + 2].a = static_cast(pointAlpha + 0.5f); + colors[2 * i + 3] = colors[2 * i + 2]; + pointAlpha += alphaStep; + texCoords[2 * i + 2].x = texCoord; + texCoords[2 * i + 2].y = 0.0f; + texCoords[2 * i + 3].x = texCoord; + texCoords[2 * i + 3].y = 1.0f; + texCoord += vehicle->m_msslTrgtArcRepeat; + } + + CGxMatrixStack& texStack = g_theGxDevicePtr->m_xforms[GxXform_Tex0]; + texStack.m_dirty = 1; + texStack.m_flags[texStack.m_level] &= ~CGxMatrixStack::F_Identity; + texStack.m_mtx[texStack.m_level] = C44Matrix(); + g_theGxDevicePtr->RsSet(GxRs_Texture0, arcTex); + C3Vector normal(0.0f, 0.0f, 1.0f); + GxRsSet(GxRs_TextureShader0, 1); + GxPrimLockVertexPtrs(vertexCount, positions, sizeof(C3Vector), &normal, 0, colors, sizeof(CImVector), nullptr, 0, texCoords, sizeof(C2Vector), nullptr, 0); + GxDrawLockedElements(GxPrim_TriangleStrip, vertexCount, indices); + GxPrimUnlockVertexPtrs(); + GxXformPop(GxXform_World); + GxXformPop(GxXform_Tex0); + g_theGxDevicePtr->RsPop(); + } + + if (!s_trajectoryTexture1) { + return; + } + + CGxTex* impactTex = TextureGetGxTex(s_trajectoryTexture1, 0, nullptr); + + if (!impactTex) { + return; + } + + g_theGxDevicePtr->RsPush(); + GxRsSet(GxRs_BlendingMode, 3); + GxRsSet(GxRs_Culling, 0); + GxRsSet(GxRs_Lighting, 0); + GxRsSet(GxRs_DepthWrite, 0); + g_theGxDevicePtr->RsSet(GxRs_Texture0, impactTex); + g_theGxDevicePtr->RsSet(GxRs_Texture1, ProjectTex2dGetAddFadeTex()); + GxRsSet(GxRs_ColorOp0, 0); + GxRsSet(GxRs_AlphaOp0, 0); + GxRsSet(GxRs_ColorOp1, 0); + GxRsSet(GxRs_AlphaOp1, 0); + const C3Vector& impact = CGUnit_C::s_trajectoryPoints[s_trajectoryPointCount - 1]; + float radius = vehicle->m_msslTrgtImpactTexRadius; + CAaBox box; + box.b.x = impact.x - radius; + box.b.y = impact.y - radius; + box.b.z = impact.z - radius; + box.t.x = radius + impact.x; + box.t.y = radius + impact.y; + box.t.z = radius + impact.z; + CImVector color; + color.b = 0xFF; + color.g = 0xFF; + color.r = 0xFF; + color.a = static_cast(s_trajectoryAlpha * 255.0f + 0.5f); + C44Matrix rotation; + rotation.RotateAroundZ(-facing); + ProjectTex::Render2d(box, color, &rotation, 0.5f, 0x200122, 5, 0.039999999f); + g_theGxDevicePtr->RsPop(); +} diff --git a/WoW/Source/Object/ObjectClient/UnitVehicle_C.cpp b/WoW/Source/Object/ObjectClient/UnitVehicle_C.cpp index 783bdb8..93e88b0 100644 --- a/WoW/Source/Object/ObjectClient/UnitVehicle_C.cpp +++ b/WoW/Source/Object/ObjectClient/UnitVehicle_C.cpp @@ -9,6 +9,8 @@ #include "WoW/Source/UIUtil/InputControl.h" #include "Engine/Source/FrameScript/FrameScript.h" #include "WoW/Source/Ui/Types.h" +#include "WoW/Source/Ui/WorldFrame.h" +#include "WoW/Source/UIUtil/Camera.h" // VERIFY: bc21d620 manual // OFFSET: 0x0074C650 @@ -313,3 +315,25 @@ int32_t CGUnit_C::VehiclePassengerStartWaitingForVehicleTransitionAnim(uint64_t this->m_vehiclePassenger->StartWaitingForVehicleTransitionAnim(WOWGUID{ transport }, seat, seatRec, entering, animVehicle); return 1; } + +// VERIFY: 65e43ba1 manual +// OFFSET: 0x0074CD60 +void CGUnit_C::DestroyVehicleCamera() { + if (!this->m_vehicleCamera) { + return; + } + + CGUnit_C* unit = static_cast(ClntObjMgrObjectPtr(this->m_vehicleCamera->m_nextCameraGuid, TYPEMASK_UNIT, __FILE__, __LINE__)); + CVehicleCamera_C* camera = this->m_vehicleCamera; + camera->Destroy(); + this->m_vehicleCamera = nullptr; + CGCamera* activeCamera = CGWorldFrame::GetActiveCamera(); + + if (activeCamera && activeCamera->m_vehicleCamera == camera) { + activeCamera->OnVehicleCameraDestroyed(); + } + + if (unit) { + unit->OnVehicleCameraPossiblyUnneeded(); + } +} diff --git a/WoW/Source/Object/ObjectClient/Unit_C.cpp b/WoW/Source/Object/ObjectClient/Unit_C.cpp index ec73e61..f25555c 100644 --- a/WoW/Source/Object/ObjectClient/Unit_C.cpp +++ b/WoW/Source/Object/ObjectClient/Unit_C.cpp @@ -131,6 +131,11 @@ #include "WoW/Source/DB/Rec/MapRec.h" #include "Engine/Source/Frame/CLayoutFrame.h" #include "WoW/Source/DB/Rec/VehicleRec.h" +#include "WoW/Source/DB/Rec/TerrainTypeRec.h" +#include "WoW/Source/DB/Rec/UnitBloodRec.h" + +// STATIC: 0x00ADAC04 +static INVENTORY_SLOTS s_virtualItemInvSlots[2] = { INVSLOT_MAINHAND, INVSLOT_OFFHAND }; // STATIC: 0x00CA1398 static char s_objectNameBuffers[2][305]; @@ -141,6 +146,9 @@ static uint32_t s_objectNameIndex; // STATIC: 0x00ADAA10 static int32_t s_baseSpiritRegenCap = 50; +// STATIC: 0x00ADAA14 +static const char* s_genderSuffix[2] = { "M", "F" }; + // STATIC: 0x00CA11A8 static WOWGUID s_unk_CA11A8; @@ -5809,6 +5817,43 @@ void CGUnit_C::RemoveMountModel() { } } +// VERIFY: 472acfa3 auto +// OFFSET: 0x00717910 +void CGUnit_C::SetMountModel(CM2Model* model) { + if (model == this->m_mountModel) { + return; + } + + this->CleanUpVehicleBoneAnimsBeforeObjectModelChange(); + + if (model) { + model->m_refCount++; + } + + if (this->m_mountModel) { + if (this->m_mountModel->m_attachParent) { + this->m_mountModel->DetachFromParent(); + } + + this->m_mountModel->SetLoadedCallback(nullptr, nullptr); + this->m_mountModel->Release(); + } + + this->m_mountModel = model; + + if (model) { + model->SetLoadedCallback(CGObject_C::ModelLoadedCallback, this); + } else if (this->GetObjectModel()->IsLoaded(0, 0)) { + this->ModelChanged(); + } else { + this->SetBoundsDirty(); + } + + if (this->m_worldObject) { + World::ObjectSetModel(this->m_worldObject, this->GetObjectModel()); + } +} + // VERIFY: 615d1384 auto // OFFSET: 0x00715270 void CGUnit_C::RotateFacing(float delta) { @@ -22190,3 +22235,743 @@ float CreatureSoundDataGetFidgetDelayMax(const CreatureSoundDataRec* rec) { return 0.0f; } + +// VERIFY: b7b739bd manual +// OFFSET: 0x0071D450 +static int32_t IsWeaponAnimBehavior(uint32_t animId) { + AnimationDataRec* animation = g_animationDataDB.GetRecord(animId); + int32_t behavior = animation ? animation->m_behaviorID : 506; + + switch (behavior) { + case 16: + case 20: + case 25: + case 117: + case 118: + return 1; + + default: + return 0; + } +} + +// VERIFY: 8ff14a38 auto +// OFFSET: 0x00721ED0 +bool CGUnit_C::IsPlayingWeaponAnim() const { + uint32_t sequence; + + if (this->m_worldModel && this->m_worldModel->IsLoaded(0, 0)) { + if (this->m_torsoKeyBone == -1 || (sequence = this->m_worldModel->GetBoneSequenceId(this->m_torsoKeyBone)) == 0xFFFFFFFF) { + sequence = this->m_worldModel->GetBoneSequenceId(0xFFFFFFFF); + } + } else { + sequence = 0xFFFFFFFF; + } + + if (IsWeaponAnimBehavior(sequence)) { + return true; + } + + return IsMeleeAttackAnim(sequence) && !this->GetVirtualItem(0, false); +} + +// VERIFY: 697b8b23 manual +// OFFSET: 0x0071EE70 +void CGUnit_C::Unk71EE70() { + if (this->m_obj->m_guid != CGGameUI::m_lockedTarget) { + return; + } + + CGPlayer_C* player = static_cast(ClntObjMgrObjectPtr(ClntObjMgrGetActivePlayer(), TYPEMASK_PLAYER, __FILE__, __LINE__)); + + if (player && player->m_combat.m_attacking) { + player->SetCombatMode(); + } + + Spell_C_CancelAutoRepeat(true); + + if (this->m_unit->m_unitDynamicFlags & 0x20) { + WOWGUID guid = this->m_obj->m_guid; + + if (CGGameUI::IsRaidMemberOrPet(guid)) { + return; + } + } + + CGGameUI::Target(WOWGUID()); +} + +// VERIFY: bed80791 manual +// OFFSET: 0x0071B1E0 +void CGUnit_C::HandlePendingTrackEvents() { + if (s_unk_CA11C8) { + if (ClntObjMgrObjectPtr(s_unk_CA11C8, TYPEMASK_UNIT, __FILE__, __LINE__) && this->m_obj->m_guid == ClntObjMgrGetActivePlayer()) { + static_cast(this)->CombatModeEnter(s_unk_CA11C8, 0, 0); + } + + s_unk_CA11C8 = WOWGUID(); + } else if (s_unk_CA11C0) { + CGUnit_C* unit = static_cast(ClntObjMgrObjectPtr(s_unk_CA11C0, TYPEMASK_UNIT, __FILE__, __LINE__)); + + if (unit && this->m_obj->m_guid == ClntObjMgrGetActivePlayer()) { + static_cast(this)->LootUnit(unit, false); + } + + s_unk_CA11C0 = WOWGUID(); + } else if (s_unk_CA11B8) { + CGGameObject_C* gameObject = static_cast(ClntObjMgrObjectPtr(s_unk_CA11B8, TYPEMASK_GAMEOBJECT, __FILE__, __LINE__)); + + if (gameObject) { + gameObject->UseObject(); + } + + s_unk_CA11B8 = WOWGUID(); + } else if (s_unk_CA11B0) { + CGUnit_C* unit = static_cast(ClntObjMgrObjectPtr(s_unk_CA11B0, TYPEMASK_OBJECT, __FILE__, __LINE__)); + + if (unit && this->IsActivePlayer()) { + static_cast(this)->HandleSkinning(unit, false, false); + } + + s_unk_CA11B0 = WOWGUID(); + } else if (s_unk_CA11A8) { + CGUnit_C* unit = static_cast(ClntObjMgrObjectPtr(s_unk_CA11A8, TYPEMASK_UNIT, __FILE__, __LINE__)); + + if (unit && this->IsActivePlayer()) { + static_cast(this)->HandleOnRightClick(unit, false); + } + + s_unk_CA11A8 = WOWGUID(); + } +} + +// VERIFY: ca6629ea manual +// OFFSET: 0x0073D940 +void CGUnit_C::DestroyUnitMount(int32_t a2) { + if (!this->m_mountModel) { + return; + } + + CM2Model* parent = this->m_worldModel->m_attachParent; + + if (parent) { + CM2Model* grandParent = parent->m_attachParent; + uint32_t attachmentId = parent->m_attachmentId; + this->m_worldModel->m_fFlags ^= (this->m_worldModel->m_fFlags ^ parent->m_fFlags) & 0x80000; + this->m_worldModel->DetachFromParent(); + + if (grandParent) { + this->m_worldModel->AttachToParent(grandParent, attachmentId, nullptr, 0); + } + } + + CM2Model* mount = this->m_mountModel; + this->m_worldModel->unk_0180 = mount->unk_0180; + this->m_worldModel->unk_0184 = mount->unk_0184; + this->m_worldModel->unk_0188 = mount->unk_0188; + this->SetMountModel(nullptr); + this->SetKeyBoneSequence(this->m_worldModel, 0xFFFFFFFF, 0, 0xFFFFFFFF, 0, 1.0f, 0, 1, 0); + this->m_animationState &= 0xFF77DFFB; + this->UpdateBaseAnimation(0, -1); + this->UpdateSelectionRadius(); + this->UpdateEffectAttachments(); + this->m_soundDataOverride = nullptr; + + if (this->m_obj->m_guid == CGWorldFrame::GetActiveCamera()->m_targetGUID) { + CGGameUI::ResetCamera(this->m_obj->m_guid); + } + + this->PlayDismountSound(); + + if (a2) { + this->UpdateUnitCollisionBox(1, 0); + } + + if (this->GetObjectModel()->IsLoaded(0, 0)) { + this->InitWheels(); + } else { + this->m_wheelMask = 0; + } + + this->UpdateObjectEffectAnimationStates(); + this->m_clientFlags &= ~0x10000000; +} + +// VERIFY: 0ebfdfad manual +// OFFSET: 0x0073D5D0 +void CGUnit_C::CreateUnitMount(int32_t a2, int32_t a3) { + this->m_wheelMask = 0; + + if (!this->m_mountModel) { + CreatureDisplayInfoRec* displayInfo = g_creatureDisplayInfoDB.GetRecord(this->m_mountDisplayId); + + if (!displayInfo) { + return; + } + + CreatureModelDataRec* modelData = g_creatureModelDataDB.GetRecord(displayInfo->m_modelID); + + if (!modelData) { + return; + } + + this->m_mountScale = displayInfo->m_creatureModelScale; + CM2Model* mount = World::s_m2Scene->CreateModel(modelData->m_modelName, 0); + mount->SetSequenceCallback(reinterpret_cast(&CGUnit_C::MountAnimEndCallback), this->m_obj->m_guid.m_guid); + mount->SetEventCallback(reinterpret_cast(&CGUnit_C::AnimEventCallback), this->m_obj->m_guid.m_guid); + C44Matrix transform = this->m_worldModel->m_worldTransform; + mount->m_fFlags |= 0x8000; + mount->m_worldTransform = transform; + CCharacterComponent::ApplyMonsterGeosets(mount, displayInfo); + CCharacterComponent::ReplaceMonsterSkin(mount, displayInfo, modelData); + this->SetMountModel(mount); + mount->Release(); + this->m_mountFootprintTextureId = modelData->m_footprintTextureID; + this->m_mountFootprintLength = modelData->m_footprintTextureWidth * 0.027777778f; + this->m_mountFootprintWidth = 0.027777778f * modelData->m_footprintTextureLength; + this->m_soundDataOverride = this->GetMountSoundDataRec(); + this->m_mountModel->m_fFlags ^= (this->m_mountModel->m_fFlags ^ this->m_worldModel->m_fFlags) & 0x80000; + this->m_worldModel->m_fFlags &= ~0x80000; + CM2Model* parent = this->m_worldModel->m_attachParent; + uint32_t attachmentId = this->m_worldModel->m_attachmentId; + + if (parent) { + this->m_worldModel->DetachFromParent(); + } + + this->m_worldModel->AttachToParent(this->m_mountModel, 0, nullptr, 0); + + if (parent) { + this->m_mountModel->AttachToParent(parent, attachmentId, nullptr, 0); + } + + this->SetKeyBoneSequence(this->m_worldModel, 0xFFFFFFFF, this->m_mountAnimBehaviorId, 0xFFFFFFFF, 0, 1.0f, 1, 1, 0); + C44Matrix scale(1.0f / this->m_mountScale); + this->m_worldModel->m_fFlags |= 0x8000; + this->m_worldModel->m_worldTransform = scale; + mount->unk_0180 = this->m_worldModel->unk_0180; + mount->unk_0184 = this->m_worldModel->unk_0184; + mount->unk_0188 = this->m_worldModel->unk_0188; + this->m_worldModel->m_fadeAlpha = 1.0f; + this->m_worldModel->unk_0180 = 1.0f; + this->m_worldModel->unk_0184 = 1.0f; + this->m_worldModel->unk_0188 = 1.0f; + this->m_worldModel->unk_018C = 0.0f; + this->m_worldModel->unk_0190 = 0.0f; + this->m_worldModel->unk_0194 = 0.0f; + + if ((this->m_obj->m_type & TYPEMASK_PLAYER) && a3 && !static_cast(this)->UpdateMountedCollisionBox(modelData->m_mountHeight, a2)) { + this->Dismount(); + } + } + + CEffect* effect = this->m_mountTransitionEffect; + + if (effect && !(effect->m_flags & 0x100)) { + effect->MoveToDestroyList(); + } + + this->m_animationState |= 0x10; + this->UpdateBaseAnimation(0, -1); + + if (this->m_obj->m_guid == CGWorldFrame::GetActiveCamera()->m_targetGUID) { + CGGameUI::ResetCamera(this->m_obj->m_guid); + } + + this->UpdateObjectEffectAnimationStates(); +} + +// VERIFY: e8fc52d0 manual +// OFFSET: 0x0073C140 +void CGUnit_C::MountAnimEndCallback(CM2Model* model, uint32_t boneId, uint32_t sequenceId, int32_t interrupted, uint32_t time, uint64_t param) { + CGUnit_C* unit = static_cast(ClntObjMgrObjectPtr(WOWGUID{ param }, TYPEMASK_UNIT, __FILE__, __LINE__)); + + if (!unit) { + return; + } + + if (unit->m_mountModel && unit->m_vehicle && unit->m_vehicle->m_vehicleRec && unit->m_vehicle->IsBoneAnimPlaying(boneId)) { + unit->m_vehicle->BoneAnimEndHandler(model, boneId, sequenceId, interrupted, time); + } else { + unit->MountAnimEndHandler(model, boneId, sequenceId, interrupted, time); + } +} + +// VERIFY: 3001c8a3 auto +// OFFSET: 0x0073BFF0 +void CGUnit_C::MountAnimEndHandler(CM2Model* model, uint32_t boneId, uint32_t sequenceId, int32_t interrupted, uint32_t time) { + if (this->m_awaitingEndAnimId == static_cast(sequenceId)) { + this->m_awaitingEndAnimId = -1; + } + + if (sequenceId == 192 || sequenceId == 200) { + this->m_animationState &= ~0x40000; + } + + if (sequenceId == 121) { + this->m_animationState &= ~0x80000; + } else if (sequenceId == 37) { + this->m_animationState &= ~0x800000; + } + + if (interrupted) { + if (sequenceId == 39 || sequenceId == 187) { + this->m_animationState &= ~0x4; + } + + return; + } + + this->m_animationState = (this->m_animationState & ~0x60) | 0x10; + this->OnBaseAnimEnd(model, boneId, sequenceId); + this->m_animationState |= 0x70; +} + +// VERIFY: 381b5889 manual +// OFFSET: 0x00724EA0 +void CGUnit_C::PostShutdown() { + CMissile::Destroy(); + CGNamePlateFrame* plate = s_unusedNamePlates.Head(); + + while (!s_unusedNamePlates.IsEnd(plate)) { + CGNamePlateFrame* next = s_unusedNamePlates.RawNext(plate); + s_unusedNamePlates.UnlinkNode(plate); + delete plate; + plate = next; + } + + CGUnit_C::s_lastNPCSoundGUID = WOWGUID(); + CVehicle_C::UninitSystem(); + CVehiclePassenger_C::UninitSystem(); + CVehicleCamera_C::UninitSystem(); + CGUnit_C::ShutdownMissileTrajectorySystem(); +} + +// VERIFY: dc577adb manual +// OFFSET: 0x00723A50 +void CGUnit_C::FootstepAnimEventHit(const C3Vector* position, int32_t left) { + if (this->m_unit->m_unitFieldPetnumber || (this->m_movement->m_flags & 0x40000000) || (this->m_unit->m_unitFieldBytes1[2] & 0x2) || this->GetTransportGUID()) { + return; + } + + if ((this->m_obj->m_type & TYPEMASK_PLAYER) && (static_cast(this)->m_player->m_playerFlags & 0x10)) { + return; + } + + const C3Vector& cameraPos = CGWorldFrame::GetActiveCamera()->m_position; + float dx = position->x - cameraPos.x; + float dy = position->y - cameraPos.y; + float dz = position->z - cameraPos.z; + float distanceSquared = dx * dx + (dy * dy + dz * dz); + + if (distanceSquared > 2500.0f) { + return; + } + + if ((CWorld::enables & 0x400) && !(this->m_modelData->m_flags & 0x20)) { + float size[2]; + size[0] = 0.0f; + size[1] = 0.0f; + int32_t textureId; + this->GetFootprintInfo(&textureId, size); + WOWGUID guid = this->m_obj->m_guid; + int32_t activePlayer = guid == ClntObjMgrGetActivePlayer() ? 1 : 0; + World::NewFootprint(textureId, size, position, this->GetFacing(), left == 0, this->m_terrainTypeId, activePlayer); + } + + if (this->m_modelData->m_footstepShakeSize) { + CGWorldFrame::GetActiveCamera()->AddShakeById(this->m_modelData->m_footstepShakeSize, position); + } + + if (distanceSquared > 625.0f || (this->m_movement->m_flags & 0x2) || (this->m_modelData->m_flags & 0x1) || !CGUnit_C::s_cvShowFootPrintParticles->m_intValue) { + return; + } + + int32_t liquidType; + float liquidHeight; + int32_t liquidFlags; + + if (World::QueryObjectLiquid(this->m_worldObject, &liquidType, &liquidHeight, &liquidFlags)) { + int32_t flag8; + int32_t flag9; + World::QueryObjectLiquidFlags(this->m_worldObject, &flag8, &flag9); + + if (!flag9) { + return; + } + + float depth = liquidHeight - this->GetPosition().z; + + if (this->m_movementData.m_collisionHeight * 0.5f <= depth) { + return; + } + + C3Vector splash; + splash.x = position->x; + splash.y = position->y; + splash.z = depth + position->z; + CEffect* effect = new (SMemAlloc(sizeof(CEffect), __FILE__, __LINE__, 0)) CEffect(); + WOWGUID owner = this->m_obj->m_guid; + effect->AddSpecialByPosition(!this->IsRunning(), splash, &owner, 0x220, CGObject_C::EffectOnceHandler); + effect->Release(); + return; + } + + TerrainTypeRec* terrain = g_terrainTypeDB.GetRecord(this->m_terrainTypeId); + + if (!terrain) { + return; + } + + SpellVisualEffectNameRec* effectName = g_spellVisualEffectNameDB.GetRecord(this->IsRunning() ? terrain->m_footstepSprayWalk : terrain->m_footstepSprayRun); + + if (!effectName) { + return; + } + + C3Vector effectPosition = *position; + + if (this->GetTransportGUID()) { + C44Matrix transport; + MovementGetTransportMtxX(WOWGUID{ this->GetTransportGUID() }, &transport, this->m_obj->m_guid, __FILE__, __LINE__); + effectPosition *= transport.AffineInverse(); + } + + CEffect* effect = new (SMemAlloc(sizeof(CEffect), __FILE__, __LINE__, 0)) CEffect(); + WOWGUID owner = this->m_obj->m_guid; + effect->InitFromUnit(effectPosition, OsGetAsyncTimeMs(), 0, nullptr, effectName, &owner, 0x220, CGObject_C::EffectOnceHandler, 0, nullptr, WOWGUID{ this->GetTransportGUID() }); + effect->Release(); +} + +// VERIFY: 5b00631f auto +// OFFSET: 0x007555E0 +void CGUnit_C::ShakeCameraOnHit() { + if (this->m_unit->m_unitFieldPetnumber) { + return; + } + + int32_t shakeId = this->m_modelData->m_deathThudShakeSize; + + if (shakeId) { + C3Vector position = this->GetPosition(); + CGWorldFrame::GetActiveCamera()->AddShakeById(shakeId, &position); + } +} + +// VERIFY: 9e04967c manual +// OFFSET: 0x0071DCC0 +int32_t IsSpecialIdleAnim(uint32_t animId) { + if (IsSpellCastAnim(animId)) { + return 1; + } + + AnimationDataRec* rec = g_animationDataDB.GetRecord(animId); + + if (rec && rec->m_behaviorID == 107) { + return 1; + } + + rec = g_animationDataDB.GetRecord(animId); + + if (rec && rec->m_behaviorID == 46) { + return 1; + } + + return GetAnimBehaviorId(animId) == 49; +} + +// VERIFY: 597f8f44 manual +// OFFSET: 0x0072CDE0 +void CreatureQueryCallback(int32_t id, const WOWGUID& guid, void* param, bool success) { + CreatureStats_C* stats = g_creatureDBCache.GetRecord(id, WOWGUID(), nullptr, nullptr, false); + + if (!stats) { + return; + } + + CGUnit_C* unit = static_cast(ClntObjMgrObjectPtr(guid, TYPEMASK_UNIT, __FILE__, __LINE__)); + + if (unit) { + unit->DestroyNamePlate(); + unit->m_creatureCacheEntry = stats; + + if (stats->m_family) { + unit->UpdateModelScale(nullptr); + } + + unit->UpdateUnitCollisionBox(1, 0); + } + + CGGameUI::UnitNameUpdate(guid); + Script_SendUnitSignal(guid, SCRIPT_EVENT_UNIT_CLASSIFICATION_CHANGED); + TotemInfo* totem = CGGameUI::GetTotemInfo(guid); + + if (totem) { + totem->m_name = unit->GetUnitName(nullptr, 1); + FrameScript_SignalEvent(SCRIPT_EVENT_PLAYER_TOTEM_UPDATE, "%d", totem->m_slot + 1); + } +} + +// VERIFY: 4078ec8f manual +// OFFSET: 0x00755380 +void CGUnit_C::ShowBloodSpurt(const WOWGUID& attacker, int32_t a3) { + UnitBloodRec* blood = this->GetBloodRecord(); + + if (!blood) { + return; + } + + int32_t attachType = 15; + CGUnit_C* attackerUnit = static_cast(ClntObjMgrObjectPtr(attacker, TYPEMASK_UNIT, __FILE__, __LINE__)); + + if (attackerUnit) { + C3Vector position = this->GetPosition(); + C3Vector attackerPosition = attackerUnit->GetPosition(); + float dx = attackerPosition.x - position.x; + float dy = attackerPosition.y - position.y; + float facing = this->CGUnit_C::GetRenderFacing(); + float cosFacing = cosf(facing); + float sinFacing = sinf(facing); + + if (dy * sinFacing + dx * cosFacing < 0.0f) { + attachType = 16; + } + } + + int32_t effectId = attachType == 15 ? blood->m_combatBloodSpurtFront[a3 != 0] : blood->m_combatBloodSpurtBack[a3 != 0]; + SpellVisualEffectNameRec* effectName = g_spellVisualEffectNameDB.GetRecord(effectId); + + if (!effectName) { + return; + } + + CEffect* effect = new (SMemAlloc(sizeof(CEffect), __FILE__, __LINE__, 0)) CEffect(); + WOWGUID source = this->m_obj->m_guid; + effect->AddEffect(attachType, 0, nullptr, effectName, &attacker, &source, 0x20, CGObject_C::EffectOnceHandler, nullptr, 0, nullptr); + effect->Release(); +} + +// VERIFY: 8ffb4576 manual +// OFFSET: 0x00720BF0 +int32_t CGUnit_C::OverrideMissileFirePos(C3Vector* position, const SpellRec* spell) { + if (!this->m_worldModel || !this->m_worldModel->IsLoaded(0, 0)) { + return 0; + } + + const SpellVisualRec* visual = GetSpellVisual(spell); + + if (!visual) { + return 0; + } + + C3Vector offset; + + if (visual->m_missileAttachment == -1) { + if (0.0f == visual->m_missileCastOffset[0] && 0.0f == visual->m_missileCastOffset[1] && 0.0f == visual->m_missileCastOffset[2]) { + return 0; + } + + CM2Model* model = this->m_worldModel; + + if (model && model->IsLoaded(0, 0) && model->HasAttachment(s_effectAttachmentIds[12])) { + offset.x = visual->m_missileCastOffset[0]; + offset.y = -visual->m_missileCastOffset[1]; + offset.z = visual->m_missileCastOffset[2]; + *position = this->GetAttachmentPosition(s_effectAttachmentIds[12], &offset); + return 1; + } + + C44Matrix matrix = this->GetModelMatrix(); + matrix.d0 = 0.0f; + matrix.d1 = 0.0f; + matrix.d2 = 0.0f; + offset.x = visual->m_missileCastOffset[0]; + offset.y = -visual->m_missileCastOffset[1]; + offset.z = visual->m_missileCastOffset[2]; + C3Vector rotated = offset * matrix; + *position = this->GetModelPosition() + rotated; + return 1; + } + + int32_t raw = visual->m_flags & 0x200; + + if (!this->HasAttachmentForEffect(visual->m_missileAttachment, raw)) { + return 0; + } + + offset.x = visual->m_missileCastOffset[0]; + offset.y = -visual->m_missileCastOffset[1]; + offset.z = visual->m_missileCastOffset[2]; + *position = this->GetAttachmentPositionForEffect(visual->m_missileAttachment, offset, raw); + return 1; +} + +// VERIFY: 228a87fd manual +// OFFSET: 0x00732100 +CM2Model* CGUnit_C::CreateItemModel(uint32_t displayId, uint32_t inventoryType, float* scale) { + if (scale) { + *scale = 1.0f; + } + + const char* path; + + switch (inventoryType) { + case 1: + path = "Item\ObjectComponents\Head\\"; + break; + case 3: + path = "Item\ObjectComponents\Shoulder\\"; + break; + case 14: + path = "Item\ObjectComponents\Shield\\"; + break; + case 24: + path = "Item\ObjectComponents\Ammo\\"; + break; + case 27: + path = "Item\ObjectComponents\Quiver\\"; + break; + default: + path = "Item\ObjectComponents\Weapon\\"; + break; + } + + ItemDisplayInfoRec rec; + + if (!g_itemDisplayInfoDB.GetRecordByIndex(displayId, &rec)) { + return nullptr; + } + + uint32_t index; + + if (*rec.m_modelName[0]) { + index = 0; + } else if (*rec.m_modelName[1]) { + index = 1; + } else { + return nullptr; + } + + char fileName[260]; + + if (inventoryType == 1) { + int32_t sex = this->m_displayInfoExtra ? this->m_displayInfoExtra->m_displaySexID : this->m_unit->m_unitFieldBytes0[2]; + ChrRacesRec* race = g_chrRacesDB.GetRecord(sex); + + if (!race) { + return nullptr; + } + + SStrPrintf(fileName, sizeof(fileName), "%s%s_%s%s.mdx", path, rec.m_modelName[index], race->m_clientPrefix, s_genderSuffix[sex]); + } else { + SStrPrintf(fileName, sizeof(fileName), "%s%s", path, rec.m_modelName[index]); + } + + CM2Model* model = World::s_m2Scene->CreateModel(fileName, 0); + + if (!model) { + return nullptr; + } + + if (*rec.m_modelTexture[index]) { + SStrPrintf(fileName, sizeof(fileName), "%s%s", path, rec.m_modelTexture[index]); + CStatus status; + CTexture* texture = CreateTexture(fileName, &status); + + if (texture) { + model->ReplaceTexture(2, texture); + HandleClose(reinterpret_cast(texture)); + } + } + + CCharacterComponent::ComponentUtilAddItemVisual(model, rec.m_itemVisual); + CM2Model* worldModel = this->m_worldModel; + + if (scale && worldModel && worldModel->IsLoaded(0, 0)) { + uint32_t attachId; + + switch (inventoryType) { + case 1: + attachId = 11; + break; + case 14: + attachId = 0; + break; + case 22: + attachId = 2; + break; + case 24: + case 25: + attachId = 0xFFFFFFFF; + break; + default: + attachId = 1; + break; + } + + if (worldModel->HasAttachment(attachId)) { + C44Matrix transform = worldModel->GetAttachmentWorldTransform(attachId); + *scale = sqrtf(transform.a1 * transform.a1 + transform.a2 * transform.a2 + transform.a0 * transform.a0); + } + } + + return model; +} + +// VERIFY: 0a6c1295 auto +// OFFSET: 0x00719FF0 +UnitBloodRec* CGUnit_C::GetBloodRecord() { + if (!this->m_bloodlevels) { + return nullptr; + } + + return g_unitBloodDB.GetRecord(this->m_bloodlevels->m_violencelevel[ViolenceGetLevel()]); +} + +// VERIFY: ce51319d auto +// OFFSET: 0x00725010 +void CGUnit_C::OnVirtualItemChanged(uint32_t slot, int32_t oldItemId) { + ItemRec* oldRec = g_itemDB.GetRecord(oldItemId); + ItemRec* rec = g_itemDB.GetRecord(this->m_unit->m_unitVirtualItemSlotId[slot]); + this->m_virtualItemDisplayId[slot] = rec ? rec->m_displayInfoID : 0; + CGUnitVirtualItem item; + item.m_pad[0] = 0; + item.m_pad[1] = 0; + + if (rec) { + item.m_classID = static_cast(rec->m_classID); + item.m_subclassID = static_cast(rec->m_subclassID); + item.m_soundOverrideSubclassID = static_cast(rec->m_soundOverrideSubclassID); + item.m_material = static_cast(rec->m_material); + item.m_inventoryType = static_cast(rec->m_inventoryType); + item.m_sheatheType = static_cast(rec->m_sheatheType); + } else { + item.m_classID = 0; + item.m_subclassID = 0; + item.m_soundOverrideSubclassID = 0; + item.m_material = 0; + item.m_inventoryType = 0; + item.m_sheatheType = 0; + } + + this->m_virtualItem[slot] = item; + SHEATHE_TYPE sheatheType = static_cast(oldRec ? oldRec->m_sheatheType : 0); + CCharacterComponent::RemoveHandItem(this->m_worldModel, s_virtualItemInvSlots[slot], sheatheType, false); + + if (slot == 1) { + CCharacterComponent::RemoveHandItem(this->m_worldModel, s_virtualItemInvSlots[1], sheatheType, true); + } + + const CGUnitVirtualItem* current = this->GetVirtualItem(slot, false); + ItemDisplayInfoRec displayRec; + + if (current && this->GetVirtualItemDisplayRec(slot, displayRec)) { + GEOCOMPONENTLINKS link = CCharacterComponent::AddHandItem(this->m_worldModel, &displayRec, s_virtualItemInvSlots[slot], static_cast(current->m_sheatheType), this->m_sheatheState == 0, current->m_inventoryType == 14, false, 0); + + if (this->m_characterComponent) { + this->m_characterComponent->SetItemSlotUsingAttachSlot(static_cast(-1), link); + } + + this->SetWeaponTrail(this->m_worldModel, slot); + } +} diff --git a/WoW/Source/Object/ObjectClient/Unit_C.h b/WoW/Source/Object/ObjectClient/Unit_C.h index 94c9e27..186d5d1 100644 --- a/WoW/Source/Object/ObjectClient/Unit_C.h +++ b/WoW/Source/Object/ObjectClient/Unit_C.h @@ -135,6 +135,7 @@ class CGUnitVirtualItem { /* 0006 */ uint8_t m_pad [2]; }; +class UnitBloodRec; class CGUnit_C : public CGObject_C, public CGUnit { public: int32_t InitializeExtendedDisplay(CGPlayer_C* player, int32_t hasDisplayInfo); @@ -144,6 +145,7 @@ class CGUnit_C : public CGObject_C, public CGUnit { int32_t IsPlayingUnarmedAnim(); float GetMeleeChanceToCrit() const; float GetHealthRegenRateFromSpirit() const; + float GetManaRegenRateFromSpirit() const; CGUnit_C* GetVehicleUnit() const; void SetWeaponTrail(CM2Model* model, uint32_t hand); static void InitActiveMover(const WOWGUID& guid); @@ -227,8 +229,10 @@ class CGUnit_C : public CGObject_C, public CGUnit { static bool __stdcall IsAreaInAreaGroup(int32_t areaId, int32_t areaGroupId, int32_t* checked); static float __fastcall ComputeTrackingElevationAngle(const C3Vector& position, const C3Vector& target); static void InitMissileTrajectorySystem(); + static void ShutdownMissileTrajectorySystem(); static void UpdateVehicleUISliders(CGUnit_C* unit, const VehicleRec* vehicleRec); static void AnimEndCallback(CM2Model* model, uint32_t boneId, uint32_t sequenceId, int32_t interrupted, uint32_t time, uint64_t param); + static void MountAnimEndCallback(CM2Model* model, uint32_t boneId, uint32_t sequenceId, int32_t interrupted, uint32_t time, uint64_t param); static void AnimEventCallback(CM2Model* model, uint32_t boneId, uint32_t eventId, uint32_t data, const C3Vector* position, uint32_t time, uint64_t param); /* 00DC */ TSList m_unitMirrorLists [142]; @@ -468,7 +472,7 @@ class CGUnit_C : public CGObject_C, public CGUnit { int32_t IsUpdatingMissileTrajectory() const; int32_t IsMissileTrajectoryUpdateWaitingForMissileRelease() const; void SendFinalMissileTrajectoryUpdate(); - int32_t ComputeMissileTrajectory(const SpellRec* spell, int32_t* a2, CGUnit_C** a3, float* a4, C3Vector* position, float* facing, C3Vector* points, uint32_t* count, int32_t a9); + int32_t ComputeMissileTrajectory(const SpellRec* spell, int32_t* a2, CGUnit_C** a3, C3Vector* launchPosition, C3Vector* position, float* facing, C3Vector* points, uint32_t* count, int32_t a9); int32_t OverrideMissileFirePos(C3Vector* position, const SpellRec* spell); bool IsLocalClientControlled() const; void FreeComponent(); @@ -868,6 +872,7 @@ class CGUnit_C : public CGObject_C, public CGUnit { void SetAttacking(WOWGUID guid); void UpdateObjectEffectMovementStates(); void DestroyUnitMount(int32_t a2); + void SetMountModel(CM2Model* model); void OnDeathAnimate(); void ReadLootList(CDataStore* msg); void RemoveLootEffect(); @@ -942,12 +947,14 @@ class CGUnit_C : public CGObject_C, public CGUnit { int32_t UnsheatheRightWeapon(); int32_t UnsheatheLeftWeapon(); void AnimEndHandler(CM2Model* model, uint32_t boneId, uint32_t sequenceId, int32_t interrupted, uint32_t time); + void MountAnimEndHandler(CM2Model* model, uint32_t boneId, uint32_t sequenceId, int32_t interrupted, uint32_t time); void OnBaseAnimEnd(CM2Model* model, uint32_t boneId, uint32_t sequenceId); void ExchangeSheathedWeapon(const C3Vector* position, uint32_t hand, uint32_t flag); int32_t GetPrecastStartAnim(); static void BowModelLoaded(CM2Model* model, void* arg); void PlayWoundAnimKit(int32_t crit); void ShowBloodSpurt(const WOWGUID& attacker, int32_t a3); + UnitBloodRec* GetBloodRecord(); void ModifyPredictedPower(int32_t powerType, int32_t delta); void AddWorldText(const WOWGUID& source, int32_t reason, const SpellRec* spell, bool periodic); void AddWorldHealingText(const WOWGUID& source, int32_t amount, const SpellRec* spell, bool crit, int32_t a6); @@ -1096,7 +1103,6 @@ void NameQueryCallback(int32_t id, const WOWGUID& guid, void* param, bool succes float CalculateFacingTo(const C3Vector* from, const C3Vector* to); void WeaponTrailsInitialize(); -void WeaponTrailsShutdown(); const char* GetObjectNameFromGuid(const WOWGUID& guid); void WriteMovementPacket(CGUnit_C* unit, uint32_t msgId, CDataStore* msg, int32_t include); diff --git a/WoW/Source/Object/ObjectClient/VehiclePassenger_C.cpp b/WoW/Source/Object/ObjectClient/VehiclePassenger_C.cpp index db8dfdd..a84b894 100644 --- a/WoW/Source/Object/ObjectClient/VehiclePassenger_C.cpp +++ b/WoW/Source/Object/ObjectClient/VehiclePassenger_C.cpp @@ -922,3 +922,19 @@ void CVehiclePassenger_C::UpdateAll(uint32_t time) { passenger = next; } } + +// VERIFY: 8bae8c48 manual +// OFFSET: 0x00749CB0 +void CVehiclePassenger_C::ExecutePendingRescueTransitions() { + for (uint32_t i = 0; i < CVehiclePassenger_C::s_rescueTransitions->Count(); i++) { + VehiclePassengerRescueTransition& transition = CVehiclePassenger_C::s_rescueTransitions->m_data[i]; + CGUnit_C* unit = static_cast(ClntObjMgrObjectPtr(transition.m_passengerGuid, TYPEMASK_UNIT, __FILE__, __LINE__)); + + if (unit && unit->m_vehiclePassenger) { + unit->m_vehiclePassenger->BeginTransition(transition.m_vehicleGuid, transition.m_seat, transition.m_instant); + } + } + + CVehiclePassenger_C::s_rescueTransitions->m_count = 0; + CVehiclePassenger_C::s_pendingCount = 0; +} diff --git a/WoW/Source/Object/ObjectClient/VehiclePassenger_C.h b/WoW/Source/Object/ObjectClient/VehiclePassenger_C.h index bdc3440..ad72bf2 100644 --- a/WoW/Source/Object/ObjectClient/VehiclePassenger_C.h +++ b/WoW/Source/Object/ObjectClient/VehiclePassenger_C.h @@ -44,6 +44,7 @@ class CVehiclePassenger_C { static void Init(CGUnit_C* unit); void StopMovement(); + void BeginTransition(WOWGUID vehicleGuid, uint8_t seat, uint8_t instant); void SetState(uint32_t state, CGUnit_C* vehicle, uint8_t seat, VehicleSeatRec* seatRec, uint32_t time, WOWGUID vehicleGuid); /* 0000 */ uint32_t m_memHandle; diff --git a/WoW/Source/Object/Passenger.h b/WoW/Source/Object/Passenger.h index a42050a..17726f8 100644 --- a/WoW/Source/Object/Passenger.h +++ b/WoW/Source/Object/Passenger.h @@ -3,7 +3,6 @@ #include #include -#include #include "Engine/Source/Tempest/C3Vector.h" #include "Engine/Source/Tempest/C4Quaternion.h" #include "Engine/Source/Storm/H/stpl.h" diff --git a/WoW/Source/SoundInterface/SoundInterface2.cpp b/WoW/Source/SoundInterface/SoundInterface2.cpp index 3c35ef0..8615381 100644 --- a/WoW/Source/SoundInterface/SoundInterface2.cpp +++ b/WoW/Source/SoundInterface/SoundInterface2.cpp @@ -27,6 +27,7 @@ #include "WoW/Source/WorldClient/Map.h" #include "WoW/Source/WorldClient/World.h" #include "_Triage/AreaList.h" +#include "Engine/Source/Tempest/CMath.h" // STATIC: 0x009F2010 const char SI2::s_channelGroupNames[18][32] = { @@ -72,6 +73,9 @@ const int32_t SI2::s_channelGroupMaxSounds[18] = { 4, }; +// STATIC: 0x00AC384C +static float s_unk_AC384C = 0.5f; + // STATIC: 0x00B4A340 int32_t SI2::s_channelGroupNumSounds[18]; @@ -1442,3 +1446,38 @@ void SI2::ForceUpdateZoneSounds() { AreaListUpdateSounds(zone, area, rootRec, groupRec, inside); } + +// VERIFY: 34fea195 manual +// OFFSET: 0x004C5D60 +bool SI2::GetObjectPosition(uint64_t guid, C3Vector* position) { + CGObject_C* object = ClntObjMgrObjectPtr(WOWGUID{ guid }, TYPEMASK_OBJECT, __FILE__, __LINE__); + + if (object) { + *position = object->GetPosition(); + } + + return object != nullptr; +} + +// VERIFY: 8084b184 manual +// OFFSET: 0x004C6810 +int32_t SI2::GetChunkLocation(int32_t* mapId, int32_t* chunkX, int32_t* chunkY, int32_t* subchunkX, int32_t* subchunkY) { + *mapId = World::QueryMapId(); + CGObject_C* player = ClntObjMgrObjectPtr(ClntObjMgrGetActivePlayer(), TYPEMASK_PLAYER, __FILE__, __LINE__); + + if (!player) { + return 0; + } + + C3Vector position = player->GetPosition(); + float x = -(position.x - 17066.666f); + float y = -(position.y - 17066.666f) * 0.029999999f; + *subchunkX = CMath::fint_(y - s_unk_AC384C); + x *= 0.029999999f; + *subchunkY = CMath::fint_(x - s_unk_AC384C); + *chunkX = (*subchunkX >> 4) & 0x3F; + *chunkY = (*subchunkY >> 4) & 0x3F; + *subchunkX &= 0xF; + *subchunkY &= 0xF; + return 1; +} diff --git a/WoW/Source/UIUtil/AddOns.cpp b/WoW/Source/UIUtil/AddOns.cpp index 9bdb01a..b5183c8 100644 --- a/WoW/Source/UIUtil/AddOns.cpp +++ b/WoW/Source/UIUtil/AddOns.cpp @@ -1421,3 +1421,200 @@ void LoadAddOnEnableState(const char* character) { SFile::Unload(data); } + +// VERIFY: 3bde2f06 manual +// OFFSET: 0x005F5620 +void UnloadAddOns() { + int32_t changed = 0; + char path[260]; + SStrPrintf(path, sizeof(path), "WTF\\Account\\%s\\SavedVariables", s_addOnAccountName); + + if (!OsDirectoryExists(path)) { + OsCreateDirectory(path, 1); + } + + SStrPrintf(path, sizeof(path), "WTF\\Account\\%s\\%s\\%s\\SavedVariables", s_addOnAccountName, ClientServices::GetSelectedRealmName(), ClientServices::GetCharacterName()); + + if (!OsDirectoryExists(path)) { + OsCreateDirectory(path, 1); + } + + for (UIADDON* addon = s_addons.m_fulllist.Head(); addon; addon = s_addons.Next(addon)) { + if (!addon->m_loading) { + continue; + } + + SStrPrintf(path, sizeof(path), "WTF\\Account\\%s\\SavedVariables\\%s.lua", s_addOnAccountName, addon->m_key.m_str); + + if (addon->m_savedVariables.Count()) { + if (OsFileExists(path)) { + char backup[260]; + SStrCopy(backup, path, sizeof(backup)); + SStrPack(backup, ".bak", sizeof(backup)); + OsMoveFile(path, backup); + } else { + changed = 1; + } + + HOSFILE file = OsCreateFile(path, OS_GENERIC_WRITE, 0, OS_CREATE_ALWAYS, OS_FILE_ATTRIBUTE_NORMAL, OS_FILE_TYPE_ANY); + + if (file != OS_INVALID_FILE) { + FrameScript_GetContext(); + const char* savedTaint = lua_tainted; + + if (++lua_taintexpected && !lua_taintedclosure) { + lua_tainted = nullptr; + } + + for (uint32_t i = 0; i < addon->m_savedVariables.Count(); i++) { + const char* name = addon->m_savedVariables.m_data[i]; + + if (!name || !*name) { + continue; + } + + const char* c = name; + + while (*c < 0 || (*c >= '0' && *c <= '9') || (*c >= 'a' && *c <= 'z') || (*c >= 'A' && *c <= 'Z') || *c == '_') { + if (!*++c) { + FrameScript_PrintVariable(file, name); + break; + } + } + } + + uint32_t written; + OsWriteFile(file, "\r\n", 2, &written); + OsCloseFile(file); + + if (lua_taintexpected && !lua_taintedclosure) { + lua_tainted = savedTaint; + } + + if (--lua_taintexpected <= 0) { + lua_taintexpected = 0; + } + } + } else if (OsFileExists(path)) { + OsDeleteFile(path); + changed = 1; + } + + SStrPrintf(path, sizeof(path), "WTF\\Account\\%s\\%s\\%s\\SavedVariables\\%s.lua", s_addOnAccountName, ClientServices::GetSelectedRealmName(), ClientServices::GetCharacterName(), addon->m_key.m_str); + + if (addon->m_savedVariablesPerCharacter.Count()) { + if (OsFileExists(path)) { + char backup[260]; + SStrCopy(backup, path, sizeof(backup)); + SStrPack(backup, ".bak", sizeof(backup)); + OsMoveFile(path, backup); + } else { + changed = 1; + } + + HOSFILE file = OsCreateFile(path, OS_GENERIC_WRITE, 0, OS_CREATE_ALWAYS, OS_FILE_ATTRIBUTE_NORMAL, OS_FILE_TYPE_ANY); + + if (file != OS_INVALID_FILE) { + FrameScript_GetContext(); + const char* savedTaint = lua_tainted; + + if (++lua_taintexpected && !lua_taintedclosure) { + lua_tainted = nullptr; + } + + for (uint32_t i = 0; i < addon->m_savedVariablesPerCharacter.Count(); i++) { + const char* name = addon->m_savedVariablesPerCharacter.m_data[i]; + + if (!name || !*name) { + continue; + } + + const char* c = name; + + while (*c < 0 || (*c >= '0' && *c <= '9') || (*c >= 'a' && *c <= 'z') || (*c >= 'A' && *c <= 'Z') || *c == '_') { + if (!*++c) { + FrameScript_PrintVariable(file, name); + break; + } + } + } + + uint32_t written; + OsWriteFile(file, "\r\n", 2, &written); + OsCloseFile(file); + + if (lua_taintexpected && !lua_taintedclosure) { + lua_tainted = savedTaint; + } + + if (--lua_taintexpected <= 0) { + lua_taintexpected = 0; + } + } + } else { + if (OsFileExists(path)) { + OsDeleteFile(path); + changed = 1; + } + + SStrPrintf(path, sizeof(path), "WTF\\Account\\%s\\%s\\SavedVariables\\%s.lua", s_addOnAccountName, ClientServices::GetCharacterName(), addon->m_key.m_str); + + if (OsFileExists(path)) { + OsDeleteFile(path); + changed = 1; + } + } + + addon->m_loading = false; + addon->m_loaded = false; + } + + if (changed) { + SFile::RebuildHash(); + } +} + +// VERIFY: fceb3ea4 manual +// OFFSET: 0x005F76A0 +void SaveAddOnEnableState() { + int32_t created = 0; + + for (ADDONSTATELIST* list = s_addOnStates.Head(); list; list = s_addOnStates.Next(list)) { + if (!list->m_accountWide) { + continue; + } + + list->m_accountWide = false; + char path[260]; + SStrPrintf(path, sizeof(path), "WTF\\Account\\%s\\%s\\%s", s_addOnAccountName, ClientServices::GetSelectedRealmName(), list->m_name); + + if (!OsDirectoryExists(path)) { + OsCreateDirectory(path, 1); + } + + SStrPack(path, "\\AddOns.txt", sizeof(path)); + + if (!created) { + created = !OsFileExists(path); + } + + HOSFILE file = OsCreateFile(path, OS_GENERIC_WRITE, 0, OS_CREATE_ALWAYS, OS_FILE_ATTRIBUTE_NORMAL, OS_FILE_TYPE_ANY); + + if (file == OS_INVALID_FILE) { + continue; + } + + for (ADDONSTATE* state = list->m_states.m_fulllist.Head(); state; state = list->m_states.Next(state)) { + char line[1024]; + SStrPrintf(line, sizeof(line), "%s: %s\r\n", state->m_key.m_str, state->m_enabled ? "enabled" : "disabled"); + uint32_t written; + OsWriteFile(file, line, SStrLen(line), &written); + } + + OsCloseFile(file); + } + + if (created) { + SFile::RebuildHash(); + } +} diff --git a/WoW/Source/UIUtil/Camera.cpp b/WoW/Source/UIUtil/Camera.cpp index 2323b9d..94992c8 100644 --- a/WoW/Source/UIUtil/Camera.cpp +++ b/WoW/Source/UIUtil/Camera.cpp @@ -38,6 +38,7 @@ #include "WoW/Source/WorldClient/FrameTime.h" #include "WoW/Source/WorldClient/World.h" #include "_Triage/CMoveSpline.h" +#include "WoW/Source/DB/DBClient/DBClient.h" // STATIC: 0x00AD1B4C float MAX_PITCH_ANGLE = 1.55334306f; @@ -4186,3 +4187,13 @@ void CGCamera::RestoreSavedDistancePitch() { float CGCamera::GetDefaultZoomMinDistance() { return 0.0f; } + +// VERIFY: 26a4f582 manual +// OFFSET: 0x00606410 +void CGCamera::AddShakeById(int32_t shakeId, const C3Vector* position) { + CameraShakesRec* shake = g_cameraShakesDB.GetRecord(shakeId); + + if (shake) { + this->AddShake(*position, shake->m_shakeType, shake->m_direction, shake->m_amplitude * 0.027777778f, shake->m_frequency, shake->m_duration, shake->m_phase, shake->m_coefficient); + } +} diff --git a/WoW/Source/UIUtil/Cursor.h b/WoW/Source/UIUtil/Cursor.h index 7e1a5e7..f79ae0d 100644 --- a/WoW/Source/UIUtil/Cursor.h +++ b/WoW/Source/UIUtil/Cursor.h @@ -8,6 +8,7 @@ struct MipBits; int32_t CopyCursorImage(uint32_t* image, MipBits* mipImages, uint32_t width, uint32_t height); void CursorInitialize(); +void CursorDestroy(); void CursorReleaseItemMips(); void CursorSetHeldItem(WOWGUID item); diff --git a/WoW/Source/UIUtil/PortraitButton.cpp b/WoW/Source/UIUtil/PortraitButton.cpp index 36348c6..4f36231 100644 --- a/WoW/Source/UIUtil/PortraitButton.cpp +++ b/WoW/Source/UIUtil/PortraitButton.cpp @@ -828,3 +828,30 @@ int32_t ReadyModelForUI(CGUnit_C* unit, uint32_t flags) { return QueuePortraitUpdate(unit, flags) == 0; } + +// VERIFY: 7490c1d9 auto +// OFFSET: 0x00617860 +void PortraitShutdown() { + s_portraitMaskGxTex = nullptr; + HandleClose(reinterpret_cast(s_portraitMaskTexture)); + s_portraitMaskTexture = nullptr; + + if (s_portraitDepthTexture) { + HandleClose(reinterpret_cast(s_portraitDepthTexture)); + s_portraitDepthTexture = nullptr; + } + + PortraitCachePurge(&s_playerPortraitCache, 0, 1); + PortraitCachePurge(&s_unitPortraitCache, 0, 1); + + for (uint32_t i = 0; i < s_freePortraitTextures.m_count; i++) { + HandleClose(reinterpret_cast(s_freePortraitTextures.m_data[i])); + } + + s_freePortraitTextures.Clear(); + s_playerPortraits.Clear(); + s_unitPortraits.Clear(); + s_itemPortraits.Clear(); + s_pendingPortraits.Clear(); + s_freePortraits.Clear(); +} diff --git a/WoW/Source/UIUtil/PortraitButton.h b/WoW/Source/UIUtil/PortraitButton.h index 2252e82..9750a16 100644 --- a/WoW/Source/UIUtil/PortraitButton.h +++ b/WoW/Source/UIUtil/PortraitButton.h @@ -43,6 +43,7 @@ int32_t RTAlphaSupported(); void __fastcall UpdateAllPortraits(); void PortraitInitialize(); +void PortraitShutdown(); void UpdatePendingPortraits(); void SetPortraitTexture(CSimpleTexture* texture, const char* fileName); void SetPortraitTexture(CSimpleTexture* texture, uint32_t race, uint32_t sex, WOWGUID guid); diff --git a/WoW/Source/UIUtil/SmartScreenRect.cpp b/WoW/Source/UIUtil/SmartScreenRect.cpp index 3bf1c8c..f9106ba 100644 --- a/WoW/Source/UIUtil/SmartScreenRect.cpp +++ b/WoW/Source/UIUtil/SmartScreenRect.cpp @@ -442,3 +442,14 @@ void SmartScreenRectPositionFrame(uint32_t grid, CSimpleFrame* frame, CSimpleFra frame->SetPoint(center ? FRAMEPOINT_CENTER : FRAMEPOINT_TOP, parent, FRAMEPOINT_BOTTOMLEFT, point.x, point.y, 1); frame->SetFrameDepth(depth, true); } + +// VERIFY: 98e897bd auto +// OFFSET: 0x00616060 +void SmartScreenRectShutdown() { + s_searchQueue.Clear(); + s_freeNodes.Clear(); + + for (uint32_t i = 0; i < 2; i++) { + s_grids[i].Clear(); + } +} diff --git a/WoW/Source/UIUtil/SmartScreenRect.h b/WoW/Source/UIUtil/SmartScreenRect.h index 104a099..b46d282 100644 --- a/WoW/Source/UIUtil/SmartScreenRect.h +++ b/WoW/Source/UIUtil/SmartScreenRect.h @@ -8,6 +8,7 @@ class CRect; class CSimpleFrame; void SmartScreenRectClearAllGrids(); +void SmartScreenRectShutdown(); void SmartScreenRectClearGrid(uint32_t grid); void SmartScreenRectPlace(uint32_t grid, CRect& rect); void SmartScreenRectPositionFrame(uint32_t grid, CSimpleFrame* frame, CSimpleFrame* parent, const C3Vector& position, int32_t center); diff --git a/WoW/Source/UIUtil/Tooltip.h b/WoW/Source/UIUtil/Tooltip.h index 92346b6..90a4691 100644 --- a/WoW/Source/UIUtil/Tooltip.h +++ b/WoW/Source/UIUtil/Tooltip.h @@ -48,6 +48,7 @@ class ItemLinkInfo { }; class CGTalentGroup_C; +struct ScriptAuraInfo; class CGTooltip; class TalentRec; class CAaRect; @@ -253,4 +254,7 @@ class CSimpleUI { extern uint32_t s_tooltipTitleColor; extern uint32_t s_tooltipTextColor; +int32_t SetCompareItem(CGTooltip* tooltip, uint32_t itemId, int32_t offset, int32_t shift, CGTooltip* compare); +int32_t SetTooltipUnitAura(CGTooltip* tooltip, ScriptAuraInfo* info); + #endif diff --git a/WoW/Source/UIUtil/Tooltip_Scripts.cpp b/WoW/Source/UIUtil/Tooltip_Scripts.cpp index 5d92975..8547b87 100644 --- a/WoW/Source/UIUtil/Tooltip_Scripts.cpp +++ b/WoW/Source/UIUtil/Tooltip_Scripts.cpp @@ -44,7 +44,6 @@ int32_t Script_AddFontStrings(lua_State* L); int32_t Script_SetAnchorType(lua_State* L); int32_t Script_SetPetAction(lua_State* L); -int32_t Script_SetShapeshift(lua_State* L); int32_t Script_SetPossession(lua_State* L); int32_t Script_SetQuestItem(lua_State* L); int32_t Script_SetQuestLogItem(lua_State* L); @@ -57,14 +56,12 @@ int32_t Script_SetTradeTargetItem(lua_State* L); int32_t Script_SetUnit(lua_State* L); int32_t Script_SetUnitBuff(lua_State* L); int32_t Script_SetUnitDebuff(lua_State* L); -int32_t Script_SetUnitAura(lua_State* L); int32_t Script_SetSendMailItem(lua_State* L); int32_t Script_SetInboxItem(lua_State* L); int32_t Script_SetAuctionSellItem(lua_State* L); int32_t Script_SetAuctionItem(lua_State* L); int32_t Script_SetQuestRewardSpell(lua_State* L); int32_t Script_SetQuestLogRewardSpell(lua_State* L); -int32_t Script_SetHyperlinkCompareItem(lua_State* L); int32_t Script_SetBuybackItem(lua_State* L); int32_t Script_SetSocketedItem(lua_State* L); int32_t Script_SetSocketGem(lua_State* L); @@ -464,6 +461,49 @@ static int32_t Script_SetSpell(lua_State* L) { return 1; } +// VERIFY: 12bc9108 manual +// OFFSET: 0x00625630 +static int32_t Script_SetShapeshift(lua_State* L) { + CGTooltip* tooltip = static_cast(FrameScript_GetObjectThis(L, CGTooltip::GetObjectType())); + + if (!lua_isnumber(L, 2)) { + const char* name = tooltip->GetName(); + luaL_error(L, "Usage: %s:SetShapeshift(slot)", name ? name : ""); + } + + uint32_t slot = static_cast(lua_tonumber(L, 2)); + + if (slot - 1 < s_shapeshiftSpells.m_count) { + int32_t spellId = s_shapeshiftSpells.m_data[slot - 1].m_spellId; + uint32_t duration = 0; + uint32_t start = 0; + uint32_t enable = 0; + Spell_C_GetSpellCooldown(spellId, 0, &duration, &start, &enable); + int32_t brief = 1; + CVar* uberTooltips = CVar::Lookup("UberTooltips"); + + if (uberTooltips && uberTooltips->m_intValue) { + brief = 0; + } + + int32_t result; + + if (enable && start && duration) { + result = tooltip->SetSpell(spellId, brief, start + duration - OsGetAsyncTimeMs(), 0, 1, 0, 0, nullptr, nullptr, 0, 0, -1, -1, 0, 0); + } else { + result = tooltip->SetSpell(spellId, brief, 0, 0, 1, 0, 0, nullptr, nullptr, 0, 0, -1, -1, 0, 0); + } + + if (result) { + lua_pushnumber(L, 1.0); + return 1; + } + } + + lua_pushnil(L); + return 1; +} + // VERIFY: ed4d980b manual // OFFSET: 0x00625B90 static int32_t Script_SetSpellByID(lua_State* L) { @@ -1126,6 +1166,64 @@ done: return 1; } +// VERIFY: c5b104e7 auto +// OFFSET: 0x00626240 +static int32_t Script_SetUnitAura(lua_State* L) { + CGTooltip* tooltip = static_cast(FrameScript_GetObjectThis(L, CGTooltip::GetObjectType())); + ScriptAuraInfo info; + + if (!Script_GetUnitAuraInfo(L, 2, &info)) { + const char* name = tooltip->GetName(); + luaL_error(L, "Usage: %s:SetUnitAura(\"unit\", [index] or [\"name\", \"rank\"][, \"filter\"])", name ? name : ""); + return 0; + } + + return SetTooltipUnitAura(tooltip, &info); +} + +// VERIFY: 51f1907f manual +// OFFSET: 0x00631B60 +static int32_t Script_SetHyperlinkCompareItem(lua_State* L) { + CGTooltip* tooltip = static_cast(FrameScript_GetObjectThis(L, CGTooltip::GetObjectType())); + + if (!lua_isstring(L, 2)) { + const char* name = tooltip->GetName(); + luaL_error(L, "Usage: %s:SetHyperlinkCompareItem(\"hyperlink\" [, offset, shiftButton])", name ? name : ""); + return 0; + } + + const char* link = lua_tolstring(L, 2, nullptr); + ItemLinkInfo linkInfo; + linkInfo.Clear(); + + if (ClntObjMgrObjectPtr(ClntObjMgrGetActivePlayer(), TYPEMASK_PLAYER, __FILE__, __LINE__) && linkInfo.GetItemIdFromLink(link)) { + int32_t offset = 0; + int32_t shift = StringToBOOL(L, 4, 0); + + if (lua_isnumber(L, 3)) { + offset = static_cast(lua_tonumber(L, 3)) - 1; + } + + if (lua_type(L, 5) == LUA_TTABLE) { + lua_rawgeti(L, 5, 0); + CGTooltip* compare = static_cast(lua_touserdata(L, -1)); + + if (compare->IsA(CGTooltip::GetObjectType()) && SetCompareItem(tooltip, linkInfo.m_itemId, offset, shift, compare)) { + lua_pushnumber(L, 1.0); + return 1; + } + } + + if (SetCompareItem(tooltip, linkInfo.m_itemId, offset, shift, nullptr)) { + lua_pushnumber(L, 1.0); + return 1; + } + } + + lua_pushnil(L); + return 1; +} + // STATIC: 0x00AD2AE0 // VERIFY: da7bc442 manual // OFFSET: 0x0062E520 diff --git a/WoW/Source/Ui/AchievementInfo.cpp b/WoW/Source/Ui/AchievementInfo.cpp index 2adc42d..1b64c60 100644 --- a/WoW/Source/Ui/AchievementInfo.cpp +++ b/WoW/Source/Ui/AchievementInfo.cpp @@ -355,3 +355,64 @@ void CGAchievementInfo::LoadTrackedAchievements() { list.m_cvar->Set(value, true, false, false, true); } } + +// VERIFY: 628f101d manual +// OFFSET: 0x005B4F00 +void CGAchievementInfo::ShutdownGame() { + ClientServices::ClearMessageHandler(SMSG_ACHIEVEMENT_EARNED); + ClientServices::ClearMessageHandler(SMSG_CRITERIA_UPDATE); + ClientServices::ClearMessageHandler(SMSG_RESPOND_INSPECT_ACHIEVEMENTS); + ClientServices::ClearMessageHandler(SMSG_ALL_ACHIEVEMENT_DATA); + ClientServices::ClearMessageHandler(SMSG_ACHIEVEMENT_DELETED); + ClientServices::ClearMessageHandler(SMSG_CRITERIA_DELETED); + ClientServices::ClearMessageHandler(SMSG_QUERY_QUESTS_COMPLETED_RESPONSE); + s_unkC1F450 = 0; + s_unkACFD98.Clear(); + s_unkACFDA4.Clear(); + s_completedAchievements.Clear(); + s_unkACFDBC.Clear(); + s_unkACFDC8.Clear(); + s_unkACFDD4.Clear(); + s_trackedAchievements.Clear(); + s_completedQuests.Clear(); + + for (uint32_t i = 0; i < 124; i++) { + ACHIEVEMENTCRITERIALIST* list = s_criteriaByType[i].m_fulllist.Head(); + + while (list) { + ACHIEVEMENTCRITERIALIST* next = s_criteriaByType[i].Next(list); + list->m_criteria.Clear(); + s_criteriaByType[i].Delete(list); + list = next; + } + } + + ACHIEVEMENT* achievement = s_achievements.m_fulllist.Head(); + + while (achievement) { + ACHIEVEMENT* next = s_achievements.Next(achievement); + achievement->m_criteria.Clear(); + s_achievements.Delete(achievement); + achievement = next; + } +} + +// VERIFY: f42c8dbe manual +// OFFSET: 0x005B1FA0 +void CGAchievementInfo::SaveTrackedAchievements() { + CVarIntListWrapper list; + list.m_cvar = CVar::Lookup("trackedAchievements"); + list.m_pos = 2; + list.m_state = 0; + + for (CLIENT_ACHIEVEMENTS* node = s_trackedAchievements.Head(); node; node = s_trackedAchievements.Next(node)) { + list.AddNextValue(node->m_id); + } + + if (list.m_state != 1) { + list.m_buffer[0] = 'v'; + list.m_buffer[1] = 1; + list.m_buffer[list.m_pos] = 0; + list.m_cvar->Set(list.m_buffer, true, false, false, true); + } +} diff --git a/WoW/Source/Ui/AchievementInfo.h b/WoW/Source/Ui/AchievementInfo.h index aa91d71..b99f0be 100644 --- a/WoW/Source/Ui/AchievementInfo.h +++ b/WoW/Source/Ui/AchievementInfo.h @@ -55,11 +55,13 @@ int32_t Packet_SMSG_QUERY_QUESTS_COMPLETED_RESPONSE(void* param, NETMESSAGE msgI class CGAchievementInfo { public: + static void SaveTrackedAchievements(); static int32_t m_showAchievementUI; static void LoadTrackedAchievements(); static WOWGUID m_inspect; static void InitializeGame(); + static void ShutdownGame(); static bool IsCriteriaStat(int32_t criteriaId); static void UpdateAchievement(int32_t id, WowTime date); static void UpdateCriteria(int32_t id, uint64_t counter, uint32_t flags, WowTime date, WOWGUID player, uint32_t timer1, uint32_t timer2); diff --git a/WoW/Source/Ui/ActionBarFrame.cpp b/WoW/Source/Ui/ActionBarFrame.cpp index 54fe3ba..ec7063e 100644 --- a/WoW/Source/Ui/ActionBarFrame.cpp +++ b/WoW/Source/Ui/ActionBarFrame.cpp @@ -1948,3 +1948,22 @@ void CGActionBar::PickupAction(uint32_t slot) { CGActionBar::RemoveAction(slot); } } + +// VERIFY: 01a1fb58 auto +// OFFSET: 0x005EEB70 +void CGActionBar::ShutdownGame() { +} + +// VERIFY: 58205ae6 auto +// OFFSET: 0x005A7A90 +int32_t CGActionBar::GetMacroItem(uint32_t slot) { + uint32_t action = CGActionBar::m_slotActions[slot]; + uint32_t macroId = (action && (action & 0xF0000000) == 0x40000000) ? action & 0xBFFFFFFF : 0; + MACRONODE* macro = CGUIMacros::GetMacroByID(macroId); + + if (macro) { + return macro->m_itemID; + } + + return 0; +} diff --git a/WoW/Source/Ui/ActionBarFrame.h b/WoW/Source/Ui/ActionBarFrame.h index c91c13d..66395bd 100644 --- a/WoW/Source/Ui/ActionBarFrame.h +++ b/WoW/Source/Ui/ActionBarFrame.h @@ -53,6 +53,7 @@ class CGActionBar { static void SetTemporaryActionBarFlags(uint32_t flags, int32_t enable); static void UpdateShapeShiftBar(); static void InitializeGame(); + static void ShutdownGame(); static void UpdateAttackAction(); static void UpdateItem(int32_t itemId); static void UpdateRangedAttackAction(); diff --git a/WoW/Source/Ui/AddOns.h b/WoW/Source/Ui/AddOns.h index 0f82a29..61620e8 100644 --- a/WoW/Source/Ui/AddOns.h +++ b/WoW/Source/Ui/AddOns.h @@ -22,5 +22,7 @@ char* AddOnUnloadableToken(UIADDON_LOADABLE_REASON reason, UIADDON_LOADABLE_REAS bool LoadAddOn(const char* name, bool demandLoad, CStatus* status); uint32_t LoadAddOnFileCount(); void LoadAddOns(CStatus* status); +void UnloadAddOns(); +void SaveAddOnEnableState(); #endif diff --git a/WoW/Source/Ui/ArenaTeamInfo.cpp b/WoW/Source/Ui/ArenaTeamInfo.cpp index b75f3d7..2bd7d29 100644 --- a/WoW/Source/Ui/ArenaTeamInfo.cpp +++ b/WoW/Source/Ui/ArenaTeamInfo.cpp @@ -201,3 +201,14 @@ void CGArenaTeamInfo::UpdateTeams(int32_t signal) { void CGArenaTeamInfo::EnterWorld() { CGArenaTeamInfo::UpdateTeams(0); } + +// VERIFY: 05e453ae auto +// OFFSET: 0x005A3DD0 +void CGArenaTeamInfo::ShutdownGame() { + ClientServices::ClearMessageHandler(SMSG_ARENA_TEAM_ROSTER); + ClientServices::ClearMessageHandler(SMSG_ARENA_TEAM_STATS); + + for (uint32_t i = 0; i < 3; i++) { + CGArenaTeamInfo::m_arenaTeams[i].FreeMemberArray(); + } +} diff --git a/WoW/Source/Ui/ArenaTeamInfo.h b/WoW/Source/Ui/ArenaTeamInfo.h index ad28259..78cf297 100644 --- a/WoW/Source/Ui/ArenaTeamInfo.h +++ b/WoW/Source/Ui/ArenaTeamInfo.h @@ -56,6 +56,7 @@ class CGArenaTeamInfo { static WOWGUID m_selectedMember; static void EnterWorld(); static void InitializeGame(); + static void ShutdownGame(); static void QueryRoster(uint32_t index); static void UpdateTeams(int32_t signal); static bool CheckPersonalAndTeamRating(uint32_t rating, int32_t bracket); diff --git a/WoW/Source/Ui/AuctionHouse.cpp b/WoW/Source/Ui/AuctionHouse.cpp index 0aa3816..1533c94 100644 --- a/WoW/Source/Ui/AuctionHouse.cpp +++ b/WoW/Source/Ui/AuctionHouse.cpp @@ -299,3 +299,24 @@ bool CGAuctionHouse::IsItemForSell(WOWGUID item) { return false; } + +// VERIFY: 93924a65 manual +// OFFSET: 0x0059E090 +void CGAuctionHouse::ShutdownGame() { + ClientServices::ClearMessageHandler(MSG_AUCTION_HELLO); + ClientServices::ClearMessageHandler(SMSG_AUCTION_COMMAND_RESULT); + ClientServices::ClearMessageHandler(SMSG_AUCTION_LIST_RESULT); + ClientServices::ClearMessageHandler(SMSG_AUCTION_LIST_OWNER_ITEMS_RESULT); + ClientServices::ClearMessageHandler(SMSG_AUCTION_LIST_BIDDER_ITEMS_RESULT); + ClientServices::ClearMessageHandler(SMSG_AUCTION_BIDDER_NOTIFICATION); + ClientServices::ClearMessageHandler(SMSG_AUCTION_OWNER_NOTIFICATION); + ClientServices::ClearMessageHandler(SMSG_AUCTION_REMOVED_NOTIFICATION); + ClientServices::ClearMessageHandler(SMSG_AUCTION_LIST_PENDING_SALES); + + for (uint32_t i = 0; i < CGAuctionHouse::m_outbidItems.m_count; i++) { + delete CGAuctionHouse::m_outbidItems.m_data[i]; + } + + CGAuctionHouse::m_outbidItems.Clear(); + CGAuctionHouse::m_numOutbidItems = 0; +} diff --git a/WoW/Source/Ui/AuctionHouse.h b/WoW/Source/Ui/AuctionHouse.h index 6102bbf..c07190f 100644 --- a/WoW/Source/Ui/AuctionHouse.h +++ b/WoW/Source/Ui/AuctionHouse.h @@ -104,6 +104,7 @@ class CGAuctionHouse { static TSGrowableArray m_bidderList; static void EnterWorld(); static void InitializeGame(); + static void ShutdownGame(); static uint8_t m_auctionsTabShowing; static bool IsSellItemValid(CGItem_C* item, int32_t showError); static void GetSellItem(WOWGUID* item, uint8_t* bag, uint8_t* slot); diff --git a/WoW/Source/Ui/BarberShop.cpp b/WoW/Source/Ui/BarberShop.cpp index 08429b7..f3ce2e1 100644 --- a/WoW/Source/Ui/BarberShop.cpp +++ b/WoW/Source/Ui/BarberShop.cpp @@ -133,3 +133,12 @@ void CGBarberShop::EnterWorld() { CGBarberShop::m_currentFacialHair = CGBarberShop::GetStyle(2, player->m_unit->m_unitFieldBytes0[0], player->m_player->m_playerBytes3[0], player->m_player->m_playerBytes2[0]); CGBarberShop::m_currentSkinColor = CGBarberShop::GetStyle(3, player->m_unit->m_unitFieldBytes0[0], player->m_player->m_playerBytes3[0], player->m_player->m_playerBytes[0]); } + +// VERIFY: 51a462fe auto +// OFFSET: 0x0052F060 +void CGBarberShop::ShutdownGame() { + CGBarberShop::m_initialized = 0; + CGBarberShop::m_useableStyles.InternalClear(0); + ClientServices::ClearMessageHandler(SMSG_ENABLE_BARBER_SHOP); + ClientServices::ClearMessageHandler(SMSG_BARBER_SHOP_RESULT); +} diff --git a/WoW/Source/Ui/BarberShop.h b/WoW/Source/Ui/BarberShop.h index c26a195..5782dda 100644 --- a/WoW/Source/Ui/BarberShop.h +++ b/WoW/Source/Ui/BarberShop.h @@ -31,6 +31,7 @@ class CGBarberShop { static void AppearanceApplied(); static void DisableBarberShop(); static void InitializeGame(); + static void ShutdownGame(); static void RegisterScriptFunctions(); }; diff --git a/WoW/Source/Ui/BattlefieldInfo.cpp b/WoW/Source/Ui/BattlefieldInfo.cpp index 225012f..482a8bf 100644 --- a/WoW/Source/Ui/BattlefieldInfo.cpp +++ b/WoW/Source/Ui/BattlefieldInfo.cpp @@ -19,6 +19,7 @@ #include "WoW/Source/DB/DBClient/DBClient.h" #include "WoW/Source/DB/Rec/BattlemasterListRec.h" #include "WoW/Source/Ui/CGWorldStateInfo.h" +#include "WoW/Source/Object/ObjectClient/Player_C.h" // STATIC: 0x00BEA4A8 WorldPvPQueueStatus CGBattlefieldInfo::m_worldPvPQueues[1]; @@ -617,3 +618,64 @@ void CGBattlefieldInfo::AddVehicle(const WOWGUID& guid) { CGBattlefieldInfo::m_vehicleGuids[CGBattlefieldInfo::m_numVehicles] = guid; CGBattlefieldInfo::m_numVehicles++; } + +// VERIFY: e38a0e4a manual +// OFFSET: 0x0054E220 +void CGBattlefieldInfo::ShutdownGame() { + ClientServices::ClearMessageHandler(SMSG_BATTLEFIELD_LIST); + ClientServices::ClearMessageHandler(SMSG_BATTLEFIELD_STATUS); + ClientServices::ClearMessageHandler(MSG_PVP_LOG_DATA); + ClientServices::ClearMessageHandler(SMSG_BATTLEFIELD_STATUS_QUEUED); + ClientServices::ClearMessageHandler(MSG_BATTLEGROUND_PLAYER_POSITIONS); + ClientServices::ClearMessageHandler(SMSG_BATTLEGROUND_PLAYER_JOINED); + ClientServices::ClearMessageHandler(SMSG_BATTLEGROUND_PLAYER_LEFT); + ClientServices::ClearMessageHandler(SMSG_ARENA_OPPONENT_UPDATE); + ClientServices::ClearMessageHandler(SMSG_BATTLEFIELD_PORT_DENIED); + ClientServices::ClearMessageHandler(SMSG_BATTLEFIELD_MGR_ENTRY_INVITE); + ClientServices::ClearMessageHandler(SMSG_BATTLEFIELD_MGR_ENTERING); + ClientServices::ClearMessageHandler(SMSG_BATTLEFIELD_MGR_QUEUE_REQUEST_RESPONSE); + ClientServices::ClearMessageHandler(SMSG_BATTLEFIELD_MGR_EJECT_PENDING); + ClientServices::ClearMessageHandler(SMSG_BATTLEFIELD_MGR_EJECTED); + ClientServices::ClearMessageHandler(SMSG_BATTLEFIELD_MGR_QUEUE_INVITE); + ClientServices::ClearMessageHandler(SMSG_BATTLEFIELD_MGR_STATE_CHANGE); + + for (uint32_t i = 0; i < 80; i++) { + delete CGBattlefieldInfo::m_scores[i]; + } + + CGBattlefieldInfo::m_battlegroundTypes.Clear(); +} + +// VERIFY: 8e23bef8 manual +// OFFSET: 0x0054E5B0 +void CGBattlefieldInfo::RequestBattlegroundInstanceInfo(uint32_t index) { + CGPlayer_C* player = static_cast(ClntObjMgrObjectPtr(ClntObjMgrGetActivePlayer(), TYPEMASK_PLAYER, __FILE__, __LINE__)); + + if (!player || static_cast(index) < 0 || index >= CGBattlefieldInfo::m_battlegroundTypes.m_count) { + return; + } + + BattlemasterListRec* rec = g_battlemasterListDB.GetRecord(CGBattlefieldInfo::m_battlegroundTypes.m_data[index]); + + if (!rec) { + return; + } + + CDataStore msg; + msg.Put(static_cast(CMSG_BATTLEFIELD_LIST)); + msg.Put(static_cast(rec->m_id)); + msg.Put(static_cast(1)); + uint8_t flag; + + if (player->m_unit->m_unitFieldLevel >= player->m_player->m_playerFieldMaxLevel) { + flag = 0; + } else { + flag = (player->m_player->m_playerFlags >> 25) & 1; + } + + msg.Put(flag); + msg.Finalize(); + ClientServices::Send2(&msg); + CGBattlefieldInfo::m_instances.Clear(); + CGBattlefieldInfo::m_bgTypeID = rec->m_id; +} diff --git a/WoW/Source/Ui/BattlefieldInfo.h b/WoW/Source/Ui/BattlefieldInfo.h index b77eab6..47ea514 100644 --- a/WoW/Source/Ui/BattlefieldInfo.h +++ b/WoW/Source/Ui/BattlefieldInfo.h @@ -71,9 +71,11 @@ void BattlefieldNameCacheCallback(int32_t id, const WOWGUID& guid, void* param, class CGBattlefieldInfo { public: + static void RequestBattlegroundInstanceInfo(uint32_t index); static void SetBattlemaster(WOWGUID battlemaster); static void EnterWorld(); static void InitializeGame(); + static void ShutdownGame(); static WOWGUID m_arenaOpponentPets[5][2]; static WOWGUID m_arenaOpponents[5]; static CGPartyMemberState m_arenaOpponentStats[5]; diff --git a/WoW/Source/Ui/BattlefieldInfo_Scripts.cpp b/WoW/Source/Ui/BattlefieldInfo_Scripts.cpp index fe49316..73b2552 100644 --- a/WoW/Source/Ui/BattlefieldInfo_Scripts.cpp +++ b/WoW/Source/Ui/BattlefieldInfo_Scripts.cpp @@ -683,6 +683,20 @@ static int32_t Script_GetBattlegroundInfo(lua_State* L) { return 5; } +// VERIFY: 81438931 auto +// OFFSET: 0x0054E6D0 +int32_t Script_RequestBattlegroundInstanceInfo(lua_State* L) { + if (!lua_isnumber(L, 1)) { + luaL_error(L, "Usage: RequestBattlegroundInstanceInfo(index)"); + return 0; + } + + uint32_t index = static_cast(lua_tonumber(L, 1)); + CGBattlefieldInfo::RequestBattlegroundInstanceInfo(index - 1); + + return 0; +} + // STATIC: 0x00ACD178 static FrameScript_Method s_ScriptFunctions[] = { { "GetNumBattlefields", &Script_GetNumBattlefields }, diff --git a/WoW/Source/Ui/BattlenetUI.h b/WoW/Source/Ui/BattlenetUI.h index d9a6484..7c965e2 100644 --- a/WoW/Source/Ui/BattlenetUI.h +++ b/WoW/Source/Ui/BattlenetUI.h @@ -14,6 +14,13 @@ struct BattlenetPresenceValue { /* 0005 */ uint8_t unk_0005[519]; }; +struct BattlenetBlockList { + /* 0000 */ uint32_t m_blockedCount; + /* 0004 */ uint32_t m_blocked[100]; + /* 0194 */ uint32_t m_blockedToonCount; + /* 0198 */ uint32_t m_blockedToons[100]; +}; + struct BattlenetUIFriend { /* 0000 */ uint32_t m_presenceID; /* 0004 */ uint8_t unk_0004[820]; @@ -37,6 +44,7 @@ class BattlenetUI { namespace BattlenetAPI { bool IsRIDEnabled(); BattlenetPresenceValue GetPresenceValue(uint32_t presenceID, uint32_t field); + BattlenetBlockList GetBlockList(); } bool BattlenetUI_IsAvailable(); @@ -74,13 +82,11 @@ int32_t Script_BNGetNumConversationMembers(lua_State* L); int32_t Script_BNGetConversationMemberInfo(lua_State* L); int32_t Script_BNGetConversationInfo(lua_State* L); int32_t Script_BNListConversation(lua_State* L); -int32_t Script_BNGetNumBlocked(lua_State* L); int32_t Script_BNGetBlockedInfo(lua_State* L); int32_t Script_BNIsBlocked(lua_State* L); int32_t Script_BNSetBlocked(lua_State* L); int32_t Script_BNSetSelectedBlock(lua_State* L); int32_t Script_BNGetSelectedBlock(lua_State* L); -int32_t Script_BNGetNumBlockedToons(lua_State* L); int32_t Script_BNGetBlockedToonInfo(lua_State* L); int32_t Script_BNIsToonBlocked(lua_State* L); int32_t Script_BNSetToonBlocked(lua_State* L); diff --git a/WoW/Source/Ui/BattlenetUI_Scripts.cpp b/WoW/Source/Ui/BattlenetUI_Scripts.cpp index a620cfa..7b80822 100644 --- a/WoW/Source/Ui/BattlenetUI_Scripts.cpp +++ b/WoW/Source/Ui/BattlenetUI_Scripts.cpp @@ -5,6 +5,7 @@ #include "WoW/Source/WowServices/BattlenetLogin.h" #include "WoW/Source/WowServices/Login.h" #include "WoW/Source/WowSvcs/WowSvcsClient/ClientServices.h" +#include "Engine/Source/Storm/H/storm.h" // STATIC: 0x00ACC9E8 static uint32_t s_presenceOnlineField = 0x10002; @@ -71,6 +72,50 @@ static int32_t Script_BNGetMaxPlayersInConversation(lua_State* L) { return 1; } +// VERIFY: 423fdd2d manual +// OFFSET: 0x00536400 +static int32_t Script_BNGetNumBlocked(lua_State* L) { + Login* login = ClientServices::LoginConnection(); + + if (!login || login->GetLoginServerType() != 1 || login->IsTrialAccount() || !BattlenetAPI::IsRIDEnabled()) { + lua_pushnumber(L, 0.0); + return 1; + } + + if (!BattlenetUI_IsAvailable()) { + lua_pushnumber(L, 0.0); + DebugLog("BNUI: Num Blocked is 0. NOT CONNECTED"); + return 1; + } + + BattlenetBlockList blockList = BattlenetAPI::GetBlockList(); + lua_pushnumber(L, blockList.m_blockedCount); + DebugLog("BNUI: Num Blocked is %d", blockList.m_blockedCount); + return 1; +} + +// VERIFY: 6fff9574 manual +// OFFSET: 0x00536890 +static int32_t Script_BNGetNumBlockedToons(lua_State* L) { + Login* login = ClientServices::LoginConnection(); + + if (!login || login->GetLoginServerType() != 1 || login->IsTrialAccount() || !BattlenetAPI::IsRIDEnabled()) { + lua_pushnumber(L, 0.0); + return 1; + } + + if (!BattlenetUI_IsAvailable()) { + lua_pushnumber(L, 0.0); + DebugLog("BNUI: Num Blocked toons is 0. NOT CONNECTED"); + return 1; + } + + BattlenetBlockList blockList = BattlenetAPI::GetBlockList(); + lua_pushnumber(L, blockList.m_blockedToonCount); + DebugLog("BNUI: Num Blocked toons is %d", blockList.m_blockedToonCount); + return 1; +} + // STATIC: 0x00ACCAE8 static FrameScript_Method s_ScriptFunctions[] = { { "BNGetInfo", &Script_BNGetInfo }, diff --git a/WoW/Source/Ui/CGAutoCompleteName.cpp b/WoW/Source/Ui/CGAutoCompleteName.cpp index f8125a9..5db7081 100644 --- a/WoW/Source/Ui/CGAutoCompleteName.cpp +++ b/WoW/Source/Ui/CGAutoCompleteName.cpp @@ -1,5 +1,8 @@ #include "CGAutoCompleteName.h" #include "Engine/Source/Storm/H/storm.h" +#include +#include +#include "WoW/Source/WorldClient/FrameTime.h" // STATIC: 0x00ACEB70 TSList> CGAutoCompleteName::m_list; @@ -49,3 +52,95 @@ void CGAutoCompleteName::ResortAll() { node = next; } } + +// VERIFY: cd399474 manual +// OFFSET: 0x0057AE80 +static AUTOCOMPLETE_NAMENODE* FindNodeByGuid(const WOWGUID& guid) { + for (AUTOCOMPLETE_NAMENODE* node = CGAutoCompleteName::m_list.Head(); node; node = CGAutoCompleteName::m_list.Next(node)) { + if (!node->m_presenceId && node->m_guid == guid) { + return node; + } + } + + return nullptr; +} + +// VERIFY: 040c821a auto +// OFFSET: 0x0057B630 +static int32_t ApplyNodeFlags(AUTOCOMPLETE_NAMENODE* node, uint32_t flags, int32_t touch, const char* name) { + if (!node) { + SErrDisplayAppFatalMessage("", "", 0); + } + + node->m_flags |= flags; + + if (touch) { + node->m_lastUsed = FrameTime::s_curTimeMs; + } + + if (name && !node->m_name[0]) { + SStrCopy(node->m_name, name, 305); + } + + SortNameNode(node); + return 1; +} + +// VERIFY: 4d5b0997 manual +// OFFSET: 0x0057B6A0 +static AUTOCOMPLETE_NAMENODE* AllocNameNode(const WOWGUID& guid, uint32_t flags, uint32_t lastUsed, const char* name) { + AUTOCOMPLETE_NAMENODE* node = new (SMemAlloc(sizeof(AUTOCOMPLETE_NAMENODE), typeid(AUTOCOMPLETE_NAMENODE).raw_name(), -2, 0x8)) AUTOCOMPLETE_NAMENODE; + node->m_presenceId = 0; + node->m_guid = guid; + + if (name) { + SStrCopy(node->m_name, name, 305); + } else { + node->m_name[0] = '\0'; + } + + if (node->m_lastUsed != lastUsed) { + node->m_lastUsed = lastUsed; + SortNameNode(node); + } + + node->m_flags = flags; + SortNameNode(node); + return node; +} + +// VERIFY: d91cc811 auto +// OFFSET: 0x0057B7C0 +void CGAutoCompleteName::AddFlags(const WOWGUID& guid, uint32_t flags, int32_t add, const char* name) { + if (guid == WOWGUID()) { + return; + } + + if (flags & 0x8) { + SErrDisplayAppFatalMessage("", "", 0); + } + + AUTOCOMPLETE_NAMENODE* node = FindNodeByGuid(guid); + + if (node) { + ApplyNodeFlags(node, flags, add, name); + } else { + AllocNameNode(guid, flags, add ? FrameTime::s_curTimeMs : 0, name); + } +} + +// VERIFY: 912690b2 auto +// OFFSET: 0x0057B000 +int32_t CGAutoCompleteName::RemoveFlags(const WOWGUID& guid, uint32_t flags) { + AUTOCOMPLETE_NAMENODE* node = FindNodeByGuid(guid); + + if (node) { + node->m_flags &= ~flags; + + if (!(node->m_flags & ~0x20)) { + CGAutoCompleteName::m_list.DeleteNode(node); + } + } + + return 1; +} diff --git a/WoW/Source/Ui/CGAutoCompleteName.h b/WoW/Source/Ui/CGAutoCompleteName.h index 058f4ad..94e4394 100644 --- a/WoW/Source/Ui/CGAutoCompleteName.h +++ b/WoW/Source/Ui/CGAutoCompleteName.h @@ -8,12 +8,16 @@ struct lua_State; struct AUTOCOMPLETE_NAMENODE : public TSLinkedNode { - /* 0008 */ char m_name[312]; + /* 0008 */ char m_name[308]; + /* 013C */ uint32_t m_flags; /* 0140 */ uint32_t m_lastUsed; + /* 0144 */ uint32_t m_presenceId; + /* 0148 */ WOWGUID m_guid; }; class CGAutoCompleteName { public: + static void RemoveFlagsFromAllNodes(uint32_t flags); static TSList> m_list; static bool s_resortNamesOnRecency; static void RemoveFlagsByName(const char* name, uint32_t flags, int32_t a3, int32_t a4); diff --git a/WoW/Source/Ui/CGMinigameInfo.cpp b/WoW/Source/Ui/CGMinigameInfo.cpp index b7fb088..41fcfd7 100644 --- a/WoW/Source/Ui/CGMinigameInfo.cpp +++ b/WoW/Source/Ui/CGMinigameInfo.cpp @@ -7,3 +7,10 @@ void CGMinigameInfo::InitializeGame() { ClientServices::SetMessageHandler(SMSG_MINIGAME_SETUP, Packet_SMSG_MINIGAME_SETUP, nullptr); ClientServices::SetMessageHandler(SMSG_MINIGAME_STATE, Packet_SMSG_MINIGAME_STATE, nullptr); } + +// VERIFY: 8dc40695 auto +// OFFSET: 0x005C54B0 +void CGMinigameInfo::ShutdownGame() { + ClientServices::ClearMessageHandler(SMSG_MINIGAME_SETUP); + ClientServices::ClearMessageHandler(SMSG_MINIGAME_STATE); +} diff --git a/WoW/Source/Ui/CGMinigameInfo.h b/WoW/Source/Ui/CGMinigameInfo.h index 3fb75e3..3059099 100644 --- a/WoW/Source/Ui/CGMinigameInfo.h +++ b/WoW/Source/Ui/CGMinigameInfo.h @@ -8,6 +8,7 @@ struct lua_State; class CGMinigameInfo { public: + static void ShutdownGame(); static void InitializeGame(); }; diff --git a/WoW/Source/Ui/CGWorldStateInfo.cpp b/WoW/Source/Ui/CGWorldStateInfo.cpp index 9a2dda1..f06e805 100644 --- a/WoW/Source/Ui/CGWorldStateInfo.cpp +++ b/WoW/Source/Ui/CGWorldStateInfo.cpp @@ -7,6 +7,10 @@ #include "WoW/Source/WowSvcs/WowSvcsClient/ClientServices.h" #include #include "WoW/Source/Ui/MinimapFrame.h" +#include "WoW/Source/DB/DBClient/DBClient.h" +#include "WoW/Source/Ui/GameUI.h" +#include "Engine/Source/Storm/H/storm.h" +#include "WoW/Source/Ui/QuestTextParser.h" // STATIC: 0x00BE8F40 uint32_t CGWorldStateInfo::m_nextUITimeUpdate; @@ -129,3 +133,105 @@ bool CGWorldStateInfo::SetWorldState(uint32_t state, uint32_t value) { RefreshWorldStatePOIs(state); return true; } + +// VERIFY: 597548a3 auto +// OFFSET: 0x005486E0 +void CGWorldStateInfo::OnUITime(uint32_t time) { + CGWorldStateInfo::m_UITimeOffset = time - static_cast(::time(nullptr)); +} + +// VERIFY: 004fb22d manual +// OFFSET: 0x005487D0 +void CGWorldStateInfo::ResetWorldStateUI() { + CGWorldStateInfo::m_worldStateUI.m_count = 0; + + for (int32_t i = 0; i < g_worldStateUIDB.m_numRecords; i++) { + WorldStateUIRec* rec = g_worldStateUIDB.GetRecordByIndex(i); + + if (rec->m_mapID != -1 && rec->m_mapID != CGWorldStateInfo::m_mapID) { + continue; + } + + if (rec->m_areaID && rec->m_areaID != CGWorldStateInfo::m_areaID && rec->m_areaID != CGWorldStateInfo::m_subAreaID) { + continue; + } + + if (rec->m_phaseShift && !(rec->m_phaseShift & CGGameUI::unk_AC80A4)) { + continue; + } + + if (rec->m_type && rec->m_type != 3 && rec->m_type != 1) { + continue; + } + + WorldStateUIEntry* entry = CGWorldStateInfo::m_worldStateUI.New(); + entry->m_id = rec->m_id; + entry->m_state = rec->m_type; + } +} + +// VERIFY: 52346cc7 manual +// OFFSET: 0x00548B20 +void CGWorldStateInfo::ShutdownGame() { + CGWorldStateInfo::m_worldStates.InternalClear(0); + CGWorldStateInfo::m_worldStateUI.Clear(); +} + +// VERIFY: 78ef8608 auto +// OFFSET: 0x005770D0 +bool WorldStateParseText(const char* text, char* buffer, uint32_t size) { + if (!text) { + return false; + } + + int32_t error = 0; + *buffer = '\0'; + const char* start = text; + + for (const char* percent = SStrChr(text, '%'); percent && *percent; percent = SStrChr(start, '%')) { + uint32_t length = percent - start; + + if (length) { + uint32_t used = SStrLen(buffer); + SStrPack(buffer, start, size); + + if (used + length < size) { + buffer[used + length] = '\0'; + } + } + + const char* cursor = percent + 1; + const char* number = cursor; + + while (*cursor >= '0' && *cursor <= '9') { + cursor++; + } + + switch (*cursor) { + case 'K': + case 'k': + ParseCountDownTimerText(buffer, size, GetWorldState(SStrToInt(number))); + cursor++; + break; + + case 'W': + case 'w': { + char value[16]; + SStrPrintf(value, sizeof(value), "%d", GetWorldState(SStrToInt(number))); + SStrPack(buffer, value, size); + cursor++; + break; + } + + default: + error = 1; + SStrPack(buffer, "%", size); + break; + } + + start = cursor; + } + + SStrPack(buffer, start, size); + return error == 0; +} diff --git a/WoW/Source/Ui/CGWorldStateInfo.h b/WoW/Source/Ui/CGWorldStateInfo.h index d2b83d8..c2340c4 100644 --- a/WoW/Source/Ui/CGWorldStateInfo.h +++ b/WoW/Source/Ui/CGWorldStateInfo.h @@ -17,6 +17,7 @@ struct WorldStateUIEntry { }; int32_t GetWorldState(int32_t id); +bool WorldStateParseText(const char* text, char* buffer, uint32_t size); class CGWorldStateInfo { public: @@ -31,6 +32,7 @@ class CGWorldStateInfo { static int32_t GetUITime(); static void InitializeGame(); + static void ShutdownGame(); static bool InitWorldStates(uint32_t mapId, uint32_t zoneId, uint32_t areaId); static bool SetWorldState(uint32_t state, uint32_t value); static void OnUITime(uint32_t time); diff --git a/WoW/Source/Ui/CGWorldStateInfo_Scripts.cpp b/WoW/Source/Ui/CGWorldStateInfo_Scripts.cpp index b8dfdd5..06fdc39 100644 --- a/WoW/Source/Ui/CGWorldStateInfo_Scripts.cpp +++ b/WoW/Source/Ui/CGWorldStateInfo_Scripts.cpp @@ -3,6 +3,9 @@ #include "Engine/Source/FrameScript/FrameScript.h" #include "Engine/Source/FrameScript/FrameScript_Object.h" #include "Engine/Source/lua-5.1/src/lua.h" +#include "WoW/Source/DB/DBClient/DBClient.h" +#include "WoW/Source/DB/Rec/WorldStateUIRec.h" +#include "Engine/Source/lua-5.1/src/lauxlib.h" // VERIFY: f57c55c3 manual // OFFSET: 0x00548720 @@ -11,6 +14,51 @@ static int32_t Script_GetNumWorldStateUI(lua_State* L) { return 1; } +// VERIFY: 7bc72600 manual +// OFFSET: 0x00548D40 +int32_t Script_GetWorldStateUIInfo(lua_State* L) { + if (!lua_isnumber(L, 1)) { + luaL_error(L, "Usage: GetWorldStateUIInfo(index)"); + return 0; + } + + uint32_t index = static_cast(lua_tonumber(L, 1)); + int32_t id = index - 1 < CGWorldStateInfo::m_worldStateUI.m_count ? CGWorldStateInfo::m_worldStateUI.m_data[index - 1].m_id : 0; + WorldStateUIRec* rec = g_worldStateUIDB.GetRecord(id); + + if (!rec) { + lua_pushnumber(L, 0.0); + return 1; + } + + lua_pushnumber(L, rec->m_type); + double state; + + if (rec->m_stateVariable) { + WORLDSTATE* worldState = CGWorldStateInfo::m_worldStates.Ptr(rec->m_stateVariable, HASHKEY_NONE()); + state = worldState ? worldState->m_value : 0; + } else { + state = 1.0; + } + + lua_pushnumber(L, state); + char text[256]; + WorldStateParseText(rec->m_string, text, sizeof(text)); + lua_pushstring(L, text); + lua_pushstring(L, rec->m_icon); + lua_pushstring(L, rec->m_dynamicIcon); + lua_pushstring(L, rec->m_tooltip); + lua_pushstring(L, rec->m_dynamicTooltip); + lua_pushstring(L, rec->m_extendedUi); + + for (uint32_t i = 0; i < 3; i++) { + WORLDSTATE* worldState = CGWorldStateInfo::m_worldStates.Ptr(rec->m_extendedUistateVariable[i], HASHKEY_NONE()); + lua_pushnumber(L, worldState ? worldState->m_value : 0); + } + + return 11; +} + // STATIC: 0x00ACD0D0 static FrameScript_Method s_ScriptFunctions[] = { { "GetNumWorldStateUI", &Script_GetNumWorldStateUI }, diff --git a/WoW/Source/Ui/Calendar.cpp b/WoW/Source/Ui/Calendar.cpp index 74c9818..742a7d3 100644 --- a/WoW/Source/Ui/Calendar.cpp +++ b/WoW/Source/Ui/Calendar.cpp @@ -16,6 +16,7 @@ #include "WoW/Source/ObjectMgrClient/ObjectMgrClient.h" #include "WoW/Source/Ui/Types.h" #include "WoW/Source/WowSvcs/WowSvcsClient/FriendList.h" +#include "WoW/Source/Ui/CalendarEvent.h" // STATIC: 0x00AD0340 static TSList > s_pendingInvites; @@ -23,6 +24,21 @@ static TSList > s_pendin // STATIC: 0x00AD0350 static CalendarEventClipboard s_eventClipboard; +// STATIC: 0x00AD0328 +static TSList > s_holidays; + +// STATIC: 0x00AD0334 +static TSList > s_raidResets; + +// STATIC: 0x00C2080C +static CalendarDayInfo s_days[3][31]; + +// STATIC: 0x00C20DD8 +static CalendarEventTables s_eventTables; + +// STATIC: 0x00C20F38 +static TSHashTable s_dynamicHolidays; + // STATIC: 0x00C20F60 static TSFixedArray s_eventTextures[2]; @@ -204,3 +220,191 @@ uint32_t CGCalendar::CountPendingInvites() { return count > static_cast(CGCalendar::m_numInitialPending) ? count : CGCalendar::m_numInitialPending; } + +// VERIFY: 6c9627bd manual +// OFFSET: 0x005C3FE0 +int32_t PH_CALENDAR_GROUP(void* param, NETMESSAGE msgId, uint32_t time, CDataStore* msg) { + uint8_t clearPending = 1; + + switch (msgId) { + case SMSG_CALENDAR_SEND_CALENDAR: + PH_SMSG_CALENDAR_SEND_CALENDAR(msg); + break; + + case SMSG_CALENDAR_SEND_EVENT: + CGCalendar::ProcessGetEvent(msg); + break; + + case SMSG_CALENDAR_FILTER_GUILD: + case SMSG_CALENDAR_ARENA_TEAM: + CGCalendar::ProcessInitialInviteList(msg); + break; + + case SMSG_CALENDAR_EVENT_INVITE: + CGCalendar::ProcessInvite(msg, &clearPending); + + if (!clearPending) { + return 1; + } + + break; + + case SMSG_CALENDAR_EVENT_INVITE_REMOVED: + CGCalendar::ProcessInviteRemoved(msg, &clearPending); + + if (!clearPending) { + return 1; + } + + break; + + case SMSG_CALENDAR_EVENT_STATUS: + CGCalendar::ProcessInviteStatus(msg, &clearPending); + + if (!clearPending) { + return 1; + } + + break; + + case SMSG_CALENDAR_RAID_LOCKOUT_ADDED: + CGCalendar::ProcessLockoutAdded(msg); + break; + + case SMSG_CALENDAR_RAID_LOCKOUT_REMOVED: + CGCalendar::ProcessLockoutRemoved(msg); + break; + + case SMSG_CALENDAR_EVENT_INVITE_ALERT: + CGCalendar::ProcessInviteAlert(msg); + return 1; + + case SMSG_CALENDAR_EVENT_INVITE_REMOVED_ALERT: + CGCalendar::ProcessInviteRemovedAlert(msg); + return 1; + + case SMSG_CALENDAR_EVENT_INVITE_STATUS_ALERT: + CGCalendar::ProcessInviteStatusAlert(msg); + return 1; + + case SMSG_CALENDAR_EVENT_REMOVED_ALERT: + CGCalendar::ProcessEventRemovedAlert(msg, &clearPending); + + if (!clearPending) { + return 1; + } + + break; + + case SMSG_CALENDAR_EVENT_UPDATED_ALERT: + CGCalendar::ProcessEventUpdatedAlert(msg, &clearPending); + + if (!clearPending) { + return 1; + } + + break; + + case SMSG_CALENDAR_EVENT_MODERATOR_STATUS_ALERT: + CGCalendar::ProcessInviteModeratorStatusAlert(msg, &clearPending); + + if (!clearPending) { + return 1; + } + + break; + + case SMSG_CALENDAR_SEND_NUM_PENDING: + CGCalendar::UpdatePendingInvites(msg); + break; + + case SMSG_CALENDAR_EVENT_INVITE_NOTES: + CGCalendar::ProcessInviteNotes(msg, &clearPending); + + if (!clearPending) { + return 1; + } + + break; + + case SMSG_CALENDAR_EVENT_INVITE_NOTES_ALERT: + CGCalendar::ProcessInviteNotesAlert(msg); + return 1; + + case SMSG_CALENDAR_RAID_LOCKOUT_UPDATED: + CGCalendar::ProcessLockoutUpdated(msg); + break; + } + + CGCalendar::m_actionPending = 0; + FrameScript_SignalEvent(SCRIPT_EVENT_CALENDAR_ACTION_PENDING, "%b", 0); + return 1; +} + +// VERIFY: d895f606 manual +// OFFSET: 0x005BE220 +void CalendarEventTables::Clear() { + for (uint32_t i = 0; i < 8; i++) { + this->m_counts[i] = 0; + this->m_tables[i].InternalClear(0); + } +} + +// VERIFY: 4b509dcd manual +// OFFSET: 0x005BEAD0 +void CGCalendar::ShutdownGame() { + if (CGCalendar::m_curEvent) { + delete CGCalendar::m_curEvent; + } + + memset(&s_eventClipboard, 0, sizeof(s_eventClipboard)); + s_eventTables.Clear(); + s_holidays.Clear(); + s_raidResets.Clear(); + s_pendingInvites.Clear(); + s_dynamicHolidays.InternalClear(0); + + for (uint32_t month = 0; month < 3; month++) { + for (uint32_t day = 0; day < 31; day++) { + s_days[month][day].m_numEvents = 0; + } + } + + for (uint32_t i = 0; i < 2; i++) { + if (s_eventTextures[i].m_count) { + s_eventTextures[i].Clear(); + } + } + + ClientServices::ClearMessageHandler(SMSG_CALENDAR_SEND_CALENDAR); + ClientServices::ClearMessageHandler(SMSG_CALENDAR_SEND_EVENT); + ClientServices::ClearMessageHandler(SMSG_CALENDAR_EVENT_INVITE); + ClientServices::ClearMessageHandler(SMSG_CALENDAR_EVENT_INVITE_REMOVED); + ClientServices::ClearMessageHandler(SMSG_CALENDAR_EVENT_STATUS); + ClientServices::ClearMessageHandler(SMSG_CALENDAR_EVENT_INVITE_NOTES); + ClientServices::ClearMessageHandler(SMSG_CALENDAR_FILTER_GUILD); + ClientServices::ClearMessageHandler(SMSG_CALENDAR_ARENA_TEAM); + ClientServices::ClearMessageHandler(SMSG_CALENDAR_RAID_LOCKOUT_REMOVED); + ClientServices::ClearMessageHandler(SMSG_CALENDAR_RAID_LOCKOUT_ADDED); + ClientServices::ClearMessageHandler(SMSG_CALENDAR_RAID_LOCKOUT_UPDATED); + ClientServices::ClearMessageHandler(SMSG_CALENDAR_EVENT_INVITE_ALERT); + ClientServices::ClearMessageHandler(SMSG_CALENDAR_EVENT_INVITE_REMOVED_ALERT); + ClientServices::ClearMessageHandler(SMSG_CALENDAR_EVENT_INVITE_STATUS_ALERT); + ClientServices::ClearMessageHandler(SMSG_CALENDAR_EVENT_INVITE_NOTES_ALERT); + ClientServices::ClearMessageHandler(SMSG_CALENDAR_EVENT_REMOVED_ALERT); + ClientServices::ClearMessageHandler(SMSG_CALENDAR_EVENT_UPDATED_ALERT); + ClientServices::ClearMessageHandler(SMSG_CALENDAR_EVENT_MODERATOR_STATUS_ALERT); + ClientServices::ClearMessageHandler(SMSG_CALENDAR_SEND_NUM_PENDING); + ClientServices::ClearMessageHandler(SMSG_CALENDAR_CLEAR_PENDING_ACTION); +} + +// VERIFY: 24ff9070 auto +// OFFSET: 0x005B7CE0 +void CGCalendar::UpdatePendingInvites(CDataStore* msg) { + int32_t previous = CGCalendar::m_numInitialPending; + msg->Get(reinterpret_cast(CGCalendar::m_numInitialPending)); + + if (CGCalendar::m_numInitialPending != previous) { + FrameScript_SignalEvent(SCRIPT_EVENT_CALENDAR_UPDATE_PENDING_INVITES, nullptr); + } +} diff --git a/WoW/Source/Ui/Calendar.h b/WoW/Source/Ui/Calendar.h index 9d86c69..ccd9eba 100644 --- a/WoW/Source/Ui/Calendar.h +++ b/WoW/Source/Ui/Calendar.h @@ -17,6 +17,32 @@ struct CalendarEventClipboard { }; int32_t PH_CALENDAR_GROUP(void* param, NETMESSAGE msgId, uint32_t time, CDataStore* msg); +void PH_SMSG_CALENDAR_SEND_CALENDAR(CDataStore* msg); + +struct CALENDARHOLIDAYNODE : public TSLinkedNode { +}; + +struct CALENDARRAIDRESETNODE : public TSLinkedNode { +}; + +struct DYNAMICHOLIDAYHASH : public TSHashObject { +}; + +struct CALENDAREVENTHASH : public TSHashObject { +}; + +struct CalendarDayInfo { + /* 0000 */ int32_t m_numEvents; + /* 0004 */ uint32_t unk_0004[3]; +}; + +class CalendarEventTables { + public: + /* 0000 */ TSHashTable m_tables[8]; + /* 0140 */ int32_t m_counts[8]; + + void Clear(); +}; struct CalendarPendingInvite : public TSLinkedNode { /* 0008 */ uint8_t unk_0008[16]; @@ -38,8 +64,26 @@ class CGCalendar { static void EnterWorld(); static void InitializeGame(); + static void ShutdownGame(); static void QueryPendingInvites(); static void SetFilter(CVar* var, int32_t value); + static void ProcessGetEvent(CDataStore* msg); + static void ProcessInitialInviteList(CDataStore* msg); + static void ProcessInvite(CDataStore* msg, uint8_t* clearPending); + static void ProcessInviteRemoved(CDataStore* msg, uint8_t* clearPending); + static void ProcessInviteStatus(CDataStore* msg, uint8_t* clearPending); + static void ProcessLockoutAdded(CDataStore* msg); + static void ProcessLockoutRemoved(CDataStore* msg); + static void ProcessLockoutUpdated(CDataStore* msg); + static void ProcessInviteAlert(CDataStore* msg); + static void ProcessInviteRemovedAlert(CDataStore* msg); + static void ProcessInviteStatusAlert(CDataStore* msg); + static void ProcessEventRemovedAlert(CDataStore* msg, uint8_t* clearPending); + static void ProcessEventUpdatedAlert(CDataStore* msg, uint8_t* clearPending); + static void ProcessInviteModeratorStatusAlert(CDataStore* msg, uint8_t* clearPending); + static void ProcessInviteNotes(CDataStore* msg, uint8_t* clearPending); + static void ProcessInviteNotesAlert(CDataStore* msg); + static void UpdatePendingInvites(CDataStore* msg); }; int32_t Script_CalendarGetMinDate(lua_State* L); diff --git a/WoW/Source/Ui/CalendarEvent.h b/WoW/Source/Ui/CalendarEvent.h index edd2699..bbff4e7 100644 --- a/WoW/Source/Ui/CalendarEvent.h +++ b/WoW/Source/Ui/CalendarEvent.h @@ -53,6 +53,8 @@ class CGCalendarEvent { /* 054C */ uint32_t unk_054C; /* 0550 */ uint8_t unk_0550[3760]; /* 1400 */ uint8_t unk_1400; + + ~CGCalendarEvent(); }; #endif diff --git a/WoW/Source/Ui/ChatFrame.cpp b/WoW/Source/Ui/ChatFrame.cpp index 46fcce4..0622e5f 100644 --- a/WoW/Source/Ui/ChatFrame.cpp +++ b/WoW/Source/Ui/ChatFrame.cpp @@ -38,6 +38,7 @@ #include "WoW/Source/WowSvcs/WowSvcsClient/ClientServices.h" #include "WoW/Source/WowSvcs/WowSvcsClient/FriendList.h" #include "Engine/Source/Tempest/CMath.h" +#include "WoW/Source/WowSvcs/WowSvcsClient/AccountData.h" // STATIC: 0x00BCEFEC int32_t CGChat::m_afk; @@ -215,7 +216,7 @@ TSExplicitList CGChat::s_pendingChat; static int32_t s_chatLogging[2]; // STATIC: 0x00B759D8 -static HSLOG s_chatLog; +static HSLOG s_chatLog[2]; // STATIC: 0x00B75A60 ChatRecord CGChat::m_chatHistory[60]; @@ -357,6 +358,9 @@ int32_t CGChat::m_complaintsSystemStatus; // STATIC: 0x00BCF010 static uint32_t s_joinedZoneChannels; +// STATIC: 0x00BCF014 +static uint32_t s_numSavedInstances; + // STATIC: 0x00BCF09C TSGrowableArray s_channelColors; @@ -405,6 +409,9 @@ static TSGrowableArray s_pendingChannelFlags; // STATIC: 0x00BCFAD0 static TSGrowableArray s_pendingChannelNumbers; +// STATIC: 0x00BCFAE0 +static TSGrowableArray s_savedInstances; + // VERIFY: 36ed0e4f auto // OFFSET: 0x004FBAF0 int32_t CGChat::IsVoiceChatAllowed() { @@ -956,7 +963,7 @@ bool SpamFilter(char* text, bool cache) { return spam; } -// VERIFY: fe4a88da manual +// VERIFY: 812184e4 manual // OFFSET: 0x00509DD0 void CGChat::AddChatMessage(const char* text, int32_t type, const char* senderName, uint32_t language, const char* channelName, const char* targetName, const char* flags, WOWGUID senderGuid, uint32_t senderUnk, WOWGUID targetGuid, int32_t achievementID, bool isGM, const ChatConversation* conversation) { if (type >= CHAT_MSG_MAX) { @@ -1282,36 +1289,36 @@ emoteDone: channelPrefix[0] = 0; } - SLogWrite(s_chatLog, "%s%s", channelPrefix, translated); + SLogWrite(s_chatLog[0], "%s%s", channelPrefix, translated); return; } case CHAT_MSG_CHANNEL_NOTICE: case CHAT_MSG_CHANNEL_NOTICE_USER: { SStrPrintf(token, sizeof(token), "CHAT_%s_NOTICE", translated); - SLogWrite(s_chatLog, FrameScript_GetText(token, -1, GENDER_NOT_APPLICABLE), channelString, senderName, targetName); + SLogWrite(s_chatLog[0], FrameScript_GetText(token, -1, GENDER_NOT_APPLICABLE), channelString, senderName, targetName); return; } case CHAT_MSG_IGNORED: { - SLogWrite(s_chatLog, FrameScript_GetText("CHAT_IGNORED", -1, GENDER_NOT_APPLICABLE), senderName); + SLogWrite(s_chatLog[0], FrameScript_GetText("CHAT_IGNORED", -1, GENDER_NOT_APPLICABLE), senderName); return; } case CHAT_MSG_FILTERED: { - SLogWrite(s_chatLog, FrameScript_GetText("CHAT_FILTERED", -1, GENDER_NOT_APPLICABLE), senderName); + SLogWrite(s_chatLog[0], FrameScript_GetText("CHAT_FILTERED", -1, GENDER_NOT_APPLICABLE), senderName); return; } case CHAT_MSG_RESTRICTED: { - SLogWrite(s_chatLog, FrameScript_GetText("CHAT_RESTRICTED", -1, GENDER_NOT_APPLICABLE)); + SLogWrite(s_chatLog[0], FrameScript_GetText("CHAT_RESTRICTED", -1, GENDER_NOT_APPLICABLE)); return; } case CHAT_MSG_BN_CONVERSATION_NOTICE: { char noticeToken[128]; SStrPrintf(noticeToken, sizeof(noticeToken), "CHAT_CONVERSATION_%s_NOTICE", translated); - SLogWrite(s_chatLog, FrameScript_GetText(noticeToken, -1, GENDER_NOT_APPLICABLE), channelString, senderName); + SLogWrite(s_chatLog[0], FrameScript_GetText(noticeToken, -1, GENDER_NOT_APPLICABLE), channelString, senderName); return; } @@ -1400,7 +1407,7 @@ emoteDone: } *dest = 0; - SLogWrite(s_chatLog, line, senderName ? senderName : ""); + SLogWrite(s_chatLog[0], line, senderName ? senderName : ""); return; } } @@ -3114,7 +3121,7 @@ bool InebriatedParseText(const char* text, char* buffer, uint32_t size, float dr return true; } -// VERIFY: f7ebdad8 manual +// VERIFY: ea4fbe56 manual // OFFSET: 0x00503660 void CGChat::AddTextEmoteMessage(const WOWGUID& guid, uint32_t emote, const char* target, uint32_t emoteNum) { if (!target) { @@ -3209,7 +3216,7 @@ void CGChat::AddTextEmoteMessage(const WOWGUID& guid, uint32_t emote, const char FrameScript_SignalEvent(SCRIPT_EVENT_CHAT_MSG_TEXT_EMOTE, "%s%s%s%s%s%s%d%d%s%d%d%s%u", buffer, sender->m_name, languageName, "", "", "", 0, 0, "", 0, 0, guidString, 0); if (s_chatLogging[0]) { - SLogWrite(s_chatLog, "%s", buffer); + SLogWrite(s_chatLog[0], "%s", buffer); } } @@ -3919,7 +3926,7 @@ int32_t CGChat::IsChatLogging(int32_t type) { return s_chatLogging[type]; } -// VERIFY: 13db2022 auto +// VERIFY: c767ca52 auto // OFFSET: 0x004FB3C0 void CGChat::AddCombatMessage(const char* text) { if (!text) { @@ -3928,7 +3935,7 @@ void CGChat::AddCombatMessage(const char* text) { } if (s_chatLogging[1]) { - SLogWrite(s_chatLog, "%s", text); + SLogWrite(s_chatLog[1], "%s", text); } } @@ -4874,3 +4881,307 @@ int32_t FormatTime(char* buffer, uint32_t size, int32_t seconds) { int32_t minutes = (seconds - 3600 * (hours + 24 * days)) / 60; return SStrPrintf(buffer, size, "%dd %dh %dm %ds", days, hours, minutes, seconds % 60); } + +// VERIFY: 55b356a1 manual +// OFFSET: 0x00501030 +int32_t CGChat::OnRaidInstanceInfo(void* param, NETMESSAGE msgId, uint32_t time, CDataStore* msg) { + uint32_t count; + msg->Get(count); + + if (count) { + if (count >= s_savedInstances.Count()) { + s_savedInstances.SetCount(count); + } + + for (uint32_t i = 0; i < count; i++) { + RaidInstanceInfo& info = s_savedInstances.m_data[i]; + msg->Get(info.m_mapID); + msg->Get(info.m_difficulty); + msg->Get(info.m_instanceID); + uint8_t locked = 0; + msg->Get(locked); + info.m_locked = locked; + uint8_t extended = 0; + msg->Get(extended); + info.m_extended = extended; + msg->Get(info.m_resetTime); + } + } + + s_numSavedInstances = count; + FrameScript_SignalEvent(SCRIPT_EVENT_UPDATE_INSTANCE_INFO, nullptr); + return 1; +} + +// VERIFY: 7fc804e5 manual +// OFFSET: 0x005019D0 +void ChatWindowInfo::Reset() { + for (uint32_t i = 0; i < this->m_channels.m_count; i++) { + if (this->m_channels.m_data[i]) { + SMemFree(this->m_channels.m_data[i], __FILE__, __LINE__, 0); + } + + this->m_channels.m_data[i] = nullptr; + } + + this->m_channels.Clear(); + this->m_channelIDs.Clear(); +} + +// VERIFY: 9faa2cc3 manual +// OFFSET: 0x005072B0 +void CGChat::ShutdownGame() { + for (uint32_t i = 0; i < 2; i++) { + if (s_chatLog[i]) { + SLogClose(s_chatLog[i]); + } + + s_chatLog[i] = nullptr; + s_chatLogging[i] = 0; + } + + s_wordLists.Clear(); + s_profanityCache.Clear(); + s_spamCache.Clear(); + CGChat::s_pendingChat.Clear(); + CGChat::s_channels.SetCount(0); + s_channelColors.Clear(); + + for (uint32_t i = 0; i < 10; i++) { + s_chatWindows[i].Reset(); + } + + for (uint32_t i = 0; i < s_pendingChannelNames.m_count; i++) { + if (s_pendingChannelNames.m_data[i]) { + SMemFree(s_pendingChannelNames.m_data[i], __FILE__, __LINE__, 0); + } + } + + s_pendingChannelNames.Clear(); + s_pendingChannelFlags.Clear(); + s_pendingChannelNumbers.Clear(); + s_numSavedInstances = 0; + s_savedInstances.Clear(); + s_channelThrottle.Clear(); + CGChat::s_throttledChat.Clear(); + ClientServices::ClearMessageHandler(SMSG_CHANNEL_NOTIFY); + ClientServices::ClearMessageHandler(SMSG_CHANNEL_LIST); + ClientServices::ClearMessageHandler(SMSG_CHAT); + ClientServices::ClearMessageHandler(SMSG_TEXT_EMOTE); + ClientServices::ClearMessageHandler(SMSG_ZONE_UNDER_ATTACK); + ClientServices::ClearMessageHandler(SMSG_DEFENSE_MESSAGE); + ClientServices::ClearMessageHandler(SMSG_CHAT_SERVER_MESSAGE); + ClientServices::ClearMessageHandler(SMSG_RAID_INSTANCE_INFO); + ClientServices::ClearMessageHandler(SMSG_RAID_INSTANCE_MESSAGE); + ClientServices::ClearMessageHandler(SMSG_INSTANCE_RESET); + ClientServices::ClearMessageHandler(SMSG_INSTANCE_RESET_FAILED); + ClientServices::ClearMessageHandler(SMSG_UPDATE_LAST_INSTANCE); + ClientServices::ClearMessageHandler(SMSG_UPDATE_INSTANCE_OWNERSHIP); + ClientServices::ClearMessageHandler(SMSG_EXPECTED_SPAM_RECORDS); + ClientServices::ClearMessageHandler(SMSG_TITLE_EARNED); + ClientServices::ClearMessageHandler(SMSG_RESET_FAILED_NOTIFY); + ClientServices::ClearMessageHandler(SMSG_GM_MESSAGECHAT); + ClientServices::ClearMessageHandler(SMSG_LOG_XP_GAIN); + ClientServices::ClearMessageHandler(SMSG_DURABILITY_DAMAGE_DEATH); + ClientServices::ClearMessageHandler(SMSG_CHANNEL_MEMBER_COUNT); + ClientServices::ClearMessageHandler(SMSG_COMSAT_RECONNECT_TRY); + ClientServices::ClearMessageHandler(SMSG_COMSAT_DISCONNECT); + ClientServices::ClearMessageHandler(SMSG_COMSAT_CONNECT_FAIL); + ClientServices::ClearMessageHandler(SMSG_VOICE_CHAT_STATUS); + ClientServices::ClearMessageHandler(SMSG_USERLIST_ADD); + ClientServices::ClearMessageHandler(SMSG_USERLIST_REMOVE); + ClientServices::ClearMessageHandler(SMSG_USERLIST_UPDATE); + ClientServices::ClearMessageHandler(SMSG_VOICESESSION_FULL); + ClientServices::ClearMessageHandler(SMSG_SERVER_FIRST_ACHIEVEMENT); +} + +// VERIFY: f304335d manual +// OFFSET: 0x00500380 +int32_t CGChat::OnUserListUpdate(void* param, NETMESSAGE msgId, uint32_t time, CDataStore* msg) { + WOWGUID guid; + uint8_t memberFlags; + uint8_t channelFlags; + uint32_t count; + char channelName[128]; + msg->Get(guid.m_guid); + msg->Get(memberFlags); + msg->Get(channelFlags); + msg->Get(count); + msg->GetString(channelName, sizeof(channelName)); + + if (s_activeDisplayChannelType || SStrCmpUTF8I(channelName, CGChat::s_activeDisplayChannelName, STORM_MAX_STR)) { + msg->m_read = msg->m_size; + return 1; + } + + uint32_t displayIndex = CGChat::FindDisplayChannelIndex(channelName, 0); + + if (displayIndex) { + ChatChannel* channel = &CGChat::s_channels.m_data[CGChat::s_displayChannels[displayIndex - 1].m_channelIndex]; + + if (channel->m_flags != channelFlags) { + channel->m_flags = channelFlags; + FrameScript_SignalEvent(SCRIPT_EVENT_CHANNEL_FLAGS_UPDATED, "%d", displayIndex); + } + } + + for (uint32_t i = 0; i < s_pendingUsers.m_count; i++) { + PENDINGUSERLIST* user = &s_pendingUsers.m_data[i]; + + if (user->m_guid != guid) { + continue; + } + + user->m_flags = memberFlags; + + if (ComSatClient_IsMemberInVoiceSession(user->m_guid, 0, channelName)) { + user->m_flags |= 0x40; + } + + if (ComSatClient_Unk7DB830(user->m_guid, 0, channelName)) { + user->m_flags |= 0x80; + } + + if (ComSatClient_IsPlayerMuted(user->m_guid) || ComSatClient_IsTalkerSquelchedInChannel(user->m_guid, 0, channelName)) { + user->m_flags |= 0x20; + } + + if (displayIndex) { + CGChat::s_displayChannels[displayIndex - 1].m_count = s_pendingUsers.m_count; + FrameScript_SignalEvent(SCRIPT_EVENT_CHANNEL_COUNT_UPDATE, "%d%d", displayIndex, s_pendingUsers.m_count); + FrameScript_SignalEvent(SCRIPT_EVENT_CHANNEL_ROSTER_UPDATE, "%d%d", displayIndex, s_pendingUsers.m_count); + } + + break; + } + + return 1; +} + +// VERIFY: e9ce2aa4 manual +// OFFSET: 0x004FD300 +void CGChat::SaveChatSettingsCallback(HOSFILE localFile, HOSFILE file, void* param) { + if (file == OS_INVALID_FILE) { + return; + } + + uint32_t written = 0; + char line[256]; + SStrPrintf(line, sizeof(line), "VERSION %d\n\n", 5); + OsWriteFile(file, line, SStrLen(line), &written); + SStrPrintf(line, sizeof(line), "ADDEDVERSION %d\n\n", 13); + OsWriteFile(file, line, SStrLen(line), &written); + SStrPrintf(line, sizeof(line), "%s %s\n\n", s_guildRecruitmentOption, CGChat::m_guildRecruitmentMode == 1 ? "AUTO" : "STANDARD"); + OsWriteFile(file, line, SStrLen(line), &written); + OsWriteFile(file, "CHANNELS\n", SStrLen("CHANNELS\n"), &written); + + for (uint32_t i = 0; i < CGChat::s_channels.m_count; i++) { + ChatChannel* channel = &CGChat::s_channels.m_data[i]; + + if (channel->m_channelNumber && !channel->m_unk9C && !channel->m_zoneChannelID && channel->m_unkA5) { + SStrPrintf(line, sizeof(line), "%s %d %d\n", channel->m_name, channel->m_unkA4 != 0, channel->m_channelNumber); + OsWriteFile(file, line, SStrLen(line), &written); + } + } + + OsWriteFile(file, "END\n\n", SStrLen("END\n\n"), &written); + SStrPrintf(line, sizeof(line), "ZONECHANNELS %d\n\n", s_joinedZoneChannels); + OsWriteFile(file, line, SStrLen(line), &written); + OsWriteFile(file, "COLORS\n", SStrLen("COLORS\n"), &written); + + for (uint32_t i = 0; i < CHAT_MSG_MAX; i++) { + ChatColorInfo* color = &s_chatColors[i]; + + if (color->m_name[0]) { + SStrPrintf(line, sizeof(line), "%s %d %d %d %c\n", color->m_name, color->m_color[0], color->m_color[1], color->m_color[2], color->m_unk48 ? 'Y' : 'N'); + OsWriteFile(file, line, SStrLen(line), &written); + } + } + + for (uint32_t i = 0; i < s_channelColors.m_count; i++) { + ChatColorInfo* color = &s_channelColors.m_data[i]; + + if (color->m_name[0]) { + SStrPrintf(line, sizeof(line), "%s %d %d %d %c\n", color->m_name, color->m_color[0], color->m_color[1], color->m_color[2], color->m_unk48 ? 'Y' : 'N'); + OsWriteFile(file, line, SStrLen(line), &written); + } + } + + OsWriteFile(file, "END\n\n", SStrLen("END\n\n"), &written); + + for (uint32_t w = 0; w < 10; w++) { + ChatWindowInfo* info = &s_chatWindows[w]; + SStrPrintf(line, sizeof(line), "WINDOW %d\n", w + 1); + OsWriteFile(file, line, SStrLen(line), &written); + + if (info->m_name[0]) { + SStrPrintf(line, sizeof(line), "NAME %s\n", info->m_name); + OsWriteFile(file, line, SStrLen(line), &written); + } + + SStrPrintf(line, sizeof(line), "SIZE %d\n", info->m_unkD0); + OsWriteFile(file, line, SStrLen(line), &written); + SStrPrintf(line, sizeof(line), "COLOR %d %d %d %d\n", info->m_color.r, info->m_color.g, info->m_color.b, info->m_color.a); + OsWriteFile(file, line, SStrLen(line), &written); + SStrPrintf(line, sizeof(line), "LOCKED %d\n", info->m_unkD8 != 0); + OsWriteFile(file, line, SStrLen(line), &written); + SStrPrintf(line, sizeof(line), "UNINTERACTABLE %d\n", info->m_unkE4 != 0); + OsWriteFile(file, line, SStrLen(line), &written); + SStrPrintf(line, sizeof(line), "DOCKED %d\n", info->m_docked); + OsWriteFile(file, line, SStrLen(line), &written); + SStrPrintf(line, sizeof(line), "SHOWN %d\n", info->m_shown != 0); + OsWriteFile(file, line, SStrLen(line), &written); + + if (info->m_unkF4) { + SStrPrintf(line, sizeof(line), "POSITION %s %f %f\n", FramePointToString(static_cast(info->m_unkE8)), info->m_unkEC, info->m_unkF0); + OsWriteFile(file, line, SStrLen(line), &written); + SStrPrintf(line, sizeof(line), "DIMENSIONS %f %f\n\n", info->m_width, info->m_height); + OsWriteFile(file, line, SStrLen(line), &written); + } + + OsWriteFile(file, "MESSAGES\n", SStrLen("MESSAGES\n"), &written); + + for (uint32_t i = 0; i < 46; i++) { + if (info->m_messageGroups[i]) { + SStrPrintf(line, sizeof(line), "%s\n", s_chatMessageGroups[i].m_name); + OsWriteFile(file, line, SStrLen(line), &written); + } + } + + OsWriteFile(file, "END\n\n", SStrLen("END\n\n"), &written); + OsWriteFile(file, "CHANNELS\n", SStrLen("CHANNELS\n"), &written); + uint32_t zoneChannels = 0; + + for (uint32_t i = 0; i < info->m_channels.m_count; i++) { + if (!info->m_channels.m_data[i]) { + continue; + } + + int32_t channelId = info->m_channelIDs.m_data[i]; + + if (channelId) { + zoneChannels |= 1 << (channelId - 1); + } + + for (uint32_t j = 0; j < CGChat::s_channels.m_count; j++) { + if (!SStrCmpUTF8I(CGChat::s_channels.m_data[j].m_name, info->m_channels.m_data[i], STORM_MAX_STR) && !CGChat::s_channels.m_data[j].m_unkA0) { + SStrPrintf(line, sizeof(line), "%s\n", info->m_channels.m_data[i]); + OsWriteFile(file, line, SStrLen(line), &written); + break; + } + } + } + + OsWriteFile(file, "END\n\n", SStrLen("END\n\n"), &written); + SStrPrintf(line, sizeof(line), "ZONECHANNELS %d\n\n", zoneChannels & s_joinedZoneChannels); + OsWriteFile(file, line, SStrLen(line), &written); + OsWriteFile(file, "END\n\n", SStrLen("END\n\n"), &written); + } +} + +// VERIFY: 86438221 auto +// OFFSET: 0x004FFDA0 +void CGChat::SaveChatSettings() { + s_chatSettingsDirty = 0; + SaveAccountData(7, CGChat::SaveChatSettingsCallback, nullptr); +} diff --git a/WoW/Source/Ui/ChatFrame.h b/WoW/Source/Ui/ChatFrame.h index 34a2c7c..7f990fd 100644 --- a/WoW/Source/Ui/ChatFrame.h +++ b/WoW/Source/Ui/ChatFrame.h @@ -80,6 +80,16 @@ enum SLASH_COMMAND_ID { CHAT_MSG_MAX = 62, }; +struct RaidInstanceInfo { + /* 0000 */ uint32_t m_mapID; + /* 0004 */ uint32_t m_difficulty; + /* 0008 */ uint64_t m_instanceID; + /* 0010 */ uint32_t m_locked; + /* 0014 */ uint32_t m_extended; + /* 0018 */ uint32_t m_resetTime; + /* 001C */ uint32_t unk_001C; +}; + struct ChatConversation { /* 0000 */ uint8_t m_index; /* 0004 */ uint32_t m_presenceID; @@ -234,6 +244,7 @@ class ChatWindowInfo { void AddChannel(const char* name, int32_t id); void Init(); void RemoveChannel(const char* name); + void Reset(); }; struct ChatRecord { @@ -260,14 +271,17 @@ int32_t Packet_SMSG_LOG_XPGAIN(void* param, NETMESSAGE msgId, uint32_t time, CDa class CGChat { public: + static void SaveChatSettings(); static void ZoneUpdate(); static void ProcessPendingChatQueue(); static void LogReactionChanged(int32_t faction, int32_t reaction); static void LogFactionChanged(int32_t faction, int32_t delta, int32_t generic, float bonus); static void EnterWorld(); static void InitializeGame(); + static void ShutdownGame(); static void LoadChatSettings(); static void LoadChatSettingsCallback(HOSFILE localFile, HOSFILE file, void* param); + static void SaveChatSettingsCallback(HOSFILE localFile, HOSFILE file, void* param); static const char* GetChannelString(const char* name); static bool ChatTokenToGUID(const char* token, WOWGUID& guid); static CImVector GetChatColor(int32_t type); diff --git a/WoW/Source/Ui/ClassTrainerFrame.cpp b/WoW/Source/Ui/ClassTrainerFrame.cpp index f8e4891..cec8107 100644 --- a/WoW/Source/Ui/ClassTrainerFrame.cpp +++ b/WoW/Source/Ui/ClassTrainerFrame.cpp @@ -456,3 +456,19 @@ void CGClassTrainer::RefreshList() { CGClassTrainer::FilterAndSortServices(); FrameScript_SignalEvent(SCRIPT_EVENT_TRAINER_UPDATE, nullptr); } + +// VERIFY: a07b4562 manual +// OFFSET: 0x005963C0 +void CGClassTrainer::ShutdownGame() { + for (uint32_t i = 0; i < CGClassTrainer::m_services.m_count; i++) { + delete CGClassTrainer::m_services.m_data[i]; + } + + CGClassTrainer::m_services.m_count = 0; + + for (uint32_t i = 0; i < CGClassTrainer::m_skillLines.m_count; i++) { + delete CGClassTrainer::m_skillLines.m_data[i]; + } + + CGClassTrainer::m_skillLines.m_count = 0; +} diff --git a/WoW/Source/Ui/ClassTrainerFrame.h b/WoW/Source/Ui/ClassTrainerFrame.h index 542b3a0..338bd3b 100644 --- a/WoW/Source/Ui/ClassTrainerFrame.h +++ b/WoW/Source/Ui/ClassTrainerFrame.h @@ -35,6 +35,7 @@ struct TrainerSkillLineInfo { class CGClassTrainer { public: + static void ShutdownGame(); static WOWGUID m_trainer; static char m_greetingText[2048]; static int32_t m_trainerType; diff --git a/WoW/Source/Ui/CommentatorFrame.cpp b/WoW/Source/Ui/CommentatorFrame.cpp index 01ee645..1a53a79 100644 --- a/WoW/Source/Ui/CommentatorFrame.cpp +++ b/WoW/Source/Ui/CommentatorFrame.cpp @@ -177,3 +177,13 @@ void CGCommentator::PostInit(CGPlayer_C* player) { FrameScript_SignalEvent(SCRIPT_EVENT_COMMENTATOR_ENTER_WORLD, nullptr); } + +// VERIFY: acad482e auto +// OFFSET: 0x00568340 +void CGCommentator::ShutdownGame() { + ClientServices::ClearMessageHandler(SMSG_COMMENTATOR_PLAYER_INFO); + ClientServices::ClearMessageHandler(SMSG_COMMENTATOR_MAP_INFO); + ClientServices::ClearMessageHandler(SMSG_COMMENTATOR_STATE_CHANGED); + ClientServices::ClearMessageHandler(SMSG_COMMENTATOR_SKIRMISH_QUEUE_RESULT1); + ClientServices::ClearMessageHandler(SMSG_COMMENTATOR_SKIRMISH_QUEUE_RESULT2); +} diff --git a/WoW/Source/Ui/CommentatorFrame.h b/WoW/Source/Ui/CommentatorFrame.h index 7132918..b3e49a3 100644 --- a/WoW/Source/Ui/CommentatorFrame.h +++ b/WoW/Source/Ui/CommentatorFrame.h @@ -37,6 +37,7 @@ class CGCommentator { static CGCommentator s_Commentator; static void InitializeGame(); + static void ShutdownGame(); static void RegisterScriptFunctions(); /* 0000 */ float m_facing; diff --git a/WoW/Source/Ui/CurrencyTypes.cpp b/WoW/Source/Ui/CurrencyTypes.cpp index 1d59cb1..94059df 100644 --- a/WoW/Source/Ui/CurrencyTypes.cpp +++ b/WoW/Source/Ui/CurrencyTypes.cpp @@ -294,3 +294,52 @@ CurrencyTypesRec* CGCurrencyTypes::GetBackpackCurrencyInfo(int32_t index) { return nullptr; } + +// VERIFY: 6cfe7d42 auto +// OFFSET: 0x005EEB70 +void CGCurrencyTypes::ShutdownGame() { +} + +// VERIFY: 01c6b2ac manual +// OFFSET: 0x005AFFD0 +CurrencyTypesRec* CGCurrencyTypes::GetCurrencyRec(int32_t index) { + if (index < 0 || index >= CGCurrencyTypes::m_listSize) { + return nullptr; + } + + for (int32_t i = 0; i < g_currencyTypesDB.m_numRecords; i++) { + CurrencyTypesRec* rec = &g_currencyTypesDB.m_records[i]; + + if (rec->m_itemID == CGCurrencyTypes::m_list[index].m_itemID) { + return rec; + } + } + + return nullptr; +} + +// VERIFY: 86e21a80 manual +// OFFSET: 0x005B04F0 +int32_t CGCurrencyTypes::IsCurrencyShown(int32_t index) { + if (index < 0 || index >= CGCurrencyTypes::m_listSize) { + return 0; + } + + if (CGCurrencyTypes::m_list[index].m_isHeader) { + return CGCurrencyTypes::m_list[index].m_categoryID == CGCurrencyTypes::m_categories[CGCurrencyTypes::m_numCategories - 1].m_id; + } + + CurrencyTypesRec* rec = CGCurrencyTypes::GetCurrencyRec(index); + + if (!rec) { + return 0; + } + + int32_t bit = rec->m_bitIndex; + + if (bit > 32) { + return (g_currencyTokensUnused2CVar->m_intValue & (1 << (bit - 33))) != 0; + } + + return bit > 0 && (g_currencyTokensUnused1CVar->m_intValue & (1 << (bit - 1))) != 0; +} diff --git a/WoW/Source/Ui/CurrencyTypes.h b/WoW/Source/Ui/CurrencyTypes.h index 8b2adeb..db1fd1e 100644 --- a/WoW/Source/Ui/CurrencyTypes.h +++ b/WoW/Source/Ui/CurrencyTypes.h @@ -25,6 +25,8 @@ class CurrencyTypesRec; class CGCurrencyTypes { public: + static CurrencyTypesRec* GetCurrencyRec(int32_t index); + static int32_t IsCurrencyShown(int32_t index); static int32_t m_listSize; static CurrencyListEntry m_list[95]; static CurrencyCategoryInfo m_categories[32]; @@ -35,6 +37,7 @@ class CGCurrencyTypes { static int32_t CurrencyCategorySortCallback(const void* a, const void* b); static int32_t DisplayListSortCallback(const void* a, const void* b); static void InitializeGame(); + static void ShutdownGame(); static void EnterWorld(); }; diff --git a/WoW/Source/Ui/CurrencyTypes_Scripts.cpp b/WoW/Source/Ui/CurrencyTypes_Scripts.cpp index 24f6c52..40e3b97 100644 --- a/WoW/Source/Ui/CurrencyTypes_Scripts.cpp +++ b/WoW/Source/Ui/CurrencyTypes_Scripts.cpp @@ -93,6 +93,93 @@ static int32_t Script_GetBackpackCurrencyInfo(lua_State* L) { return 5; } +// VERIFY: cae29f5c manual +// OFFSET: 0x005B0680 +int32_t Script_GetCurrencyListInfo(lua_State* L) { + if (!lua_isnumber(L, 1)) { + luaL_error(L, "Usage: GetCurrencyListInfo(index)"); + } + + int32_t index = static_cast(lua_tonumber(L, 1)) - 1; + + if (index < 0 || index >= CGCurrencyTypes::m_listSize) { + lua_pushnil(L); + lua_pushnil(L); + lua_pushnil(L); + lua_pushnil(L); + lua_pushnil(L); + lua_pushnil(L); + lua_pushnil(L); + lua_pushnil(L); + lua_pushnil(L); + return 9; + } + + CurrencyListEntry* entry = &CGCurrencyTypes::m_list[index]; + + if (entry->m_name) { + lua_pushstring(L, entry->m_name); + } else { + lua_pushnil(L); + } + + lua_pushboolean(L, entry->m_isHeader); + lua_pushboolean(L, entry->m_isExpanded); + lua_pushboolean(L, CGCurrencyTypes::IsCurrencyShown(index)); + lua_pushboolean(L, entry->m_isWatched); + CGPlayer_C* player = static_cast(ClntObjMgrObjectPtr(ClntObjMgrGetActivePlayer(), TYPEMASK_PLAYER, __FILE__, __LINE__)); + + if (player) { + uint32_t count = 0; + int32_t extraCurrencyType = 0; + + if (entry->m_itemID == 43307) { + count = player->m_player->m_playerFieldArenaCurrency; + extraCurrencyType = 1; + } else if (entry->m_itemID == 43308) { + count = player->m_player->m_playerFieldHonorCurrency; + extraCurrencyType = 2; + } else { + CGBag_C* bag = player->GetBag(); + + if (bag) { + for (uint32_t slot = 118; slot <= 149; slot++) { + WOWGUID itemGuid; + itemGuid.m_guid = bag->GetItemGuid(slot); + CGItem_C* item = static_cast(ClntObjMgrObjectPtr(itemGuid, TYPEMASK_ITEM, __FILE__, __LINE__)); + + if (item && static_cast(item->m_obj->m_entryID) == entry->m_itemID) { + count = item->m_item->m_itemFieldStackCount; + break; + } + } + } + } + + lua_pushnumber(L, count); + lua_pushinteger(L, extraCurrencyType); + } else { + lua_pushnumber(L, 0.0); + lua_pushboolean(L, 0); + } + + WOWGUID none = WOWGUID(); + ItemStats_C* stats = g_itemDBCache.GetRecord(entry->m_itemID, none, nullptr, nullptr, false); + + if (stats) { + const char* path = ClientDBStringLookup(3); + char texture[260]; + SStrPrintf(texture, sizeof(texture), "%s%s%s", path, *path ? "\\" : "", CGItem_C::GetInventoryArt(stats->m_displayId)); + lua_pushstring(L, texture); + } else { + lua_pushnil(L); + } + + lua_pushinteger(L, entry->m_itemID); + + return 9; +} + // STATIC: 0x00ACFC34 static FrameScript_Method s_ScriptFunctions[] = { { "GetCurrencyListSize", &Script_GetCurrencyListSize }, diff --git a/WoW/Source/Ui/DanceStudio.cpp b/WoW/Source/Ui/DanceStudio.cpp index 92c465e..4cbd6fa 100644 --- a/WoW/Source/Ui/DanceStudio.cpp +++ b/WoW/Source/Ui/DanceStudio.cpp @@ -5,6 +5,9 @@ // STATIC: 0x00BEB630 uint64_t CGDanceStudio::m_learnedDanceMoves; +// STATIC: 0x00BEB638 +static TSHashTable s_knownDances; + // VERIFY: 166fac44 auto // OFFSET: 0x00576A90 void CGDanceStudio::InitializeGame() { @@ -20,3 +23,13 @@ int32_t Packet_SMSG_LEARNED_DANCE_MOVES(void* param, NETMESSAGE msgId, uint32_t msg->Get(CGDanceStudio::m_learnedDanceMoves); return 1; } + +// VERIFY: 02b8c154 auto +// OFFSET: 0x00575F20 +void CGDanceStudio::ShutdownGame() { + ClientServices::ClearMessageHandler(SMSG_PLAY_DANCE); + ClientServices::ClearMessageHandler(SMSG_STOP_DANCE); + ClientServices::ClearMessageHandler(SMSG_NOTIFY_DANCE); + ClientServices::ClearMessageHandler(SMSG_LEARNED_DANCE_MOVES); + s_knownDances.InternalClear(0); +} diff --git a/WoW/Source/Ui/DanceStudio.h b/WoW/Source/Ui/DanceStudio.h index 45c4730..674fade 100644 --- a/WoW/Source/Ui/DanceStudio.h +++ b/WoW/Source/Ui/DanceStudio.h @@ -4,10 +4,14 @@ #include #include #include "WoW/Source/Net/Types.h" +#include "Engine/Source/Storm/H/stpl.h" class CDataStore; struct lua_State; +struct KNOWNDANCES : public TSHashObject { +}; + int32_t Packet_SMSG_PLAY_DANCE(void* param, NETMESSAGE msgId, uint32_t time, CDataStore* msg); int32_t Packet_SMSG_STOP_DANCE(void* param, NETMESSAGE msgId, uint32_t time, CDataStore* msg); int32_t Packet_SMSG_NOTIFY_DANCE(void* param, NETMESSAGE msgId, uint32_t time, CDataStore* msg); @@ -18,6 +22,7 @@ class CGDanceStudio { static uint64_t m_learnedDanceMoves; static void InitializeGame(); + static void ShutdownGame(); static void LoadDance(int32_t danceId); static void RegisterScriptFunctions(); }; diff --git a/WoW/Source/Ui/DuelInfo.cpp b/WoW/Source/Ui/DuelInfo.cpp index 5c029f2..c0f0249 100644 --- a/WoW/Source/Ui/DuelInfo.cpp +++ b/WoW/Source/Ui/DuelInfo.cpp @@ -30,3 +30,14 @@ int32_t Packet_SMSG_DUEL_INBOUNDS(void* param, NETMESSAGE msgId, uint32_t time, FrameScript_SignalEvent(SCRIPT_EVENT_DUEL_INBOUNDS, nullptr); return 1; } + +// VERIFY: 0f292ee9 auto +// OFFSET: 0x005CF830 +void CGDuelInfo::ShutdownGame() { + ClientServices::ClearMessageHandler(SMSG_DUEL_REQUESTED); + ClientServices::ClearMessageHandler(SMSG_DUEL_OUT_OF_BOUNDS); + ClientServices::ClearMessageHandler(SMSG_DUEL_IN_BOUNDS); + ClientServices::ClearMessageHandler(SMSG_DUEL_COUNTDOWN); + ClientServices::ClearMessageHandler(SMSG_DUEL_COMPLETE); + ClientServices::ClearMessageHandler(SMSG_DUEL_WINNER); +} diff --git a/WoW/Source/Ui/DuelInfo.h b/WoW/Source/Ui/DuelInfo.h index dbbfd95..d1c79a1 100644 --- a/WoW/Source/Ui/DuelInfo.h +++ b/WoW/Source/Ui/DuelInfo.h @@ -9,6 +9,7 @@ struct lua_State; class CGDuelInfo { public: + static void ShutdownGame(); static WOWGUID m_dueler; static void InitializeGame(); diff --git a/WoW/Source/Ui/EquipmentManager.cpp b/WoW/Source/Ui/EquipmentManager.cpp index b0e510d..e0b406a 100644 --- a/WoW/Source/Ui/EquipmentManager.cpp +++ b/WoW/Source/Ui/EquipmentManager.cpp @@ -184,3 +184,22 @@ int32_t Packet_SMSG_EQUIPMENT_SET_LIST(void* param, NETMESSAGE msgId, uint32_t t CGEquipmentManager::m_loaded = 1; return 1; } + +// VERIFY: 04c7f51f manual +// OFFSET: 0x005AE1B0 +void CGEquipmentManager::ShutdownGame() { + ClientServices::ClearMessageHandler(SMSG_LOAD_EQUIPMENT_SET); + ClientServices::ClearMessageHandler(SMSG_EQUIPMENT_SET_ID); + ClientServices::ClearMessageHandler(SMSG_USE_EQUIPMENT_SET_RESULT); + CGEquipmentManager::m_swapPending = 0; + CGEquipmentManager::m_pendingSetID = 0; + CGEquipmentManager::m_loaded = 0; + + for (EQUIPMENT_SET_NODE* node = CGEquipmentManager::s_equipmentSets.Head(); node; node = CGEquipmentManager::s_equipmentSets.Next(node)) { + ObjectFree(*CGEquipmentManager::s_equipmentSetHeap, node->m_set->m_handle); + } + + CGEquipmentManager::s_equipmentSets.Clear(); + delete CGEquipmentManager::s_equipmentSetHeap; + CGEquipmentManager::s_equipmentSetHeap = nullptr; +} diff --git a/WoW/Source/Ui/EquipmentManager.h b/WoW/Source/Ui/EquipmentManager.h index b870190..7e218e5 100644 --- a/WoW/Source/Ui/EquipmentManager.h +++ b/WoW/Source/Ui/EquipmentManager.h @@ -46,6 +46,7 @@ class CGEquipmentManager { static int32_t SetContainsLockedItems(const EQUIPMENT_SET* set); static int32_t SetUsesLockedSlots(const EQUIPMENT_SET* set); static void InitializeGame(); + static void ShutdownGame(); static void EquipSet(int32_t id); static void GetFullIconPath(int32_t id, char* buffer, uint32_t size); static int32_t GetSetList(char* buffer, uint32_t size, const WOWGUID* item); diff --git a/WoW/Source/Ui/GMSurveyInfo.cpp b/WoW/Source/Ui/GMSurveyInfo.cpp index 6c4a851..097389a 100644 --- a/WoW/Source/Ui/GMSurveyInfo.cpp +++ b/WoW/Source/Ui/GMSurveyInfo.cpp @@ -1,6 +1,42 @@ #include "GMSurveyInfo.h" +#include "Engine/Source/Storm/H/storm.h" + +// STATIC: 0x00C1E8C4 +uint8_t CGGMSurveyInfo::m_surveyAnswers[10]; + +// STATIC: 0x00C1E8D8 +char* CGGMSurveyInfo::m_surveyAnswerComments[10]; + +// STATIC: 0x00C1E900 +char* CGGMSurveyInfo::m_surveyComment; // VERIFY: cd4c7b4d auto // OFFSET: 0x005EEB70 void CGGMSurveyInfo::InitializeGame() { } + +// VERIFY: 849050ba manual +// OFFSET: 0x005AC1F0 +void CGGMSurveyInfo::FreeAnswers() { + for (uint32_t i = 0; i < 10; i++) { + CGGMSurveyInfo::m_surveyAnswers[i] = 0; + + if (CGGMSurveyInfo::m_surveyAnswerComments[i]) { + SMemFree(CGGMSurveyInfo::m_surveyAnswerComments[i], __FILE__, __LINE__, 0); + } + + CGGMSurveyInfo::m_surveyAnswerComments[i] = nullptr; + } + + if (CGGMSurveyInfo::m_surveyComment) { + SMemFree(CGGMSurveyInfo::m_surveyComment, __FILE__, __LINE__, 0); + } + + CGGMSurveyInfo::m_surveyComment = nullptr; +} + +// VERIFY: df97a125 auto +// OFFSET: 0x005AC520 +void CGGMSurveyInfo::ShutdownGame() { + CGGMSurveyInfo::FreeAnswers(); +} diff --git a/WoW/Source/Ui/GMSurveyInfo.h b/WoW/Source/Ui/GMSurveyInfo.h index 00c2f24..f43e53f 100644 --- a/WoW/Source/Ui/GMSurveyInfo.h +++ b/WoW/Source/Ui/GMSurveyInfo.h @@ -6,6 +6,11 @@ class CGGMSurveyInfo { public: + static uint8_t m_surveyAnswers[10]; + static char* m_surveyAnswerComments[10]; + static char* m_surveyComment; + static void ShutdownGame(); + static void FreeAnswers(); static void InitializeGame(); }; diff --git a/WoW/Source/Ui/GMTicketInfo.cpp b/WoW/Source/Ui/GMTicketInfo.cpp index 918ce39..63d8fc9 100644 --- a/WoW/Source/Ui/GMTicketInfo.cpp +++ b/WoW/Source/Ui/GMTicketInfo.cpp @@ -2,6 +2,11 @@ #include "Engine/Source/Base/CDataStore.h" #include "WoW/Source/Net/Types.h" #include "WoW/Source/WowSvcs/WowSvcsClient/ClientServices.h" +#include +#include "Engine/Source/FrameScript/FrameScript.h" +#include "Engine/Source/Storm/H/storm.h" +#include "WoW/Source/Ui/GameUI.h" +#include "WoW/Source/Ui/Types.h" // STATIC: 0x00C1E8D0 int32_t CGGMTicketInfo::m_ticketID; @@ -37,3 +42,166 @@ void SendGetTicketOpcode() { msg.Finalize(); ClientServices::Send2(&msg); } + +// VERIFY: 96fb670a manual +// OFFSET: 0x005AD240 +int32_t Packet_Group_5(void* param, NETMESSAGE msgId, uint32_t time, CDataStore* msg) { + switch (msgId) { + case SMSG_GM_TICKET_CREATE: + case SMSG_GM_TICKET_UPDATE_TEXT: { + uint32_t result; + msg->Get(result); + + switch (result) { + case 1: + CGGameUI::DisplayError(ERR_TICKET_ALREADY_EXISTS); + break; + + case 2: + case 4: + SendGetTicketOpcode(); + break; + + case 3: + CGGameUI::DisplayError(ERR_TICKET_CREATE_ERROR); + break; + + case 5: + CGGameUI::DisplayError(ERR_TICKET_UPDATE_ERROR); + break; + } + + break; + } + + case SMSG_GM_TICKET_GET_TICKET: { + uint32_t status; + msg->Get(status); + + if (status != 6) { + if (!status) { + CGGameUI::DisplayError(ERR_TICKET_DB_ERROR); + } + + FrameScript_SignalEvent(SCRIPT_EVENT_UPDATE_TICKET, nullptr); + break; + } + + CGGMTicketInfo::m_responseID = 0; + msg->Get(reinterpret_cast(CGGMTicketInfo::m_ticketID)); + char text[2000]; + msg->GetString(text, sizeof(text)); + uint8_t category; + msg->Get(category); + float ticketAge; + msg->Get(ticketAge); + + if (ticketAge < 0.0f) { + ticketAge = 0.0f; + } + + float oldestTicketAge; + msg->Get(oldestTicketAge); + float lastUpdate; + msg->Get(lastUpdate); + uint8_t assigned; + msg->Get(assigned); + uint8_t opened; + msg->Get(opened); + FrameScript_SignalEvent(SCRIPT_EVENT_UPDATE_TICKET, "%d%s%f%f%f%d%d", category, text, ticketAge, oldestTicketAge, lastUpdate, assigned, opened); + break; + } + + case SMSG_GM_TICKET_DELETE_TICKET: { + uint32_t result; + msg->Get(result); + + if (result == 9) { + CGGMTicketInfo::m_ticketID = 0; + CGGMTicketInfo::m_responseID = 0; + FrameScript_SignalEvent(SCRIPT_EVENT_UPDATE_TICKET, nullptr); + } else { + CGGameUI::DisplayError(ERR_TICKET_DB_ERROR); + } + + break; + } + + case SMSG_GM_TICKET_STATUS_UPDATE: { + uint32_t status; + msg->Get(status); + + switch (status) { + case 1: + case 4: + SendGetTicketOpcode(); + break; + + case 2: + CGGMTicketInfo::m_ticketID = 0; + CGGMTicketInfo::m_responseID = 0; + FrameScript_SignalEvent(SCRIPT_EVENT_UPDATE_TICKET, nullptr); + break; + + case 3: + CGGMTicketInfo::m_ticketID = 0; + CGGMTicketInfo::m_responseID = 0; + FrameScript_SignalEvent(SCRIPT_EVENT_GMSURVEY_DISPLAY, nullptr); + break; + } + + break; + } + + case SMSG_GMRESPONSE_DB_ERROR: + CGGameUI::DisplayError(ERR_GMRESPONSE_DB_ERROR); + break; + + case SMSG_GMRESPONSE_RECEIVED: { + msg->Get(reinterpret_cast(CGGMTicketInfo::m_responseID)); + msg->Get(reinterpret_cast(CGGMTicketInfo::m_ticketID)); + char text[2000]; + msg->GetString(text, sizeof(text)); + char response[16000] = { 0 }; + + for (int32_t i = 0; i < 4; i++) { + char line[4000]; + msg->GetString(line, sizeof(line)); + SStrPack(response, line, 0x7FFFFFFF); + } + + FrameScript_SignalEvent(SCRIPT_EVENT_GMRESPONSE_RECEIVED, "%s%s", text, response); + break; + } + + case SMSG_GMRESPONSE_STATUS_UPDATE: { + CGGMTicketInfo::m_ticketID = 0; + CGGMTicketInfo::m_responseID = 0; + uint8_t showSurvey = 0; + msg->Get(showSurvey); + + if (showSurvey) { + FrameScript_SignalEvent(SCRIPT_EVENT_GMSURVEY_DISPLAY, nullptr); + } else { + FrameScript_SignalEvent(SCRIPT_EVENT_UPDATE_TICKET, nullptr); + } + + break; + } + } + + return 1; +} + +// VERIFY: 0cce60c6 auto +// OFFSET: 0x005AC100 +void CGGMTicketInfo::ShutdownGame() { + ClientServices::ClearMessageHandler(SMSG_GM_TICKET_CREATE); + ClientServices::ClearMessageHandler(SMSG_GM_TICKET_UPDATE_TEXT); + ClientServices::ClearMessageHandler(SMSG_GM_TICKET_GET_TICKET); + ClientServices::ClearMessageHandler(SMSG_GM_TICKET_DELETE_TICKET); + ClientServices::ClearMessageHandler(SMSG_GMRESPONSE_DB_ERROR); + ClientServices::ClearMessageHandler(SMSG_GMRESPONSE_RECEIVED); + ClientServices::ClearMessageHandler(SMSG_GMRESPONSE_STATUS_UPDATE); + ClientServices::ClearMessageHandler(SMSG_GM_TICKET_STATUS_UPDATE); +} diff --git a/WoW/Source/Ui/GMTicketInfo.h b/WoW/Source/Ui/GMTicketInfo.h index b6607da..56ee052 100644 --- a/WoW/Source/Ui/GMTicketInfo.h +++ b/WoW/Source/Ui/GMTicketInfo.h @@ -19,6 +19,7 @@ class CGGMTicketInfo { public: static void EnterWorld(); static void InitializeGame(); + static void ShutdownGame(); static int32_t m_ticketID; static int32_t m_responseID; }; diff --git a/WoW/Source/Ui/GameUI.cpp b/WoW/Source/Ui/GameUI.cpp index 13b16db..390606b 100644 --- a/WoW/Source/Ui/GameUI.cpp +++ b/WoW/Source/Ui/GameUI.cpp @@ -159,6 +159,8 @@ #include #include "WoW/Source/WowServices/WDataStore.h" #include "WoW/Source/Object/ObjectClient/Movement_C.h" +#include "WoW/Source/Object/ObjectClient/Trade_C.h" +#include "Engine/Source/Services/AsyncFile.h" // STATIC: 0x00ACC3F8 static CImVector s_deadSelectionColor = CImVector(0x7F, 0x7F, 0x7F, 0xFF); @@ -969,6 +971,12 @@ WOWGUID CGGameUI::m_cursorItem; // STATIC: 0x00BD0774 CGTooltip* CGGameUI::m_gameTooltip; +// STATIC: 0x00BD0C24 +static int32_t s_unk_BD0C24; + +// STATIC: 0x00BD0C40 +static TSHashTable s_taintEvents; + // STATIC: 0x00BD0778 CSimpleFrame* CGGameUI::m_UISimpleParent; @@ -1098,9 +1106,6 @@ int32_t CGGameUI::m_iCurrentMapID; // STATIC: 0x00BD0894 uint32_t CGGameUI::m_instanceDifficulty; -// STATIC: 0x00BD1980 -uint32_t CGGameUI::unk_BD1980; - // STATIC: 0x00BD0898 uint32_t CGGameUI::m_dungeonDifficulty; @@ -5222,7 +5227,7 @@ void CGGameUI::UpdateAreaSpiritHealerTime(WOWGUID guid, int32_t time) { } } -// VERIFY: 69109a0f manual +// VERIFY: 5827fa27 manual // OFFSET: 0x00526530 int32_t CGGameUI::MessageHandler(void* param, NETMESSAGE msgId, uint32_t time, CDataStore* msg) { switch (msgId) { @@ -5470,7 +5475,7 @@ int32_t CGGameUI::MessageHandler(void* param, NETMESSAGE msgId, uint32_t time, C uint32_t unk; msg->Get(difficulty); msg->Get(unk); - CGGameUI::unk_BD1980 = unk; + CGPartyInfo::m_dynamicDifficulty = unk; CGGameUI::m_instanceDifficulty = difficulty; return 1; } @@ -5821,6 +5826,61 @@ void CGGameUI::SetDungeonDifficulty(uint32_t difficulty, uint32_t unk, uint32_t } } +// VERIFY: dad7dd6b manual +// OFFSET: 0x00524780 +void CGGameUI::SendRaidDifficultyMessage() { + char token[64]; + MapRec* map = g_mapDB.GetRecord(CGGameUI::m_iCurrentMapID); + + if (map && (map->m_flags & 0x100)) { + SStrPrintf(token, sizeof(token), "RAID_DIFFICULTY%d", CGGameUI::GetCurrentRaidDifficulty() + 1); + CGGameUI::DisplayError(ERR_RAID_LOCKOUT_CHANGED_S, FrameScript_GetText(token, -1, GENDER_NOT_APPLICABLE)); + SStrPrintf(token, sizeof(token), "PLAYER_DIFFICULTY%d", CGPartyInfo::m_dynamicDifficulty + 1); + CGGameUI::DisplayError(ERR_PLAYER_DIFFICULTY_CHANGED_S, FrameScript_GetText(token, -1, GENDER_NOT_APPLICABLE)); + return; + } + + map = g_mapDB.GetRecord(CGGameUI::m_iCurrentMapID); + + if (map->m_instanceType == 2) { + MapDifficultyRec* difficulty = GetMapDifficultyEntryByMapIdAndDifficulty(CGGameUI::m_iCurrentMapID, CGGameUI::m_instanceDifficulty, nullptr); + CGGameUI::DisplayError(ERR_RAID_DIFFICULTY_CHANGED_S, FrameScript_GetText(difficulty->m_difficultystring, -1, GENDER_NOT_APPLICABLE)); + } else { + SStrPrintf(token, sizeof(token), "RAID_DIFFICULTY%d", CGGameUI::GetCurrentRaidDifficulty() + 1); + CGGameUI::DisplayError(ERR_RAID_DIFFICULTY_CHANGED_S, FrameScript_GetText(token, -1, GENDER_NOT_APPLICABLE)); + } +} + +// VERIFY: 28031d67 manual +// OFFSET: 0x005255A0 +void CGGameUI::SetRaidDifficulty(uint32_t difficulty, uint32_t unk, uint32_t inGroup) { + uint32_t previous = CGGameUI::GetCurrentRaidDifficulty(); + + if (unk) { + CGGameUI::m_raidDifficulty = difficulty; + } + + if (inGroup) { + MapRec* map = g_mapDB.GetRecord(CGGameUI::m_iCurrentMapID); + + if (map && (map->m_flags & 0x100)) { + CGPartyInfo::ChangeRaidDifficulty(difficulty > 1); + } else { + CGPartyInfo::m_raidDifficulty = difficulty; + } + } + + uint32_t dungeonDifficulty = CGGameUI::GetCurrentDungeonDifficulty(); + + if (previous != CGGameUI::GetCurrentRaidDifficulty()) { + CGGameUI::SendRaidDifficultyMessage(); + } + + if (dungeonDifficulty != CGGameUI::GetCurrentDungeonDifficulty()) { + CGGameUI::ShowDungeonDifficultyChanged(); + } +} + // VERIFY: fc4f2074 manual // OFFSET: 0x0057EA60 void CGGameUI::LoadMinimapTrackingState(const char* state) { @@ -5836,3 +5896,303 @@ void CGGameUI::LoadMinimapTrackingState(const char* state) { } } } + +// VERIFY: be336278 manual +// OFFSET: 0x00529160 +void CGGameUI::ShutdownGame() { + CGGameUI::Shutdown(); + PortraitShutdown(); + CGMinimapFrame::ShutdownGame(); + CGChat::ShutdownGame(); + CGPartyInfo::ShutdownGame(); + CGSpellBook::ShutdownGame(); + CGActionBar::ShutdownGame(); + CGLootInfo::ShutdownGame(); + CGItemText::ShutdownGame(); + CGGossipInfo::ShutdownGame(); + CGQuestLog::ShutdownGame(); + CGTaxiMap::ShutdownGame(); + CGClassTrainer::ShutdownGame(); + CGTradeSkillInfo::ShutdownGame(); + CGPetInfo::ShutdownGame(); + CGWorldMap::ShutdownGame(); + CGReputationInfo::ShutdownGame(); + CGDuelInfo::ShutdownGame(); + CGTutorial::ShutdownGame(); + CGSkillInfo::ShutdownGame(); + CGGuildInfo::ShutdownGame(); + CGMailInfo::ShutdownGame(); + CGBattlefieldInfo::ShutdownGame(); + CGTalentInfo::ShutdownGame(); + CGTalentInfo_Inspect::ShutdownGame(); + CGAuctionHouse::ShutdownGame(); + CGStableInfo::ShutdownGame(); + CGRaidInfo::ShutdownGame(); + CGChatBubbleFrame::ShutdownGame(); + CGCharacterInfo::ShutdownGame(); + CGWorldStateInfo::ShutdownGame(); + CGMinigameInfo::ShutdownGame(); + CGArenaTeamInfo::ShutdownGame(); + CGLookingForGroup::ShutdownGame(); + CGPetitionInfo::ShutdownGame(); + CGCommentator::ShutdownGame(); + CGCalendar::ShutdownGame(); + CGDanceStudio::ShutdownGame(); + CGBarberShop::ShutdownGame(); + CGGuildBankInfo::ShutdownGame(); + CGAchievementInfo::ShutdownGame(); + CGRuneInfo::ShutdownGame(); + CGCurrencyTypes::ShutdownGame(); + CGEquipmentManager::ShutdownGame(); + CGAutoCompleteName::m_list.Clear(); + CGGMTicketInfo::ShutdownGame(); + CGGMSurveyInfo::ShutdownGame(); + FrameScript_Flush(); + + for (uint32_t i = 0; i < sizeof(s_readOnlyCVars) / sizeof(s_readOnlyCVars[0]); i++) { + CVar* var = CVar::Lookup(s_readOnlyCVars[i]); + + if (var) { + var->SetReadOnly(false); + } + } + + CGGameUI::m_areaID = 0; + CGGameUI::m_subzoneID = 0; + CGGameUI::m_wmoGroupID = 0; + + if (CGGameUI::m_zoneText) { + SMemFree(const_cast(CGGameUI::m_zoneText), __FILE__, __LINE__, 0); + } + + CGGameUI::m_zoneText = nullptr; + + if (CGGameUI::m_subZoneText) { + SMemFree(const_cast(CGGameUI::m_subZoneText), __FILE__, __LINE__, 0); + } + + CGGameUI::m_subZoneText = nullptr; + + if (CGGameUI::m_realZoneText) { + SMemFree(const_cast(CGGameUI::m_realZoneText), __FILE__, __LINE__, 0); + } + + CGGameUI::m_realZoneText = nullptr; + + if (CGGameUI::m_minimapZoneText) { + SMemFree(const_cast(CGGameUI::m_minimapZoneText), __FILE__, __LINE__, 0); + } + + CGGameUI::m_minimapZoneText = nullptr; + CGGameUI::s_threatMap.Clear(); + + for (int32_t i = 0; i < 3; i++) { + MirrorTimerInfo& timer = CGGameUI::m_mirrorTimerInfo[i]; + timer.m_type = 3; + timer.unk_0018 = 0; + timer.m_spellId = 0; + timer.m_paused = 0; + timer.m_scale = 0; + timer.m_maxValue = 0; + timer.m_value = 0; + } + + ClientServices::ClearMessageHandler(SMSG_PVP_CREDIT); + ClientServices::ClearMessageHandler(MSG_CORPSE_QUERY); + ClientServices::ClearMessageHandler(SMSG_CORPSE_RECLAIM_DELAY); + ClientServices::ClearMessageHandler(SMSG_GM_PLAYER_INFO); + ClientServices::ClearMessageHandler(CMSG_GM_REQUEST_PLAYER_INFO); + ClientServices::ClearMessageHandler(SMSG_PLAY_MUSIC); + ClientServices::ClearMessageHandler(SMSG_PLAY_SOUND); + ClientServices::ClearMessageHandler(SMSG_PLAY_OBJECT_SOUND); + ClientServices::ClearMessageHandler(SMSG_TRIGGER_MOVIE); + ClientServices::ClearMessageHandler(SMSG_AREA_TRIGGER_MESSAGE); + ClientServices::ClearMessageHandler(SMSG_AREA_TRIGGER_NO_CORPSE); + ClientServices::ClearMessageHandler(SMSG_INIT_WORLD_STATES); + ClientServices::ClearMessageHandler(SMSG_UPDATE_WORLD_STATE); + ClientServices::ClearMessageHandler(SMSG_AREA_SPIRIT_HEALER_TIME); + ClientServices::ClearMessageHandler(SMSG_INVALID_PROMOTION_CODE); + ClientServices::ClearMessageHandler(SMSG_WEATHER); + ClientServices::ClearMessageHandler(SMSG_OVERRIDE_LIGHT); + ClientServices::ClearMessageHandler(SMSG_INSTANCE_DIFFICULTY); + ClientServices::ClearMessageHandler(MSG_SET_DUNGEON_DIFFICULTY); + ClientServices::ClearMessageHandler(MSG_SET_RAID_DIFFICULTY); + ClientServices::ClearMessageHandler(SMSG_UPDATE_COMBO_POINTS); + ClientServices::ClearMessageHandler(SMSG_PHASE_SHIFT_CHANGE); + ClientServices::ClearMessageHandler(SMSG_TOTEM_CREATED); + ClientServices::ClearMessageHandler(SMSG_START_MIRROR_TIMER); + ClientServices::ClearMessageHandler(SMSG_PAUSE_MIRROR_TIMER); + ClientServices::ClearMessageHandler(SMSG_STOP_MIRROR_TIMER); + ClientServices::ClearMessageHandler(SMSG_PROPOSE_LEVEL_GRANT); + ClientServices::ClearMessageHandler(SMSG_REFER_A_FRIEND_FAILURE); + ClientServices::ClearMessageHandler(SMSG_REFER_A_FRIEND_EXPIRED); + ClientServices::ClearMessageHandler(SMSG_BREAK_TARGET); + ClientServices::ClearMessageHandler(SMSG_CORPSE_MAP_POSITION_QUERY_RESPONSE); + ClientServices::ClearMessageHandler(SMSG_REMOVED_FROM_PVP_QUEUE); + ClientServices::ClearMessageHandler(SMSG_UI_TIME); + ClientServices::ClearMessageHandler(SMSG_TALENTS_INVOLUNTARILY_RESET); +} + +// VERIFY: 39e91d8f manual +// OFFSET: 0x00528F00 +void CGGameUI::Shutdown() { + CGGameUI::unk_BD08C4++; + g_theGxDevicePtr->RemoveTextureRecreationCallback(UpdateAllPortraits); + g_theGxDevicePtr->RemoveDeviceRestoredCallback(UpdateAllPortraits); + CGChat::LeaveWorld(); + CGGameUI::unk_BD08CC = 0; + + if (CGGameUI::m_lockedTarget != WOWGUID()) { + CGGameUI::m_lastTarget = CGGameUI::m_lockedTarget; + CGGameUI::ClearTarget(CGGameUI::m_lockedTarget, 1); + + if (Spell_C_GetAutoRepeatingSpell()) { + Spell_C_CancelAutoRepeat(true); + } + } + + CGGameUI::SetFocusTarget(WOWGUID()); + Trade_C_CancelTrade(); + CGTradeSkillInfo::Close(); + + if (!(SFile::IsStreamingMode() | SFile::IsTrial())) { + AsyncFileReadWaitAll(); + } + + if (ClntObjMgrGetActivePlayer() != WOWGUID()) { + CGPlayer_C* player = static_cast(ClntObjMgrObjectPtr(ClntObjMgrGetActivePlayer(), TYPEMASK_PLAYER, __FILE__, __LINE__)); + + if (player) { + player->ClearTrackingTarget(false, true); + + if (player->m_unit->m_unitFieldFlags & 0x80000) { + CGGameUI::m_simpleTop->m_allowProtectedActions = 1; + FrameScript_SignalEvent(SCRIPT_EVENT_PLAYER_REGEN_ENABLED, nullptr); + CGGameUI::UpdateCombatMode(); + } + } + + CGGameUI::LeaveWorld(); + } + + CGLCD::Logout(); + FrameScript_SignalEvent(SCRIPT_EVENT_PLAYER_LOGOUT, nullptr); + ClearUniqueSignals(); + CGGameUI::m_initialized = 0; + DBCache_ClearPending(); + CSimpleScriptManager::Destroy(); + CGUnit_C::NamePlateClearAll(); + CGChatBubbleFrame::ClearAll(); + CGWorldMap::ClearArrowFrames(); + CGChat::SaveChatSettings(); + CGUIMacros::SaveMacros(); + CGUIMacros::Shutdown(); + CGUIBindings::SaveBindings(); + CGUIBindings::Shutdown(); + CGQuestLog::SaveTrackedQuests(); + CGAchievementInfo::SaveTrackedAchievements(); + CGTutorial::SaveFlaggedTutorials(); + CGGameUI::SaveSavedVariables(); + SaveAccountData(6, SavePlacedFrames, CGGameUI::m_simpleTop); + SaveAccountData(0, SaveGameCVarsCallback, reinterpret_cast(16)); + SaveAccountData(1, SaveGameCVarsCallback, reinterpret_cast(32)); + CVar::SaveAll(); + CVar::DeleteCharacterCVars(); + AccountDataFlush(); + UnloadAddOns(); + SaveAddOnEnableState(); + + if (CGGameUI::m_simpleTop) { + delete CGGameUI::m_simpleTop; + CGGameUI::m_simpleTop = nullptr; + CGGameUI::m_UISimpleParent = nullptr; + CGGameUI::m_gameTooltip = nullptr; + } + + CursorDestroy(); + + if (SFile::IsTrial()) { + StreamingSetState(0); + } + + UnloadScriptFunctions(); + EventUnregister(EVENT_ID_IDLE, CGGameUI::Idle); + DisableFadingScreen(0.0f, nullptr, nullptr); + CGChat::Resume(); + + if (s_taintLog) { + SLogClose(s_taintLog); + s_taintLog = nullptr; + } + + s_unk_BD0C24 = 0; + s_taintEvents.InternalClear(0); +} + +// VERIFY: 39aaac88 manual +// OFFSET: 0x0051A1D0 +int32_t IsInFlyableArea() { + AreaTableRec* area = g_areaTableDB.GetRecord(CGGameUI::m_subzoneID); + + if (!area) { + area = g_areaTableDB.GetRecord(CGGameUI::m_areaID); + } + + if (area && (area->m_flags & 0x400) && !(area->m_flags & 0x20000000)) { + return 1; + } + + return 0; +} + +// VERIFY: 1314bc98 manual +// OFFSET: 0x00527130 +void CGGameUI::SaveSavedVariables() { + int32_t created = 0; + + for (int32_t i = 0; i < 2; i++) { + char path[260]; + + if (i) { + SStrPrintf(path, sizeof(path), "WTF\\Account\\%s\\%s\\%s", ClientServices::GetAccountName(), ClientServices::GetSelectedRealmName(), ClientServices::GetCharacterName()); + } else { + SStrPrintf(path, sizeof(path), "WTF\\Account\\%s", ClientServices::GetAccountName()); + } + + if (!OsDirectoryExists(path)) { + OsCreateDirectory(path, 1); + } + + SStrPack(path, "\\SavedVariables.lua", sizeof(path)); + + if (OsFileExists(path)) { + char backup[260]; + SStrCopy(backup, path, sizeof(backup)); + SStrPack(backup, ".bak", sizeof(backup)); + OsMoveFile(path, backup); + } else { + created = 1; + } + + HOSFILE file = OsCreateFile(path, OS_GENERIC_WRITE, 0, OS_CREATE_ALWAYS, OS_FILE_ATTRIBUTE_NORMAL, OS_FILE_TYPE_ANY); + + if (file == OS_INVALID_FILE) { + return; + } + + for (SAVEDVARIABLE* variable = CGGameUI::s_savedVariables[i].m_fulllist.Head(); variable; variable = CGGameUI::s_savedVariables[i].Next(variable)) { + HASHKEY_STR name; + name = variable->m_key.m_str; + FrameScript_PrintVariable(file, name.m_str); + } + + uint32_t written; + OsWriteFile(file, "\r\n", 2, &written); + OsCloseFile(file); + CGGameUI::s_savedVariables[i].Clear(); + } + + if (created) { + SFile::RebuildHash(); + } +} diff --git a/WoW/Source/Ui/GameUI.h b/WoW/Source/Ui/GameUI.h index bc45310..8903f0b 100644 --- a/WoW/Source/Ui/GameUI.h +++ b/WoW/Source/Ui/GameUI.h @@ -39,6 +39,7 @@ class FrameScript_Object; struct lua_State; extern CVar* g_autoClearAFKCVar; +extern CVar* g_questPOICVar; extern CVar* g_nameplateShowEnemiesCVar; extern CVar* g_nameplateShowEnemyPetsCVar; extern CVar* g_nameplateShowEnemyGuardiansCVar; @@ -61,6 +62,7 @@ extern CVar* g_petSpellDamageCVar; extern CVar* g_deselectOnClickCVar; extern CVar* g_scriptProfileCVar; extern CVar* g_taintLogCVar; +extern CVar* g_guildMemberNotifyCVar; extern CVar* g_uiScaleCVar; extern CVar* g_useUiScaleCVar; extern CVar* g_rotateMinimapCVar; @@ -102,6 +104,9 @@ struct SAVEDVARIABLE : public TSHashObject { class SE2SoundKitObject; class CGGameUI { public: + static void SendRaidDifficultyMessage(); + static void LeaveWorld(); + static void SaveSavedVariables(); struct THREATMAP : public TSHashObject { /* 0020 */ TSGrowableArray m_units; @@ -256,7 +261,6 @@ class CGGameUI { static void SetPhaseShift(uint32_t phase); static void ProposeLevelGrant(WOWGUID guid); static void SetCorpseMapPosition(const C3Vector& position, const float& facing); - static uint32_t unk_BD1980; static void CastSpiritHealSpell(); static void SetCursorItem(WOWGUID item, WOWGUID container, uint32_t slot, int32_t a4, int32_t stackSplit, int32_t playSound); static WOWGUID m_lockedTarget; @@ -430,7 +434,16 @@ bool CVarHandler_useUiScale(CVar* var, const char* oldValue, const char* value, void LoadAccountVariables(); void LoadPlacedFrames(HOSFILE localFile, HOSFILE cacheFile, void* param); void LoadSavedVariables(CStatus* status); +struct TAINTEVENT : public TSHashObject { +}; + void LoadScriptFunctions(); +int32_t IsInFlyableArea(); +void UnloadScriptFunctions(); +void SavePlacedFrames(HOSFILE localFile, HOSFILE file, void* param); +void SaveGameCVarsCallback(HOSFILE localFile, HOSFILE file, void* param); +void DisableFadingScreen(float duration, void (*callback)(void*), void* param); +extern HSLOG s_taintLog; bool GuildShowOfflineCallback(CVar* var, const char* oldValue, const char* value, void* arg); bool SetCalendarFilterCVarCallback(CVar* var, const char* oldValue, const char* value, void* arg); bool SetTaintLogCallback(CVar* var, const char* oldValue, const char* value, void* arg); diff --git a/WoW/Source/Ui/GossipInfo.cpp b/WoW/Source/Ui/GossipInfo.cpp index bb3c270..1800410 100644 --- a/WoW/Source/Ui/GossipInfo.cpp +++ b/WoW/Source/Ui/GossipInfo.cpp @@ -460,3 +460,11 @@ void CGGossipInfo::SelectGossipActiveQuest(int32_t index) { found++; } } + +// VERIFY: adc27a92 auto +// OFFSET: 0x0058A520 +void CGGossipInfo::ShutdownGame() { + ClientServices::ClearMessageHandler(SMSG_GOSSIP_MESSAGE); + ClientServices::ClearMessageHandler(SMSG_GOSSIP_COMPLETE); + ClientServices::ClearMessageHandler(SMSG_GOSSIP_POI); +} diff --git a/WoW/Source/Ui/GossipInfo.h b/WoW/Source/Ui/GossipInfo.h index fa1edbb..743690f 100644 --- a/WoW/Source/Ui/GossipInfo.h +++ b/WoW/Source/Ui/GossipInfo.h @@ -43,6 +43,7 @@ class CGGossipInfo { static GossipOption m_options[32]; static char m_gossipText[2048]; static void InitializeGame(); + static void ShutdownGame(); static WOWGUID m_gossip; static uint32_t m_gossipOptionsCount; }; diff --git a/WoW/Source/Ui/GuildBankFrame.cpp b/WoW/Source/Ui/GuildBankFrame.cpp index 7ec194a..518ac1c 100644 --- a/WoW/Source/Ui/GuildBankFrame.cpp +++ b/WoW/Source/Ui/GuildBankFrame.cpp @@ -5,6 +5,10 @@ #include "WoW/Source/Ui/GameUI.h" #include "WoW/Source/Ui/Types.h" #include "Engine/Source/Base/CDataStore.h" +#include "WoW/Source/Game/ValidateName.h" +#include "WoW/Source/DB/DBClient/DBCacheInstances.h" +#include "WoW/Source/ObjectMgrClient/ObjectMgrClient.h" +#include "WoW/Source/Object/ObjectClient/Player_C.h" // STATIC: 0x00C1DC10 WOWGUID CGGuildBankInfo::m_banker; @@ -24,6 +28,12 @@ uint8_t CGGuildBankInfo::m_numTabs; // STATIC: 0x00C1DC0D uint8_t CGGuildBankInfo::m_currentTab; +// STATIC: 0x00C1DC28 +static uint32_t s_pendingItemQueries; + +// STATIC: 0x00C1DC30 +uint32_t CGGuildBankInfo::unk_C1DC30; + // STATIC: 0x00C1DC34 int32_t CGGuildBankInfo::m_remainingWithdrawMoney; @@ -129,3 +139,205 @@ void CGGuildBankInfo::Unlock(int32_t itemId, uint32_t virtualSlot) { } } } + +// VERIFY: 19c3efd7 auto +// OFFSET: 0x005A7760 +void CGGuildBankInfo::ClearAllTabs() { + for (uint32_t i = 0; i < 6; i++) { + CGGuildBankInfo::m_tabSlots[i].Clear(); + CGGuildBankInfo::m_guildBankTabInfo[i].unk_2140 = 1; + CGGuildBankInfo::unk_C0F8E8[i] = 1; + } + + CGGuildBankInfo::m_numTabs = 0; + CGGuildBankInfo::m_currentTab = 0; +} + +// VERIFY: 23cd4443 auto +// OFFSET: 0x005A7830 +void CGGuildBankInfo::ShutdownGame() { + ClientServices::ClearMessageHandler(SMSG_GUILD_BANK_QUERY_RESULTS); + ClientServices::ClearMessageHandler(MSG_GUILD_BANK_LOG_QUERY); + ClientServices::ClearMessageHandler(MSG_GUILD_BANK_MONEY_WITHDRAWN); + ClientServices::ClearMessageHandler(MSG_QUERY_GUILD_BANK_TEXT); + CGGuildBankInfo::ClearAllTabs(); +} + +// VERIFY: fa9b79e8 auto +// OFFSET: 0x005A4AB0 +int32_t Packet_MSG_GUILD_BANK_MONEY_WITHDRAWN(void* param, NETMESSAGE msgId, uint32_t time, CDataStore* msg) { + msg->Get(reinterpret_cast(CGGuildBankInfo::m_remainingWithdrawMoney)); + FrameScript_SignalEvent(SCRIPT_EVENT_GUILDBANK_UPDATE_WITHDRAWMONEY, nullptr); + + return 1; +} + +// VERIFY: fcedae56 auto +// OFFSET: 0x005A47A0 +static void Signal_EVENT_GUILDBANKBAGSLOTS_CHANGED(int32_t id, const WOWGUID& guid, void* param, bool success) { + if (!s_pendingItemQueries || !--s_pendingItemQueries) { + FrameScript_SignalEvent(SCRIPT_EVENT_GUILDBANKBAGSLOTS_CHANGED, nullptr); + } +} + +// VERIFY: 03f83d73 manual +// OFFSET: 0x005A4B60 +void CGGuildBankInfo::ClearGuildTabList(uint32_t tab) { + if (tab >= 6) { + return; + } + + for (uint32_t i = 0; i < CGGuildBankInfo::m_tabSlots[tab].m_count; i++) { + GuildBankSlotInfo& slot = CGGuildBankInfo::m_tabSlots[tab].m_data[i]; + slot.m_itemID = 0; + slot.m_randomPropertyID = 0; + slot.m_suffixFactor = 0; + slot.m_count = 0; + slot.unk_0010 = 0; + slot.unk_0014 = 0; + slot.m_enchants[0] = 0; + slot.m_enchants[1] = 0; + slot.m_enchants[2] = 0; + slot.m_locked = 0; + slot.unk_0028 = 0; + } +} + +// VERIFY: 5a5cd21a manual +// OFFSET: 0x005A7250 +int32_t Packet_SMSG_GUILD_BANK_LIST(void* param, NETMESSAGE msgId, uint32_t time, CDataStore* msg) { + uint64_t money; + uint8_t tab; + uint8_t hasTabInfo; + msg->Get(money); + msg->Get(tab); + msg->Get(CGGuildBankInfo::unk_C1DC30); + msg->Get(hasTabInfo); + + if (s_pendingItemQueries) { + s_pendingItemQueries = 0; + + for (uint32_t i = 0; i < CGGuildBankInfo::m_tabSlots[tab].m_count; i++) { + g_nameDBCache.CancelCallback(*reinterpret_cast(&CGGuildBankInfo::m_tabSlots[tab].m_data[i]), Signal_EVENT_GUILDBANKBAGSLOTS_CHANGED, nullptr); + } + } + + if (money >= 0x7FFFFFFFFFFFFull) { + money = 0x7FFFFFFFFFFFFull; + } + + CGGuildBankInfo::m_money = money; + + if (!CGGuildBankInfo::m_tabSlots[tab].m_count) { + CGGuildBankInfo::m_tabSlots[tab].SetCount(98); + CGGuildBankInfo::ClearGuildTabList(tab); + } + + if (hasTabInfo && !tab) { + msg->Get(CGGuildBankInfo::m_numTabs); + + for (uint32_t i = 0; i < CGGuildBankInfo::m_numTabs; i++) { + char name[64]; + char icon[256]; + msg->GetString(name, sizeof(name)); + msg->GetString(icon, sizeof(icon)); + ScrubString(name, CGGuildBankInfo::m_guildBankTabInfo[i].m_name, 16, sizeof(name), 1); + SStrCopy(CGGuildBankInfo::m_guildBankTabInfo[i].m_icon, icon, STORM_MAX_STR); + FrameScript_SignalEvent(SCRIPT_EVENT_GUILDBANK_UPDATE_TABS, nullptr); + } + + CGGuildBankInfo::ClearGuildTabList(tab); + } + + uint8_t numSlots; + msg->Get(numSlots); + int32_t cursorId = 0; + int32_t cursorSlot = 0; + + if (CGGameUI::m_cursorItemType == 11) { + CGGameUI::GetCursorVirtualItem(cursorId, cursorSlot); + } + + CGPlayer_C* player = static_cast(ClntObjMgrObjectPtr(ClntObjMgrGetActivePlayer(), TYPEMASK_PLAYER, __FILE__, __LINE__)); + + if (!player) { + return 0; + } + + WOWGUID playerGuid = player->m_obj->m_guid; + + for (uint32_t i = 0; i < numSlots; i++) { + uint8_t slotIndex; + msg->Get(slotIndex); + + if (cursorId && tab == static_cast(cursorSlot) / 98 && slotIndex == static_cast(cursorSlot) % 98) { + CGGameUI::ClearCursor(1, 1); + CGGameUI::UnlockVirtualItem(cursorId, cursorSlot, 0); + } + + msg->Get(reinterpret_cast(CGGuildBankInfo::m_tabSlots[tab].m_data[slotIndex].m_itemID)); + GuildBankSlotInfo* slot = &CGGuildBankInfo::m_tabSlots[tab].m_data[slotIndex]; + + if (!slot->m_itemID) { + continue; + } + + msg->Get(slot->unk_0028); + msg->Get(reinterpret_cast(CGGuildBankInfo::m_tabSlots[tab].m_data[slotIndex].m_randomPropertyID)); + slot = &CGGuildBankInfo::m_tabSlots[tab].m_data[slotIndex]; + + if (slot->m_randomPropertyID) { + msg->Get(slot->m_suffixFactor); + } else { + slot->m_suffixFactor = 0; + } + + msg->Get(reinterpret_cast(CGGuildBankInfo::m_tabSlots[tab].m_data[slotIndex].m_count)); + msg->Get(CGGuildBankInfo::m_tabSlots[tab].m_data[slotIndex].unk_0010); + msg->Get(CGGuildBankInfo::m_tabSlots[tab].m_data[slotIndex].unk_0014); + uint8_t numEnchants; + msg->Get(numEnchants); + slot = &CGGuildBankInfo::m_tabSlots[tab].m_data[slotIndex]; + slot->m_enchants[0] = 0; + slot->m_enchants[1] = 0; + slot->m_enchants[2] = 0; + + for (uint32_t j = 0; j < numEnchants; j++) { + uint8_t enchantSlot; + msg->Get(enchantSlot); + msg->Get(CGGuildBankInfo::m_tabSlots[tab].m_data[slotIndex].m_enchants[enchantSlot]); + } + + CGGuildBankInfo::m_tabSlots[tab].m_data[slotIndex].m_locked = 0; + + if (!g_itemDBCache.GetRecord(CGGuildBankInfo::m_tabSlots[tab].m_data[slotIndex].m_itemID, playerGuid, Signal_EVENT_GUILDBANKBAGSLOTS_CHANGED, nullptr, false)) { + s_pendingItemQueries++; + } + } + + CGGuildBankInfo::m_guildBankTabInfo[tab].unk_2140 = 0; + + if (CGGuildBankInfo::m_banker == WOWGUID()) { + if (CGGuildBankInfo::m_pendingBanker == WOWGUID()) { + FrameScript_SignalEvent(SCRIPT_EVENT_GUILDBANKFRAME_CLOSED, nullptr); + CGGameUI::ClearInteractTarget(CGGuildBankInfo::m_banker, 0); + CGGuildBankInfo::m_banker = WOWGUID(); + CGGuildBankInfo::m_pendingBanker = WOWGUID(); + return 1; + } + + CGGameUI::SetInteractTarget(CGGuildBankInfo::m_pendingBanker); + CGGuildBankInfo::m_banker = CGGuildBankInfo::m_pendingBanker; + FrameScript_SignalEvent(SCRIPT_EVENT_GUILDBANKFRAME_OPENED, nullptr); + } else if (!s_pendingItemQueries) { + FrameScript_SignalEvent(SCRIPT_EVENT_GUILDBANKBAGSLOTS_CHANGED, nullptr); + } + + return 1; +} + +// VERIFY: c082d582 auto +// OFFSET: 0x005A4310 +void CGGuildBankInfo::SetTextUpdate(uint8_t tab, int32_t update) { + CGGuildBankInfo::unk_C0F8E8[tab] = update; +} diff --git a/WoW/Source/Ui/GuildBankFrame.h b/WoW/Source/Ui/GuildBankFrame.h index 45b85bc..0b48315 100644 --- a/WoW/Source/Ui/GuildBankFrame.h +++ b/WoW/Source/Ui/GuildBankFrame.h @@ -18,20 +18,28 @@ struct GuildBankTabInfo { struct GuildBankSlotInfo { /* 0000 */ int32_t m_itemID; - /* 0004 */ uint8_t unk_0004[8]; + /* 0004 */ uint32_t m_suffixFactor; + /* 0008 */ int32_t m_randomPropertyID; /* 000C */ int32_t m_count; - /* 0010 */ uint8_t unk_0010[20]; + /* 0010 */ uint32_t unk_0010; + /* 0014 */ uint32_t unk_0014; + /* 0018 */ uint32_t m_enchants[3]; /* 0024 */ int32_t m_locked; /* 0028 */ uint32_t unk_0028; }; int32_t Packet_SMSG_GUILD_BANK_LIST(void* param, NETMESSAGE msgId, uint32_t time, CDataStore* msg); int32_t Packet_MSG_GUILD_BANK_LOG_QUERY(void* param, NETMESSAGE msgId, uint32_t time, CDataStore* msg); +void SendGuildBankQueryTabOpcode(uint8_t tab); int32_t Packet_MSG_GUILD_BANK_MONEY_WITHDRAWN(void* param, NETMESSAGE msgId, uint32_t time, CDataStore* msg); int32_t Packet_MSG_QUERY_GUILD_BANK_TEXT(void* param, NETMESSAGE msgId, uint32_t time, CDataStore* msg); class CGGuildBankInfo { public: + static void UpdateTabInfo(uint8_t tab, const char* name, const char* icon); + static void SetTextUpdate(uint8_t tab, int32_t update); + static void ClearGuildTabList(uint32_t tab); + static uint32_t unk_C1DC30; static WOWGUID m_banker; static WOWGUID m_pendingBanker; static void AutoStoreItem(WOWGUID item, WOWGUID container, uint32_t slot); @@ -49,6 +57,7 @@ class CGGuildBankInfo { static void SetGuildBanker(const WOWGUID& banker); static void EnterWorld(); static void InitializeGame(); + static void ShutdownGame(); static void ClearAllTabs(); static void Unlock(int32_t itemId, uint32_t virtualSlot); static void GetTabAndSlotFromVirtual(uint32_t virtualSlot, uint32_t* tab, uint32_t* slot); diff --git a/WoW/Source/Ui/GuildInfo.cpp b/WoW/Source/Ui/GuildInfo.cpp index 911b936..89e2efc 100644 --- a/WoW/Source/Ui/GuildInfo.cpp +++ b/WoW/Source/Ui/GuildInfo.cpp @@ -7,6 +7,15 @@ #include "WoW/Source/Ui/Types.h" #include "WoW/Source/ObjectMgrClient/ObjectMgrClient.h" #include "WoW/Source/Object/ObjectClient/Player_C.h" +#include "WoW/Source/Ui/GuildBankFrame.h" +#include "WoW/Source/Game/ValidateName.h" +#include "WoW/Source/Ui/CGAutoCompleteName.h" +#include +#include "Engine/Source/Storm/H/storm.h" +#include "WoW/Source/DB/DBClient/DBClient.h" +#include "WoW/Source/DB/Rec/AreaTableRec.h" +#include "WoW/Source/DB/Rec/ChrClassesRec.h" +#include "Engine/Source/Os/TimeManager.h" // STATIC: 0x00C22ACC int32_t CGGuildInfo::m_numEventLogEntries; @@ -128,3 +137,275 @@ void CGGuildInfo::EnterWorld() { CGGuildInfo::m_rankInfo[0].m_bankTabStacksPerDay[i] = -1; } } + +// VERIFY: 245e09f1 manual +// OFFSET: 0x005CC560 +void CGGuildInfo::ShutdownGame() { + ClientServices::ClearMessageHandler(SMSG_GUILD_ROSTER); + ClientServices::ClearMessageHandler(MSG_GUILD_PERMISSIONS); + ClientServices::ClearMessageHandler(MSG_GUILD_EVENT_LOG_QUERY); + uint32_t count = CGGuildInfo::m_roster.m_count; + + for (uint32_t i = 0; i < count; i++) { + delete CGGuildInfo::m_roster.m_data[i]; + CGGuildInfo::m_roster.m_data[i] = nullptr; + } + + CGGuildInfo::m_numMembers = 0; + CGGuildInfo::m_roster.m_count = 0; +} + +// VERIFY: 7db72a57 manual +// OFFSET: 0x005CB9F0 +int32_t Packet_MSG_GUILD_PERMISSIONS(void* param, NETMESSAGE msgId, uint32_t time, CDataStore* msg) { + if (!ClntObjMgrGetActivePlayerObj()) { + return 0; + } + + uint32_t rank; + msg->Get(rank); + msg->Get(CGGuildInfo::m_rankInfo[rank].m_rights); + msg->Get(reinterpret_cast(CGGuildInfo::m_rankInfo[rank].m_bankMoneyPerDay)); + uint8_t numTabs = 0; + msg->Get(numTabs); + CGGuildBankInfo::m_numTabs = numTabs; + + for (uint32_t i = 0; i < 6; i++) { + msg->Get(CGGuildInfo::m_rankInfo[rank].m_bankTabRights[i]); + msg->Get(reinterpret_cast(CGGuildInfo::m_rankInfo[rank].m_bankTabStacksPerDay[i])); + } + + FrameScript_SignalEvent(SCRIPT_EVENT_GUILD_ROSTER_UPDATE, nullptr); + + return 1; +} + +// VERIFY: 9a68ee60 manual +// OFFSET: 0x005CC5D0 +int32_t Packet_SMSG_GUILD_ROSTER(void* param, NETMESSAGE msgId, uint32_t time, CDataStore* msg) { + uint32_t allocated = CGGuildInfo::m_roster.m_count; + CGGuildInfo::m_numOnlineMembers = 0; + CGGuildInfo::m_numRanks = 0; + msg->Get(CGGuildInfo::m_numMembers); + + if (CGGuildInfo::m_numMembers > allocated) { + CGGuildInfo::m_roster.SetCount(CGGuildInfo::m_numMembers); + + for (; allocated < CGGuildInfo::m_numMembers; allocated++) { + CGGuildInfo::m_roster.m_data[allocated] = static_cast(SMemAlloc(sizeof(GuildMemberInfo), __FILE__, __LINE__, 0)); + } + } + + char motd[516]; + msg->GetString(motd, sizeof(motd)); + ScrubString(motd, CGGuildInfo::m_motd, 129, sizeof(CGGuildInfo::m_motd), 1); + char infoText[2004]; + msg->GetString(infoText, sizeof(infoText)); + ScrubString(infoText, CGGuildInfo::m_infoText, 501, sizeof(CGGuildInfo::m_infoText), 0); + msg->Get(CGGuildInfo::m_numRanks); + uint32_t rank = 0; + + for (; rank < CGGuildInfo::m_numRanks; rank++) { + GuildRankInfo& info = CGGuildInfo::m_rankInfo[rank]; + msg->Get(info.m_rights); + msg->Get(reinterpret_cast(info.m_bankMoneyPerDay)); + + for (uint32_t i = 0; i < 6; i++) { + msg->Get(info.m_bankTabRights[i]); + msg->Get(reinterpret_cast(info.m_bankTabStacksPerDay[i])); + } + } + + for (; rank < 10; rank++) { + memset(&CGGuildInfo::m_rankInfo[rank], 0, sizeof(GuildRankInfo)); + } + + for (uint32_t i = 0; i < CGGuildInfo::m_numMembers; i++) { + GuildMemberInfo* member = CGGuildInfo::m_roster.m_data[i]; + msg->Get(member->m_guid.m_guid); + uint8_t status; + msg->Get(status); + CGGuildInfo::m_roster.m_data[i]->m_online = status != 0; + CGGuildInfo::m_roster.m_data[i]->m_status = status; + msg->GetString(CGGuildInfo::m_roster.m_data[i]->m_name, sizeof(member->m_name)); + msg->Get(reinterpret_cast(CGGuildInfo::m_roster.m_data[i]->m_rank)); + uint8_t level; + uint8_t classId; + uint8_t unk; + msg->Get(level); + msg->Get(classId); + msg->Get(unk); + CGGuildInfo::m_roster.m_data[i]->m_level = level; + CGGuildInfo::m_roster.m_data[i]->m_class = classId; + CGGuildInfo::m_roster.m_data[i]->unk_0040 = unk; + msg->Get(reinterpret_cast(CGGuildInfo::m_roster.m_data[i]->m_zoneID)); + member = CGGuildInfo::m_roster.m_data[i]; + + if (member->m_online) { + member->m_lastOnline = 0.0f; + CGAutoCompleteName::AddFlags(CGGuildInfo::m_roster.m_data[i]->m_guid, 34, 0, CGGuildInfo::m_roster.m_data[i]->m_name); + } else { + msg->Get(member->m_lastOnline); + CGAutoCompleteName::AddFlags(CGGuildInfo::m_roster.m_data[i]->m_guid, 2, 0, CGGuildInfo::m_roster.m_data[i]->m_name); + CGAutoCompleteName::RemoveFlags(CGGuildInfo::m_roster.m_data[i]->m_guid, 32); + } + + char note[128]; + msg->GetString(note, sizeof(note)); + ScrubString(note, CGGuildInfo::m_roster.m_data[i]->m_note, 32, sizeof(member->m_note), 1); + msg->GetString(note, sizeof(note)); + ScrubString(note, CGGuildInfo::m_roster.m_data[i]->m_officerNote, 32, sizeof(member->m_officerNote), 1); + + if (CGGuildInfo::m_roster.m_data[i]->m_online) { + CGGuildInfo::m_numOnlineMembers++; + } + } + + qsort(CGGuildInfo::m_roster.m_data, CGGuildInfo::m_numMembers, sizeof(GuildMemberInfo*), QSortRoster); + FrameScript_SignalEvent(SCRIPT_EVENT_GUILD_ROSTER_UPDATE, nullptr); + + if (CGGuildInfo::unk_C22AD4) { + CGGuildInfo::SaveToFile(); + } + + return 1; +} + +// VERIFY: e01e8061 auto +// OFFSET: 0x005CA060 +void CGGuildInfo::SetMOTD(const char* motd) { + ScrubString(motd, CGGuildInfo::m_motd, 129, sizeof(CGGuildInfo::m_motd), 1); +} + +// VERIFY: 20231a2d auto +// OFFSET: 0x005CA0F0 +void UpdateGuildRoster(int32_t a1) { + if (a1) { + CGGuildInfo::unk_C22AC8 = 0; + FrameScript_SignalEvent(SCRIPT_EVENT_GUILD_ROSTER_UPDATE, "%d", 1); + } else { + FrameScript_SignalEvent(SCRIPT_EVENT_GUILD_ROSTER_UPDATE, nullptr); + } +} + +// VERIFY: d4f94ffa manual +// OFFSET: 0x005CA490 +int32_t QSortRoster(const void* a, const void* b) { + if (!a || !b) { + SErrDisplayAppFatalMessage("", "", 0); + } + + GuildMemberInfo* left = *static_cast(a); + GuildMemberInfo* right = *static_cast(b); + + if (!CGGuildInfo::m_showOffline && (!left->m_online || !right->m_online) && left->m_online != right->m_online) { + return 2 * (left->m_online == 0) - 1; + } + + for (uint32_t i = 0; i < 8; i++) { + GuildRosterSortCriteria* criteria = &CGGuildInfo::m_sortCriteria[i]; + int32_t result; + + switch (criteria->m_column) { + case 0: { + if (right->m_rank == left->m_rank) { + continue; + } + + result = static_cast(right->m_rank) < static_cast(left->m_rank) ? -1 : 1; + break; + } + + case 1: { + if (left->m_level == right->m_level) { + continue; + } + + result = 2 * (left->m_level >= right->m_level) - 1; + break; + } + + case 2: { + result = SStrCmpUTF8I(left->m_name, right->m_name, STORM_MAX_STR); + break; + } + + case 3: { + AreaTableRec* leftArea = g_areaTableDB.GetRecord(left->m_zoneID); + AreaTableRec* rightArea = g_areaTableDB.GetRecord(right->m_zoneID); + + if (!leftArea || !rightArea) { + continue; + } + + result = SStrSortUTF8I(leftArea->m_areaName, rightArea->m_areaName, STORM_MAX_STR); + break; + } + + case 4: { + ChrClassesRec* leftClass = g_chrClassesDB.GetRecord(left->m_class); + ChrClassesRec* rightClass = g_chrClassesDB.GetRecord(right->m_class); + + if (!leftClass || !rightClass) { + continue; + } + + result = SStrSortUTF8I(leftClass->m_name, rightClass->m_name, STORM_MAX_STR); + break; + } + + case 6: { + if (left->m_online && right->m_online) { + continue; + } + + if (left->m_online != right->m_online) { + result = 2 * (left->m_online == 0) - 1; + break; + } + + result = right->m_lastOnline <= left->m_lastOnline ? 1 : -1; + return criteria->m_descending ? -result : result; + } + + case 7: { + if (right->unk_0051) { + right->unk_0051 = 0; + } + + if (left->unk_0051) { + left->unk_0051 = 0; + } + + result = SStrSortUTF8I(left->m_note, right->m_note, STORM_MAX_STR); + break; + } + + default: { + continue; + } + } + + if (result) { + return criteria->m_descending ? -result : result; + } + } + + return 0; +} + +// VERIFY: a23b0c6d manual +// OFFSET: 0x005CA9B0 +void CGGuildInfo::QueryRosterAndRanks() { + uint32_t now = OsGetAsyncTimeMs(); + + if (CGGuildInfo::unk_C22AC8 && static_cast(now - CGGuildInfo::unk_C22AC8) < 0) { + return; + } + + CDataStore msg; + msg.Put(static_cast(CMSG_GUILD_GET_ROSTER)); + msg.Finalize(); + ClientServices::Send2(&msg); + CGGuildInfo::unk_C22AC8 = now + 10000; +} diff --git a/WoW/Source/Ui/GuildInfo.h b/WoW/Source/Ui/GuildInfo.h index 0d65b2e..0b631bb 100644 --- a/WoW/Source/Ui/GuildInfo.h +++ b/WoW/Source/Ui/GuildInfo.h @@ -45,6 +45,9 @@ struct GuildRankFlag { class CGGuildInfo { public: + static void SetMOTD(const char* motd); + static void SaveToFile(); + static void QueryRosterAndRanks(); static char m_infoText[2004]; static char m_motd[516]; static GuildRosterSortCriteria m_sortCriteria[8]; @@ -61,6 +64,7 @@ class CGGuildInfo { static uint32_t m_numRanks; static void EnterWorld(); static void InitializeGame(); + static void ShutdownGame(); static void QueryPermissions(); static void SetShowOffline(int32_t show); }; @@ -71,6 +75,7 @@ int32_t Packet_SMSG_GUILD_ROSTER(void* param, NETMESSAGE msgId, uint32_t time, C int32_t Packet_MSG_GUILD_PERMISSIONS(void* param, NETMESSAGE msgId, uint32_t time, CDataStore* msg); int32_t Packet_MSG_GUILD_EVENT_LOG_QUERY(void* param, NETMESSAGE msgId, uint32_t time, CDataStore* msg); int32_t QSortRoster(const void* a, const void* b); +void UpdateGuildRoster(int32_t a1); int32_t Script_GetNumGuildMembers(lua_State* L); int32_t Script_GetGuildRosterInfo(lua_State* L); diff --git a/WoW/Source/Ui/GuildInfo_Scripts.cpp b/WoW/Source/Ui/GuildInfo_Scripts.cpp index 592e0c0..239732f 100644 --- a/WoW/Source/Ui/GuildInfo_Scripts.cpp +++ b/WoW/Source/Ui/GuildInfo_Scripts.cpp @@ -399,6 +399,14 @@ static int32_t Script_GetGuildRosterMOTD(lua_State* L) { return 1; } +// VERIFY: 9075d012 auto +// OFFSET: 0x005CB810 +int32_t Script_GuildRoster(lua_State* L) { + CGGuildInfo::QueryRosterAndRanks(); + + return 0; +} + // STATIC: 0x00AD0840 static FrameScript_Method s_ScriptFunctions[] = { { "GetNumGuildMembers", &Script_GetNumGuildMembers }, diff --git a/WoW/Source/Ui/ItemTextFrame.cpp b/WoW/Source/Ui/ItemTextFrame.cpp index 90720ed..4e56744 100644 --- a/WoW/Source/Ui/ItemTextFrame.cpp +++ b/WoW/Source/Ui/ItemTextFrame.cpp @@ -26,3 +26,9 @@ void CGItemText::InitializeGame() { CGItemText::m_pages[1] = 0; CGItemText::m_text[0] = '\0'; } + +// VERIFY: 954655b8 auto +// OFFSET: 0x00589E50 +void CGItemText::ShutdownGame() { + CGItemText::m_pages.Clear(); +} diff --git a/WoW/Source/Ui/ItemTextFrame.h b/WoW/Source/Ui/ItemTextFrame.h index 76f66b2..7756462 100644 --- a/WoW/Source/Ui/ItemTextFrame.h +++ b/WoW/Source/Ui/ItemTextFrame.h @@ -11,6 +11,7 @@ struct lua_State; class CGItemText { public: static void InitializeGame(); + static void ShutdownGame(); static WOWGUID m_itemGUID; static uint32_t m_currentPage; static uint8_t m_hasItemText; diff --git a/WoW/Source/Ui/LFGInfo.cpp b/WoW/Source/Ui/LFGInfo.cpp index d04bbd4..13ad76f 100644 --- a/WoW/Source/Ui/LFGInfo.cpp +++ b/WoW/Source/Ui/LFGInfo.cpp @@ -8,6 +8,23 @@ #include "WoW/Source/DB/Rec/LfgDungeonGroupRec.h" #include "WoW/Source/WowSvcs/WowSvcsClient/ClientServices.h" #include "WoW/Source/WowServices/RealmConnection.h" +#include "WoW/Source/Ui/GameUI.h" +#include "WoW/Source/Ui/PartyFrame.h" +#include "WoW/Source/Ui/RaidInfo.h" +#include "WoW/Source/Ui/LootFrame.h" +#include "WoW/Source/Ui/Types.h" +#include "WoW/Source/SoundInterface/SoundInterface2.h" +#include "WoW/Source/Game/GameClient/NameCache.h" +#include "WoW/Source/DB/DBClient/DBCacheInstances.h" +#include "WoW/Source/ObjectMgrClient/ObjectMgrClient.h" +#include "Engine/Source/FrameScript/FrameScript.h" +#include "Engine/Source/Os/TimeManager.h" +#include + +struct LFGJoinResultError { + /* 0000 */ uint32_t m_result; + /* 0004 */ UIErrors m_error; +}; // STATIC: 0x00BEAA14 int32_t CGLookingForGroup::m_searchJoinedID; @@ -30,6 +47,9 @@ TSFixedArray CGLookingForGroup::m_lfrEntries; // STATIC: 0x00BEA820 CGLookingForGroup::LFGEntryInfo CGLookingForGroup::m_unkBEA820[7]; +// STATIC: 0x00BEA858 +LFGBootProposal CGLookingForGroup::m_bootProposal; + // STATIC: 0x00BEA980 LFGProposal CGLookingForGroup::m_proposal; @@ -412,3 +432,991 @@ LfgDungeonExpansionRec* GetLfgDungeonExpansionRec(int32_t dungeonID, int32_t exp return nullptr; } + +// VERIFY: 9f6b8622 auto +// OFFSET: 0x00552850 +void LFGProposal::Clear() { + this->m_id = 0; + this->m_state = 0; + this->unk_0008 = 0; + this->m_completedMask = 0; + this->unk_0010 = 0; + memset(this->m_members, 0, sizeof(this->m_members)); +} + +// VERIFY: 8daf3271 manual +// OFFSET: 0x00552870 +void LFGQueueStatus::Clear() { + this->m_lfgID = 0; + this->m_averageWait = 0; + this->m_tankWait = 0; + this->m_healerWait = 0; + this->m_damageWait = 0; + this->m_myWait = 0; + this->m_tanksNeeded = 0; + this->m_healersNeeded = 0; + this->m_damageNeeded = 0; + this->m_statusTime = 0; + this->m_queuedTime = 0; +} + +// VERIFY: 9624669a auto +// OFFSET: 0x00552900 +void CGLookingForGroup::ShowProposal(int32_t silent) { + FrameScript_SignalEvent(SCRIPT_EVENT_LFG_PROPOSAL_UPDATE, nullptr); + + if (CGLookingForGroup::m_lastProposalID != CGLookingForGroup::m_proposal.unk_0008) { + CGLookingForGroup::m_lastProposalID = CGLookingForGroup::m_proposal.unk_0008; + + if (!silent) { + FrameScript_SignalEvent(SCRIPT_EVENT_LFG_PROPOSAL_SHOW, nullptr); + } + } +} + +// VERIFY: b8ab3e63 auto +// OFFSET: 0x005570C0 +LFGDungeonEntry* LFGInfo::FindDungeon(uint32_t slot) const { + for (LFGDungeonEntry* dungeon = const_cast(this)->m_dungeons.Head(); !this->m_dungeons.IsEnd(dungeon); dungeon = dungeon->RawNext()) { + if (dungeon->m_slot == slot) { + return dungeon; + } + } + + return nullptr; +} + +// VERIFY: dd19911d manual +// OFFSET: 0x005570F0 +bool LFGInfo::Equals(const LFGInfo& other) const { + if ((this->m_joined != 0) != (other.m_joined != 0) || (this->unk_0001 != 0) != (other.unk_0001 != 0) || (this->m_queued != 0) != (other.m_queued != 0) || (this->unk_0004 != 0) != (other.unk_0004 != 0) || (this->unk_0005 != 0) != (other.unk_0005 != 0) || this->m_numDungeons != other.m_numDungeons) { + return false; + } + + if (memcmp(this->m_roles, other.m_roles, sizeof(this->m_roles)) || SStrCmp(this->m_comment, other.m_comment, 0x7FFFFFFF)) { + return false; + } + + LFGInfo* self = const_cast(this); + + for (LFGDungeonEntry* dungeon = self->m_dungeons.Head(); !self->m_dungeons.IsEnd(dungeon); dungeon = self->m_dungeons.Next(dungeon)) { + if (!other.FindDungeon(dungeon->m_slot)) { + return false; + } + } + + return true; +} + +// INLINED +LFGDungeonEntry::LFGDungeonEntry() { + this->m_slot = 0; + this->m_rewardDone = 0; + this->m_locked = 0; + this->m_lockReason = 0; + this->m_baseMoney = 0; + this->m_baseXP = 0; + this->m_variableMoney = 0; + this->m_variableXP = 0; +} + +// VERIFY: 0df5071f manual +// OFFSET: 0x00559840 +LFGDungeonEntry* LFGLockInfo::AddDungeon(uint32_t slot) { + for (LFGDungeonEntry* dungeon = this->m_dungeons.Head(); !this->m_dungeons.IsEnd(dungeon); dungeon = dungeon->RawNext()) { + if (dungeon->m_slot == slot) { + return dungeon; + } + } + + LFGDungeonEntry* dungeon = new (__FILE__, __LINE__) LFGDungeonEntry(); + dungeon->m_slot = slot; + this->m_dungeons.LinkToTail(dungeon); + return dungeon; +} + +// VERIFY: e83e8eb7 auto +// OFFSET: 0x005598D0 +LFGInfo::LFGInfo() { + this->Reset(); +} + +// VERIFY: 1a192e21 manual +// OFFSET: 0x00559900 +LFGInfo::~LFGInfo() { + this->Reset(); +} + +// VERIFY: 3eab0733 manual +// OFFSET: 0x00559950 +LFGDungeonEntry* LFGInfo::AddDungeon(uint32_t slot) { + for (LFGDungeonEntry* dungeon = this->m_dungeons.Head(); !this->m_dungeons.IsEnd(dungeon); dungeon = dungeon->RawNext()) { + if (dungeon->m_slot == slot) { + return dungeon; + } + } + + LFGDungeonEntry* dungeon = new (__FILE__, __LINE__) LFGDungeonEntry(); + dungeon->m_slot = slot; + this->m_dungeons.LinkToTail(dungeon); + this->m_numDungeons++; + return dungeon; +} + +// VERIFY: bb433006 manual +// OFFSET: 0x005599F0 +void LFGInfo::CopyFrom(const LFGInfo& other) { + this->m_joined = other.m_joined; + this->unk_0001 = other.unk_0001; + this->m_queued = other.m_queued; + this->unk_0004 = other.unk_0004; + this->unk_0005 = other.unk_0005; + memcpy(this->m_roles, other.m_roles, sizeof(this->m_roles)); + SStrCopy(this->m_comment, other.m_comment, sizeof(this->m_comment)); + + for (LFGDungeonEntry* dungeon = this->m_dungeons.Head(); !this->m_dungeons.IsEnd(dungeon); ) { + LFGDungeonEntry* next = dungeon->RawNext(); + + if (!other.FindDungeon(dungeon->m_slot)) { + delete dungeon; + this->m_numDungeons--; + } + + dungeon = next; + } + + LFGInfo& source = const_cast(other); + + for (LFGDungeonEntry* dungeon = source.m_dungeons.Head(); !source.m_dungeons.IsEnd(dungeon); dungeon = dungeon->RawNext()) { + if (!this->FindDungeon(dungeon->m_slot)) { + this->AddDungeon(dungeon->m_slot); + } + } +} + +// VERIFY: 704dfe19 auto +// OFFSET: 0x00558C30 +static void ClearSearchResults() { + CGLookingForGroup::m_searchResults.Clear(); + FrameScript_SignalEvent(SCRIPT_EVENT_UPDATE_LFG_LIST, nullptr); +} + +// STATIC: 0x00ACDDA8 +static const LFGJoinResultError s_joinResultErrors[17] = { + { 1, ERR_LFG_ROLE_CHECK_FAILED }, + { 2, ERR_LFG_GROUP_FULL }, + { 4, ERR_LFG_NO_LFG_OBJECT }, + { 5, ERR_LFG_NO_SLOTS_PLAYER }, + { 6, ERR_LFG_NO_SLOTS_PARTY }, + { 7, ERR_LFG_MISMATCHED_SLOTS }, + { 8, ERR_LFG_PARTY_PLAYERS_FROM_DIFFERENT_REALMS }, + { 9, ERR_LFG_MEMBERS_NOT_PRESENT }, + { 10, ERR_LFG_GET_INFO_TIMEOUT }, + { 11, ERR_LFG_INVALID_SLOT }, + { 12, ERR_LFG_DESERTER_PLAYER }, + { 13, ERR_LFG_DESERTER_PARTY }, + { 14, ERR_LFG_RANDOM_COOLDOWN_PLAYER }, + { 15, ERR_LFG_RANDOM_COOLDOWN_PARTY }, + { 16, ERR_LFG_TOO_MANY_MEMBERS }, + { 17, ERR_LFG_CANT_USE_DUNGEONS }, + { 18, ERR_LFG_ROLE_CHECK_FAILED }, +}; + +// VERIFY: dc655d6f manual +// OFFSET: 0x0055BDC0 +int32_t LFGPacketHandler(void* param, NETMESSAGE msgId, uint32_t time, CDataStore* msg) { + switch (msgId) { + case SMSG_LFG_TELEPORT_DENIED: { + uint32_t reason; + msg->Get(reason); + DebugLog("LFGMessage: LFG_TELEPORT_DENIED - Reason: %u", reason); + + switch (reason) { + case 0: + case 5: + case 7: + break; + + case 1: + CGGameUI::DisplayError(ERR_PLAYER_DEAD); + break; + + case 2: + CGGameUI::DisplayError(ERR_NOT_WHILE_FALLING); + break; + + case 4: + CGGameUI::DisplayError(ERR_NOT_WHILE_FATIGUED); + break; + + case 6: + CGGameUI::DisplayError(ERR_INVALID_TELEPORT_LOCATION); + CGGameUI::DisplayError(ERR_CLIENT_LOCKED_OUT); + break; + + default: + CGGameUI::DisplayError(ERR_CLIENT_LOCKED_OUT); + break; + } + + break; + } + + case SMSG_LFG_PLAYER_REWARD: { + LFGRewardInfo& reward = CGLookingForGroup::m_reward; + reward.Reset(); + msg->Get(reward.m_randomSlot); + msg->Get(reward.m_actualSlot); + msg->GetInt8(reward.m_first); + msg->Get(reinterpret_cast(reward.m_strangers)); + msg->Get(reinterpret_cast(reward.m_baseMoney)); + msg->Get(reinterpret_cast(reward.m_baseXP)); + msg->Get(reinterpret_cast(reward.m_variableMoney)); + msg->Get(reinterpret_cast(reward.m_variableXP)); + DebugLog("LFGMessage: LFG_PLAYER_REWARD - Random Slot: %u, Actual Slot: %u, First: %d, Strangers: %u, Base Money: %d, Base XP: %d, Var Money: %d, Var XP: %d", reward.m_randomSlot, reward.m_actualSlot, reward.m_first, reward.m_strangers, reward.m_baseMoney, reward.m_baseXP, reward.m_variableMoney, reward.m_variableXP); + uint8_t itemCount = 0; + msg->Get(itemCount); + + for (uint32_t i = 0; i < itemCount; i++) { + LFGRewardItem* item = new (__FILE__, __LINE__) LFGRewardItem; + reward.m_items.LinkToTail(item); + msg->Get(reinterpret_cast(item->m_itemID)); + msg->Get(reinterpret_cast(item->m_displayID)); + msg->Get(reinterpret_cast(item->m_quantity)); + DebugLog("LFG_PLAYER_REWARD: Receiving Item %u, Display %u, Quantity: %u", item->m_itemID, item->m_displayID, item->m_quantity); + } + + int32_t variableMoney = reward.m_variableMoney * reward.m_strangers; + int32_t variableXP = reward.m_variableXP * reward.m_strangers; + + if (reward.m_baseXP > 0) { + CGGameUI::DisplayError(ERR_QUEST_REWARD_EXP_I, reward.m_baseXP); + } + + if (variableXP > 0) { + CGGameUI::DisplayError(ERR_QUEST_REWARD_EXP_I, variableXP); + } + + char money[1024]; + + if (reward.m_baseMoney > 0) { + GetCurrencyText(reward.m_baseMoney, money, sizeof(money), ", "); + CGGameUI::DisplayError(ERR_QUEST_REWARD_MONEY_S, money); + } + + if (variableMoney > 0) { + GetCurrencyText(variableMoney, money, sizeof(money), ", "); + CGGameUI::DisplayError(ERR_QUEST_REWARD_MONEY_S, money); + } + + FrameScript_SignalEvent(SCRIPT_EVENT_LFG_COMPLETION_REWARD, nullptr); + break; + } + + case SMSG_LFG_OFFER_CONTINUE: { + uint32_t slot; + msg->Get(slot); + DebugLog("LFGMessage: LFG_OFFER_CONTINUE - Slot: %u", slot); + LfgDungeonsRec* dungeon = g_lfgDungeonsDB.GetRecord(slot & 0xFFFFFF); + + if (dungeon) { + FrameScript_SignalEvent(SCRIPT_EVENT_LFG_OFFER_CONTINUE, "%s%d%d", dungeon->m_name, dungeon->m_id, dungeon->m_typeID); + } + + break; + } + + case SMSG_LFG_ROLE_CHOSEN: { + uint64_t guid; + msg->Get(guid); + uint32_t accepted; + msg->GetInt8(accepted); + uint32_t roles; + msg->Get(roles); + DebugLog("LFGMessage: ROLE_CHOSEN - GUID: %016I64X, Accepted: %d, Roles Desired: %x", guid, accepted, roles); + NameCache* name = g_nameDBCache.GetRecord(guid, WOWGUID(), nullptr, nullptr, false); + + if (!name) { + break; + } + + if (accepted) { + FrameScript_SignalEvent(SCRIPT_EVENT_LFG_ROLE_CHECK_ROLE_CHOSEN, "%s%b%b%b", name->m_name, (roles >> 1) & 1, (roles >> 2) & 1, (roles >> 3) & 1); + } else { + CGGameUI::DisplayError(ERR_LFG_PLAYER_DECLINED_ROLE_CHECK, name->m_name); + } + + break; + } + + case SMSG_LFG_PROPOSAL_UPDATE: { + LFGProposal& proposal = CGLookingForGroup::m_proposal; + msg->Get(proposal.m_id); + msg->Get(proposal.m_state); + msg->Get(proposal.unk_0008); + msg->Get(proposal.m_completedMask); + msg->GetInt8(proposal.unk_0010); + uint8_t memberCount; + msg->Get(memberCount); + uint8_t declinedSelf = 0; + uint8_t declinedParty = 0; + + for (uint32_t i = 0; i < memberCount; i++) { + if (i >= 5) { + break; + } + + LFGProposalMember& member = proposal.m_members[i]; + msg->Get(member.m_roles); + msg->GetInt8(member.m_isLocal); + msg->GetInt8(member.unk_0008); + msg->GetInt8(member.unk_000C); + msg->GetInt8(member.m_accepted); + msg->GetInt8(member.unk_0014); + + if (member.m_accepted && !member.unk_0014) { + if (member.m_isLocal) { + declinedSelf = 1; + } else if (member.unk_000C) { + declinedParty = 1; + } + } + } + + DebugLog("LFGMessage: LFG_PROPOSAL_UPDATE - Slot: %u, State: %d, ID: %u, Last ID: %u, Completed Mask: %X, silent %d, I Declined: %d, Party Declined: %d", proposal.m_id, proposal.m_state, proposal.unk_0008, CGLookingForGroup::m_lastProposalID, proposal.m_completedMask, proposal.unk_0010, declinedSelf, declinedParty); + CGLookingForGroup::ShowProposal(proposal.unk_0010); + + if (declinedParty) { + SI2::PlayUISound(0x43BD); + CGGameUI::DisplayError(ERR_LFG_PROPOSAL_DECLINED_PARTY); + proposal.m_id = 0; + proposal.m_state = 0; + proposal.unk_0008 = 0; + proposal.m_completedMask = 0; + proposal.unk_0010 = 0; + memset(proposal.m_members, 0, sizeof(proposal.m_members)); + FrameScript_SignalEvent(SCRIPT_EVENT_LFG_PROPOSAL_FAILED, nullptr); + } else if (declinedSelf) { + SI2::PlayUISound(0x43BD); + CGGameUI::DisplayError(ERR_LFG_PROPOSAL_DECLINED_SELF); + proposal.Clear(); + FrameScript_SignalEvent(SCRIPT_EVENT_LFG_PROPOSAL_FAILED, nullptr); + } + + break; + } + + case SMSG_LFG_ROLE_CHECK_UPDATE: { + msg->Get(reinterpret_cast(CGLookingForGroup::m_roleCheckState)); + uint32_t beginning; + msg->GetInt8(beginning); + uint8_t slotCount; + msg->Get(slotCount); + CGLookingForGroup::m_roleCheckSlots.SetCount(slotCount); + + for (int32_t i = 0; i < slotCount; i++) { + msg->Get(CGLookingForGroup::m_roleCheckSlots.m_data[i]); + } + + uint8_t memberCount; + msg->Get(memberCount); + CGLookingForGroup::m_roleCheckMembers.SetCount(memberCount); + uint32_t localIndex = 0; + + for (uint32_t i = 0; i < memberCount; i++) { + LFGRoleCheckMember& member = CGLookingForGroup::m_roleCheckMembers.m_data[i]; + msg->Get(member.m_guid.m_guid); + uint8_t confirmed = 0; + msg->Get(confirmed); + member.m_confirmed = confirmed; + msg->Get(member.m_roles); + msg->Get(member.m_level); + + if (ClntObjMgrGetActivePlayer() == member.m_guid) { + localIndex = i; + } + } + + DebugLog("LFGMessage: LFG_ROLE_CHECK_UPDATE - Status: %u, Is Beginning: %d, Count: %d", CGLookingForGroup::m_roleCheckState, beginning, memberCount); + + if (beginning) { + CGGameUI::DisplayError(ERR_LFG_ROLE_CHECK_INITIATED); + SI2::PlayUISound(0x43A6); + + for (int32_t i = 0; i < memberCount; i++) { + LFGRoleCheckMember& member = CGLookingForGroup::m_roleCheckMembers.m_data[i]; + + if (!member.m_confirmed) { + continue; + } + + NameCache* name = g_nameDBCache.GetRecord(member.m_guid.m_guid, WOWGUID(), nullptr, nullptr, false); + + if (name) { + FrameScript_SignalEvent(SCRIPT_EVENT_LFG_ROLE_CHECK_ROLE_CHOSEN, "%s%b%b%b", name->m_name, (CGLookingForGroup::m_roleCheckMembers.m_data[i].m_roles >> 1) & 1, (CGLookingForGroup::m_roleCheckMembers.m_data[i].m_roles >> 2) & 1, (CGLookingForGroup::m_roleCheckMembers.m_data[i].m_roles >> 3) & 1); + } + } + } + + FrameScript_SignalEvent(SCRIPT_EVENT_LFG_ROLE_CHECK_UPDATE, nullptr); + + if (!CGLookingForGroup::m_roleCheckMembers.m_data[localIndex].m_confirmed && CGLookingForGroup::m_roleCheckState == 2) { + FrameScript_SignalEvent(SCRIPT_EVENT_LFG_ROLE_CHECK_SHOW, nullptr); + } else if (CGLookingForGroup::m_roleCheckState == 5) { + SI2::PlayUISound(0x43BD); + CGGameUI::DisplayError(ERR_LFG_ROLE_CHECK_ABORTED); + FrameScript_SignalEvent(SCRIPT_EVENT_LFG_ROLE_CHECK_HIDE, nullptr); + } else { + if (CGLookingForGroup::m_roleCheckState == 6) { + SI2::PlayUISound(0x43BD); + } + + FrameScript_SignalEvent(SCRIPT_EVENT_LFG_ROLE_CHECK_HIDE, nullptr); + } + + break; + } + + case SMSG_LFG_JOIN_RESULT: { + uint32_t result; + msg->Get(result); + uint32_t reason; + msg->Get(reason); + DebugLog("LFGMessage: LFG_JOIN_RESULT - Result: %u, Reason: %u", result, reason); + + if (result == 6) { + CGLookingForGroup::m_partyLockInfo.Clear(); + CGLookingForGroup::ParsePartyInfo(msg); + CGLookingForGroup::m_partyLockInfo.m_valid = 1; + } + + if (result == 1) { + if (reason == 3) { + CGGameUI::DisplayError(ERR_LFG_ROLE_CHECK_FAILED_TIMEOUT); + break; + } + + if (reason == 4) { + CGGameUI::DisplayError(ERR_LFG_ROLE_CHECK_FAILED_NOT_VIABLE); + break; + } + } + + for (uint32_t i = 0; i < 17; i++) { + if (s_joinResultErrors[i].m_result == result) { + CGGameUI::DisplayError(s_joinResultErrors[i].m_error); + break; + } + } + + break; + } + + case SMSG_LFG_QUEUE_STATUS: { + LFGQueueStatus& status = CGLookingForGroup::m_queueStatus; + msg->Get(reinterpret_cast(status.m_lfgID)); + msg->Get(reinterpret_cast(status.m_averageWait)); + msg->Get(reinterpret_cast(status.m_tankWait)); + msg->Get(reinterpret_cast(status.m_healerWait)); + msg->Get(reinterpret_cast(status.m_damageWait)); + msg->Get(reinterpret_cast(status.m_myWait)); + msg->Get(status.m_tanksNeeded); + msg->Get(status.m_healersNeeded); + msg->Get(status.m_damageNeeded); + uint32_t queuedTime; + msg->Get(queuedTime); + status.m_queuedTime = OsGetAsyncTimeMs() - 1000 * queuedTime; + + if (!status.m_tanksNeeded && !status.m_healersNeeded && !status.m_damageNeeded) { + status.m_damageNeeded = 1; + } + + DebugLog("LFGMessage: LFG_QUEUE_STATUS - LFGID: %d, Wait: %d, Wait Tanks: %d, Wait Healer: %d, Wait DPS: %d, Tanks Needed: %d, Healers Needed: %d, DPS Needed: %d", status.m_lfgID, status.m_averageWait, status.m_tankWait, status.m_healerWait, status.m_damageWait, status.m_tanksNeeded, status.m_healersNeeded, status.m_damageNeeded); + status.m_statusTime = static_cast(::time(nullptr)); + FrameScript_SignalEvent(SCRIPT_EVENT_LFG_QUEUE_STATUS_UPDATE, nullptr); + break; + } + + case SMSG_LFG_UPDATE_PLAYER: { + LFGInfo info; + uint8_t queued = 0; + uint8_t updateType; + msg->Get(updateType); + uint8_t joined; + msg->Get(joined); + info.m_joined = joined != 0; + info.unk_0001 = joined != 0; + + if (joined) { + msg->Get(queued); + uint8_t flag4; + msg->Get(flag4); + uint8_t flag5; + msg->Get(flag5); + uint8_t dungeonCount = 0; + msg->Get(dungeonCount); + info.m_queued = queued != 0; + info.unk_0004 = flag4 != 0; + info.unk_0005 = flag5 != 0; + + for (uint32_t i = 0; i < dungeonCount; i++) { + uint32_t slot; + msg->Get(slot); + info.AddDungeon(slot); + } + + msg->GetString(info.m_comment, sizeof(info.m_comment)); + } + + DebugLog("LFGMessage: LFG_UPDATE_PLAYER - Joined: %d, Queued: %d, Slot Count: %u, Proposal is valid: %d, In Party: %d", joined, queued, info.m_numDungeons, CGLookingForGroup::m_proposal.m_id, CGRaidInfo::m_numMembers); + + if (CGLookingForGroup::m_proposal.m_id && (!joined || queued) && !CGPartyInfo::InParty() && !CGRaidInfo::m_numMembers) { + CGLookingForGroup::m_proposal.Clear(); + + if (joined) { + CGGameUI::DisplayError(ERR_LFG_PROPOSAL_FAILED); + } + + if (updateType == 10) { + FrameScript_SignalEvent(SCRIPT_EVENT_LFG_PROPOSAL_SUCCEEDED, nullptr); + } else { + FrameScript_SignalEvent(SCRIPT_EVENT_LFG_PROPOSAL_FAILED, nullptr); + } + } + + LFGInfo& current = CGLookingForGroup::m_playerInfo; + + if (info.Equals(current)) { + break; + } + + bool left = false; + + if (info.unk_0001) { + if (!current.unk_0001) { + SI2::PlayUISound(0x210E); + CGGameUI::DisplayError(CGLookingForGroup::HasRaidDungeon(&info) ? ERR_LFG_JOINED_LIST : ERR_LFG_JOINED_QUEUE); + } else if (!info.m_queued && current.m_queued) { + left = true; + } + } else if (current.unk_0001 || (!info.m_queued && current.m_queued)) { + left = true; + } + + if (left && (updateType == 7 || updateType == 15)) { + SI2::PlayUISound(0x43BD); + CGGameUI::DisplayError(CGLookingForGroup::HasRaidDungeon(¤t) ? ERR_LFG_LEFT_LIST : ERR_LFG_LEFT_QUEUE); + } + + current.CopyFrom(info); + + if (!CGPartyInfo::InParty() && !CGRaidInfo::m_numMembers) { + if (!info.m_queued) { + CGLookingForGroup::m_queueStatus.Clear(); + } + + FrameScript_SignalEvent(SCRIPT_EVENT_LFG_UPDATE, "%b", 0); + } + + break; + } + + case SMSG_LFG_UPDATE_PARTY: { + LFGInfo info; + uint8_t lfgJoined = 0; + uint8_t queued = 0; + uint8_t updateType; + msg->Get(updateType); + uint8_t joined; + msg->Get(joined); + info.m_joined = joined != 0; + uint32_t dungeonCount = 0; + + if (joined) { + msg->Get(lfgJoined); + msg->Get(queued); + uint8_t flag4; + msg->Get(flag4); + uint8_t flag5; + msg->Get(flag5); + info.unk_0001 = lfgJoined != 0; + info.m_queued = queued != 0; + info.unk_0004 = flag4 != 0; + info.unk_0005 = flag5 != 0; + + for (uint32_t i = 0; i < 3; i++) { + msg->Get(info.m_roles[i]); + } + + uint8_t count = 0; + msg->Get(count); + dungeonCount = count; + + for (uint32_t i = 0; i < dungeonCount; i++) { + uint32_t slot; + msg->Get(slot); + info.AddDungeon(slot); + } + + msg->GetString(info.m_comment, sizeof(info.m_comment)); + } + + DebugLog("LFGMessage: LFG_UPDATE_PARTY - Joined: %d, LfgJoined: %d, Queued: %d, Slot Count: %u, Proposal is valid: %d, In Party: %d", joined, lfgJoined, queued, info.m_numDungeons, CGLookingForGroup::m_proposal.m_id, CGPartyInfo::InParty()); + + if (CGLookingForGroup::m_proposal.m_id && (!joined || queued) && (CGPartyInfo::InParty() || CGRaidInfo::m_numMembers)) { + LFGProposal& proposal = CGLookingForGroup::m_proposal; + proposal.m_id = 0; + proposal.m_state = 0; + proposal.unk_0008 = 0; + proposal.m_completedMask = 0; + proposal.unk_0010 = 0; + memset(proposal.m_members, 0, sizeof(proposal.m_members)); + + if (joined) { + CGGameUI::DisplayError(ERR_LFG_PROPOSAL_FAILED); + } + + if (updateType == 10 || updateType == 1 || updateType == 16) { + FrameScript_SignalEvent(SCRIPT_EVENT_LFG_PROPOSAL_SUCCEEDED, nullptr); + } else { + FrameScript_SignalEvent(SCRIPT_EVENT_LFG_PROPOSAL_FAILED, nullptr); + } + } + + LFGInfo& current = CGLookingForGroup::m_partyInfo; + + if (info.Equals(current)) { + break; + } + + bool left = false; + + if (info.unk_0001) { + if (!current.unk_0001 && dungeonCount) { + SI2::PlayUISound(0x210E); + CGGameUI::DisplayError(CGLookingForGroup::HasRaidDungeon(&info) ? ERR_LFG_JOINED_LIST : ERR_LFG_JOINED_QUEUE); + } else if (!info.m_queued && current.m_queued) { + left = true; + } + } else if (current.unk_0001 || (!info.m_queued && current.m_queued)) { + left = true; + } + + if (left && (updateType == 7 || updateType == 15)) { + SI2::PlayUISound(0x43BD); + CGGameUI::DisplayError(CGLookingForGroup::HasRaidDungeon(¤t) ? ERR_LFG_LEFT_LIST : ERR_LFG_LEFT_QUEUE); + } + + current.CopyFrom(info); + + if (CGPartyInfo::InParty() || CGRaidInfo::m_numMembers) { + if (!info.m_queued) { + CGLookingForGroup::m_queueStatus.Clear(); + } + + FrameScript_SignalEvent(SCRIPT_EVENT_LFG_UPDATE, "%b", 0); + } + + break; + } + + case SMSG_LFG_UPDATE_SEARCH: { + uint8_t joined = 0; + msg->Get(joined); + DebugLog("LFGMessage: LFG_UPDATE_SEARCH"); + + if (joined || !CGLookingForGroup::m_searchJoinedID) { + break; + } + + CGLookingForGroup::m_prevSearchResults.Clear(); + CGLookingForGroup::m_searchJoinedID = 0; + ClearSearchResults(); + break; + } + + case SMSG_LFG_BOOT_PROPOSAL_UPDATE: { + LFGBootProposal& boot = CGLookingForGroup::m_bootProposal; + msg->GetInt8(boot.m_inProgress); + msg->GetInt8(boot.m_didVote); + msg->GetInt8(boot.m_myVote); + msg->Get(boot.m_target.m_guid); + msg->Get(boot.m_totalVotes); + msg->Get(boot.m_bootVotes); + msg->Get(boot.m_timeLeft); + msg->Get(boot.m_votesNeeded); + msg->GetString(boot.m_reason, sizeof(boot.m_reason)); + DebugLog("LFGMessage: LFG_BOOT_PLAYER - In Progress: %d, I Voted: %d, My Vote: %d, Target: %016I64X, Total Votes: %u, Boot Votes: %u, Time Left: %d, Votes Needed: %u, Comment: %s", boot.m_inProgress, boot.m_didVote, boot.m_myVote, boot.m_target.m_guid, boot.m_totalVotes, boot.m_bootVotes, boot.m_timeLeft, boot.m_votesNeeded, boot.m_reason); + + if (!boot.m_inProgress) { + NameCache* name = g_nameDBCache.GetRecord(boot.m_target.m_guid, WOWGUID(), nullptr, nullptr, false); + + if (name) { + CGGameUI::DisplayError(boot.m_bootVotes < boot.m_votesNeeded ? ERR_PARTY_LFG_BOOT_VOTE_FAILED : ERR_PARTY_LFG_BOOT_VOTE_SUCCEEDED, name->m_name); + } + } + + FrameScript_SignalEvent(SCRIPT_EVENT_LFG_BOOT_PROPOSAL_UPDATE, nullptr); + break; + } + + case SMSG_LFG_PLAYER_INFO: { + LFGLockInfo& lockInfo = CGLookingForGroup::m_playerLockInfo; + lockInfo.m_valid = 0; + lockInfo.m_guid = WOWGUID(); + lockInfo.ClearDungeons(); + uint8_t dungeonCount; + msg->Get(dungeonCount); + DebugLog("LFGMessage: MSG_LFG_PLAYER_INFO"); + + for (uint32_t i = 0; i < dungeonCount; i++) { + uint32_t slot; + msg->Get(slot); + LFGDungeonEntry* dungeon = lockInfo.AddDungeon(slot); + uint8_t rewardDone = 0; + msg->Get(rewardDone); + dungeon->m_rewardDone = rewardDone != 0; + msg->Get(reinterpret_cast(dungeon->m_baseMoney)); + msg->Get(reinterpret_cast(dungeon->m_baseXP)); + msg->Get(reinterpret_cast(dungeon->m_variableMoney)); + msg->Get(reinterpret_cast(dungeon->m_variableXP)); + uint8_t itemCount; + msg->Get(itemCount); + + for (uint32_t j = 0; j < itemCount; j++) { + LFGRewardItem* item = new (__FILE__, __LINE__) LFGRewardItem; + dungeon->m_rewards.LinkToTail(item); + msg->Get(reinterpret_cast(item->m_itemID)); + msg->Get(reinterpret_cast(item->m_displayID)); + msg->Get(reinterpret_cast(item->m_quantity)); + } + } + + CGLookingForGroup::ParseBlackList(msg, &lockInfo); + lockInfo.m_valid = 1; + CGLookingForGroup::UpdateRandomDungeons(); + FrameScript_SignalEvent(SCRIPT_EVENT_LFG_LOCK_INFO_RECEIVED, nullptr); + FrameScript_SignalEvent(SCRIPT_EVENT_LFG_UPDATE_RANDOM_INFO, nullptr); + break; + } + + case SMSG_LFG_PARTY_INFO: + DebugLog("LFGMessage: LFG_PARTY_INFO"); + CGLookingForGroup::m_partyLockInfo.Clear(); + CGLookingForGroup::ParsePartyInfo(msg); + CGLookingForGroup::m_partyLockInfo.m_valid = 1; + CGLookingForGroup::UpdateRandomDungeons(); + FrameScript_SignalEvent(SCRIPT_EVENT_LFG_LOCK_INFO_RECEIVED, nullptr); + FrameScript_SignalEvent(SCRIPT_EVENT_LFG_UPDATE_RANDOM_INFO, nullptr); + break; + + case SMSG_LFG_DISABLED: + CGLookingForGroup::m_localInfo.Reset(); + CGLookingForGroup::m_playerInfo.Reset(); + CGLookingForGroup::m_partyInfo.Reset(); + CGLookingForGroup::m_playerLockInfo.m_valid = 0; + CGLookingForGroup::m_playerLockInfo.m_guid = WOWGUID(); + CGLookingForGroup::m_playerLockInfo.ClearDungeons(); + CGLookingForGroup::m_partyLockInfo.Clear(); + CGLookingForGroup::m_queueStatus.Clear(); + CGLookingForGroup::m_reward.Reset(); + DebugLog("LFGMessage: LFG_DISABLED"); + FrameScript_SignalEvent(SCRIPT_EVENT_LFG_UPDATE, "%b", 0); + CGGameUI::DisplayError(ERR_SYSTEM_DISABLED); + break; + } + + return 1; +} + +// VERIFY: 55669ffa auto +// OFFSET: 0x0055AF20 +void CGLookingForGroup::ShutdownGame() { + CGLookingForGroup::m_prevSearchResults.Clear(); + CGLookingForGroup::m_searchResults.Clear(); + CGLookingForGroup::m_localInfo.Reset(); + CGLookingForGroup::m_playerInfo.Reset(); + CGLookingForGroup::m_partyInfo.Reset(); + CGLookingForGroup::m_playerLockInfo.m_valid = 0; + CGLookingForGroup::m_playerLockInfo.m_guid = WOWGUID(); + CGLookingForGroup::m_playerLockInfo.ClearDungeons(); + CGLookingForGroup::m_partyLockInfo.Clear(); + CGLookingForGroup::m_queueStatus.Clear(); + CGLookingForGroup::m_reward.Reset(); + ClientServices::ClearMessageHandler(SMSG_LFG_LFR_LIST); + ClientServices::ClearMessageHandler(SMSG_LFG_UPDATE_PLAYER); + ClientServices::ClearMessageHandler(SMSG_LFG_UPDATE_PARTY); + ClientServices::ClearMessageHandler(SMSG_LFG_UPDATE_SEARCH); + ClientServices::ClearMessageHandler(SMSG_LFG_QUEUE_STATUS); + ClientServices::ClearMessageHandler(SMSG_LFG_DISABLED); + ClientServices::ClearMessageHandler(SMSG_LFG_PROPOSAL_UPDATE); + ClientServices::ClearMessageHandler(SMSG_LFG_ROLE_CHECK_UPDATE); + ClientServices::ClearMessageHandler(SMSG_LFG_ROLE_CHOSEN); + ClientServices::ClearMessageHandler(SMSG_LFG_JOIN_RESULT); + ClientServices::ClearMessageHandler(SMSG_LFG_BOOT_PROPOSAL_UPDATE); + ClientServices::ClearMessageHandler(SMSG_LFG_PLAYER_INFO); + ClientServices::ClearMessageHandler(SMSG_LFG_PARTY_INFO); + ClientServices::ClearMessageHandler(SMSG_LFG_PLAYER_REWARD); + ClientServices::ClearMessageHandler(SMSG_LFG_TELEPORT_DENIED); + ClientServices::ClearMessageHandler(SMSG_LFG_OFFER_CONTINUE); + ClientServices::ClearMessageHandler(SMSG_OPEN_LFG_DUNGEON_FINDER); +} + +// VERIFY: 3776dc9d auto +// OFFSET: 0x00559B10 +void CGLookingForGroup::ParseBlackList(CDataStore* msg, LFGLockInfo* lockInfo) { + uint32_t count; + msg->Get(count); + + for (uint32_t i = 0; i < count; i++) { + uint32_t slot; + msg->Get(slot); + LFGDungeonEntry* entry = lockInfo->AddDungeon(slot); + entry->m_locked = 1; + uint32_t reason; + msg->Get(reason); + entry->m_lockReason = reason; + } +} + +// VERIFY: 72ac9659 manual +// OFFSET: 0x00559D40 +bool CGLookingForGroup::IsRandomDungeonUnlocked(const LfgDungeonsRec* rec) { + if (!(rec->m_flags & 0x4)) { + return false; + } + + uint32_t slot = (rec->m_id & 0xFFFFFF) | (rec->m_typeID << 24); + + for (LFGDungeonEntry* entry = CGLookingForGroup::m_playerLockInfo.m_dungeons.Head(); entry; entry = CGLookingForGroup::m_playerLockInfo.m_dungeons.Next(entry)) { + if (entry->m_slot == slot) { + return !entry->m_locked; + } + } + + return false; +} + +// VERIFY: 589ed3a1 manual +// OFFSET: 0x0055AAF0 +void CGLookingForGroup::UpdateRandomDungeons() { + int32_t numRecords = g_lfgDungeonsDB.m_numRecords; + uint32_t count = 0; + + for (int32_t i = 0; i < numRecords; i++) { + LfgDungeonsRec* rec = i < 0 || i >= g_lfgDungeonsDB.m_numRecords ? nullptr : &g_lfgDungeonsDB.m_records[i]; + + if (rec->m_typeID == 6 || CGLookingForGroup::IsRandomDungeonUnlocked(rec)) { + count++; + } + } + + CGLookingForGroup::m_randomDungeons.SetCount(count); + uint32_t index = 0; + + for (int32_t i = 0; i < numRecords; i++) { + LfgDungeonsRec* rec = i < 0 || i >= g_lfgDungeonsDB.m_numRecords ? nullptr : &g_lfgDungeonsDB.m_records[i]; + uint32_t slot = (rec->m_id & 0xFFFFFF) | (rec->m_typeID << 24); + + if (rec->m_typeID == 6) { + CGLookingForGroup::m_randomDungeons.m_data[index++] = slot; + } else if (rec->m_flags & 0x4) { + for (LFGDungeonEntry* entry = CGLookingForGroup::m_playerLockInfo.m_dungeons.Head(); entry; entry = CGLookingForGroup::m_playerLockInfo.m_dungeons.Next(entry)) { + if (entry->m_slot == slot) { + if (!entry->m_locked) { + CGLookingForGroup::m_randomDungeons.m_data[index++] = slot; + } + + break; + } + } + } + } + + CGLookingForGroup::UpdateRandomDungeonBestChoice(); +} + +// VERIFY: 000b89b3 manual +// OFFSET: 0x00559C90 +bool CGLookingForGroup::IsSlotValidForAll(uint32_t slot) { + if (CGLookingForGroup::m_playerLockInfo.m_valid) { + for (LFGDungeonEntry* entry = CGLookingForGroup::m_playerLockInfo.m_dungeons.Head(); entry; entry = CGLookingForGroup::m_playerLockInfo.m_dungeons.Next(entry)) { + if (entry->m_slot == slot) { + if (entry->m_locked) { + return false; + } + + break; + } + } + } + + if ((slot & 0xFF000000) != 0x2000000 && CGLookingForGroup::m_partyLockInfo.m_valid) { + for (LFGLockInfo* member = CGLookingForGroup::m_partyLockInfo.m_members.Head(); member; member = CGLookingForGroup::m_partyLockInfo.m_members.Next(member)) { + for (LFGDungeonEntry* entry = member->m_dungeons.Head(); entry; entry = member->m_dungeons.Next(entry)) { + if (entry->m_slot == slot) { + if (entry->m_locked) { + return false; + } + + break; + } + } + } + } + + return true; +} + +// VERIFY: 0a9ddc1b manual +// OFFSET: 0x00559DA0 +static bool IsBetterRandomDungeon(const LfgDungeonsRec* candidate, const LfgDungeonsRec* best) { + if (!candidate || candidate->m_typeID != 6 || !CGLookingForGroup::IsSlotValidForAll(candidate->m_id & 0xFFFFFF | 0x6000000)) { + return false; + } + + if (!best) { + return true; + } + + if (candidate->m_expansionLevel != best->m_expansionLevel) { + return candidate->m_expansionLevel > best->m_expansionLevel; + } + + LfgDungeonExpansionRec* bestExpansion = GetLfgDungeonExpansionRec(best->m_id, ClientServices::Connection()->m_accountExpansion); + LfgDungeonExpansionRec* candidateExpansion = GetLfgDungeonExpansionRec(candidate->m_id, ClientServices::Connection()->m_accountExpansion); + int32_t bestLevel = (bestExpansion ? bestExpansion->m_targetLevelMin + bestExpansion->m_targetLevelMax : best->m_targetLevelMin + best->m_targetLevelMax) / 2; + int32_t candidateLevel = (candidateExpansion ? candidateExpansion->m_targetLevelMin + candidateExpansion->m_targetLevelMax : candidate->m_targetLevelMin + candidate->m_targetLevelMax) / 2; + + if (candidateLevel != bestLevel) { + return candidateLevel > bestLevel; + } + + int32_t bestMin = bestExpansion ? bestExpansion->m_hardLevelMin : best->m_minLevel; + int32_t candidateMin = candidateExpansion ? candidateExpansion->m_hardLevelMin : candidate->m_minLevel; + return candidateMin > bestMin; +} + +// VERIFY: fa41cf18 auto +// OFFSET: 0x00559EA0 +bool CGLookingForGroup::UpdateRandomDungeonBestChoice() { + LfgDungeonsRec* best = nullptr; + + for (uint32_t i = 0; i < CGLookingForGroup::m_randomDungeons.m_count; i++) { + LfgDungeonsRec* rec = g_lfgDungeonsDB.GetRecord(CGLookingForGroup::m_randomDungeons.m_data[i] & 0xFFFFFF); + + if (IsBetterRandomDungeon(rec, best)) { + best = rec; + } + } + + uint32_t previous = CGLookingForGroup::m_randomDungeonBestChoice; + + if (best) { + CGLookingForGroup::m_randomDungeonBestChoice = best->m_id & 0xFFFFFF | (best->m_typeID << 24); + return previous != CGLookingForGroup::m_randomDungeonBestChoice; + } + + CGLookingForGroup::m_randomDungeonBestChoice = 0; + return previous != 0; +} diff --git a/WoW/Source/Ui/LFGInfo.h b/WoW/Source/Ui/LFGInfo.h index 00fd401..abbf771 100644 --- a/WoW/Source/Ui/LFGInfo.h +++ b/WoW/Source/Ui/LFGInfo.h @@ -30,6 +30,7 @@ struct LFGDungeonEntry : public TSLinkedNode { /* 0020 */ int32_t m_variableXP; /* 0024 */ TSList> m_rewards; + LFGDungeonEntry(); ~LFGDungeonEntry(); }; @@ -47,7 +48,13 @@ struct LFGInfo { /* 001C */ char m_comment[256]; /* 011C */ uint32_t unk_011C; + LFGInfo(); + ~LFGInfo(); void Reset(); + LFGDungeonEntry* AddDungeon(uint32_t slot); + LFGDungeonEntry* FindDungeon(uint32_t slot) const; + bool Equals(const LFGInfo& other) const; + void CopyFrom(const LFGInfo& other); }; struct LFGLockInfo : public TSLinkedNode { @@ -59,6 +66,7 @@ struct LFGLockInfo : public TSLinkedNode { ~LFGLockInfo(); void ClearDungeons(); + LFGDungeonEntry* AddDungeon(uint32_t slot); }; struct LFGPartyLockInfo { @@ -100,6 +108,8 @@ struct LFGProposal { /* 000C */ uint32_t m_completedMask; /* 0010 */ uint32_t unk_0010; /* 0014 */ LFGProposalMember m_members[5]; + + void Clear(); }; struct LFGQueueStatus { @@ -115,16 +125,33 @@ struct LFGQueueStatus { /* 001B */ uint8_t unk_001B; /* 001C */ uint32_t m_statusTime; /* 0020 */ int32_t m_queuedTime; + + void Clear(); +}; + +struct LFGBootProposal { + /* 0000 */ uint32_t m_inProgress; + /* 0004 */ uint32_t m_didVote; + /* 0008 */ uint32_t m_myVote; + /* 000C */ uint32_t unk_000C; + /* 0010 */ WOWGUID m_target; + /* 0018 */ uint32_t m_totalVotes; + /* 001C */ uint32_t m_bootVotes; + /* 0020 */ uint32_t m_timeLeft; + /* 0024 */ uint32_t m_votesNeeded; + /* 0028 */ char m_reason[256]; }; struct LFGRoleCheckMember { /* 0000 */ WOWGUID m_guid; /* 0008 */ int32_t m_confirmed; /* 000C */ uint32_t m_roles; - /* 0010 */ int32_t m_level; + /* 0010 */ uint8_t m_level; + /* 0011 */ uint8_t unk_0011[3]; /* 0014 */ uint32_t unk_0014; }; +class LfgDungeonsRec; class CGLookingForGroup { public: struct LFGEntryInfo { @@ -142,6 +169,7 @@ class CGLookingForGroup { static LFGLIST m_prevSearchResults; static LFGProposal m_proposal; static CGLookingForGroup::LFGEntryInfo m_unkBEA820[7]; + static LFGBootProposal m_bootProposal; static uint8_t m_unkBEAA10; static uint8_t m_unkACD660; static LFGInfo m_localInfo; @@ -156,6 +184,7 @@ class CGLookingForGroup { static TSGrowableArray m_roleCheckMembers; static void EnterWorld(); static void InitializeGame(); + static void ShutdownGame(); static int32_t GetLFGRoleUpdate(lua_State* L); static int32_t GetLFGRoleUpdateSlot(lua_State* L); static void RequestLFGStatus(); @@ -165,6 +194,13 @@ class CGLookingForGroup { static bool HasRaidDungeon(LFGInfo* info); static void UpdateLFDEntries(); static void UpdateLFREntries(); + static void ShowProposal(int32_t silent); + static void ParsePartyInfo(CDataStore* msg); + static void ParseBlackList(CDataStore* msg, LFGLockInfo* lockInfo); + static void UpdateRandomDungeons(); + static bool IsRandomDungeonUnlocked(const LfgDungeonsRec* rec); + static bool UpdateRandomDungeonBestChoice(); + static bool IsSlotValidForAll(uint32_t slot); }; namespace DungeonEncounterDB { diff --git a/WoW/Source/Ui/LootFrame.cpp b/WoW/Source/Ui/LootFrame.cpp index 5f8a04e..999c971 100644 --- a/WoW/Source/Ui/LootFrame.cpp +++ b/WoW/Source/Ui/LootFrame.cpp @@ -769,3 +769,8 @@ void CGLootInfo::OnLootSlotChanged(uint8_t slot) { FrameScript_SignalEvent(SCRIPT_EVENT_LOOT_SLOT_CHANGED, "%d", index + 1); } } + +// VERIFY: 29eb8814 auto +// OFFSET: 0x005EEB70 +void CGLootInfo::ShutdownGame() { +} diff --git a/WoW/Source/Ui/LootFrame.h b/WoW/Source/Ui/LootFrame.h index de3e8d3..c504032 100644 --- a/WoW/Source/Ui/LootFrame.h +++ b/WoW/Source/Ui/LootFrame.h @@ -44,6 +44,7 @@ class CGLootInfo { static int32_t m_autolooted; static void InitializeGame(); + static void ShutdownGame(); static void LeaveWorld(); static void DoAutoLoot(int32_t a1); static int32_t HasLoot(); diff --git a/WoW/Source/Ui/MacroCondition.cpp b/WoW/Source/Ui/MacroCondition.cpp index 5954d35..0d1f854 100644 --- a/WoW/Source/Ui/MacroCondition.cpp +++ b/WoW/Source/Ui/MacroCondition.cpp @@ -1 +1,4 @@ #include "MacroCondition.h" +#include +#include "WoW/Source/Ui/GameUI.h" +#include "WoW/Source/Ui/MacroConditions.h" diff --git a/WoW/Source/Ui/MacroCondition.h b/WoW/Source/Ui/MacroCondition.h index 337ca16..02d4176 100644 --- a/WoW/Source/Ui/MacroCondition.h +++ b/WoW/Source/Ui/MacroCondition.h @@ -3,11 +3,23 @@ #include #include +#include "Engine/Source/Storm/H/stpl.h" +#include "WoW/Source/Ui/MacroSubstring.h" class MacroCondition { public: - /* 0000 */ uint8_t unk_0000[20]; - /* 0014 */ uint32_t unk_0014; + /* 0000 */ int32_t m_type; + /* 0004 */ TSGrowableArray m_args; + /* 0014 */ int32_t m_negate; + + MacroCondition(); + void Parse(const char* start, const char* end); }; +// INLINED +inline MacroCondition::MacroCondition() { + this->m_type = 0; + this->m_negate = 0; +} + #endif diff --git a/WoW/Source/Ui/MacroConditions.cpp b/WoW/Source/Ui/MacroConditions.cpp index af137df..c012407 100644 --- a/WoW/Source/Ui/MacroConditions.cpp +++ b/WoW/Source/Ui/MacroConditions.cpp @@ -1 +1,301 @@ #include "MacroConditions.h" +#include +#include "WoW/Source/Ui/MacroSubstring.h" +#include "WoW/Source/Ui/UIMacros.h" + +#include "WoW/Source/Ui/ScriptEvents.h" +#include "WoW/Source/Ui/GameUI.h" +#include "Engine/Source/Storm/H/storm.h" + +// STATIC: 0x00C2438C +TSHashTable s_macroConditions; + +// STATIC: 0x00AD14D8 +static const char* s_conditionNames[33] = { "", "combat", "exists", "help", "harm", "party", "raid", "dead", "flyable", "indoors", "outdoors", "swimming", "flying", "mounted", "stealth", "group", "stance", "form", "pet", "modifier", "mod", "button", "btn", "actionbar", "bar", "bonusbar", "equipped", "worn", "channeling", "spec", "vehicleui", "unithasvehicleui", "cursor" }; + +// VERIFY: 92beef98 auto +// OFFSET: 0x008C8DE0 +static int32_t EvaluateNone(const WOWGUID* unit, const TSGrowableArray* args) { + return 1; +} + +// STATIC: 0x00AD1560 +static MACROCONDITIONFUNC s_conditionFuncs[33] = { EvaluateNone, EvaluateCombat, EvaluateExists, EvaluateHelp, EvaluateHarm, EvaluateParty, EvaluateRaid, EvaluateDead, EvaluateFlyable, EvaluateIndoors, EvaluateOutdoors, EvaluateSwimming, EvaluateFlying, EvaluateMounted, EvaluateStealth, EvaluateGroup, EvaluateStance, EvaluateStance, EvaluatePet, EvaluateModifier, EvaluateModifier, EvaluateButton, EvaluateButton, EvaluateActionBar, EvaluateActionBar, EvaluateBonusBar, EvaluateEquipped, EvaluateEquipped, EvaluateChanneling, EvaluateSpec, EvaluateVehicleUI, EvaluateUnitHasVehicleUI, EvaluateCursor }; + +// VERIFY: 7d0b0703 manual +// OFFSET: 0x005F0DF0 +int32_t EvaluateMacroOptions(const char* start, const char* end, MacroSubstring* result, MacroSubstring* target) { + if (!start) { + return 1; + } + + const char* cursor = start; + const char* conditions = nullptr; + const char* optionStart; + int32_t matched = 0; + + while (true) { + while (true) { + optionStart = cursor; + + while (cursor < end && *cursor != '[' && *cursor != ';') { + cursor++; + } + + if (cursor >= end || *cursor == ';') { + break; + } + + for (conditions = cursor + 1; conditions < end && *conditions == ' '; conditions++) { + } + + const char* close = conditions; + + while (close < end && *close != ']') { + close++; + } + + const char* last = close; + + while (last > conditions && last[-1] == ' ') { + last--; + } + + if (!matched) { + uint32_t length = last - conditions; + + if (length > 1023) { + length = 1023; + } + + char text[1024]; + memcpy(text, conditions, length); + text[length] = '\0'; + MacroConditions* macroConditions = s_macroConditions.Ptr(text); + + if (!macroConditions) { + macroConditions = s_macroConditions.New(text, 0, 0); + macroConditions->Parse(); + } + + matched = macroConditions->Evaluate(target); + } + + cursor = close + 1; + } + + if (!conditions || matched) { + break; + } + + if (cursor >= end) { + return 0; + } + + conditions = nullptr; + cursor++; + } + + result->m_start = optionStart; + + while (result->m_start < cursor && *result->m_start == ' ') { + result->m_start++; + } + + result->m_end = cursor; + + while (result->m_end > result->m_start && result->m_end[-1] == ' ') { + result->m_end--; + } + + return 1; +} + +// VERIFY: 77048a72 manual +// OFFSET: 0x005F0BB0 +void MacroConditions::Parse() { + const char* text = this->m_key.m_str; + const char* end = text + SStrLen(text); + + if (text == end) { + return; + } + + uint32_t count = 0; + + for (int32_t pass = 0; pass < 2; pass++) { + if (pass == 1) { + this->m_conditions.SetCount(count); + count = 0; + } + + const char* cursor = text; + + while (cursor < end) { + while (cursor < end && *cursor == ' ') { + cursor++; + } + + const char* tokenEnd = cursor; + + while (tokenEnd < end && *tokenEnd != ',') { + tokenEnd++; + } + + const char* next = tokenEnd + 1; + + while (tokenEnd > cursor && tokenEnd[-1] == ' ') { + tokenEnd--; + } + + if (tokenEnd - cursor >= 7 && !SStrCmp(cursor, "target=", 7)) { + if (pass == 1) { + this->m_target.m_start = cursor + 7; + + while (this->m_target.m_start < tokenEnd && *this->m_target.m_start == ' ') { + this->m_target.m_start++; + } + + this->m_target.m_end = tokenEnd; + + while (this->m_target.m_end > this->m_target.m_start && this->m_target.m_end[-1] == ' ') { + this->m_target.m_end--; + } + } + } else if (*cursor == '@') { + if (pass == 1) { + this->m_target.m_start = cursor + 1; + + while (this->m_target.m_start < tokenEnd && *this->m_target.m_start == ' ') { + this->m_target.m_start++; + } + + this->m_target.m_end = tokenEnd; + + while (this->m_target.m_end > this->m_target.m_start && this->m_target.m_end[-1] == ' ') { + this->m_target.m_end--; + } + } + } else { + if (pass == 1) { + this->m_conditions.m_data[count].Parse(cursor, tokenEnd); + } + + count++; + } + + cursor = next; + } + } +} + +// VERIFY: 32005717 auto +// OFFSET: 0x005EF5C0 +int32_t MacroConditions::Evaluate(MacroSubstring* target) { + uint32_t count = this->m_conditions.m_count; + + if (count) { + WOWGUID unit; + char token[32]; + uint32_t length = this->m_target.m_end - this->m_target.m_start; + + if (length > 31) { + length = 31; + } + + memcpy(token, this->m_target.m_start, length); + token[length] = '\0'; + Script_GetGUIDFromToken(token, unit, true); + + for (uint32_t i = 0; i < count; i++) { + MacroCondition* condition = &this->m_conditions.m_data[i]; + int32_t result = s_conditionFuncs[condition->m_type](&unit, &condition->m_args); + + if (condition->m_negate) { + result = !result; + } + + if (!result) { + return 0; + } + } + } + + *target = this->m_target; + return 1; +} + +// VERIFY: c63507a8 manual +// OFFSET: 0x005F0040 +void MacroCondition::Parse(const char* start, const char* end) { + MacroSubstring option; + option.m_start = nullptr; + option.m_end = nullptr; + const char* cursor = start; + + if (end - start <= 2 || SStrCmp(start, "no", 2)) { + this->m_negate = 0; + } else { + cursor = start + 2; + this->m_negate = 1; + } + + option.SetText(cursor, end, ':', &cursor); + int32_t type = 0; + + for (; type < 33; type++) { + if (option == s_conditionNames[type]) { + this->m_type = type; + break; + } + } + + if (type == 33) { + char text[1024]; + uint32_t length = option.m_end - option.m_start; + + if (length > 1023) { + length = 1023; + } + + memcpy(text, option.m_start, length); + text[length] = '\0'; + CGGameUI::DisplayError(ERR_UNKNOWN_MACRO_OPTION_S, text); + return; + } + + if (cursor + 1 >= end) { + return; + } + + uint32_t count = 1; + + for (const char* c = cursor; c < end; c++) { + if (*c == '/') { + count++; + } + } + + this->m_args.SetCount(count); + + for (uint32_t i = 0; i < count; i++) { + MacroSubstring* arg = &this->m_args.m_data[i]; + arg->m_start = cursor + 1; + + while (arg->m_start < end && *arg->m_start == ' ') { + arg->m_start++; + } + + arg->m_end = arg->m_start; + + while (arg->m_end < end && *arg->m_end != '/') { + arg->m_end++; + } + + cursor = arg->m_end; + + while (arg->m_end > arg->m_start && arg->m_end[-1] == ' ') { + arg->m_end--; + } + } +} diff --git a/WoW/Source/Ui/MacroConditions.h b/WoW/Source/Ui/MacroConditions.h index 6433a9c..0030b27 100644 --- a/WoW/Source/Ui/MacroConditions.h +++ b/WoW/Source/Ui/MacroConditions.h @@ -3,16 +3,50 @@ #include #include +#include "Engine/Source/Storm/H/stpl.h" +#include "WoW/Source/Object/WGUID.h" +#include "WoW/Source/Ui/MacroCondition.h" +#include "WoW/Source/Ui/MacroSubstring.h" -class MacroConditions { +typedef int32_t (*MACROCONDITIONFUNC)(const WOWGUID* unit, const TSGrowableArray* args); + +class MacroConditions : public TSHashObject { public: - /* 0000 */ uint8_t unk_0000[20]; - /* 0014 */ uint32_t unk_0014; - /* 0018 */ uint32_t unk_0018; - /* 001C */ uint32_t unk_001C; - /* 0020 */ uint8_t unk_0020[4]; - /* 0024 */ uint32_t unk_0024; - /* 0028 */ uint32_t unk_0028; + /* 0018 */ MacroSubstring m_target; + /* 0020 */ TSGrowableArray m_conditions; + + void Parse(); + int32_t Evaluate(MacroSubstring* target); }; +extern TSHashTable s_macroConditions; + +int32_t EvaluateCombat(const WOWGUID* unit, const TSGrowableArray* args); +int32_t EvaluateExists(const WOWGUID* unit, const TSGrowableArray* args); +int32_t EvaluateHelp(const WOWGUID* unit, const TSGrowableArray* args); +int32_t EvaluateHarm(const WOWGUID* unit, const TSGrowableArray* args); +int32_t EvaluateParty(const WOWGUID* unit, const TSGrowableArray* args); +int32_t EvaluateRaid(const WOWGUID* unit, const TSGrowableArray* args); +int32_t EvaluateDead(const WOWGUID* unit, const TSGrowableArray* args); +int32_t EvaluateFlyable(const WOWGUID* unit, const TSGrowableArray* args); +int32_t EvaluateIndoors(const WOWGUID* unit, const TSGrowableArray* args); +int32_t EvaluateOutdoors(const WOWGUID* unit, const TSGrowableArray* args); +int32_t EvaluateSwimming(const WOWGUID* unit, const TSGrowableArray* args); +int32_t EvaluateFlying(const WOWGUID* unit, const TSGrowableArray* args); +int32_t EvaluateMounted(const WOWGUID* unit, const TSGrowableArray* args); +int32_t EvaluateStealth(const WOWGUID* unit, const TSGrowableArray* args); +int32_t EvaluateGroup(const WOWGUID* unit, const TSGrowableArray* args); +int32_t EvaluateStance(const WOWGUID* unit, const TSGrowableArray* args); +int32_t EvaluatePet(const WOWGUID* unit, const TSGrowableArray* args); +int32_t EvaluateModifier(const WOWGUID* unit, const TSGrowableArray* args); +int32_t EvaluateButton(const WOWGUID* unit, const TSGrowableArray* args); +int32_t EvaluateActionBar(const WOWGUID* unit, const TSGrowableArray* args); +int32_t EvaluateBonusBar(const WOWGUID* unit, const TSGrowableArray* args); +int32_t EvaluateEquipped(const WOWGUID* unit, const TSGrowableArray* args); +int32_t EvaluateChanneling(const WOWGUID* unit, const TSGrowableArray* args); +int32_t EvaluateSpec(const WOWGUID* unit, const TSGrowableArray* args); +int32_t EvaluateVehicleUI(const WOWGUID* unit, const TSGrowableArray* args); +int32_t EvaluateUnitHasVehicleUI(const WOWGUID* unit, const TSGrowableArray* args); +int32_t EvaluateCursor(const WOWGUID* unit, const TSGrowableArray* args); + #endif diff --git a/WoW/Source/Ui/MailInfo.cpp b/WoW/Source/Ui/MailInfo.cpp index 742b3f9..11e1a01 100644 --- a/WoW/Source/Ui/MailInfo.cpp +++ b/WoW/Source/Ui/MailInfo.cpp @@ -283,3 +283,60 @@ bool CGMailInfo::IsSendItem(WOWGUID item) { return false; } + +// VERIFY: 5655f664 manual +// OFFSET: 0x0056DAF0 +int32_t Packet_MSG_QUERY_NEXT_MAIL_TIME(void* param, NETMESSAGE msgId, uint32_t time, CDataStore* msg) { + msg->Get(CGMailInfo::m_nextMailTime); + uint32_t count; + msg->Get(count); + + for (uint32_t i = 0; i < count; i++) { + if (i >= 3) { + break; + } + + MailSenderInfo& sender = s_recentSenders[i]; + msg->Get(sender.m_guid.m_guid); + msg->Get(reinterpret_cast(sender.m_entry)); + msg->Get(reinterpret_cast(sender.unk_000C)); + msg->Get(reinterpret_cast(sender.unk_0010)); + msg->Get(sender.unk_0014); + } + + for (uint32_t i = count; i < 3; i++) { + MailSenderInfo& sender = s_recentSenders[i]; + sender.unk_0014 = 0.0f; + sender.m_guid = WOWGUID(); + sender.m_entry = 0; + sender.unk_000C = 0; + sender.unk_0010 = 0; + } + + FrameScript_SignalEvent(SCRIPT_EVENT_UPDATE_PENDING_MAIL, nullptr); + return 1; +} + +// VERIFY: 7438366f manual +// OFFSET: 0x00571630 +void CGMailInfo::ShutdownGame() { + uint32_t count = CGMailInfo::m_stationeries.m_count; + + for (uint32_t i = 0; i < count; i++) { + delete CGMailInfo::m_stationeries.m_data[i]; + } + + CGMailInfo::m_stationeries.Clear(); + count = CGMailInfo::m_inbox.m_count; + + for (uint32_t i = 0; i < count; i++) { + delete CGMailInfo::m_inbox.m_data[i]; + } + + CGMailInfo::m_inbox.Clear(); + ClientServices::ClearMessageHandler(SMSG_MAIL_COMMAND_RESULT); + ClientServices::ClearMessageHandler(SMSG_MAIL_LIST_RESULT); + ClientServices::ClearMessageHandler(MSG_QUERY_NEXT_MAIL_TIME); + ClientServices::ClearMessageHandler(SMSG_RECEIVED_MAIL); + ClientServices::ClearMessageHandler(SMSG_SHOW_MAILBOX); +} diff --git a/WoW/Source/Ui/MailInfo.h b/WoW/Source/Ui/MailInfo.h index cbf482a..687fc8c 100644 --- a/WoW/Source/Ui/MailInfo.h +++ b/WoW/Source/Ui/MailInfo.h @@ -67,6 +67,7 @@ class CGMailInfo { static TSGrowableArray m_inbox; static void EnterWorld(); static void InitializeGame(); + static void ShutdownGame(); static void UpdatePendingMail(float elapsed); static uint32_t m_sendMoney; static uint32_t m_sendCOD; diff --git a/WoW/Source/Ui/MinimapFrame.cpp b/WoW/Source/Ui/MinimapFrame.cpp index 0d7c139..d00325d 100644 --- a/WoW/Source/Ui/MinimapFrame.cpp +++ b/WoW/Source/Ui/MinimapFrame.cpp @@ -3408,3 +3408,68 @@ int32_t MinimapGetZoom() { int32_t MinimapGetZoomLevels() { return 6; } + +// VERIFY: 0f410ab6 auto +// OFFSET: 0x007F4810 +void RefreshWorldStatePOIs(uint32_t state) { + for (uint32_t i = 0; i < s_numPOIs; i++) { + AreaPOIRec* poi = s_pois.m_data[i]; + + if (0.0f != poi->m_pos[0] && 0.0f != poi->m_pos[1] && poi->m_worldStateID == static_cast(state)) { + UpdatePointsOfInterest(); + s_poisChanged = 1; + return; + } + } +} + +// VERIFY: ac080634 manual +// OFFSET: 0x0057BD90 +void CGMinimapFrame::ShutdownGame() { + if (s_maskTexture) { + HandleClose(reinterpret_cast(s_maskTexture)); + } + + s_maskTexture = nullptr; + + if (s_iconTexture) { + HandleClose(reinterpret_cast(s_iconTexture)); + } + + s_iconTexture = nullptr; + + if (s_blipTexture) { + HandleClose(reinterpret_cast(s_blipTexture)); + } + + s_blipTexture = nullptr; + + if (s_classBlipTexture) { + HandleClose(reinterpret_cast(s_classBlipTexture)); + } + + s_classBlipTexture = nullptr; + + for (uint32_t i = 0; i < 7; i++) { + HandleClose(reinterpret_cast(s_vehicleTextures[i])); + s_vehicleTextures[i] = nullptr; + } + + if (s_staticPOIArrowTexture) { + HandleClose(reinterpret_cast(s_staticPOIArrowTexture)); + } + + s_staticPOIArrowTexture = nullptr; + + if (s_poiArrowTexture) { + HandleClose(reinterpret_cast(s_poiArrowTexture)); + } + + s_poiArrowTexture = nullptr; + + if (s_groupArrowTexture) { + HandleClose(reinterpret_cast(s_groupArrowTexture)); + } + + s_groupArrowTexture = nullptr; +} diff --git a/WoW/Source/Ui/MinimapFrame.h b/WoW/Source/Ui/MinimapFrame.h index 0bde2a5..c8c16e0 100644 --- a/WoW/Source/Ui/MinimapFrame.h +++ b/WoW/Source/Ui/MinimapFrame.h @@ -136,6 +136,7 @@ void DisplayQuestPoint(float x, float y, int32_t a3, const char* name); class CGMinimapFrame : public CSimpleFrame { public: static void EnterWorld(); + static void ShutdownGame(); static CDataAllocator s_minimapHeap; static void SetPingPosition(const WOWGUID& guid, const C2Vector& position); static void MinimapTextureCallback(EGxTexCommand command, uint32_t width, uint32_t height, uint32_t depth, uint32_t mipLevel, void* userArg, uint32_t& texelStrideInBytes, const void*& texels); diff --git a/WoW/Source/Ui/PaperDollInfoFrame.cpp b/WoW/Source/Ui/PaperDollInfoFrame.cpp index ecd01ab..cab2b5e 100644 --- a/WoW/Source/Ui/PaperDollInfoFrame.cpp +++ b/WoW/Source/Ui/PaperDollInfoFrame.cpp @@ -23,6 +23,7 @@ #include "WoW/Source/Net/Types.h" #include "WoW/Source/Object/Unit.h" #include "WoW/Source/Ui/Tutorial.h" +#include "WoW/Source/Ui/ScriptEvents.h" // STATIC: 0x00A1CE4C static const int32_t s_inventoryAlertSlots[12] = { 0, 2, 4, 5, 6, 7, 8, 9, 15, 16, 17, -1 }; @@ -559,3 +560,18 @@ int32_t CGCharacterInfo::CalculateInventoryAlertStatus(CGPlayer_C* player, uint3 CGTutorial::TriggerTutorial(36); return 2; } + +// VERIFY: d40125b4 auto +// OFFSET: 0x005E7690 +void CGCharacterInfo::ShutdownGame() { + ClientServices::ClearMessageHandler(MSG_INSPECT_HONOR_STATS); + ClientServices::ClearMessageHandler(MSG_INSPECT_ARENA_TEAMS); +} + +// VERIFY: fbee3a82 auto +// OFFSET: 0x005E7760 +void GuildNameCallback(int32_t id, const WOWGUID& guid, void* param, bool success) { + if (success) { + Script_SendUnitSignal(guid, SCRIPT_EVENT_PLAYER_GUILD_UPDATE); + } +} diff --git a/WoW/Source/Ui/PaperDollInfoFrame.h b/WoW/Source/Ui/PaperDollInfoFrame.h index e89d451..7597a99 100644 --- a/WoW/Source/Ui/PaperDollInfoFrame.h +++ b/WoW/Source/Ui/PaperDollInfoFrame.h @@ -41,6 +41,7 @@ class CGCharacterInfo { static void EnterWorld(); static void SetInspectTarget(const WOWGUID& guid); static void InitializeGame(); + static void ShutdownGame(); static void UpdateInventoryAlerts(); static void UpdateItem(WOWGUID guid); }; diff --git a/WoW/Source/Ui/PartyFrame.cpp b/WoW/Source/Ui/PartyFrame.cpp index c844759..e6e85fa 100644 --- a/WoW/Source/Ui/PartyFrame.cpp +++ b/WoW/Source/Ui/PartyFrame.cpp @@ -450,3 +450,13 @@ void CGPartyInfo::EnableMember(CGPlayer_C* player, int32_t enable) { Script_SendUniqueSignal(SCRIPT_EVENT_PARTY_MEMBER_DISABLE); } + +// VERIFY: 4289bd20 auto +// OFFSET: 0x0052BC10 +void CGPartyInfo::ShutdownGame() { + ClientServices::ClearMessageHandler(MSG_SET_DUNGEON_DIFFICULTY); + ClientServices::ClearMessageHandler(MSG_SET_RAID_DIFFICULTY); + ClientServices::ClearMessageHandler(SMSG_INSTANCE_SAVE_CREATED); + ClientServices::ClearMessageHandler(SMSG_CHANGE_PLAYER_DIFFICULTY_RESULT); + ConsoleCommandUnregister("changePlayerDifficulty"); +} diff --git a/WoW/Source/Ui/PartyFrame.h b/WoW/Source/Ui/PartyFrame.h index 4fbe0ce..05ed714 100644 --- a/WoW/Source/Ui/PartyFrame.h +++ b/WoW/Source/Ui/PartyFrame.h @@ -48,6 +48,7 @@ class CGPartyMemberState { class CGPartyInfo { public: + static void ChangeRaidDifficulty(int32_t heroic); static uint32_t m_memberRoles[4]; static uint32_t unk_BD0D00; static uint32_t unk_BD1984; @@ -55,6 +56,7 @@ class CGPartyInfo { static uint8_t unk_BD1989; static uint8_t m_playerRole; static void InitializeGame(); + static void ShutdownGame(); static void CheckClearLFGSlot(); static int32_t IsMemberOrPet(const WOWGUID& guid); static void RegisterScriptFunctions(); diff --git a/WoW/Source/Ui/PetInfo.cpp b/WoW/Source/Ui/PetInfo.cpp index 951e1ab..2b15770 100644 --- a/WoW/Source/Ui/PetInfo.cpp +++ b/WoW/Source/Ui/PetInfo.cpp @@ -778,3 +778,17 @@ void CGPetInfo::SetIsAttackingTarget(int32_t attacking) { CGPetInfo::m_attackingTarget = 0; } } + +// VERIFY: 62a49fb5 auto +// OFFSET: 0x005D2F90 +void CGPetInfo::ShutdownGame() { + ClientServices::ClearMessageHandler(SMSG_PET_SPELLS_MESSAGE); + ClientServices::ClearMessageHandler(SMSG_PET_LEARNED_SPELLS); + ClientServices::ClearMessageHandler(SMSG_PET_UNLEARNED_SPELLS); + ClientServices::ClearMessageHandler(SMSG_PET_MODE); + ClientServices::ClearMessageHandler(SMSG_PET_ACTION_FEEDBACK); + ClientServices::ClearMessageHandler(SMSG_PET_BROKEN); + ClientServices::ClearMessageHandler(SMSG_PET_RENAMEABLE); + ClientServices::ClearMessageHandler(SMSG_PET_UPDATE_COMBO_POINTS); + ClientServices::ClearMessageHandler(SMSG_PET_GUIDS); +} diff --git a/WoW/Source/Ui/PetInfo.h b/WoW/Source/Ui/PetInfo.h index 861f9ca..5ac89c7 100644 --- a/WoW/Source/Ui/PetInfo.h +++ b/WoW/Source/Ui/PetInfo.h @@ -12,6 +12,7 @@ struct lua_State; class CGPetInfo { public: static void InitializeGame(); + static void ShutdownGame(); static void FindPossessedSpell(); static WOWGUID GetPet(uint32_t index); static uint32_t* FindSpellByID(int32_t spellId); diff --git a/WoW/Source/Ui/PetitionInfo.cpp b/WoW/Source/Ui/PetitionInfo.cpp index 1a43787..57df718 100644 --- a/WoW/Source/Ui/PetitionInfo.cpp +++ b/WoW/Source/Ui/PetitionInfo.cpp @@ -42,3 +42,9 @@ void CGPetitionInfo::EnterWorld() { CGPetitionInfo::m_petition = nullptr; CGPetitionInfo::m_signers.SetCount(10); } + +// VERIFY: 8452d77d auto +// OFFSET: 0x005CE9F0 +void CGPetitionInfo::ShutdownGame() { + ClientServices::ClearMessageHandler(SMSG_OFFER_PETITION_ERROR); +} diff --git a/WoW/Source/Ui/PetitionInfo.h b/WoW/Source/Ui/PetitionInfo.h index c7706e6..7f36c78 100644 --- a/WoW/Source/Ui/PetitionInfo.h +++ b/WoW/Source/Ui/PetitionInfo.h @@ -17,6 +17,7 @@ struct PetitionSignerInfo { class CGPetitionInfo { public: + static void ShutdownGame(); static WOWGUID m_petitionGUID; static WOWGUID m_petitionItem; static uint32_t unk_C22B30; diff --git a/WoW/Source/Ui/QuestLog.cpp b/WoW/Source/Ui/QuestLog.cpp index 3194523..ec08e02 100644 --- a/WoW/Source/Ui/QuestLog.cpp +++ b/WoW/Source/Ui/QuestLog.cpp @@ -32,6 +32,8 @@ #include "WoW/Source/Object/ItemStats.h" #include "WoW/Source/Ui/ChatFrame.h" #include "WoW/Source/Ui/QuestLogLeaderBoardParams.h" +#include "WoW/Source/Ui/WorldMap.h" +#include // STATIC: 0x00C23618 int32_t CGQuestLog::m_sortTypes[25]; @@ -1821,3 +1823,179 @@ int32_t CGQuestLog::SetQuestExpiredByID(int32_t questId) { return 1; } + +// VERIFY: 246aa072 manual +// OFFSET: 0x005E5A50 +int32_t CGQuestLog::UpdateAllQuestPOI() { + if (!g_questPOICVar->m_intValue) { + return 0; + } + + if (!ClntObjMgrObjectPtr(ClntObjMgrGetActivePlayer(), TYPEMASK_PLAYER, __FILE__, __LINE__)) { + return 0; + } + + WorldMapAreaRec* area = nullptr; + int32_t dungeonMapId = CGWorldMap::m_currentOrphanZone == -1 ? -1 : CGWorldMap::m_currentDungeonMap; + DungeonMapRec* dungeonMap = g_dungeonMapDB.GetRecord(dungeonMapId); + + if (!dungeonMap) { + area = g_worldMapAreaDB.GetRecord(CGWorldMap::GetCurrentAreaID()); + + if (CGWorldMap::GetCurrentAreaID() == -1 || !area) { + return 0; + } + } + + int32_t visible = 0; + + for (uint32_t i = 0; i < 25; i++) { + QuestPOIInfo& poi = CGQuestLog::m_questPOIs[i]; + poi.unk_002C = CGQuestLog::ComputeBlobQuestObjectives(poi.m_questId); + poi.unk_0028 = 0; + + for (int32_t j = 0; j < static_cast(poi.m_blobs.Count()); j++) { + QuestPOIBlob& blob = poi.m_blobs.m_data[j]; + + if (poi.unk_002C == 0xFFFFFFFF) { + if (blob.unk_001C != -1) { + continue; + } + } else if (blob.unk_001C == -1 || !((1 << blob.unk_001C) & poi.unk_002C)) { + continue; + } + + bool onMap; + + if (dungeonMap) { + onMap = CGQuestLog::IsPOIVisibleOnDungeonMap(&blob.m_centerX, blob.unk_0020, blob.unk_0028, dungeonMap->m_id); + } else { + if (!area || ((blob.unk_002C & 0x4) && blob.unk_0024 != area->m_id)) { + continue; + } + + onMap = CGQuestLog::IsPOIOnCurrentMap(&blob.m_centerX, blob.unk_0020, area->m_mapID); + } + + if (onMap) { + visible++; + poi.unk_0028 = 1; + break; + } + } + } + + return visible; +} + +// VERIFY: a01f8ce6 manual +// OFFSET: 0x005E6F30 +void CGQuestLog::ShutdownGame() { + ClientServices::ClearMessageHandler(SMSG_QUERY_TIME_RESPONSE); + + for (uint32_t i = 0; i < 25; i++) { + QuestPOIInfo* poi = &CGQuestLog::m_questPOIs[i]; + poi->m_questId = 0; + poi->m_blobs.Clear(); + } + + CGQuestLog::m_trackedQuestsLoaded = 0; + ConsoleCommandUnregister("UpdatePOI"); +} + +// VERIFY: e4df824d manual +// OFFSET: 0x005E2950 +uint32_t CGQuestLog::ComputeBlobQuestObjectives(int32_t questId) { + uint32_t result = 0; + int32_t index = CGQuestLog::GetQuestIndex(questId) - 1; + + if (index >= CGQuestLog::m_numQuest || CGQuestLog::m_quests[index].m_isHeader || index < 0) { + return 0; + } + + CGPlayer_C* player = static_cast(ClntObjMgrObjectPtr(ClntObjMgrGetActivePlayer(), TYPEMASK_PLAYER, __FILE__, __LINE__)); + + if (!player) { + return 0; + } + + uint32_t slot = CGQuestLog::m_quests[index].m_logSlot; + PlayerQuestLogEntry* entry = slot <= 25 ? &player->m_player->m_playerQuestLog[slot] : nullptr; + WOWGUID none = { 0 }; + QuestCache* quest = g_questDBCache.GetRecord(CGQuestLog::m_quests[index].m_questId, none, nullptr, nullptr, false); + + if (!quest || !entry || (entry->m_state & 2) || CGQuestLog::IsQuestFailed(index)) { + return 0; + } + + if (CGQuestLog::IsQuestCompleteEx(index, 0)) { + return 0xFFFFFFFF; + } + + for (uint32_t i = 0; i < 4; i++) { + if (quest->m_objectiveId[i] && entry->m_counts[i] < quest->m_objectiveRequiredCount[i]) { + result |= 1 << i; + } + } + + for (uint32_t i = 0; i < 6; i++) { + if (quest->m_collectItemId[i] && player->m_bag.GetItemTypeCount(quest->m_collectItemId[i], 8) < static_cast(quest->m_collectItemCount[i])) { + result |= 1 << (i + 4); + } + } + + for (uint32_t i = 0; i < 4; i++) { + uint32_t itemId = quest->m_intermediateItemId[i]; + + if (itemId && itemId != quest->m_startingItemId && !player->m_bag.GetItemTypeCount(itemId, 8)) { + result |= 1 << (i + 10); + } + } + + if ((quest->m_flags & 6) && !(entry->m_state & 1)) { + result |= 0x10000; + } + + return result; +} + +// VERIFY: 89e426ef auto +// OFFSET: 0x005E0110 +bool CGQuestLog::IsPOIOnCurrentMap(const int32_t* point, int32_t mapId, int32_t currentMapId) { + if (mapId != currentMapId) { + return false; + } + + C3Vector position(static_cast(point[0]), static_cast(point[1]), 0.0f); + float x; + float y; + bool outland; + + if (!CGWorldMap::GetWorldPosition(position, currentMapId, &x, &y, &outland, false, 0)) { + return false; + } + + return !outland && fabs(fabs(x * y)) >= 0.001f; +} + +// VERIFY: 2b97ec8b manual +// OFFSET: 0x005E0240 +void CGQuestLog::SaveTrackedQuests() { + CVarIntListWrapper list; + list.m_cvar = CVar::Lookup("trackedQuests"); + list.m_pos = 2; + list.m_state = 0; + + for (uint32_t i = 0; i < CGQuestLog::m_numQuestWatches; i++) { + if (!CGQuestLog::m_questWatches[i].m_expireTime) { + list.AddNextValue(CGQuestLog::m_questWatches[i].m_questId); + } + } + + if (list.m_state != 1) { + list.m_buffer[0] = 'v'; + list.m_buffer[1] = 1; + list.m_buffer[list.m_pos] = 0; + list.m_cvar->Set(list.m_buffer, true, false, false, true); + } +} diff --git a/WoW/Source/Ui/QuestLog.h b/WoW/Source/Ui/QuestLog.h index 0d01403..3983dda 100644 --- a/WoW/Source/Ui/QuestLog.h +++ b/WoW/Source/Ui/QuestLog.h @@ -75,7 +75,11 @@ int32_t CountQuestItemDropsNeeded(int32_t questId, void (*callback)(int32_t id, class CGQuestLog { public: + static void SaveTrackedQuests(); static int32_t UpdateAllQuestPOI(); + static uint32_t ComputeBlobQuestObjectives(int32_t questId); + static bool IsPOIVisibleOnDungeonMap(const int32_t* point, int32_t mapId, int32_t floor, int32_t dungeonMapId); + static bool IsPOIOnCurrentMap(const int32_t* point, int32_t mapId, int32_t currentMapId); static int32_t GetQuestLogSlot(int32_t index); static int32_t IsOnQuest(int32_t questId); static int32_t FindOrFreePOISlot(int32_t questId); @@ -126,6 +130,7 @@ class CGQuestLog { static int32_t GetQuestGreenRange(); static void InitializeGame(); + static void ShutdownGame(); static int32_t GetQuestAt(int32_t index); static int32_t GetQuestLeaderBoardForItem(int32_t questId, int32_t itemId, QuestLogLeaderBoardParams* params); static int32_t IsQuestCompleteEx(uint32_t index, int32_t a2); diff --git a/WoW/Source/Ui/RaidInfo.cpp b/WoW/Source/Ui/RaidInfo.cpp index 6750fe1..fad9d12 100644 --- a/WoW/Source/Ui/RaidInfo.cpp +++ b/WoW/Source/Ui/RaidInfo.cpp @@ -14,6 +14,7 @@ #include "Engine/Source/Base/CDataStore.h" #include "WoW/Source/Net/Types.h" #include "WoW/Source/Ui/ScriptEvents.h" +#include "WoW/Source/Client.h" // STATIC: 0x00BEB568 CGRaidMember* CGRaidInfo::m_members[40]; @@ -364,3 +365,24 @@ void CGRaidInfo::EnableMember(CGPlayer_C* player, int32_t enable) { msg.Finalize(); ClientServices::Send2(&msg); } + +// VERIFY: 9571779b manual +// OFFSET: 0x00574310 +void CGRaidInfo::ShutdownGame() { + ClientServices::ClearMessageHandler(MSG_RAID_TARGET_UPDATE); + ClientServices::ClearMessageHandler(MSG_RAID_READY_CHECK); + ClientServices::ClearMessageHandler(MSG_RAID_READY_CHECK_CONFIRM); + ClientServices::ClearMessageHandler(MSG_RAID_READY_CHECK_FINISHED); + ClientServices::ClearMessageHandler(SMSG_READY_CHECK_ERROR); + ClientServices::ClearMessageHandler(MSG_NOTIFY_PARTY_SQUELCH); + ClientServices::ClearMessageHandler(SMSG_ECHO_PARTY_SQUELCH); + + for (uint32_t i = 0; i < 40; i++) { + delete CGRaidInfo::m_members[i]; + CGRaidInfo::m_members[i] = nullptr; + } + + if (CGRaidInfo::m_readyCheckTimer) { + ClientKillTimer(CGRaidInfo::m_readyCheckTimer, CGRaidInfo::ProcessReadyCheckTimer, "ProcessReadyCheckTimer"); + } +} diff --git a/WoW/Source/Ui/RaidInfo.h b/WoW/Source/Ui/RaidInfo.h index 45d7c5a..cc0c8ed 100644 --- a/WoW/Source/Ui/RaidInfo.h +++ b/WoW/Source/Ui/RaidInfo.h @@ -43,6 +43,8 @@ class CGRaidInfo { static void EnterWorld(); static void InitializeGame(); + static void ShutdownGame(); + static int32_t ProcessReadyCheckTimer(const void* data, void* param); static int32_t GetPartyMemberIndex(WOWGUID guid); static int32_t IsPartyMemberReadyCheckPending(uint32_t index); static int32_t IsPartyMemberReadyCheckReady(uint32_t index); diff --git a/WoW/Source/Ui/ReputationInfo.cpp b/WoW/Source/Ui/ReputationInfo.cpp index b92814f..7426ce8 100644 --- a/WoW/Source/Ui/ReputationInfo.cpp +++ b/WoW/Source/Ui/ReputationInfo.cpp @@ -15,6 +15,7 @@ #include "WoW/Source/Object/ObjectClient/Effect_C.h" #include "WoW/Source/Ui/QuestLog.h" #include "WoW/Source/Ui/Tutorial.h" +#include // STATIC: 0x00C22B70 FactionStanding CGReputationInfo::m_factionStandings[128]; @@ -847,3 +848,30 @@ int32_t GetRepListRepValue(int32_t faction) { return CGReputationInfo::m_factionStandings[rec->m_reputationIndex].m_base + CGReputationInfo::m_factionStandings[rec->m_reputationIndex].m_standing; } + +// VERIFY: 5e6896c2 manual +// OFFSET: 0x005D14F0 +void CGReputationInfo::ShutdownGame() { + CGReputationInfo::m_numFactions = 0; + CGReputationInfo::m_numShownFactions = 0; + CGReputationInfo::m_numHeaders = 0; + CGReputationInfo::m_selectedFaction = 0; + ClientServices::ClearMessageHandler(SMSG_INITIALIZE_FACTIONS); + ClientServices::ClearMessageHandler(SMSG_SET_FACTION_AT_WAR); + ClientServices::ClearMessageHandler(SMSG_SET_FACTION_VISIBLE); + ClientServices::ClearMessageHandler(SMSG_SET_FACTION_STANDING); + ClientServices::ClearMessageHandler(SMSG_SET_FORCED_REACTIONS); + + for (uint32_t i = 0; i < CGReputationInfo::m_factionList.m_count; i++) { + delete CGReputationInfo::m_factionList.m_data[i]; + CGReputationInfo::m_factionList.m_data[i] = nullptr; + } + + for (uint32_t i = 0; i < 64; i++) { + delete CGReputationInfo::m_headers[i]; + CGReputationInfo::m_headers[i] = nullptr; + } + + CGReputationInfo::m_forcedReactions.m_count = 0; + memset(CGReputationInfo::m_factionStandings, 0, sizeof(CGReputationInfo::m_factionStandings)); +} diff --git a/WoW/Source/Ui/ReputationInfo.h b/WoW/Source/Ui/ReputationInfo.h index 28062a8..8138191 100644 --- a/WoW/Source/Ui/ReputationInfo.h +++ b/WoW/Source/Ui/ReputationInfo.h @@ -64,6 +64,7 @@ class CGReputationInfo { static void SortFactions(); static bool IsFactionInactive(uint32_t index); static void InitializeGame(); + static void ShutdownGame(); static bool GetForcedReaction(int32_t faction, int32_t* reaction); static int32_t GetFactionStandingReaction(int32_t faction); static bool IsAtWar(int32_t faction); diff --git a/WoW/Source/Ui/RuneInfo.cpp b/WoW/Source/Ui/RuneInfo.cpp index 838e03a..2cceb3f 100644 --- a/WoW/Source/Ui/RuneInfo.cpp +++ b/WoW/Source/Ui/RuneInfo.cpp @@ -299,3 +299,8 @@ bool CGRuneInfo::ComputeRuneSpellCooldown(const SpellRec* spell, uint32_t* coold *cooldown = blood <= other ? other : blood; return true; } + +// VERIFY: 31a366a2 auto +// OFFSET: 0x005EEB70 +void CGRuneInfo::ShutdownGame() { +} diff --git a/WoW/Source/Ui/RuneInfo.h b/WoW/Source/Ui/RuneInfo.h index 5e829a9..315dd28 100644 --- a/WoW/Source/Ui/RuneInfo.h +++ b/WoW/Source/Ui/RuneInfo.h @@ -19,6 +19,7 @@ class CGRuneInfo { static uint32_t m_predictedRunes; static void SetPredictedRunes(uint8_t available, uint8_t used, const uint8_t* cooldowns); static void InitializeGame(); + static void ShutdownGame(); static bool HasRunesForSpell(int32_t spellId, int32_t* needed); static uint32_t GetRuneRechargeTime(int32_t index); static int32_t CountPredictedRunesOfType(int32_t type); diff --git a/WoW/Source/Ui/ScriptEvents.cpp b/WoW/Source/Ui/ScriptEvents.cpp index 251f0dd..d646004 100644 --- a/WoW/Source/Ui/ScriptEvents.cpp +++ b/WoW/Source/Ui/ScriptEvents.cpp @@ -1093,3 +1093,9 @@ int32_t PushUnitAura(lua_State* L, ScriptAuraInfo* info) { return 0; } + +// VERIFY: 9260c5f6 auto +// OFFSET: 0x006147B0 +void ClearUniqueSignals() { + s_uniqueSignals.m_count = 0; +} diff --git a/WoW/Source/Ui/ScriptEvents.h b/WoW/Source/Ui/ScriptEvents.h index 8ef7b8b..f27d1fd 100644 --- a/WoW/Source/Ui/ScriptEvents.h +++ b/WoW/Source/Ui/ScriptEvents.h @@ -52,4 +52,6 @@ void Script_SendUnitSpellSignal(const WOWGUID& guid, uint8_t castCount, const Sp void ScriptEventsRegisterUnit(CGUnit_C* unit); void ScriptEventsUnregisterUnit(CGUnit_C* unit); +void ClearUniqueSignals(); + #endif diff --git a/WoW/Source/Ui/ScriptEvents_Scripts.cpp b/WoW/Source/Ui/ScriptEvents_Scripts.cpp index 32c7d7e..32dc17e 100644 --- a/WoW/Source/Ui/ScriptEvents_Scripts.cpp +++ b/WoW/Source/Ui/ScriptEvents_Scripts.cpp @@ -127,7 +127,6 @@ int32_t Script_UnitIsSameServer(lua_State* L); int32_t Script_GetUnitHealthModifier(lua_State* L); int32_t Script_GetUnitMaxHealthModifier(lua_State* L); int32_t Script_GetUnitPowerModifier(lua_State* L); -int32_t Script_GetUnitManaRegenRateFromSpirit(lua_State* L); int32_t Script_GetManaRegen(lua_State* L); int32_t Script_GetPowerRegen(lua_State* L); int32_t Script_GetRuneCount(lua_State* L); @@ -150,7 +149,6 @@ int32_t Script_UnitSwitchToVehicleSeat(lua_State* L); int32_t Script_CanSwitchVehicleSeat(lua_State* L); int32_t Script_GetVehicleUIIndicator(lua_State* L); int32_t Script_GetVehicleUIIndicatorSeat(lua_State* L); -int32_t Script_UnitDetailedThreatSituation(lua_State* L); int32_t Script_UnitIsControlling(lua_State* L); int32_t Script_EjectPassengerFromSeat(lua_State* L); int32_t Script_CanEjectPassengerFromSeat(lua_State* L); @@ -2621,6 +2619,47 @@ static int32_t Script_UnitThreatSituation(lua_State* L) { return 1; } +// VERIFY: 8d073de3 manual +// OFFSET: 0x00613B40 +static int32_t Script_UnitDetailedThreatSituation(lua_State* L) { + WOWGUID unitGuid; + WOWGUID mobGuid; + + if (!Script_GetGUIDFromToken(lua_tolstring(L, 1, nullptr), unitGuid, false) || !Script_GetGUIDFromToken(lua_tolstring(L, 2, nullptr), mobGuid, false)) { + luaL_error(L, "Usage: UnitDetailedThreatSituation(\"unit\" [, \"mob\"])"); + return 0; + } + + CGUnit_C* mob = static_cast(ClntObjMgrObjectPtr(mobGuid, TYPEMASK_UNIT, __FILE__, __LINE__)); + + if (!mob) { + return 0; + } + + uint8_t status; + uint8_t rawPercent; + float percent; + int32_t threat; + mob->CalculateThreat(unitGuid, &status, &rawPercent, &percent, &threat); + + if (!status) { + return 0; + } + + if (mob->m_highestThreatGuid == unitGuid) { + lua_pushnumber(L, 1.0); + } else { + lua_pushnil(L); + } + + lua_pushnumber(L, status - 1); + lua_pushnumber(L, percent); + lua_pushnumber(L, rawPercent); + lua_pushnumber(L, threat); + + return 5; +} + // VERIFY: 4231ad42 auto // OFFSET: 0x00614CA0 static int32_t Script_UnitBuff(lua_State* L) { @@ -3378,6 +3417,24 @@ void SystemUnregisterFunctions() { } } +// VERIFY: a8ddc867 auto +// OFFSET: 0x00612A00 +static int32_t Script_GetUnitManaRegenRateFromSpirit(lua_State* L) { + if (!lua_isstring(L, 1)) { + luaL_error(L, "Usage: GetUnitManaRegenRateFromSpirit(\"unit\")"); + } + + CGUnit_C* unit = GetUnitFromName(lua_tolstring(L, 1, nullptr)); + + if (unit && (unit->IsActivePlayer() || unit->m_unit->m_unitFieldPetnumber)) { + lua_pushnumber(L, unit->GetManaRegenRateFromSpirit() + 0.001); + } else { + lua_pushnumber(L, 0.0); + } + + return 1; +} + // STATIC: 0x00AD21D8 static FrameScript_Method s_UnitFunctions[] = { { "UnitExists", &Script_UnitExists }, diff --git a/WoW/Source/Ui/SkillInfo.cpp b/WoW/Source/Ui/SkillInfo.cpp index b1c1561..99f326d 100644 --- a/WoW/Source/Ui/SkillInfo.cpp +++ b/WoW/Source/Ui/SkillInfo.cpp @@ -267,3 +267,17 @@ int32_t CGSkillInfo::GetSkillTypeCollapsed(uint32_t index) { return 0; } + +// VERIFY: 3727cac0 manual +// OFFSET: 0x005CD3A0 +void CGSkillInfo::ShutdownGame() { + for (uint32_t i = 0; i < CGSkillInfo::m_lines.m_count; i++) { + delete CGSkillInfo::m_lines.m_data[i]; + CGSkillInfo::m_lines.m_data[i] = nullptr; + } + + for (uint32_t i = 0; i < CGSkillInfo::m_types.m_count; i++) { + delete CGSkillInfo::m_types.m_data[i]; + CGSkillInfo::m_types.m_data[i] = nullptr; + } +} diff --git a/WoW/Source/Ui/SkillInfo.h b/WoW/Source/Ui/SkillInfo.h index b5b0ffe..5b1d5af 100644 --- a/WoW/Source/Ui/SkillInfo.h +++ b/WoW/Source/Ui/SkillInfo.h @@ -33,6 +33,7 @@ class CGSkillInfo { static TSFixedArray m_lines; static TSFixedArray m_types; static void InitializeGame(); + static void ShutdownGame(); static int32_t GetSelectedIndex(); static void UpdateSkillLines(); static int32_t GetSkillTypeCollapsed(uint32_t index); diff --git a/WoW/Source/Ui/SpellBookFrame.cpp b/WoW/Source/Ui/SpellBookFrame.cpp index 111601d..7f8968a 100644 --- a/WoW/Source/Ui/SpellBookFrame.cpp +++ b/WoW/Source/Ui/SpellBookFrame.cpp @@ -2159,3 +2159,22 @@ void CGSpellBook::DelKnownSpell(int32_t spellId, int32_t notify) { CGSpellBook::UpdateSpells(removed, 0, 1); } + +// VERIFY: 1789a24e manual +// OFFSET: 0x0053F290 +void CGSpellBook::ShutdownGame() { + for (uint32_t i = 0; i < s_skillInfos.m_count; i++) { + delete s_skillInfos.m_data[i]; + } + + s_skillInfos.Clear(); + s_numSkillInfos = 0; + s_knownSpellBits.m_count = 0; + + if (s_knownSpellBits.m_bits.m_count) { + s_knownSpellBits.m_bits.Clear(); + } + + CGSpellBook::m_languageSpells.Clear(); + s_spellsByName.Clear(); +} diff --git a/WoW/Source/Ui/SpellBookFrame.h b/WoW/Source/Ui/SpellBookFrame.h index d3ef5a7..b63ccba 100644 --- a/WoW/Source/Ui/SpellBookFrame.h +++ b/WoW/Source/Ui/SpellBookFrame.h @@ -74,6 +74,7 @@ class CGSpellBook { static void UpdateUsable(); static void CastSpell(int32_t spellId, int32_t petSpell, WOWGUID target); static void InitializeGame(); + static void ShutdownGame(); static void MakeKnownSpellModelsLocal(); static int32_t GetSkinningSpell(const CGUnit_C* unit); static void ReplaceSpell(int32_t oldSpell, int32_t newSpell); diff --git a/WoW/Source/Ui/StableInfo.cpp b/WoW/Source/Ui/StableInfo.cpp index 59099df..c10a164 100644 --- a/WoW/Source/Ui/StableInfo.cpp +++ b/WoW/Source/Ui/StableInfo.cpp @@ -48,3 +48,10 @@ void CGStableInfo::EnterWorld() { CGStableInfo::unk_C0F6D0 = 0; memset(&CGStableInfo::m_pets[0], 0, sizeof(CGStableInfo::m_pets[0])); } + +// VERIFY: c3ced28b auto +// OFFSET: 0x005A0EF0 +void CGStableInfo::ShutdownGame() { + ClientServices::ClearMessageHandler(MSG_LIST_STABLED_PETS); + ClientServices::ClearMessageHandler(SMSG_STABLE_RESULT); +} diff --git a/WoW/Source/Ui/StableInfo.h b/WoW/Source/Ui/StableInfo.h index 8480034..decd8d2 100644 --- a/WoW/Source/Ui/StableInfo.h +++ b/WoW/Source/Ui/StableInfo.h @@ -18,6 +18,7 @@ struct StablePetInfo { class CGStableInfo { public: + static void ShutdownGame(); static StablePetInfo m_pets[6]; static WOWGUID m_stableMaster; static int32_t unk_C0F6C8; diff --git a/WoW/Source/Ui/TaxiMapFrame.cpp b/WoW/Source/Ui/TaxiMapFrame.cpp index 8f2a407..d59919e 100644 --- a/WoW/Source/Ui/TaxiMapFrame.cpp +++ b/WoW/Source/Ui/TaxiMapFrame.cpp @@ -3,6 +3,9 @@ #include "WoW/Source/DB/Rec/TaxiNodesRec.h" #include "WoW/Source/DB/Rec/TaxiPathRec.h" #include "WoW/Source/DB/Rec/TaxiPathNodeRec.h" +#include "Engine/Source/Storm/H/storm.h" +#include "Engine/Source/Base/Types.h" +#include "Engine/Source/Services/Texture.h" // STATIC: 0x00C0D7E0 CTexture* CGTaxiMap::m_mapTexture; @@ -34,6 +37,9 @@ static TSGrowableArray s_nodeMask; // STATIC: 0x00C0DC50 static TSFixedArray> s_paths; +// STATIC: 0x00C0DC60 +static TSGrowableArray s_taxiLines; + // STATIC: 0x00C0DC70 static TSGrowableArray s_unkC0DC70; @@ -90,3 +96,27 @@ void CGTaxiMap::InitializeGame() { } } } + +// VERIFY: 7b70e52d manual +// OFFSET: 0x00591A10 +void CGTaxiMap::FreeRouteLines() { + if (CGTaxiMap::m_mapTexture) { + HandleClose(reinterpret_cast(CGTaxiMap::m_mapTexture)); + CGTaxiMap::m_mapTexture = nullptr; + } + + s_taxiLines.Clear(); + + for (uint32_t i = 0; i < CGTaxiMap::m_maxNodeID; i++) { + CGTaxiMap::m_routeLines.m_data[i].Clear(); + } + + CGTaxiMap::m_numNodes = 0; +} + +// VERIFY: 7911d34a auto +// OFFSET: 0x005920D0 +void CGTaxiMap::ShutdownGame() { + s_pathNodes.InternalClear(0); + CGTaxiMap::FreeRouteLines(); +} diff --git a/WoW/Source/Ui/TaxiMapFrame.h b/WoW/Source/Ui/TaxiMapFrame.h index a969041..47442c5 100644 --- a/WoW/Source/Ui/TaxiMapFrame.h +++ b/WoW/Source/Ui/TaxiMapFrame.h @@ -31,6 +31,11 @@ struct TAXIPATHNODESCLIENT : public TSHashObject CGTradeSkillInfo::m_displayList; @@ -613,3 +619,56 @@ void CGTradeSkillInfo::RefreshList(int32_t full) { FrameScript_SignalEvent(SCRIPT_EVENT_TRADE_SKILL_UPDATE, nullptr); } + +// VERIFY: 9ddd6131 manual +// OFFSET: 0x005DCAF0 +void CGTradeSkillInfo::ShutdownGame() { + for (uint32_t i = 0; i < CGTradeSkillInfo::m_displayList.m_count; i++) { + delete CGTradeSkillInfo::m_displayList.m_data[i]; + } + + for (uint32_t i = 0; i < CGTradeSkillInfo::m_subClassList.m_count; i++) { + delete CGTradeSkillInfo::m_subClassList.m_data[i]; + } + + CGTradeSkillInfo::m_playerGuid = WOWGUID(); + CGTradeSkillInfo::m_spellID = 0; + CGTradeSkillInfo::m_skillLineID = 0; + CGTradeSkillInfo::m_displayList.Clear(); + CGTradeSkillInfo::m_subClassList.Clear(); + CGTradeSkillInfo::m_numDisplayEntries = 0; + CGTradeSkillInfo::m_filteredSkills = 0; + CGTradeSkillInfo::m_numSubClasses = 0; + + if (CGTradeSkillInfo::m_itemNameFilter) { + SMemFree(CGTradeSkillInfo::m_itemNameFilter, __FILE__, __LINE__, 0); + } + + CGTradeSkillInfo::m_itemNameFilter = nullptr; + CGTradeSkillInfo::unk_C235F0 = 0; + CGTradeSkillInfo::m_recastSpellID = 0; + CGTradeSkillInfo::m_pendingRecastSpellID = 0; + + if (CGTradeSkillInfo::m_linkData) { + SMemFree(CGTradeSkillInfo::m_linkData, __FILE__, __LINE__, 0); + } + + CGTradeSkillInfo::m_linkData = nullptr; + CGTradeSkillInfo::m_skillRank = 0; + CGTradeSkillInfo::m_skillMaxRank = 0; +} + +// VERIFY: 9c6c8940 manual +// OFFSET: 0x005DA5A0 +void CGTradeSkillInfo::Close() { + CGTradeSkillInfo::m_spellID = 0; + CGTradeSkillInfo::m_skillLineID = 0; + + if (CGTradeSkillInfo::m_recastSpellID || CGTradeSkillInfo::m_pendingRecastSpellID) { + CGTradeSkillInfo::m_recastSpellID = 0; + CGTradeSkillInfo::m_pendingRecastSpellID = 0; + FrameScript_SignalEvent(SCRIPT_EVENT_UPDATE_TRADESKILL_RECAST, nullptr); + } + + FrameScript_SignalEvent(SCRIPT_EVENT_TRADE_SKILL_CLOSE, nullptr); +} diff --git a/WoW/Source/Ui/TradeSkillFrame.h b/WoW/Source/Ui/TradeSkillFrame.h index 2a4f984..ee256fc 100644 --- a/WoW/Source/Ui/TradeSkillFrame.h +++ b/WoW/Source/Ui/TradeSkillFrame.h @@ -29,6 +29,8 @@ struct TradeSkillSubClassInfo { class CGTradeSkillInfo { public: + static void Close(); + static void ShutdownGame(); static WOWGUID m_playerGuid; static uint32_t m_itemsPending; static uint32_t m_numDisplayEntries; @@ -37,6 +39,8 @@ class CGTradeSkillInfo { static int32_t m_showOnlySkillUps; static uint32_t m_invSlots; static int32_t m_skillRank; + static int32_t m_skillMaxRank; + static int32_t unk_C235F0; static TSGrowableArray m_displayList; static TSGrowableArray m_subClassList; static uint32_t m_subClassFilter; diff --git a/WoW/Source/Ui/Tutorial.cpp b/WoW/Source/Ui/Tutorial.cpp index 81c3517..1afa0d5 100644 --- a/WoW/Source/Ui/Tutorial.cpp +++ b/WoW/Source/Ui/Tutorial.cpp @@ -123,3 +123,32 @@ void CGTutorial::LoadFlaggedTutorials() { list.m_cvar->Set(text, true, false, false, true); } } + +// VERIFY: 01796b88 auto +// OFFSET: 0x005EEB70 +void CGTutorial::ShutdownGame() { +} + +// VERIFY: f7491634 manual +// OFFSET: 0x00530300 +void CGTutorial::SaveFlaggedTutorials() { + CVarIntListWrapper list; + list.m_cvar = CVar::Lookup("flaggedTutorials"); + list.m_pos = 2; + list.m_state = 0; + + for (uint32_t i = 0; i < 60; i++) { + if (!s_tutorialsCompleted[i]) { + break; + } + + list.AddNextValue(s_tutorialsCompleted[i]); + } + + if (list.m_state != 1) { + list.m_buffer[0] = 'v'; + list.m_buffer[1] = 1; + list.m_buffer[list.m_pos] = 0; + list.m_cvar->Set(list.m_buffer, true, false, false, true); + } +} diff --git a/WoW/Source/Ui/Tutorial.h b/WoW/Source/Ui/Tutorial.h index 9ae72c4..990a387 100644 --- a/WoW/Source/Ui/Tutorial.h +++ b/WoW/Source/Ui/Tutorial.h @@ -10,7 +10,9 @@ struct lua_State; class CGTutorial { public: + static void SaveFlaggedTutorials(); static void InitializeGame(); + static void ShutdownGame(); static void LoadFlaggedTutorials(); static TSBitField > m_tutorialShown; static TSBitField > m_tutorialFlags; diff --git a/WoW/Source/Ui/UILCD/LCD.cpp b/WoW/Source/Ui/UILCD/LCD.cpp index a591827..f2809f0 100644 --- a/WoW/Source/Ui/UILCD/LCD.cpp +++ b/WoW/Source/Ui/UILCD/LCD.cpp @@ -38,6 +38,15 @@ uint8_t CGLCD::m_inWorld; // STATIC: 0x00D4131D static uint8_t s_classFlag8; +// STATIC: 0x00D4131E +static uint8_t s_unk_D4131E; + +// STATIC: 0x00B1C098 +static int32_t s_currentScreen = -1; + +// STATIC: 0x00B1C09C +static int32_t s_previousScreen = -1; + // STATIC: 0x00B1C0A0 static int32_t s_unk_B1C0A0; @@ -178,3 +187,32 @@ void CGLCD::Login() { const char* text = FrameScript_GetText("BF_NOT_IN", -1, GENDER_NOT_APPLICABLE); CGLCD::m_lcd->SetText(CGLCD::GetHandle("BF_NOT_IN"), text); } + +// VERIFY: 638d6a34 auto +// OFFSET: 0x00848100 +void CGLCD::SetScreen(int32_t screen) { + if (screen == s_currentScreen) { + return; + } + + s_previousScreen = s_currentScreen; + s_currentScreen = screen; + CGLCD::m_lcd->ShowPage(screen); + CGLCD::m_lcd->HideGlobals(); +} + +// VERIFY: 6e17fc01 auto +// OFFSET: 0x008481F0 +void CGLCD::Logout() { + if (!CGLCD::m_lcd || !CGLCD::m_lcd->IsConnected() || !IsLCDAvailable()) { + return; + } + + if (CGLCD::initComplete) { + CGLCD::m_inWorld = 0; + CGLCD::SetScreen(0); + s_unk_D4131E = 0; + CGLCD::m_player = nullptr; + CGLCD::m_lcd->Update(); + } +} diff --git a/WoW/Source/Ui/UILCD/LCD.h b/WoW/Source/Ui/UILCD/LCD.h index 6e6b1ef..dc142ed 100644 --- a/WoW/Source/Ui/UILCD/LCD.h +++ b/WoW/Source/Ui/UILCD/LCD.h @@ -19,6 +19,7 @@ struct POIIcon : public TSLinkedNode { class CGLCD { public: + static void Logout(); static CEzLcd* m_lcd; static int32_t m_chatAlertLines; static uint8_t initComplete; diff --git a/WoW/Source/Ui/UILCD/Windows/EZ_LCD.h b/WoW/Source/Ui/UILCD/Windows/EZ_LCD.h index b325af0..1f1ada8 100644 --- a/WoW/Source/Ui/UILCD/Windows/EZ_LCD.h +++ b/WoW/Source/Ui/UILCD/Windows/EZ_LCD.h @@ -53,6 +53,8 @@ class CEzLcd { void SetText(void* handle, const char* text); int32_t IsDeviceAvailable(int32_t type); void Update(); + int32_t ShowPage(int32_t page); + void HideGlobals(); }; #endif diff --git a/WoW/Source/Ui/UIMacros.cpp b/WoW/Source/Ui/UIMacros.cpp index 7d0d715..2a32e73 100644 --- a/WoW/Source/Ui/UIMacros.cpp +++ b/WoW/Source/Ui/UIMacros.cpp @@ -26,6 +26,7 @@ #include "WoW/Source/Ui/SpellBookFrame.h" #include "WoW/Source/Object/ObjectClient/Bag_C.h" #include "WoW/Source/Object/ObjectClient/Player_C.h" +#include "WoW/Source/Ui/MacroConditions.h" // STATIC: 0x00ACE2A0 static TSExplicitList s_dynamicMacros; @@ -39,6 +40,9 @@ static TSHashTable s_macros; // STATIC: 0x00ACE1E8 static const char* s_macroIconPath = "Interface\\Icons\\"; +// STATIC: 0x00BEAF40 +int32_t CGUIMacros::m_saveMacros; + // STATIC: 0x00BEAF44 uint32_t CGUIMacros::m_state; @@ -878,3 +882,69 @@ int32_t MACRONODE::FindSpellID() { return 0; } + +// VERIFY: 4415731b manual +// OFFSET: 0x00566530 +void CGUIMacros::Shutdown() { + s_initCounter++; + s_dynamicMacros.UnlinkAll(); + s_macros.Clear(); + + for (uint32_t i = s_macroIcons.Count(); i; i--) { + SMemFree(s_macroIcons.m_data[i - 1], __FILE__, __LINE__, 0); + } + + s_macroIcons.Clear(); + + for (uint32_t i = s_macroItemIcons.Count(); i; i--) { + SMemFree(s_macroItemIcons.m_data[i - 1], __FILE__, __LINE__, 0); + } + + s_macroItemIcons.Clear(); + CGUIMacros::m_numMacros[0] = 0; + CGUIMacros::m_numMacros[1] = 0; + s_macroConditions.Clear(); +} + +// VERIFY: 55fecf8f auto +// OFFSET: 0x005668F0 +void CGUIMacros::SaveMacrosCallback(HOSFILE localFile, HOSFILE cacheFile, void* param) { + if (cacheFile == OS_INVALID_FILE) { + return; + } + + uint32_t set = static_cast(reinterpret_cast(param)); + uint32_t written = 0; + + for (uint32_t i = 0; i < CGUIMacros::m_numMacros[set]; i++) { + MACRONODE* macro = s_macros.Ptr(CGUIMacros::m_sortedMacros[36 * set + i], HASHKEY_NONE()); + char text[1536]; + SStrPrintf(text, sizeof(text), "MACRO %d \"%s\" %s\r\n", macro->m_id, macro->m_name, macro->m_icon); + const char* body = macro->m_body; + + while (body && *body) { + char line[1024]; + SStrTokenize(&body, line, sizeof(line), "\r\n", nullptr); + + if (line[0]) { + SStrPack(text, line, sizeof(text)); + SStrPack(text, "\r\n", sizeof(text)); + } + } + + SStrPack(text, "END\r\n", sizeof(text)); + OsWriteFile(cacheFile, text, SStrLen(text), &written); + } +} + +// VERIFY: 67e45d3d auto +// OFFSET: 0x00566A30 +void CGUIMacros::SaveMacros() { + if (!CGUIMacros::m_saveMacros) { + return; + } + + CGUIMacros::m_saveMacros = 0; + SaveAccountData(4, CGUIMacros::SaveMacrosCallback, nullptr); + SaveAccountData(5, CGUIMacros::SaveMacrosCallback, reinterpret_cast(1)); +} diff --git a/WoW/Source/Ui/UIMacros.h b/WoW/Source/Ui/UIMacros.h index d572e47..938f65e 100644 --- a/WoW/Source/Ui/UIMacros.h +++ b/WoW/Source/Ui/UIMacros.h @@ -43,10 +43,13 @@ void MacroQueryCastSequence(MacroSubstring* text); class CGUIMacros { public: + static void SaveMacros(); + static void Shutdown(); static uint32_t m_state; static const char* m_macroRunning; static MACRONODE* m_macroButton; static uint32_t m_numMacros[2]; + static int32_t m_saveMacros; static uint32_t m_sortedMacros[72]; static MACRONODE* FindMacro(const char* name); @@ -63,6 +66,7 @@ class CGUIMacros { static void CheckActionBar(); static void LoadMacros(); static void LoadMacrosCallback(HOSFILE localFile, HOSFILE cacheFile, void* param); + static void SaveMacrosCallback(HOSFILE localFile, HOSFILE cacheFile, void* param); static void RunMacro(MACRONODE* macro, const char* button); static void UpdateDynamicMacros(); static void RunMacro(int32_t id, const char* button); diff --git a/WoW/Source/Ui/WorldFrame.cpp b/WoW/Source/Ui/WorldFrame.cpp index 97b28e0..62180d0 100644 --- a/WoW/Source/Ui/WorldFrame.cpp +++ b/WoW/Source/Ui/WorldFrame.cpp @@ -2409,3 +2409,45 @@ int32_t CGWorldFrame::SpellEffectEnumProc(void* param, uint32_t flags, uint64_t return 1; } + +// VERIFY: 57ad68af manual +// OFFSET: 0x004FA390 +CGWorldFrame::~CGWorldFrame() { + EventUnregisterEx(EVENT_ID_IDLE, CGWorldFrame::Update, this, 0xFFFFFFFF); + EventSetMouseMode(MOUSE_MODE_NORMAL, 0); + CGWorldFrame::s_currentWorldFrame = nullptr; + + for (uint32_t i = 0; i < sizeof(s_spellShadowTexture) / sizeof(s_spellShadowTexture[0]); i++) { + if (s_spellShadowTexture[i]) { + HandleClose(reinterpret_cast(s_spellShadowTexture[i])); + } + + s_spellShadowTexture[i] = nullptr; + } + + SmartScreenRectShutdown(); + Spell_C_ClearInTransitList(); + this->m_modelList.Clear(); + this->m_hitModelList.Clear(); + this->m_freeModelList.Clear(); + delete this->m_camera; + this->m_camera = nullptr; + + if (CGWorldFrame::ffxEffectGlow) { + delete CGWorldFrame::ffxEffectGlow; + } + + if (CGWorldFrame::ffxEffectDeath) { + delete CGWorldFrame::ffxEffectDeath; + } + + if (CGWorldFrame::ffxEffectNetherWorld) { + delete CGWorldFrame::ffxEffectNetherWorld; + } + + if (CGWorldFrame::ffxEffectSwirlingFog) { + delete CGWorldFrame::ffxEffectSwirlingFog; + } + + FFX::Destroy(); +} diff --git a/WoW/Source/Ui/WorldMap.cpp b/WoW/Source/Ui/WorldMap.cpp index a054bfd..a061d1d 100644 --- a/WoW/Source/Ui/WorldMap.cpp +++ b/WoW/Source/Ui/WorldMap.cpp @@ -1167,3 +1167,42 @@ void CGWorldMap::RefreshCurrentMap() { CGWorldMap::SetMap(CGWorldMap::m_currentContinent, CGWorldMap::m_currentOrphanZone, CGWorldMap::m_currentDungeonMap); } } + +// VERIFY: 3d6efa14 manual +// OFFSET: 0x00542FB0 +void CGWorldMap::ClearArrowFrames() { + if (CGWorldMap::m_playerArrowFrame) { + delete CGWorldMap::m_playerArrowFrame; + CGWorldMap::m_playerArrowFrame = nullptr; + } + + if (CGWorldMap::m_playerArrowEffectFrame) { + delete CGWorldMap::m_playerArrowEffectFrame; + CGWorldMap::m_playerArrowEffectFrame = nullptr; + } + + if (CGWorldMap::m_playerMiniArrowFrame) { + delete CGWorldMap::m_playerMiniArrowFrame; + CGWorldMap::m_playerMiniArrowFrame = nullptr; + } + + if (CGWorldMap::m_playerMiniArrowEffectFrame) { + delete CGWorldMap::m_playerMiniArrowEffectFrame; + CGWorldMap::m_playerMiniArrowEffectFrame = nullptr; + } +} + +// VERIFY: f429796e manual +// OFFSET: 0x00547D20 +void CGWorldMap::ShutdownGame() { + CGWorldMap::ClearArrowFrames(); + + for (uint32_t i = 0; i < CGWorldMap::m_continents.m_count; i++) { + CGWorldMap::m_continents.m_data[i].m_zones.Clear(); + } + + CGWorldMap::m_continents.Clear(); + CGWorldMap::m_landmarks.Clear(); + CGWorldMap::m_overlays.Clear(); + CGWorldMap::m_orphanZones.Clear(); +} diff --git a/WoW/Source/Ui/WorldMap.h b/WoW/Source/Ui/WorldMap.h index 5fc0b79..3657d48 100644 --- a/WoW/Source/Ui/WorldMap.h +++ b/WoW/Source/Ui/WorldMap.h @@ -76,6 +76,8 @@ class CGWorldMap { static void CreateArrowFrame(CSimpleFrame* parent); static void EnterWorld(); static void InitializeGame(); + static void ShutdownGame(); + static void ClearArrowFrames(); static void SetMapToCurrentZone(int32_t debug); static void RefreshCurrentMap(); static void SetMap(uint32_t continent, uint32_t zone, int32_t dungeonMap); diff --git a/WoW/Source/Win64/BotCheck.cpp b/WoW/Source/Win64/BotCheck.cpp new file mode 100644 index 0000000..c6742ae --- /dev/null +++ b/WoW/Source/Win64/BotCheck.cpp @@ -0,0 +1,38 @@ +#include +#include +#include "Engine/Source/Os/OsLibrary.h" +#include "Engine/Source/Os/System.h" +#include "WoW/Source/Client.h" +#include "WoW/Source/Net/Types.h" + +// OFFSET: 0x004046C0 +void AdditionalCheck1() { + if (!s_botCheckEnabled || s_botCheckDelay <= 0 || s_botCheckDelay > 420) { + return; + } + + if (_InterlockedCompareExchange(&s_additionalCheckArmed, 0, 1) != 1) { + return; + } + + AdditionalCheckInterface iface; + iface.m_memAlloc = Client_MemAlloc; + iface.m_memFree = Client_MemFree; + iface.m_loadLibrary = OsLoadLibrary; + iface.m_getLibraryEntryPoint = OsGetLibraryEntryPoint; + iface.m_freeLibrary = OsFreeLibrary; + uint8_t detected = 0; + + __try { + if (*reinterpret_cast(&OsValidateFunctionPointer) == 0xE9) { + return; + } + + detected = AdditionalCheck1Scan(&iface, 0); + } __except (1) { + } + + if (detected) { + SendBotDetected2(CMSG_BOT_DETECTED2, 0x60231D69); + } +} diff --git a/WoW/Source/WorldClient/Barrier.cpp b/WoW/Source/WorldClient/Barrier.cpp index 2af59a6..e98f5f6 100644 --- a/WoW/Source/WorldClient/Barrier.cpp +++ b/WoW/Source/WorldClient/Barrier.cpp @@ -13,6 +13,11 @@ #include "Engine/Source/Model2/M2Model.h" #include "Engine/Source/Gx/CGxTexFlags.h" #include "Engine/Source/Services/Texture.h" +#include "Engine/Source/Gx/Gx.h" +#include "Engine/Source/Gx/CGxDevice/CGxDevice.h" +#include "Engine/Source/Model2/M2Shared.h" +#include "Engine/Source/Model2/M2Data.h" +#include "Engine/Source/Services/ParticleSystem2.h" // STATIC: 0x00CD85F8 CM2Model* CBarrier::s_sparkles[4]; @@ -23,6 +28,9 @@ CTexture* CBarrier::s_pattern; // STATIC: 0x00CD860C CTexture* CBarrier::s_mask; +// STATIC: 0x00CDD79C +static float s_patternPhase; + // VERIFY: 5b06e6d6 auto // OFFSET: 0x00790900 CGxVertexPCT0T1::CGxVertexPCT0T1() { @@ -292,3 +300,194 @@ void CBarrier::Destroy() { CBarrier::s_pattern = nullptr; } } + +// VERIFY: 52b19b7e manual +// OFFSET: 0x00794B50 +void CBarrier::Render(const C3Vector& viewerPos, float elapsedSec) { + if (!this->m_mode || !this->m_verts.Count()) { + return; + } + + int32_t contactCount = this->m_contacts.Count(); + + if (contactCount > 4) { + contactCount = 4; + } + + for (int32_t i = 0; i < contactCount; i++) { + CM2Model* sparkle = CBarrier::s_sparkles[i]; + + if (!sparkle) { + continue; + } + + CBarrier_Contact& contact = this->m_contacts.m_data[i]; + const C3Vector& normal = contact.m_plane.n; + C3Vector right; + right.x = normal.y - normal.z * 0.0f; + right.y = normal.z * 0.0f - normal.x; + right.z = normal.x * 0.0f - 0.0f * normal.y; + C3Vector up; + up.x = right.y * normal.z - right.z * normal.y; + up.y = right.z * normal.x - right.x * normal.z; + up.z = right.x * normal.y - right.y * normal.x; + C44Matrix transform(normal, right, up, contact.m_point); + sparkle->SetAnimating(1); + CM2Model* model = CBarrier::s_sparkles[i]; + + if (model->m_attachParent) { + model->m_fFlags |= 0x80; + } else { + model->m_fFlags |= 0x8; + } + + if (model->m_attachParent) { + model->m_fFlags |= 0x20000; + } else { + model->m_fFlags |= 0x10000; + } + + CBarrier::s_sparkles[i]->m_fFlags |= 0x8000; + CBarrier::s_sparkles[i]->m_worldTransform = transform; + CBarrier::s_sparkles[i]->m_fadeAlpha = this->m_contacts.m_data[i].m_strength; + + for (uint32_t j = 0; ; j++) { + CM2Model* loaded = CBarrier::s_sparkles[i]; + + if (!(loaded->m_fFlags & 0x1)) { + loaded->WaitForLoad(nullptr); + } + + if (j >= loaded->m_shared->m_data->m_particles.m_count) { + break; + } + + CM2Model* emitterModel = CBarrier::s_sparkles[i]; + + if (!(emitterModel->m_fFlags & 0x1)) { + emitterModel->WaitForLoad(nullptr); + } + + CParticleEmitter2* emitter = emitterModel->m_particleEmitters[j]; + emitter->SetWidth(100.0f); + emitter->SetHeight(100.0f); + } + } + + C44Matrix world; + world.Translate(-viewerPos); + g_theGxDevicePtr->XformPushAndSet(GxXform_World, world); + g_theGxDevicePtr->RsPush(); + GxRsSet(GxRs_DepthWrite, 0); + GxRsSet(GxRs_DepthTest, 1); + GxRsSet(GxRs_BlendingMode, 3); + GxRsSet(GxRs_Culling, 0); + GxRsSet(GxRs_Lighting, 0); + GxRsSet(GxRs_Fog, 0); + CGxTex* maskTex = TextureGetGxTex(CBarrier::s_mask, 1, nullptr); + + if (!maskTex) { + return; + } + + CGxTex* patternTex = TextureGetGxTex(CBarrier::s_pattern, 1, nullptr); + + if (!patternTex) { + return; + } + + g_theGxDevicePtr->RsSet(GxRs_Texture0, maskTex); + GxRsSet(GxRs_TextureCoord0, 0); + g_theGxDevicePtr->RsSet(GxRs_Texture1, patternTex); + GxRsSet(GxRs_TextureCoord1, 1); + C44Matrix identity; + g_theGxDevicePtr->XformPushAndSet(GxXform_Tex0, identity); + g_theGxDevicePtr->XformPushAndSet(GxXform_Tex1, identity); + GxRsSet(GxRs_TextureShader0, 1); + GxRsSet(GxRs_TextureShader1, 1); + GxRsSet(GxRs_ColorOp1, 0); + GxRsSet(GxRs_AlphaOp1, 1); + uint32_t vertCount = this->m_verts.Count(); + uint32_t triangleCount = vertCount / 3; + uint32_t bufferVertCount = 2 * vertCount; + uint32_t indexCount = 6 * triangleCount; + CGxBuf* vertexBuf = g_theGxDevicePtr->BufStream(GxPoolTarget_Vertex, sizeof(CGxVertexPCT0T1), bufferVertCount); + CGxBuf* indexBuf = g_theGxDevicePtr->BufStream(GxPoolTarget_Index, sizeof(uint16_t), indexCount); + CGxVertexPCT0T1* vertices = reinterpret_cast(g_theGxDevicePtr->BufLock(vertexBuf)); + uint16_t* indices = reinterpret_cast(g_theGxDevicePtr->BufLock(indexBuf)); + s_patternPhase = elapsedSec * 0.1f + s_patternPhase; + + if (s_patternPhase > 3.1415927f) { + s_patternPhase = s_patternPhase - 3.1415927f; + } + + if (vertices && indices) { + int32_t passCount = 2 * triangleCount; + + for (int32_t t = 0; t < passCount; t++) { + indices[0] = 3 * t; + indices[2] = 3 * t + 2; + indices[1] = 3 * t + 1; + indices += 3; + const CGxVertexPCT0T1* source = &this->m_verts.m_data[3 * (t / 2)]; + int32_t odd = t & 1; + + for (int32_t k = 0; k < 3; k++) { + vertices->m_pos = source->m_pos; + vertices->m_t0x = source->m_t0x; + vertices->m_t0y = source->m_t0y; + vertices->m_t1x = source->m_t1x; + vertices->m_t1y = source->m_t1y; + CImVector color; + color.r = 0; + color.b = 0xFF; + color.a = source->m_color.a; + color.g = odd ? 0xFF : 0; + + if (g_theGxDevicePtr->Caps().m_colorFormat == GxCF_rgba) { + CImVector swapped; + swapped.a = color.a; + swapped.r = 0xFF; + swapped.g = color.g; + swapped.b = 0; + color = swapped; + } + + vertices->m_color = color; + + if (odd) { + vertices->m_t1x = source->m_t1x * 0.050000001f + 0.5f; + vertices->m_t1y = 0.050000001f * source->m_t1y - static_cast(fmod(s_patternPhase, 3.1415927410125732)) * 1.5915494f; + } else { + vertices->m_t1x = source->m_t1x * 0.1f; + vertices->m_t1y = 0.1f * source->m_t1y - static_cast(fmod(s_patternPhase, 3.1415927410125732)) * 1.5915494f; + } + + vertices++; + source++; + } + } + } + + g_theGxDevicePtr->BufUnlock(vertexBuf, 0); + vertexBuf->unk_001C = 1; + g_theGxDevicePtr->BufUnlock(indexBuf, 0); + indexBuf->unk_001C = 1; + GxPrimVertexPtr(vertexBuf, GxVBF_PCT2); + g_theGxDevicePtr->PrimIndexPtr(indexBuf); + CGxBatch batch; + batch.m_primType = GxPrim_Triangles; + batch.m_start = 0; + batch.m_count = indexCount; + batch.m_minIndex = 0; + batch.m_maxIndex = bufferVertCount - 1; + g_theGxDevicePtr->Draw(&batch, 1); + GxXformPop(GxXform_Tex0); + GxXformPop(GxXform_Tex1); + g_theGxDevicePtr->RsPop(); + GxXformPop(GxXform_World); + this->m_verts.SetCount(0); + this->m_contacts.SetCount(0); + this->m_chunks.m_count = 0; + this->m_groups.m_count = 0; +} diff --git a/WoW/Source/WorldClient/CWorldMath.cpp b/WoW/Source/WorldClient/CWorldMath.cpp index 59a3201..887d375 100644 --- a/WoW/Source/WorldClient/CWorldMath.cpp +++ b/WoW/Source/WorldClient/CWorldMath.cpp @@ -268,3 +268,17 @@ int32_t CWorldMath::PointInPolygon(int32_t count, const C2Vector* points, const *distance = sqrt(nearest); return inside; } + +// VERIFY: fd69952e auto +// OFFSET: 0x0079F6F0 +void CWorldMath::MakeAaBox(CAaBox& box, const C3Vector& center, const float* size) { + float extent = (size[1] >= size[0] ? size[1] : size[0]) * 0.66000003f; + box.b = center; + box.t = center; + box.b.x -= extent; + box.b.y -= extent; + box.b.z -= extent; + box.t.x += extent; + box.t.y += extent; + box.t.z += extent; +} diff --git a/WoW/Source/WorldClient/CWorldMath.h b/WoW/Source/WorldClient/CWorldMath.h index 137c3c1..e922bb2 100644 --- a/WoW/Source/WorldClient/CWorldMath.h +++ b/WoW/Source/WorldClient/CWorldMath.h @@ -14,6 +14,7 @@ class C4Plane; class CWorldMath { public: static void TransformAABox(C44Matrix& m, CAaBox& src, CAaBox& dst); + static void MakeAaBox(CAaBox& box, const C3Vector& center, const float* size); static void TransformAABoxInner(const float* row1, const float* row0, CAaBox& dst, CAaBox& src, const float* row2); static void TransformAABox(C33Matrix& m, CAaBox& src, CAaBox& dst); static bool VectorIntersectAABox2(CAaBox& box, C3Vector& start, C3Vector& end); diff --git a/WoW/Source/WorldClient/DayNight.cpp b/WoW/Source/WorldClient/DayNight.cpp index 7b8a7e2..4c154f8 100644 --- a/WoW/Source/WorldClient/DayNight.cpp +++ b/WoW/Source/WorldClient/DayNight.cpp @@ -76,10 +76,10 @@ DayNight::DNClouds DayNight::g_clouds; DayNight::DNPlanets DayNight::g_planets; // STATIC: 0x00D38EA8 -DayNight::DNGlare DayNight::g_sunGlare; +DayNight::DNSunGlare DayNight::g_sunGlare; // STATIC: 0x00D38F58 -DayNight::DNGlare DayNight::g_moonGlare; +DayNight::DNMoonGlare DayNight::g_moonGlare; // STATIC: 0x00AF4A68 static int32_t s_useZoneLights = 1; @@ -177,6 +177,18 @@ static float s_skyMinZ = 0.9990234375f; // STATIC: 0x00ADEEF4 static float s_skyMaxZ = 1.0f; +// STATIC: 0x00AF4B70 +static uint16_t s_glareIndices[4] = { 0, 2, 1, 3 }; + +// STATIC: 0x00AF4CB0 +static C3Vector s_glareVertices[4] = { C3Vector(0.0f, -0.5f, 0.5f), C3Vector(0.0f, 0.5f, 0.5f), C3Vector(0.0f, -0.5f, -0.5f), C3Vector(0.0f, 0.5f, -0.5f) }; + +// STATIC: 0x00AF4CE0 +static C2Vector s_glareTexCoords[4] = { C2Vector(0.0f, 0.0f), C2Vector(1.0f, 0.0f), C2Vector(0.0f, 1.0f), C2Vector(1.0f, 1.0f) }; + +// STATIC: 0x00AF4DC0 +static float s_glarePower = 10.0f; + // STATIC: 0x00D38188 static float s_cloudFade[256]; @@ -1288,6 +1300,32 @@ void DayNight::DNClouds::WorldToTexture(const C3Vector* world, C2Vector* uv) { uv->y = (radius * ny + 0.5f) * this->m_size; } +// VERIFY: 7f090860 manual +// OFFSET: 0x007EFA30 +float DayNight::DNClouds::GetDensity(const C3Vector* position, float scale) { + if (!this->m_enabled) { + return 0.0f; + } + + C2Vector uv; + uv.x = 0.0f; + uv.y = 0.0f; + this->WorldToTexture(position, &uv); + uint32_t max = this->m_size - 1; + uint32_t x = static_cast(static_cast(uv.x)); + uint32_t y = static_cast(static_cast(uv.y)); + + if (x > max) { + x = ~(static_cast(x) >> 31) & max; + } + + if (y > max) { + y = ~(static_cast(y) >> 31) & max; + } + + return this->m_densities.m_data[(y << this->m_shift) + x] * 0.0039215689f; +} + // VERIFY: e28145b2 manual // OFFSET: 0x007EFAE0 void DayNight::DNClouds::SetupBumpMap(C3Vector* shadeColor, C3Vector* sunColor, C3Vector* baseColor, C3Vector* sunPos, float* intensity) { @@ -2849,3 +2887,202 @@ void DayNight::RenderGlares() { DayNight::g_moonGlare.Update(DayNight::g_dnInfo.m_deltaSec); DayNight::g_moonGlare.Render(); } + +// VERIFY: e14afd01 auto +// OFFSET: 0x007EE3F0 +DayNight::DNGlare::DNGlare() { + this->m_position.x = 0.0f; + this->m_position.y = 0.0f; + this->m_occlusionQuery = nullptr; + this->m_position.z = 0.0f; + this->m_color = CImVector(); + this->unk_003C[0] = 0.0f; + this->unk_003C[1] = 0.0f; + this->unk_003C[2] = 0.0f; + this->unk_003C[3] = 0.0f; + this->unk_003C[4] = 0.0f; + this->unk_003C[5] = 0.0f; + this->unk_003C[6] = 0.0f; + this->unk_003C[7] = 0.0f; + this->unk_005C[0] = 0; + this->unk_005C[1] = 0; + this->unk_005C[2] = 0; + this->unk_005C[3] = 0; + this->m_alphaCurve[0].m_time = 0.0f; + this->m_alphaCurve[0].m_value = 0.0f; + this->m_planet = nullptr; + this->m_alphaCurve[1].m_time = 0.0f; + this->m_alphaCurve[1].m_value = 0.0f; + this->m_alphaCurve[2].m_time = 0.0f; + this->m_alphaCurve[2].m_value = 0.0f; + this->m_alphaCurve[3].m_time = 0.0f; + this->m_alphaCurve[3].m_value = 0.0f; +} + +// VERIFY: 32883be1 auto +// OFFSET: 0x007EF6E0 +void DayNight::DNGlare::Update(float deltaSec) { + this->m_fadeTarget = 1.0f; + float dx = this->m_position.x - DayNight::g_dnInfo.m_cameraPos.x; + float dy = this->m_position.y - DayNight::g_dnInfo.m_cameraPos.y; + float dz = this->m_position.z - DayNight::g_dnInfo.m_cameraPos.z; + float length = sqrt(dy * dy + dz * dz + dx * dx); + float dirX = dx * (1.0f / length); + float dirY = dy * (1.0f / length); + float dirZ = (1.0f / length) * dz; + this->m_fadeTarget = this->GetCloudDensityFade() * this->m_fadeTarget; + this->m_fadeTarget = this->GetLiquidDepthFade() * this->m_fadeTarget; + float skyboxWeight; + + if (DayNight::g_dnInfo.m_skybox && DayNight::g_dnInfo.m_skyboxWeight > 0.0f) { + skyboxWeight = DayNight::g_dnInfo.m_skyboxWeight; + } else { + skyboxWeight = 0.0f; + + if (DayNight::g_dnInfo.m_blendSkybox[0] && DayNight::g_dnInfo.m_blendSkyboxWeight[0] > 0.0f) { + skyboxWeight = DayNight::g_dnInfo.m_blendSkyboxWeight[0]; + } + + if (DayNight::g_dnInfo.m_blendSkybox[1] && DayNight::g_dnInfo.m_blendSkyboxWeight[1] > skyboxWeight) { + skyboxWeight = DayNight::g_dnInfo.m_blendSkyboxWeight[1]; + } + + if (DayNight::g_dnInfo.m_blendSkybox[2] && DayNight::g_dnInfo.m_blendSkyboxWeight[2] > skyboxWeight) { + skyboxWeight = DayNight::g_dnInfo.m_blendSkyboxWeight[2]; + } + } + + float target = (1.0f - skyboxWeight) * this->m_fadeTarget; + this->m_fadeTarget = target; + this->m_fadeTarget = DayNight::InterpTable(reinterpret_cast(this->m_alphaCurve), 4, DayNight::g_dnInfo.m_dayProgression) * target; + + if (this->m_fadeTarget != 0.0f) { + this->m_fadeTarget = this->GetOcclusionFade() * this->m_fadeTarget; + } + + if (this->m_fade < this->m_fadeTarget) { + float fade = this->m_fadeInRate * deltaSec + this->m_fade; + this->m_fade = fade >= this->m_fadeTarget ? this->m_fadeTarget : fade; + } else if (this->m_fade > this->m_fadeTarget) { + float fade = this->m_fade - this->m_fadeOutRate * deltaSec; + this->m_fade = fade <= this->m_fadeTarget ? this->m_fadeTarget : fade; + } + + float dot = DayNight::g_dnInfo.m_cameraDir.y * dirY + DayNight::g_dnInfo.m_cameraDir.z * dirZ + DayNight::g_dnInfo.m_cameraDir.x * dirX; + + if (dot < this->m_minDot) { + dot = this->m_minDot; + } + + float t = (dot - this->m_minDot) / (1.0f - this->m_minDot); + this->m_scale = ((this->m_scaleMax - this->m_scaleMin) * t + this->m_scaleMin) * this->m_baseScale; + this->m_color.a = static_cast((t * (this->m_alphaMax - this->m_alphaMin) + this->m_alphaMin) * this->m_fade * (this->m_color.a * 0.0039215689f) * 255.0f); + this->m_screenGlow = pow(dot, s_glarePower) * this->m_fade; +} + +// VERIFY: 40579330 manual +// OFFSET: 0x009AC400 +void DayNight::DNGlare::Render() { + if (!DayNight::GlareBase::m_masterEnable || !this->m_enable || !this->m_color.a) { + return; + } + + CGxTex* gxTex = TextureGetGxTex(this->m_texture, 0, nullptr); + + if (!gxTex) { + return; + } + + DayNight::DNInfo* info = DayNight::GetInfo(); + C44Matrix view; + GxXformView(view); + C3Vector direction(view.a2, view.b2, view.c2); + C44Matrix world; + DayNight::Billboard(world, direction); + world.d0 = this->m_position.x - info->m_cameraPos.x; + world.d1 = this->m_position.y - info->m_cameraPos.y; + world.d2 = this->m_position.z - info->m_cameraPos.z; + world.Scale(C3Vector(this->m_scale, this->m_scale, this->m_scale)); + g_theGxDevicePtr->XformPushAndSet(GxXform_World, world); + float minX = 0.0f; + float maxX = 0.0f; + float minY = 0.0f; + float maxY = 0.0f; + float minZ = 0.0f; + float maxZ = 0.0f; + GxXformViewport(minX, maxX, minY, maxY, minZ, maxZ); + GxXformSetViewport(minX, maxX, minY, maxY, s_skyMinZ, s_skyMaxZ); + g_theGxDevicePtr->RsPush(); + GxRsSet(GxRs_BlendingMode, 3); + GxUpdateAlphaRef(GxRs_AlphaRef); + GxRsSet(GxRs_Lighting, 0); + GxRsSet(GxRs_Fog, 0); + GxRsSet(GxRs_DepthWrite, 0); + GxRsSet(GxRs_Culling, 0); + GxRsSet(GxRs_DepthTest, 0); + g_theGxDevicePtr->RsSet(GxRs_Texture0, gxTex); + GxRsSet(GxRs_ColorOp0, 0); + GxRsSet(GxRs_AlphaOp0, 0); + GxPrimVertexPtr(4, s_glareVertices, sizeof(C3Vector), nullptr, 0, &this->m_color, 0, s_glareTexCoords, sizeof(C2Vector), nullptr, 0); + GxPrimIndexPtr(4, s_glareIndices); + CGxBatch batch; + batch.m_primType = GxPrim_TriangleStrip; + batch.m_start = 0; + batch.m_count = 4; + batch.m_minIndex = 0; + batch.m_maxIndex = 3; + g_theGxDevicePtr->Draw(&batch, 1); + GxXformSetViewport(minX, maxX, minY, maxY, minZ, maxZ); + GxXformPop(GxXform_World); + g_theGxDevicePtr->RsPop(); +} + +// VERIFY: 736a9501 auto +// OFFSET: 0x009AC3C0 +float DayNight::DNGlare::GetOcclusionFade() { + if (!DayNight::GlareBase::m_masterEnable || !this->m_enable || !this->m_color.a) { + return 0.0f; + } + + if (this->m_occlusionQuery && CWorldParam::cvar_occlusion->m_intValue) { + return this->GetQueryOcclusion(); + } + + return this->GetPointOcclusion(); +} + +// VERIFY: a694bf5f manual +// OFFSET: 0x007EDA30 +float DayNight::DNGlare::GetLiquidDepthFade() { + float fade = 1.0f; + float depth; + + if (!World::SceneCamLiquidStatus(&depth)) { + return fade; + } + + float scaled = depth * 0.1f; + + if (scaled < 0.0f) { + return 1.0f - 0.0f; + } + + if (scaled >= 1.0f) { + scaled = 1.0f; + } + + return 1.0f - scaled; +} + +// VERIFY: fead6e16 auto +// OFFSET: 0x007F1020 +float DayNight::DNSunGlare::GetCloudDensityFade() { + return 1.0f - DayNight::g_clouds.GetDensity(&this->m_position, 1.0f); +} + +// VERIFY: 86e92cf3 auto +// OFFSET: 0x007F1040 +float DayNight::DNMoonGlare::GetCloudDensityFade() { + float density = DayNight::g_clouds.GetDensity(&this->m_position, 1.0f) - 0.5f; + return 1.0f - fabs(density + density); +} diff --git a/WoW/Source/WorldClient/DayNight.h b/WoW/Source/WorldClient/DayNight.h index 3d559a3..9499480 100644 --- a/WoW/Source/WorldClient/DayNight.h +++ b/WoW/Source/WorldClient/DayNight.h @@ -22,6 +22,7 @@ class CM2Model; class CM2Scene; class CTexture; class CGxQuery; +class C44Matrix; class CPortalView; namespace DayNight { struct DNPlanet; } class LightRec; @@ -119,12 +120,12 @@ struct DNClouds { void SetupBumpMap(C3Vector* shadeColor, C3Vector* sunColor, C3Vector* baseColor, C3Vector* sunPos, float* intensity); void UpdateTextureAnimation(); void WorldToTexture(const C3Vector* world, C2Vector* uv); + float GetDensity(const C3Vector* position, float scale); }; } namespace DayNight { struct DNGlare { - /* 0000 */ void* m_vtbl; /* 0004 */ CGxQuery* m_occlusionQuery; /* 0008 */ uint32_t m_enable; /* 000C */ C3Vector m_position; @@ -137,7 +138,8 @@ struct DNGlare { /* 0030 */ float m_fade; /* 0034 */ float m_fadeTarget; /* 0038 */ uint32_t m_skipOcclusionOnce; - /* 003C */ uint8_t unk_003C [48]; + /* 003C */ float unk_003C[8]; + /* 005C */ uint32_t unk_005C[4]; /* 006C */ uint32_t m_occlusionPixels; /* 0070 */ DNKeyframe m_alphaCurve [4]; /* 0090 */ float m_scaleMin; @@ -148,11 +150,28 @@ struct DNGlare { /* 00A4 */ float m_screenGlow; /* 00A8 */ DayNight::DNPlanet* m_planet; + virtual void Update(float deltaSec); + virtual void Render(); + virtual float GetOcclusionFade(); + virtual float GetCloudDensityFade() = 0; + virtual float GetLiquidDepthFade(); + + DNGlare(); void Destroy(); void Initialize(const char* fileName); - void Render(); - void Update(float deltaSec); + float GetQueryOcclusion(); + float GetPointOcclusion(); }; + +struct DNSunGlare : public DNGlare { + float GetCloudDensityFade() override; +}; + +struct DNMoonGlare : public DNGlare { + float GetCloudDensityFade() override; +}; + +void Billboard(C44Matrix& matrix, const C3Vector& direction); } namespace DayNight { @@ -324,8 +343,8 @@ extern DNStars g_stars; extern DNSky g_sky; extern DNClouds g_clouds; extern DNPlanets g_planets; -extern DNGlare g_sunGlare; -extern DNGlare g_moonGlare; +extern DNSunGlare g_sunGlare; +extern DNMoonGlare g_moonGlare; extern TSGrowableArray g_areaLights; extern TSHashTable g_overrideSky; } diff --git a/WoW/Source/WorldClient/FVBBList.cpp b/WoW/Source/WorldClient/FVBBList.cpp index 2c6cfca..6783bd2 100644 --- a/WoW/Source/WorldClient/FVBBList.cpp +++ b/WoW/Source/WorldClient/FVBBList.cpp @@ -49,3 +49,41 @@ void FVBBList::Destroy() { g_theGxDevicePtr->PoolDestroy(this->m_pool); } } + +// VERIFY: 8a1a34ab manual +// OFFSET: 0x007D5540 +FVBBList::Block* FVBBList::AllocBlock(Block** owner) { + Block* block = this->m_blocks.Head(); + block->m_link.Unlink(); + this->m_usedBlocks.LinkToTail(block); + block->m_buf->unk_001C = 0; + block->m_owner = owner; + return block; +} + +// VERIFY: c47a50ff manual +// OFFSET: 0x007D5DE0 +void FVBBList::AcquireBlock(Block** owner) { + if (!this->m_blocks.Head()) { + Block* oldest = this->m_usedBlocks.Head(); + Block* newest = this->m_usedBlocks.Head(); + + for (Block* block = this->m_usedBlocks.Head(); block; block = this->m_usedBlocks.Next(block)) { + if (block->unk_0008 < oldest->unk_0008) { + oldest = block; + } + + if (block->unk_0008 > newest->unk_0008) { + newest = block; + } + } + + if (newest->unk_0008 - oldest->unk_0008 <= 10) { + return; + } + + this->Release(oldest); + } + + *owner = this->AllocBlock(owner); +} diff --git a/WoW/Source/WorldClient/FVBBList.h b/WoW/Source/WorldClient/FVBBList.h index afeb632..d300b5a 100644 --- a/WoW/Source/WorldClient/FVBBList.h +++ b/WoW/Source/WorldClient/FVBBList.h @@ -21,11 +21,13 @@ class FVBBList { /* 0000 */ CGxPool* m_pool; /* 0004 */ uint32_t m_blockSize; /* 0008 */ TSExplicitList m_blocks; + /* 0014 */ TSExplicitList m_usedBlocks; void Destroy(); void Initialize(EGxPoolTarget target, EGxPoolUsage usage, uint32_t itemSize, uint32_t itemCount, uint32_t blockCount); void Release(Block* block); void AcquireBlock(Block** owner); + Block* AllocBlock(Block** owner); }; #endif diff --git a/WoW/Source/WorldClient/Map.cpp b/WoW/Source/WorldClient/Map.cpp index a6c2d59..92eccb4 100644 --- a/WoW/Source/WorldClient/Map.cpp +++ b/WoW/Source/WorldClient/Map.cpp @@ -80,6 +80,8 @@ #include "WoW/Source/WorldClient/WorldParam.h" #include "Engine/Source/Gx/Gx.h" #include "Engine/Source/ConsoleBase/ConsoleVar.h" +#include "WoW/Source/Game/GameClient/ProjectTex.h" +#include "WoW/Source/DB/Rec/TerrainTypeRec.h" // STATIC: 0x00CF4938 TSGrowableArray CMap::debugVertexArray; @@ -232,7 +234,7 @@ uint32_t* CMap::areaHeap; uint32_t* CMap::areaMedHeap; // STATIC: 0x00D25418 -uint32_t* CMap::areaLowHeap; +CMapAreaLowHeap* CMap::areaLowHeap; // STATIC: 0x00D2541C uint32_t* CMap::chunkHeap; @@ -249,6 +251,15 @@ static uint32_t unk_CF4958; // STATIC: 0x00CF495C static uint32_t unk_CF495C; +// STATIC: 0x00A405E8 +static const int32_t s_subVertexTriangles[12] = { 17, 9, 0, 9, 1, 0, 9, 17, 18, 9, 18, 1 }; + +// STATIC: 0x00A40618 +static const int32_t s_subVertexIndexFlat[5] = { 0, 9, 17, 1, 18 }; + +// STATIC: 0x00ADFD04 +static World::FacetData s_footprintFacets; + // STATIC: 0x00CF4960 static CMapFootprint s_footprints[144][4]; @@ -336,6 +347,9 @@ bool CMap::enableTerrainShaderVertex; // STATIC: 0x00CE04A3 HASHKEY_NONE CMap::s_mapObjDefHashKey; +// STATIC: 0x00ADFBF8 +TSList > CMap::s_unk_ADFBF8 = TSExplicitList(); + // STATIC: 0x00ADFC04 TSList > CMap::mapObjDefLinkList = TSExplicitList(); @@ -642,7 +656,7 @@ void CMap::InitializePCFShaders() { g_theGxDevicePtr->ShaderCreate(CMap::pixelShader_Terrain3, GxSh_Pixel, "Shaders\\Pixel", CShaderEffect::s_usePcfFiltering ? "Terrain3_pcf" : "Terrain3", sizeof(CMap::pixelShader_Terrain3) / sizeof(CMap::pixelShader_Terrain3[0])); } -// VERIFY: f2cf813b manual +// VERIFY: 98a7e674 manual // OFFSET: 0x0079E7C0 void CMap::Initialize() { CMapArea::Initialize(); @@ -739,7 +753,7 @@ void CMap::Initialize() { CMap::baseObjLinkHeap = new (__FILE__, __LINE__) uint32_t(ObjectAllocAddHeap(sizeof(CMapBaseObjLink), 10000, "WBASEOBJLINK", true)); CMap::areaHeap = new (__FILE__, __LINE__) uint32_t(ObjectAllocAddHeap(sizeof(CMapArea), 16, "WAREA", true)); CMap::areaMedHeap = new (__FILE__, __LINE__) uint32_t(ObjectAllocAddHeap(sizeof(CMapAreaMed), 16, "WAREAMED", true)); - CMap::areaLowHeap = new (__FILE__, __LINE__) uint32_t(ObjectAllocAddHeap(sizeof(CMapAreaLow), 16, "WAREALOW", true)); + CMap::areaLowHeap = new (__FILE__, __LINE__) CMapAreaLowHeap{ ObjectAllocAddHeap(sizeof(CMapAreaLow), 16, "WAREALOW", true) }; CMap::chunkHeap = new (__FILE__, __LINE__) uint32_t(ObjectAllocAddHeap(sizeof(CMapChunk), 256, "WCHUNK", true)); CMap::doodadDefHeap = new (__FILE__, __LINE__) uint32_t(ObjectAllocAddHeap(sizeof(CMapDoodadDef), 5000, "WDOODADDEF", true)); CMap::entityHeap = new (__FILE__, __LINE__) uint32_t(ObjectAllocAddHeap(sizeof(CMapEntity), 128, "WENTITY", true)); @@ -2362,6 +2376,34 @@ CMapDoodadDef* CMap::CreateDoodadDef(const char* fileName, SMDoodadDef* doodadDe return mapDoodadDef; } +// VERIFY: 84c1a3e9 manual +// OFFSET: 0x007BEB40 +CMapDoodadDef* CMap::CreateDoodadDef(const char* fileName, const C3Vector* position, float facing, int32_t a4) { + int32_t id = CMap::uniqueId--; + HASHKEY_DWORD key = { 0 }; + CMap::doodadDefHash.Ptr(id, key); + CMapDoodadDef* doodadDef = CMap::AllocDoodadDef(); + HASHKEY_DWORD insertKey = { 0 }; + CMap::doodadDefHash.Insert(doodadDef, id, insertKey); + doodadDef->m_position = *position; + doodadDef->m_scale = 1.0f; + doodadDef->m_sphere.r = 0.0f; + doodadDef->m_sphere.c = doodadDef->m_position; + doodadDef->m_bbox.b = doodadDef->m_position; + doodadDef->m_bbox.t = doodadDef->m_position; + doodadDef->m_mat = C44Matrix(); + doodadDef->m_mat.d0 = position->x; + doodadDef->m_mat.d1 = position->y; + doodadDef->m_mat.d2 = position->z; + doodadDef->m_mat.RotateAroundZ(facing); + doodadDef->m_identity = C44Matrix(); + doodadDef->m_flags = MAPOBJ_FLAG_UNPLACED; + doodadDef->m_model = nullptr; + CMapDoodadDef::CreateModel(fileName, doodadDef, a4, 0); + + return doodadDef; +} + // VERIFY: ea13d7f6 manual // OFFSET: 0x007BEF40 CMapDoodadDef* CMap::CreateDoodadDef(uint32_t doodadRef, SMODoodadDef* doodadDef, char* name, uint32_t key, C44Matrix* mat, uint16_t doodadSet) { @@ -2503,6 +2545,83 @@ CMapObjDef* CMap::CreateMapObjDef(char* fileName, SMMapObjDef* mapObjectDef, C3V return mapObjDef; } +// VERIFY: 5ac717a0 manual +// OFFSET: 0x007BF120 +CMapObjDef* CMap::CreateMapObjDef(const char* fileName, const C3Vector* position, float facing, int32_t waitLoad, uint32_t doodadSetCount, const int16_t* doodadSets, float* radius, uint32_t id) { + uint32_t uniqueId = id; + + if (!id) { + uniqueId = CMap::uniqueId--; + } + + CMap::mapObjDefHash.Ptr(uniqueId, CMap::s_mapObjDefHashKey); + CMapObjDef* mapObjDef = CMap::AllocMapObjDef(); + CMap::mapObjDefHash.Insert(mapObjDef, uniqueId, CMap::s_mapObjDefHashKey); + CMapObj* mapObj = CMapObj::Create(const_cast(fileName)); + mapObjDef->m_owner = mapObj; + + if (waitLoad && !mapObj->m_isGroupLoaded) { + mapObj->WaitLoad(); + } + + mapObjDef->m_flags = static_cast(0); + + if (doodadSetCount) { + mapObjDef->m_flags = MAPOBJ_FLAG_MAPOBJDEF; + } + + mapObjDef->m_nameId = 0; + mapObjDef->m_doodadSet = 0; + mapObjDef->m_nameSet = 0; + mapObjDef->m_position = *position; + mapObjDef->m_objectGuid = WOWGUID(); + + for (int32_t i = 0; i < 3; i++) { + mapObjDef->m_doodadSetOverrides[i] = i < static_cast(doodadSetCount) ? doodadSets[i] : 0; + } + + mapObjDef->m_mat = C44Matrix(); + mapObjDef->m_mat.d0 = position->x; + mapObjDef->m_mat.d1 = position->y; + mapObjDef->m_mat.d2 = position->z; + mapObjDef->m_mat.RotateAroundZ(facing); + mapObjDef->m_invMat = mapObjDef->m_mat.AffineInverse(); + + if (mapObj->m_isGroupLoaded) { + CAaBox bounds(C3Vector(0.0f, 0.0f, 0.0f), C3Vector(0.0f, 0.0f, 0.0f)); + mapObj->GetBounds(mapObjDef->m_sphere); + mapObjDef->m_sphere.c *= mapObjDef->m_mat; + mapObj->GetBounds(&bounds); + CWorldMath::TransformAABox(mapObjDef->m_mat, bounds, mapObjDef->m_bbox); + mapObjDef->m_lightsArray.m_count = 0; + return mapObjDef; + } + + float sphereRadius; + + if (radius) { + CAaBox extents; + extents.b.x = *radius * -1.0f; + extents.b.y = extents.b.x; + extents.b.z = extents.b.x; + extents.t.x = *radius; + extents.t.y = *radius; + extents.t.z = *radius; + CWorldMath::TransformAABox(mapObjDef->m_mat, extents, mapObjDef->m_bbox); + sphereRadius = *radius; + } else { + sphereRadius = 0.0f; + mapObjDef->m_bbox.b = *position; + mapObjDef->m_bbox.t = *position; + } + + mapObjDef->m_sphere.c = *position; + mapObjDef->m_sphere.r = sphereRadius; + mapObjDef->m_lightsArray.m_count = 0; + + return mapObjDef; +} + // VERIFY: aade514a manual // OFFSET: 0x007BF8B0 void CMap::LoadWdt() { @@ -2990,13 +3109,13 @@ void CMap::FreeBaseObjLink(CMapBaseObjLink* link) { ObjectFree(*CMap::baseObjLinkHeap, link->m_objectIndex); } -// VERIFY: c37a9deb auto +// VERIFY: f22f4d25 auto // OFFSET: 0x007C0A90 CMapAreaLow* CMap::AllocAreaLow() { uint32_t memHandle; void* object = nullptr; - if (!ObjectAlloc(*CMap::areaLowHeap, &memHandle, &object, false)) { + if (!ObjectAlloc(CMap::areaLowHeap->m_heapId, &memHandle, &object, false)) { return nullptr; } @@ -3006,6 +3125,19 @@ CMapAreaLow* CMap::AllocAreaLow() { return areaLow; } +// VERIFY: 41bd42d1 manual +// OFFSET: 0x007C0AE0 +void CMapAreaLowHeap::Delete(CMapAreaLow* areaLow) { + areaLow->m_horizonLink.Unlink(); + ObjectFree(this->m_heapId, areaLow->m_objectIndex); +} + +// VERIFY: 51f512f8 auto +// OFFSET: 0x007C0C60 +void CMap::FreeAreaLow(CMapAreaLow* areaLow) { + CMap::areaLowHeap->Delete(areaLow); +} + // VERIFY: 9da97e61 auto // OFFSET: 0x007C15F0 void CMap::ClassifyStaticEntityLink(CMapStaticEntity* entity, CMapObjDef* mapObjDef, CMapObjDefGroup* mapObjDefGroup, uint32_t faceInfo, C3Vector* pos) { @@ -4051,7 +4183,7 @@ bool CMap::GetChunkLiquidFacets(CMapChunk* chunk, CAaBox* box, CiRect* rect, CCh return World::TriDataToFacetData(&triData, facets, WOWGUID{ 0 }) != 0; } -// VERIFY: be7caf2c manual +// VERIFY: 92053872 manual // OFFSET: 0x007A5A60 bool CMap::GetChunkFacets(int32_t chunkX, int32_t chunkY, CiRect* subRect, CAaBox* queryBox, CAaBox* box, World::FacetData* facets, uint32_t flags) { uint32_t first = facets->facets.Count(); @@ -4065,7 +4197,7 @@ bool CMap::GetChunkFacets(int32_t chunkX, int32_t chunkY, CiRect* subRect, CAaBo return false; } - if (chunk->m_header->m_flags & 0x40) { + if (chunk->m_flags & MAPOBJ_FLAG_IMPASSABLE) { CMap::CreateImpassableFacets(chunk, box, facets); } @@ -5170,3 +5302,497 @@ void CMap::RenderFootprints() { GxXformPop(GxXform_World); g_theGxDevicePtr->RsPop(); } + +// VERIFY: 331b297f manual +// OFFSET: 0x007C3830 +void CMap::Unload() { + CMap::PurgeMaps(); + CMap::s_lowDetail.Unload(); + + for (CMapBaseObjLink* link = CMap::mapObjDefLinkList.Head(); link;) { + CMapBaseObjLink* next = CMap::mapObjDefLinkList.Next(link); + CMapObjDef* mapObjDef = static_cast(link->m_owner); + CMap::FreeBaseObjLink(link); + CMap::PurgeMapObjDef(mapObjDef); + link = next; + } + + for (CMapBaseObjLink* link = CMap::s_unk_ADFBF8.Head(); link;) { + CMapBaseObjLink* next = CMap::s_unk_ADFBF8.Next(link); + CMapBaseObj* owner = link->m_owner; + CMap::FreeBaseObjLink(link); + + if (!(owner->m_type & 0x200)) { + CMapDoodadDef::Purge(static_cast(owner)); + } + + link = next; + } + + CDestructibleProxy* proxy = CMap::s_destructibleProxyList.Head(); + + while (!CMap::s_destructibleProxyList.IsEnd(proxy)) { + CDestructibleProxy* next = CMap::s_destructibleProxyList.RawNext(proxy); + + if (proxy->m_uniqueId) { + CMap::s_destructibleProxyList.UnlinkNode(proxy); + CMap::s_destructibleProxyList.DeleteNode(proxy); + } + + proxy = next; + } + + CMap::s_destructibleProxyList.Clear(); + CMapObj::ClearCache(1); + World::s_m2Scene->PurgeModelCache(); + CMap::ClearAllFootprints(); + CDetailDoodad::FreeGxBufMat(); + CMapRenderChunk::Destroy(); + CMapObj::DestroyPools(); + TextureGxCacheFlush(); + g_theGxDevicePtr->DeviceEvictResources(); + DayNight::UnloadMap(); + CMap::DestroyLight(CMap::s_mapLight); + CMap::FreeAllChunkLiquids(); + CMap::bActive = 0; + CMap::bDungeon = 0; + CMap::enableChunkBatching = 0; + char path[260]; + SStrCopy(path, CMap::wdtFilename, 0x7FFFFFFF); + SStrCopy(strrchr(path, '.'), ".tex", 0x7FFFFFFF); + TextureUnloadBlob(path); +} + +// VERIFY: 6b4c3b7f auto +// OFFSET: 0x0079D460 +void CMap::CreateWaterRipple(const C3Vector& pos, float a2, float a3, float a4, float a5, float a6, int32_t a7, int32_t a8) { + if (CWorld::s_waterRipples && !World::s_waterLOD) { + float alpha = 1.0f; + + if (a5 < 0.16666667f) { + alpha = a5 * 6.0f; + } + + WaterRipple::Create(pos, a2, a3, alpha, a4, a6, a7, a8); + } +} + +// VERIFY: b6f5c768 auto +// OFFSET: 0x007B4A50 +void CMap::SnapBaseObjToSubChunk(CMapBaseObj* baseObj, const C3Vector* position, float facing) { + C44Matrix rotation = C44Matrix::RotationAroundZ(facing); + CAaBox bounds(C3Vector(0.0f, 0.0f, 0.0f), C3Vector(0.0f, 0.0f, 0.0f)); + + if (baseObj->m_type & 0x8) { + static_cast(baseObj)->m_owner->GetBounds(&bounds); + } else { + bounds = static_cast(baseObj)->m_model->GetBoundingBox(); + } + + float centerX = (bounds.t.x + bounds.b.x) * 0.5f; + float centerY = (bounds.t.y + bounds.b.y) * 0.5f; + float centerZ = (bounds.t.z + bounds.b.z) * 0.5f; + bounds.t.x = bounds.t.x - centerX; + bounds.t.y = bounds.t.y - centerY; + bounds.t.z = bounds.t.z - centerZ; + bounds.b.x = bounds.b.x - centerX; + bounds.b.y = bounds.b.y - centerY; + bounds.b.z = bounds.b.z - centerZ; + CAaBox rotated(C3Vector(0.0f, 0.0f, 0.0f), C3Vector(0.0f, 0.0f, 0.0f)); + CWorldMath::TransformAABox(rotation, bounds, rotated); + C3Vector* snapped = const_cast(position); + float x = snapped->x + rotated.t.x; + float y = snapped->y + rotated.t.y; + int32_t cellX = CMath::fint_((x + 4.1666665f) * 0.24f - 0.5f); + int32_t cellY = CMath::fint_((y + 4.1666665f) * 0.24f - 0.5f); + snapped->x = snapped->x - (x - cellX * 4.1666665f); + snapped->y = snapped->y - (y - 4.1666665f * cellY); +} + +// VERIFY: 153db93c manual +// OFFSET: 0x007B58C0 +void CMap::UpdateDoodadDef(CMapDoodadDef* doodadDef, const C3Vector* position, float facing) { + doodadDef->m_position = *position; + doodadDef->m_scale = 1.0f; + doodadDef->m_mat = C44Matrix(); + doodadDef->m_mat.d0 = position->x; + doodadDef->m_mat.d1 = position->y; + doodadDef->m_mat.d2 = position->z; + doodadDef->m_mat.RotateAroundZ(facing); + CMap::UpdateDoodadDefBounds(doodadDef); +} + +// VERIFY: 05946402 manual +// OFFSET: 0x007B5870 +void CMap::UpdateDoodadDefTransform(CMapDoodadDef* doodadDef, const C44Matrix& matrix) { + doodadDef->m_position.x = matrix.d0; + doodadDef->m_position.y = matrix.d1; + doodadDef->m_position.z = matrix.d2; + doodadDef->m_scale = sqrtf(matrix.a2 * matrix.a2 + matrix.a1 * matrix.a1 + matrix.a0 * matrix.a0); + doodadDef->m_mat = matrix; + CMap::UpdateDoodadDefBounds(doodadDef); +} + +// VERIFY: 7fce3415 manual +// OFFSET: 0x0079F760 +void CMap::BuildFootprintMatrix(C44Matrix& matrix, const float* size, int32_t left, float facing) { + if (left) { + matrix.Scale(C3Vector(-1.0f, 1.0f, 1.0f)); + } + + if (size[1] <= size[0]) { + if (size[0] > size[1]) { + matrix.Scale(C3Vector(size[0] / size[1], 1.0f, 1.0f)); + } + } else { + matrix.Scale(C3Vector(1.0f, size[1] / size[0], 1.0f)); + } + + matrix.RotateAroundZ(-facing); +} + +// VERIFY: 1e420023 manual +// OFFSET: 0x0079FA70 +void CMap::NewFootprint(int32_t textureId, const float* size, const C3Vector* position, float facing, int32_t left, int32_t terrainType, int32_t activePlayer) { + if (static_cast(textureId) >= unk_CFBE60.Count()) { + return; + } + + TerrainTypeRec* rec = g_terrainTypeDB.GetRecord(terrainType); + + if (!rec || !(rec->m_flags & 0x1)) { + return; + } + + CAaBox box; + box.b = C3Vector(0.0f, 0.0f, 0.0f); + box.t = C3Vector(0.0f, 0.0f, 0.0f); + CWorldMath::MakeAaBox(box, *position, size); + + if (!World::GetFacets(&box, &s_footprintFacets, 0x200122, nullptr)) { + return; + } + + CMapFootprint* footprint; + + if (activePlayer) { + footprint = &s_footprints[0][0] + unk_CF4958++; + + if (unk_CF4958 >= 64) { + unk_CF4958 = 0; + } + } else { + footprint = &s_footprints[0][0] + unk_CF495C++; + + if (unk_CF495C >= 576) { + unk_CF495C = 64; + } + } + + footprint->m_link.Unlink(); + footprint->m_position = *position; + footprint->m_startTime = FrameTime::s_curTimeMs; + footprint->m_textureIndex = textureId; + C44Matrix texMatrix; + C44Matrix fadeMatrix; + C44Matrix rotation; + CMap::BuildFootprintMatrix(rotation, size, left, facing); + ProjectTex2dMakeMatrices(texMatrix, fadeMatrix, box, &rotation, 0.5f, 1); + footprint->m_vertices.SetCount(3 * s_footprintFacets.facets.m_count); + CGxVertexPT0T1* vertex = footprint->m_vertices.m_data; + + for (uint32_t i = 0; i < s_footprintFacets.facets.m_count; i++) { + CFacet& facet = s_footprintFacets.facets.m_data[i]; + + for (uint32_t j = 0; j < 3; j++) { + vertex->m_position = facet.v[j]; + vertex->m_texture0 = C2Vector(facet.v[j] * texMatrix); + vertex->m_texture1 = C2Vector(facet.v[j] * fadeMatrix); + vertex++; + } + } +} + +// VERIFY: fe26d705 manual +// OFFSET: 0x007A6260 +bool CMap::GetTriSubchunk(CMapChunk* chunk, const CiRect* rect, const CAaBox* box) { + int32_t base = 16 * rect->minY + rect->minX + rect->minY; + C3Vector* vertices = &CMapChunk::vertexList[base]; + float* height = &chunk->m_height[base]; + int32_t rowSkip = 17 - (rect->maxX - rect->minX + 1); + World::TriData::Batch* batch = nullptr; + uint16_t* indices = nullptr; + bool found = false; + + for (int32_t y = rect->minY; y <= rect->maxY; y++, vertices += rowSkip, height += rowSkip) { + for (int32_t x = rect->minX; x <= rect->maxX; x++, vertices++, height++) { + if (chunk->m_header->m_holes & CMap::s_holeMask[4 * (y >> 1) + (x >> 1)]) { + continue; + } + + uint8_t outcodes[20]; + + for (uint32_t i = 0; i < 5; i++) { + int32_t index = s_subVertexIndexFlat[i]; + vertices[index].z = height[index]; + outcodes[index] = static_cast(CWorldMath::ComputeAaBoxOutcode(const_cast(box), &vertices[index])); + } + + uint16_t vertexIndex = static_cast(vertices - CMapChunk::vertexList); + + for (uint32_t tri = 0; tri < 12; tri += 3) { + const int32_t* triangle = &s_subVertexTriangles[tri]; + + if (outcodes[triangle[0]] & outcodes[triangle[1]] & outcodes[triangle[2]]) { + continue; + } + + if (!found) { + batch = World::TriData::AllocBatch(); + + if (batch) { + batch->m_def = reinterpret_cast(chunk); + C44Matrix* matrix; + + if (World::TriData::unk_CB7538 + 1 < 32) { + matrix = &World::TriData::matrixPool[World::TriData::unk_CB7538++]; + } else { + World::TriData::statusFlags |= 1; + matrix = nullptr; + } + + matrix->a0 = 1.0f; + matrix->a1 = 0.0f; + matrix->a2 = 0.0f; + matrix->a3 = 0.0f; + matrix->b0 = 0.0f; + matrix->b1 = 1.0f; + matrix->b2 = 0.0f; + matrix->b3 = 0.0f; + matrix->c0 = 0.0f; + matrix->c1 = 0.0f; + matrix->c2 = 1.0f; + matrix->c3 = 0.0f; + matrix->d0 = chunk->m_topLeftCoords.x; + matrix->d1 = chunk->m_topLeftCoords.y; + matrix->d2 = chunk->m_topLeftCoords.z; + matrix->d3 = 1.0f; + batch->m_matrix = matrix; + batch->m_vertexList = CMapChunk::vertexList; + batch->m_heightList = chunk->m_height; + batch->m_normalList = nullptr; + indices = World::TriData::AllocIndices(12 * (rect->maxX - rect->minX + 1) * (rect->maxY - rect->minY + 1)); + batch->m_indices = indices; + } + } + + found = true; + + if (!batch || !batch->m_indices || !batch->m_vertexList) { + continue; + } + + for (uint32_t i = 0; i < 3; i++) { + uint16_t index = vertexIndex + static_cast(triangle[i]); + *indices++ = index; + + if (batch->m_minVertexIndex >= index) { + batch->m_minVertexIndex = index; + } + + if (batch->m_maxVertexIndex <= index) { + batch->m_maxVertexIndex = index; + } + } + + batch->m_indexCount += 3; + batch->m_faceCount++; + } + } + } + + return found; +} + +// VERIFY: c11b2d43 manual +// OFFSET: 0x007A6630 +bool CMap::GetTrisChunk(int32_t chunkX, int32_t chunkY, const CiRect& cellRect, const CAaBox& box, World::TriData* triData, uint32_t flags) { + CMapArea* area = CMap::m_areaTable[64 * ((chunkY >> 4) & 0x3F) + ((chunkX >> 4) & 0x3F)]; + + if (!area || area->m_asyncObject) { + return false; + } + + CMapChunk* chunk = area->m_mapChunks[(chunkX & 0xF) + 16 * (chunkY & 0xF)]; + + if (!chunk) { + return false; + } + + CAaBox localBox = box; + localBox.b.x = localBox.b.x - chunk->m_topLeftCoords.x; + localBox.b.y = localBox.b.y - chunk->m_topLeftCoords.y; + localBox.b.z = localBox.b.z - chunk->m_topLeftCoords.z; + localBox.t.x = localBox.t.x - chunk->m_topLeftCoords.x; + localBox.t.y = localBox.t.y - chunk->m_topLeftCoords.y; + localBox.t.z = localBox.t.z - chunk->m_topLeftCoords.z; + bool result = false; + static CiRect s_chunkRect(0, 0, 7, 7); + CiRect rect; + rect.minY = cellRect.minY - 8 * chunkY; + rect.minX = cellRect.minX - 8 * chunkX; + rect.maxY = cellRect.maxY - 8 * chunkY; + rect.maxX = cellRect.maxX - 8 * chunkX; + rect &= s_chunkRect; + + if (flags & 0x100) { + result = CMap::GetTriSubchunk(chunk, &rect, &localBox); + } + + if (flags & 0x30000) { + bool oceanOnly = (flags & 0x10000) && !(flags & 0x20000); + + for (CChunkLiquid* liquid = chunk->m_liquidChunkLinkList.Head(); liquid; liquid = chunk->m_liquidChunkLinkList.Next(liquid)) { + if (oceanOnly && !(g_liquidTypeDB.GetRecord(liquid->m_type)->m_flags & 0x4)) { + continue; + } + + result |= liquid->GetTris(triData, localBox, rect); + } + } + + return result; +} + +// VERIFY: bd067831 manual +// OFFSET: 0x007A6830 +bool CMap::GetTrisTerrain(const CAaBox& box, World::TriData* triData, uint32_t flags) { + bool result = false; + CiRect cellRect; + cellRect.minY = CMath::fint_(-(box.t.x - 17066.666f) * 0.23999999f - 0.5f); + cellRect.minX = CMath::fint_(-(box.t.y - 17066.666f) * 0.23999999f - 0.5f); + cellRect.maxY = CMath::fint_(-(box.b.x - 17066.666f) * 0.23999999f - 0.5f); + cellRect.maxX = CMath::fint_(-(box.b.y - 17066.666f) * 0.23999999f - 0.5f); + + for (int32_t chunkY = cellRect.minY >> 3; chunkY <= cellRect.maxY >> 3; chunkY++) { + for (int32_t chunkX = cellRect.minX >> 3; chunkX <= cellRect.maxX >> 3; chunkX++) { + result |= CMap::GetTrisChunk(chunkX, chunkY, cellRect, box, triData, flags); + } + } + + return result; +} + +// VERIFY: 24d73f6d manual +// OFFSET: 0x007A6940 +bool CMap::QueryTrisMapObjDefs(const CAaBox& box, World::TriData* triData, uint32_t flags) { + CAaBox localBox; + localBox.b = C3Vector(0.0f, 0.0f, 0.0f); + localBox.t = C3Vector(0.0f, 0.0f, 0.0f); + C3Vector center((box.b.x + box.t.x) * 0.5f, (box.t.y + box.b.y) * 0.5f, 0.5f * (box.t.z + box.b.z)); + CAaBox extents; + extents.b = box.b - center; + extents.t = box.t - center; + bool result = false; + + for (CMapObjDef* mapObjDef = CMap::mapObjDefHash.m_fulllist.Head(); mapObjDef; mapObjDef = CMap::mapObjDefHash.Next(mapObjDef)) { + if (mapObjDef->m_flags & 0x20) { + continue; + } + + CMapObj* mapObj = mapObjDef->m_owner; + + if (!mapObj) { + continue; + } + + C3Vector localCenter = center * mapObjDef->m_invMat; + C33Matrix rotation(mapObjDef->m_invMat); + CWorldMath::TransformAABox(rotation, extents, localBox); + localBox.b += localCenter; + localBox.t += localCenter; + + if (mapObj->TestBounds(localBox)) { + result |= mapObj->GetTris(localBox, flags, triData, mapObjDef); + } + } + + return result; +} + +// VERIFY: 87b59ea2 auto +// OFFSET: 0x007A6AF0 +bool CMap::QueryTris(const CAaBox& box, World::TriData* triData, uint32_t flags) { + bool result = false; + + if (flags & 0x300F0) { + result = CMap::QueryTrisMapObjDefs(box, triData, flags); + } + + if (flags & 0x30100) { + return CMap::GetTrisTerrain(box, triData, flags) | result; + } + + return result; +} + +// VERIFY: 0e38b513 manual +// OFFSET: 0x007A2AA0 +uint32_t CMap::QueryIntersectingModels(CM2Model** models, uint32_t maxModels, const CAaBox& box, uint32_t flags) { + if (!maxModels) { + return 0; + } + + uint32_t count = 0; + + for (CMapObjDef* mapObjDef = CMap::mapObjDefHash.m_fulllist.Head(); mapObjDef; mapObjDef = CMap::mapObjDefHash.Next(mapObjDef)) { + if ((mapObjDef->m_flags & 0x100) || !mapObjDef->m_bbox.Intersects(box)) { + continue; + } + + CMapObj* mapObj = mapObjDef->m_owner; + + for (CMapBaseObjLink* link = mapObjDef->m_mapObjDefGroupLinkList.Head(); link; link = mapObjDef->m_mapObjDefGroupLinkList.Next(link)) { + CMapObjDefGroup* defGroup = static_cast(link->m_owner); + + if (!mapObj->IsGroupLoaded(defGroup->m_groupNum) || !defGroup->m_bbox.Intersects(box)) { + continue; + } + + for (CMapBaseObjLink* doodadLink = defGroup->m_doodadDefLinkList.Head(); doodadLink; doodadLink = defGroup->m_doodadDefLinkList.Next(doodadLink)) { + CMapStaticEntity* doodadDef = static_cast(doodadLink->m_owner); + CM2Model* model = doodadDef->m_model; + + if (!model) { + continue; + } + + uint32_t doodadFlags = doodadDef->m_flags; + + if (!(doodadFlags & 0x80) || !doodadDef->m_bbox.Intersects(box)) { + continue; + } + + uint32_t match = (flags & 0x200122) != 0; + + if (flags & 0x2000000) { + match |= doodadFlags & 0x1000; + } + + if (flags & 0x100111) { + match |= (doodadFlags & 0x100) == 0; + } + + if (match) { + models[count++] = model; + + if (count == maxModels) { + return count; + } + } + } + } + } + + return count; +} diff --git a/WoW/Source/WorldClient/Map.h b/WoW/Source/WorldClient/Map.h index 8f28805..a9d7585 100644 --- a/WoW/Source/WorldClient/Map.h +++ b/WoW/Source/WorldClient/Map.h @@ -38,7 +38,7 @@ class CMapStaticEntity; class CiRect; class SFileImpl; class SFile; -namespace World { class FacetData; struct LiquidQueryResult; class ObjectCollisionData; } +namespace World { class FacetData; class TriData; struct LiquidQueryResult; class ObjectCollisionData; } struct CGxBuf; struct CGxPool; @@ -100,7 +100,7 @@ class CGxVertexPT0T1 { }; struct CMapFootprint { - /* 0000 */ uint32_t unk_0000[3]; + /* 0000 */ C3Vector m_position; /* 000C */ uint32_t m_alpha; /* 0010 */ uint32_t m_textureIndex; /* 0014 */ uint32_t unk_0014; @@ -148,6 +148,11 @@ class CDestructibleProxy { class CMap { public: + static void UpdateDoodadDefTransform(CMapDoodadDef* doodadDef, const C44Matrix& matrix); + static void UpdateDoodadDefBounds(CMapDoodadDef* doodadDef); + static CMapObjDef* CreateMapObjDef(const char* fileName, const C3Vector* position, float facing, int32_t waitLoad, uint32_t doodadSetCount, const int16_t* doodadSets, float* radius, uint32_t id); + static void SnapBaseObjToSubChunk(CMapBaseObj* baseObj, const C3Vector* position, float facing); + static void UpdateDoodadDef(CMapDoodadDef* doodadDef, const C3Vector* position, float facing); static TSGrowableArray debugVertexArray; static TSGrowableArray debugIndexArray; static CMapLight* s_mapLight; @@ -163,6 +168,7 @@ class CMap { static bool enablePixelShaders; static bool enableVertexShaders; static TSList > mapObjDefLinkList; + static TSList > s_unk_ADFBF8; static TSList > s_unk_AF16CC; static CGxBuf* lowDetailIndexBuf; static CGxPool* lowDetailIndexPool; @@ -198,7 +204,7 @@ class CMap { static uint32_t* baseObjLinkHeap; static uint32_t* areaHeap; static uint32_t* areaMedHeap; - static uint32_t* areaLowHeap; + static CMapAreaLowHeap* areaLowHeap; static uint32_t* chunkHeap; static uint32_t* doodadDefHeap; static uint32_t* entityHeap; @@ -262,6 +268,15 @@ class CMap { static CMapArea* GetAreaAtPosition(const C2Vector* pos); static CMapChunk* GetChunkAtPosition(const C2Vector* pos); static CMapAreaLow* AllocAreaLow(); + static bool QueryTris(const CAaBox& box, World::TriData* triData, uint32_t flags); + static bool GetTrisTerrain(const CAaBox& box, World::TriData* triData, uint32_t flags); + static bool GetTrisChunk(int32_t chunkX, int32_t chunkY, const CiRect& cellRect, const CAaBox& box, World::TriData* triData, uint32_t flags); + static bool GetTriSubchunk(CMapChunk* chunk, const CiRect* rect, const CAaBox* box); + static bool QueryTrisMapObjDefs(const CAaBox& box, World::TriData* triData, uint32_t flags); + static uint32_t QueryIntersectingModels(CM2Model** models, uint32_t maxModels, const CAaBox& box, uint32_t flags); + static void BuildFootprintMatrix(C44Matrix& matrix, const float* size, int32_t left, float facing); + static void NewFootprint(int32_t textureId, const float* size, const C3Vector* position, float facing, int32_t left, int32_t terrainType, int32_t activePlayer); + static void FreeAreaLow(CMapAreaLow* areaLow); static void RenderLowDetail(CMapAreaLow* area); static void BuildLowDetailGridVertices(CMapAreaLow* area, CGxBuf* buf); static void BuildLowDetailGridIndices(uint16_t* holes, int32_t pass, CGxBuf* buf); @@ -294,6 +309,7 @@ class CMap { static CMapLight* AllocLight(); static CMapObjDef* CreateMapObjDef(char* fileName, SMMapObjDef* mapObjectDef, C3Vector* center, bool cached); static CMapDoodadDef* CreateDoodadDef(const char* fileName, SMDoodadDef* doodadDef, C3Vector* center); + static CMapDoodadDef* CreateDoodadDef(const char* fileName, const C3Vector* position, float facing, int32_t a4); static CMapLight* CreateLight(uint8_t a1, uint8_t a2); static CMapDoodadDef* CreateDoodadDef(uint32_t doodadRef, SMODoodadDef* doodadDef, char* name, uint32_t key, C44Matrix* mat, uint16_t doodadSet); static void FreeBaseObjLinksInBounds(CAaBox* box); diff --git a/WoW/Source/WorldClient/MapChunkLiquid.cpp b/WoW/Source/WorldClient/MapChunkLiquid.cpp index a3277c3..a38dbac 100644 --- a/WoW/Source/WorldClient/MapChunkLiquid.cpp +++ b/WoW/Source/WorldClient/MapChunkLiquid.cpp @@ -687,6 +687,41 @@ bool CChunkLiquid::GetTris(World::TriData* triData, uint8_t* codes, const C2iVec return batch != nullptr; } +// VERIFY: 9cf4f78e manual +// OFFSET: 0x007CE960 +bool CChunkLiquid::GetTris(World::TriData* triData, const CAaBox& box, const CiRect& rect) { + CiRect query; + query.minY = rect.minY; + query.minX = rect.minX; + query.maxY = rect.maxY + 1; + query.maxX = rect.maxX + 1; + CiRect clip = reinterpret_cast(this->m_tileBegin) & query; + C2iVector size; + size.x = clip.maxX - clip.minX; + size.y = clip.maxY - clip.minY; + int32_t stride = this->m_tileEnd.y - this->m_tileBegin.y + 1; + C2iVector start; + start.x = clip.minX; + start.y = clip.minY; + const C3Vector* vert = &this->m_verts[(clip.minY - this->m_tileBegin.x) * stride - this->m_tileBegin.y + clip.minX]; + uint8_t codes[81]; + uint8_t* code = codes; + + for (int32_t y = 0; y < size.y + 1; y++) { + for (int32_t x = 0; x < size.x + 1; x++) { + float below = vert->z - box.b.z + 0.019444443f; + float above = box.t.z - vert->z + 0.019444443f; + *code = static_cast(((reinterpret_cast(below) >> 29) & 0x4) | ((reinterpret_cast(above) >> 26) & 0x20)); + vert++; + code++; + } + + vert += stride - (size.x + 1); + } + + return this->GetTris(triData, codes, start, size); +} + // VERIFY: 22a3788a manual // OFFSET: 0x007CEB80 bool CChunkLiquid::GetTris(World::TriData* triData, const CFrustum& frustum, const CiRect& rect) const { diff --git a/WoW/Source/WorldClient/MapDoodadDef.cpp b/WoW/Source/WorldClient/MapDoodadDef.cpp index 2810186..ef06c11 100644 --- a/WoW/Source/WorldClient/MapDoodadDef.cpp +++ b/WoW/Source/WorldClient/MapDoodadDef.cpp @@ -17,6 +17,7 @@ #include "WoW/Source/WorldClient/Types.h" #include "WoW/Source/WorldClient/World.h" #include "WoW/Source/WorldClient/WorldView.h" +#include "Engine/Source/Model2/M2Scene.h" // VERIFY: 4012bf37 manual // OFFSET: 0x007B4FA0 @@ -224,3 +225,25 @@ void CMapDoodadDef::Purge(CMapDoodadDef* doodadDef) { doodadDef->m_doodadDefLink.Unlink(); CMap::FreeDoodadDef(doodadDef); } + +// VERIFY: 9bd1ba20 manual +// OFFSET: 0x007BDA70 +void CMapDoodadDef::CreateModel(const char* fileName, CMapDoodadDef* doodadDef, int32_t waitForLoad, int32_t a4) { + CM2Model* model = World::s_m2Scene->CreateModel(fileName, a4 ? 0x20 : 0); + doodadDef->m_model = model; + + if (!model) { + return; + } + + model->m_fFlags |= 0x8000; + model->m_worldTransform = doodadDef->m_mat; + doodadDef->m_model->SetEventCallback(reinterpret_cast(CMapStaticEntity::ModelEventCallback), reinterpret_cast(doodadDef)); + doodadDef->m_model->m_lightingCallback = CMapStaticEntity::ModelLightingCallback; + doodadDef->m_model->m_lightingArg = doodadDef; + doodadDef->m_model->SetBoneSequence(0xFFFFFFFF, 0, 0xFFFFFFFF, 0, 1.0f, 1, 1); + + if (waitForLoad) { + doodadDef->m_model->IsLoaded(1, 0); + } +} diff --git a/WoW/Source/WorldClient/MapDoodadDef.h b/WoW/Source/WorldClient/MapDoodadDef.h index f16a4df..d8a9237 100644 --- a/WoW/Source/WorldClient/MapDoodadDef.h +++ b/WoW/Source/WorldClient/MapDoodadDef.h @@ -16,6 +16,7 @@ class CMapObjDef; class CMapDoodadDef : public CMapStaticEntity, public TSHashObject { public: + static void CreateModel(const char* fileName, CMapDoodadDef* doodadDef, int32_t waitForLoad, int32_t a4); static void ExtendBounds(CMapDoodadDef* doodadDef, CMapBaseObj* parent); static void Purge(CMapDoodadDef* doodadDef); diff --git a/WoW/Source/WorldClient/MapLowDetail.cpp b/WoW/Source/WorldClient/MapLowDetail.cpp index a7a0ad1..340c3f3 100644 --- a/WoW/Source/WorldClient/MapLowDetail.cpp +++ b/WoW/Source/WorldClient/MapLowDetail.cpp @@ -13,6 +13,7 @@ #include "Engine/Source/Gx/CGxDevice/CGxDevice.h" #include "Engine/Source/Gx/Gx.h" #include "WoW/Source/WorldClient/DayNight__DNInfo.h" +#include "Engine/Source/Gx/CGxVertexPC.h" // VERIFY: pending // VERIFY: 3763adce auto @@ -317,3 +318,109 @@ void CMap::RenderLowDetail(CMapAreaLow* area) { g_theGxDevicePtr->RsPop(); g_theGxDevicePtr->m_xforms[GxXform_Tex0].Identity(); } + +// VERIFY: 894a0529 manual +// OFFSET: 0x007D5150 +void CMap::BuildLowDetailGridVertices(CMapAreaLow* area, CGxBuf* buf) { + CGxVertexPC* vertex = reinterpret_cast(g_theGxDevicePtr->BufLock(buf)); + uint32_t index = 0; + float x = area->m_topLeft.x; + + for (int32_t row = 0; row < 17; row++) { + float y = area->m_topLeft.y; + + for (int32_t col = 0; col < 17; col++) { + vertex->p.x = x; + vertex->p.y = y; + vertex->p.z = area->m_heights[index++]; + vertex->c = CImVector(0xFF, 0xFF, 0xFF, 0xFF); + vertex++; + y -= 33.333332f; + } + + x -= 33.333332f; + } + + x = area->m_topLeft.x - 16.666666f; + + for (int32_t row = 0; row < 16; row++) { + float y = area->m_topLeft.y - 16.666666f; + + for (int32_t col = 0; col < 16; col++) { + vertex->p.x = x; + vertex->p.y = y; + vertex->p.z = area->m_heights[index++]; + vertex->c = CImVector(0xFF, 0xFF, 0xFF, 0xFF); + vertex++; + y -= 33.333332f; + } + + x -= 33.333332f; + } + + g_theGxDevicePtr->BufUnlock(buf, 0); + buf->unk_001C = 1; +} + +// VERIFY: 7d2e0b07 manual +// OFFSET: 0x007D5240 +void CMap::BuildLowDetailGridIndices(uint16_t* holes, int32_t pass, CGxBuf* buf) { + uint16_t* indices = reinterpret_cast(g_theGxDevicePtr->BufLock(buf)); + uint32_t outer = 0; + uint32_t inner = 289; + + for (uint32_t row = 0; row < 16; row++) { + for (int32_t col = 0; col < 16; col++) { + if (!holes || (pass ? (holes[row] & (1 << col)) != 0 : (holes[row] & (1 << col)) == 0)) { + *indices++ = inner; + *indices++ = outer + 1; + *indices++ = outer; + *indices++ = inner; + *indices++ = outer + 18; + *indices++ = outer + 1; + *indices++ = inner; + *indices++ = outer + 17; + *indices++ = outer + 18; + *indices++ = inner; + *indices++ = outer; + *indices++ = outer + 17; + } + + outer++; + inner++; + } + + outer++; + } + + g_theGxDevicePtr->BufUnlock(buf, 0); + buf->unk_001C = 1; +} + +// VERIFY: f803b515 manual +// OFFSET: 0x007CC770 +void CMapLowDetail::Unload() { + for (uint32_t i = 0; i < 4096; i++) { + if (this->m_areas[i]) { + CMap::FreeAreaLow(this->m_areas[i]); + this->m_areas[i] = nullptr; + } + } + + for (uint32_t i = 0; i < this->m_mapObjDefList.m_count; i++) { + this->m_mapObjDefList.m_data[i]->m_refCount--; + CMap::PurgeMapObjDef(this->m_mapObjDefList.m_data[i]); + } + + this->m_mapObjDefList.m_count = 0; + this->m_mapObjNames = nullptr; + this->m_mapObjNameOffsets = nullptr; + this->m_mapObjDefs = nullptr; + this->m_mapObjDefCount = 0; + this->m_areaOffsets = nullptr; + + if (this->m_data) { + SMemFree(this->m_data, nullptr, 0, 0); + this->m_data = nullptr; + } +} diff --git a/WoW/Source/WorldClient/MapLowDetail.h b/WoW/Source/WorldClient/MapLowDetail.h index 8153c00..d20b7cb 100644 --- a/WoW/Source/WorldClient/MapLowDetail.h +++ b/WoW/Source/WorldClient/MapLowDetail.h @@ -30,6 +30,13 @@ class CMapAreaLow { CMapAreaLow(); }; +class CMapAreaLowHeap { + public: + /* 0000 */ uint32_t m_heapId; + + void Delete(CMapAreaLow* areaLow); +}; + class CMapLowDetail { public: /* 0000 */ char* m_data; @@ -45,6 +52,7 @@ class CMapLowDetail { void Load(const char* mapPath, const char* mapName); void Purge(); + void Unload(); }; #endif diff --git a/WoW/Source/WorldClient/MapObj.cpp b/WoW/Source/WorldClient/MapObj.cpp index 5b6c112..192ca9d 100644 --- a/WoW/Source/WorldClient/MapObj.cpp +++ b/WoW/Source/WorldClient/MapObj.cpp @@ -55,6 +55,7 @@ #include "WoW/Source/Ui/GameUI.h" #include #include "Engine/Source/ConsoleBase/ConsoleVar.h" +#include "Engine/Source/Gx/CGxMatrixStack.h" // STATIC: 0x00AEE008 uint32_t CMapObj::s_unk_AEE008 = 2; @@ -161,7 +162,7 @@ static uint32_t s_smolVertCacheSize; // STATIC: 0x00D1BF00 static SMOLiquidVert s_smolVertCache[64]; -// VERIFY: 05ab90b4 auto +// VERIFY: 7a37847b auto // OFFSET: 0x007A6140 World::TriData::Batch* World::TriData::AllocBatch() { if (World::TriData::nBatches + 1 >= 32) { @@ -173,7 +174,7 @@ World::TriData::Batch* World::TriData::AllocBatch() { batch->m_matrix = nullptr; batch->m_vertexList = nullptr; batch->m_normalList = nullptr; - batch->unk_000C = 0; + batch->m_heightList = nullptr; batch->m_indices = nullptr; batch->m_faceIndices = nullptr; batch->m_indexCount = 0; @@ -3123,3 +3124,89 @@ bool CMapObj::VectorIntersectPortals(uint32_t groupNum, C3Segment& seg, float* t return found; } + +// VERIFY: e67c38fa manual +// OFFSET: 0x007AB760 +void CMapObj::RenderMapObjGroupsShadowMap(void* groups, uint32_t count, void* groupData, const C44Matrix& translation, CFrustum& frustum) { + CAaBox box; + box.b.x = 0.0f; + box.b.y = 0.0f; + box.b.z = 0.0f; + box.t.x = 0.0f; + box.t.y = 0.0f; + box.t.z = 0.0f; + g_theGxDevicePtr->RsPush(); + float constants[4] = { 1.0f, 0.0f, 0.0f, 0.0f }; + CMapObjGroup** groupList = static_cast(groups); + C44Matrix** matrices = static_cast(groupData); + + for (uint32_t i = 0; i < count; i++) { + C44Matrix* matrix = matrices[i]; + CMapObjGroup* group = groupList[i]; + CMapObj* mapObj = group->m_parent; + C44Matrix world = *matrix * translation; + CGxMatrixStack& stack = g_theGxDevicePtr->m_xforms[GxXform_World]; + stack.m_dirty = 1; + stack.m_flags[stack.m_level] &= ~CGxMatrixStack::F_Identity; + stack.m_mtx[stack.m_level] = world; + CWorldMath::TransformAABox(*matrix, group->m_bbox, box); + + if (!group->m_batchListCount || !frustum.Cull(box)) { + continue; + } + + group->m_timer = 0.0f; + group->AllocVB(); + group->SetIndexVB(); + group->SetVertexVB(); + CShaderEffect::UpdateWorldViewMatrix(); + + if (group->m_unkLoadedFlag & 0x4) { + CShaderEffect::SetAlphaRef(0.0f); + CShaderEffect::SetDefaultShaders(0); + GxRsSet(GxRs_Texture0, 0); + constants[3] = 0.0f; + g_theGxDevicePtr->ShaderConstantsSet(GxSh_Pixel, 2, constants, 1); + CGxBatch batch; + batch.m_primType = GxPrim_Triangles; + batch.m_start = group->m_indexMin; + batch.m_count = group->m_indexMax - group->m_indexMin + 1; + batch.m_minIndex = group->m_vertexMin; + batch.m_maxIndex = group->m_vertexMax; + g_theGxDevicePtr->Draw(&batch, 1); + continue; + } + + CShaderEffect::SetAlphaRef(0.87843138f); + CShaderEffect::SetDefaultShaders(0); + + for (int32_t j = 0; j < group->m_batchListCount; j++) { + SMOBatch& smoBatch = group->m_batchList[j]; + SMOMaterial& material = mapObj->m_materialList[smoBatch.m_texture]; + CGxTex* gxTex = TextureGetGxTex(material.Textures()[0], 0, nullptr); + + if (!gxTex) { + continue; + } + + g_theGxDevicePtr->RsSet(GxRs_Texture0, gxTex); + constants[3] = material.m_blendMode == 1 ? 0.87843138f : 0.0f; + g_theGxDevicePtr->ShaderConstantsSet(GxSh_Pixel, 2, constants, 1); + CGxBatch batch; + batch.m_primType = GxPrim_Triangles; + batch.m_start = smoBatch.m_indexStart; + batch.m_count = smoBatch.m_indexCount; + batch.m_minIndex = smoBatch.m_vertexStart; + batch.m_maxIndex = smoBatch.m_vertexEnd; + g_theGxDevicePtr->Draw(&batch, 1); + } + } + + g_theGxDevicePtr->RsPop(); +} + +// VERIFY: 2d3fae74 auto +// OFFSET: 0x007AE050 +void CMapObj::DestroyPools() { + CMapObj::bPoolsDirty = 1; +} diff --git a/WoW/Source/WorldClient/MapObj.h b/WoW/Source/WorldClient/MapObj.h index ebfa6d9..34220b1 100644 --- a/WoW/Source/WorldClient/MapObj.h +++ b/WoW/Source/WorldClient/MapObj.h @@ -54,7 +54,7 @@ typedef void (*RENDER_CALLBACK)(uint32_t, void*); class CMapObj : public CMapObjIndex, public TSHashObject { public: - static void RenderMapObjGroupsShadowMap(void* groups, uint32_t count, void* groupData, const C44Matrix& translation, const CFrustum& frustum); + static void RenderMapObjGroupsShadowMap(void* groups, uint32_t count, void* groupData, const C44Matrix& translation, CFrustum& frustum); bool QueryLighting(uint32_t groupNum, const C3Vector& point, uint16_t face, CImVector* color, uint8_t* flag); bool QueryLighting(uint32_t groupNum, const C3Segment& seg, CImVector* color, uint8_t* flag); static TSList > s_asyncLoadQueue; @@ -73,6 +73,7 @@ class CMapObj : public CMapObjIndex, public TSHashObject static uint32_t s_unk_AEE008; static void ClearCache(int32_t a1); + static void DestroyPools(); int32_t IsAllLoaded(); static void Destroy(); diff --git a/WoW/Source/WorldClient/MapObjDef.cpp b/WoW/Source/WorldClient/MapObjDef.cpp index 182c9ff..5a7b340 100644 --- a/WoW/Source/WorldClient/MapObjDef.cpp +++ b/WoW/Source/WorldClient/MapObjDef.cpp @@ -7,6 +7,10 @@ #include "WoW/Source/WorldClient/MapObj.h" #include "WoW/Source/WorldClient/MapObjGroup.h" #include "WoW/Source/WorldClient/Types.h" +#include "WoW/Source/WorldClient/MapDoodadDef.h" +#include "Engine/Source/BlizzardCore/SFile2-Core.h" +#include "Engine/Source/Model2/M2Model.h" +#include "WoW/Source/WorldClient/MapLoad.h" // VERIFY: 18be6c93 auto // OFFSET: 0x007B3990 @@ -98,3 +102,95 @@ int32_t CMapObjDef::GetGroundType(uint32_t groupNum, uint16_t faceIndex) { return -1; } + +// VERIFY: 14be0e9a manual +// OFFSET: 0x007B66E0 +void CMapObjDef::UpdatePos(CMapObjDef* mapObjDef, const C3Vector* position, float facing, float a4, float a5) { + mapObjDef->m_position = *position; + mapObjDef->m_mat = C44Matrix(); + mapObjDef->m_mat.d0 = position->x; + mapObjDef->m_mat.d1 = position->y; + mapObjDef->m_mat.d2 = position->z; + mapObjDef->m_mat.RotateAroundZ(facing); + mapObjDef->m_mat.RotateAroundY(a4); + mapObjDef->m_mat.RotateAroundX(a5); + mapObjDef->m_invMat = mapObjDef->m_mat.AffineInverse(); + CMapObjDef::UpdateMoved(mapObjDef); +} + +// VERIFY: 70a9844c manual +// OFFSET: 0x007B41F0 +void CMapObjDefGroup::SetSequenceFinishedCallback(M2SequenceCallback callback, uint64_t param, uint16_t doodadSet) { + for (CMapBaseObjLink* link = this->m_doodadDefLinkList.Head(); link; link = this->m_doodadDefLinkList.Next(link)) { + CMapDoodadDef* doodadDef = static_cast(link->m_owner); + + if (doodadSet && !doodadDef->unk_016C) { + break; + } + + if (doodadDef->m_model && doodadDef->unk_016C == doodadSet) { + doodadDef->m_model->SetSequenceCallback(reinterpret_cast(callback), param); + } + } +} + +// VERIFY: 5ecf6841 manual +// OFFSET: 0x007B4640 +void CMapObjDef::SetSequenceFinishedCallback(M2SequenceCallback callback, uint64_t param, uint16_t doodadSet) { + for (CMapBaseObjLink* link = this->m_mapObjDefGroupLinkList.Head(); link; link = this->m_mapObjDefGroupLinkList.Next(link)) { + static_cast(link->m_owner)->SetSequenceFinishedCallback(callback, param, doodadSet); + } +} + +// VERIFY: a5601f23 manual +// OFFSET: 0x007B67B0 +void CMapObjDef::UpdateMatrix(CMapObjDef* mapObjDef, const C44Matrix& matrix) { + mapObjDef->m_position.x = matrix.d0; + mapObjDef->m_position.y = matrix.d1; + mapObjDef->m_position.z = matrix.d2; + mapObjDef->m_mat = matrix; + mapObjDef->m_invMat = matrix.AffineInverse(); + CMapObjDef::UpdateMoved(mapObjDef); +} + +// VERIFY: 04ab0ef9 manual +// OFFSET: 0x007B42F0 +bool CMapObjDefGroup::IsAllLoaded() { + if (!(this->m_flags & MAPOBJ_FLAG_REFS_CREATED)) { + return false; + } + + for (CMapBaseObjLink* link = this->m_doodadDefLinkList.Head(); link; link = this->m_doodadDefLinkList.Next(link)) { + CMapStaticEntity* doodadDef = static_cast(link->m_owner); + + if (doodadDef->m_model && !(static_cast(doodadDef->m_flags) & 0x80000000)) { + if (SFile::IsStreamingMode()) { + doodadDef->m_model->LinkToAsyncHead(1); + } + + return false; + } + } + + return true; +} + +// VERIFY: c4f26801 manual +// OFFSET: 0x007B4760 +bool CMapObjDef::IsAllLoaded() { + if (!(this->m_flags & MAPOBJ_FLAG_PREPARED)) { + return false; + } + + if (!(this->m_flags & 0x4000)) { + for (CMapBaseObjLink* link = this->m_mapObjDefGroupLinkList.Head(); link; link = this->m_mapObjDefGroupLinkList.Next(link)) { + if (!static_cast(link->m_owner)->IsAllLoaded()) { + return false; + } + } + + this->m_flags = static_cast(this->m_flags | 0x4000); + } + + return true; +} diff --git a/WoW/Source/WorldClient/MapObjDef.h b/WoW/Source/WorldClient/MapObjDef.h index c541cd6..063be38 100644 --- a/WoW/Source/WorldClient/MapObjDef.h +++ b/WoW/Source/WorldClient/MapObjDef.h @@ -1,10 +1,10 @@ #ifndef WOW_SOURCE_WORLDCLIENT_MAPOBJDEF_H #define WOW_SOURCE_WORLDCLIENT_MAPOBJDEF_H +#include "Engine/Source/Model2/M2Model.h" #include #include #include "WoW/Source/Object/WGUID.h" -#include #include "Engine/Source/Tempest/C3Vector.h" #include "Engine/Source/Tempest/C44Matrix.h" #include "Engine/Source/Tempest/CAaBox.h" @@ -47,10 +47,16 @@ class CMapObjDefGroup : public CMapBaseObj { CMapObjDefGroup(); void UpdateLights(); + void SetSequenceFinishedCallback(M2SequenceCallback callback, uint64_t param, uint16_t doodadSet); + bool IsAllLoaded(); }; class CMapObjDef : public CMapBaseObj, public TSHashObject { public: + static void UpdateMatrix(CMapObjDef* mapObjDef, const C44Matrix& matrix); + void SetSequenceFinishedCallback(M2SequenceCallback callback, uint64_t param, uint16_t doodadSet); + static void UpdateMoved(CMapObjDef* mapObjDef); + static void UpdatePos(CMapObjDef* mapObjDef, const C3Vector* position, float facing, float a4, float a5); /* 003C */ C3Vector m_position; /* 0048 */ CAaBox m_bbox; /* 0060 */ CAaSphere m_sphere; @@ -77,7 +83,7 @@ class CMapObjDef : public CMapBaseObj, public TSHashObject* groups); void CullMapObjDefGroupFromExterior(CMapObjDefGroup* mapObjDefGroup, CRect* rect, uint32_t skipOcclusion); diff --git a/WoW/Source/WorldClient/MapObjGroup.cpp b/WoW/Source/WorldClient/MapObjGroup.cpp index bca5201..646aaee 100644 --- a/WoW/Source/WorldClient/MapObjGroup.cpp +++ b/WoW/Source/WorldClient/MapObjGroup.cpp @@ -279,7 +279,7 @@ BspQuery::~BspQuery() { BspQuery::testFaceSub = 0; } -// VERIFY: 1f9c3dca auto +// VERIFY: 8fcd1fbd auto // OFFSET: 0x007C7710 World::TriData::Batch* __stdcall World::TriData::AllocBatch(uint32_t indexCount, uint32_t faceCount) { if (World::TriData::nBatches + 1 >= 32 || indexCount + World::TriData::indexCursor >= 0xC000 || faceCount + World::TriData::faceIndexCursor >= 0x4000) { @@ -291,7 +291,7 @@ World::TriData::Batch* __stdcall World::TriData::AllocBatch(uint32_t indexCount, batch->m_matrix = nullptr; batch->m_vertexList = nullptr; batch->m_normalList = nullptr; - batch->unk_000C = 0; + batch->m_heightList = nullptr; batch->m_indices = nullptr; batch->m_faceIndices = nullptr; batch->m_indexCount = 0; diff --git a/WoW/Source/WorldClient/MapObjGroup.h b/WoW/Source/WorldClient/MapObjGroup.h index a3ef0b0..cd51ee2 100644 --- a/WoW/Source/WorldClient/MapObjGroup.h +++ b/WoW/Source/WorldClient/MapObjGroup.h @@ -348,7 +348,7 @@ namespace World { /* 0000 */ C44Matrix* m_matrix; /* 0004 */ C3Vector* m_vertexList; /* 0008 */ C3Vector* m_normalList; - /* 000C */ uint32_t unk_000C; + /* 000C */ float* m_heightList; /* 0010 */ uint16_t* m_indices; /* 0014 */ uint16_t* m_faceIndices; /* 0018 */ uint16_t m_indexCount; diff --git a/WoW/Source/WorldClient/MapWeather.cpp b/WoW/Source/WorldClient/MapWeather.cpp index 2c8643f..e968289 100644 --- a/WoW/Source/WorldClient/MapWeather.cpp +++ b/WoW/Source/WorldClient/MapWeather.cpp @@ -543,3 +543,13 @@ void Weather::UpdatePosDeltas() { this->unk_016C = 0.0f; } } + +// VERIFY: e5f3f9ba auto +// OFFSET: 0x00783B90 +void Weather::FillInDefaultPrecipTexturePath(uint32_t type) { + if (type == 1) { + SStrCopy(this->m_precipTexture, "textures\\Weather\\RainDrop01.blp", 0x7FFFFFFF); + } else if (type == 2) { + SStrCopy(this->m_precipTexture, "textures\\Weather\\SnowFlake01.blp", 0x7FFFFFFF); + } +} diff --git a/WoW/Source/WorldClient/WaterRipple.cpp b/WoW/Source/WorldClient/WaterRipple.cpp index 4b410c1..fb24478 100644 --- a/WoW/Source/WorldClient/WaterRipple.cpp +++ b/WoW/Source/WorldClient/WaterRipple.cpp @@ -20,6 +20,7 @@ #include "Engine/Source/Gx/CGxTexFlags.h" #include "Engine/Source/Services/Texture.h" #include "Engine/Source/Storm/H/stpl.h" +#include "WoW/Source/WorldClient/MapObjGroup.h" // STATIC: 0x00ADF7F4 static const char* unk_ADF7F4[2] = { @@ -27,6 +28,9 @@ static const char* unk_ADF7F4[2] = { "XTextures\\splash\\wake.blp" }; +// STATIC: 0x00A3FAC0 +static float s_rippleFadeFraction[2] = { 0.40000001f, 0.40000001f }; + // STATIC: 0x00ADFB58 static TSExplicitList s_unk_ADFB58; @@ -53,7 +57,6 @@ CGxShader* WaterRipple::s_psWaterRipples; // INLINED CWaterRipple::CWaterRipple() { - this->unk_004C = 0; } // VERIFY: 7160b523 manual @@ -290,3 +293,77 @@ void WaterRipple::Destroy() { g_theGxDevicePtr->ShaderDestroy(WaterRipple::s_psWaterRipples); } } + +// VERIFY: 3fca29ac manual +// OFFSET: 0x0079CF40 +void CWaterRipple::InitRipple(const C3Vector& pos, float rotation, float size, float alpha, float duration, float growth, int32_t type) { + int32_t directional = type != 0; + this->m_type = directional; + this->m_position = pos; + this->m_rotation = rotation; + this->m_size = size; + float endSize = growth * duration + size; + this->m_growth = (endSize - size) / duration; + this->m_alpha = 0.0f; + this->m_maxAlpha = alpha; + this->m_fadeIn = alpha / (s_rippleFadeFraction[directional] * duration); + this->m_fadeOut = -(alpha / ((1.0f - s_rippleFadeFraction[directional]) * duration)); + this->m_endTime = duration + FrameTime::s_curTimeSec; + CAaBox box; + box.b.x = pos.x - endSize; + box.b.y = pos.y - endSize; + box.b.z = pos.z - 1.0f; + box.t.x = pos.x + endSize; + box.t.y = endSize + pos.y; + box.t.z = pos.z + 1.0f; + this->m_verts.SetCount(0); + World::TriData::statusFlags = 0; + World::TriData::nBatches = 0; + World::TriData::faceIndexCursor = 0; + World::TriData::indexCursor = 0; + World::TriData::unk_CB7538 = 0; + World::TriData triData; + + if (!World::GetTris(box, &triData, 0x20000)) { + return; + } + + for (uint32_t i = 0; i < World::TriData::nBatches; i++) { + World::TriData::Batch& batch = World::TriData::batches[i]; + const uint16_t* indices = batch.m_indices; + uint32_t base = this->m_verts.Count(); + this->m_verts.SetCount(batch.m_faceCount + base + 2 * batch.m_faceCount); + C3Vector* out = &this->m_verts.m_data[base]; + + for (uint32_t j = 0; j < batch.m_faceCount; j++) { + *out++ = batch.m_vertexList[indices[0]] * *batch.m_matrix; + *out++ = batch.m_vertexList[indices[1]] * *batch.m_matrix; + *out++ = batch.m_vertexList[indices[2]] * *batch.m_matrix; + indices += 3; + } + } +} + +// VERIFY: ab8c02c2 auto +// OFFSET: 0x0079D180 +void WaterRipple::Create(const C3Vector& pos, float facing, float size, float alpha, float duration, float growth, int32_t type, int32_t player) { + uint32_t index; + + if (player) { + index = WaterRipple::s_nextPlayerRipple++; + + if (WaterRipple::s_nextPlayerRipple >= 32) { + WaterRipple::s_nextPlayerRipple = 0; + } + } else { + index = WaterRipple::s_nextUnitRipple++; + + if (WaterRipple::s_nextUnitRipple >= 128) { + WaterRipple::s_nextUnitRipple = 32; + } + } + + CWaterRipple* ripple = &unk_CDFFE0.m_data[index]; + ripple->InitRipple(pos, -facing, size, alpha, duration, growth, type); + s_unk_ADFB58.LinkToTail(ripple); +} diff --git a/WoW/Source/WorldClient/WaterRipple.h b/WoW/Source/WorldClient/WaterRipple.h index 8114729..2ec33c2 100644 --- a/WoW/Source/WorldClient/WaterRipple.h +++ b/WoW/Source/WorldClient/WaterRipple.h @@ -22,15 +22,17 @@ class CWaterRipple { /* 002C */ int32_t m_type; /* 0030 */ TSLink m_link; /* 0038 */ TSLink m_bucketLink; - /* 0040 */ TSFixedArray m_verts; - /* 004C */ uint32_t unk_004C; + /* 0040 */ TSGrowableArray m_verts; CWaterRipple(); ~CWaterRipple(); + + void InitRipple(const C3Vector& pos, float rotation, float size, float alpha, float duration, float growth, int32_t type); }; class WaterRipple { public: + static void Create(const C3Vector& pos, float facing, float size, float alpha, float duration, float growth, int32_t type, int32_t player); static uint32_t s_nextPlayerRipple; static uint32_t s_nextUnitRipple; static CGxShader* s_psWaterRipples; diff --git a/WoW/Source/WorldClient/World.cpp b/WoW/Source/WorldClient/World.cpp index 445ed7f..6eaee58 100644 --- a/WoW/Source/WorldClient/World.cpp +++ b/WoW/Source/WorldClient/World.cpp @@ -98,6 +98,7 @@ #include #include #include "WoW/Source/Object/ObjectClient/Object_C.h" +#include "WoW/Source/Game/GameClient/ProjectTex.h" // STATIC: 0x00ADEE48 static const char* s_zonePaths[11] = { @@ -818,6 +819,32 @@ int32_t World::ObjectIsLoaded(CMapBaseObj* object) { return model->IsLoaded(0, 0); } +// VERIFY: d8d20c5a auto +// OFFSET: 0x0077F340 +bool World::GetTris(const CAaBox& box, World::TriData* triData, uint32_t flags) { + return CMap::QueryTris(box, triData, flags); +} + +// VERIFY: 457f7c03 auto +// OFFSET: 0x0077F350 +uint32_t World::GetIntersectingDoodadModels(CM2Model** models, uint32_t maxModels, const CAaBox& box, uint32_t flags) { + return CMap::QueryIntersectingModels(models, maxModels, box, flags); +} + +// VERIFY: fbdca5c7 auto +// OFFSET: 0x0077F500 +void World::ProjectTextureCallback(const CAaBox& box, const CImVector& color, int32_t index, void* param, int32_t flags) { + if (flags || (CWorld::enables2 & 0x4)) { + ProjectTex2dDrawShaderEffect(box, color, 0x200122, index ? 2 : 0, 0.40000001f); + } +} + +// VERIFY: aa9498a7 auto +// OFFSET: 0x00780190 +int32_t World::ObjectIsWMO(CMapBaseObj* object) { + return object->m_type & 0x8; +} + // VERIFY: b8f47c0c auto // OFFSET: 0x007801C0 void World::ObjectSetShadow(CMapEntity* entity, uint32_t shadow, uint32_t mask) { @@ -4780,3 +4807,211 @@ void World::UpdateObjectFadeouts() { fadeout = next; } } + +// VERIFY: 6429c545 auto +// OFFSET: 0x0077FE00 +void World::ObjectSetMoveable(CMapEntity* entity, int32_t moveable) { + if (moveable) { + entity->m_flags = static_cast(entity->m_flags | 0x1000); + } else { + entity->m_flags = static_cast(entity->m_flags & ~0x1000); + } +} + +// VERIFY: 380eef33 manual +// OFFSET: 0x007823D0 +static int32_t ObjectFadeoutCallback(void* param, uint32_t flags, uint64_t a3, uintptr_t a4) { + CMapEntity* entity = static_cast(param); + + if (!entity) { + return 0; + } + + if (flags & 0x1) { + entity->m_model->SetAnimating(1); + CM2Model* model = entity->m_model; + + if (model->m_attachParent) { + model->m_fFlags |= 0x80; + } else { + model->m_fFlags |= 0x8; + } + + if (model->m_attachParent) { + model->m_fFlags |= 0x20000; + } else { + model->m_fFlags |= 0x10000; + } + + return 1; + } + + CM2Model* model = entity->m_model; + + if (model->m_attachParent) { + model->m_fFlags &= ~0x80; + } else { + model->m_fFlags &= ~0x8; + } + + if (model->m_attachParent) { + model->m_fFlags &= ~0x20000; + } else { + model->m_fFlags &= ~0x10000; + } + + entity->m_model->SetAnimating(0); + model = entity->m_model; + + if (model->m_attachParent) { + model->m_fFlags &= ~0x20000; + } else { + model->m_fFlags &= ~0x10000; + } + + return 1; +} + +// VERIFY: b75aa230 manual +// OFFSET: 0x00783630 +void CGObject_C::PrepareToFadeInt(CMapEntity* entity, float alpha, uint64_t transportGuid) { + if (!entity) { + return; + } + + if (!entity->m_model || !entity->m_model->IsDrawable(0, 0) || alpha < 0.0099999998f || (entity->unk_007C & 0x4)) { + World::ObjectDestroy(entity); + return; + } + + SWModelFadeout* fadeout = s_fadeoutDataPool.Head(); + + if (!fadeout) { + fadeout = s_fadeoutDataPool.NewNode(0, 0, 0); + } + + fadeout->m_entity = entity; + fadeout->m_startTime = OsGetAsyncTimeMs(); + fadeout->m_alpha = alpha; + + if (transportGuid) { + CGObject_C* transport = ClntObjMgrObjectPtr(WOWGUID{ transportGuid }, TYPEMASK_GAMEOBJECT, __FILE__, __LINE__); + + if (transport) { + fadeout->m_transportGuid.m_guid = transportGuid; + C44Matrix world = entity->m_model->m_worldTransform; + fadeout->m_localTransform = world * transport->GetMatrix().AffineInverse(); + } else { + fadeout->m_transportGuid = WOWGUID(); + } + } else { + fadeout->m_transportGuid = WOWGUID(); + } + + s_fadeoutList.LinkToTail(fadeout); + entity->m_func = ObjectFadeoutCallback; + entity->m_funcParam = entity; +} + +// VERIFY: 9ca78c2b auto +// OFFSET: 0x0077F040 +void World::NewFootprint(int32_t textureId, const float* size, const C3Vector* position, float facing, int32_t left, int32_t terrainType, int32_t activePlayer) { + CMap::NewFootprint(textureId, size, position, facing, left, terrainType, activePlayer); +} + +// VERIFY: 04260407 manual +// OFFSET: 0x0077FBF0 +int32_t World::QueryOutdoors(CMapEntity* entity) { + if (!entity) { + return 1; + } + + CMapObjDef* mapObjDef; + CMapObj* mapObj; + CMapObjDefGroup* mapObjDefGroup; + CMapObjGroup* mapObjGroup = nullptr; + + if (entity->GetMapObjAndGroup(&mapObjDef, &mapObj, &mapObjDefGroup, &mapObjGroup, 0)) { + int32_t outdoors = (mapObjGroup->m_flags >> 3) & 1; + WMOAreaTableRec* rec = GetWMOAreaRec(mapObj->m_header->m_wmoID, mapObjDef->m_nameSet, mapObjGroup->m_wmoGroupId); + + if (!rec) { + return outdoors; + } + + if (rec->m_flags & 0x4) { + return 1; + } + + return (rec->m_flags & 0x2) ? 0 : outdoors; + } + + int32_t areaId = CMap::QueryAreaIdTerrain(&entity->m_position); + AreaTableRec* area = g_areaTableDB.GetRecord(areaId); + + if (!area || (area->m_flags & 0x4000000)) { + return 1; + } + + return (area->m_flags & 0x2000000) ? 0 : 1; +} + +// VERIFY: 4fb148c8 auto +// OFFSET: 0x00783500 +CMapBaseObj* CWorld::ObjectCreate(const char* name, const C3Vector& position, float facing, int32_t waitLoad, int32_t snap, uint64_t guid, uint32_t doodadSetCount, const int16_t* doodadSets, float* radius, uint32_t id) { + const char* extension = SStrChrR(name, '.'); + + if (extension && !SStrCmpI(extension, ".wmo", STORM_MAX_STR)) { + CMapObjDef* mapObjDef = CMap::CreateMapObjDef(name, &position, facing, waitLoad, doodadSetCount, doodadSets, radius, id); + mapObjDef->m_objectGuid.m_guid = guid; + CMapBaseObjLink* link = CMap::AllocBaseObjLink(mapObjDef); + link->m_ref = nullptr; + CMap::mapObjDefLinkList.LinkToTail(link); + + if (snap) { + CMap::SnapBaseObjToSubChunk(mapObjDef, &position, facing); + CMapObjDef::UpdatePos(mapObjDef, &position, facing, 0.0f, 0.0f); + } + + mapObjDef->m_refCount++; + + return mapObjDef; + } + + CMapDoodadDef* doodadDef = CMap::CreateDoodadDef(name, &position, facing, waitLoad); + doodadDef->unk_007C |= 0x2010; + doodadDef->unk_00B8.m_guid = guid; + + if (snap) { + CMap::SnapBaseObjToSubChunk(doodadDef, &position, facing); + CMap::UpdateDoodadDef(doodadDef, &position, facing); + } + + doodadDef->m_refCount++; + + return doodadDef; +} + +// VERIFY: 1612d04a auto +// OFFSET: 0x0077FF10 +void World::ObjectSetSequenceFinishedCallback(CMapEntity* entity, void (*callback)(CM2Model* model, uint32_t boneId, uint32_t sequenceId, int32_t interrupted, uint32_t time, uint64_t param), uint64_t param, uint16_t doodad) { + CMapBaseObj* object = entity; + + if (object->m_type & 0x8) { + static_cast(object)->SetSequenceFinishedCallback(callback, param, doodad); + } else if ((object->m_type & 0x40) && entity->m_model) { + entity->m_model->SetSequenceCallback(reinterpret_cast(callback), param); + } +} + +// VERIFY: b0e04ce8 auto +// OFFSET: 0x0077FDD0 +void World::ObjectUpdate(CMapEntity* entity, const C44Matrix& matrix) { + CMapBaseObj* object = entity; + + if (object->m_type & 0x8) { + CMapObjDef::UpdateMatrix(reinterpret_cast(object), matrix); + } else if (object->m_type & 0x40) { + CMap::UpdateDoodadDefTransform(reinterpret_cast(object), matrix); + } +} diff --git a/WoW/Source/WorldClient/World.h b/WoW/Source/WorldClient/World.h index ad8892a..82a2ce9 100644 --- a/WoW/Source/WorldClient/World.h +++ b/WoW/Source/WorldClient/World.h @@ -334,6 +334,7 @@ extern WOWGUID s_highlightedObjectGuid; class WMOAreaTableRec; namespace World { + class TriData; class HitTestDebug; struct LiquidQueryResult { @@ -386,6 +387,7 @@ namespace World { void Update(const C3Vector& position); int32_t QueryOutdoors(CMapEntity* entity); int32_t QueryObjectLiquid(CMapEntity* entity, int32_t* liquidType, float* height, int32_t* a4); + void NewFootprint(int32_t textureId, const float* size, const C3Vector* position, float facing, int32_t left, int32_t terrainType, int32_t activePlayer); int32_t QueryGroundType(CMapEntity* entity, int32_t* groundType); int32_t QueryObjectLiquidFlags(CMapEntity* entity, int32_t* flag8, int32_t* flag9); int32_t SceneCamLiquidStatus(float* depth); @@ -446,7 +448,12 @@ float ValidateFarClip(float farClip, int32_t mapID); int32_t GetFlightBoundsLower(const C3Vector& pos, float* height); int32_t Intersect(const C3Vector& start, const C3Vector& end, C3Vector* hit, float* distance, uint32_t flags, HitTestDebug* debug); void ObjectSetModel(CMapEntity* entity, CM2Model* model); + void ObjectSetMoveable(CMapEntity* entity, int32_t moveable); int32_t ObjectIsLoaded(CMapBaseObj* object); + int32_t ObjectIsWMO(CMapBaseObj* object); + bool GetTris(const CAaBox& box, World::TriData* triData, uint32_t flags); + uint32_t GetIntersectingDoodadModels(CM2Model** models, uint32_t maxModels, const CAaBox& box, uint32_t flags); + void ObjectSetSequence(CMapEntity* entity, uint32_t sequence, int32_t a3, int32_t a4); void ObjectSetShadow(CMapEntity* entity, uint32_t shadow, uint32_t mask); void ObjectSetSequenceFinishedCallback(CMapEntity* entity, void (*callback)(CM2Model* model, uint32_t boneId, uint32_t sequenceId, int32_t interrupted, uint32_t time, uint64_t param), uint64_t param, uint16_t doodad); bool ObjectTestConvexVolume(CMapEntity* entity, const C3Vector& point); @@ -504,6 +511,7 @@ class CWorld { static void Destroy(); static void Initialize(); static void LoadMap(const char* mapName, C3Vector* position, int32_t zoneID, int32_t a4); + static CMapBaseObj* ObjectCreate(const char* name, const C3Vector& position, float facing, int32_t waitLoad, int32_t snap, uint64_t guid, uint32_t doodadSetCount, const int16_t* doodadSets, float* radius, uint32_t id); static void Update(C3Vector* camPos, C3Vector* camTarget, C3Vector* position); }; diff --git a/WoW/Source/WorldClient/shadow.cpp b/WoW/Source/WorldClient/shadow.cpp index 6abdeb4..046ee7d 100644 --- a/WoW/Source/WorldClient/shadow.cpp +++ b/WoW/Source/WorldClient/shadow.cpp @@ -13,6 +13,16 @@ #include "Engine/Source/Tempest/CAaBox.h" #include "WoW/Source/WorldClient/World.h" #include "WoW/Source/WorldClient/Map.h" +#include "WoW/Source/Game/GameClient/ProjectTex.h" +#include "WoW/Source/WorldClient/MapObjGroup.h" +#include "WoW/Source/WorldClient/MapChunk.h" +#include "WoW/Source/Ui/WorldFrame.h" +#include "Engine/Source/Gx/CGxBuf.h" +#include "Engine/Source/Gx/CGxVertexPC.h" +#include "Engine/Source/Gx/CGxDevice/CGxDevice.h" +#include "Engine/Source/ShaderEffect/ShaderEffect.h" +#include "Engine/Source/Tempest/C4Vector.h" +#include "Engine/Source/Tempest/C44Matrix.h" // STATIC: 0x00AF3E08 int32_t s_shadowLOD = 1; @@ -23,6 +33,30 @@ static uint32_t s_shadowTexelCount = 64 * 8; // STATIC: 0x00AF3E24 static CImVector s_shadowTexels[64 * 8]; +// STATIC: 0x00AF3E0C +static int32_t s_queryFrame = -1; + +// STATIC: 0x00AF4644 +static C3Vector s_projectNormal(0.0f, 0.0f, 1.0f); + +// STATIC: 0x00D38010 +static int32_t s_queryDoodads; + +// STATIC: 0x00D38014 +static CM2Model* s_doodadModelBuffer[10]; + +// STATIC: 0x00D38050 +static uint32_t s_queryTriFlags; + +// STATIC: 0x00D38054 +static uint32_t s_doodadModelCount; + +// STATIC: 0x00D38058 +static CAaBox s_queryBox; + +// STATIC: 0x00D38070 +static World::TriData s_queryTriData; + // STATIC: 0x00D3803C static CTexture* s_shadowModTexture; @@ -213,3 +247,263 @@ void CWorldScene::RequestModelStreaming(CM2Model* model, const CAaBox* box) { CGxTex* ProjectTex2dGetModFadeTex() { return TextureGetGxTex(s_shadowModTexture, 1, nullptr); } + +// VERIFY: 04f96856 manual +// OFFSET: 0x007E2FD0 +static void ProjectTexBuildVertexBuffer(World::TriData::Batch* triBatch, CGxBatch* batch, uint32_t flags) { + CGxBuf* buf = g_theGxDevicePtr->BufStream(GxPoolTarget_Vertex, sizeof(CGxVertexPN), triBatch->m_indexCount); + CGxVertexPN* vertex = reinterpret_cast(g_theGxDevicePtr->BufLock(buf)); + + if (triBatch->m_heightList) { + for (uint16_t i = 0; i < triBatch->m_indexCount; i++) { + uint16_t index = triBatch->m_indices[i]; + vertex->m_position = triBatch->m_vertexList[index]; + vertex->m_position.z = triBatch->m_heightList[index]; + vertex->m_normal = s_projectNormal; + vertex++; + } + } else { + batch->m_count = 0; + + if (flags & 0x4) { + for (uint32_t i = 0; i < triBatch->m_indexCount; i += 3) { + const C3Vector& v0 = triBatch->m_vertexList[triBatch->m_indices[i]]; + const C3Vector& v1 = triBatch->m_vertexList[triBatch->m_indices[i + 1]]; + const C3Vector& v2 = triBatch->m_vertexList[triBatch->m_indices[i + 2]]; + vertex[0].m_position = v0; + vertex[0].m_normal = s_projectNormal; + vertex[1].m_position = v1; + vertex[1].m_normal = s_projectNormal; + vertex[2].m_position = v2; + vertex[2].m_normal = s_projectNormal; + batch->m_count += 3; + vertex += 3; + } + } else { + for (uint16_t i = 0; i < triBatch->m_indexCount; i += 3) { + const C3Vector& v0 = triBatch->m_vertexList[triBatch->m_indices[i]]; + const C3Vector& v1 = triBatch->m_vertexList[triBatch->m_indices[i + 1]]; + const C3Vector& v2 = triBatch->m_vertexList[triBatch->m_indices[i + 2]]; + + if ((v2.y - v0.y) * (v1.x - v0.x) - (v1.y - v0.y) * (v2.x - v0.x) >= 0.0f) { + vertex[0].m_position = v0; + vertex[0].m_normal = s_projectNormal; + vertex[1].m_position = v1; + vertex[1].m_normal = s_projectNormal; + vertex[2].m_position = v2; + vertex[2].m_normal = s_projectNormal; + vertex += 3; + batch->m_count += 3; + } + } + } + } + + g_theGxDevicePtr->BufUnlock(buf, 0); + buf->unk_001C = 1; + GxPrimVertexPtr(buf, GxVBF_PN); +} + +// VERIFY: 2dba67bb manual +// OFFSET: 0x007E32F0 +static void ProjectTexBuildVertexBufferVariant(World::TriData::Batch* triBatch, CImVector color, CGxBatch* batch, uint32_t flags) { + CGxBuf* buf = g_theGxDevicePtr->BufStream(GxPoolTarget_Vertex, sizeof(CGxVertexPC), triBatch->m_indexCount); + CGxVertexPC* vertex = reinterpret_cast(g_theGxDevicePtr->BufLock(buf)); + + if (triBatch->m_heightList) { + for (uint32_t i = 0; i < triBatch->m_indexCount; i++) { + uint16_t index = triBatch->m_indices[i]; + vertex->p = triBatch->m_vertexList[index]; + vertex->p.z = triBatch->m_heightList[index]; + vertex->c = color; + vertex++; + } + } else { + batch->m_count = 0; + + if (flags & 0x4) { + for (uint32_t i = 0; i < triBatch->m_indexCount; i += 3) { + const C3Vector& v0 = triBatch->m_vertexList[triBatch->m_indices[i]]; + const C3Vector& v1 = triBatch->m_vertexList[triBatch->m_indices[i + 1]]; + const C3Vector& v2 = triBatch->m_vertexList[triBatch->m_indices[i + 2]]; + vertex[0].p = v0; + vertex[0].c = color; + vertex[1].p = v1; + vertex[1].c = color; + vertex[2].p = v2; + vertex[2].c = color; + batch->m_count += 3; + vertex += 3; + } + } else { + for (uint16_t i = 0; i < triBatch->m_indexCount; i += 3) { + const C3Vector& v0 = triBatch->m_vertexList[triBatch->m_indices[i]]; + const C3Vector& v1 = triBatch->m_vertexList[triBatch->m_indices[i + 1]]; + const C3Vector& v2 = triBatch->m_vertexList[triBatch->m_indices[i + 2]]; + + if ((v2.y - v0.y) * (v1.x - v0.x) - (v1.y - v0.y) * (v2.x - v0.x) >= 0.0f) { + vertex[0].p = v0; + vertex[0].c = color; + vertex[1].p = v1; + vertex[1].c = color; + vertex[2].p = v2; + vertex[2].c = color; + vertex += 3; + batch->m_count += 3; + } + } + } + } + + g_theGxDevicePtr->BufUnlock(buf, 0); + buf->unk_001C = 1; + GxPrimVertexPtr(buf, GxVBF_PC); +} + +// VERIFY: 2df38cbe auto +// OFFSET: 0x007E3580 +static void ProjectTexRenderIndices(World::TriData::Batch* triBatch) { + CGxBuf* buf = g_theGxDevicePtr->BufStream(GxPoolTarget_Index, sizeof(uint16_t), triBatch->m_indexCount); + uint16_t* indices = reinterpret_cast(g_theGxDevicePtr->BufLock(buf)); + + for (uint32_t i = 0; i < triBatch->m_indexCount; i++) { + indices[i] = static_cast(i); + } + + g_theGxDevicePtr->BufUnlock(buf, 0); + buf->unk_001C = 1; + g_theGxDevicePtr->PrimIndexPtr(buf); +} + +// VERIFY: 3c679037 auto +// OFFSET: 0x007E35F0 +static int32_t ProjectTexRenderGetQuery2d(const CAaBox& box, uint32_t flags, uint32_t triFlags, int32_t* doodads, int32_t* tris) { + *doodads = flags & 0x1; + s_doodadModelCount = 0; + s_queryTriFlags = 0; + s_queryDoodads = 0; + *tris = triFlags != 0; + s_queryBox = box; + s_queryFrame = CWorld::frameCnt; + + if (*doodads) { + s_queryDoodads = 1; + s_doodadModelCount = World::GetIntersectingDoodadModels(s_doodadModelBuffer, 10, box, 0x2000000); + } + + if (*tris) { + s_queryTriFlags = triFlags; + World::TriData::statusFlags = 0; + World::TriData::nBatches = 0; + World::TriData::faceIndexCursor = 0; + World::TriData::indexCursor = 0; + World::TriData::unk_CB7538 = 0; + World::GetTris(box, &s_queryTriData, triFlags); + } + + return s_doodadModelCount || World::TriData::nBatches; +} + +// VERIFY: f32d24b7 manual +// OFFSET: 0x007E3AA0 +void ProjectTex2dDrawShaderEffect(const CAaBox& box, const CImVector& color, uint32_t triFlags, uint32_t flags, float polygonOffset) { + int32_t doodads; + int32_t tris; + + if (!ProjectTexRenderGetQuery2d(box, flags, triFlags, &doodads, &tris)) { + return; + } + + CGxAppRenderState* states = g_theGxDevicePtr->m_appRenderStates.m_data; + + if (states[GxRs_BlendingMode].m_value.m_data.i[0] == GxBlend_Mod) { + g_theGxDevicePtr->RsSet(GxRs_Texture1, TextureGetGxTex(s_shadowModTexture, 1, nullptr)); + } else if (!states[GxRs_Texture1].m_value.m_data.i[0]) { + g_theGxDevicePtr->RsSet(GxRs_Texture1, TextureGetGxTex(s_shadowAddTexture, 1, nullptr)); + } + + float savedOffset = 0.0f; + + if (polygonOffset != 0.0f) { + savedOffset = g_theGxDevicePtr->m_appRenderStates.m_data[GxRs_PolygonOffset].m_value.m_data.f[0]; + GxRsSet(GxRs_PolygonOffset, (polygonOffset + polygonOffset) * 3.0518044e-05f); + } + + CImVector packed = color; + + if (flags & 0x2) { + CShaderEffect::SetDiffuse(C4Vector(color)); + } else { + GxFormatColor(packed); + } + + C3Vector cameraPos(0.0f, 0.0f, 0.0f); + CGWorldFrame::GetCameraPosition(&cameraPos); + C44Matrix view; + view.a0 = 1.0f; + view.a1 = 0.0f; + view.a2 = 0.0f; + view.a3 = 0.0f; + view.b0 = 0.0f; + view.b1 = 1.0f; + view.b2 = 0.0f; + view.b3 = 0.0f; + view.c0 = 0.0f; + view.c1 = 0.0f; + view.c2 = 1.0f; + view.c3 = 0.0f; + view.d0 = -cameraPos.x; + view.d1 = -cameraPos.y; + view.d2 = -cameraPos.z; + view.d3 = 1.0f; + g_theGxDevicePtr->XformPush(GxXform_World); + + if (tris) { + for (uint32_t i = 0; i < World::TriData::nBatches; i++) { + World::TriData::Batch* triBatch = &World::TriData::batches[i]; + + if (3 * triBatch->m_indexCount > 0x10000 || !triBatch->m_matrix || !triBatch->m_vertexList || !triBatch->m_indices) { + continue; + } + + GxXformSet(GxXform_World, *triBatch->m_matrix * view); + CGxBatch batch; + batch.m_primType = GxPrim_Triangles; + batch.m_start = 0; + batch.m_count = triBatch->m_indexCount; + batch.m_minIndex = 0; + batch.m_maxIndex = triBatch->m_indexCount - 1; + + if (flags & 0x2) { + ProjectTexBuildVertexBuffer(triBatch, &batch, flags); + } else { + ProjectTexBuildVertexBufferVariant(triBatch, packed, &batch, flags); + } + + ProjectTexRenderIndices(triBatch); + CShaderEffect::SetDefaultShaders(0); + CShaderEffect::UpdateWorldViewMatrix(); + + if (batch.m_count) { + GxDraw(&batch, 1); + } + } + } + + if (doodads) { + for (uint32_t i = 0; i < s_doodadModelCount; i++) { + CM2Model* model = s_doodadModelBuffer[i]; + C44Matrix world = model->m_worldTransform; + GxXformSet(GxXform_World, world * view); + CShaderEffect::UpdateWorldViewMatrix(); + CShaderEffect::SetDiffuse(C4Vector(color)); + model->RenderModelBatchesForProjectedTexture(); + } + } + + GxXformPop(GxXform_World); + + if (polygonOffset != 0.0f) { + GxRsSet(GxRs_PolygonOffset, savedOffset); + } +} diff --git a/WoW/Source/WowSvcs/WowSvcsClient/AccountData.cpp b/WoW/Source/WowSvcs/WowSvcsClient/AccountData.cpp index c373d5a..e5013d8 100644 --- a/WoW/Source/WowSvcs/WowSvcsClient/AccountData.cpp +++ b/WoW/Source/WowSvcs/WowSvcsClient/AccountData.cpp @@ -9,6 +9,8 @@ #include "WoW/Source/Glue/CGlueMgr.h" #include "WoW/Source/WowSvcs/WowSvcsClient/ClientServices.h" #include "ThirdParty/zlib/zlib.h" +#include "WoW/Source/Client.h" +#include "Engine/Source/Event/Event.h" // STATIC: 0x00AD94E0 static AccountDataInfo s_accountData[] = { @@ -312,7 +314,50 @@ void DownloadAccountData(int32_t type) { s_accountData[type].m_downloading = true; } -// VERIFY: ffb25893 manual +// VERIFY: e1dd25e9 manual +// OFFSET: 0x006B9340 +static int32_t SaveTimerHandler(const void* data, void* param) { + int32_t type = static_cast(reinterpret_cast(param)); + AccountDataInfo& info = s_accountData[type]; + uint8_t digest[16]; + MD5AccountFile(info.m_cacheFile, digest, info.m_global); + + if (!memcmp(digest, info.m_md5, sizeof(digest))) { + info.m_changed = false; + info.m_time = info.m_serverTime; + SaveCachedChecksums(info.m_global); + } else { + UploadAccountData(type); + } + + info.unk_0020 = 0; + return 1; +} + +// VERIFY: e2437ae6 auto +// OFFSET: 0x006B9440 +static void ScheduleAccountDataSave(int32_t type) { + AccountDataInfo& info = s_accountData[type]; + info.m_changed = true; + + if (!s_cvSynchronizeSettings->m_intValue) { + return; + } + + CVar* cvar = CVar::Lookup(info.m_cvarName); + + if ((cvar && !cvar->m_intValue) || info.m_localOnly) { + return; + } + + if (info.unk_0020) { + ClientKillTimer(info.unk_0020, SaveTimerHandler, "SaveTimerHandler"); + info.unk_0020 = 0; + } + + info.unk_0020 = EventSetTimer(30000, SaveTimerHandler, reinterpret_cast(static_cast(type))); +} + // OFFSET: 0x006B94C0 static int32_t Packet_SMSG_ACCOUNT_DATA_TIMES(void* param, NETMESSAGE msgId, uint32_t time, CDataStore* msg) { uint32_t serverTime = 0; @@ -537,3 +582,38 @@ void AccountDataInitialize(bool global) { s_accountData[1].m_changed = true; } } + +// VERIFY: 8182067a auto +// OFFSET: 0x006B9B90 +void AccountDataFlush() { + for (int32_t i = 0; i < static_cast(sizeof(s_accountData) / sizeof(s_accountData[0])); i++) { + if (s_accountData[i].unk_0020) { + ClientKillTimer(s_accountData[i].unk_0020, SaveTimerHandler, "SaveTimerHandler"); + SaveTimerHandler(nullptr, reinterpret_cast(static_cast(i))); + } + } +} + +// VERIFY: aad4b10d auto +// OFFSET: 0x006B9BE0 +void SaveAccountData(int32_t type, ACCOUNTDATALOADFUNC func, void* param) { + AccountDataInfo& info = s_accountData[type]; + + if (info.m_downloading) { + return; + } + + HOSFILE localFile = OpenAccountFile(info.m_global, info.m_localFile, true); + HOSFILE cacheFile = OpenAccountFile(info.m_global, info.m_cacheFile, true); + func(localFile, cacheFile, param); + + if (localFile != OS_INVALID_FILE) { + OsCloseFile(localFile); + } + + if (cacheFile != OS_INVALID_FILE) { + OsCloseFile(cacheFile); + } + + ScheduleAccountDataSave(type); +} diff --git a/WoW/Source/WowSvcs/WowSvcsClient/AccountData.h b/WoW/Source/WowSvcs/WowSvcsClient/AccountData.h index d2b363c..7642f65 100644 --- a/WoW/Source/WowSvcs/WowSvcsClient/AccountData.h +++ b/WoW/Source/WowSvcs/WowSvcsClient/AccountData.h @@ -36,6 +36,7 @@ void AccountDataShutdownBasicSystem(); void DownloadAccountData(int32_t type); void LoadAccountData(int32_t type, ACCOUNTDATALOADFUNC func, void* param); void SaveAccountData(int32_t type, ACCOUNTDATALOADFUNC func, void* param); +void AccountDataFlush(); int32_t Packet_SMSG_CHECK_FOR_BOTS(void* param, NETMESSAGE msgId, uint32_t time, CDataStore* msg); void UploadAccountData(int32_t type); diff --git a/WoW/Source/WowSvcs/WowSvcsClient/ClientServices.cpp b/WoW/Source/WowSvcs/WowSvcsClient/ClientServices.cpp index 9191c2b..b70b59f 100644 --- a/WoW/Source/WowSvcs/WowSvcsClient/ClientServices.cpp +++ b/WoW/Source/WowSvcs/WowSvcsClient/ClientServices.cpp @@ -20,6 +20,7 @@ #include "WoW/Source/WowServices/LoginResponse.h" #include "WoW/Source/Ui/Types.h" #include "WoW/Source/WowSvcs/WowSvcsClient/AccountData.h" +#include "WoW/Source/Ui/GameUI.h" // STATIC: 0x00AD91F0 static const char* s_errorTokens[] = { @@ -1325,3 +1326,14 @@ void ClientServices::LoginEnterToken(const char* token) { ClientServices::s_loginObj->EnterToken(token); } + +// VERIFY: e448981b manual +// OFFSET: 0x006B08B0 +void ClientConnection::HandleLogoutResponse(int32_t result, int32_t instant) { + if (result) { + CGGameUI::DisplayError(ERR_LOGOUT_FAILED); + this->m_loggingOut = 0; + } else if (!instant) { + FrameScript_SignalEvent(this->m_quitAfterLogout ? SCRIPT_EVENT_PLAYER_QUITING : SCRIPT_EVENT_PLAYER_CAMPING, nullptr); + } +} diff --git a/WoW/Source/WowSvcs/WowSvcsClient/FriendList.cpp b/WoW/Source/WowSvcs/WowSvcsClient/FriendList.cpp index e227bf2..2d0ef1c 100644 --- a/WoW/Source/WowSvcs/WowSvcsClient/FriendList.cpp +++ b/WoW/Source/WowSvcs/WowSvcsClient/FriendList.cpp @@ -294,3 +294,103 @@ int32_t Packet_SMSG_CONTACT_LIST(void* param, NETMESSAGE msgId, uint32_t time, C FriendList::s_friendList->ReadPacket(msg); return 1; } + +// VERIFY: 40fabbbe auto +// OFFSET: 0x006B3630 +uint32_t FriendList::GetNumIgnores() { + uint32_t count = 0; + + while (count < 50 && this->m_ignores[count].m_guid) { + count++; + } + + return count; +} + +// VERIFY: dfd1e135 manual +// OFFSET: 0x006B3960 +int32_t QSortFriends(const void* a, const void* b) { + if (!a || !b) { + SErrDisplayAppFatalMessage("", "", 0); + } + + const FriendInfo* friendA = static_cast(a); + const FriendInfo* friendB = static_cast(b); + + if (!friendA->m_guid && !friendB->m_guid) { + return 0; + } + + if (!friendA->m_guid) { + return 1; + } + + if (!friendB->m_guid) { + return -1; + } + + if (friendA->m_connected != friendB->m_connected) { + return friendA->m_connected ? -1 : 1; + } + + if (friendA->m_name && friendB->m_name) { + return SStrSortUTF8I(friendA->m_name, friendB->m_name, 0x7FFFFFFF); + } + + if (!friendA->m_name && !friendB->m_name) { + return 0; + } + + return friendA->m_name ? -1 : 1; +} + +// VERIFY: 5c7fff6f manual +// OFFSET: 0x006B3A60 +int32_t QSortIgnore(const void* a, const void* b) { + if (!a || !b) { + SErrDisplayAppFatalMessage("", "", 0); + } + + WOWGUID guidA = static_cast(a)->m_guid; + WOWGUID guidB = static_cast(b)->m_guid; + + if (!guidA) { + return guidB ? 1 : 0; + } + + if (!guidB) { + return -1; + } + + NameCache* nameA = g_nameDBCache.GetRecord(guidA.m_guid, WOWGUID(), nullptr, nullptr, false); + NameCache* nameB = g_nameDBCache.GetRecord(guidB.m_guid, WOWGUID(), nullptr, nullptr, false); + + if (!nameA) { + return nameB ? 1 : 0; + } + + if (!nameB) { + return -1; + } + + char fullNameA[305]; + char fullNameB[305]; + return SStrCmp(nameA->FullName(fullNameA, sizeof(fullNameA)), nameB->FullName(fullNameB, sizeof(fullNameB)), 0x7FFFFFFF); +} + +// VERIFY: 851ea1b0 manual +// OFFSET: 0x006B51B0 +void FriendList::Destroy() { + if (!FriendList::s_friendList) { + return; + } + + ClientServices::ClearMessageHandler(SMSG_WHO); + ClientServices::ClearMessageHandler(SMSG_WHO_IS); + ClientServices::ClearMessageHandler(SMSG_RWHOIS); + ClientServices::ClearMessageHandler(SMSG_CONTACT_LIST); + ClientServices::ClearMessageHandler(SMSG_FRIEND_STATUS); + ConsoleCommandUnregister("whois"); + delete FriendList::s_friendList; + FriendList::s_friendList = nullptr; +} diff --git a/WoW/Source/WowSvcs/WowSvcsClient/FriendList.h b/WoW/Source/WowSvcs/WowSvcsClient/FriendList.h index 142abda..a45b633 100644 --- a/WoW/Source/WowSvcs/WowSvcsClient/FriendList.h +++ b/WoW/Source/WowSvcs/WowSvcsClient/FriendList.h @@ -65,6 +65,7 @@ class FriendList { FriendInfo* GetFriend(WOWGUID guid); FriendInfo* ClearRecruitAFriend(WOWGUID guid); uint32_t GetNumFriends(); + uint32_t GetNumIgnores(); static void Destroy(); static void Initialize(); @@ -95,7 +96,6 @@ int32_t Script_AddOrRemoveFriend(lua_State* L); int32_t Script_AddFriend(lua_State* L); int32_t Script_RemoveFriend(lua_State* L); int32_t Script_SetFriendNotes(lua_State* L); -int32_t Script_GetNumIgnores(lua_State* L); int32_t Script_GetIgnoreName(lua_State* L); int32_t Script_SetSelectedIgnore(lua_State* L); int32_t Script_GetSelectedIgnore(lua_State* L); diff --git a/WoW/Source/WowSvcs/WowSvcsClient/FriendList_Scripts.cpp b/WoW/Source/WowSvcs/WowSvcsClient/FriendList_Scripts.cpp index 9f9ea77..799dca1 100644 --- a/WoW/Source/WowSvcs/WowSvcsClient/FriendList_Scripts.cpp +++ b/WoW/Source/WowSvcs/WowSvcsClient/FriendList_Scripts.cpp @@ -61,6 +61,18 @@ static int32_t Script_GetNumFriends(lua_State* L) { return 2; } +// VERIFY: 1ace5852 manual +// OFFSET: 0x006B4560 +static int32_t Script_GetNumIgnores(lua_State* L) { + if (FriendList::s_friendList) { + lua_pushnumber(L, FriendList::s_friendList->GetNumIgnores()); + } else { + lua_pushnumber(L, 0.0); + } + + return 1; +} + // STATIC: 0x00AD93D8 static FrameScript_Method s_ScriptFunctions[] = { { "GetNumFriends", &Script_GetNumFriends },