Compare commits

..

4 Commits

Author SHA1 Message Date
fallenoak
04c3dac382
feat(object): handle creature geosets and skins in CGUnit_C::PostInit
Some checks are pending
Push / ${{ matrix.build.system_name }} / ${{ matrix.build.build_type }} / ${{ matrix.build.compiler_name }} (map[build_type:Release cc:cl compiler_name:MSVC cxx:cl os:windows-latest system_name:Windows test_path:WhoaTest]) (push) Waiting to run
Push / ${{ matrix.build.system_name }} / ${{ matrix.build.build_type }} / ${{ matrix.build.compiler_name }} (map[build_type:Release cc:clang compiler_name:Clang cxx:clang++ os:macos-latest system_name:macOS test_path:WhoaTest]) (push) Waiting to run
Push / ${{ matrix.build.system_name }} / ${{ matrix.build.build_type }} / ${{ matrix.build.compiler_name }} (map[build_type:Release cc:gcc compiler_name:GCC cxx:g++ os:ubuntu-latest system_name:Linux test_path:WhoaTest]) (push) Waiting to run
2026-02-13 21:10:02 -06:00
fallenoak
6860d86369
feat(object): add CGUnit_C::RefreshDataPointers 2026-02-13 14:32:55 -06:00
fallenoak
e56bde0dde
feat(db): add UnitBloodLevelsRec 2026-02-13 14:16:07 -06:00
fallenoak
c6a89b5ef8
feat(db): add CreatureSoundDataRec 2026-02-13 13:51:48 -06:00
12 changed files with 383 additions and 6 deletions

View File

