Skip to content

Commit

Permalink
修复playerID不对应的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
GuoWQ222 committed Mar 16, 2024
1 parent 672fbad commit ae7b575
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 16 deletions.
4 changes: 2 additions & 2 deletions logic/Server/ArgumentOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class ArgumentOptions
[Option("MaxCivilShipNum", Required = false, HelpText = "The number of max civil ship num, 2 by default")]
public ushort MaxCivilShipCount { get; set; } = 2;

[Option("MaxPlayerNumPerTeam", Required = false, HelpText = "The max player number of team, 4 by defualt")]
[Option("MaxPlayerNumPerTeam", Required = false, HelpText = "The max player number of team, 6 by defualt")]
public ushort MaxPlayerNumPerTeam { get; set; } = 6;

[Option("warShipNum", Required = false, HelpText = "The number of war ship num, 0 by default")]
Expand All @@ -41,7 +41,7 @@ public class ArgumentOptions
[Option("MaxFlagShipNum", Required = false, HelpText = "The number of flag ship num, 1 by default")]
public ushort MaxFlagShipCount { get; set; } = 1;

[Option("MaxShipNum", Required = false, HelpText = "The max number of Ship, 3 by default")]
[Option("MaxShipNum", Required = false, HelpText = "The max number of Ship, 5 by default")]
public ushort MaxShipCount { get; set; } = 5;

[Option("homeNum", Required = false, HelpText = "The number of Home , 1 by default")]
Expand Down
18 changes: 4 additions & 14 deletions logic/Server/GameServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -210,18 +210,11 @@ private uint GetBirthPointIdx(long playerID) // 获取出生点位置

private bool ValidPlayerID(long playerID)
{
if ((0 <= playerID && playerID < options.ShipCount) || (options.MaxShipCount <= playerID && playerID < options.MaxShipCount + options.HomeCount))
if (playerID==0 || (1 <= playerID && playerID <= options.ShipCount))
return true;
return false;
}

private int PlayerIDToTeamID(long playerID)
{
if (0 <= playerID && playerID < options.MaxPlayerNumPerTeam) return 0;
if (options.MaxPlayerNumPerTeam <= playerID && playerID < options.MaxPlayerNumPerTeam * 2) return 1;
return -1;
}

private MessageOfAll GetMessageOfAll(int time)
{
MessageOfAll msg = new()
Expand Down Expand Up @@ -314,13 +307,10 @@ public GameServer(ArgumentOptions options)
//创建server时先设定待加入对象都是invalid
for (int team = 0; team < TeamCount; team++)
{
for (int i = 0; i < options.MaxShipCount; i++)
{
communicationToGameID[team][i] = GameObj.invalidID;
}
for (int i = options.MaxShipCount; i < options.MaxShipCount + options.HomeCount; i++)
communicationToGameID[team][0]= GameObj.invalidID; // team
for (int i = 1; i <= options.MaxShipCount; i++)
{
communicationToGameID[team][i] = GameObj.invalidID;
communicationToGameID[team][i] = GameObj.invalidID; //sweeper
}
}

Expand Down

0 comments on commit ae7b575

Please sign in to comment.