mirror of
https://github.com/brues-code/ClassicAPI.git
synced 2026-11-16 08:00:42 +00:00
feat(quest): completed quests on Turtle-lineage servers
QueryQuestsCompleted, GetQuestsCompleted, C_QuestLog.IsQuestFlaggedCompleted, C_QuestLog.GetAllCompletedQuestIDs and QUEST_QUERY_COMPLETE, on Turtle clients only. The server answers `.queststatuses` with TWQUEST guild addon messages from the player, split at 2000 characters; the shorter last message is the end of the list, so no timers are needed. The DLL sends the request itself on SMSG_LOGIN_VERIFY_WORLD (the earliest request the server answers), after each turn-in, and from QueryQuestsCompleted. It reads every answer at the packet funnel, checks that the sender is the player, replaces the list and fires QUEST_QUERY_COMPLETE. A turned-in quest goes into the list at once; the server's next answer takes repeatable quests out again. The list lives through /reload. Net::OutPacket replaces the two hand-built CDataStore senders (item cache resend, SetPVP). Replaces the closed Lua collector of PR #86.
This commit is contained in:
Vendored
+5
-32
@@ -15,45 +15,18 @@
|
||||
|
||||
#include "Game.h"
|
||||
#include "Offsets.h"
|
||||
#include "net/PacketWriter.h"
|
||||
|
||||
namespace Cache::Query {
|
||||
|
||||
namespace {
|
||||
|
||||
// The engine's stack CDataStore (see Offsets::VTABLE_CDATASTORE).
|
||||
struct DataStore {
|
||||
uintptr_t vtable;
|
||||
void *buffer;
|
||||
uint32_t base;
|
||||
uint32_t alloc;
|
||||
uint32_t size;
|
||||
uint32_t read;
|
||||
};
|
||||
static_assert(sizeof(DataStore) == 0x18, "CDataStore layout");
|
||||
|
||||
using PutU32_t = void(__thiscall *)(DataStore *self, uint32_t value);
|
||||
using PutGuid_t = void(__thiscall *)(DataStore *self, uint32_t lo, uint32_t hi);
|
||||
using Send_t = void(__thiscall *)(DataStore *self);
|
||||
using Free_t = void(__thiscall *)(DataStore *self, void **buffer, uint32_t *base, uint32_t *alloc);
|
||||
|
||||
} // namespace
|
||||
|
||||
// The send of FUN_DBCACHE_ITEMSTATS_GET_RECORD (0x0055BB18..0x0055BB89),
|
||||
// step for step. Every DBCache<T> clone builds the same packet.
|
||||
void Send(void *cache, uint32_t key) {
|
||||
DataStore packet{Offsets::VTABLE_CDATASTORE, nullptr, 0, 0, 0, 0xFFFFFFFF};
|
||||
const auto putU32 = reinterpret_cast<PutU32_t>(Offsets::FUN_DATASTORE_PUT_U32);
|
||||
putU32(&packet, Game::Read<uint32_t>(cache, Offsets::OFF_DBCACHE_QUERY_OPCODE));
|
||||
putU32(&packet, key);
|
||||
Net::OutPacket packet(Game::Read<uint32_t>(cache, Offsets::OFF_DBCACHE_QUERY_OPCODE));
|
||||
packet.PutU32(key);
|
||||
if (Game::Read<uint8_t>(cache, Offsets::OFF_DBCACHE_OWNER_FLAG) != 0)
|
||||
reinterpret_cast<PutGuid_t>(Offsets::FUN_DATASTORE_PUT_GUID)(&packet, 0, 0);
|
||||
packet.read = 0;
|
||||
reinterpret_cast<Send_t>(Offsets::FUN_CLIENT_SERVICES_SEND)(&packet);
|
||||
if (packet.alloc != 0xFFFFFFFF) {
|
||||
const auto release =
|
||||
*reinterpret_cast<const Free_t *>(Offsets::VTABLE_CDATASTORE + sizeof(uintptr_t));
|
||||
release(&packet, &packet.buffer, &packet.base, &packet.alloc);
|
||||
}
|
||||
packet.PutGuid(0);
|
||||
packet.Send();
|
||||
}
|
||||
|
||||
} // namespace Cache::Query
|
||||
|
||||
Reference in New Issue
Block a user