@ -121,6 +121,10 @@ bool ComponentCompressCallback(CVar* var, const char* oldValue, const char* valu
return true;
}
void ReplaceParticleColor(CM2Model* model, int32_t particleColorID) {
// TODO
}
int32_t CCharacterComponent::AddHandItem(CM2Model* model, const ItemDisplayInfoRec* displayRec, INVENTORY_SLOTS invSlot, SHEATHE_TYPE sheatheType, bool sheathed, bool shield, bool a7, int32_t visualID) {
if (!model || !displayRec || invSlot > INVSLOT_TABARD) {
return -1;
@ -247,6 +251,26 @@ CCharacterComponent* CCharacterComponent::AllocComponent() {
return component;
}
void CCharacterComponent::ApplyMonsterGeosets(CM2Model* model, const CreatureDisplayInfoRec* displayInfoRec) {
if (!model || !displayInfoRec || !displayInfoRec->m_creatureGeosetData) {
return;
}
for (int32_t group = 100, dataOfs = 0; group < 900; group += 100, dataOfs += 4) {
auto section = (displayInfoRec->m_creatureGeosetData >> dataOfs) & 0xF;
if (section) {
// Hide all sections in group
model->SetGeometryVisible(group, group + 99, false);
// Show matching section
model->SetGeometryVisible(group + section, group + section, true);
}
}
model->OptimizeVisibleGeometry();
}
void CCharacterComponent::ComponentCloseFingers(CM2Model* model, COMP_HAND_SLOT handSlot) {
uint32_t firstBone;
uint32_t lastBone;
@ -789,6 +813,54 @@ void CCharacterComponent::RemoveLinkpt(CM2Model* model, GEOCOMPONENTLINKS link)
}
}
void CCharacterComponent::ReplaceMonsterSkin(CM2Model* model, const CreatureDisplayInfoRec* displayInfoRec, const CreatureModelDataRec* modelDataRec) {
if (!model || !displayInfoRec || !modelDataRec) {
return;
}
CStatus status;
char texturePath[STORM_MAX_PATH];
// Copy model path to use as base path for texture
auto src = modelDataRec->m_modelName;
auto dst = texturePath;
while (*src) {
*dst++ = *src++;
}
*dst = '\0';
// Locate start of model file name
auto lastSlash = strrchr(texturePath, '\\');
auto modelFileName = lastSlash ? lastSlash + 1 : texturePath;
auto textureFlags = CGxTexFlags(GxTex_LinearMipLinear, 1, 1, 0, 0, 0, 1);
for (uint32_t i = 0; i < 3; i++) {
auto textureName = displayInfoRec->m_textureVariation[i];
if (textureName[0] == '\0') {
continue;
}
// Replace model file name with texture name
src = textureName;
dst = modelFileName;
while (*src) {
*dst++ = *src++;
}
*dst = '\0';
auto texture = TextureCreate(texturePath, textureFlags, &status, 0);
if (texture) {
model->ReplaceTexture(11 + i, texture);
HandleClose(texture);
}
}
ReplaceParticleColor(model, displayInfoRec->m_particleColorID);
}
void CCharacterComponent::UpdateBaseTexture(EGxTexCommand cmd, uint32_t width, uint32_t height, uint32_t depth, uint32_t mipLevel, void* userArg, uint32_t& texelStrideInBytes, const void*& texels) {
auto component = static_cast<CCharacterComponent*>(userArg);

View File

@ -10,6 +10,8 @@
class CACHEENTRY;
class CCharacterComponent;
class CharSectionsRec;
class CreatureDisplayInfoRec;
class CreatureModelDataRec;
class ItemDisplayInfoRec;
struct BlpPalPixel;
@ -51,6 +53,7 @@ class CCharacterComponent {
static int32_t AddHandItem(CM2Model* model, const ItemDisplayInfoRec* displayRec, INVENTORY_SLOTS invSlot, SHEATHE_TYPE sheatheType, bool sheathed, bool shield, bool a7, int32_t a8);
static void AddLink(CM2Model* parent, GEOCOMPONENTLINKS link, char const* modelPath, char const* texturePath, int32_t visualID, const ItemDisplayInfoRec* displayRec);
static CCharacterComponent* AllocComponent();
static void ApplyMonsterGeosets(CM2Model* model, const CreatureDisplayInfoRec* displayInfoRec);
static void ComponentCloseFingers(CM2Model* model, COMP_HAND_SLOT handSlot);
static void ComponentOpenFingers(CM2Model* model, COMP_HAND_SLOT handSlot);
static HTEXTURE CreateTexture(const char* fileName, CStatus* status);
@ -68,6 +71,7 @@ class CCharacterComponent {
static void PasteTransparent4Bit(void* srcTexture, const BlpPalPixel* srcPal, MipBits* dstMips, const C2iVector& dstPos, uint32_t dstWidth, const C2iVector& srcPos, const C2iVector& srcSize, TCTEXTUREINFO& srcInfo, int32_t srcMipLevel, int32_t dstMipLevelOfs);
static void PasteTransparent8Bit(void* srcTexture, const BlpPalPixel* srcPal, MipBits* dstMips, const C2iVector& dstPos, uint32_t dstWidth, const C2iVector& srcPos, const C2iVector& srcSize, TCTEXTUREINFO& srcInfo, int32_t srcMipLevel, int32_t dstMipLevelOfs);
static void RemoveLinkpt(CM2Model* model, GEOCOMPONENTLINKS link);
static void ReplaceMonsterSkin(CM2Model* model, const CreatureDisplayInfoRec* displayInfoRec, const CreatureModelDataRec* modelDataRec);
static void UpdateBaseTexture(EGxTexCommand cmd, uint32_t width, uint32_t height, uint32_t depth, uint32_t mipLevel, void* userArg, uint32_t& texelStrideInBytes, const void*& texels);
// Member variables

View File

@ -14,6 +14,7 @@ WowClientDB<ChrRacesRec> g_chrRacesDB;
WowClientDB<CreatureDisplayInfoRec> g_creatureDisplayInfoDB;
WowClientDB<CreatureDisplayInfoExtraRec> g_creatureDisplayInfoExtraDB;
WowClientDB<CreatureModelDataRec> g_creatureModelDataDB;
WowClientDB<CreatureSoundDataRec> g_creatureSoundDataDB;
WowClientDB<FactionGroupRec> g_factionGroupDB;
WowClientDB<FactionTemplateRec> g_factionTemplateDB;
WowClientDB<ItemDisplayInfoRec> g_itemDisplayInfoDB;
@ -22,6 +23,7 @@ WowClientDB<MapRec> g_mapDB;
WowClientDB<PaperDollItemFrameRec> g_paperDollItemFrameDB;
WowClientDB<SoundEntriesRec> g_soundEntriesDB;
WowClientDB<SoundEntriesAdvancedRec> g_soundEntriesAdvancedDB;
WowClientDB<UnitBloodLevelsRec> g_unitBloodLevelsDB;
void LoadDB(WowClientDB_Base* db, const char* filename, int32_t linenumber) {
db->Load(filename, linenumber);
@ -41,6 +43,7 @@ void StaticDBLoadAll(void (*loadFn)(WowClientDB_Base*, const char*, int32_t)) {
loadFn(&g_creatureDisplayInfoDB, __FILE__, __LINE__);
loadFn(&g_creatureDisplayInfoExtraDB, __FILE__, __LINE__);
loadFn(&g_creatureModelDataDB, __FILE__, __LINE__);
loadFn(&g_creatureSoundDataDB, __FILE__, __LINE__);
loadFn(&g_factionGroupDB, __FILE__, __LINE__);
loadFn(&g_factionTemplateDB, __FILE__, __LINE__);
loadFn(&g_itemDisplayInfoDB, __FILE__, __LINE__);
@ -49,6 +52,7 @@ void StaticDBLoadAll(void (*loadFn)(WowClientDB_Base*, const char*, int32_t)) {
loadFn(&g_paperDollItemFrameDB, __FILE__, __LINE__);
loadFn(&g_soundEntriesDB, __FILE__, __LINE__);
loadFn(&g_soundEntriesAdvancedDB, __FILE__, __LINE__);
loadFn(&g_unitBloodLevelsDB, __FILE__, __LINE__);
};
void ClientDBInitialize() {

View File

@ -15,6 +15,7 @@
#include "db/rec/CreatureDisplayInfoRec.hpp"
#include "db/rec/CreatureDisplayInfoExtraRec.hpp"
#include "db/rec/CreatureModelDataRec.hpp"
#include "db/rec/CreatureSoundDataRec.hpp"
#include "db/rec/FactionGroupRec.hpp"
#include "db/rec/FactionTemplateRec.hpp"
#include "db/rec/ItemDisplayInfoRec.hpp"
@ -23,6 +24,7 @@
#include "db/rec/PaperDollItemFrameRec.hpp"
#include "db/rec/SoundEntriesRec.hpp"
#include "db/rec/SoundEntriesAdvancedRec.hpp"
#include "db/rec/UnitBloodLevelsRec.hpp"
extern WowClientDB<AchievementRec> g_achievementDB;
extern WowClientDB<AreaTableRec> g_areaTableDB;
@ -37,6 +39,7 @@ extern WowClientDB<ChrRacesRec> g_chrRacesDB;
extern WowClientDB<CreatureDisplayInfoRec> g_creatureDisplayInfoDB;
extern WowClientDB<CreatureDisplayInfoExtraRec> g_creatureDisplayInfoExtraDB;
extern WowClientDB<CreatureModelDataRec> g_creatureModelDataDB;
extern WowClientDB<CreatureSoundDataRec> g_creatureSoundDataDB;
extern WowClientDB<FactionGroupRec> g_factionGroupDB;
extern WowClientDB<FactionTemplateRec> g_factionTemplateDB;
extern WowClientDB<ItemDisplayInfoRec> g_itemDisplayInfoDB;
@ -45,6 +48,7 @@ extern WowClientDB<MapRec> g_mapDB;
extern WowClientDB<PaperDollItemFrameRec> g_paperDollItemFrameDB;
extern WowClientDB<SoundEntriesRec> g_soundEntriesDB;
extern WowClientDB<SoundEntriesAdvancedRec> g_soundEntriesAdvancedDB;
extern WowClientDB<UnitBloodLevelsRec> g_unitBloodLevelsDB;
void ClientDBInitialize();

View File

@ -0,0 +1,75 @@
// DO NOT EDIT: generated by whoa-autocode
#include "db/rec/CreatureSoundDataRec.hpp"
#include "util/Locale.hpp"
#include "util/SFile.hpp"
const char* CreatureSoundDataRec::GetFilename() {
return "DBFilesClient\\CreatureSoundData.dbc";
}
uint32_t CreatureSoundDataRec::GetNumColumns() {
return 38;
}
uint32_t CreatureSoundDataRec::GetRowSize() {
return 152;
}
bool CreatureSoundDataRec::NeedIDAssigned() {
return false;
}
int32_t CreatureSoundDataRec::GetID() {
return this->m_ID;
}
void CreatureSoundDataRec::SetID(int32_t id) {
this->m_ID = id;
}
bool CreatureSoundDataRec::Read(SFile* f, const char* stringBuffer) {
if (
!SFile::Read(f, &this->m_ID, sizeof(this->m_ID), nullptr, nullptr, nullptr)
|| !SFile::Read(f, &this->m_soundExertionID, sizeof(this->m_soundExertionID), nullptr, nullptr, nullptr)
|| !SFile::Read(f, &this->m_soundExertionCriticalID, sizeof(this->m_soundExertionCriticalID), nullptr, nullptr, nullptr)
|| !SFile::Read(f, &this->m_soundInjuryID, sizeof(this->m_soundInjuryID), nullptr, nullptr, nullptr)
|| !SFile::Read(f, &this->m_soundInjuryCriticalID, sizeof(this->m_soundInjuryCriticalID), nullptr, nullptr, nullptr)
|| !SFile::Read(f, &this->m_soundInjuryCrushingBlowID, sizeof(this->m_soundInjuryCrushingBlowID), nullptr, nullptr, nullptr)
|| !SFile::Read(f, &this->m_soundDeathID, sizeof(this->m_soundDeathID), nullptr, nullptr, nullptr)
|| !SFile::Read(f, &this->m_soundStunID, sizeof(this->m_soundStunID), nullptr, nullptr, nullptr)
|| !SFile::Read(f, &this->m_soundStandID, sizeof(this->m_soundStandID), nullptr, nullptr, nullptr)
|| !SFile::Read(f, &this->m_soundFootstepID, sizeof(this->m_soundFootstepID), nullptr, nullptr, nullptr)
|| !SFile::Read(f, &this->m_soundAggroID, sizeof(this->m_soundAggroID), nullptr, nullptr, nullptr)
|| !SFile::Read(f, &this->m_soundWingFlapID, sizeof(this->m_soundWingFlapID), nullptr, nullptr, nullptr)
|| !SFile::Read(f, &this->m_soundWingGlideID, sizeof(this->m_soundWingGlideID), nullptr, nullptr, nullptr)
|| !SFile::Read(f, &this->m_soundAlertID, sizeof(this->m_soundAlertID), nullptr, nullptr, nullptr)
|| !SFile::Read(f, &this->m_soundFidget[0], sizeof(m_soundFidget[0]), nullptr, nullptr, nullptr)
|| !SFile::Read(f, &this->m_soundFidget[1], sizeof(m_soundFidget[0]), nullptr, nullptr, nullptr)
|| !SFile::Read(f, &this->m_soundFidget[2], sizeof(m_soundFidget[0]), nullptr, nullptr, nullptr)
|| !SFile::Read(f, &this->m_soundFidget[3], sizeof(m_soundFidget[0]), nullptr, nullptr, nullptr)
|| !SFile::Read(f, &this->m_soundFidget[4], sizeof(m_soundFidget[0]), nullptr, nullptr, nullptr)
|| !SFile::Read(f, &this->m_customAttack[0], sizeof(m_customAttack[0]), nullptr, nullptr, nullptr)
|| !SFile::Read(f, &this->m_customAttack[1], sizeof(m_customAttack[0]), nullptr, nullptr, nullptr)
|| !SFile::Read(f, &this->m_customAttack[2], sizeof(m_customAttack[0]), nullptr, nullptr, nullptr)
|| !SFile::Read(f, &this->m_customAttack[3], sizeof(m_customAttack[0]), nullptr, nullptr, nullptr)
|| !SFile::Read(f, &this->m_npcsoundID, sizeof(this->m_npcsoundID), nullptr, nullptr, nullptr)
|| !SFile::Read(f, &this->m_loopSoundID, sizeof(this->m_loopSoundID), nullptr, nullptr, nullptr)
|| !SFile::Read(f, &this->m_creatureImpactType, sizeof(this->m_creatureImpactType), nullptr, nullptr, nullptr)
|| !SFile::Read(f, &this->m_soundJumpStartID, sizeof(this->m_soundJumpStartID), nullptr, nullptr, nullptr)
|| !SFile::Read(f, &this->m_soundJumpEndID, sizeof(this->m_soundJumpEndID), nullptr, nullptr, nullptr)
|| !SFile::Read(f, &this->m_soundPetAttackID, sizeof(this->m_soundPetAttackID), nullptr, nullptr, nullptr)
|| !SFile::Read(f, &this->m_soundPetOrderID, sizeof(this->m_soundPetOrderID), nullptr, nullptr, nullptr)
|| !SFile::Read(f, &this->m_soundPetDismissID, sizeof(this->m_soundPetDismissID), nullptr, nullptr, nullptr)
|| !SFile::Read(f, &this->m_fidgetDelaySecondsMin, sizeof(this->m_fidgetDelaySecondsMin), nullptr, nullptr, nullptr)
|| !SFile::Read(f, &this->m_fidgetDelaySecondsMax, sizeof(this->m_fidgetDelaySecondsMax), nullptr, nullptr, nullptr)
|| !SFile::Read(f, &this->m_birthSoundID, sizeof(this->m_birthSoundID), nullptr, nullptr, nullptr)
|| !SFile::Read(f, &this->m_spellCastDirectedSoundID, sizeof(this->m_spellCastDirectedSoundID), nullptr, nullptr, nullptr)
|| !SFile::Read(f, &this->m_submergeSoundID, sizeof(this->m_submergeSoundID), nullptr, nullptr, nullptr)
|| !SFile::Read(f, &this->m_submergedSoundID, sizeof(this->m_submergedSoundID), nullptr, nullptr, nullptr)
|| !SFile::Read(f, &this->m_creatureSoundDataIdpet, sizeof(this->m_creatureSoundDataIdpet), nullptr, nullptr, nullptr)
) {
return false;
}
return true;
}

View File

@ -0,0 +1,52 @@
// DO NOT EDIT: generated by whoa-autocode
#ifndef DB_REC_CREATURE_SOUND_DATA_REC_HPP
#define DB_REC_CREATURE_SOUND_DATA_REC_HPP
#include <cstdint>
class SFile;
class CreatureSoundDataRec {
public:
int32_t m_ID;
int32_t m_soundExertionID;
int32_t m_soundExertionCriticalID;
int32_t m_soundInjuryID;
int32_t m_soundInjuryCriticalID;
int32_t m_soundInjuryCrushingBlowID;
int32_t m_soundDeathID;
int32_t m_soundStunID;
int32_t m_soundStandID;
int32_t m_soundFootstepID;
int32_t m_soundAggroID;
int32_t m_soundWingFlapID;
int32_t m_soundWingGlideID;
int32_t m_soundAlertID;
int32_t m_soundFidget[5];
int32_t m_customAttack[4];
int32_t m_npcsoundID;
int32_t m_loopSoundID;
int32_t m_creatureImpactType;
int32_t m_soundJumpStartID;
int32_t m_soundJumpEndID;
int32_t m_soundPetAttackID;
int32_t m_soundPetOrderID;
int32_t m_soundPetDismissID;
float m_fidgetDelaySecondsMin;
float m_fidgetDelaySecondsMax;
int32_t m_birthSoundID;
int32_t m_spellCastDirectedSoundID;
int32_t m_submergeSoundID;
int32_t m_submergedSoundID;
int32_t m_creatureSoundDataIdpet;
static const char* GetFilename();
static uint32_t GetNumColumns();
static uint32_t GetRowSize();
static bool NeedIDAssigned();
int32_t GetID();
void SetID(int32_t id);
bool Read(SFile* f, const char* stringBuffer);
};
#endif

View File

@ -0,0 +1,41 @@
// DO NOT EDIT: generated by whoa-autocode
#include "db/rec/UnitBloodLevelsRec.hpp"
#include "util/Locale.hpp"
#include "util/SFile.hpp"
const char* UnitBloodLevelsRec::GetFilename() {
return "DBFilesClient\\UnitBloodLevels.dbc";
}
uint32_t UnitBloodLevelsRec::GetNumColumns() {
return 4;
}
uint32_t UnitBloodLevelsRec::GetRowSize() {
return 16;
}
bool UnitBloodLevelsRec::NeedIDAssigned() {
return false;
}
int32_t UnitBloodLevelsRec::GetID() {
return this->m_ID;
}
void UnitBloodLevelsRec::SetID(int32_t id) {
this->m_ID = id;
}
bool UnitBloodLevelsRec::Read(SFile* f, const char* stringBuffer) {
if (
!SFile::Read(f, &this->m_ID, sizeof(this->m_ID), nullptr, nullptr, nullptr)
|| !SFile::Read(f, &this->m_violencelevel[0], sizeof(m_violencelevel[0]), nullptr, nullptr, nullptr)
|| !SFile::Read(f, &this->m_violencelevel[1], sizeof(m_violencelevel[0]), nullptr, nullptr, nullptr)
|| !SFile::Read(f, &this->m_violencelevel[2], sizeof(m_violencelevel[0]), nullptr, nullptr, nullptr)
) {
return false;
}
return true;
}

View File

@ -0,0 +1,23 @@
// DO NOT EDIT: generated by whoa-autocode
#ifndef DB_REC_UNIT_BLOOD_LEVELS_REC_HPP
#define DB_REC_UNIT_BLOOD_LEVELS_REC_HPP
#include <cstdint>
class SFile;
class UnitBloodLevelsRec {
public:
int32_t m_ID;
int32_t m_violencelevel[3];
static const char* GetFilename();
static uint32_t GetNumColumns();
static uint32_t GetRowSize();
static bool NeedIDAssigned();
int32_t GetID();
void SetID(int32_t id);
bool Read(SFile* f, const char* stringBuffer);
};
#endif

View File

@ -1604,6 +1604,10 @@ void CM2Model::LinkToCallbackListTail() {
this->m_shared->m_callbackListTail = &this->m_callbackNext;
}
void CM2Model::OptimizeVisibleGeometry() {
// TODO
}
int32_t CM2Model::ProcessCallbacks() {
// TODO
return 1;

View File

@ -178,6 +178,7 @@ class CM2Model {
int32_t IsDrawable(int32_t a2, int32_t a3);
int32_t IsLoaded(int32_t a2, int32_t attachments);
void LinkToCallbackListTail();
void OptimizeVisibleGeometry();
int32_t ProcessCallbacks();
void ProcessCallbacksRecursive();
uint32_t Release();

View File

@ -1,7 +1,10 @@
#include "object/client/CGUnit_C.hpp"
#include "component/CCharacterComponent.hpp"
#include "model/Model2.hpp"
#include "object/client/ObjMgr.hpp"
#include "db/Db.hpp"
#include "ui/Game.hpp"
#include <storm/Error.hpp>
WOWGUID CGUnit_C::s_activeMover;
@ -95,6 +98,10 @@ const char* CGUnit_C::GetDisplayRaceNameFromRecord(const ChrRacesRec* raceRec, U
CGUnit_C::CGUnit_C(uint32_t time, CClientObjCreate& objCreate) : CGObject_C(time, objCreate) {
// TODO
this->RefreshDataPointers();
// TODO
}
CGUnit_C::~CGUnit_C() {
@ -115,16 +122,22 @@ int32_t CGUnit_C::CanBeTargetted() {
return this->CanHighlight();
}
int32_t CGUnit_C::GetDisplayID() const {
// Prefer local display ID if set and unit's display ID hasn't been overridden from unit's
// native display ID.
if (this->GetLocalDisplayID() && this->GetDisplayID() == this->GetNativeDisplayID()) {
return this->GetLocalDisplayID();
}
return this->CGUnit::GetDisplayID();
}
int32_t CGUnit_C::GetLocalDisplayID() const {
return this->m_localDisplayID;
}
CreatureModelDataRec* CGUnit_C::GetModelData() const {
// Prefer local display ID if set and unit's display ID hasn't been overridden from unit's
// native display ID; otherwise prefer overridden display ID.
auto displayID = this->GetLocalDisplayID() && this->GetDisplayID() == this->GetNativeDisplayID()
? this->GetLocalDisplayID()
: this->GetDisplayID();
auto displayID = this->GetDisplayID();
auto creatureDisplayInfoRec = g_creatureDisplayInfoDB.GetRecord(displayID);
@ -164,12 +177,80 @@ void CGUnit_C::PostInit(uint32_t time, const CClientObjCreate& init, bool a4) {
this->CGObject_C::PostInit(time, init, a4);
// TODO
if (this->m_displayInfo) {
CCharacterComponent::ApplyMonsterGeosets(this->m_model, this->m_displayInfo);
CCharacterComponent::ReplaceMonsterSkin(this->m_model, this->m_displayInfo, this->m_modelData);
if (this->m_modelData) {
this->m_model->m_flag4 = (this->m_modelData->m_flags & 0x200) ? true : false;
}
}
// TODO
}
void CGUnit_C::PostMovementUpdate(const CClientMoveUpdate& move, int32_t activeMover) {
// TODO
}
void CGUnit_C::RefreshDataPointers() {
auto displayID = this->GetDisplayID();
// Display info
this->m_displayInfo = g_creatureDisplayInfoDB.GetRecord(displayID);
if (!this->m_displayInfo) {
// TODO auto name = this->GetUnitName(0, 1);
// TODO SysMsgPrintf(2, 2, "NOUNITDISPLAYID|%d|%s", displayID, name);
this->m_displayInfo = g_creatureDisplayInfoDB.GetRecordByIndex(0);
if (!this->m_displayInfo) {
STORM_APP_FATAL("Error, NO creature display records found");
}
}
// Display info extra
this->m_displayInfoExtra = g_creatureDisplayInfoExtraDB.GetRecord(this->m_displayInfo->m_extendedDisplayInfoID);
// Model data
this->m_modelData = g_creatureModelDataDB.GetRecord(this->m_displayInfo->m_modelID);
// Sound data
this->m_soundData = g_creatureSoundDataDB.GetRecord(this->m_displayInfo->m_soundID);
if (!this->m_soundData) {
this->m_soundData = g_creatureSoundDataDB.GetRecord(this->m_modelData->m_soundID);
}
// Blood levels
this->m_bloodRec = g_unitBloodLevelsDB.GetRecord(this->m_displayInfo->m_bloodID);
if (!this->m_bloodRec) {
this->m_bloodRec = g_unitBloodLevelsDB.GetRecord(this->m_modelData->m_bloodID);
if (!this->m_bloodRec) {
this->m_bloodRec = g_unitBloodLevelsDB.GetRecordByIndex(0);
}
}
// Creature stats
if (this->GetType() == HIER_TYPE_UNIT) {
// TODO load creature stats
}
// Flags
// TODO set flags
}
void CGUnit_C::SetStorage(uint32_t* storage, uint32_t* saved) {
this->CGObject_C::SetStorage(storage, saved);

View File

@ -9,7 +9,11 @@
class ChrClassesRec;
class ChrRacesRec;
class CreatureDisplayInfoRec;
class CreatureDisplayInfoExtraRec;
class CreatureModelDataRec;
class CreatureSoundDataRec;
class UnitBloodLevelsRec;
class CGUnit_C : public CGObject_C, public CGUnit {
public:
@ -31,15 +35,27 @@ class CGUnit_C : public CGObject_C, public CGUnit {
// Public member functions
CGUnit_C(uint32_t time, CClientObjCreate& objCreate);
int32_t GetLocalDisplayID() const;
int32_t GetDisplayID() const;
CreatureModelDataRec* GetModelData() const;
void PostInit(uint32_t time, const CClientObjCreate& init, bool a4);
void PostMovementUpdate(const CClientMoveUpdate& move, int32_t activeMover);
void SetStorage(uint32_t* storage, uint32_t* saved);
protected:
// Protected member functions
int32_t GetLocalDisplayID() const;
void RefreshDataPointers();
private:
// Private member variables
// TODO
CreatureDisplayInfoRec* m_displayInfo;
CreatureDisplayInfoExtraRec* m_displayInfoExtra;
CreatureModelDataRec* m_modelData;
CreatureSoundDataRec* m_soundData;
// TODO
UnitBloodLevelsRec* m_bloodRec;
// TODO
int32_t m_localDisplayID = 0;
// TODO
};