From e4be8f41905489faf26eedf63068ebfa540afe09 Mon Sep 17 00:00:00 2001 From: ragnarok-clanker Date: Thu, 29 Oct 2026 09:48:08 +0000 Subject: [PATCH] Decompile 18 functions in Source/Client/Application/UnhandledExceptionHandler.cpp, Source/Client/Session.h, ... Batch #2077 by ragnarok-clanker: 0 byte-identical, 18 confirmed by peer review. - fn_04709 TopLevelExceptionFilter: logic confirmed by peer review (already on main) - fn_08004 C3dGrannyModelRes::PlayAnimation: logic confirmed by peer review - fn_09315 UIRequestJoinPartyWnd::SendMsg: logic confirmed by peer review - fn_19761 EffectParticle::EffectParticle: logic confirmed by peer review - fn_19768 EffectParticle::InitializeRecords: logic confirmed by peer review - fn_20007 AttachedEffect::AttachedEffect: logic confirmed by peer review - fn_20076 CreateEffectParticle: logic confirmed by peer review - fn_20088 UpdatePartyEffect: logic confirmed by peer review - fn_20991 CRenderObject::CRenderObject: logic confirmed by peer review - fn_21069 ?CreatePartyEffect@?A0xba063134@@YAPAUAttachedEffect@@AAUEffectActor@@AAUPartyEffectMode@@@Z: logic confirmed by peer review - fn_21086 RenderObjectState::Reset: logic confirmed by peer review - fn_23396 CSession::GetJobName: logic confirmed by peer review - fn_23495 CSession::InitJobNameTable: logic confirmed by peer review - fn_23788 CSession::GetMonsterActName: logic confirmed by peer review - fn_23791 CSession::GetMonsterTalkText: logic confirmed by peer review - fn_20987 EffectActor::EffectActor: logic confirmed by peer review - fn_22363 CSoundMaker::CSoundMaker: logic confirmed by peer review - fn_24251 CEffectMaker::CEffectMaker: logic confirmed by peer review Reviewed-by: ragnarok-clanker --- .../Application/UnhandledExceptionHandler.cpp | 4 +-- Source/Client/Session.h | 16 ++++++--- Source/Contents/Actors/RenderObject.cpp | 2 +- Source/Contents/Actors/RenderObject.h | 2 +- Source/Contents/Actors/RenderObjectState.cpp | 16 ++++----- Source/Contents/Actors/RenderObjectState.h | 5 ++- Source/Contents/Effects/AttachedEffect.cpp | 2 +- Source/Contents/Effects/AttachedEffect.h | 2 +- Source/Contents/Effects/EffectActor.cpp | 2 +- Source/Contents/Effects/EffectActor.h | 2 +- Source/Contents/Effects/EffectMaker.cpp | 2 +- Source/Contents/Effects/EffectMaker.h | 2 +- Source/Contents/Effects/EffectParticle.cpp | 6 ++-- Source/Contents/Effects/EffectParticle.h | 6 ++-- .../Effects/EffectPrimitiveRecords.cpp | 35 ++++++++++--------- .../Contents/Effects/EffectPrimitiveState.h | 1 - Source/Contents/Effects/PartyEffect.cpp | 4 +-- Source/Contents/Effects/PartyEffect.h | 3 +- .../Contents/Effects/PartyMemberEffects.cpp | 2 +- Source/Contents/Effects/PartyMemberEffects.h | 2 -- Source/Contents/EnemyMonsterTalk.cpp | 2 +- .../Contents/Jobs/JobNameInitialization.cpp | 31 ++++++++-------- Source/Contents/Jobs/JobNames.cpp | 25 ++++++------- Source/Contents/Jobs/JobNames.h | 9 ----- Source/Contents/MonsterResources.cpp | 4 +-- Source/Contents/Sound/SoundMaker.cpp | 2 +- Source/Contents/Sound/SoundMaker.h | 2 +- Source/Resource/Models/ModelResource.cpp | 4 +-- Source/Resource/Models/ModelResource.h | 2 -- Source/UI/Party/UIRequestJoinPartyWnd.cpp | 4 +-- Source/UI/Party/UIRequestJoinPartyWnd.h | 2 -- 31 files changed, 96 insertions(+), 107 deletions(-) diff --git a/Source/Client/Application/UnhandledExceptionHandler.cpp b/Source/Client/Application/UnhandledExceptionHandler.cpp index e75209b..f4346cd 100644 --- a/Source/Client/Application/UnhandledExceptionHandler.cpp +++ b/Source/Client/Application/UnhandledExceptionHandler.cpp @@ -40,8 +40,8 @@ namespace { // INLINED const char* ReadPlayerJobName(int jobId) { - const char* const* namesBegin = g_session.m_jobNamesBegin; - const char* const* namesEnd = g_session.m_jobNamesEnd; + const char* const* namesBegin = g_session.m_jobNameTable.data(); + const char* const* namesEnd = namesBegin + g_session.m_jobNameTable.size(); if (!namesBegin || !namesEnd || namesBegin >= namesEnd) { return ""; diff --git a/Source/Client/Session.h b/Source/Client/Session.h index e972214..e8db795 100644 --- a/Source/Client/Session.h +++ b/Source/Client/Session.h @@ -19,6 +19,7 @@ class CActRes; class CRenderObject; class LuaScript; +struct JobNameInitialization; struct ActionFrame; struct WindowDialogs; @@ -103,9 +104,10 @@ public: /* 0F70 */ unsigned char unknown_0F70[0x08]; /* 0F78 */ const char* const* m_humanFemaleHeadNames; /* 0F7C */ unsigned char unknown_0F7C[0x2C]; - /* 0FA8 */ const char* const* m_jobNamesBegin; - /* 0FAC */ const char* const* m_jobNamesEnd; - /* 0FB0 */ unsigned char unknown_0FB0[0x34]; + /* 0FA8 */ std::vector m_jobNameTable; + /* 0FB4 */ std::map m_jobNameTableWoman; + /* 0FBC */ std::map m_jobNameTableMan; + /* 0FC4 */ unsigned char unknown_0FC4[0x20]; /* 0FE4 */ std::list m_pingSamples; /* 0FEC */ unsigned char unknown_0FEC[0x24]; /* 1010 */ std::uint32_t unknown_1010; @@ -295,6 +297,8 @@ public: int MercSkillLevel(int skillId) const; int HomunSkillLevel(int skillId) const; CRenderObject* FindGameActor(std::uint32_t aid) const; + const char* GetJobName(unsigned job, int sex); + void InitJobNameTable(JobNameInitialization& context); int SyncUnknown0E98(); void LoadXmlTables(); std::string GetAccessoryName(int id); @@ -398,8 +402,10 @@ static_assert(offsetof(CSession, m_playerX) == 0xF18); static_assert(offsetof(CSession, m_playerY) == 0xF1C); static_assert(offsetof(CSession, m_score1) == 0xF28); static_assert(offsetof(CSession, m_score2) == 0xF2C); -static_assert(offsetof(CSession, m_jobNamesBegin) == 0xFA8); -static_assert(offsetof(CSession, m_jobNamesEnd) == 0xFAC); +static_assert(offsetof(CSession, m_jobNameTable) == 0xFA8); +static_assert(offsetof(CSession, m_jobNameTableWoman) == 0xFB4); +static_assert(offsetof(CSession, m_jobNameTableMan) == 0xFBC); +static_assert(offsetof(CSession, m_pingSamples) == 0xFE4); static_assert(offsetof(CSession, m_head) == 0xED8); static_assert(offsetof(CSession, m_headPalette) == 0xEF0); static_assert(offsetof(CSession, m_humanMaleHeadNames) == 0xF6C); diff --git a/Source/Contents/Actors/RenderObject.cpp b/Source/Contents/Actors/RenderObject.cpp index 97b7c26..6cef02b 100644 --- a/Source/Contents/Actors/RenderObject.cpp +++ b/Source/Contents/Actors/RenderObject.cpp @@ -20,7 +20,7 @@ // OFFSET: 0x00CA8730 // FUNCTION: fn_20991 -CRenderObject::CRenderObject(ResourceMgr& resources, JobNames& names) : render(resources, names) { +CRenderObject::CRenderObject() { } // OFFSET: 0x00CA8F90 diff --git a/Source/Contents/Actors/RenderObject.h b/Source/Contents/Actors/RenderObject.h index 23d24e0..9818530 100644 --- a/Source/Contents/Actors/RenderObject.h +++ b/Source/Contents/Actors/RenderObject.h @@ -11,7 +11,7 @@ struct SpriteQuad; class CRenderObject : public CGameObject { public: - CRenderObject(ResourceMgr& resources, JobNames& names); + CRenderObject(); ~CRenderObject() override; bool Update() override; void SendObjectMessage(CGameObject* sender, int message, int a, int b, int c, int d, int e, int f, int g, int h, int i, int j, int k, int l, int m) override; diff --git a/Source/Contents/Actors/RenderObjectState.cpp b/Source/Contents/Actors/RenderObjectState.cpp index d660549..d419060 100644 --- a/Source/Contents/Actors/RenderObjectState.cpp +++ b/Source/Contents/Actors/RenderObjectState.cpp @@ -1,4 +1,4 @@ -#include "Contents/Jobs/JobNames.h" +#include "Client/Session.h" #include "Contents/Actors/RenderObjectState.h" #include "Resource/Sprites/ActionResource.h" #include "Resource/ResourceMgr.h" @@ -9,8 +9,8 @@ #include // INLINED -RenderObjectState::RenderObjectState(ResourceMgr& resources, JobNames& names) : sprite(nullptr), action(nullptr) { - this->Reset(resources, names); +RenderObjectState::RenderObjectState() : sprite(nullptr), action(nullptr) { + this->Reset(); } // INLINED @@ -26,7 +26,7 @@ RenderObjectState::~RenderObjectState() { // OFFSET: 0x00CAF990 // FUNCTION: fn_21086 -void RenderObjectState::Reset(ResourceMgr& resources, JobNames& names) { +void RenderObjectState::Reset() { this->position.x = 0; this->position.y = 0; this->position.z = 0; @@ -64,14 +64,14 @@ void RenderObjectState::Reset(ResourceMgr& resources, JobNames& names) { char spriteName[128]; char actionName[128]; - std::sprintf(spriteName, "NPC\\%s.spr", names.Lookup(46, -1)); - std::sprintf(actionName, "NPC\\%s.act", names.Lookup(46, -1)); + std::sprintf(spriteName, "NPC\\%s.spr", g_session.GetJobName(46, -1)); + std::sprintf(actionName, "NPC\\%s.act", g_session.GetJobName(46, -1)); if (this->sprite) { this->sprite->Release(); } - this->sprite = static_cast(resources.Load(spriteName)); + this->sprite = static_cast(ResourceMgr::Instance().Load(spriteName)); if (this->sprite) { ++this->sprite->references; @@ -81,7 +81,7 @@ void RenderObjectState::Reset(ResourceMgr& resources, JobNames& names) { this->action->Release(); } - this->action = static_cast(resources.Load(actionName)); + this->action = static_cast(ResourceMgr::Instance().Load(actionName)); if (this->action) { ++this->action->references; diff --git a/Source/Contents/Actors/RenderObjectState.h b/Source/Contents/Actors/RenderObjectState.h index ea268ca..ade8725 100644 --- a/Source/Contents/Actors/RenderObjectState.h +++ b/Source/Contents/Actors/RenderObjectState.h @@ -8,15 +8,14 @@ #include #include -struct JobNames; class ResourceMgr; class CSprRes; class CActRes; struct RenderObjectState { - RenderObjectState(ResourceMgr& resources, JobNames& names); + RenderObjectState(); ~RenderObjectState(); - void Reset(ResourceMgr& resources, JobNames& names); + void Reset(); RenderObjectState(const RenderObjectState&) = delete; RenderObjectState& operator=(const RenderObjectState&) = delete; diff --git a/Source/Contents/Effects/AttachedEffect.cpp b/Source/Contents/Effects/AttachedEffect.cpp index f2e312a..6e176b7 100644 --- a/Source/Contents/Effects/AttachedEffect.cpp +++ b/Source/Contents/Effects/AttachedEffect.cpp @@ -43,7 +43,7 @@ inline RagEffectState::~RagEffectState() { // OFFSET: 0x00BF84B0 // FUNCTION: fn_20007 -AttachedEffect::AttachedEffect(ResourceMgr& resources, JobNames& names) : CRenderObject(resources, names) { +AttachedEffect::AttachedEffect() { } AttachedEffect::~AttachedEffect() = default; diff --git a/Source/Contents/Effects/AttachedEffect.h b/Source/Contents/Effects/AttachedEffect.h index 9f5c51c..132b27b 100644 --- a/Source/Contents/Effects/AttachedEffect.h +++ b/Source/Contents/Effects/AttachedEffect.h @@ -7,7 +7,7 @@ #include struct AttachedEffect : CRenderObject { - AttachedEffect(ResourceMgr& resources, JobNames& names); + AttachedEffect(); ~AttachedEffect() override; /* 0138 */ RagEffectState state; diff --git a/Source/Contents/Effects/EffectActor.cpp b/Source/Contents/Effects/EffectActor.cpp index 4aae63d..ab956cc 100644 --- a/Source/Contents/Effects/EffectActor.cpp +++ b/Source/Contents/Effects/EffectActor.cpp @@ -16,6 +16,6 @@ EffectAttachments EffectActorState::Attachments() { // OFFSET: 0x00CA82E0 // FUNCTION: fn_20987 -EffectActor::EffectActor(ResourceMgr& resources, JobNames& names) : CRenderObject(resources, names) { +EffectActor::EffectActor() { this->render.unknown_0130[0] = 0; } diff --git a/Source/Contents/Effects/EffectActor.h b/Source/Contents/Effects/EffectActor.h index 363948d..af07464 100644 --- a/Source/Contents/Effects/EffectActor.h +++ b/Source/Contents/Effects/EffectActor.h @@ -20,7 +20,7 @@ struct EffectActorState { }; struct EffectActor : CRenderObject { - EffectActor(ResourceMgr& resources, JobNames& names); + EffectActor(); bool EffectVisible() const; /* 0138 */ EffectActorState state; diff --git a/Source/Contents/Effects/EffectMaker.cpp b/Source/Contents/Effects/EffectMaker.cpp index c5d30a6..35cb290 100644 --- a/Source/Contents/Effects/EffectMaker.cpp +++ b/Source/Contents/Effects/EffectMaker.cpp @@ -2,7 +2,7 @@ // OFFSET: 0x00E4A2B0 // FUNCTION: fn_24251 -CEffectMaker::CEffectMaker(ResourceMgr& resources, JobNames& names) : EffectActor(resources, names) { +CEffectMaker::CEffectMaker() { this->unknown_0160 = -1; this->unknown_015C = 360; this->unknown_0158 = 360; diff --git a/Source/Contents/Effects/EffectMaker.h b/Source/Contents/Effects/EffectMaker.h index b300c46..728a456 100644 --- a/Source/Contents/Effects/EffectMaker.h +++ b/Source/Contents/Effects/EffectMaker.h @@ -6,7 +6,7 @@ #include struct CEffectMaker : EffectActor { - CEffectMaker(ResourceMgr& resources, JobNames& names); + CEffectMaker(); /* 0158 */ int unknown_0158; /* 015C */ int unknown_015C; diff --git a/Source/Contents/Effects/EffectParticle.cpp b/Source/Contents/Effects/EffectParticle.cpp index e8104d3..11136c6 100644 --- a/Source/Contents/Effects/EffectParticle.cpp +++ b/Source/Contents/Effects/EffectParticle.cpp @@ -3,16 +3,16 @@ // OFFSET: 0x00BAD940 // FUNCTION: fn_19761 -EffectParticle::EffectParticle(ResourceMgr& resources, JobNames& names) : CRenderObject(resources, names), state(this->render) { +EffectParticle::EffectParticle() : state(this->render) { } // OFFSET: 0x00C1DE70 // FUNCTION: fn_20076 EffectParticle* CreateEffectParticle( - AttachedEffect& master, const RenderObjectState& masterRender, int type, float x, float y, float z, ResourceMgr& resources, JobNames& names, + AttachedEffect& master, const RenderObjectState& masterRender, int type, float x, float y, float z, std::list& worldObjects ) { - auto* particle = new EffectParticle(resources, names); + auto* particle = new EffectParticle(); particle->state.Initialize(particle->render, master, masterRender, type, x, y, z); master.state.related.push_back(&particle->state); diff --git a/Source/Contents/Effects/EffectParticle.h b/Source/Contents/Effects/EffectParticle.h index 8b0b20a..4129be2 100644 --- a/Source/Contents/Effects/EffectParticle.h +++ b/Source/Contents/Effects/EffectParticle.h @@ -6,12 +6,11 @@ #include -struct JobNames; class ResourceMgr; struct AttachedEffect; struct EffectParticle : CRenderObject { - EffectParticle(ResourceMgr& resources, JobNames& names); + EffectParticle(); bool UpdateFireWall(); bool UpdateStoneCurse(); @@ -48,12 +47,13 @@ struct EffectParticle : CRenderObject { void FollowMasterAndTickSlots(); void FollowMasterAndTickSlots2(); void UpdateRecords(); + void InitializeRecords(); /* 0138 */ EffectPrimitiveState state; }; EffectParticle* CreateEffectParticle( - AttachedEffect& master, const RenderObjectState& masterRender, int type, float x, float y, float z, ResourceMgr& resources, JobNames& names, + AttachedEffect& master, const RenderObjectState& masterRender, int type, float x, float y, float z, std::list& worldObjects ); diff --git a/Source/Contents/Effects/EffectPrimitiveRecords.cpp b/Source/Contents/Effects/EffectPrimitiveRecords.cpp index c335d34..dd72c7d 100644 --- a/Source/Contents/Effects/EffectPrimitiveRecords.cpp +++ b/Source/Contents/Effects/EffectPrimitiveRecords.cpp @@ -1,3 +1,4 @@ +#include "Contents/Effects/EffectParticle.h" #include "Contents/Effects/EffectPrimitiveState.h" #include "Contents/Actors/RenderObjectState.h" @@ -6,22 +7,24 @@ // OFFSET: 0x00BAE670 // FUNCTION: fn_19768 -void EffectPrimitiveState::InitializeRecords(const RenderObjectState& render) { - for (int index = 0; index < this->unknown_01F4; ++index) { - EffectPrimitiveRecord& record = this->records[index]; - record.position = {render.position.x, render.position.y, render.position.z}; - std::memcpy(record.corners, this->corners, sizeof(record.corners)); - record.unknown_003C = this->unknown_0348; - record.scale = this->scale; - record.angle = this->unknown_030C; - std::memcpy(record.matrix, this->matrix1, sizeof(record.matrix)); - record.alpha = this->alpha; - record.red = this->red; - record.green = this->green; - record.blue = this->blue; +void EffectParticle::InitializeRecords() { + for (int index = 0; index < this->state.unknown_01F4; ++index) { + EffectPrimitiveRecord& record = this->state.records[index]; + record.position = this->render.position; + std::memcpy(record.corners, this->state.corners, sizeof(record.corners)); + record.unknown_003C = this->state.unknown_0348; + record.scale = this->state.scale; + record.angle = this->state.unknown_030C; + std::memcpy(record.matrix, this->state.matrix1, sizeof(record.matrix)); + record.alpha = this->state.alpha; + record.red = this->state.red; + record.green = this->state.green; + record.blue = this->state.blue; - const int alpha = TruncateToInt(this->alpha); - record.color = static_cast(this->blue) + - ((static_cast(this->green) + ((static_cast(this->red) + (static_cast(alpha) << 8)) << 8)) << 8); + const int alpha = TruncateToInt(this->state.alpha); + record.color = static_cast(this->state.blue) + + ((static_cast(this->state.green) + + ((static_cast(this->state.red) + (static_cast(alpha) << 8)) << 8)) + << 8); } } diff --git a/Source/Contents/Effects/EffectPrimitiveState.h b/Source/Contents/Effects/EffectPrimitiveState.h index 4b8067a..8b76a65 100644 --- a/Source/Contents/Effects/EffectPrimitiveState.h +++ b/Source/Contents/Effects/EffectPrimitiveState.h @@ -58,7 +58,6 @@ struct EffectPrimitiveState { ~EffectPrimitiveState(); void Initialize(RenderObjectState& render, AttachedEffect& master, const RenderObjectState& masterRender, int type, float x, float y, float z); void UpdateColor(); - void InitializeRecords(const RenderObjectState& render); void GetColorOverride(unsigned char* red, unsigned char* green, unsigned char* blue); /* 0138 */ std::uint32_t unknown_0138; diff --git a/Source/Contents/Effects/PartyEffect.cpp b/Source/Contents/Effects/PartyEffect.cpp index b030d31..1422417 100644 --- a/Source/Contents/Effects/PartyEffect.cpp +++ b/Source/Contents/Effects/PartyEffect.cpp @@ -10,7 +10,7 @@ // OFFSET: 0x00C2CF20 // FUNCTION: fn_20088 bool UpdatePartyEffect( - AttachedEffect& self, ResourceMgr& resources, JobNames& names, std::list& worldObjects, TextureCache& textures, const TerrainHeight& ground, + AttachedEffect& self, ResourceMgr& resources, std::list& worldObjects, TextureCache& textures, const TerrainHeight& ground, int updateTick ) { RagEffectState& effect = self.state; @@ -39,7 +39,7 @@ bool UpdatePartyEffect( } if (effect.unknown_0178 == 0) { - EffectParticle* particle = CreateEffectParticle(self, render, 15, 0, 0, 0, resources, names, worldObjects); + EffectParticle* particle = CreateEffectParticle(self, render, 15, 0, 0, 0, worldObjects); effect.unknown_11C84 = &particle->state; EffectPrimitiveState& state = *effect.unknown_11C84; state.lifetime = 9999; diff --git a/Source/Contents/Effects/PartyEffect.h b/Source/Contents/Effects/PartyEffect.h index 53f4aa4..38ee149 100644 --- a/Source/Contents/Effects/PartyEffect.h +++ b/Source/Contents/Effects/PartyEffect.h @@ -5,14 +5,13 @@ struct AttachedEffect; struct EffectParticle; -struct JobNames; struct TerrainHeight; class ResourceMgr; class TextureCache; class CRenderObject; bool UpdatePartyEffect( - AttachedEffect& self, ResourceMgr& resources, JobNames& names, std::list& worldObjects, TextureCache& textures, const TerrainHeight& ground, + AttachedEffect& self, ResourceMgr& resources, std::list& worldObjects, TextureCache& textures, const TerrainHeight& ground, int updateTick ); diff --git a/Source/Contents/Effects/PartyMemberEffects.cpp b/Source/Contents/Effects/PartyMemberEffects.cpp index c37aa4a..ceea6a9 100644 --- a/Source/Contents/Effects/PartyMemberEffects.cpp +++ b/Source/Contents/Effects/PartyMemberEffects.cpp @@ -10,7 +10,7 @@ namespace { // FUNCTION: fn_21069 AttachedEffect* CreatePartyEffect(EffectActor& actor, PartyEffectMode& mode) { mode.lastEffectId = 160; - auto* effect = new AttachedEffect(mode.resources, mode.names); + auto* effect = new AttachedEffect(); bool force = false; mode.effectScript.Call("IsForceRenderEffect", "d>b", 160, &force); effect->state.forceRender = force; diff --git a/Source/Contents/Effects/PartyMemberEffects.h b/Source/Contents/Effects/PartyMemberEffects.h index 512d903..23c0d03 100644 --- a/Source/Contents/Effects/PartyMemberEffects.h +++ b/Source/Contents/Effects/PartyMemberEffects.h @@ -6,7 +6,6 @@ struct EffectActor; class CRenderObject; -struct JobNames; struct ServiceOptions; class ResourceMgr; class LuaScript; @@ -17,7 +16,6 @@ struct PartyEffectMode { std::list& actors; std::list& objects; ResourceMgr& resources; - JobNames& names; ServiceOptions& options; LuaScript& effectScript; int& lastEffectId; diff --git a/Source/Contents/EnemyMonsterTalk.cpp b/Source/Contents/EnemyMonsterTalk.cpp index 87aae9c..8265dc9 100644 --- a/Source/Contents/EnemyMonsterTalk.cpp +++ b/Source/Contents/EnemyMonsterTalk.cpp @@ -19,7 +19,7 @@ void CSession::GetMonsterTalkText(int job, int event, int skill, char* text, std } char monster[256]; - std::strcpy(monster, g_session.m_jobNamesBegin[job]); + std::strcpy(monster, g_session.m_jobNameTable[job]); _strlwr(monster); node = node->FindChild(DecodeMessageRot(monster)); if (node == nullptr) { diff --git a/Source/Contents/Jobs/JobNameInitialization.cpp b/Source/Contents/Jobs/JobNameInitialization.cpp index 284390d..ce8036f 100644 --- a/Source/Contents/Jobs/JobNameInitialization.cpp +++ b/Source/Contents/Jobs/JobNameInitialization.cpp @@ -1,26 +1,27 @@ #include "Contents/Jobs/JobNames.h" +#include "Client/Session.h" #include "Contents/Jobs/JobId.h" #include "Script/LuaScript.h" // OFFSET: 0x00DE67E0 // FUNCTION: fn_23495 -void JobNames::Initialize(JobNameInitialization& context) { - this->names.resize(32003, "Poring"); +void CSession::InitJobNameTable(JobNameInitialization& context) { + this->m_jobNameTable.resize(32003, "Poring"); const char* name = nullptr; const auto player = [&](int first, int end) { for (int id = first; id < end; ++id) { if (context.playerScript.Call("ReqPCJobName", "d>s", id, &name) && *name != '\0') { - this->names[id] = name; + this->m_jobNameTable[id] = name; } if (context.playerScript.Call("ReqPCJobNameMan", "d>s", id, &name) && *name != '\0') { - this->male[id] = name; + this->m_jobNameTableMan[id] = name; } if (context.playerScript.Call("ReqPCJobNameWoman", "d>s", id, &name) && *name != '\0') { - this->female[id] = name; + this->m_jobNameTableWoman[id] = name; } } }; @@ -32,7 +33,7 @@ void JobNames::Initialize(JobNameInitialization& context) { const auto other = [&](int first, int end) { for (int id = first; id < end; ++id) { - context.otherScript.Call("ReqJobName", "d>s", id, &this->names[id]); + context.otherScript.Call("ReqJobName", "d>s", id, &this->m_jobNameTable[id]); } }; @@ -46,25 +47,25 @@ void JobNames::Initialize(JobNameInitialization& context) { "LIF_H", "AMISTR_H", "FILIR_H", "VANILMIRTH_H", "LIF_H2", "AMISTR_H2", "FILIR_H2", "VANILMIRTH_H2"}; for (unsigned index = 0; index < 16; ++index) { - this->names[JT_MER_LIF + index] = homunculi[index]; + this->m_jobNameTable[JT_MER_LIF + index] = homunculi[index]; } - this->names[JT_MER_EIRA] = "MER_EIRA"; - this->names[JT_MER_DIETER] = "MER_DIETER"; - this->names[JT_MER_BAYERI] = "MER_BAYERI"; - this->names[JT_MER_ELEANOR] = "MER_ELEANOR"; - this->names[JT_MER_SERA] = "MER_SERA"; + this->m_jobNameTable[JT_MER_EIRA] = "MER_EIRA"; + this->m_jobNameTable[JT_MER_DIETER] = "MER_DIETER"; + this->m_jobNameTable[JT_MER_BAYERI] = "MER_BAYERI"; + this->m_jobNameTable[JT_MER_ELEANOR] = "MER_ELEANOR"; + this->m_jobNameTable[JT_MER_SERA] = "MER_SERA"; for (unsigned id = JT_MER_ARCHER01; id <= JT_MER_ARCHER10; ++id) { - this->names[id] = "여\\활용병"; + this->m_jobNameTable[id] = "여\\활용병"; } for (unsigned id = JT_MER_LANCER01; id <= JT_MER_LANCER10; ++id) { - this->names[id] = "남\\창용병"; + this->m_jobNameTable[id] = "남\\창용병"; } for (unsigned id = JT_MER_SWORDMAN01; id <= JT_MER_SWORDMAN10; ++id) { - this->names[id] = "남\\검용병"; + this->m_jobNameTable[id] = "남\\검용병"; } context.sexLabels.resize(2, "F"); diff --git a/Source/Contents/Jobs/JobNames.cpp b/Source/Contents/Jobs/JobNames.cpp index e89fd49..fc03d3b 100644 --- a/Source/Contents/Jobs/JobNames.cpp +++ b/Source/Contents/Jobs/JobNames.cpp @@ -1,4 +1,5 @@ #include "Contents/Jobs/JobNames.h" +#include "Client/Session.h" #include "Contents/Jobs/JobId.h" // OFFSET: 0x00E2FE80 @@ -316,38 +317,34 @@ unsigned JobNames::BaseJob(unsigned job) { // OFFSET: 0x00DDE5C0 // FUNCTION: fn_23396 -const char* JobNames::Lookup(unsigned job, int sex) { - if (this->names.size() <= job) { +const char* CSession::GetJobName(unsigned job, int sex) { + if (this->m_jobNameTable.size() <= job) { return ""; } if (job - JT_NOVICE_H > unsigned(JT_MER_BEGIN - 1 - JT_NOVICE_H) && job > unsigned(JT_SUMMER2)) { - return this->names[job]; + return this->m_jobNameTable[job]; } - const unsigned base = BaseJob(job); + const unsigned base = JobNames::BaseJob(job); if (sex == -1) { - if (this->cachedSex != this->currentSex) { - this->cachedSex = this->currentSex; - } - - sex = this->currentSex; + sex = this->SyncUnknown0E98(); } if (sex == 0) { - const auto found = this->female.find(base); + const auto found = this->m_jobNameTableWoman.find(base); - if (found != this->female.end()) { + if (found != this->m_jobNameTableWoman.end()) { return found->second; } } else if (sex == 1) { - const auto found = this->male.find(base); + const auto found = this->m_jobNameTableMan.find(base); - if (found != this->male.end()) { + if (found != this->m_jobNameTableMan.end()) { return found->second; } } - return this->names[base]; + return this->m_jobNameTable[base]; } diff --git a/Source/Contents/Jobs/JobNames.h b/Source/Contents/Jobs/JobNames.h index f2f9556..589cc14 100644 --- a/Source/Contents/Jobs/JobNames.h +++ b/Source/Contents/Jobs/JobNames.h @@ -1,7 +1,6 @@ #ifndef RAGNAROK_SOURCE_CONTENTS_JOBS_JOBNAMES_H #define RAGNAROK_SOURCE_CONTENTS_JOBS_JOBNAMES_H -#include #include class LuaScript; @@ -17,15 +16,7 @@ struct JobNameInitialization { }; struct JobNames { - std::vector& names; - std::map& female; - std::map& male; - const int& currentSex; - int& cachedSex; - static unsigned BaseJob(unsigned job); - const char* Lookup(unsigned job, int sex); - void Initialize(JobNameInitialization& context); }; #endif diff --git a/Source/Contents/MonsterResources.cpp b/Source/Contents/MonsterResources.cpp index c4c8dd1..6674143 100644 --- a/Source/Contents/MonsterResources.cpp +++ b/Source/Contents/MonsterResources.cpp @@ -7,7 +7,7 @@ // OFFSET: 0x00E09AB0 // FUNCTION: fn_23788 std::string CSession::GetMonsterActName(int job) { - std::string name = FormatOwnedString("몬스터\\%s.act", this->m_jobNamesBegin[job]); + std::string name = FormatOwnedString("몬스터\\%s.act", this->m_jobNameTable[job]); if (!ResourceMgr::Instance().Exists(name.c_str())) { name = ""; } @@ -17,7 +17,7 @@ std::string CSession::GetMonsterActName(int job) { // OFFSET: 0x00E09DC0 // FUNCTION: fn_23790 std::string CSession::GetMonsterSprName(int job) { - std::string name = FormatOwnedString("몬스터\\%s.spr", this->m_jobNamesBegin[job]); + std::string name = FormatOwnedString("몬스터\\%s.spr", this->m_jobNameTable[job]); if (!ResourceMgr::Instance().Exists(name.c_str())) { name = ""; } diff --git a/Source/Contents/Sound/SoundMaker.cpp b/Source/Contents/Sound/SoundMaker.cpp index 8dce01c..5b423f0 100644 --- a/Source/Contents/Sound/SoundMaker.cpp +++ b/Source/Contents/Sound/SoundMaker.cpp @@ -19,7 +19,7 @@ // OFFSET: 0x00DA1E30 // FUNCTION: fn_22363 -CSoundMaker::CSoundMaker(ResourceMgr& resources, JobNames& names) : CRenderObject(resources, names) { +CSoundMaker::CSoundMaker() { this->file.clear(); this->volume = 100.0f; this->range = 1.0f; diff --git a/Source/Contents/Sound/SoundMaker.h b/Source/Contents/Sound/SoundMaker.h index 1b650fb..b83a397 100644 --- a/Source/Contents/Sound/SoundMaker.h +++ b/Source/Contents/Sound/SoundMaker.h @@ -7,7 +7,7 @@ class CSoundMaker : public CRenderObject { public: - CSoundMaker(ResourceMgr& resources, JobNames& names); + CSoundMaker(); ~CSoundMaker() override; bool Update() override; void SendObjectMessage( diff --git a/Source/Resource/Models/ModelResource.cpp b/Source/Resource/Models/ModelResource.cpp index 132c3d7..43a47a8 100644 --- a/Source/Resource/Models/ModelResource.cpp +++ b/Source/Resource/Models/ModelResource.cpp @@ -1,5 +1,5 @@ #include "Client/Application/ErrorDialog.h" -#include "Contents/Jobs/JobNames.h" +#include "Client/Session.h" #include "File/File.h" #include "File/ResourcePath.h" #include "Render/DeviceContext/DCSurface.h" @@ -681,7 +681,7 @@ granny_control* C3dGrannyModelRes::PlayAnimation(unsigned action, granny_model_i } if (action == 0) { - std::sprintf(g_modelPath, "model\\3dmob\\%s", this->m_context->jobNames.Lookup(g_animationJobs[job], -1)); + std::sprintf(g_modelPath, "model\\3dmob\\%s", g_session.GetJobName(g_animationJobs[job], -1)); } else { std::sprintf(g_modelPath, "model\\3dmob_bone\\%d_%s.gr2", job, g_animationNames[action]); } diff --git a/Source/Resource/Models/ModelResource.h b/Source/Resource/Models/ModelResource.h index 3bc522b..5c1ded1 100644 --- a/Source/Resource/Models/ModelResource.h +++ b/Source/Resource/Models/ModelResource.h @@ -12,7 +12,6 @@ class ResourceBytes; class TextureCache; -struct JobNames; struct ResourceByteReader; class C3dModelRes; @@ -96,7 +95,6 @@ struct ModelResourceContext { ResourceBytes& file; TextureCache& textures; CRenderSystemBase*& renderSystem; - JobNames& jobNames; }; class C3dModelRes : public CRes { diff --git a/Source/UI/Party/UIRequestJoinPartyWnd.cpp b/Source/UI/Party/UIRequestJoinPartyWnd.cpp index d6ec95b..8fa2d8a 100644 --- a/Source/UI/Party/UIRequestJoinPartyWnd.cpp +++ b/Source/UI/Party/UIRequestJoinPartyWnd.cpp @@ -1,5 +1,5 @@ #include "Client/Mode/ModeEvents.h" -#include "Contents/Jobs/JobNames.h" +#include "Client/Session.h" #include "Render/DeviceContext/DeviceContext.h" #include "Render/Text/TextContext.h" #include "Resource/Bitmap/BitmapResource.h" @@ -187,7 +187,7 @@ int UIRequestJoinPartyWnd::SendMsg(UIWindow* sender, int message, std::intptr_t this->icon->SetBitmap(path, state, 0); } - this->icon->SetTooltip(this->m_request->jobs.Lookup(static_cast(static_cast(this->job)), -1)); + this->icon->SetTooltip(g_session.GetJobName(static_cast(static_cast(this->job)), -1)); char level[5] = {}; _snprintf_s(level, sizeof(level), _TRUNCATE, "%d", this->level); this->levelText->SetText(level, 0); diff --git a/Source/UI/Party/UIRequestJoinPartyWnd.h b/Source/UI/Party/UIRequestJoinPartyWnd.h index 94e5220..b14cfc4 100644 --- a/Source/UI/Party/UIRequestJoinPartyWnd.h +++ b/Source/UI/Party/UIRequestJoinPartyWnd.h @@ -10,13 +10,11 @@ class UICheckBox; class UIStaticText; class UIBitmapButton; struct UITextViewerContext; -struct JobNames; struct PartyJoinRequest; class UIRequestJoinPartyMgr; struct UIRequestJoinPartyContext { UITextViewerContext& text; - JobNames& jobs; UIRequestJoinPartyMgr& requests; };