Skip to content

Commit

Permalink
Merge branch 'eesast:dev' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
shangfengh authored Apr 10, 2024
2 parents f379597 + 0177f3a commit ea455eb
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 28 deletions.
70 changes: 42 additions & 28 deletions logic/Server/GameServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -262,47 +262,61 @@ public GameServer(ArgumentOptions options)
game = new(MapInfo.defaultMapStruct, options.TeamCount);
else
{
uint[,] map = new uint[GameData.MapRows, GameData.MapCols];
try
// txt文本方案
if (options.MapResource.EndsWith(".txt"))
{
string? line;
int i = 0, j = 0;
using StreamReader sr = new(options.MapResource);
while (!sr.EndOfStream && i < GameData.MapRows)
try
{
if ((line = sr.ReadLine()) != null)
uint[,] map = new uint[GameData.MapRows, GameData.MapCols];
string? line;
int i = 0, j = 0;
using StreamReader sr = new(options.MapResource);
#region 读取txt地图
while (!sr.EndOfStream && i < GameData.MapRows)
{
string[] nums = line.Split(' ');
foreach (string item in nums)
if ((line = sr.ReadLine()) != null)
{
if (item.Length > 1)//以兼容原方案
{
map[i, j] = (uint)int.Parse(item);
}
else
string[] nums = line.Split(' ');
foreach (string item in nums)
{
//2022-04-22 by LHR 十六进制编码地图方案(防止地图编辑员瞎眼x
map[i, j] = (uint)MapEncoder.Hex2Dec(char.Parse(item));
}
j++;
if (j >= GameData.MapCols)
{
j = 0;
break;
if (item.Length > 1)//以兼容原方案
map[i, j] = (uint)int.Parse(item);
else
//2022-04-22 by LHR 十六进制编码地图方案(防止地图编辑员瞎眼x
map[i, j] = (uint)MapEncoder.Hex2Dec(char.Parse(item));
j++;
if (j >= GameData.MapCols)
{
j = 0;
break;
}
}
i++;
}
i++;
}
#endregion
game = new(new(GameData.MapRows, GameData.MapCols, map), options.TeamCount);
}
catch
{
game = new(MapInfo.defaultMapStruct, options.TeamCount);
}
}
catch
// MapStruct二进制方案
else if (options.MapResource.EndsWith(".map"))
{
map = MapInfo.defaultMap;
try
{
game = new(MapStruct.FromFile(options.MapResource), options.TeamCount);
}
catch
{
game = new(MapInfo.defaultMapStruct, options.TeamCount);
}
}
finally
else
{
MapStruct mapResource = new(GameData.MapRows, GameData.MapCols, map);
game = new(mapResource, options.TeamCount);
game = new(MapInfo.defaultMapStruct, options.TeamCount);
}
}
currentMapMsg = new() { MapMessage = MapMsg() };
Expand Down
1 change: 1 addition & 0 deletions map-generator/JavaScript/assets/js/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ function saveAsTxt() {
for (var i = 0; i < 50; i++) {
for (var j = 0; j < 50; j++) {
str += map[j][i];
str += " ";
}
str += "\n";
}
Expand Down

0 comments on commit ea455eb

Please sign in to comment.