Skip to content

Commit b2211d3

Browse files
committed
Push updates, final changes
1 parent d0b15e5 commit b2211d3

4 files changed

Lines changed: 53 additions & 18 deletions

File tree

.github/workflows/build.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ jobs:
3535
uses: actions/upload-artifact@v4
3636
with:
3737
name: CrowControl
38+
retention-days: 10
3839
path: |
3940
everest.yaml
4041
bin
@@ -43,3 +44,14 @@ jobs:
4344
Dialog/**/*
4445
Graphics/**/*
4546
Loenn/**/*
47+
- name: Make Draft Release
48+
uses: ncipollo/release-action@v1
49+
if: startsWith(github.ref, 'refs/tags/')
50+
with:
51+
artifacts: "CrowControl.zip"
52+
allowUpdates: true
53+
generateReleaseNotes: true
54+
makeLatest: "latest"
55+
draft: true
56+
57+

README.md

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,23 @@
11
# CrowControl
22

3-
Twitch in Celeste.
3+
Twitch Integration in Celeste without CrowdControl.
4+
5+
## What does this fork change?
6+
7+
This is the same as original CrowControl with the following fixes:
8+
9+
* Update version.
10+
* Update to the current API/SDK.
11+
* Update plugin layout layout.
12+
* Requests properly count up.
13+
* Option: Commands can require unique user, allowing you to prevent the scenario of one user be able to spam `!die` a bunch of times.
14+
* Option: Spawned enemy AI is cleaned up properly on death.
15+
* Fix `!die` to work properly when already dead.
16+
* Exit the application cleanly, when connected.
17+
* Fix high CPU usage (because of inf. loop).
18+
* Fix websocket connection options so they do not crash the application.
19+
* Adds github runners.
20+
21+
I do not play Celeste, I just made these fixes for [ffoxes](https://twitch.tv/ffoxes).
22+
23+
You can download this from the releases tab, so long as the github actions decide to work.

Source/CrowControlModule.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,7 @@ private void Player_Added(On.Celeste.Player.orig_Added orig, Player self, Monocl
519519
static private void Engine_OnExiting(Engine.orig_OnExiting orig, Monocle.Engine self, object sender, EventArgs args)
520520
{
521521
Settings.ReconnectOnDisconnect = false;
522+
Settings.IsExiting = true;
522523
Settings.StopThread();
523524
orig(self, sender, args);
524525
}

Source/CrowControlSettings.cs

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,11 @@ public class CrowControlSettings : EverestModuleSettings
131131
private Thread webSocketThread;
132132
private Random rand = new Random();
133133

134+
// better handle socket disconnections
135+
public bool IsExiting = false;
136+
private CancellationTokenSource cancelToken;
137+
private bool clickedDisconnect = false;
138+
134139
[YamlIgnore] public Dictionary<MessageType, List<string>> currentVoteCounts = new Dictionary<MessageType, List<string>>();
135140

136141
public CrowControlSettings()
@@ -150,11 +155,6 @@ public void EffectTimeChange()
150155
CrowControlModule.GetTimerHelper().ChangeTimerIntervals();
151156
}
152157

153-
public void ClearAllVotes()
154-
{
155-
156-
}
157-
158158
public void CreateChannelNameEntry(TextMenu textMenu, bool inGame)
159159
{
160160
if (!inGame)
@@ -176,6 +176,9 @@ public void CreateConnectEntry(TextMenu textMenu, bool inGame)
176176
{
177177
if (webSocketThread == null && Enabled)
178178
{
179+
IsReconnecting = false;
180+
clickedDisconnect = false;
181+
cancelToken = new CancellationTokenSource();
179182
webSocketThread = new Thread(StartWebSocket);
180183
webSocketThread.Start();
181184
}
@@ -188,6 +191,8 @@ public void CreateDisconnectEntry(TextMenu textMenu, bool inGame)
188191
{
189192
if (webSocketThread != null && webSocketThread.IsAlive)
190193
{
194+
IsReconnecting = false;
195+
clickedDisconnect = true;
191196
StopThread();
192197
}
193198
}));
@@ -203,7 +208,7 @@ public void StopThread()
203208
{
204209
if (webSocketThread != null && webSocketThread.IsAlive)
205210
{
206-
Enabled = false;
211+
cancelToken.Cancel();
207212
webSocketThread.Join();
208213
webSocketThread = null;
209214
}
@@ -233,17 +238,13 @@ public void StartWebSocket()
233238
Console.WriteLine("JOINING");
234239

235240
IsReconnecting = false;
236-
237-
while (Enabled)
238-
{
239-
240-
}
241+
cancelToken.Token.WaitHandle.WaitOne();
241242
}
242243
}
243244

244245
private void ReconnectIfDisconnected()
245246
{
246-
if (ReconnectOnDisconnect)
247+
if (ReconnectOnDisconnect && !IsExiting && !clickedDisconnect)
247248
{
248249
if (Connected == false)
249250
{
@@ -254,7 +255,7 @@ private void ReconnectIfDisconnected()
254255

255256
if (webSocketThread == null)
256257
{
257-
Enabled = true;
258+
cancelToken = new CancellationTokenSource();
258259
webSocketThread = new Thread(StartWebSocket);
259260
webSocketThread.Start();
260261
}
@@ -279,7 +280,10 @@ private void Ws_OnClose(object sender, CloseEventArgs e)
279280

280281
CrowControlModule.OnDisconnect();
281282
Connected = false;
282-
ReconnectIfDisconnected();
283+
if (!clickedDisconnect)
284+
ReconnectIfDisconnected();
285+
// Reset this flag
286+
clickedDisconnect = false;
283287
}
284288

285289
private void Ws_OnOpen(object sender, EventArgs e)
@@ -303,10 +307,8 @@ private void Ws_OnMessage(object sender, MessageEventArgs e)
303307
if (chatMsg.Bits >= MinimumBitsToSkip && MinimumBitsToSkip > 0)
304308
{
305309
CrowControlModule.OnMessageWithBits(chatMsg);
306-
return;
307310
}
308-
309-
if ((chatMsg.IsCustomReward && RequireChannelPoints) || !RequireChannelPoints)
311+
else if ((chatMsg.IsCustomReward && RequireChannelPoints) || !RequireChannelPoints)
310312
{
311313
CrowControlModule.OnCustomRewardMessage(chatMsg);
312314
}

0 commit comments

Comments
 (0)