Skip to content

Commit 76298bd

Browse files
committed
Merge branch 'master' into pd-upscaler
2 parents 48dc40a + 2f75948 commit 76298bd

File tree

7 files changed

+1617
-34
lines changed

7 files changed

+1617
-34
lines changed

csharp-api/REFCoreDeps/PipeServer.cs

Lines changed: 40 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ static void ServerLoop()
154154
pipe = null; // prevent finally from disposing
155155
var clientThread = new Thread(() => {
156156
try { HandleClient(clientPipe, token); }
157+
catch (Exception ex) { Console.WriteLine("[PipeServer] Client error: " + ex.Message); }
157158
finally { try { clientPipe.Dispose(); } catch { } }
158159
}) { IsBackground = true, Name = "PipeServer.Client" };
159160
clientThread.Start();
@@ -178,46 +179,54 @@ static void ServerLoop()
178179

179180
static void HandleClient(NamedPipeServerStream pipe, CancellationToken token)
180181
{
181-
using var reader = new StreamReader(pipe, s_utf8NoBom, detectEncodingFromByteOrderMarks: false, leaveOpen: true);
182-
using var writer = new StreamWriter(pipe, s_utf8NoBom, leaveOpen: true) { AutoFlush = true };
182+
var reader = new StreamReader(pipe, s_utf8NoBom, detectEncodingFromByteOrderMarks: false, leaveOpen: true);
183+
var writer = new StreamWriter(pipe, s_utf8NoBom, leaveOpen: true) { AutoFlush = true };
183184

184-
while (!token.IsCancellationRequested && pipe.IsConnected)
185+
try
185186
{
186-
string line;
187-
try
188-
{
189-
line = reader.ReadLine();
190-
}
191-
catch
187+
while (!token.IsCancellationRequested && pipe.IsConnected)
192188
{
193-
break; // pipe broken
194-
}
189+
string line;
190+
try
191+
{
192+
line = reader.ReadLine();
193+
}
194+
catch
195+
{
196+
break; // pipe broken
197+
}
195198

196-
if (line == null) break; // client disconnected
199+
if (line == null) break; // client disconnected
197200

198-
line = line.Trim();
199-
if (line.Length == 0) continue;
201+
line = line.Trim();
202+
if (line.Length == 0) continue;
200203

201-
string response;
202-
try
203-
{
204-
response = DispatchRequest(line);
205-
}
206-
catch (Exception ex)
207-
{
208-
response = JsonSerializer.Serialize(new { id = 0, error = ex.Message });
209-
}
204+
string response;
205+
try
206+
{
207+
response = DispatchRequest(line);
208+
}
209+
catch (Exception ex)
210+
{
211+
response = JsonSerializer.Serialize(new { id = 0, error = ex.Message });
212+
}
210213

211-
try
212-
{
213-
writer.WriteLine(response);
214-
pipe.Flush();
215-
}
216-
catch
217-
{
218-
break; // pipe broken
214+
try
215+
{
216+
writer.WriteLine(response);
217+
pipe.Flush();
218+
}
219+
catch
220+
{
221+
break; // pipe broken
222+
}
219223
}
220224
}
225+
finally
226+
{
227+
try { writer.Dispose(); } catch { }
228+
try { reader.Dispose(); } catch { }
229+
}
221230

222231
Console.WriteLine("[PipeServer] Client disconnected");
223232
}

csharp-api/cmake.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ set_dotnet_references(CSharpAPITestWebAPI "mhwilds" "${MHWILDS_DLLS}")
282282
[target.CSharpAPITestRE9]
283283
condition = "build-csharp-test-re9"
284284
type = "CSharpSharedTarget"
285-
sources = ["test/Test/TestRE9.cs"]
285+
sources = ["test/Test/ZombieSpawner.cs"]
286286
link-libraries = ["csharp-api"]
287287
cmake-after = """
288288
set_dotnet_references(CSharpAPITestRE9 "re9" "${RE9_DLLS}")

0 commit comments

Comments
 (0)