From f270d847ccf7a5edff852568e57f11da4f3dc013 Mon Sep 17 00:00:00 2001 From: Kesefon Date: Tue, 29 Dec 2020 13:56:39 +0100 Subject: [PATCH] Fix spelling Based on https://github.com/fluffy-servers/gmod-discord-rpc/commit/286e47e95c0fa23e70dbbb7c95de711e0a039d1d --- cpp/GRPCTest.cpp | 54 ++++++++++++++++++++++-------------------------- 1 file changed, 25 insertions(+), 29 deletions(-) diff --git a/cpp/GRPCTest.cpp b/cpp/GRPCTest.cpp index 19de6d7..4d11ab0 100644 --- a/cpp/GRPCTest.cpp +++ b/cpp/GRPCTest.cpp @@ -11,48 +11,46 @@ std::pair cbError; char cbJoinSecret; char cbSpectateSecret; DiscordUser cbJoinRequest; -bool cbConUserTriggerd, cbDisconnectedTriggerd, cbErrorTriggerd, cbJoinTriggerd, - cbSpectateTriggerd, cbJoinRequestTriggerd; +bool cbConUserTriggered, cbDisconnectedTriggered, cbErrorTriggered, + cbJoinTriggered, cbSpectateTriggered, cbJoinRequestTriggered; static void HandleDiscordReady(const DiscordUser *connectedUser) { cbConUser = *connectedUser; - cbConUserTriggerd = true; + cbConUserTriggered = true; } static void HandleDiscordDisconnected(int errcode, const char *message) { cbDisconnected.first = errcode; cbDisconnected.second = *message; - cbDisconnectedTriggerd = true; + cbDisconnectedTriggered = true; } static void HandleDiscordError(int errcode, const char *message) { cbError.first = errcode; cbError.second = *message; - cbConUserTriggerd = true; + cbConUserTriggered = true; } static void HandleDiscordJoin(const char *secret) { cbJoinSecret = *secret; - cbJoinTriggerd = true; + cbJoinTriggered = true; } static void HandleDiscordSpectate(const char *secret) { cbSpectateSecret = *secret; - cbSpectateTriggerd = true; + cbSpectateTriggered = true; } static void HandleDiscordJoinRequest(const DiscordUser *request) { cbJoinRequest = *request; - cbJoinRequestTriggerd = true; + cbJoinRequestTriggered = true; } LUA_FUNCTION(StartDiscordStatus) { - - const char *appid = LUA->GetString(1); + const char *discordAppId = LUA->GetString(1); // Discord RPC DiscordEventHandlers handlers{}; - handlers.ready = HandleDiscordReady; handlers.disconnected = HandleDiscordDisconnected; handlers.errored = HandleDiscordError; @@ -60,8 +58,7 @@ LUA_FUNCTION(StartDiscordStatus) { handlers.spectateGame = HandleDiscordSpectate; handlers.joinRequest = HandleDiscordJoinRequest; - Discord_Initialize(appid, &handlers, 1, 0); - + Discord_Initialize(discordAppId, &handlers, 1, "4000"); return 0; } @@ -69,62 +66,62 @@ LUA_FUNCTION(RunDiscordCallbacks) { Discord_RunCallbacks(); LUA->PushSpecial(GarrysMod::Lua::SPECIAL_GLOB); LUA->GetField(-1, "hook"); - if (cbConUserTriggerd) { + if (cbConUserTriggered) { LUA->GetField(-1, "Run"); LUA->PushString("DiscordReady"); LUA->PushString(cbConUser.userId); LUA->PushString(cbConUser.username); LUA->PushString(cbConUser.discriminator); LUA->PushString(cbConUser.avatar); - LUA->PushString(cbConUser.username); + LUA->PushString(cbConUser.username); // wontfix; use upstream LUA->Call(6, 0); - cbConUserTriggerd = false; + cbConUserTriggered = false; } - if (cbDisconnectedTriggerd) { + if (cbDisconnectedTriggered) { LUA->GetField(-1, "Run"); LUA->PushString("DiscordDisconnected"); LUA->PushNumber(cbDisconnected.first); LUA->PushString(&cbDisconnected.second); LUA->Call(3, 0); - cbDisconnectedTriggerd = false; + cbDisconnectedTriggered = false; } - if (cbErrorTriggerd) { + if (cbErrorTriggered) { LUA->GetField(-1, "Run"); LUA->PushString("DiscordError"); LUA->PushNumber(cbError.first); LUA->PushString(&cbError.second); LUA->Call(3, 0); - cbErrorTriggerd = false; + cbErrorTriggered = false; } - if (cbJoinTriggerd) { + if (cbJoinTriggered) { LUA->GetField(-1, "Run"); LUA->PushString("DiscordJoin"); LUA->PushString(&cbJoinSecret); LUA->Call(2, 0); - cbJoinTriggerd = false; + cbJoinTriggered = false; } - if (cbSpectateTriggerd) { + if (cbSpectateTriggered) { LUA->GetField(-1, "Run"); LUA->PushString("DiscordSpectate"); LUA->PushString(&cbSpectateSecret); LUA->Call(2, 0); - cbSpectateTriggerd = false; + cbSpectateTriggered = false; } - if (cbJoinRequestTriggerd) { + if (cbJoinRequestTriggered) { LUA->GetField(-1, "Run"); LUA->PushString("DiscordJoinRequest"); LUA->PushString(cbJoinRequest.userId); LUA->PushString(cbJoinRequest.username); LUA->PushString(cbJoinRequest.discriminator); LUA->PushString(cbJoinRequest.avatar); - LUA->PushString(cbJoinRequest.username); + LUA->PushString(cbJoinRequest.username); // wontfix; use upstream LUA->Call(6, 0); - cbJoinRequestTriggerd = false; + cbJoinRequestTriggered = false; } LUA->Pop(2); @@ -233,7 +230,6 @@ LUA_FUNCTION(UpdateDiscordStatus_Elapsed) { } GMOD_MODULE_OPEN() { - // Create the functions LUA->PushSpecial(GarrysMod::Lua::SPECIAL_GLOB); LUA->PushCFunction(StartDiscordStatus); LUA->SetField(-2, "DiscordRPCInitialize"); @@ -270,4 +266,4 @@ GMOD_MODULE_OPEN() { GMOD_MODULE_CLOSE() { Discord_Shutdown(); return 0; -} \ No newline at end of file +}