Skip to content

Commit 2826016

Browse files
authored
Merge pull request #33 from swiftly-solution/rewrite
Rewrite
2 parents 670305c + 2c21dac commit 2826016

File tree

444 files changed

+141813
-10685
lines changed

Some content is hidden

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

444 files changed

+141813
-10685
lines changed

AMBuilder

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,13 @@ for sdk_target in MMSPlugin.sdk_targets:
6868
os.path.join(builder.sourcePath, 'vendor', 'funchook', 'lib', 'libfunchook.a'),
6969
os.path.join(builder.sourcePath, 'vendor', 'funchook', 'lib', 'libdistorm.a'),
7070
os.path.join(builder.sourcePath, 'vendor', 'curl', 'linuxsteamrt64', 'lib', 'libcurl.a'),
71-
os.path.join(builder.sourcePath, 'vendor', 'mysql', 'linuxsteamrt64', 'lib', 'libmysqlclient.a'),
71+
os.path.join(builder.sourcePath, 'vendor', 'mysql', 'linuxsteamrt64', 'lib', 'libmariadbclient.a'),
7272
os.path.join(builder.sourcePath, 'vendor', 'dynohook', 'linuxsteamrt64', 'lib', 'libdynohook.a'),
7373
os.path.join(builder.sourcePath, 'vendor', 'zydis', 'linuxsteamrt64', 'libZydis.a'),
7474
os.path.join(builder.sourcePath, 'vendor', 'dyncall', 'linuxsteamrt64', 'lib', 'libdyncall_s.a'),
7575
os.path.join(builder.sourcePath, 'vendor', 'bzip2', 'linuxsteamrt64', 'lib', 'libbz2.a'),
7676

77+
"-lgnutls",
7778
"-lz",
7879
"-lpthread",
7980
"-lssl",

plugin_files/gamedata/signatures.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
"UTIL_CreateEntityByName": {
4848
"lib": "server",
4949
"windows": "48 83 EC 48 C6 44 24 30 00",
50-
"linux": "48 8B 05 ? ? ? ? 48 85 C0 74 ? 85 FF"
50+
"linux": "48 8D 05 ? ? ? ? 55 48 89 FA"
5151
},
5252
"CBaseModelEntity_SetModel": {
5353
"lib": "server",

src/database/Database.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,21 @@ bool Database::Connect()
3737
return true;
3838
}
3939

