mirror of
https://github.com/thunderbrewhq/thunderbrew
synced 2025-12-12 11:12:29 +00:00
feat(world): add skeleton for DayNight system
This commit is contained in:
parent
4418c789f9
commit
35e44e0976
14 changed files with 197 additions and 18 deletions
|
|
@ -808,5 +808,12 @@ void ClientInitializeGame(int32_t continentID, const C3Vector& position) {
|
||||||
ClientServices::SetMessageHandler(SMSG_NEW_WORLD, &NewWorldHandler, nullptr);
|
ClientServices::SetMessageHandler(SMSG_NEW_WORLD, &NewWorldHandler, nullptr);
|
||||||
ClientServices::SetMessageHandler(SMSG_LOGIN_VERIFY_WORLD, &LoginVerifyWorldHandler, nullptr);
|
ClientServices::SetMessageHandler(SMSG_LOGIN_VERIFY_WORLD, &LoginVerifyWorldHandler, nullptr);
|
||||||
|
|
||||||
|
auto record = g_mapDB.GetRecord(continentID);
|
||||||
|
if (!record) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
CWorld::LoadMap(record->m_directory, position, continentID);
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,12 +5,8 @@
|
||||||
|
|
||||||
#include "console/Console.hpp"
|
#include "console/Console.hpp"
|
||||||
#include "world/World.hpp"
|
#include "world/World.hpp"
|
||||||
|
#include "db/Db.hpp"
|
||||||
|
#include "event/Timer.hpp"
|
||||||
uint32_t s_newZoneID = 0;
|
|
||||||
C3Vector s_newPosition;
|
|
||||||
float s_newFacing = 0.0f;
|
|
||||||
const char* s_newMapname = nullptr;
|
|
||||||
|
|
||||||
|
|
||||||
int32_t NewWorldHandler(void* param, NETMESSAGE msgId, uint32_t time, CDataStore* msg) {
|
int32_t NewWorldHandler(void* param, NETMESSAGE msgId, uint32_t time, CDataStore* msg) {
|
||||||
|
|
@ -23,7 +19,16 @@ int32_t NewWorldHandler(void* param, NETMESSAGE msgId, uint32_t time, CDataStore
|
||||||
msg->Get(s_newFacing);
|
msg->Get(s_newFacing);
|
||||||
|
|
||||||
if (msg->IsRead()) {
|
if (msg->IsRead()) {
|
||||||
// TODO
|
auto record = g_mapDB.GetRecord(s_newZoneID);
|
||||||
|
if (!record) {
|
||||||
|
ConsoleWrite("Bad SMSG_NEW_WORLD zoneID\n", DEFAULT_COLOR);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
s_newMapname = record->m_directory;
|
||||||
|
// TODO: EventSetTimer(0, LoadNewWorld, 1);
|
||||||
|
// WORKAROUND:
|
||||||
|
LoadNewWorld(nullptr);
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
ConsoleWrite("Bad SMSG_NEW_WORLD\n", DEFAULT_COLOR);
|
ConsoleWrite("Bad SMSG_NEW_WORLD\n", DEFAULT_COLOR);
|
||||||
|
|
@ -45,17 +50,19 @@ int32_t LoginVerifyWorldHandler(void* param, NETMESSAGE msgId, uint32_t time, CD
|
||||||
|
|
||||||
float facing;
|
float facing;
|
||||||
msg->Get(facing);
|
msg->Get(facing);
|
||||||
// zoneID != ClntObjMgrGetMapID()
|
|
||||||
if (false) {
|
if (false /* zoneID != ClntObjMgrGetMapID() */) {
|
||||||
s_newFacing = facing;
|
s_newFacing = facing;
|
||||||
s_newPosition = position;
|
s_newPosition = position;
|
||||||
s_newZoneID = zoneID;
|
s_newZoneID = zoneID;
|
||||||
//if (zoneID < dword_AD4170 || zoneID > dword_AD416C || (v0 = *(_DWORD*)(dword_AD4180 + 4 * (zoneID - dword_AD4170))) == 0) {
|
auto record = g_mapDB.GetRecord(s_newZoneID);
|
||||||
// ConsoleWrite("Bad SMSG_NEW_WORLD zoneID\n", 0);
|
if (!record) {
|
||||||
// return 0;
|
ConsoleWrite("Bad SMSG_NEW_WORLD zoneID\n", DEFAULT_COLOR);
|
||||||
//}
|
return 0;
|
||||||
//s_newMapname = *(_DWORD*)(v0 + 4);
|
}
|
||||||
LoadNewWorld();
|
|
||||||
|
s_newMapname = record->m_directory;
|
||||||
|
LoadNewWorld(nullptr);
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
#include "gx/Transform.hpp"
|
#include "gx/Transform.hpp"
|
||||||
#include "gx/Draw.hpp"
|
#include "gx/Draw.hpp"
|
||||||
#include "gx/Shader.hpp"
|
#include "gx/Shader.hpp"
|
||||||
|
#include "world/CWorld.hpp"
|
||||||
|
|
||||||
#include <bc/Memory.hpp>
|
#include <bc/Memory.hpp>
|
||||||
#include <tempest/Matrix.hpp>
|
#include <tempest/Matrix.hpp>
|
||||||
|
|
@ -62,4 +63,5 @@ void CGWorldFrame::OnWorldUpdate() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CGWorldFrame::OnWorldRender() {
|
void CGWorldFrame::OnWorldRender() {
|
||||||
|
CWorld::Render();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,8 @@
|
||||||
file(GLOB PRIVATE_SOURCES "*.cpp")
|
file(GLOB PRIVATE_SOURCES
|
||||||
|
"daynight/*.cpp"
|
||||||
|
"map/*.cpp"
|
||||||
|
"*.cpp"
|
||||||
|
)
|
||||||
|
|
||||||
add_library(world STATIC
|
add_library(world STATIC
|
||||||
${PRIVATE_SOURCES}
|
${PRIVATE_SOURCES}
|
||||||
|
|
@ -13,4 +17,9 @@ target_link_libraries(world
|
||||||
PRIVATE
|
PRIVATE
|
||||||
gx
|
gx
|
||||||
model
|
model
|
||||||
|
PUBLIC
|
||||||
|
bc
|
||||||
|
common
|
||||||
|
storm
|
||||||
|
tempest
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,8 @@
|
||||||
#include "gx/Device.hpp"
|
#include "gx/Device.hpp"
|
||||||
#include "gx/Shader.hpp"
|
#include "gx/Shader.hpp"
|
||||||
#include "model/Model2.hpp"
|
#include "model/Model2.hpp"
|
||||||
|
#include "world/map/CMap.hpp"
|
||||||
|
#include "world/daynight/DayNight.hpp"
|
||||||
|
|
||||||
uint32_t CWorld::s_enables;
|
uint32_t CWorld::s_enables;
|
||||||
uint32_t CWorld::s_enables2;
|
uint32_t CWorld::s_enables2;
|
||||||
|
|
@ -42,3 +44,11 @@ void CWorld::Initialize() {
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CWorld::LoadMap(const char* mapName, const C3Vector& position, int32_t zoneID) {
|
||||||
|
CMap::Load(mapName, zoneID);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CWorld::Render() {
|
||||||
|
DayNight::RenderSky();
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
#define WORLD_C_WORLD_HPP
|
#define WORLD_C_WORLD_HPP
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
#include <tempest/Vector.hpp>
|
||||||
|
|
||||||
class CWorld {
|
class CWorld {
|
||||||
public:
|
public:
|
||||||
|
|
@ -47,6 +48,8 @@ class CWorld {
|
||||||
|
|
||||||
// Static functions
|
// Static functions
|
||||||
static void Initialize(void);
|
static void Initialize(void);
|
||||||
|
static void LoadMap(const char* mapName, const C3Vector& position, int32_t zoneID);
|
||||||
|
static void Render();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,13 @@
|
||||||
#include "world/World.hpp"
|
#include "world/World.hpp"
|
||||||
|
|
||||||
int32_t LoadNewWorld() {
|
uint32_t s_newZoneID = 0;
|
||||||
|
C3Vector s_newPosition;
|
||||||
|
float s_newFacing = 0.0f;
|
||||||
|
const char* s_newMapname = nullptr;
|
||||||
|
|
||||||
|
|
||||||
|
int32_t LoadNewWorld(const void* eventData) {
|
||||||
|
// TODO
|
||||||
|
CWorld::LoadMap(s_newMapname, s_newPosition, s_newZoneID);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,11 @@
|
||||||
|
|
||||||
#include "world/CWorld.hpp"
|
#include "world/CWorld.hpp"
|
||||||
|
|
||||||
int32_t LoadNewWorld();
|
extern uint32_t s_newZoneID;
|
||||||
|
extern C3Vector s_newPosition;
|
||||||
|
extern float s_newFacing;
|
||||||
|
extern const char* s_newMapname;
|
||||||
|
|
||||||
|
int32_t LoadNewWorld(const void* eventData);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
46
src/world/daynight/DNStars.cpp
Normal file
46
src/world/daynight/DNStars.cpp
Normal file
|
|
@ -0,0 +1,46 @@
|
||||||
|
#include "world/daynight/DNStars.hpp"
|
||||||
|
#include "model/Model2.hpp"
|
||||||
|
#include <common/Time.hpp>
|
||||||
|
|
||||||
|
namespace DayNight {
|
||||||
|
|
||||||
|
void DNStars::Initialize() {
|
||||||
|
this->m_scene = M2CreateScene();
|
||||||
|
this->m_model = this->m_scene->CreateModel("Environments\\Stars\\stars.mdl", 0);
|
||||||
|
this->m_time = OsGetAsyncTimeMs();
|
||||||
|
}
|
||||||
|
|
||||||
|
void DNStars::Destroy() {
|
||||||
|
if (this->m_model) {
|
||||||
|
this->m_model->Release();
|
||||||
|
this->m_model = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this->m_scene) {
|
||||||
|
// TODO: this->m_scene->Release();
|
||||||
|
this->m_scene = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DNStars::Update() {
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
void DNStars::Render() {
|
||||||
|
if (this->m_color.a < 2) {
|
||||||
|
//return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this->m_model->SetAnimating(1);
|
||||||
|
|
||||||
|
// TODO
|
||||||
|
|
||||||
|
uint32_t elapsed = OsGetAsyncTimeMs() - this->m_time;
|
||||||
|
this->m_time += elapsed;
|
||||||
|
this->m_scene->AdvanceTime(elapsed);
|
||||||
|
this->m_scene->Animate(C3Vector());
|
||||||
|
this->m_scene->Draw(M2PASS_0);
|
||||||
|
this->m_scene->Draw(M2PASS_1);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace DayNight
|
||||||
32
src/world/daynight/DNStars.hpp
Normal file
32
src/world/daynight/DNStars.hpp
Normal file
|
|
@ -0,0 +1,32 @@
|
||||||
|
#ifndef WORLD_DAY_NIGHT_STARS_HPP
|
||||||
|
#define WORLD_DAY_NIGHT_STARS_HPP
|
||||||
|
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
#include <tempest/Vector.hpp>
|
||||||
|
|
||||||
|
|
||||||
|
class CM2Scene;
|
||||||
|
class CM2Model;
|
||||||
|
|
||||||
|
|
||||||
|
namespace DayNight {
|
||||||
|
|
||||||
|
class DNStars {
|
||||||
|
public:
|
||||||
|
void Initialize();
|
||||||
|
void Destroy();
|
||||||
|
void Update();
|
||||||
|
void Render();
|
||||||
|
|
||||||
|
CM2Scene* m_scene = nullptr;
|
||||||
|
CM2Model* m_model = nullptr;
|
||||||
|
CImVector m_color { 0 };
|
||||||
|
C3Vector m_pos;
|
||||||
|
uint32_t m_time = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace DayNight
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
20
src/world/daynight/DayNight.cpp
Normal file
20
src/world/daynight/DayNight.cpp
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
#include "world/daynight/DayNight.hpp"
|
||||||
|
#include "world/daynight/DNStars.hpp"
|
||||||
|
|
||||||
|
|
||||||
|
namespace DayNight {
|
||||||
|
|
||||||
|
static DNStars g_stars;
|
||||||
|
|
||||||
|
|
||||||
|
void LoadMap(int32_t zoneID) {
|
||||||
|
// TODO
|
||||||
|
g_stars.Initialize();
|
||||||
|
}
|
||||||
|
|
||||||
|
void RenderSky() {
|
||||||
|
// TODO
|
||||||
|
g_stars.Render();
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace DayNight
|
||||||
13
src/world/daynight/DayNight.hpp
Normal file
13
src/world/daynight/DayNight.hpp
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
#ifndef WORLD_DAY_NIGHT_HPP
|
||||||
|
#define WORLD_DAY_NIGHT_HPP
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
namespace DayNight {
|
||||||
|
|
||||||
|
void LoadMap(int32_t zoneID);
|
||||||
|
void RenderSky();
|
||||||
|
|
||||||
|
} // namespace DayNight
|
||||||
|
|
||||||
|
#endif
|
||||||
7
src/world/map/CMap.cpp
Normal file
7
src/world/map/CMap.cpp
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
#include "world/map/CMap.hpp"
|
||||||
|
#include "world/daynight/DayNight.hpp"
|
||||||
|
|
||||||
|
|
||||||
|
void CMap::Load(const char* mapName, int32_t zoneID) {
|
||||||
|
DayNight::LoadMap(zoneID);
|
||||||
|
}
|
||||||
11
src/world/map/CMap.hpp
Normal file
11
src/world/map/CMap.hpp
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
#ifndef WORLD_C_MAP_HPP
|
||||||
|
#define WORLD_C_MAP_HPP
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
class CMap {
|
||||||
|
public:
|
||||||
|
static void Load(const char* mapName, int32_t zoneID);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
Loading…
Add table
Add a link
Reference in a new issue