Compare commits

...

4 Commits

Author SHA1 Message Date
Tristan 'Natrist' Cormier
57ac718d2c
Merge a82628adaa into 7ec9a35b4b 2026-02-08 11:25:33 -05:00
fallenoak
7ec9a35b4b
feat(ui): implement Script_GetBonusBarOffset
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-02-08 07:16:58 -06:00
fallenoak
43895197af
feat(ui): implement Script_SetCVar 2026-02-08 06:58:15 -06:00
Tristan Cormier
a82628adaa feat(glue): implement Script_DeleteCharacter 2026-01-05 22:35:20 -05:00
13 changed files with 103 additions and 6 deletions

View File

@ -160,6 +160,10 @@ ClientConnection* ClientServices::Connection() {
return ClientServices::s_currentConnection;
}
void ClientServices::CharacterDelete(uint64_t guid) {
ClientServices::Connection()->RequestCharacterDelete(guid);
}
void ClientServices::Disconnect() {
ClientServices::Connection()->Disconnect();
}

View File

@ -33,6 +33,7 @@ class ClientServices : public LoginResponse {
// Static functions
static void ConnectToSelectedServer();
static ClientConnection* Connection();
static void CharacterDelete(uint64_t guid);
static void Disconnect();
static const char* GetCurrentLoginPortal();
static const char* GetCurrentLoginServer();

View File

@ -1,4 +1,5 @@
#include "glue/CCharacterSelectionScript.hpp"
#include "CGlueMgr.hpp"
#include "db/Db.hpp"
#include "glue/CCharacterSelection.hpp"
#include "object/client/CGUnit_C.hpp"
@ -157,7 +158,17 @@ int32_t Script_SelectCharacter(lua_State* L) {
}
int32_t Script_DeleteCharacter(lua_State* L) {
WHOA_UNIMPLEMENTED(0);
if (!lua_isnumber(L, 1)) {
luaL_error(L, "Usage: DeleteCharacter(index)");
}
int32_t index = static_cast<int32_t>(lua_tonumber(L, 1)) - 1;
if (index >= 0 && index < CCharacterSelection::s_characterList.Count()) {
CGlueMgr::DeleteCharacter(CCharacterSelection::s_characterList.m_data[index].m_info.guid);
}
return 0;
}
int32_t Script_RenameCharacter(lua_State* L) {

View File

@ -129,6 +129,17 @@ void CGlueMgr::ChangeRealm(const REALM_INFO* realmInfo) {
ClientServices::Connection()->Connect();
}
void CGlueMgr::DeleteCharacter(uint64_t guid) {
if (guid) {
CGlueMgr::SetIdleState(IDLE_DELETE_CHARACTER);
auto text = FrameScript_GetText(ClientServices::GetErrorToken(70), -1, GENDER_NOT_APPLICABLE);
FrameScript_SignalEvent(OPEN_STATUS_DIALOG, "%s%s", "CANCEL", text);
ClientServices::CharacterDelete(guid);
}
}
void CGlueMgr::EnterWorld() {
if (!ClientServices::GetSelectedRealm()) {
return;

View File

@ -66,6 +66,7 @@ class CGlueMgr {
// Static functions
static void CancelRealmListQuery();
static void ChangeRealm(const REALM_INFO* realmInfo);
static void DeleteCharacter(uint64_t guid);
static void DisplayLoginStatus();
static void EnterWorld();
static void GetCharacterList();

View File

@ -1,6 +1,7 @@
#include "net/connection/ClientConnection.hpp"
#include "net/Login.hpp"
#include "client/ClientServices.hpp"
#include "common/datastore/CDataStore.hpp"
#include "net/Login.hpp"
#include "ui/FrameScript.hpp"
void ClientConnection::AccountLogin(const char* name, const char* password, int32_t region, WOW_LOCALE locale) {
@ -160,3 +161,19 @@ int32_t ClientConnection::PollStatus(WOWCS_OPS& op, const char** msg, int32_t& r
return this->m_statusComplete;
}
void ClientConnection::RequestCharacterDelete(uint64_t guid) {
this->Initiate(COP_DELETE_CHARACTER, 70, nullptr);
if (this->IsConnected()) {
CDataStore netMsg;
netMsg.Put(static_cast<uint32_t>(CMSG_CHAR_DELETE));
netMsg.Put(guid);
netMsg.Finalize();
this->Send(&netMsg);
}
else {
this->Cancel(4);
}
}

View File

@ -43,6 +43,7 @@ class ClientConnection : public RealmConnection {
void Initiate(WOWCS_OPS op, int32_t errorCode, void (*cleanup)());
int32_t IsConnected();
int32_t PollStatus(WOWCS_OPS& op, const char** msg, int32_t& result, int32_t& errorCode);
void RequestCharacterDelete(uint64_t guid);
};
#endif

View File

@ -83,7 +83,9 @@ int32_t Script_IsActionInRange(lua_State* L) {
}
int32_t Script_GetBonusBarOffset(lua_State* L) {
WHOA_UNIMPLEMENTED(0);
lua_pushnumber(L, CGActionBar::GetBonusBarOffset());
return 1;
}
int32_t Script_GetMultiCastBarOffset(lua_State* L) {

View File

@ -1,4 +1,9 @@
#include "ui/game/CGActionBar.hpp"
uint32_t CGActionBar::s_bonusBarOffset;
uint32_t CGActionBar::s_currentPage;
uint32_t CGActionBar::s_tempPageActiveFlags;
uint32_t CGActionBar::GetBonusBarOffset() {
return CGActionBar::s_bonusBarOffset;
}

View File

@ -5,9 +5,16 @@
class CGActionBar {
public:
// Static variables
// Public static variables
static uint32_t s_currentPage;
static uint32_t s_tempPageActiveFlags;
// Public static functions
static uint32_t GetBonusBarOffset();
private:
// Private static variables
static uint32_t s_bonusBarOffset;
};
#endif

View File

@ -4,6 +4,7 @@
#include "ui/FrameScript.hpp"
#include "ui/ScriptFunctionsShared.hpp"
#include "ui/game/CGGameUI.hpp"
#include "ui/game/Types.hpp"
#include "ui/simple/CSimpleTop.hpp"
#include "util/StringTo.hpp"
#include "util/Unimplemented.hpp"
@ -131,7 +132,41 @@ int32_t Script_GetCVarInfo(lua_State* L) {
}
int32_t Script_SetCVar(lua_State* L) {
WHOA_UNIMPLEMENTED(0);
if (!lua_isstring(L, 1)) {
luaL_error(L, "Usage: SetCVar(\"cvar\", value [, \"scriptCvar\")");
return 0;
}
auto varName = lua_tostring(L, 1);
auto var = CVar::LookupRegistered(varName);
if (!var || (var->m_flags & 0x40)) {
luaL_error(L, "Couldn't find CVar named '%s'", varName);
return 0;
}
if (var->m_flags & 0x4 || var->m_flags & 0x100) {
luaL_error(L, "\"%s\" is read-only", varName);
return 0;
}
if (!(var->m_flags & 0x8)/* TODO || CSimpleTop::GetInstance()->dword124C */) {
auto value = lua_tostring(L, 2);
if (!value) {
value = "0";
}
var->Set(value, true, false, false, true);
if (lua_isstring(L, 3)) {
auto scriptVarName = lua_tostring(L, 3);
FrameScript_SignalEvent(SCRIPT_CVAR_UPDATE, "%s%s", scriptVarName, value);
}
} else {
// TODO CGGameUI::ShowBlockedActionFeedback(nullptr, 2);
}
return 0;
}
int32_t Script_GetCVar(lua_State* L) {

View File

@ -1187,7 +1187,7 @@ void ScriptEventsInitialize() {
g_scriptEvents[295] = "TRAINER_UPDATE";
g_scriptEvents[296] = "TRAINER_DESCRIPTION_UPDATE";
g_scriptEvents[297] = "TRAINER_CLOSED";
g_scriptEvents[298] = "CVAR_UPDATE";
g_scriptEvents[SCRIPT_CVAR_UPDATE] = "CVAR_UPDATE";
g_scriptEvents[299] = "TRADE_SKILL_SHOW";
g_scriptEvents[300] = "TRADE_SKILL_UPDATE";
g_scriptEvents[301] = "TRADE_SKILL_CLOSE";

View File

@ -9,6 +9,8 @@ enum SCRIPTEVENT {
SCRIPT_PLAYER_LOGOUT = 254,
SCRIPT_PLAYER_ENTERING_WORLD = 255,
// TODO
SCRIPT_CVAR_UPDATE = 298,
// TODO
};
#endif