mirror of
https://github.com/thunderbrewhq/thunderbrew
synced 2025-12-12 19:22:30 +00:00
feat(net): add RealmConnection::HandleCharEnum implementation
This commit is contained in:
parent
ba21fb2994
commit
1e8dc7aef9
10 changed files with 171 additions and 10 deletions
|
|
@ -1,6 +1,8 @@
|
|||
#ifndef NET_TYPES_HPP
|
||||
#define NET_TYPES_HPP
|
||||
|
||||
#include <tempest/vector/C3Vector.hpp>
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
enum LOGIN_RESULT {
|
||||
|
|
@ -1252,4 +1254,36 @@ struct REALM_INFO {
|
|||
uint16_t revision;
|
||||
};
|
||||
|
||||
struct INVENTORY_ITEM {
|
||||
uint8_t type;
|
||||
uint32_t displayID;
|
||||
uint32_t auraID;
|
||||
};
|
||||
|
||||
struct CHARACTER_INFO {
|
||||
uint64_t guid;
|
||||
char name[48];
|
||||
uint32_t mapID;
|
||||
uint32_t zoneID;
|
||||
uint32_t guildID;
|
||||
C3Vector position;
|
||||
INVENTORY_ITEM items[23];
|
||||
uint32_t petDisplayInfoID;
|
||||
uint32_t petExperienceLevel;
|
||||
uint32_t petCreatureFamilyID;
|
||||
uint32_t flags;
|
||||
uint32_t customizeFlags;
|
||||
uint8_t raceID;
|
||||
uint8_t classID;
|
||||
uint8_t sexID;
|
||||
uint8_t skinID;
|
||||
uint8_t faceID;
|
||||
uint8_t hairStyleID;
|
||||
uint8_t hairColorID;
|
||||
uint8_t facialHairStyleID;
|
||||
uint8_t experienceLevel;
|
||||
uint8_t firstLogin;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -132,6 +132,15 @@ void ClientConnection::AccountLogin_Queued() {
|
|||
// TODO CGlueMgr::UpdateWaitQueue(this->m_queuePosition);
|
||||
}
|
||||
|
||||
void ClientConnection::GetCharacterList() {
|
||||
this->Initiate(COP_GET_CHARACTERS, 43, nullptr);
|
||||
if (this->m_connected) {
|
||||
this->RequestCharacterEnum();
|
||||
} else {
|
||||
this->Cancel(4);
|
||||
}
|
||||
}
|
||||
|
||||
void ClientConnection::Cancel(int32_t errorCode) {
|
||||
this->Complete(0, errorCode);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ class ClientConnection : public RealmConnection {
|
|||
|
||||
// Virtual member functions
|
||||
virtual int32_t HandleConnect();
|
||||
virtual void Complete(int32_t result, int32_t errorCode);
|
||||
|
||||
// Member functions
|
||||
ClientConnection(RealmResponse* realmResponse)
|
||||
|
|
@ -26,9 +27,9 @@ class ClientConnection : public RealmConnection {
|
|||
void AccountLogin(const char* name, const char* password, int32_t region, int32_t locale);
|
||||
void AccountLogin_Finish(int32_t authResult);
|
||||
void AccountLogin_Queued();
|
||||
void GetCharacterList();
|
||||
void Cancel(int32_t errorCode);
|
||||
void Cleanup();
|
||||
void Complete(int32_t result, int32_t errorCode);
|
||||
void Connect();
|
||||
int32_t Disconnect();
|
||||
void Initiate(WOWCS_OPS op, int32_t errorCode, void (*cleanup)());
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ int32_t RealmConnection::MessageHandler(void* param, NETMESSAGE msgId, uint32_t
|
|||
}
|
||||
|
||||
case SMSG_ENUM_CHARACTERS_RESULT: {
|
||||
// TODO
|
||||
result = connection->HandleCharEnum(msgId, time, msg);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -192,6 +192,98 @@ int32_t RealmConnection::HandleAuthResponse(uint32_t msgId, uint32_t time, CData
|
|||
return 1;
|
||||
}
|
||||
|
||||
int32_t RealmConnection::HandleCharEnum(uint32_t msgId, uint32_t time, CDataStore* msg) {
|
||||
if (this->m_realmResponse) {
|
||||
this->m_realmResponse->GameServerResult(this, "SMSG_CHAR_ENUM", nullptr, nullptr);
|
||||
}
|
||||
|
||||
uint8_t count;
|
||||
msg->Get(count);
|
||||
|
||||
bool overflow = false;
|
||||
if (count > 10) {
|
||||
count = 0;
|
||||
overflow = true;
|
||||
}
|
||||
|
||||
m_characterList.SetCount(count);
|
||||
|
||||
for (uint32_t i = 0; i < count; ++i) {
|
||||
auto& character = m_characterList[i];
|
||||
msg->Get(character.guid);
|
||||
msg->GetString(character.name, 48);
|
||||
msg->Get(character.raceID);
|
||||
msg->Get(character.classID);
|
||||
msg->Get(character.sexID);
|
||||
msg->Get(character.skinID);
|
||||
msg->Get(character.faceID);
|
||||
msg->Get(character.hairStyleID);
|
||||
msg->Get(character.hairColorID);
|
||||
msg->Get(character.facialHairStyleID);
|
||||
msg->Get(character.experienceLevel);
|
||||
msg->Get(character.zoneID);
|
||||
msg->Get(character.mapID);
|
||||
msg->Get(character.position.x);
|
||||
msg->Get(character.position.y);
|
||||
msg->Get(character.position.z);
|
||||
msg->Get(character.guildID);
|
||||
msg->Get(character.flags);
|
||||
msg->Get(character.customizeFlags);
|
||||
msg->Get(character.firstLogin);
|
||||
msg->Get(character.petDisplayInfoID);
|
||||
msg->Get(character.petExperienceLevel);
|
||||
msg->Get(character.petCreatureFamilyID);
|
||||
for (uint32_t j = 0; j < 23; ++j) {
|
||||
msg->Get(character.items[j].displayID);
|
||||
msg->Get(character.items[j].type);
|
||||
msg->Get(character.items[j].auraID);
|
||||
}
|
||||
}
|
||||
|
||||
bool success = false;
|
||||
if (msg->IsRead()) {
|
||||
if (!overflow) {
|
||||
success = true;
|
||||
}
|
||||
} else if (!overflow) {
|
||||
// TODO: Proper implementation
|
||||
uint32_t value;
|
||||
msg->Get(value);
|
||||
msg->Get(value);
|
||||
msg->Get(value);
|
||||
msg->Get(value);
|
||||
msg->Get(value);
|
||||
msg->Get(value);
|
||||
msg->Get(value);
|
||||
msg->Get(value);
|
||||
msg->Get(value);
|
||||
msg->Get(value);
|
||||
if (msg->IsRead()) {
|
||||
success = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!success) {
|
||||
m_characterList.Clear();
|
||||
}
|
||||
|
||||
// TODO: Should be implemented as call of sub_6B2000
|
||||
if (success) {
|
||||
this->Complete(1, 44);
|
||||
} else {
|
||||
this->Complete(1, 45);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void RealmConnection::SetSelectedRealm(uint32_t a2, uint32_t a3, uint32_t a4) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
void RealmConnection::RequestCharacterEnum() {
|
||||
CDataStore msg;
|
||||
msg.Put(static_cast<uint32_t>(CMSG_ENUM_CHARACTERS));
|
||||
msg.Finalize();
|
||||
this->Send(&msg);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ class RealmConnection : public NetClient {
|
|||
|
||||
// Member variables
|
||||
RealmResponse* m_realmResponse;
|
||||
TSFixedArray<CHARACTER_INFO> m_characterList;
|
||||
uint8_t m_authenticated = 0;
|
||||
uint32_t m_queuePosition = 0;
|
||||
uint32_t m_freeCharacterMigration = 0;
|
||||
|
|
@ -34,11 +35,14 @@ class RealmConnection : public NetClient {
|
|||
|
||||
// Virtual member functions
|
||||
virtual int32_t HandleAuthChallenge(AuthenticationChallenge* challenge);
|
||||
virtual void Complete(int32_t result, int32_t errorCode) = 0;
|
||||
|
||||
// Member functions
|
||||
RealmConnection(RealmResponse* realmResponse);
|
||||
int32_t HandleAuthResponse(uint32_t msgId, uint32_t time, CDataStore* msg);
|
||||
int32_t HandleCharEnum(uint32_t msgId, uint32_t time, CDataStore* msg);
|
||||
void SetSelectedRealm(uint32_t a2, uint32_t a3, uint32_t a4);
|
||||
void RequestCharacterEnum();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue