Skip to content

Commit a52b57f

Browse files
author
copernicium
committed
OneSync prototype support side-by-side with classical servers (for internal consumption only)
1 parent 86e81b0 commit a52b57f

66 files changed

Lines changed: 7605 additions & 61 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitlab-ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ build_proot_linux:
6262
- tags
6363
- master
6464
- feature/update-to-1290
65+
- feature/cloning-stuff-releng
6566
tags:
6667
- linux
6768

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,3 +85,6 @@
8585
[submodule "vendor/nanomsg"]
8686
path = vendor/nanomsg
8787
url = https://github.com/nanomsg/nanomsg.git
88+
[submodule "vendor/lz4"]
89+
path = vendor/lz4
90+
url = https://github.com/lz4/lz4.git

code/client/clrcore/External/World.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using CitizenFX.Core.Native;
1+
using CitizenFX.Core.Native;
22
using System;
33
using System.Collections.Generic;
44
using System.Collections.Specialized;

code/client/shared/CrossLibraryInterfaces.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ class INetLibrary
1313
public:
1414
virtual uint16_t GetServerNetID() = 0;
1515

16+
virtual uint16_t GetServerSlotID() = 0;
17+
1618
virtual uint16_t GetHostNetID() = 0;
1719

1820
virtual uint32_t GetHostBase() = 0;

code/client/shared/ICoreGameInit.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ class ICoreGameInit
3131

3232
bool EnhancedHostSupport = false;
3333

34+
bool OneSyncEnabled = false;
35+
3436
private:
3537
std::set<std::string, std::less<>> VariableList;
3638

code/components/citizen-playernames-five/src/HookPlayerNameHandling.cpp

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
static NetLibrary* g_netLibrary;
1919
static std::unordered_map<int, std::string> g_netIdToNames;
20+
static std::unordered_map<int, int> g_netIdToSlots;
2021

2122
// needs to be kept in sync with gta:net:five
2223
struct ScInAddr
@@ -37,6 +38,11 @@ struct ScInAddr
3738