40+
static constexpr int MYSQL_JSON =
41+
#ifdef _WIN32
42+
245
43+
#else
44+
enum_field_types::MYSQL_TYPE_JSON
45+
#endif
46+
;
47+
4048
std::any ParseFieldType(enum_field_types type, const char *value)
4149
{
4250
if (type == enum_field_types::MYSQL_TYPE_FLOAT || type == enum_field_types::MYSQL_TYPE_DOUBLE || type == enum_field_types::MYSQL_TYPE_DECIMAL)
4351
return atof(value);
4452
else if (type == enum_field_types::MYSQL_TYPE_INT24 || type == enum_field_types::MYSQL_TYPE_LONG || type == enum_field_types::MYSQL_TYPE_LONGLONG)
4553
return atoi(value);
46-
else if (type == enum_field_types::MYSQL_TYPE_VARCHAR || type == enum_field_types::MYSQL_TYPE_VAR_STRING || type == enum_field_types::MYSQL_TYPE_BLOB || type == 245 || type == enum_field_types::MYSQL_TYPE_TIMESTAMP)
54+
else if (type == enum_field_types::MYSQL_TYPE_VARCHAR || type == enum_field_types::MYSQL_TYPE_VAR_STRING || type == enum_field_types::MYSQL_TYPE_BLOB || type == MYSQL_JSON || type == enum_field_types::MYSQL_TYPE_TIMESTAMP)
4755
return std::string(value);
4856
else if (type == enum_field_types::MYSQL_TYPE_SHORT || type == enum_field_types::MYSQL_TYPE_TINY)
4957
return (short)strtol(value, nullptr, 10);

src/entrypoint.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -631,7 +631,7 @@ const char *Swiftly::GetLicense()
631631

632632
const char *Swiftly::GetVersion()
633633
{
634-
return "v1.0.0";
634+
return "v1.0.1";
635635
}
636636

637637
const char *Swiftly::GetDate()

src/gameevents/gameevents.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,9 @@ bool EventManager::OnFireEvent(IGameEvent *pEvent, bool bDontBroadcast)
9696
if (prettyEventName == "OnPlayerSpawn")
9797
{
9898
auto slot = pEvent->GetPlayerSlot("userid");
99-
Player* player = g_playerManager->GetPlayer(slot);
100-
if(player) player->SetFirstSpawn(false);
99+
Player *player = g_playerManager->GetPlayer(slot);
100+
if (player)
101+
player->SetFirstSpawn(false);
101102
}
102103
if (result != EventResult::Continue)
103104
{

src/plugins/PluginManager.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "PluginManager.h"
22

33
#include "core/scripting.h"
4+
#include "../menus/MenuManager.h"
45

56
#include <vector>
67
#include <msgpack.hpp>
@@ -122,11 +123,11 @@ bool PluginManager::StartPlugin(std::string plugin_name)
122123
if (plugin->GetPluginState() == PluginState_t::Started)
123124
return true;
124125

125-
plugin->SetPluginState(PluginState_t::Started);
126126
if (!plugin->LoadScriptingEnvironment())
127127
return false;
128128
if (!plugin->ExecuteStart())
129129
return false;
130+
plugin->SetPluginState(PluginState_t::Started);
130131

131132
if (AllPluginsStarted)
132133
{
@@ -156,6 +157,7 @@ void PluginManager::StopPlugin(std::string plugin_name)
156157

157158
plugin->ExecuteStop();
158159
plugin->DestroyScriptingEnvironment();
160+
g_MenuManager->UnregisterPluginMenus(plugin_name);
159161
}
160162

161163
Plugin *PluginManager::FetchPlugin(std::string name)

src/plugins/core/scripting.h

Lines changed: 89 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -200,95 +200,95 @@ class PluginUserMessage
200200
std::string GetMessageName();
201201
int GetMessageID();
202202

203-
bool HasField(const char *pszFieldName);
204-
205-
int32 GetInt32(const char *pszFieldName);
206-
void SetInt32(const char *pszFieldName, int32 value);
207-
int32 GetRepeatedInt32(const char *pszFieldName, int index);
208-
void SetRepeatedInt32(const char *pszFieldName, int index, int32 value);
209-
void AddInt32(const char *pszFieldName, int32 value);
210-
211-
int64 GetInt64(const char *pszFieldName);
212-
void SetInt64(const char *pszFieldName, int64 value);
213-
int64 GetRepeatedInt64(const char *pszFieldName, int index);
214-
void SetRepeatedInt64(const char *pszFieldName, int index, int64 value);
215-
void AddInt64(const char *pszFieldName, int64 value);
216-
217-
uint32 GetUInt32(const char *pszFieldName);
218-
void SetUInt32(const char *pszFieldName, uint32 value);
219-
uint32 GetRepeatedUInt32(const char *pszFieldName, int index);
220-
void SetRepeatedUInt32(const char *pszFieldName, int index, uint32 value);
221-
void AddUInt32(const char *pszFieldName, uint32 value);
222-
223-
uint64 GetUInt64(const char *pszFieldName);
224-
void SetUInt64(const char *pszFieldName, uint64 value);
225-
uint64 GetRepeatedUInt64(const char *pszFieldName, int index);
226-
void SetRepeatedUInt64(const char *pszFieldName, int index, uint64 value);
227-
void AddUInt64(const char *pszFieldName, uint64 value);
228-
229-
int64 GetInt64OrUnsigned(const char *pszFieldName);
230-
void SetInt64OrUnsigned(const char *pszFieldName, int64 value);
231-
int64 GetRepeatedInt64OrUnsigned(const char *pszFieldName, int index);
232-
void SetRepeatedInt64OrUnsigned(const char *pszFieldName, int index, int64 value);
233-
void AddInt64OrUnsigned(const char *pszFieldName, int64 value);
234-
235-
bool GetBool(const char *pszFieldName);
236-
void SetBool(const char *pszFieldName, bool value);
237-
bool GetRepeatedBool(const char *pszFieldName, int index);
238-
void SetRepeatedBool(const char *pszFieldName, int index, bool value);
239-
void AddBool(const char *pszFieldName, bool value);
240-
241-
float GetFloat(const char *pszFieldName);
242-
void SetFloat(const char *pszFieldName, float value);
243-
float GetRepeatedFloat(const char *pszFieldName, int index);
244-
void SetRepeatedFloat(const char *pszFieldName, int index, float value);
245-
void AddFloat(const char *pszFieldName, float value);
246-
247-
double GetDouble(const char *pszFieldName);
248-
void SetDouble(const char *pszFieldName, double value);
249-
double GetRepeatedDouble(const char *pszFieldName, int index);
250-
void SetRepeatedDouble(const char *pszFieldName, int index, double value);
251-
void AddDouble(const char *pszFieldName, double value);
252-
253-
float GetFloatOrDouble(const char *pszFieldName);
254-
void SetFloatOrDouble(const char *pszFieldName, float value);
255-
float GetRepeatedFloatOrDouble(const char *pszFieldName, int index);
256-
void SetRepeatedFloatOrDouble(const char *pszFieldName, int index, float value);
257-
void AddFloatOrDouble(const char *pszFieldName, float value);
258-
259-
std::string GetString(const char *pszFieldName);
260-
void SetString(const char *pszFieldName, const char *value);
261-
std::string GetRepeatedString(const char *pszFieldName, int index);
262-
void SetRepeatedString(const char *pszFieldName, int index, const char *value);
263-
void AddString(const char *pszFieldName, const char *value);
264-
265-
Color GetColor(const char *pszFieldName);
266-
void SetColor(const char *pszFieldName, const Color &value);
267-
Color GetRepeatedColor(const char *pszFieldName, int index);
268-
void SetRepeatedColor(const char *pszFieldName, int index, const Color &value);
269-
void AddColor(const char *pszFieldName, const Color &value);
270-
271-
Vector2D GetVector2D(const char *pszFieldName);
272-
void SetVector2D(const char *pszFieldName, Vector2D &vec);
273-
Vector2D GetRepeatedVector2D(const char *pszFieldName, int index);
274-
void SetRepeatedVector2D(const char *pszFieldName, int index, Vector2D &vec);
275-
void AddVector2D(const char *pszFieldName, Vector2D &vec);
276-
277-
Vector GetVector(const char *pszFieldName);
278-
void SetVector(const char *pszFieldName, Vector &vec);
279-
Vector GetRepeatedVector(const char *pszFieldName, int index);
280-
void SetRepeatedVector(const char *pszFieldName, int index, Vector &vec);
281-
void AddVector(const char *pszFieldName, Vector &vec);
282-
283-
QAngle GetQAngle(const char *pszFieldName);
284-
void SetQAngle(const char *pszFieldName, QAngle &vec);
285-
QAngle GetRepeatedQAngle(const char *pszFieldName, int index);
286-
void SetRepeatedQAngle(const char *pszFieldName, int index, QAngle &vec);
287-
void AddQAngle(const char *pszFieldName, QAngle &vec);
288-
289-
void RemoveRepeatedFieldValue(const char *pszFieldName, int index);
290-
291-
int GetRepeatedFieldCount(const char *pszFieldName);
203+
bool HasField(std::string pszFieldName);
204+
205+
int32 GetInt32(std::string pszFieldName);
206+
void SetInt32(std::string pszFieldName, int32 value);
207+
int32 GetRepeatedInt32(std::string pszFieldName, int index);
208+
void SetRepeatedInt32(std::string pszFieldName, int index, int32 value);
209+
void AddInt32(std::string pszFieldName, int32 value);
210+
211+
int64 GetInt64(std::string pszFieldName);
212+
void SetInt64(std::string pszFieldName, int64 value);
213+
int64 GetRepeatedInt64(std::string pszFieldName, int index);
214+
void SetRepeatedInt64(std::string pszFieldName, int index, int64 value);
215+
void AddInt64(std::string pszFieldName, int64 value);
216+
217+
uint32 GetUInt32(std::string pszFieldName);
218+
void SetUInt32(std::string pszFieldName, uint32 value);
219+
uint32 GetRepeatedUInt32(std::string pszFieldName, int index);
220+
void SetRepeatedUInt32(std::string pszFieldName, int index, uint32 value);
221+
void AddUInt32(std::string pszFieldName, uint32 value);
222+
223+
uint64 GetUInt64(std::string pszFieldName);
224+
void SetUInt64(std::string pszFieldName, uint64 value);
225+
uint64 GetRepeatedUInt64(std::string pszFieldName, int index);
226+
void SetRepeatedUInt64(std::string pszFieldName, int index, uint64 value);
227+
void AddUInt64(std::string pszFieldName, uint64 value);
228+
229+
int64 GetInt64OrUnsigned(std::string pszFieldName);
230+
void SetInt64OrUnsigned(std::string pszFieldName, int64 value);
231+
int64 GetRepeatedInt64OrUnsigned(std::string pszFieldName, int index);
232+
void SetRepeatedInt64OrUnsigned(std::string pszFieldName, int index, int64 value);
233+
void AddInt64OrUnsigned(std::string pszFieldName, int64 value);
234+
235+
bool GetBool(std::string pszFieldName);
236+
void SetBool(std::string pszFieldName, bool value);
237+
bool GetRepeatedBool(std::string pszFieldName, int index);
238+
void SetRepeatedBool(std::string pszFieldName, int index, bool value);
239+
void AddBool(std::string pszFieldName, bool value);
240+
241+
float GetFloat(std::string pszFieldName);
242+
void SetFloat(std::string pszFieldName, float value);
243+
float GetRepeatedFloat(std::string pszFieldName, int index);
244+
void SetRepeatedFloat(std::string pszFieldName, int index, float value);
245+
void AddFloat(std::string pszFieldName, float value);
246+
247+
double GetDouble(std::string pszFieldName);
248+
void SetDouble(std::string pszFieldName, double value);
249+
double GetRepeatedDouble(std::string pszFieldName, int index);
250+
void SetRepeatedDouble(std::string pszFieldName, int index, double value);
251+
void AddDouble(std::string pszFieldName, double value);
252+
253+
float GetFloatOrDouble(std::string pszFieldName);
254+
void SetFloatOrDouble(std::string pszFieldName, float value);
255+
float GetRepeatedFloatOrDouble(std::string pszFieldName, int index);
256+
void SetRepeatedFloatOrDouble(std::string pszFieldName, int index, float value);
257+
void AddFloatOrDouble(std::string pszFieldName, float value);
258+
259+
std::string GetString(std::string pszFieldName);
260+
void SetString(std::string pszFieldName, const char *value);
261+
std::string GetRepeatedString(std::string pszFieldName, int index);
262+
void SetRepeatedString(std::string pszFieldName, int index, const char *value);
263+
void AddString(std::string pszFieldName, const char *value);
264+
265+
Color GetColor(std::string pszFieldName);
266+
void SetColor(std::string pszFieldName, const Color &value);
267+
Color GetRepeatedColor(std::string pszFieldName, int index);
268+
void SetRepeatedColor(std::string pszFieldName, int index, const Color &value);
269+
void AddColor(std::string pszFieldName, const Color &value);
270+
271+
Vector2D GetVector2D(std::string pszFieldName);
272+
void SetVector2D(std::string pszFieldName, Vector2D &vec);
273+
Vector2D GetRepeatedVector2D(std::string pszFieldName, int index);
274+
void SetRepeatedVector2D(std::string pszFieldName, int index, Vector2D &vec);
275+
void AddVector2D(std::string pszFieldName, Vector2D &vec);
276+
277+
Vector GetVector(std::string pszFieldName);
278+
void SetVector(std::string pszFieldName, Vector &vec);
279+
Vector GetRepeatedVector(std::string pszFieldName, int index);
280+
void SetRepeatedVector(std::string pszFieldName, int index, Vector &vec);
281+
void AddVector(std::string pszFieldName, Vector &vec);
282+
283+
QAngle GetQAngle(std::string pszFieldName);
284+
void SetQAngle(std::string pszFieldName, QAngle &vec);
285+
QAngle GetRepeatedQAngle(std::string pszFieldName, int index);
286+
void SetRepeatedQAngle(std::string pszFieldName, int index, QAngle &vec);
287+
void AddQAngle(std::string pszFieldName, QAngle &vec);
288+
289+
void RemoveRepeatedFieldValue(std::string pszFieldName, int index);
290+
291+
int GetRepeatedFieldCount(std::string pszFieldName);
292292

293293
void SendToPlayer(int playerId);
294294
void SendToAllPlayers();

src/plugins/core/scripting/database.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,10 @@ PluginDatabase::PluginDatabase(std::string m_connection_name)
9797
{
9898
this->connection_name = m_connection_name;
9999
this->db = g_dbManager->GetDatabase(this->connection_name);
100-
this->dbConnected = this->db->Connect();
100+
if (!this->db)
101+
this->dbConnected = false;
102+
else
103+
this->dbConnected = this->db->Connect();
101104
}
102105

103106
bool PluginDatabase::IsConnected()

0 commit comments

Comments
 (0)