Compare commits

..

15 Commits

Author SHA1 Message Date
Tristan 'Natrist' Cormier
837a8eff41
Merge c12a79d6e6 into f1b8f495b6 2026-01-25 19:54:13 -05:00
fallenoak
f1b8f495b6
feat(ui): delete regions in CSimpleFrame dtor
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-01-25 15:05:10 -06:00
fallenoak
c2eedc1d47
feat(ui): clean up draw layers and batches in CSimpleFrame dtor 2026-01-25 14:50:16 -06:00
fallenoak
daba2a1ffd
feat(ui): delete title region in CSimpleFrame dtor 2026-01-25 14:40:28 -06:00
fallenoak
cded0d86e7
feat(ui): clear top pointer in CSimpleFrame dtor 2026-01-25 14:37:15 -06:00
fallenoak
4e9ea8f5a1
feat(ui): delete frames in CSimpleTop dtor 2026-01-25 13:40:19 -06:00
fallenoak
23be35bed2
feat(ui): delete strata in CSimpleTop dtor 2026-01-25 12:45:10 -06:00
fallenoak
1589466076
feat(ui): add proper ScriptIx dtor
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-01-24 22:48:09 -06:00
fallenoak
8d1316b163
chore: normalize signature checking logic between GlueXML and FrameXML 2026-01-24 20:58:04 -06:00
fallenoak
bdf0bd27a1
feat(ui): initialize game UI in ClientInitializeGame
Some checks failed
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) Has been cancelled
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) Has been cancelled
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) Has been cancelled
2026-01-23 21:17:43 -06:00
fallenoak
1f7aa984b0
chore(ui): move interface key to ui
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-01-23 15:23:55 -06:00
fallenoak
c5c2998efc
feat(world): add CWorld::AddObject
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-01-23 08:04:10 -06:00
fallenoak
948da084b0
feat(world): set mem handle when allocating entities
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-01-22 16:42:59 -06:00
fallenoak
fe06d5e820
feat(world): add CMap::AllocEntity 2026-01-22 16:06:48 -06:00
fallenoak
ba6f00d96c
feat(world): initialize map allocation heaps 2026-01-22 15:46:17 -06:00
32 changed files with 526 additions and 56 deletions

View File

