mirror of
https://github.com/thunderbrewhq/thunderbrew
synced 2025-04-09 23:06:47 +03:00
feat(ui): use class and area IDs for Character Selection
This commit is contained in:
parent
3689ef9b41
commit
152cb7dea4
@ -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
|
||||
|
@ -75,16 +75,14 @@ int32_t Script_GetCharacterInfo(lua_State* L) {
|
||||
auto raceName = CGUnit_C::GetDisplayRaceNameFromRecord(g_chrRacesDB.GetRecord(character.raceID), character.sexID);
|
||||
lua_pushstring(L, raceName ? raceName : "");
|
||||
|
||||
// TODO: auto className = CGUnit_C::GetDisplayClassNameFromRecord(g_chrClassesDB.GetRecord(character.classID), character.sexID);
|
||||
auto className = "Warrior";
|
||||
auto className = CGUnit_C::GetDisplayClassNameFromRecord(g_chrClassesDB.GetRecord(character.classID), character.sexID);
|
||||
lua_pushstring(L, className ? className : "");
|
||||
|
||||
lua_pushnumber(L, character.experienceLevel);
|
||||
|
||||
// TODO: auto areaRecord = g_areaTableDB.GetRecord(character.zoneID);
|
||||
void* areaRecord = nullptr;
|
||||
auto areaRecord = g_areaTableDB.GetRecord(character.zoneID);
|
||||
if (areaRecord) {
|
||||
// TODO: lua_pushstring(L, areaRecord->name)
|
||||
lua_pushstring(L, areaRecord->m_areaName);
|
||||
} else {
|
||||
lua_pushnil(L);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user