Browse Source

fix: 🐛 fix the bug that CopyInfo return null and GetGameObj in Game

tags/0.1.0
shangfengh 2 years ago
parent
commit
6d0efc07cb
3 changed files with 8 additions and 6 deletions
  1. +1
    -1
      logic/Gaming/Game.cs
  2. +5
    -2
      logic/Preparation/Utility/GameData.cs
  3. +2
    -3
      logic/Server/CopyInfo.cs

+ 1
- 1
logic/Gaming/Game.cs View File

@@ -474,7 +474,7 @@ namespace Gaming
var gameObjList = new List<IGameObj>();
foreach (var keyValuePair in gameMap.GameObjDict)
{
if (!GameData.IsMap(keyValuePair.Key))
if (GameData.NeedCopy(keyValuePair.Key))
{
gameMap.GameObjLockDict[keyValuePair.Key].EnterReadLock();
try


+ 5
- 2
logic/Preparation/Utility/GameData.cs View File

@@ -27,10 +27,13 @@ namespace Preparation.Utility
public const int numOfGenerator = 9;
public const int numOfChest = 8;

private const int numOfObjNotMap = 5;
public static bool IsMap(GameObjType gameObjType)
{
return (uint)gameObjType > numOfObjNotMap;
return (uint)gameObjType > 5;
}
public static bool NeedCopy(GameObjType gameObjType)
{
return gameObjType != GameObjType.Null && gameObjType != GameObjType.Grass && gameObjType != GameObjType.OutOfBoundBlock && gameObjType != GameObjType.Window && gameObjType != GameObjType.Wall;
}

public static XY GetCellCenterPos(int x, int y) // 求格子的中心坐标


+ 2
- 3
logic/Server/CopyInfo.cs View File

@@ -90,7 +90,6 @@ namespace Server
}
}


public static Protobuf.PlayerState ToPlayerState(Preparation.Utility.PlayerStateType playerState)
{
switch (playerState)
@@ -238,10 +237,10 @@ namespace Server
case Preparation.Utility.GameObjType.EmergencyExit:
if (((EmergencyExit)gameObj).CanOpen)
return HiddenGate((EmergencyExit)gameObj);
else return null;
else return new MessageOfObj();
case Preparation.Utility.GameObjType.Door:
return Door((Door)gameObj);
default: return null;
default: return new MessageOfObj();
}
}
public static MessageOfObj? Auto(MessageOfNews news)


Loading…
Cancel
Save