mirror of
https://github.com/thunderbrewhq/thunderbrew
synced 2025-12-12 11:12:29 +00:00
feat(glue): add realm and character handling (#7)
* fix(build): make project compilable * feat(glue): update Character Selection screen to support switching * fix(ui): fix CSimpleFontString::GetHeight() to use proper method * feat(db): add static database classes from whoa-autocode * feat(ui): use class and area IDs for Character Selection * chore(db): update ItemRandomPropertiesRec * feat(glue): update CCharacterSelection methods * chore(db): uncomment DB records * feat(glue): implement character deletion * feat(gx): update supported text tags in GxuDetermineQuotedCode * fix(ui): fix CSimpleFontString to use the FixedColor flag only if the string does not contain color tags * feat(net): implement GrunLogin::LogOff * feat(net): implement NetClient::Disconnect * feat(login): implement trimming of realm name in LoginResponse::HandleRealmData * feat(net): implement proper disconnection from login and realm servers * feat(net): implement PING/PONG messages * feat(net): add NetClient::Destroy method * feat(net): implement ClientServices::GetRealmList (second request of Realm List) * feat(glue): implement CGlueMgr::PollRealmList * feat(glue): implement CGlueMgr::PollCreateCharacter * chore(glue): add skeleton of CCharacterComponent class * fix(build): fix build using latest features * fix(glue): kill gotos in CGlueMgr::NetDisconnectHandler * fix(build): include SDL3 --------- Co-authored-by: superp00t <superp00t@tutanota.com>
This commit is contained in:
parent
50e37d16bc
commit
957a4c7e2f
633 changed files with 1729 additions and 227 deletions
51
src/clientobject/Player_C.cpp
Normal file
51
src/clientobject/Player_C.cpp
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
#include "clientobject/Player_C.hpp"
|
||||
#include "clientobject/Types.hpp"
|
||||
#include "db/Db.hpp"
|
||||
#include <storm/Error.hpp>
|
||||
|
||||
|
||||
const CreatureModelDataRec* Player_C_GetModelName(uint32_t race, uint32_t sex) {
|
||||
STORM_ASSERT(sex < UNITSEX_LAST);
|
||||
|
||||
auto displayId = Player_C_GetDisplayId(race, sex);
|
||||
auto record = g_creatureDisplayInfoDB.GetRecord(displayId);
|
||||
if (!record) {
|
||||
SErrPrepareAppFatal(__FILE__, __LINE__);
|
||||
SErrDisplayAppFatal("Error, unknown displayInfo %d specified for player race %d sex %d!", displayId, race, sex);
|
||||
}
|
||||
|
||||
auto modelData = g_creatureModelDataDB.GetRecord(record->m_modelID);
|
||||
if (!modelData) {
|
||||
SErrPrepareAppFatal(__FILE__, __LINE__);
|
||||
SErrDisplayAppFatal("Error, unknown model record %d specified for player race %d sex %d!", record->m_modelID, race, sex);
|
||||
}
|
||||
|
||||
return modelData;
|
||||
}
|
||||
|
||||
uint32_t Player_C_GetDisplayId(uint32_t race, uint32_t sex) {
|
||||
STORM_ASSERT(sex < UNITSEX_LAST);
|
||||
|
||||
auto record = g_chrRacesDB.GetRecord(race);
|
||||
if (!record) {
|
||||
SErrPrepareAppFatal(__FILE__, __LINE__);
|
||||
SErrDisplayAppFatal("Error, race %d not found in race table!", race);
|
||||
}
|
||||
|
||||
if (sex == UNITSEX_MALE) {
|
||||
return record->m_maleDisplayID;
|
||||
}
|
||||
|
||||
if (sex == UNITSEX_FEMALE) {
|
||||
return record->m_femaleDisplayID;
|
||||
}
|
||||
|
||||
if (sex == UNITSEX_NONE) {
|
||||
SErrPrepareAppFatal(__FILE__, __LINE__);
|
||||
SErrDisplayAppFatal("Error, attempted to look up model for player with sex %d (UNITSEX_NONE), all players have sex! =D", 2);
|
||||
}
|
||||
|
||||
SErrPrepareAppFatal(__FILE__, __LINE__);
|
||||
SErrDisplayAppFatal("Error, unrecognized sex code %d!", sex);
|
||||
return 0;
|
||||
}
|
||||
14
src/clientobject/Player_C.hpp
Normal file
14
src/clientobject/Player_C.hpp
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
#ifndef CLIENTOBJECT_PLAYER_C_HPP
|
||||
#define CLIENTOBJECT_PLAYER_C_HPP
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
|
||||
class CreatureModelDataRec;
|
||||
|
||||
|
||||
const CreatureModelDataRec* Player_C_GetModelName(uint32_t race, uint32_t sex);
|
||||
uint32_t Player_C_GetDisplayId(uint32_t race, uint32_t sex);
|
||||
|
||||
|
||||
#endif // CLIENTOBJECT_PLAYER_C_HPP
|
||||
14
src/clientobject/Types.hpp
Normal file
14
src/clientobject/Types.hpp
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
#ifndef CLIENTOBJECT_TYPES_HPP
|
||||
#define CLIENTOBJECT_TYPES_HPP
|
||||
|
||||
|
||||
enum UNIT_SEX {
|
||||
UNITSEX_MALE = 0x0,
|
||||
UNITSEX_FEMALE = 0x1,
|
||||
UNITSEX_NONE = 0x2,
|
||||
UNITSEX_LAST = 0x3,
|
||||
UNITSEX_BOTH = 0x3,
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
|
@ -1,8 +1,49 @@
|
|||
#include "clientobject/Unit_C.hpp"
|
||||
|
||||
const char* CGUnit_C::GetDisplayRaceNameFromRecord(ChrRacesRec* record, uint8_t sexIn, uint8_t* sexOut) {
|
||||
const char* result;
|
||||
#include "db/Db.hpp"
|
||||
|
||||
|
||||
const char* CGUnit_C::GetDisplayRaceNameFromRecord(ChrRacesRec* record, uint8_t sexIn, uint8_t* sexOut) {
|
||||
if (sexOut) {
|
||||
*sexOut = sexIn;
|
||||
}
|
||||
if (!record) {
|
||||
return nullptr;
|
||||
}
|
||||
if (!sexIn) {
|
||||
if (record->m_nameMale[0]) {
|
||||
return record->m_nameMale;
|
||||
}
|
||||
|
||||
if (record->m_nameFemale[0]) {
|
||||
if (sexOut) {
|
||||
*sexOut = 1;
|
||||
}
|
||||
return record->m_nameFemale;
|
||||
}
|
||||
|
||||
return record->m_name;
|
||||
}
|
||||
|
||||
if (sexIn != 1) {
|
||||
return record->m_name;
|
||||
}
|
||||
|
||||
if (record->m_nameFemale[0]) {
|
||||
return record->m_nameFemale;
|
||||
}
|
||||
|
||||
if (!record->m_nameMale[0]) {
|
||||
return record->m_name;
|
||||
}
|
||||
|
||||
if (sexOut) {
|
||||
*sexOut = 0;
|
||||
}
|
||||
return record->m_nameMale;
|
||||
}
|
||||
|
||||
const char* CGUnit_C::GetDisplayClassNameFromRecord(ChrClassesRec* record, uint8_t sexIn, uint8_t* sexOut) {
|
||||
if (sexOut) {
|
||||
*sexOut = sexIn;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,15 @@
|
|||
#ifndef CLIENTOBJECT_UNIT_C_HPP
|
||||
#define CLIENTOBJECT_UNIT_C_HPP
|
||||
|
||||
#include "db/rec/ChrRacesRec.hpp"
|
||||
#include <cstdint>
|
||||
|
||||
class ChrRacesRec;
|
||||
class ChrClassesRec;
|
||||
|
||||
class CGUnit_C {
|
||||
public:
|
||||
static const char* GetDisplayRaceNameFromRecord(ChrRacesRec* record, uint8_t sexIn, uint8_t* sexOut = nullptr);
|
||||
static const char* GetDisplayClassNameFromRecord(ChrClassesRec* record, uint8_t sexIn, uint8_t* sexOut = nullptr);
|
||||
};
|
||||
|
||||
#endif // CLIENTOBJECT_UNIT_C_HPP
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue