Skip to content

Commit 9360fc4

Browse files
committed
v2.1.0
1 parent 7f3bcac commit 9360fc4

File tree

5 files changed

+32
-14
lines changed

5 files changed

+32
-14
lines changed

BetterChat.cpp

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ void BetterChat::onLoad()
5353
cvarManager->registerCvar("betterchat_antispam", "1", "Enable AntiSpam", true, true, 0, true, 1);
5454
cvarManager->registerCvar("betterchat_chatfilter", "1", "Enable ChatFilter", true, true, 0, true, 1);
5555
cvarManager->registerCvar("betterchat_delay", "5", "Delay between two same messages from the same player", true, true, 0, true, 10);
56-
cvarManager->registerCvar("betterchat_writtenmsg", "0", "Disable written messages", true, true, 0, true, 1);
56+
cvarManager->registerCvar("betterchat_nowrittenmsg", "0", "Disable written messages", true, true, 0, true, 1);
57+
cvarManager->registerCvar("betterchat_writtenmsgastoxic", "0", "Consider written messages as toxic", true, true, 0, true, 1);
5758
cvarManager->registerCvar("betterchat_aftersavetime", "5", "Time the 'After save' messages are allowed after a save", true, true, 0, true, 20);
5859
cvarManager->registerCvar("betterchat_owngoal", "0", "Do not count the goal if it is an owngoal", true, true, 0, true, 1);
5960
cvarManager->registerCvar("betterchat_unwanted_pass", "0", "Do not count the pass if an opponent touch it before the goal", true, true, 0, true, 1);
@@ -80,10 +81,15 @@ void BetterChat::onLoad()
8081
void BetterChat::onUnload()
8182
{
8283
LOG("Plugin Off");
83-
gameWrapper->UnhookEvent("Function TAGame.HUDBase_TA.OnChatMessage");
84-
gameWrapper->UnhookEvent("Function TAGame.GFxData_Chat_TA.OnChatMessage");
8584
gameWrapper->UnhookEvent("Function GameEvent_TA.Countdown.BeginState");
8685
gameWrapper->UnhookEvent("Function TAGame.GFxHUD_TA.HandleStatTickerMessage");
86+
gameWrapper->UnhookEvent("Function TAGame.HUDBase_TA.OnChatMessage");
87+
gameWrapper->UnhookEvent("Function TAGame.Replay_TA.StopPlayback");
88+
gameWrapper->UnhookEvent("Function TAGame.Car_TA.EventHitBall");
89+
gameWrapper->UnhookEvent("Function TAGame.GameEvent_Soccar_TA.OnGameTimeUpdated");
90+
gameWrapper->UnhookEvent("Function TAGame.Ball_TA.OnHitGoal");
91+
gameWrapper->UnhookEvent("Function TAGame.GameEvent_TA.Destroyed");
92+
gameWrapper->UnhookEvent("Function TAGame.GameEvent_Soccar_TA.OnMatchWinnerSet");
8793
}
8894

8995
/// <summary>
@@ -568,13 +574,12 @@ void BetterChat::chatMessageEvent(ActorWrapper caller, void* params) {
568574
delay = std::chrono::seconds(0);
569575
}
570576

571-
playerInfo[playerName].numMsg += 1;
572-
573577
bool cancel = false;
574578

575579
regex quickchat_pattern("^Group\\dMessage\\d\\d?$");
576580
if (regex_match(msgID, quickchat_pattern)) // If it is a quickchat
577581
{
582+
playerInfo[playerName].numMsg += 1;
578583
if (msgID != playerInfo[playerName].previousMsg) { // Different message
579584
playerInfo[playerName].previousMsg = msgID;
580585
playerInfo[playerName].previousTime = chrono::system_clock::now();
@@ -599,9 +604,12 @@ void BetterChat::chatMessageEvent(ActorWrapper caller, void* params) {
599604
}
600605
}
601606
else {
602-
if (cvarManager->getCvar("betterchat_writtenmsg").getBoolValue()) {
607+
if (cvarManager->getCvar("betterchat_nowrittenmsg").getBoolValue()) {
603608
cancel = true;
604-
playerInfo[playerName].blockedMsg += 1;
609+
}
610+
if(cvarManager->getCvar("betterchat_writtenmsgastoxic").getBoolValue()) {
611+
if (cancel) playerInfo[playerName].blockedMsg += 1;
612+
playerInfo[playerName].numMsg += 1;
605613
}
606614
}
607615
handleMsg(cancel, playerName);

BetterChatGUI.cpp

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,13 @@ void BetterChat::RenderSettings() {
4444
if (!delayCvar) { return; }
4545
int delay = delayCvar.getIntValue();
4646

47-
CVarWrapper writtenMsgCvar = cvarManager->getCvar("betterchat_writtenmsg");
48-
if (!writtenMsgCvar) { return; }
49-
bool writtenMsg = writtenMsgCvar.getBoolValue();
47+
CVarWrapper noWrittenMsgCvar = cvarManager->getCvar("betterchat_nowrittenmsg");
48+
if (!noWrittenMsgCvar) { return; }
49+
bool noWrittenMsg = noWrittenMsgCvar.getBoolValue();
50+
51+
CVarWrapper writtenMsgAsToxicCvar = cvarManager->getCvar("betterchat_writtenmsgastoxic");
52+
if (!writtenMsgAsToxicCvar) { return; }
53+
bool writtenMsgAsToxic = writtenMsgAsToxicCvar.getBoolValue();
5054

5155
CVarWrapper afterSaveTimeCvar = cvarManager->getCvar("betterchat_aftersavetime");
5256
if (!afterSaveTimeCvar) { return; }
@@ -238,8 +242,14 @@ void BetterChat::RenderSettings() {
238242

239243
// Message filter options
240244
ImGui::Text("\nMessage filter options:");
241-
if (ImGui::Checkbox("Disable written messages", &writtenMsg)) {
242-
writtenMsgCvar.setValue(writtenMsg);
245+
if (ImGui::Checkbox("Block written messages", &noWrittenMsg)) {
246+
noWrittenMsgCvar.setValue(noWrittenMsg);
247+
}
248+
if (ImGui::Checkbox("Count written messages in the toxicity scores", &writtenMsgAsToxic)) {
249+
writtenMsgAsToxicCvar.setValue(writtenMsgAsToxic);
250+
}
251+
if (ImGui::IsItemHovered()) {
252+
ImGui::SetTooltip("If enabled, written messages will be considered as toxic if 'Block written messages' option is enabled, and as normal if not.");
243253
}
244254
if (ImGui::SliderInt("Time during which 'after a save' messages are allowed after a save.", &afterSaveTime, 0, 20)) {
245255
afterSaveTimeCvar.setValue(afterSaveTime);

plugins/BetterChat.dll

1.5 KB
Binary file not shown.

plugins/BetterChat.pdb

0 Bytes
Binary file not shown.

version.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#pragma once
22
#define VERSION_MAJOR 2
3-
#define VERSION_MINOR 0
3+
#define VERSION_MINOR 1
44
#define VERSION_PATCH 0
5-
#define VERSION_BUILD 199
5+
#define VERSION_BUILD 202
66

77
#define stringify(a) stringify_(a)
88
#define stringify_(a) #a

0 commit comments

Comments
 (0)