fix: Windows paths → ./gamepack/, empty Console.ReadLine guard

- SendPack(): C:\Users\Administrator\Desktop\temp\ → ./gamepack/
  (Path.Combine + Directory.CreateDirectory for cross-platform)
- WaitWanJiaShuRu(): add IsNullOrWhiteSpace + ss.Length checks
  before accessing ss[0]/ss[1] to prevent IndexOutOfRange on empty input
- .gitignore: add gamepack/ exclusion
This commit is contained in:
2026-07-07 12:56:39 +08:00
parent 49cc0f0df4
commit 025b8fc1e2
19 changed files with 85 additions and 63 deletions

View File

@ -488,8 +488,10 @@ namespace PdkFriendServer.Logic
if (DeskGameDo == null)
{
var str = JsonPack.GetJson(this.GamePack);
File.WriteAllText(@"C:\Users\Administrator\Desktop\temp\gamepack.txt", str);
var path = $@"C:\Users\Administrator\Desktop\temp\test\gamepack{DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss-fff")}.txt";
var dir = "./gamepack";
if (!Directory.Exists(dir)) Directory.CreateDirectory(dir);
File.WriteAllText(Path.Combine(dir, "gamepack.txt"), str);
var path = Path.Combine(dir, $"gamepack{DateTime.Now:yyyy-MM-dd-HH-mm-ss-fff}.txt");
Log("保存文件:" + path);
File.WriteAllText(path, str);
WaitWanJiaShuRu(); //等玩家输入。模拟玩家打牌
@ -619,8 +621,10 @@ namespace PdkFriendServer.Logic
while (true)
{
str = Console.ReadLine();
if (string.IsNullOrWhiteSpace(str)) continue;
Log(str);
var ss = str.Split(',');
if (ss.Length < 2) continue;
byte.TryParse(ss[0], out var pos);
byte.TryParse(ss[1], out num);
GamePack.Info.WhoPlay = pos;
@ -640,6 +644,7 @@ namespace PdkFriendServer.Logic
while (true)
{
str = Console.ReadLine(); //逗号分隔
if (string.IsNullOrWhiteSpace(str)) continue;
var ss = str.Split(',');
if (ss.Length <= 0) continue;
Log(str);