Skip to content

Commit a88bb04

Browse files
committed
fix(database): Query Callback not being set
1 parent ea31d45 commit a88bb04

File tree

7 files changed

+35
-30
lines changed

7 files changed

+35
-30
lines changed

plugin_files/gamedata/core/signatures.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,5 +118,10 @@
118118
"lib": "server",
119119
"windows": "48 8B 3D ? ? ? ? 48 85 FF 0F 84 ? ? ? ? BE",
120120
"linux": "4C 8B 35 ? ? ? ? 4D 85 F6 75 ? E9"
121+
},
122+
"CCSPlayer_MovementServices_ProcessUserCmd": {
123+
"lib": "server",
124+
"windows": "48 89 5C 24 ? 48 89 74 24 ? 57 48 83 EC ? 48 8B FA 48 8B F1 E8 ? ? ? ? 48 8B D8",
125+
"linux": "55 48 89 E5 41 55 49 89 F5 41 54 49 89 FC E8 ? ? ? ? 48 85 C0 74 30"
121126
}
122127
}

src/engine/vgui/VGUI.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ void VGUI::RegenerateScreenTexts()
4949

5050
void VGUI::FilterRenderingItems(Player* player, CCheckTransmitInfo* pInfo)
5151
{
52-
#pragma omp parallel for
5352
for(auto it = screenTexts.begin(); it != screenTexts.end(); ++it) {
5453
if(it->second->GetPlayer() != player) {
5554
int entIndex = it->second->GetEntityIndex();
@@ -72,15 +71,13 @@ void VGUI::CheckRenderForPlayer(int pid, Player* player, CHandle<CBaseEntity> sp
7271
}
7372

7473
if(shouldRegenerate) {
75-
#pragma omp parallel for
7674
for(auto it = screenTexts.begin(); it != screenTexts.end(); ++it) {
7775
if(it->second->GetPlayer() == player) {
7876
it->second->RegenerateText(false);
7977
it->second->SetRenderingTo(specView.Get());
8078
}
8179
}
8280
} else {
83-
#pragma omp parallel for
8481
for(auto it = screenTexts.begin(); it != screenTexts.end(); ++it) {
8582
if(it->second->GetPlayer() == player && !it->second->IsRenderingTo(specView)) {
8683
it->second->RegenerateText(false);

src/entrypoint.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,6 @@ void Swiftly::Hook_GameFrame(bool simulating, bool bFirstTick, bool bLastTick)
430430
//////////////////////////////////////////////////////////////
431431
///////////////// Player //////////////
432432
////////////////////////////////////////////////////////////
433-
#pragma omp parallel for
434433
for (int i = 0; i < 64; i++)
435434
{
436435
if ((g_Players & (1ULL << i)) != 0) {

src/plugins/core/scripting/network/database.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,15 @@ PluginDatabase::PluginDatabase(std::string m_connection_name)
2828

2929
void PluginDatabase::Query(std::string query, EValue callback, EContext* L)
3030
{
31-
if (this->db->GetKind() != "mysql") {
31+
if (this->db->GetKind() != "mysql" && this->db->GetKind() != "sqlite") {
3232
PLUGIN_PRINT("Database - Query", "This function is supporting only MySQL databases.\n");
3333
return;
3434
}
3535
std::string uuid = get_uuid();
3636

3737
EValue databaseRequestsQueue = EValue::getGlobal(L, "databaseRequestsQueue");
3838
if (databaseRequestsQueue.isTable())
39-
databaseRequestsQueue[uuid] = callback;
39+
databaseRequestsQueue.setProperty(uuid, EValue(callback));
4040

4141
DatabaseQueryQueue queue = {
4242
query,
@@ -47,7 +47,7 @@ void PluginDatabase::Query(std::string query, EValue callback, EContext* L)
4747

4848
void PluginDatabase::QueryParams(std::string query, std::map<EValue, EValue> params, EValue callback, EContext* L)
4949
{
50-
if (this->db->GetKind() != "mysql") {
50+
if (this->db->GetKind() != "mysql" && this->db->GetKind() != "sqlite") {
5151
PLUGIN_PRINT("Database - Query", "This function is supporting only MySQL databases.\n");
5252
return;
5353
}

src/plugins/core/scripting/network/usermessage.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -872,40 +872,40 @@ int PluginUserMessage::GetRepeatedFieldCount(std::string pszFieldName)
872872

873873
void PluginUserMessage::AddClient(int playerId)
874874
{
875-
if(!this->clients) return;
875+
if (!this->clients) return;
876876

877877
uint64 newcls = *this->clients;
878-
if(newcls & ((uint64)1 << playerId))
878+
if (newcls & ((uint64)1 << playerId))
879879
newcls |= ((uint64)1 << playerId);
880880

881881
memcpy(this->clients, &newcls, sizeof(newcls));
882882
}
883883

884884
void PluginUserMessage::RemoveClient(int playerId)
885885
{
886-
if(!this->clients) return;
886+
if (!this->clients) return;
887887

888888
uint64 newcls = *this->clients;
889-
if(newcls & ((uint64)1 << playerId))
889+
if (newcls & ((uint64)1 << playerId))
890890
newcls &= ~((uint64)1 << playerId);
891891

892892
memcpy(this->clients, &newcls, sizeof(newcls));
893893
}
894894

895895
void PluginUserMessage::ClearClients()
896896
{
897-
if(!this->clients) return;
897+
if (!this->clients) return;
898898

899899
uint64 newcls = 0;
900900
memcpy(this->clients, &newcls, sizeof(newcls));
901901
}
902902

903903
void PluginUserMessage::AddClients()
904904
{
905-
if(!this->clients) return;
906-
905+
if (!this->clients) return;
906+
907907
uint64 newcls = 0;
908-
for(int i = 0; i < 64; i++)
908+
for (int i = 0; i < 64; i++)
909909
newcls |= ((uint64)1 << i);
910910

911911
memcpy(this->clients, &newcls, sizeof(newcls));
@@ -914,11 +914,11 @@ void PluginUserMessage::AddClients()
914914
std::vector<int> PluginUserMessage::GetClients()
915915
{
916916
std::vector<int> clns;
917-
if(!this->clients) return clns;
917+
if (!this->clients) return clns;
918918

919919
uint64 cls = *this->clients;
920-
for(int i = 0; i < 64; i++)
921-
if(cls & ((uint64)1 << i))
920+
for (int i = 0; i < 64; i++)
921+
if (cls & ((uint64)1 << i))
922922
clns.push_back(i);
923923

924924
return clns;

src/plugins/core/scripting/server/utils.cpp

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,17 @@ std::string scripting_GetPluginPath(std::string plugin_name)
4040
PluginUserMessage scripting_GetUserMessage(std::string str)
4141
{
4242
auto exploded = explode(str, "|");
43-
if (exploded.size() != 3) return PluginUserMessage("");
44-
45-
INetworkMessageInternal* msg = (INetworkMessageInternal*)(strtol(exploded[0].c_str(), nullptr, 16));
46-
CNetMessage* netmsg = (CNetMessage*)(strtol(exploded[1].c_str(), nullptr, 16));
47-
uint64* clients = (uint64*)(strtol(exploded[2].c_str(), nullptr, 16));
48-
49-
return PluginUserMessage(msg, netmsg, clients);
43+
if (exploded.size() == 1) {
44+
google::protobuf::Message* msg = (google::protobuf::Message*)(strtol(exploded[0].c_str(), nullptr, 16));
45+
return PluginUserMessage(msg);
46+
}
47+
else if (exploded.size() == 3) {
48+
INetworkMessageInternal* msg = (INetworkMessageInternal*)(strtol(exploded[0].c_str(), nullptr, 16));
49+
CNetMessage* netmsg = (CNetMessage*)(strtol(exploded[1].c_str(), nullptr, 16));
50+
uint64* clients = (uint64*)(strtol(exploded[2].c_str(), nullptr, 16));
51+
return PluginUserMessage(msg, netmsg, clients);
52+
}
53+
else return PluginUserMessage("");
5054
}
5155

5256
std::string scripting_CreateTextTable(std::vector<std::vector<std::string>> data)

src/sdk/entity/services.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,13 @@ class CPlayer_MovementServices : public CPlayerPawnComponent
6060
SCHEMA_FIELD_OFFSET(float, m_flMaxspeed, 0);
6161
};
6262

63-
class CPlayer_MovementServices_Humanoid : CPlayer_MovementServices
63+
class CPlayer_MovementServices_Humanoid : public CPlayer_MovementServices
6464
{
6565
public:
6666
DECLARE_SCHEMA_CLASS_BASE(CPlayer_MovementServices_Humanoid)
6767
};
6868

69-
class CCSPlayer_MovementServices : CPlayer_MovementServices_Humanoid
69+
class CCSPlayer_MovementServices : public CPlayer_MovementServices_Humanoid
7070
{
7171
public:
7272
DECLARE_SCHEMA_CLASS_BASE(CCSPlayer_MovementServices)
@@ -194,7 +194,7 @@ class CPlayer_ObserverServices : public CPlayerPawnComponent
194194
public:
195195
DECLARE_SCHEMA_CLASS_BASE(CPlayer_ObserverServices);
196196

197-
SCHEMA_FIELD_OFFSET(uint8, m_iObserverMode, 0);
198-
SCHEMA_FIELD_OFFSET(CHandle<CBaseEntity>, m_hObserverTarget, 0);
199-
SCHEMA_FIELD_OFFSET(bool, m_bForcedObserverMode, 0);
197+
SCHEMA_FIELD_OFFSET(uint8, m_iObserverMode, 0);
198+
SCHEMA_FIELD_OFFSET(CHandle<CBaseEntity>, m_hObserverTarget, 0);
199+
SCHEMA_FIELD_OFFSET(bool, m_bForcedObserverMode, 0);
200200
};

0 commit comments

Comments
 (0)