mirror of
https://github.com/thunderbrewhq/thunderbrew
synced 2025-04-16 10:04:42 +03:00
feat(glue): handle GetServerName script function
This commit is contained in:
parent
93a0d7ee83
commit
5b9a4d240e
@ -84,6 +84,10 @@ const char* ClientServices::GetSelectedRealmName() {
|
||||
return ClientServices::s_realmNameVar->GetString();
|
||||
}
|
||||
|
||||
const REALM_INFO* ClientServices::GetSelectedRealm() {
|
||||
return &ClientServices::s_selectRealmInfo;
|
||||
}
|
||||
|
||||
void ClientServices::Initialize() {
|
||||
if (!g_clientConnection) {
|
||||
auto adapterMem = SMemAlloc(sizeof(ClientRealmResponseAdapter), __FILE__, __LINE__, 0x0);
|
||||
|
@ -27,6 +27,7 @@ class ClientServices : public LoginResponse {
|
||||
static ClientServices* GetInstance();
|
||||
static REALM_INFO* GetRealmInfoByIndex(int32_t index);
|
||||
static const char* GetSelectedRealmName();
|
||||
static const REALM_INFO* GetSelectedRealm();
|
||||
static void Initialize();
|
||||
static Login* LoginConnection();
|
||||
static void Logon(const char* accountName, const char* password);
|
||||
|
@ -12,6 +12,7 @@ target_include_directories(ui
|
||||
target_link_libraries(ui
|
||||
PRIVATE
|
||||
client
|
||||
db
|
||||
event
|
||||
glue
|
||||
gx
|
||||
|
@ -1,6 +1,7 @@
|
||||
#include "ui/ScriptFunctions.hpp"
|
||||
#include "client/Client.hpp"
|
||||
#include "client/ClientServices.hpp"
|
||||
#include "db/Db.hpp"
|
||||
#include "glue/CGlueMgr.hpp"
|
||||
#include "gx/Coordinate.hpp"
|
||||
#include "net/connection/ClientConnection.hpp"
|
||||
@ -204,7 +205,54 @@ int32_t Script_StatusDialogClick(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) {
|
||||
|
Loading…
Reference in New Issue
Block a user