mirror of
https://github.com/whoahq/whoa.git
synced 2026-02-02 08:42:45 +03:00
feat(world): add time handling functions to CWorld
This commit is contained in:
parent
c9aaa245c9
commit
c92f1b8de8
@ -520,8 +520,9 @@ void WowClientDestroy() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void WowClientInit() {
|
void WowClientInit() {
|
||||||
|
EventRegister(EVENT_ID_TICK, reinterpret_cast<EVENTHANDLERFUNC>(&CWorld::OnTick));
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
// EventRegister(EVENT_ID_5, (int)sub_4020E0);
|
|
||||||
// _cfltcvt_init_0();
|
// _cfltcvt_init_0();
|
||||||
|
|
||||||
ClientRegisterConsoleCommands();
|
ClientRegisterConsoleCommands();
|
||||||
|
|||||||
@ -6,10 +6,49 @@
|
|||||||
#include "world/Weather.hpp"
|
#include "world/Weather.hpp"
|
||||||
#include <storm/Memory.hpp>
|
#include <storm/Memory.hpp>
|
||||||
|
|
||||||
|
uint32_t CWorld::s_curTimeMs;
|
||||||
|
float CWorld::s_curTimeSec;
|
||||||
uint32_t CWorld::s_enables;
|
uint32_t CWorld::s_enables;
|
||||||
uint32_t CWorld::s_enables2;
|
uint32_t CWorld::s_enables2;
|
||||||
|
uint32_t CWorld::s_gameTimeFixed;
|
||||||
|
float CWorld::s_gameTimeSec;
|
||||||
|
uint32_t CWorld::s_tickTimeFixed;
|
||||||
|
uint32_t CWorld::s_tickTimeMs;
|
||||||
|
float CWorld::s_tickTimeSec;
|
||||||
Weather* CWorld::s_weather;
|
Weather* CWorld::s_weather;
|
||||||
|
|
||||||
|
uint32_t CWorld::GetCurTimeMs() {
|
||||||
|
return CWorld::s_curTimeMs;
|
||||||
|
}
|
||||||
|
|
||||||
|
float CWorld::GetCurTimeSec() {
|
||||||
|
return CWorld::s_curTimeSec;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t CWorld::GetFixedPrecisionTime(float timeSec) {
|
||||||
|
return static_cast<uint32_t>(timeSec * 1024.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t CWorld::GetGameTimeFixed() {
|
||||||
|
return CWorld::s_gameTimeFixed;
|
||||||
|
}
|
||||||
|
|
||||||
|
float CWorld::GetGameTimeSec() {
|
||||||
|
return CWorld::s_gameTimeSec;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t CWorld::GetTickTimeFixed() {
|
||||||
|
return CWorld::s_tickTimeFixed;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t CWorld::GetTickTimeMs() {
|
||||||
|
return CWorld::s_tickTimeMs;
|
||||||
|
}
|
||||||
|
|
||||||
|
float CWorld::GetTickTimeSec() {
|
||||||
|
return CWorld::s_tickTimeSec;
|
||||||
|
}
|
||||||
|
|
||||||
void CWorld::Initialize() {
|
void CWorld::Initialize() {
|
||||||
CWorld::s_enables |=
|
CWorld::s_enables |=
|
||||||
Enables::Enable_1
|
Enables::Enable_1
|
||||||
@ -26,6 +65,9 @@ void CWorld::Initialize() {
|
|||||||
| Enables::Enable_Particulates
|
| Enables::Enable_Particulates
|
||||||
| Enables::Enable_LowDetail;
|
| Enables::Enable_LowDetail;
|
||||||
|
|
||||||
|
CWorld::s_gameTimeFixed = 0;
|
||||||
|
CWorld::s_gameTimeSec = 0.0f;
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
|
|
||||||
if (GxCaps().m_shaderTargets[GxSh_Pixel] > GxShPS_none) {
|
if (GxCaps().m_shaderTargets[GxSh_Pixel] > GxShPS_none) {
|
||||||
@ -58,3 +100,23 @@ void CWorld::LoadMap(const char* mapName, const C3Vector& position, int32_t zone
|
|||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t CWorld::OnTick(const EVENT_DATA_TICK* data, void* param) {
|
||||||
|
CWorld::SetUpdateTime(data->tickTimeSec, data->curTimeMs);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CWorld::SetUpdateTime(float tickTimeSec, uint32_t curTimeMs) {
|
||||||
|
auto tickTimeFixed = CWorld::GetFixedPrecisionTime(tickTimeSec);
|
||||||
|
|
||||||
|
CWorld::s_curTimeMs = curTimeMs;
|
||||||
|
CWorld::s_curTimeSec = static_cast<float>(curTimeMs) * 0.001f;
|
||||||
|
|
||||||
|
CWorld::s_gameTimeFixed += tickTimeFixed;
|
||||||
|
CWorld::s_gameTimeSec += tickTimeSec;
|
||||||
|
|
||||||
|
CWorld::s_tickTimeFixed = tickTimeFixed;
|
||||||
|
CWorld::s_tickTimeMs = static_cast<uint32_t>(tickTimeSec * 1000.0f);
|
||||||
|
CWorld::s_tickTimeSec = tickTimeSec;
|
||||||
|
}
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
#ifndef WORLD_C_WORLD_HPP
|
#ifndef WORLD_C_WORLD_HPP
|
||||||
#define WORLD_C_WORLD_HPP
|
#define WORLD_C_WORLD_HPP
|
||||||
|
|
||||||
|
#include "event/Event.hpp"
|
||||||
#include <tempest/Vector.hpp>
|
#include <tempest/Vector.hpp>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
@ -44,14 +45,36 @@ class CWorld {
|
|||||||
Enable_HwPcf = 0x2
|
Enable_HwPcf = 0x2
|
||||||
};
|
};
|
||||||
|
|
||||||
// Static variables
|
// Public static variables
|
||||||
static uint32_t s_enables;
|
static uint32_t s_enables;
|
||||||
static uint32_t s_enables2;
|
static uint32_t s_enables2;
|
||||||
static Weather* s_weather;
|
static Weather* s_weather;
|
||||||
|
|
||||||
// Static functions
|
// Public static functions
|
||||||
static void Initialize(void);
|
static uint32_t GetCurTimeMs();
|
||||||
|
static float GetCurTimeSec();
|
||||||
|
static uint32_t GetGameTimeFixed();
|
||||||
|
static float GetGameTimeSec();
|
||||||
|
static uint32_t GetTickTimeFixed();
|
||||||
|
static uint32_t GetTickTimeMs();
|
||||||
|
static float GetTickTimeSec();
|
||||||
|
static void Initialize();
|
||||||
static void LoadMap(const char* mapName, const C3Vector& position, int32_t zoneID);
|
static void LoadMap(const char* mapName, const C3Vector& position, int32_t zoneID);
|
||||||
|
static int32_t OnTick(const EVENT_DATA_TICK* data, void* param);
|
||||||
|
static void SetUpdateTime(float tickTimeSec, uint32_t curTimeMs);
|
||||||
|
|
||||||
|
private:
|
||||||
|
// Private static variables
|
||||||
|
static uint32_t s_curTimeMs;
|
||||||
|
static float s_curTimeSec;
|
||||||
|
static uint32_t s_gameTimeFixed;
|
||||||
|
static float s_gameTimeSec;
|
||||||
|
static uint32_t s_tickTimeFixed;
|
||||||
|
static uint32_t s_tickTimeMs;
|
||||||
|
static float s_tickTimeSec;
|
||||||
|
|
||||||
|
// Private static functions
|
||||||
|
static uint32_t GetFixedPrecisionTime(float timeSec);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user