Skip to content

Commit e1eef6b

Browse files
committed
Added Account and Authentication Flow
Added Character List Support Fixed a couple instances of lua stack corruption Updated Submodule Engine
1 parent f7db3bc commit e1eef6b

24 files changed

+792
-136
lines changed

Source/Game-Lib/Game-Lib.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
-- Dependencies are order sensitive on Linux, keep that in mind when adding new dependencies.
2-
local mod = Solution.Util.CreateModuleTable("Game-Lib", { "renderer", "fileformat", "scripting", "gameplay", "input", "meta", "luau-analysis", "luau-compiler", "luau-vm", "luau-codegen", "enkits", "utfcpp", "base64", "jolt" })
2+
local mod = Solution.Util.CreateModuleTable("Game-Lib", { "renderer", "fileformat", "scripting", "gameplay", "input", "meta", "luau-analysis", "luau-compiler", "luau-vm", "luau-codegen", "enkits", "utfcpp", "base64", "jolt", "spake2-ee" })
33

44
Solution.Util.CreateStaticLib(mod.Name, Solution.Projects.Current.BinDir, mod.Dependencies, function()
55
local defines = { "_SILENCE_ALL_CXX17_DEPRECATION_WARNINGS", "_SILENCE_ALL_MS_EXT_DEPRECATION_WARNINGS"}

Source/Game-Lib/Game-Lib/ECS/Singletons/NetworkState.h

Lines changed: 100 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44
#include <robinhood/robinhood.h>
55

66
#include <asio/asio.hpp>
7-
#include <RTree/RTree.h>
8-
97
#include <entt/entt.hpp>
8+
#include <libsodium/sodium.h>
9+
#include <RTree/RTree.h>
10+
#include <spake2-ee/crypto_spake.h>
1011

1112
#include <memory>
1213

@@ -16,19 +17,82 @@ namespace Network
1617
class GameMessageRouter;
1718
}
1819

19-
namespace ECS::Singletons
20+
namespace ECS
2021
{
21-
struct NetworkState
22+
enum class AuthenticationStage : u8
23+
{
24+
None = 0,
25+
Step1 = 1,
26+
Step2 = 2,
27+
Failed = 3,
28+
Completed = 4
29+
};
30+
31+
struct CharacterListEntry
32+
{
33+
public:
34+
std::string name;
35+
u8 race;
36+
u8 gender;
37+
u8 unitClass;
38+
u16 level;
39+
u16 mapID;
40+
};
41+
42+
struct AuthenticationInfo
43+
{
44+
public:
45+
void Reset()
46+
{
47+
stage = AuthenticationStage::None;
48+
username.clear();
49+
password.clear();
50+
sodium_memzero(&state, sizeof(state));
51+
sodium_memzero(&sharedKeys, sizeof(sharedKeys));
52+
}
53+
54+
public:
55+
AuthenticationStage stage = AuthenticationStage::None;
56+
std::string username = "";
57+
std::string password = "";
58+
59+
crypto_spake_client_state state;
60+
crypto_spake_shared_keys_ sharedKeys;
61+
};
62+
63+
struct CharacterListInfo
2264
{
2365
public:
24-
static constexpr u64 PING_INTERVAL = 5000;
66+
void Reset()
67+
{
68+
characterSelected = false;
69+
list.clear();
70+
nameHashToIndex.clear();
71+
nameHashToSortingIndex.clear();
72+
}
73+
74+
public:
75+
bool characterSelected = false;
76+
std::vector<CharacterListEntry> list;
77+
robin_hood::unordered_map<u32, u32> nameHashToIndex;
78+
robin_hood::unordered_map<u32, u32> nameHashToSortingIndex;
79+
};
2580

26-
std::thread asioThread;
27-
asio::io_context asioContext;
28-
std::shared_ptr<asio::ip::tcp::resolver> resolver;
29-
std::unique_ptr<Network::Client> client;
30-
std::unique_ptr<Network::GameMessageRouter> gameMessageRouter;
81+
struct PingInfo
82+
{
83+
public:
84+
void Reset()
85+
{
86+
lastPingTime = 0u;
87+
lastPongTime = 0u;
88+
ping = 0;
89+
serverUpdateDiff = 0;
90+
pingHistoryIndex = 0;
91+
pingHistory.fill(0);
92+
pingHistorySize = 0;
93+
}
3194

95+
public:
3296
u64 lastPingTime = 0;
3397
u64 lastPongTime = 0;
3498

@@ -37,10 +101,31 @@ namespace ECS::Singletons
37101
u8 serverUpdateDiff = 0;
38102
std::array<u16, 6> pingHistory = { 0, 0, 0, 0, 0, 0 };
39103
u8 pingHistorySize = 0;
40-
bool isLoadingMap = false;
41-
42-
robin_hood::unordered_map<ObjectGUID, entt::entity> networkIDToEntity;
43-
robin_hood::unordered_map<entt::entity, ObjectGUID> entityToNetworkID;
44-
RTree<ObjectGUID, f32, 3>* networkVisTree;
45104
};
105+
106+
namespace Singletons
107+
{
108+
struct NetworkState
109+
{
110+
public:
111+
static constexpr u64 PING_INTERVAL = 5000;
112+
113+
std::thread asioThread;
114+
asio::io_context asioContext;
115+
std::shared_ptr<asio::ip::tcp::resolver> resolver;
116+
std::unique_ptr<Network::Client> client;
117+
std::unique_ptr<Network::GameMessageRouter> gameMessageRouter;
118+
119+
bool isLoadingMap = false;
120+
bool isInWorld = false;
121+
122+
AuthenticationInfo authInfo;
123+
CharacterListInfo characterListInfo;
124+
PingInfo pingInfo;
125+
126+
robin_hood::unordered_map<ObjectGUID, entt::entity> networkIDToEntity;
127+
robin_hood::unordered_map<entt::entity, ObjectGUID> entityToNetworkID;
128+
RTree<ObjectGUID, f32, 3>* networkVisTree = nullptr;
129+
};
130+
}
46131
}

0 commit comments

Comments
 (0)