3839
static const char* GetPlayerNameFromScAddr(ScInAddr* addr)
3940
{
41+
if (addr == (void*)0x20)
42+
{
43+
return "** Invalid **";
44+
}
45+
4046
if (addr->ipLan != addr->ipOnline || addr->ipLan != addr->ipUnk)
4147
{
4248
return (char*)addr + sizeof(ScInAddr) + (92 - 64);
@@ -47,7 +53,7 @@ static const char* GetPlayerNameFromScAddr(ScInAddr* addr)
4753

4854
if (it == g_netIdToNames.end())
4955
{
50-
return "** Invalid **";
56+
return va("player %d", netId);
5157
}
5258

5359
return it->second.c_str();
@@ -92,7 +98,7 @@ static InitFunction initFunction([] ()
9298
eventComponent->OnTriggerEvent.Connect([] (const std::string& eventName, const std::string& eventPayload, const std::string& eventSource, bool* eventCanceled)
9399
{
94100
// if this is the event 'we' handle...
95-
if (eventName == "onPlayerJoining")
101+
if (eventName == "onPlayerJoining" || eventName == "onPlayerDropped")
96102
{
97103
try
98104
{
@@ -115,8 +121,33 @@ static InitFunction initFunction([] ()
115121
int netId = arguments[0].as<int>();
116122
std::string name = arguments[1].as<std::string>();
117123

118-
// and add to the list
119-
g_netIdToNames[netId] = name;
124+
if (eventName == "onPlayerJoining")
125+
{
126+
// and add to the list
127+
g_netIdToNames[netId] = name;
128+
}
129+
130+
if (arguments.size() >= 3)
131+
{
132+
uint32_t slotId = arguments[2].as<uint32_t>();
133+
134+
g_netIdToSlots[netId] = slotId;
135+
136+
// trickle the event down the stack
137+
NetLibraryClientInfo clientInfo;
138+
clientInfo.netId = netId;
139+
clientInfo.name = name;
140+
clientInfo.slotId = slotId;
141+
142+
if (eventName == "onPlayerJoining")
143+
{
144+
g_netLibrary->OnClientInfoReceived(clientInfo);
145+
}
146+
else if (eventName == "onPlayerDropped")
147+
{
148+
g_netLibrary->OnClientInfoDropped(clientInfo);
149+
}
150+
}
120151
}
121152
}
122153
catch (std::runtime_error& e)

code/components/citizen-resources-client/src/LevelDBVFSEnvironment.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -483,15 +483,21 @@ namespace leveldb
483483

484484
Status VFSEnvironment::LockFile(const std::string& fname, FileLock** lock)
485485
{
486+
#ifdef _DEBUG
487+
return Status();
488+
#else
486489
auto vfsLock = new VFSFileLock(fname);
487490
*lock = vfsLock;
488491

489492
return vfsLock->IsValid() ? Status() : Status::IOError("Could not lock file.");
493+
#endif
490494
}
491495

492496
Status VFSEnvironment::UnlockFile(FileLock* lock)
493497
{
498+
#ifndef _DEBUG
494499
delete lock;
500+
#endif
495501

496502
return Status();
497503
}
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
#pragma once
2+
3+
#include <rapidjson/document.h>
4+
5+
#ifdef COMPILING_CITIZEN_RESOURCES_CORE
6+
#define RESOURCES_CORE_EXPORT DLL_EXPORT
7+
#else
8+
#define RESOURCES_CORE_EXPORT DLL_IMPORT
9+
#endif
10+
11+
class RESOURCES_CORE_EXPORT RpcConfiguration
12+
{
13+
public:
14+
enum class ArgumentType
15+
{
16+
Entity,
17+
Float,
18+
Int,
19+
Bool,
20+
String,
21+
Player,
22+
Hash
23+
};
24+
25+
enum class RpcType
26+
{
27+
EntityContext,
28+
EntityCreate
29+
};
30+
31+
class Argument
32+
{
33+
public:
34+
Argument();
35+
36+
void Initialize(rapidjson::Value& value);
37+
38+
inline ArgumentType GetType() const
39+
{
40+
return m_type;
41+
}
42+
43+
inline bool GetTranslated() const
44+
{
45+
return m_translate;
46+
}
47+
48+
private:
49+
ArgumentType m_type;
50+
bool m_translate;
51+
};
52+
53+
class Native
54+
{
55+
public:
56+
Native();
57+
58+
void Initialize(rapidjson::Value& value);
59+
60+
inline const std::string& GetName() const
61+
{
62+
return m_name;
63+
}
64+
65+
inline uint64_t GetGameHash() const
66+
{
67+
return m_gameHash;
68+
}
69+
70+
inline int GetContextIndex() const
71+
{
72+
return m_contextArgument;
73+
}
74+
75+
inline ArgumentType GetContextType() const
76+
{
77+
return m_contextType;
78+
}
79+
80+
inline RpcType GetRpcType() const
81+
{
82+
return m_rpcType;
83+
}
84+
85+
inline const std::vector<Argument>& GetArguments() const
86+
{
87+
return m_arguments;
88+
}
89+
90+
private:
91+
std::string m_name;
92+
uint64_t m_gameHash;
93+
94+
int m_contextArgument;
95+
ArgumentType m_contextType;
96+
97+
RpcType m_rpcType;
98+
99+
std::vector<Argument> m_arguments;
100+
};
101+
102+
public:
103+
RpcConfiguration();
104+
105+
virtual ~RpcConfiguration();
106+
107+
inline const std::vector<std::shared_ptr<Native>>& GetNatives() const
108+
{
109+
return m_natives;
110+
}
111+
112+
static std::shared_ptr<RpcConfiguration> Load(std::string_view path);
113+
114+
private:
115+
std::vector<std::shared_ptr<Native>> m_natives;
116+
};

0 commit comments

Comments
 (0)