1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
|
#include "pch.h"
#include "scriptserverbrowser.h"
#include "squirrel.h"
#include "masterserver.h"
// functions for viewing server browser
// void NSRequestServerList()
SQInteger SQ_RequestServerList(void* sqvm)
{
g_MasterServerManager->RequestServerList();
return 0;
}
// bool function NSIsRequestingServerList()
SQInteger SQ_IsRequestingServerList(void* sqvm)
{
ClientSq_pushbool(sqvm, g_MasterServerManager->m_scriptRequestingServerList);
return 1;
}
// bool function NSMasterServerConnectionSuccessful()
SQInteger SQ_MasterServerConnectionSuccessful(void* sqvm)
{
ClientSq_pushbool(sqvm, g_MasterServerManager->m_successfullyConnected);
return 1;
}
// int function NSGetServerCount()
SQInteger SQ_GetServerCount(void* sqvm)
{
ClientSq_pushinteger(sqvm, g_MasterServerManager->m_remoteServers.size());
return 1;
}
// string function NSGetServerName( int serverIndex )
SQInteger SQ_GetServerName(void* sqvm)
{
SQInteger serverIndex = ClientSq_getinteger(sqvm, 1);
if (serverIndex >= g_MasterServerManager->m_remoteServers.size())
{
spdlog::warn("Tried to get name of server index {} when only {} servers are available", serverIndex, g_MasterServerManager->m_remoteServers.size());
return 0;
}
auto iterator = g_MasterServerManager->m_remoteServers.begin();
std::advance(iterator, serverIndex);
ClientSq_pushstring(sqvm, iterator->name, -1);
return 1;
}
// string function NSGetServerMap( int serverIndex )
SQInteger SQ_GetServerMap(void* sqvm)
{
SQInteger serverIndex = ClientSq_getinteger(sqvm, 1);
if (serverIndex >= g_MasterServerManager->m_remoteServers.size())
{
spdlog::warn("Tried to get map of server index {} when only {} servers are available", serverIndex, g_MasterServerManager->m_remoteServers.size());
return 0;
}
auto iterator = g_MasterServerManager->m_remoteServers.begin();
std::advance(iterator, serverIndex);
ClientSq_pushstring(sqvm, iterator->map, -1);
return 1;
}
// string function NSGetServerPlaylist( int serverIndex )
SQInteger SQ_GetServerPlaylist(void* sqvm)
{
SQInteger serverIndex = ClientSq_getinteger(sqvm, 1);
if (serverIndex >= g_MasterServerManager->m_remoteServers.size())
{
spdlog::warn("Tried to get playlist of server index {} when only {} servers are available", serverIndex, g_MasterServerManager->m_remoteServers.size());
return 0;
}
auto iterator = g_MasterServerManager->m_remoteServers.begin();
std::advance(iterator, serverIndex);
ClientSq_pushstring(sqvm, iterator->playlist, -1);
return 1;
}
// string function NSGetServerID( int serverIndex )
SQInteger SQ_GetServerID(void* sqvm)
{
SQInteger serverIndex = ClientSq_getinteger(sqvm, 1);
if (serverIndex >= g_MasterServerManager->m_remoteServers.size())
{
spdlog::warn("Tried to get id of server index {} when only {} servers are available", serverIndex, g_MasterServerManager->m_remoteServers.size());
return 0;
}
auto iterator = g_MasterServerManager->m_remoteServers.begin();
std::advance(iterator, serverIndex);
ClientSq_pushstring(sqvm, iterator->id, -1);
return 1;
}
// void function NSClearRecievedServerList()
SQInteger SQ_ClearRecievedServerList(void* sqvm)
{
g_MasterServerManager->ClearServerList();
return 0;
}
// functions for authenticating with servers
// void function NSTryAuthWithServer( string serverId )
SQInteger SQ_TryAuthWithServer(void* sqvm)
{
return 0;
}
// int function NSWasAuthSuccessful()
SQInteger SQ_WasAuthSuccessful(void* sqvm)
{
return 0;
}
// string function NSTryGetAuthedServerAddress()
SQInteger SQ_TryGetAuthedServerAddress(void* sqvm)
{
return 0;
}
// string function NSTryGetAuthedServerToken()
SQInteger SQ_TryGetAuthedServerToken(void* sqvm)
{
return 0;
}
void InitialiseScriptServerBrowser(HMODULE baseAddress)
{
g_UISquirrelManager->AddFuncRegistration("void", "NSRequestServerList", "", "", SQ_RequestServerList);
g_UISquirrelManager->AddFuncRegistration("bool", "NSIsRequestingServerList", "", "", SQ_IsRequestingServerList);
g_UISquirrelManager->AddFuncRegistration("bool", "NSMasterServerConnectionSuccessful", "", "", SQ_MasterServerConnectionSuccessful);
g_UISquirrelManager->AddFuncRegistration("int", "NSGetServerCount", "", "", SQ_GetServerCount);
g_UISquirrelManager->AddFuncRegistration("void", "NSClearRecievedServerList", "", "", SQ_ClearRecievedServerList);
g_UISquirrelManager->AddFuncRegistration("string", "NSGetServerName", "int serverIndex", "", SQ_GetServerName);
g_UISquirrelManager->AddFuncRegistration("string", "NSGetServerMap", "int serverIndex", "", SQ_GetServerMap);
g_UISquirrelManager->AddFuncRegistration("string", "NSGetServerPlaylist", "int serverIndex", "", SQ_GetServerPlaylist);
g_UISquirrelManager->AddFuncRegistration("string", "NSGetServerID", "int serverIndex", "", SQ_GetServerID);
//g_UISquirrelManager->AddFuncRegistration("bool", "NSPollServerPage", "int page", "", SQ_PollServerPage);
//g_UISquirrelManager->AddFuncRegistration("int", "NSGetNumServersOnPage", "int page", "", SQ_GetNumServersOnPage);
//g_UISquirrelManager->AddFuncRegistration("string", "NSGetServerName", "int page, int serverIndex", "", SQ_GetServerName);
//g_UISquirrelManager->AddFuncRegistration("string", "NSGetServerMap", "int page, int serverIndex", "", SQ_GetServerMap);
//g_UISquirrelManager->AddFuncRegistration("string", "NSGetServerMode", "int page, int serverIndex", "", SQ_GetServerMode);
//g_UISquirrelManager->AddFuncRegistration("void", "NSResetRecievedServers", "", "", SQ_ResetRecievedServers);
//
//g_UISquirrelManager->AddFuncRegistration("string", "NSTryGetAuthedServerToken", "", "", SQ_TryGetAuthedServerToken);
}
|