초기커밋

This commit is contained in:
2025-05-01 07:20:41 +09:00
commit 98bb2e3c5c
2747 changed files with 646947 additions and 0 deletions

124
GameServer/GameServerApp.cs Normal file
View File

@@ -0,0 +1,124 @@
using System.Collections.Concurrent;
using Microsoft.Extensions.Configuration;
using CommandLine;
using ServerCore;
using ServerBase;
using ServerCommon;
using SESSION_ID = System.Int32;
using META_ID = System.UInt32;
using ENTITY_GUID = System.String;
using ACCOUNT_ID = System.String;
using OWNER_GUID = System.String;
using USER_GUID = System.String;
using CHARACTER_GUID = System.String;
using ITEM_GUID = System.String;
namespace GameServer;
public class Options
{
[Option("port", Default = (UInt16)9001)]
public UInt16 Port { get; set; } = 9001;
[Option("config", Default = "ServerConfig.json")]
public string Config { get; set; } = "ServerConfig.json";
[Option("serverType", Default = nameof(ServerType.Channel))]
public string ServerTypeString { get; set; } = ServerType.Channel.toServerTypeString();
[Option("worldId", Default = 1)]
public int WorldId { get; set; } = 1;
[Option("channelNo", Default = (UInt16) 1)]
public UInt16 ChannelNo { get; set; } = 1;
[Option("defaultMaxUser", Default = (UInt16)2000 )]
public UInt16 DefaultMaxUser { get; set; } = 2000;
}
public static class GameServerApp
{
private static GameServerLogic? m_server_logic;
public static GameServerLogic getServerLogic()
{
NullReferenceCheckHelper.throwIfNull(m_server_logic);
return m_server_logic;
}
private static async Task<int> Main(string[] args)
{
var result = new Result();
ServerCore.Log.getLogger().info($"GameServer start");
try
{
result = await Parser.Default.ParseArguments<Options>(args).MapResult(
async (Options opts) =>
{
return await runServer(opts);
}, errors => Task.FromResult(result)
);
}
catch (Exception e)
{
var err_msg = $"Exception !!!, GameServerApp.runServer() : message:{e}";
result.setFail(ServerErrorCode.TryCatchException, err_msg);
}
finally
{
if (result.isFail())
{
ServerCore.Log.getLogger().error($"GameServer finally error !!! - {result.toBasicString()}");
}
}
ServerCore.Log.shutdown();
ServerCore.Log.getLogger().info($"GameServer terminated");
return 0;
}
private static async Task<Result> runServer(Options argOptions)
{
var result = new Result();
var key_options = new Dictionary<string, string>
{
{ "port", argOptions.Port.ToString() },
{ "config", argOptions.Config },
{ "serverType", argOptions.ServerTypeString },
{ "worldId", argOptions.WorldId.ToString() },
{ "channelNo", argOptions.ChannelNo.ToString() },
{ "defaultMaxUser", argOptions.DefaultMaxUser.ToString() }
};
var configuration = new ConfigurationBuilder().AddInMemoryCollection(key_options!).Build();
NullReferenceCheckHelper.throwIfNull(configuration, () => $"configuration is null !!!");
var server_config = new ServerConfig();
m_server_logic = new GameServerLogic(server_config);
m_server_logic.setServerType(argOptions.ServerTypeString);
m_server_logic.setConfiguration(configuration);
result = await m_server_logic.onRunServer();
if (result.isFail())
{
return result;
}
return result;
}
}