Compare commits

...

6 Commits

Author SHA1 Message Date
fallenoak
26522016e0
feat(ui): implement Script_GetCVar
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-29 12:46:31 -06:00
fallenoak
0bb3ac157f
feat(client): implement ReceiveNewTimeSpeed 2026-01-29 08:47:19 -06:00
fallenoak
53b26169f3
feat(util): add CGameTime::GameTimeSetMinutesPerSecond 2026-01-29 08:46:57 -06:00
fallenoak
6e7c267d3e
feat(client): add ClientInitializeGameTime 2026-01-29 07:52:43 -06:00
fallenoak
50a24e8564
feat(ui): implement Script_GetGameTime 2026-01-29 07:37:43 -06:00
fallenoak
efd3f8e8f4
feat(client): add ClientGameTimeTickHandler 2026-01-29 07:33:50 -06:00
8 changed files with 131 additions and 10 deletions

View File

@ -30,6 +30,8 @@ CVar* Client::g_accountNameVar;
CVar* Client::g_accountListVar;
HEVENTCONTEXT Client::g_clientEventContext;
CGameTime g_clientGameTime;
static CVar* s_desktopGammaCvar;
static CVar* s_gammaCvar;
static CVar* s_textureCacheSizeCvar;
@ -70,10 +72,28 @@ void BaseInitializeGlobal() {
PropInitialize();
}
int32_t ClientGameTimeTickHandler(const void* data, void* param) {
STORM_ASSERT(data);
g_clientGameTime.GameTimeUpdate(static_cast<const EVENT_DATA_IDLE*>(data)->elapsedSec);
return 1;
}
void ClientInitializeGameTime() {
ClientServices::SetMessageHandler(SMSG_GAME_SPEED_SET, &ReceiveNewGameSpeed, nullptr);
ClientServices::SetMessageHandler(SMSG_LOGIN_SET_TIME_SPEED, &ReceiveNewTimeSpeed, nullptr);
ClientServices::SetMessageHandler(SMSG_GAME_TIME_UPDATE, &ReceiveGameTimeUpdate, nullptr);
ClientServices::SetMessageHandler(SMSG_SERVERTIME, &ReceiveServerTime, nullptr);
ClientServices::SetMessageHandler(SMSG_GAME_TIME_SET, &ReceiveNewGameTime, nullptr);
// TODO initialize s_forcedChangeCallbacks
}
int32_t ClientIdle(const void* data, void* param) {
// TODO
// ClientGameTimeTickHandler(data, param);
// Player_C_ZoneUpdateHandler(data, param);
ClientGameTimeTickHandler(data, nullptr);
// TODO Player_C_ZoneUpdateHandler(data, nullptr);
return 1;
}
@ -91,6 +111,7 @@ void ClientInitializeGame(uint32_t mapId, C3Vector position) {
// TODO
EventRegister(EVENT_ID_IDLE, ClientIdle);
ClientInitializeGameTime();
// TODO

View File

@ -2,6 +2,7 @@
#define CLIENT_CLIENT_HPP
#include "event/Event.hpp"
#include "util/Time.hpp"
#include <tempest/Vector.hpp>
class CVar;
@ -12,6 +13,8 @@ namespace Client {
extern HEVENTCONTEXT g_clientEventContext;
}
extern CGameTime g_clientGameTime;
void ClientInitializeGame(uint32_t mapId, C3Vector position);
void ClientPostClose(int32_t a1);

View File

@ -1,11 +1,14 @@
#include "client/ClientHandlers.hpp"
#include "Client.hpp"
#include "console/Console.hpp"
#include "db/Db.hpp"
#include "object/Client.hpp"
#include "util/Time.hpp"
#include "util/Unimplemented.hpp"
#include "world/World.hpp"
#include <common/DataStore.hpp>
#include <tempest/Vector.hpp>
#include <cstdint>
#include <tempest/Vector.hpp>
static float s_newFacing;
static C3Vector s_newPosition;
@ -77,6 +80,56 @@ int32_t PlayedTimeHandler(void* param, NETMESSAGE msgId, uint32_t time, CDataSto
return 0;
}
int32_t ReceiveGameTimeUpdate(void* param, NETMESSAGE msgId, uint32_t time, CDataStore* msg) {
WHOA_UNIMPLEMENTED(0);
}
int32_t ReceiveNewGameSpeed(void* param, NETMESSAGE msgId, uint32_t time, CDataStore* msg) {
WHOA_UNIMPLEMENTED(0);
}
int32_t ReceiveNewGameTime(void* param, NETMESSAGE msgId, uint32_t time, CDataStore* msg) {
WHOA_UNIMPLEMENTED(0);
}
int32_t ReceiveNewTimeSpeed(void* param, NETMESSAGE msgId, uint32_t time, CDataStore* msg) {
uint32_t encodedTime;
msg->Get(encodedTime);
float newSpeed;
msg->Get(newSpeed);
uint32_t holidayOffset;
msg->Get(holidayOffset);
if (!msg->IsRead()) {
STORM_ASSERT(msg->IsFinal());
// TODO ConsoleWriteA("Malformed message received: Id = %d, Len = %d, Read = %d\n", DEFAULT_COLOR, msgId, msg->Size(), msg->Tell());
return 0;
}
WowTime newTime;
WowTime::WowDecodeTime(encodedTime, &newTime);
newTime.m_holidayOffset = holidayOffset;
g_clientGameTime.GameTimeSetTime(newTime, true);
// TODO UpdateTime();
auto oldSpeed = g_clientGameTime.GameTimeSetMinutesPerSecond(newSpeed);
char logStr[256];
SStrPrintf(logStr, sizeof(logStr), "Gamespeed set from %.03f to %.03f", oldSpeed, newSpeed);
ConsoleWrite(logStr, DEFAULT_COLOR);
return 1;
}
int32_t ReceiveServerTime(void* param, NETMESSAGE msgId, uint32_t time, CDataStore* msg) {
WHOA_UNIMPLEMENTED(0);
}
int32_t TransferAbortedHandler(void* param, NETMESSAGE msgId, uint32_t time, CDataStore* msg) {
// TODO

View File

@ -14,6 +14,16 @@ int32_t NotifyHandler(void* param, NETMESSAGE msgId, uint32_t time, CDataStore*
int32_t PlayedTimeHandler(void* param, NETMESSAGE msgId, uint32_t time, CDataStore* msg);
int32_t ReceiveGameTimeUpdate(void* param, NETMESSAGE msgId, uint32_t time, CDataStore* msg);
int32_t ReceiveNewGameSpeed(void* param, NETMESSAGE msgId, uint32_t time, CDataStore* msg);
int32_t ReceiveNewGameTime(void* param, NETMESSAGE msgId, uint32_t time, CDataStore* msg);
int32_t ReceiveNewTimeSpeed(void* param, NETMESSAGE msgId, uint32_t time, CDataStore* msg);
int32_t ReceiveServerTime(void* param, NETMESSAGE msgId, uint32_t time, CDataStore* msg);
int32_t TransferAbortedHandler(void* param, NETMESSAGE msgId, uint32_t time, CDataStore* msg);
int32_t TransferPendingHandler(void* param, NETMESSAGE msgId, uint32_t time, CDataStore* msg);

View File

@ -1,4 +1,5 @@
#include "ui/FrameScript.hpp"
#include "client/Client.hpp"
#include "ui/ScriptFunctionsShared.hpp"
#include "ui/Types.hpp"
#include "util/Lua.hpp"
@ -14,10 +15,10 @@ int32_t Script_GetTime(lua_State* L) {
}
int32_t Script_GetGameTime(lua_State* L) {
// TODO real implementation
lua_pushnumber(L, 1.0);
lua_pushnumber(L, 15.0);
WHOA_UNIMPLEMENTED(2);
lua_pushnumber(L, g_clientGameTime.m_hour);
lua_pushnumber(L, g_clientGameTime.m_minute);
return 2;
}
int32_t Script_ConsoleExec(lua_State* L) {

View File

@ -133,7 +133,21 @@ int32_t Script_SetCVar(lua_State* L) {
}
int32_t Script_GetCVar(lua_State* L) {
WHOA_UNIMPLEMENTED(0);
if (!lua_isstring(L, 1)) {
luaL_error(L, "Usage: GetCVar(\"cvar\")");
return 0;
}
auto varName = lua_tostring(L, 1);
auto var = CVar::LookupRegistered(varName);
if (var && !(var->m_flags & 0x40)) {
lua_pushstring(L, var->GetString());
} else {
lua_pushnil(L);
}
return 1;
}
int32_t Script_GetCVarBool(lua_State* L) {

View File

@ -1,6 +1,20 @@
#include "util/time/CGameTime.hpp"
#include "common/Time.hpp"
float CGameTime::GameTimeSetMinutesPerSecond(float minutesPerSec) {
float oldMinutesPerSec = this->m_gameMinutesPerRealSecond;
if (minutesPerSec > CGameTime::MAX_SPEED) {
minutesPerSec = CGameTime::MAX_SPEED;
} else if (minutesPerSec < CGameTime::MIN_SPEED) {
minutesPerSec = CGameTime::MIN_SPEED;
}
this->m_gameMinutesPerRealSecond = minutesPerSec;
return oldMinutesPerSec;
}
void CGameTime::GameTimeSetTime(const WowTime& time, bool shouldTick) {
WowTime biasTime = time;

View File

@ -5,7 +5,12 @@
class CGameTime : public WowTime {
public:
// Public static variables
static constexpr float MIN_SPEED = 1.0f / 60.0f;
static constexpr float MAX_SPEED = 60.0f;
// Public member functions
float GameTimeSetMinutesPerSecond(float minutesPerSec);
void GameTimeSetTime(const WowTime& time, bool shouldTick);
void GameTimeUpdate(float elapsedSec);
@ -15,7 +20,7 @@ class CGameTime : public WowTime {
int32_t m_timeBias = 0;
int32_t m_dateBias = 0;
uint32_t m_gameMinutesElapsed = 0;
float m_gameMinutesPerRealSecond = 1.0f / 60.0f;
float m_gameMinutesPerRealSecond = MIN_SPEED;
float m_gameMinutesThisTick = 0.0f;
uint32_t m_timeDifferential = 0;
uint32_t m_lastTickMinute = 0;