@ -18,6 +18,7 @@
#include "sound/Interface.hpp"
#include "ui/FrameScript.hpp"
#include "ui/FrameXML.hpp"
#include "ui/Game.hpp"
#include "util/Random.hpp"
#include "world/World.hpp"
#include <bc/Debug.hpp>
@ -85,6 +86,10 @@ void ClientInitializeGame(uint32_t mapId, C3Vector position) {
// TODO
CGGameUI::InitializeGame();
// TODO
EventRegister(EVENT_ID_IDLE, ClientIdle);
// TODO

View File

@ -25,6 +25,7 @@
#include "ui/FrameScript.hpp"
#include "ui/FrameXML.hpp"
#include "ui/Interface.hpp"
#include "ui/Key.hpp"
#include "ui/ScriptFunctions.hpp"
#include "ui/game/CGVideoOptions.hpp"
#include "ui/simple/CSimpleModelFFX.hpp"
@ -36,25 +37,6 @@
#include <common/MD5.hpp>
#include <cstdio>
unsigned char InterfaceKey[256] = {
0xC3, 0x5B, 0x50, 0x84, 0xB9, 0x3E, 0x32, 0x42, 0x8C, 0xD0, 0xC7, 0x48, 0xFA, 0x0E, 0x5D, 0x54,
0x5A, 0xA3, 0x0E, 0x14, 0xBA, 0x9E, 0x0D, 0xB9, 0x5D, 0x8B, 0xEE, 0xB6, 0x84, 0x93, 0x45, 0x75,
0xFF, 0x31, 0xFE, 0x2F, 0x64, 0x3F, 0x3D, 0x6D, 0x07, 0xD9, 0x44, 0x9B, 0x40, 0x85, 0x59, 0x34,
0x4E, 0x10, 0xE1, 0xE7, 0x43, 0x69, 0xEF, 0x7C, 0x16, 0xFC, 0xB4, 0xED, 0x1B, 0x95, 0x28, 0xA8,
0x23, 0x76, 0x51, 0x31, 0x57, 0x30, 0x2B, 0x79, 0x08, 0x50, 0x10, 0x1C, 0x4A, 0x1A, 0x2C, 0xC8,
0x8B, 0x8F, 0x05, 0x2D, 0x22, 0x3D, 0xDB, 0x5A, 0x24, 0x7A, 0x0F, 0x13, 0x50, 0x37, 0x8F, 0x5A,
0xCC, 0x9E, 0x04, 0x44, 0x0E, 0x87, 0x01, 0xD4, 0xA3, 0x15, 0x94, 0x16, 0x34, 0xC6, 0xC2, 0xC3,
0xFB, 0x49, 0xFE, 0xE1, 0xF9, 0xDA, 0x8C, 0x50, 0x3C, 0xBE, 0x2C, 0xBB, 0x57, 0xED, 0x46, 0xB9,
0xAD, 0x8B, 0xC6, 0xDF, 0x0E, 0xD6, 0x0F, 0xBE, 0x80, 0xB3, 0x8B, 0x1E, 0x77, 0xCF, 0xAD, 0x22,
0xCF, 0xB7, 0x4B, 0xCF, 0xFB, 0xF0, 0x6B, 0x11, 0x45, 0x2D, 0x7A, 0x81, 0x18, 0xF2, 0x92, 0x7E,
0x98, 0x56, 0x5D, 0x5E, 0x69, 0x72, 0x0A, 0x0D, 0x03, 0x0A, 0x85, 0xA2, 0x85, 0x9C, 0xCB, 0xFB,
0x56, 0x6E, 0x8F, 0x44, 0xBB, 0x8F, 0x02, 0x22, 0x68, 0x63, 0x97, 0xBC, 0x85, 0xBA, 0xA8, 0xF7,
0xB5, 0x40, 0x68, 0x3C, 0x77, 0x86, 0x6F, 0x4B, 0xD7, 0x88, 0xCA, 0x8A, 0xD7, 0xCE, 0x36, 0xF0,
0x45, 0x6E, 0xD5, 0x64, 0x79, 0x0F, 0x17, 0xFC, 0x64, 0xDD, 0x10, 0x6F, 0xF3, 0xF5, 0xE0, 0xA6,
0xC3, 0xFB, 0x1B, 0x8C, 0x29, 0xEF, 0x8E, 0xE5, 0x34, 0xCB, 0xD1, 0x2A, 0xCE, 0x79, 0xC3, 0x9A,
0x0D, 0x36, 0xEA, 0x01, 0xE0, 0xAA, 0x91, 0x20, 0x54, 0xF0, 0x72, 0xD8, 0x1E, 0xC7, 0x89, 0xD2
};
int32_t CGlueMgr::m_acceptedEULA = 1; // TODO
int32_t CGlueMgr::m_acceptedTerminationWithoutNotice;
int32_t CGlueMgr::m_acceptedTOS = 1; // TODO
@ -1005,51 +987,53 @@ void CGlueMgr::Resume() {
DeleteInterfaceFiles();
MD5_CTX md5;
unsigned char digest1[16];
unsigned char digest2[16];
uint8_t digest1[16];
int32_t v8;
unsigned char* v9;
unsigned char* v10;
MD5Init(&md5);
switch (FrameXML_CheckSignature("Interface\\GlueXML\\GlueXML.toc", 0, InterfaceKey, digest1)) {
case 0:
switch (FrameXML_CheckSignature("Interface\\GlueXML\\GlueXML.toc", nullptr, InterfaceKey, digest1)) {
case 0: {
status.Add(STATUS_WARNING, "GlueXML missing signature");
ClientPostClose(9);
return;
case 1:
return;
}
case 1: {
status.Add(STATUS_WARNING, "GlueXML has corrupt signature");
ClientPostClose(9);
return;
case 2:
return;
}
case 2: {
status.Add(STATUS_WARNING, "GlueXML is modified or corrupt");
ClientPostClose(9);
return;
}
case 3:
FrameXML_FreeHashNodes();
FrameXML_CreateFrames("Interface\\GlueXML\\GlueXML.toc", 0, &md5, &status);
MD5Final(digest2, &md5);
v8 = 16;
v9 = digest2;
v10 = digest1;
case 3: {
// Success
break;
}
default:
default: {
ClientPostClose(9);
return;
}
}
// TODO
// - some kind of digest validation?
MD5_CTX md5;
MD5Init(&md5);
FrameXML_FreeHashNodes();
FrameXML_CreateFrames("Interface\\GlueXML\\GlueXML.toc", nullptr, &md5, &status);
uint8_t digest2[16];
MD5Final(digest2, &md5);
// TODO digest validation
FrameScript_SignalEvent(22, nullptr);

View File

@ -5,6 +5,12 @@
int32_t FrameScript_Object::s_objectTypes = 0;
FrameScript_Object::ScriptIx::~ScriptIx() {
if (this->luaRef) {
luaL_unref(FrameScript_GetContext(), LUA_REGISTRYINDEX, this->luaRef);
}
}
int32_t FrameScript_Object::CreateScriptMetaTable(lua_State* L, void (*a2)(lua_State* L)) {
lua_createtable(L, 0, 0);
lua_pushstring(L, "__index");
@ -24,12 +30,6 @@ void FrameScript_Object::FillScriptMethodTable(lua_State *L, FrameScript_Method
}
}
FrameScript_Object::~FrameScript_Object() {
if (this->m_onEvent.luaRef) {
luaL_unref(FrameScript_GetContext(), LUA_REGISTRYINDEX, this->m_onEvent.luaRef);
}
}
const char* FrameScript_Object::GetDisplayName() {
const char* name = this->GetName();
return name ? name : "<unnamed>";

View File

@ -14,6 +14,7 @@ class FrameScript_Object {
struct ScriptIx {
int32_t luaRef = 0;
const char* unk = nullptr;
~ScriptIx();
};
class ScriptFunction {
@ -34,7 +35,7 @@ class FrameScript_Object {
ScriptIx m_onEvent;
// Virtual member functions
virtual ~FrameScript_Object();
virtual ~FrameScript_Object() = default;
virtual char* GetName() = 0;
virtual int32_t GetScriptMetaTable() = 0;
virtual ScriptIx* GetScriptByName(const char* name, ScriptData& data);

6
src/ui/Game.hpp Normal file
View File

@ -0,0 +1,6 @@
#ifndef UI_GAME_HPP
#define UI_GAME_HPP
#include "ui/game/CGGameUI.hpp"
#endif

20
src/ui/Key.cpp Normal file
View File

@ -0,0 +1,20 @@
#include "ui/Key.hpp"
uint8_t InterfaceKey[256] = {
0xC3, 0x5B, 0x50, 0x84, 0xB9, 0x3E, 0x32, 0x42, 0x8C, 0xD0, 0xC7, 0x48, 0xFA, 0x0E, 0x5D, 0x54,
0x5A, 0xA3, 0x0E, 0x14, 0xBA, 0x9E, 0x0D, 0xB9, 0x5D, 0x8B, 0xEE, 0xB6, 0x84, 0x93, 0x45, 0x75,
0xFF, 0x31, 0xFE, 0x2F, 0x64, 0x3F, 0x3D, 0x6D, 0x07, 0xD9, 0x44, 0x9B, 0x40, 0x85, 0x59, 0x34,
0x4E, 0x10, 0xE1, 0xE7, 0x43, 0x69, 0xEF, 0x7C, 0x16, 0xFC, 0xB4, 0xED, 0x1B, 0x95, 0x28, 0xA8,
0x23, 0x76, 0x51, 0x31, 0x57, 0x30, 0x2B, 0x79, 0x08, 0x50, 0x10, 0x1C, 0x4A, 0x1A, 0x2C, 0xC8,
0x8B, 0x8F, 0x05, 0x2D, 0x22, 0x3D, 0xDB, 0x5A, 0x24, 0x7A, 0x0F, 0x13, 0x50, 0x37, 0x8F, 0x5A,
0xCC, 0x9E, 0x04, 0x44, 0x0E, 0x87, 0x01, 0xD4, 0xA3, 0x15, 0x94, 0x16, 0x34, 0xC6, 0xC2, 0xC3,
0xFB, 0x49, 0xFE, 0xE1, 0xF9, 0xDA, 0x8C, 0x50, 0x3C, 0xBE, 0x2C, 0xBB, 0x57, 0xED, 0x46, 0xB9,
0xAD, 0x8B, 0xC6, 0xDF, 0x0E, 0xD6, 0x0F, 0xBE, 0x80, 0xB3, 0x8B, 0x1E, 0x77, 0xCF, 0xAD, 0x22,
0xCF, 0xB7, 0x4B, 0xCF, 0xFB, 0xF0, 0x6B, 0x11, 0x45, 0x2D, 0x7A, 0x81, 0x18, 0xF2, 0x92, 0x7E,
0x98, 0x56, 0x5D, 0x5E, 0x69, 0x72, 0x0A, 0x0D, 0x03, 0x0A, 0x85, 0xA2, 0x85, 0x9C, 0xCB, 0xFB,
0x56, 0x6E, 0x8F, 0x44, 0xBB, 0x8F, 0x02, 0x22, 0x68, 0x63, 0x97, 0xBC, 0x85, 0xBA, 0xA8, 0xF7,
0xB5, 0x40, 0x68, 0x3C, 0x77, 0x86, 0x6F, 0x4B, 0xD7, 0x88, 0xCA, 0x8A, 0xD7, 0xCE, 0x36, 0xF0,
0x45, 0x6E, 0xD5, 0x64, 0x79, 0x0F, 0x17, 0xFC, 0x64, 0xDD, 0x10, 0x6F, 0xF3, 0xF5, 0xE0, 0xA6,
0xC3, 0xFB, 0x1B, 0x8C, 0x29, 0xEF, 0x8E, 0xE5, 0x34, 0xCB, 0xD1, 0x2A, 0xCE, 0x79, 0xC3, 0x9A,
0x0D, 0x36, 0xEA, 0x01, 0xE0, 0xAA, 0x91, 0x20, 0x54, 0xF0, 0x72, 0xD8, 0x1E, 0xC7, 0x89, 0xD2
};

8
src/ui/Key.hpp Normal file
View File

@ -0,0 +1,8 @@
#ifndef UI_KEY_HPP
#define UI_KEY_HPP
#include <cstdint>
extern uint8_t InterfaceKey[256];
#endif

94
src/ui/game/CGGameUI.cpp Normal file
View File

@ -0,0 +1,94 @@
#include "ui/game/CGGameUI.hpp"
#include "client/Client.hpp"
#include "ui/FrameXML.hpp"
#include "ui/Key.hpp"
#include "ui/game/CGWorldFrame.hpp"
#include "ui/simple/CSimpleTop.hpp"
#include "util/CStatus.hpp"
#include <common/MD5.hpp>
CSimpleTop* CGGameUI::s_simpleTop;
void CGGameUI::Initialize() {
// TODO
CGGameUI::s_simpleTop = STORM_NEW(CSimpleTop);
// TODO
CGGameUI::RegisterFrameFactories();
// TODO
CStatus status;
// TODO
uint8_t digest1[16];
switch (FrameXML_CheckSignature("Interface\\FrameXML\\FrameXML.toc", "Interface\\FrameXML\\Bindings.xml", InterfaceKey, digest1)) {
case 0: {
status.Add(STATUS_WARNING, "FrameXML missing signature");
ClientPostClose(10);
break;
}
case 1: {
status.Add(STATUS_WARNING, "FrameXML has corrupt signature");
ClientPostClose(10);
break;
}
case 2: {
status.Add(STATUS_WARNING, "FrameXML is modified or corrupt");
ClientPostClose(10);
break;
}
case 3: {
// Success
break;
}
default: {
ClientPostClose(10);
break;
}
}
MD5_CTX md5;
MD5Init(&md5);
// TODO file count and progress bar logic
FrameXML_FreeHashNodes();
FrameXML_CreateFrames("Interface\\FrameXML\\FrameXML.toc", nullptr, &md5, &status);
// TODO CGUIBindings::s_bindings->Load("Interface\\FrameXML\\Bindings.xml", &md5, &status);
uint8_t digest2[16];
MD5Final(digest2, &md5);
// TODO digest validation
// TODO
}
void CGGameUI::InitializeGame() {
// TODO
CGGameUI::Initialize();
// TODO
}
void CGGameUI::RegisterFrameFactories() {
FrameXML_RegisterFactory("WorldFrame", &CGWorldFrame::Create, true);
// TODO register remaining factories
}

17
src/ui/game/CGGameUI.hpp Normal file
View File

@ -0,0 +1,17 @@
#ifndef UI_GAME_C_G_GAME_UI_HPP
#define UI_GAME_C_G_GAME_UI_HPP
class CSimpleTop;
class CGGameUI {
public:
// Static variables
static CSimpleTop* s_simpleTop;
// Static functions
static void Initialize();
static void InitializeGame();
static void RegisterFrameFactories();
};
#endif

View File

@ -0,0 +1,22 @@
#include "ui/game/CGWorldFrame.hpp"
#include <storm/Memory.hpp>
CSimpleFrame* CGWorldFrame::Create(CSimpleFrame* parent) {
// TODO use CDataAllocator
return STORM_NEW(CGWorldFrame)(parent);
}
CGWorldFrame::CGWorldFrame(CSimpleFrame* parent) : CSimpleFrame(parent) {
// TODO
CGWorldFrame::s_currentWorldFrame = this;
// TODO
this->EnableEvent(SIMPLE_EVENT_KEY, -1);
this->EnableEvent(SIMPLE_EVENT_MOUSE, -1);
this->EnableEvent(SIMPLE_EVENT_MOUSEWHEEL, -1);
// TODO
}

View File

@ -0,0 +1,19 @@
#ifndef UI_GAME_C_G_WORLD_FRAME_HPP
#define UI_GAME_C_G_WORLD_FRAME_HPP
#include "ui/simple/CSimpleFrame.hpp"
#include <cstdint>
class CGWorldFrame : public CSimpleFrame {
public:
// Static variables
CGWorldFrame* s_currentWorldFrame;
// Static functions
static CSimpleFrame* Create(CSimpleFrame* parent);
// Member functions
CGWorldFrame(CSimpleFrame* parent);
};
#endif

View File

@ -64,11 +64,27 @@ CSimpleFrame::CSimpleFrame(CSimpleFrame* parent) : CScriptRegion() {
}
CSimpleFrame::~CSimpleFrame() {
// TODO
this->m_intAC = 3;
this->m_top->UnregisterFrame(this);
this->m_top = nullptr;
if (this->m_titleRegion) {
delete this->m_titleRegion;
}
for (int32_t layer = 0; layer < NUM_SIMPLEFRAME_DRAWLAYERS; layer++) {
this->m_drawlayers[layer].UnlinkAll();
if (this->m_batch[layer]) {
delete this->m_batch[layer];
}
}
while (auto region = this->m_regions.Head()) {
this->m_regions.UnlinkNode(region);
delete region;
}
// TODO
}

View File

@ -400,6 +400,18 @@ CSimpleTop::CSimpleTop() : CLayoutFrame() {
CSimpleTop::~CSimpleTop() {
// TODO
while (auto frame = this->m_frames.Head()) {
this->m_frames.UnlinkNode(frame);
delete frame;
}
for (auto& strata : this->m_strata) {
delete strata;
strata = nullptr;
}
// TODO
this->DisableEvents();
HandleClose(this->m_screenLayer);

View File

@ -17,6 +17,35 @@ uint32_t CWorld::s_tickTimeMs;
float CWorld::s_tickTimeSec;
Weather* CWorld::s_weather;
HWORLDOBJECT CWorld::AddObject(CM2Model* model, void* handler, void* handlerParam, uint64_t param64, uint32_t param32, uint32_t objFlags) {
auto entity = CMap::AllocEntity(objFlags & 0x8 ? true : false);
entity->m_model = model;
entity->m_param64 = param64;
entity->m_param32 = param32;
// TODO
entity->m_dirLightScale = 1.0f;
entity->m_dirLightScaleTarget = 1.0f;
// TODO
entity->m_type |= CMapBaseObj::Type_200;
// TODO
entity->m_flags = 0x0;
if (objFlags & 0x20) {
entity->m_flags = 0x20000;
}
// TODO
return reinterpret_cast<HWORLDOBJECT>(entity);
}
uint32_t CWorld::GetCurTimeMs() {
return CWorld::s_curTimeMs;
}
@ -88,6 +117,10 @@ void CWorld::Initialize() {
// TODO
CMap::Initialize();
// TODO
CWorld::s_weather = STORM_NEW(Weather);
// TODO

View File

@ -2,9 +2,11 @@
#define WORLD_C_WORLD_HPP
#include "event/Event.hpp"
#include "world/Types.hpp"
#include <tempest/Vector.hpp>
#include <cstdint>
class CM2Model;
class Weather;
class CWorld {
@ -51,6 +53,7 @@ class CWorld {
static Weather* s_weather;
// Public static functions
static HWORLDOBJECT AddObject(CM2Model* model, void* handler, void* handlerParam, uint64_t param64, uint32_t param32, uint32_t objFlags);
static uint32_t GetCurTimeMs();
static float GetCurTimeSec();
static uint32_t GetGameTimeFixed();

View File

@ -0,0 +1,9 @@
#ifndef WORLD_MAP_C_CHUNK_LIQUID_HPP
#define WORLD_MAP_C_CHUNK_LIQUID_HPP
class CChunkLiquid {
public:
// TODO
};
#endif

View File

@ -1,11 +1,66 @@
#include "world/map/CMap.hpp"
#include "world/map/CChunkLiquid.hpp"
#include "world/map/CMapArea.hpp"
#include "world/map/CMapAreaLow.hpp"
#include "world/map/CMapCacheLight.hpp"
#include "world/map/CMapChunk.hpp"
#include "world/map/CMapDoodadDef.hpp"
#include "world/map/CMapEntity.hpp"
#include "world/map/CMapLight.hpp"
#include "world/map/CMapObj.hpp"
#include "world/map/CMapObjDef.hpp"
#include "world/map/CMapObjDefGroup.hpp"
#include "world/map/CMapObjGroup.hpp"
#include <common/ObjectAlloc.hpp>
#include <storm/String.hpp>
uint32_t* CMap::s_areaHeap;
uint32_t* CMap::s_areaLowHeap;
uint32_t* CMap::s_baseObjLinkHeap;
uint32_t* CMap::s_cacheLightHeap;
uint32_t* CMap::s_chunkHeap;
uint32_t* CMap::s_chunkLiquidHeap;
uint32_t* CMap::s_doodadDefHeap;
uint32_t* CMap::s_entityHeap;
STORM_EXPLICIT_LIST(CMapBaseObj, m_lameAssLink) CMap::s_entityList;
uint32_t* CMap::s_lightHeap;
uint32_t* CMap::s_mapObjDefGroupHeap;
uint32_t* CMap::s_mapObjDefHeap;
uint32_t* CMap::s_mapObjGroupHeap;
uint32_t* CMap::s_mapObjHeap;
char CMap::s_mapName[256];
char CMap::s_mapPath[256];
char CMap::s_wdtFilename[256];
CMapEntity* CMap::AllocEntity(int32_t a1) {
CMapEntity* entity;
uint32_t memHandle;
void* mem = nullptr;
if (ObjectAlloc(*CMap::s_entityHeap, &memHandle, &mem, false)) {
entity = new (mem) CMapEntity();
entity->m_memHandle = memHandle;
} else {
entity = nullptr;
}
if (a1) {
CMap::s_entityList.LinkToHead(entity);
} else {
CMap::s_entityList.LinkToTail(entity);
}
return entity;
}
void CMap::Initialize() {
// TODO
CMap::MapMemInitialize();
// TODO
}
void CMap::Load(const char* mapName, int32_t zoneID) {
// TODO
@ -18,3 +73,20 @@ void CMap::Load(const char* mapName, int32_t zoneID) {
// TODO
}
void CMap::MapMemInitialize() {
CMap::s_lightHeap = STORM_NEW(uint32_t)(ObjectAllocAddHeap(sizeof(CMapLight), 128, "WLIGHT", true));
CMap::s_cacheLightHeap = STORM_NEW(uint32_t)(ObjectAllocAddHeap(sizeof(CMapCacheLight), 256, "WCACHELIGHT", true));
CMap::s_mapObjGroupHeap = STORM_NEW(uint32_t)(ObjectAllocAddHeap(sizeof(CMapObjGroup), 128, "WMAPOBJGROUP", true));
CMap::s_mapObjHeap = STORM_NEW(uint32_t)(ObjectAllocAddHeap(sizeof(CMapObj), 32, "WMAPOBJ", true));
CMap::s_baseObjLinkHeap = STORM_NEW(uint32_t)(ObjectAllocAddHeap(sizeof(CMapBaseObjLink), 10000, "WBASEOBJLINK", true));
CMap::s_areaHeap = STORM_NEW(uint32_t)(ObjectAllocAddHeap(sizeof(CMapArea), 16, "WAREA", true));
// CMap::s_areaMedHeap = STORM_NEW(uint32_t)(ObjectAllocAddHeap(sizeof(CMapAreaMed), 16, "WAREAMED", true)); ??
CMap::s_areaLowHeap = STORM_NEW(uint32_t)(ObjectAllocAddHeap(sizeof(CMapAreaLow), 16, "WAREALOW", true));
CMap::s_chunkHeap = STORM_NEW(uint32_t)(ObjectAllocAddHeap(sizeof(CMapChunk), 256, "WCHUNK", true));
CMap::s_doodadDefHeap = STORM_NEW(uint32_t)(ObjectAllocAddHeap(sizeof(CMapDoodadDef), 5000, "WDOODADDEF", true));
CMap::s_entityHeap = STORM_NEW(uint32_t)(ObjectAllocAddHeap(sizeof(CMapEntity), 128, "WENTITY", true));
CMap::s_mapObjDefGroupHeap = STORM_NEW(uint32_t)(ObjectAllocAddHeap(sizeof(CMapObjDefGroup), 128, "WMAPOBJDEFGROUP", true));
CMap::s_mapObjDefHeap = STORM_NEW(uint32_t)(ObjectAllocAddHeap(sizeof(CMapObjDef), 64, "WMAPOBJDEF", true));
CMap::s_chunkLiquidHeap = STORM_NEW(uint32_t)(ObjectAllocAddHeap(sizeof(CChunkLiquid), 64, "WCHUNKLIQUID", true));
}

View File

@ -2,19 +2,36 @@
#define WORLD_MAP_C_MAP_HPP
#include "world/map/CMapBaseObj.hpp"
#include "world/map/CMapEntity.hpp"
#include <storm/List.hpp>
#include <cstdint>
class CMap {
public:
// Static variables
static uint32_t* s_areaHeap;
static uint32_t* s_areaLowHeap;
static uint32_t* s_baseObjLinkHeap;
static uint32_t* s_cacheLightHeap;
static uint32_t* s_chunkHeap;
static uint32_t* s_chunkLiquidHeap;
static uint32_t* s_doodadDefHeap;
static uint32_t* s_entityHeap;
static STORM_EXPLICIT_LIST(CMapBaseObj, m_lameAssLink) s_entityList;
static uint32_t* s_lightHeap;
static uint32_t* s_mapObjDefGroupHeap;
static uint32_t* s_mapObjDefHeap;
static uint32_t* s_mapObjGroupHeap;
static uint32_t* s_mapObjHeap;
static char s_mapName[];
static char s_mapPath[];
static char s_wdtFilename[];
// Static functions
static CMapEntity* AllocEntity(int32_t a1);
static void Initialize();
static void Load(const char* mapName, int32_t zoneID);
static void MapMemInitialize();
};
#endif

View File

@ -0,0 +1,11 @@
#ifndef WORLD_MAP_C_MAP_AREA_HPP
#define WORLD_MAP_C_MAP_AREA_HPP
#include "world/map/CMapBaseObj.hpp"
class CMapArea : public CMapBaseObj {
public:
// TODO
};
#endif

View File

@ -0,0 +1,9 @@
#ifndef WORLD_MAP_C_MAP_AREA_LOW_HPP
#define WORLD_MAP_C_MAP_AREA_LOW_HPP
class CMapAreaLow {
public:
// TODO
};
#endif

View File

@ -18,6 +18,9 @@ class CMapBaseObjLink {
};
class CMapBaseObj {
friend class CMap;
friend class CWorld;
public:
// Enums
enum {
@ -29,10 +32,13 @@ class CMapBaseObj {
Type_Entity = 0x20,
Type_DoodadDef = 0x40,
Type_Light = 0x80,
Type_100 = 0x100,
Type_200 = 0x200,
};
// Public member variables
uint32_t m_memHandle;
uint32_t m_flags = 0x0;
TSLink<CMapBaseObj> m_lameAssLink;
STORM_EXPLICIT_LIST(CMapBaseObjLink, ownerLink) m_parentLinkList;

View File

@ -0,0 +1,9 @@
#ifndef WORLD_MAP_C_MAP_CACHE_LIGHT_HPP
#define WORLD_MAP_C_MAP_CACHE_LIGHT_HPP
class CMapCacheLight {
public:
// TODO
};
#endif

View File

@ -0,0 +1,11 @@
#ifndef WORLD_MAP_C_MAP_CHUNK_HPP
#define WORLD_MAP_C_MAP_CHUNK_HPP
#include "world/map/CMapBaseObj.hpp"
class CMapChunk : public CMapBaseObj {
public:
// TODO
};
#endif

View File

@ -0,0 +1,11 @@
#ifndef WORLD_MAP_C_MAP_DOODAD_DEF_HPP
#define WORLD_MAP_C_MAP_DOODAD_DEF_HPP
#include "world/map/CMapStaticEntity.hpp"
class CMapDoodadDef : public CMapStaticEntity {
public:
// TODO
};
#endif

View File

@ -0,0 +1,5 @@
#include "world/map/CMapEntity.hpp"
CMapEntity::CMapEntity() {
this->m_type |= CMapBaseObj::Type_Entity;
}

View File

@ -2,10 +2,22 @@
#define WORLD_MAP_C_MAP_ENTITY_HPP
#include "world/map/CMapStaticEntity.hpp"
#include <tempest/Vector.hpp>
class CMapEntity : public CMapStaticEntity {
public:
// Member variables
void* m_handler = nullptr;
void* m_handlerParam = nullptr;
uint64_t m_param64 = 0;
uint32_t m_param32 = 0;
// TODO
CImVector m_ambientTarget = { 0xFF, 0x00, 0x00, 0x00 };
float m_dirLightScaleTarget = 0.0f;
// TODO
// Member functions
CMapEntity();
};
#endif

View File

@ -0,0 +1,11 @@
#ifndef WORLD_MAP_C_MAP_LIGHT_HPP
#define WORLD_MAP_C_MAP_LIGHT_HPP
#include "world/map/CMapBaseObj.hpp"
class CMapLight : public CMapBaseObj {
public:
// TODO
};
#endif

View File

@ -0,0 +1,9 @@
#ifndef WORLD_MAP_C_MAP_OBJ_HPP
#define WORLD_MAP_C_MAP_OBJ_HPP
class CMapObj {
public:
// TODO
};
#endif

View File

@ -0,0 +1,11 @@
#ifndef WORLD_MAP_C_MAP_OBJ_DEF_HPP
#define WORLD_MAP_C_MAP_OBJ_DEF_HPP
#include "world/map/CMapBaseObj.hpp"
class CMapObjDef : public CMapBaseObj {
public:
// TODO
};
#endif

View File

@ -0,0 +1,9 @@
#ifndef WORLD_MAP_C_MAP_OBJ_DEF_GROUP_HPP
#define WORLD_MAP_C_MAP_OBJ_DEF_GROUP_HPP
class CMapObjDefGroup : public CMapBaseObj {
public:
// TODO
};
#endif

View File

@ -0,0 +1,9 @@
#ifndef WORLD_MAP_C_MAP_OBJ_GROUP_HPP
#define WORLD_MAP_C_MAP_OBJ_GROUP_HPP
class CMapObjGroup {
public:
// TODO
};
#endif

View File

@ -2,10 +2,19 @@
#define WORLD_MAP_C_MAP_STATIC_ENTITY_HPP
#include "world/map/CMapBaseObj.hpp"
#include <tempest/Vector.hpp>
class CM2Model;
class CMapStaticEntity : public CMapBaseObj {
public:
// Member variables
// TODO
CM2Model* m_model = nullptr;
// TODO
CImVector m_ambient = {};
CImVector m_interiorDirColor = {};
float m_dirLightScale = 0.0f;
};
#endif