Skip to content
This repository was archived by the owner on Sep 7, 2023. It is now read-only.

Commit f8efbb5

Browse files
authored
Merge pull request #72 from THU-ASTA/develop
Deal with exception in host packets
2 parents a8a81d9 + 4d5cd64 commit f8efbb5

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

Source/MainWindow.cs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,24 @@ private void Communicate()
426426
}
427427
}
428428

429+
if ((int)Game.GameDuration[this._game.GameStage] != Game.GameDuration[this._game.GameStage])
430+
{
431+
throw new Exception("GameDuration overflow");
432+
}
433+
if (ownChargingPiles.Count > 0x7f)
434+
{
435+
throw new Exception("The length of the ownChargingPiles is greater than 127");
436+
}
437+
if (opponentChargingPiles.Count > 0x7f)
438+
{
439+
throw new Exception("The length of the opponentChargingPiles is greater than 127");
440+
}
441+
if (_game.BarrierList.Count > 0x7f)
442+
{
443+
throw new Exception("The length of the BarrierList is greater than 127");
444+
}
445+
446+
429447
var gameInfoPacket = new PacketGetGameInformationHost(
430448
gameStage: this._game.GameStage,
431449
barrierList: this._game.BarrierList,
@@ -490,6 +508,14 @@ private void Communicate()
490508
this._orderToTransmitList.RemoveAt(0);
491509
}
492510

511+
if ((int)this._game.GameTime.GetValueOrDefault(0) != this._game.GameTime.GetValueOrDefault(0))
512+
{
513+
throw new Exception("GameTime overflow");
514+
}
515+
if (orderInDeliveryList.Count > 0x7f)
516+
{
517+
throw new Exception("The length of the orderInDeliveryList is greater than 127");
518+
}
493519
var packet = new PacketGetStatusHost(
494520
gameStatus: this._game.GameState,
495521
gameTime: (int)this._game.GameTime.GetValueOrDefault(0),

Source/PacketGetStatusHost.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ public PacketGetStatusHost(
3838
Order latestPendingOrder
3939
)
4040
{
41+
42+
4143
this._gameStatus = gameStatus;
4244
this._gameTime = gameTime;
4345
this._score = score;
@@ -72,6 +74,7 @@ public PacketGetStatusHost(byte[] bytes)
7274
currentIndex += 1;
7375
// time
7476
this._gameTime = BitConverter.ToInt32(data, currentIndex);
77+
7578
currentIndex += 4;
7679
// score
7780
this._score = BitConverter.ToSingle(data, currentIndex);

0 commit comments

Comments
 (0)