mirror of
https://github.com/thunderbrewhq/thunderbrew
synced 2025-12-12 03:02:30 +00:00
feat(glue): handle GetServerName script function
This commit is contained in:
parent
93a0d7ee83
commit
5b9a4d240e
4 changed files with 55 additions and 1 deletions
|
|
@ -84,6 +84,10 @@ const char* ClientServices::GetSelectedRealmName() {
|
||||||
return ClientServices::s_realmNameVar->GetString();
|
return ClientServices::s_realmNameVar->GetString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const REALM_INFO* ClientServices::GetSelectedRealm() {
|
||||||
|
return &ClientServices::s_selectRealmInfo;
|
||||||
|
}
|
||||||
|
|
||||||
void ClientServices::Initialize() {
|
void ClientServices::Initialize() {
|
||||||
if (!g_clientConnection) {
|
if (!g_clientConnection) {
|
||||||
auto adapterMem = SMemAlloc(sizeof(ClientRealmResponseAdapter), __FILE__, __LINE__, 0x0);
|
auto adapterMem = SMemAlloc(sizeof(ClientRealmResponseAdapter), __FILE__, __LINE__, 0x0);
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@ class ClientServices : public LoginResponse {
|
||||||
static ClientServices* GetInstance();
|
static ClientServices* GetInstance();
|
||||||
static REALM_INFO* GetRealmInfoByIndex(int32_t index);
|
static REALM_INFO* GetRealmInfoByIndex(int32_t index);
|
||||||
static const char* GetSelectedRealmName();
|
static const char* GetSelectedRealmName();
|
||||||
|
static const REALM_INFO* GetSelectedRealm();
|
||||||
static void Initialize();
|
static void Initialize();
|
||||||
static Login* LoginConnection();
|
static Login* LoginConnection();
|
||||||
static void Logon(const char* accountName, const char* password);
|
static void Logon(const char* accountName, const char* password);
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@ target_include_directories(ui
|
||||||
target_link_libraries(ui
|
target_link_libraries(ui
|
||||||
PRIVATE
|
PRIVATE
|
||||||
client
|
client
|
||||||
|
db
|
||||||
event
|
event
|
||||||
glue
|
glue
|
||||||
gx
|
gx
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
#include "ui/ScriptFunctions.hpp"
|
#include "ui/ScriptFunctions.hpp"
|
||||||
#include "client/Client.hpp"
|
#include "client/Client.hpp"
|
||||||
#include "client/ClientServices.hpp"
|
#include "client/ClientServices.hpp"
|
||||||
|
#include "db/Db.hpp"
|
||||||
#include "glue/CGlueMgr.hpp"
|
#include "glue/CGlueMgr.hpp"
|
||||||
#include "gx/Coordinate.hpp"
|
#include "gx/Coordinate.hpp"
|
||||||
#include "net/connection/ClientConnection.hpp"
|
#include "net/connection/ClientConnection.hpp"
|
||||||
|
|
@ -204,7 +205,54 @@ int32_t Script_StatusDialogClick(lua_State* L) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t Script_GetServerName(lua_State* L) {
|
int32_t Script_GetServerName(lua_State* L) {
|
||||||
WHOA_UNIMPLEMENTED();
|
auto selectedRealmName = ClientServices::GetSelectedRealmName();
|
||||||
|
auto selectedRealm = ClientServices::GetSelectedRealm();
|
||||||
|
|
||||||
|
auto pvp = false;
|
||||||
|
auto rp = false;
|
||||||
|
|
||||||
|
// default down to true: if realm config isn't found, consider realm down
|
||||||
|
auto down = true;
|
||||||
|
|
||||||
|
if (selectedRealm) {
|
||||||
|
for (int32_t i = 0; i < g_cfg_ConfigsDB.m_numRecords; i++) {
|
||||||
|
auto config = g_cfg_ConfigsDB.GetRecordByIndex(i);
|
||||||
|
|
||||||
|
if (config->m_realmType == selectedRealm->type) {
|
||||||
|
pvp = config->m_playerKillingAllowed != 0;
|
||||||
|
rp = config->m_roleplaying != 0;
|
||||||
|
down = selectedRealm->flags & 0x2;
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// name
|
||||||
|
lua_pushstring(L, selectedRealmName);
|
||||||
|
|
||||||
|
// pvp
|
||||||
|
if (pvp) {
|
||||||
|
lua_pushnumber(L, 1.0);
|
||||||
|
} else {
|
||||||
|
lua_pushnil(L);
|
||||||
|
}
|
||||||
|
|
||||||
|
// rp
|
||||||
|
if (rp) {
|
||||||
|
lua_pushnumber(L, 1.0);
|
||||||
|
} else {
|
||||||
|
lua_pushnil(L);
|
||||||
|
}
|
||||||
|
|
||||||
|
// down
|
||||||
|
if (down) {
|
||||||
|
lua_pushnumber(L, 1.0);
|
||||||
|
} else {
|
||||||
|
lua_pushnil(L);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t Script_DisconnectFromServer(lua_State* L) {
|
int32_t Script_DisconnectFromServer(lua_State* L) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue