Example #1
0
 static void LoadServers(string path)
 {
     string[] serverNames = Directory.GetFiles(path, "*.json", SearchOption.AllDirectories);
     foreach (string name in serverNames)
     {
         MyServer server = new MyServer();
         server.Read(name);
         ServerNames.Add(server.gameName);
         ServerList.Add(server);
     }
 }
Example #2
0
    public static bool AddServer(string gameName, int sceneMode)
    {
#if SteamVersion
        string srvDir = Path.Combine(Environment.CurrentDirectory, "Server");
        Directory.CreateDirectory(srvDir);
        string srvDataDir = Path.Combine(srvDir, "ServerData");
        Directory.CreateDirectory(srvDataDir);

        string srvGameDir = string.Empty;
        Pathea.PeGameMgr.ESceneMode mode = (Pathea.PeGameMgr.ESceneMode)sceneMode;
        if (mode == Pathea.PeGameMgr.ESceneMode.Custom)
        {
            srvGameDir = Path.Combine(srvDataDir, "CustomGames");
            Directory.CreateDirectory(srvGameDir);
        }
        else
        {
            srvGameDir = Path.Combine(srvDataDir, "CommonGames");
            Directory.CreateDirectory(srvGameDir);
        }

        string gameDir = Path.Combine(srvGameDir, gameName);
        Directory.CreateDirectory(gameDir);
        string confPath = Path.Combine(gameDir, "config.json");
        if (File.Exists(confPath))
        {
            MyServer server = ServerList.Find(iter => iter.gameName.Equals(gameName) && iter.gameMode == sceneMode);
            if (null == server)
            {
                server = new MyServer();
                server.Read(confPath);
                ServerNames.Add(server.gameName);
                ServerList.Add(server);
            }

            OnServerAdd(gameName, sceneMode);
            return(true);
        }
#endif
        return(false);
    }