/// <summary> /// Start main with dedicated_cfg /// </summary> /// <param name="config"></param> public Main(XmlDocument config) { InitializeComponent(); loadLang(); this.dedicatedConfig = config; this.chatColors = new ManiaColors(richTextBox1); Lama.log("NOTICE", "Open Main Form"); //Parse base config----------------------------------------------------------------------------------- XmlNode root = config[0]; XmlNode auth = root["authorization_levels"]; foreach (XmlNode node in auth.Childs) { switch (node["name"].Value) { case "SuperAdmin": this.login = "******"; this.passwd = node["password"].Value; break; } } this.port = int.Parse(root["system_config"]["xmlrpc_port"].Value); commonConstructor(); }
void loadPlugins() { Lama.log("NOTICE", "Load Plugins"); //Load ConfigServPlugins if (Lama.tabPlugins != null) { checkedListBox1.Items.Clear(); foreach (TabPlugin plugin in Lama.tabPlugins) { plugin.getITabInterface().getConfigValue = this.getConfigValue; Control ctrl = plugin; TabPage tp = new TabPage(plugin.PluginName); tp.Controls.Add(ctrl); ctrl.Dock = DockStyle.Fill; flatTabControl1.TabPages.Add(tp); } } //Load InGamePlugins List if (Lama.inGamePlugins != null) { checkedListBox1.Items.Clear(); foreach (BasePlugin plugin in Lama.inGamePlugins) { checkedListBox1.Items.Add(plugin.PluginName); } } }
/// <summary> /// New Server /// </summary> /// <param name="hl">The homeLauncher Form to reload</param> public NewServer(HomeLauncher hl) { Lama.log("NOTICE", "Open NewServer"); InitializeComponent(); this.hl = hl; formSkin1.Text = "New Server"; }
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Methodes Publiques /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> /// Ecrit le texte dans le control /// </summary> /// <param name="txt"></param> public void write(string txt) { string text = txt; Color color = defaultColor; List <FontStyle> fonts = new List <FontStyle>() { FontStyle.Regular }; for (int i = 0; i < text.Length; i++) { char c = text[i]; if (c == '$') { string str = new string(new char[] { c, text[i + 1] }); //Check Styles codes if (nadeoStyles.ContainsKey(str.ToUpper())) { //If $z clear style list var style = nadeoStyles[str.ToUpper()]; if (style == FontStyle.Regular) { color = defaultColor; } fonts[0] = style; text = text.Remove(i, 2); //remove code } else if (nadeoCodes.Contains(str)) { if (str.ToUpper() == "$G") { color = defaultColor; } text = text.Remove(i, 2); //remove code } else { try { //Check colors codes string colorCode = text.ToUpper().Substring(i + 1, 3); color = parseColorCode(colorCode); text = text.Remove(i, 4); //remove code }catch (Exception e) { Lama.log("ERROR", "[ManiaColors]>" + txt + " : " + e.Message); break; } } i--; } else //Write one by one { writeRich(c.ToString(), color, fonts); } } }
//Save ----------------------------------------------------------------------------------------------------------- void saveMain() { Lama.log("NOTICE", "Save Main config"); this.serverConfig["matchSettings"].Value = tb_matchFile.Text; this.serverConfig["name"].Value = tb_name.Text; this.serverConfig["internetServer"].Value = ch_internetServer.Checked.ToString(); //Save Plugin List Lama.mainConfig.save(false); }
//Start private void flatButton1_Click(object sender, EventArgs e) { try { int index = Lama.servers.getKeyFromValue(flatComboBox1.Text); start(index); } catch (Exception) { Lama.onError(this, "Error", "Undefined server : " + flatComboBox1.Text); } }
void saveMatchSettings() { Lama.log("NOTICE", "Save matchSettings"); XmlNode root = this.matchSettings[0]; root.deleteAllChildLike("map"); foreach (string map in l_mapsMatch.Items) { string path = mapFiles[map]; path = subsep(path, "\\Maps\\"); root.addChild("map").addChild("file", path); } if (!root.isChildExist("mode_script_settings")) { root.addChild("mode_script_settings"); } XmlNode modscript = root["mode_script_settings"]; modscript.deleteAllChildLike("setting"); //TimeLimit int time = (int)((n_time_h.Value * 60 * 60) + (n_time_m.Value * 60) + n_time_s.Value); modscript.addChild("setting").addAttribute("name", "S_TimeLimit") .addAttribute("type", "integer") .addAttribute("value", time.ToString()); //WarmUp Duration time = (int)((n_warm_h.Value * 60 * 60) + (n_warm_m.Value * 60) + n_warm_s.Value); modscript.addChild("setting").addAttribute("name", "S_WarmUpDuration") .addAttribute("type", "integer") .addAttribute("value", time.ToString()); //WarmUp Nb modscript.addChild("setting").addAttribute("name", "S_WarmUpDuration") .addAttribute("type", "integer") .addAttribute("value", n_nbwarm.Value.ToString()); //ForceLapsNb modscript.addChild("setting").addAttribute("name", "S_WarmUpDuration") .addAttribute("type", "integer") .addAttribute("value", n_forcelaps.Value.ToString()); if (!root.isChildExist("gameinfos")) { root.addChild("gameinfos"); } XmlNode gameInfos = root["gameinfos"]; gameInfos["script_name"].Value = cb_gameMode.Text + ".Script.txt"; this.matchSettings.save(); }
void loadMain() { Lama.log("NOTICE", "Load Main config"); tb_matchFile.Text = this.serverConfig["matchSettings"].Value; ch_internetServer.Checked = (this.serverConfig["internetServer"].Value.ToUpper().Equals("TRUE")); if (tb_matchFile.Text.Trim(' ') != "") { loadMatchSettings(this.serverPath + @"\UserData\Maps\" + tb_matchFile.Text); } else { this.matchSettings = new XmlDocument(this.serverPath + @"\UserData\Maps\MatchSettings\Default.txt"); } }
void loadPlugins() { Lama.log("NOTICE", "Load plugins"); try { DirectoryInfo pluginsDir = new DirectoryInfo(Path.GetDirectoryName(Application.ExecutablePath) + @"\Plugins\"); //Read dllignore List <string> dllignore = new List <string>(File.ReadAllLines(pluginsDir.FullName + "dllignore")); //Read dll foreach (FileInfo file in pluginsDir.GetFiles()) { if (file.Extension.Equals(".dll") && !dllignore.Contains(file.Name)) { try { DllLoader loader = new DllLoader(file.FullName); int cpt = loader.getAllCountInstances(Lama.inGamePlugins) + loader.getAllCountInstances(Lama.homeComponentPlugins) + loader.getAllCountInstances(Lama.tabPlugins); if (cpt == 0) { StreamWriter sw = new StreamWriter(File.Open(pluginsDir.FullName + "dllignore", FileMode.Append)); sw.WriteLine(file.Name); sw.Close(); } } //catch (NullReferenceException) { } catch (IOException) { } catch (Exception er) { Lama.log("ERROR", "[LoadPlugins][" + file.FullName + "]" + er.Message + er.GetType().Name); try { StreamWriter sw = new StreamWriter(File.Open(pluginsDir.FullName + "dllignore", FileMode.Append)); sw.WriteLine(file.Name); sw.Close(); } catch (Exception) { } } } } } catch (Exception e) { Lama.log("ERROR", "[LoadPlugins]" + e.Message); } }
/// <summary> /// Start main in remote mode /// </summary> public Main(string login, string pass) { InitializeComponent(); loadLang(); this.chatColors = new ManiaColors(richTextBox1); Lama.log("NOTICE", "Open Main Form"); this.login = login; this.passwd = pass; this.adrs = Lama.remoteAdrs; this.port = Lama.remotePort; commonConstructor(); }
private void b_create_Click(object sender, EventArgs e) { Lama.log("NOTICE", "Save server"); if (cfg == null) //Creation mode { if (tog_remote.Checked) { var index = Lama.mainConfig[0]["servers"].count(); var configPath = @"Config\Servers\" + index + ".xml"; //MakeConfig------------------------------------------------------------------ //Actualize main Config var root = Lama.mainConfig[0]["servers"].addChild("server") .addAttribute("id", index.ToString()); root.addChild("name", tb_name.Text); root.addChild("internetServer", "true"); root.addChild("matchSettings"); root.addChild("remote").addAttribute("value", "true") .addChild("ip", tb_ip.Text); root["remote"].addChild("port", tb_port.Text); root["remote"].addChild("login", tb_login.Text); root.addChild("plugins"); Lama.mainConfig.save(); this.hl.load(); this.Close(); } else { Lama.mainConfig.save(); ConfigServ cs = new ConfigServ(tb_name.Text); cs.Show(); this.hl.load(); this.Close(); } } else //Remote Edit mode { cfg["name"].Value = tb_name.Text; cfg["remote"]["ip"].Value = tb_ip.Text; cfg["remote"]["port"].Value = tb_port.Text; cfg["remote"]["login"].Value = tb_login.Text; Lama.mainConfig.save(); hl.load(); this.Close(); } }
/// <summary> /// Write logLine list and clear list /// </summary> public override void flush() { try { StreamWriter sw = new StreamWriter(path, true); foreach (LogLine elem in lines) { sw.WriteLine(elem.toText()); } sw.Close(); lines.Clear(); } catch (Exception e) { Lama.onException(this, e); } }
/// <summary> /// Edit remote server /// </summary> /// <param name="hl"></param> /// <param name="cfg"></param> public NewServer(HomeLauncher hl, XmlNode cfg) { Lama.log("NOTICE", "Open NewServer in Edit mode"); InitializeComponent(); formSkin1.Text = "Edit server"; this.hl = hl; this.cfg = cfg; tb_name.Text = cfg["name"].Value; tb_ip.Text = cfg["remote"]["ip"].Value; tb_port.Text = cfg["remote"]["port"].Value; tb_login.Text = cfg["remote"]["login"].Value; b_create.Text = "Save"; tog_remote.Checked = true; tog_remote.Enabled = false; tb_name.Enabled = true; tb_ip.Enabled = true; tb_port.Enabled = true; tb_login.Enabled = true; }
private string title; //Save title for change check ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Constructeurs /////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> /// New Local Server, called by NewServer /// </summary> public ConfigServ(string name) { Lama.log("NOTICE", "ConvigServ in NewServer mode"); Lama.log("NOTICE", "Create directory"); InitializeComponent(); this.index = Lama.mainConfig[0]["servers"].count(); this.serverPath = @"Servers\" + index + @"\"; // loadLang(); //Make server----------------------------------------------------------------- Directory.CreateDirectory(this.serverPath); DirectoryInfo mps = new DirectoryInfo(@"Ressources\mps\"); Lama.log("NOTICE", "Copy Directory"); copyDirectory(mps, this.serverPath); this.mapPath = serverPath + @"UserData\Maps\"; //MakeConfig------------------------------------------------------------------ Lama.log("NOTICE", "MakeConfig"); this.serverConfig = Lama.mainConfig[0]["servers"].addChild("server").addAttribute("id", index.ToString()); XmlNode root = this.serverConfig; root.addChild("name", name); root.addChild("internetServer", "true"); root.addChild("matchSettings"); XmlNode remote = root.addChild("remote").addAttribute("value", "false"); remote.addChild("ip", ""); remote.addChild("port", ""); remote.addChild("login", ""); root.addChild("plugins"); Lama.mainConfig.save(false); loadPlugins(); loadDedicated(); loadScript(); loadMain(); loadMaps(); }
/// <summary> /// Edit Local Server /// </summary> /// <param name="index"></param> public ConfigServ(int index) { Lama.log("NOTICE", "ConfigServ in Edit mode"); InitializeComponent(); this.serverPath = @"Servers\" + index + @"\"; this.mapPath = serverPath + @"UserData\Maps\"; this.index = index; this.serverConfig = Lama.mainConfig[0]["servers"].getChildByAttribute("id", this.index.ToString()); if (Lama.lang != null) { loadLang(); } this.tb_name.Text = this.serverConfig["name"].Value; loadPlugins(); loadDedicated(); loadScript(); loadMain(); loadMaps(); }
private void b_newMatch_Click(object sender, EventArgs e) { string file = tb_matchFile.Text; string path = mapPath + @"MatchSettings\" + file; if (!File.Exists(path)) { try { File.Create(path).Close(); this.matchSettings = new XmlDocument(path); } catch (Exception er) { Lama.onException(this, er); } } else { Lama.onError(this, "Error", "The file : " + file + " already exists !"); } }
//Remove private void flatButton3_Click(object sender, EventArgs e) { DialogResult res = MessageBox.Show("Are you sure ?", "Are you sure to remove" + flatComboBox1.SelectedText, MessageBoxButtons.YesNo); if (res == DialogResult.No) { return; } int index = Lama.servers.getKeyFromValue(flatComboBox1.Text); XmlNode cfg = Lama.mainConfig[0]["servers"].getChildByAttribute("id", index.ToString()); try { if (cfg["remote"].getAttibuteV("value").ToUpper().Equals("FALSE")) { Directory.Delete(Application.StartupPath + @"\Servers\" + index + @"\", true); } } catch (Exception dirEx) { Lama.onException(this, dirEx); } //Update Main Config int total = Lama.mainConfig[0]["servers"].removeChildsByAttribute("server", "id", index.ToString()); if (total != 1) { Lama.onError(this, "Error", "Unable to delete server from main config, nodes affected = "); } else { Lama.mainConfig.save(); load(); } }
/// <summary> /// Load scripts list /// </summary> void loadScript() { Lama.log("NOTICE", "Load script list"); cb_gameMode.Items.Clear(); string scriptLocation = this.serverPath + @"GameData\Scripts\Modes\"; if (tb_title.Text.Length > 3) { if (tb_title.Text.Contains("SM")) { scriptLocation += @"ShootMania\"; } else if (tb_title.Text.Contains("TM")) { scriptLocation += @"TrackMania\"; } else { LamaDialog d = new LamaDialog("Select game", "Unknow title : " + tb_title.Text + "\n Please select game :", FlatUITheme.FlatAlertBox._Kind.Info, LamaSpecialButtons.GameSlect); DialogResult r = d.ShowDialog(); if (r == DialogResult.OK) { scriptLocation += @"TrackMania\"; } else { scriptLocation += @"ShootMania\"; } } } IEnumerable <string> lst = Directory.EnumerateFiles(scriptLocation); foreach (string file in lst) { cb_gameMode.Items.Add(subsep(file, scriptLocation, ".Script")); } }
//Requests==================================================================================== void asyncRequest(String methodName, params object[] param) { if (param == null) { param = new object[] { } } ; this.handles.Add(this.client.AsyncRequest(methodName, param, asyncResult), methodName); } void asyncRequest(GbxCallCallbackHandler handler, String methodName, params object[] param) { if (param == null) { param = new object[] { } } ; this.client.AsyncRequest(methodName, param, handler); } void asyncRequest(String methodName, GbxCallCallbackHandler handler) { this.client.AsyncRequest(methodName, new object[] { }, handler); } //Main Async results========================================================================== void asyncResult(GbxCall res) { //Manage result------------------------------------------------------------------------ try { if (this.handles.ContainsKey(res.Handle) && !res.Error) { switch (this.handles[res.Handle]) { #region "Server Infos" ////////////////////////////////////////////////////////////////////////////////////////////////////// // Server Infos ///////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////// case GetScriptName: var htscript = res.getHashTable(); string script = (string)htscript["CurrentValue"]; if (script.Contains(".Script.txt")) { script = subsep(script, 0, "."); } setLabel(this.l_gameMode, "GameMode : " + script); this.isTM = Enum.TryParse(script, out this.tmGameMode); if (this.isTM) { foreach (TMGameMode suit in (TMGameMode[])Enum.GetValues(typeof(TMGameMode))) { appendCombo(cb_serverGMScript, suit.ToString()); } } else { if (Enum.TryParse(script, out this.smGameMode)) { foreach (SMGameMode suit in (SMGameMode[])Enum.GetValues(typeof(SMGameMode))) { appendCombo(cb_serverGMScript, suit.ToString()); } } else { //Show select game dialog } } break; case GetMapList: Hashtable maps = res.getHashTable(); clearDg(dg_map); foreach (Hashtable map in maps) { addDgRow(dg_map, ManiaColors.getText((string)map["Name"]), map["Author"], map["Environnement"], map["LadderRanking"]); } break; case GetCurrentMapIndex: if (this.currentMapId != -1) { this.previousMapId = this.currentMapId; } this.currentMapId = (int)res.Params[0]; break; case SetScriptName: if ((bool)res.Params[0]) { setLabel(this.l_gameMode, "GameMode: " + this.cb_serverGMScript.Text); } break; #endregion #region "Chat" ////////////////////////////////////////////////////////////////////////////////////////////////////// // Chat ///////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////// case GetChatLines: clearConsole(); var al = (ArrayList)res.Params[0]; foreach (object o in al) { string als = (string)o; if (als.Contains("$>") && als.Contains("$<")) { als = delseps(als, "[", "<"); als = als.Replace("$>]", "$000 :$fff"); } chatColors.write(als + "\n"); } break; #endregion #region "Players List" ////////////////////////////////////////////////////////////////////////////////////////////////////// // Players List ///////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////// case GetPlayerList: ArrayList userList = (ArrayList)res.Params[0]; clearList(l_users); clearDg(dg_users); this.nbPlayers = userList.Count; setLabel(l_players, "Players : " + this.nbPlayers + "/" + this.maxPlayers); foreach (Hashtable user in userList) { this.playerList.Add(new SPlayerInfo { Login = (string)user["Login"], NickName = (string)user["NickName"], PlayerId = (int)user["PlayerId"], //............... }); addDgRow(dg_users, user["PlayerId"], ManiaColors.getText((string)user["NickName"]), user["Login"], user["LadderRanking"]); appendList(l_users, ManiaColors.getText((string)user["NickName"])); } break; case SendDisplayManialinkPageToId: break; case GetGuestList: break; case GetBlackList: break; case GetBanList: break; #endregion } } else { if (res.Error) { Lama.log("ERROR", "Answer for handle n° " + res.Handle + " named '" + this.handles[res.Handle] + "' Returned Error : " + res.ErrorString); } } //Send to plugins -------------------------------------------------------------------------------- foreach (InGamePlugin plug in Lama.inGamePlugins) { try { plug.onGbxAsyncResult(res); } catch (Exception e) { Lama.log("ERROR", "Plugins " + plug.PluginName + " throws Gbx Error :" + e.Message); } } this.handles.Remove(res.Handle); } catch (Exception e) { Lama.log("ERROR", "Answer for handle n°" + res.Handle + " throws a " + e.GetType().Name + "Exception : " + e.Message); } } //Specific AsyncResult void checkError(GbxCall res) { if (res.Error) { Lama.onError(this, "Error", "Error " + res.ErrorCode + " : " + res.ErrorString + "\n from request : " + res.MethodName); } } void getServerOptions(GbxCall res) { Hashtable ht = res.getHashTable(); setLabel(l_serverName, "Name : " + ManiaColors.getText((string)ht["Name"])); setLabel(l_serverDescritpion, "Description : " + ManiaColors.getText((string)ht["Comment"])); this.maxPlayers = (int)ht["CurrentMaxPlayers"]; this.maxSpectators = (int)ht["CurrentMaxSpectators"]; //Fill ServerOptions Tab setTextBoxText(tb_ingameName, (string)ht["Name"]); setTextBoxText(tb_description, (string)ht["Comment"]); setTextBoxText(tb_playerPass, (string)ht["Password"]); setTextBoxText(tb_specPass, (string)ht["PasswordForSpectator"]); setNumeric(n_playersLimit, maxPlayers); setNumeric(n_specsLimit, maxSpectators); setTextBoxText(tb_refereePass, (string)ht["RefereePassword"]); //TODO comboboxReferee setNumeric(n_voteTimeout, (int)ht["NextCallVoteTimeOut"]); setTextBoxText(tb_voteRatio, (string)ht["NextCallVoteRatio"]); int lm = (int)ht["NextLadderMode"]; setCheckBox(ch_ladder, (lm == 1)); setCheckBox(ch_p2pUp, (bool)ht["IsP2PUpload"]); setCheckBox(ch_p2pDown, (bool)ht["IsP2PDownload"]); setCheckBox(ch_autoSaveReplay, false); setCheckBox(ch_saveValReplay, false); setCheckBox(ch_keepPlayerSlot, false); setCheckBox(ch_mapDown, false); setCheckBox(ch_horns, false); } void getCurrentGameInfo(GbxCall res) { Hashtable ht = res.getHashTable(); } void getModeScriptSettings(GbxCall res) { Hashtable ht = res.getHashTable(); foreach (string key in ht.Keys) { switch (getType(ht[key])) { case 0: //String this.flowLayoutPanel1.Controls.Add(new StringScriptSetting(key, key, (string)ht[key])); break; case 1: //Int this.flowLayoutPanel1.Controls.Add(new NumericScriptSetting(key, key, (int)ht[key])); break; case 2: //Bool this.flowLayoutPanel1.Controls.Add(new BooleanScriptSetting(key, key, (bool)ht[key])); break; case 3: //Double this.flowLayoutPanel1.Controls.Add(new DoubleScriptSetting(key, key, (double)ht[key])); break; case -1: //Unknown Lama.log("ERROR", "Unable to get ScriptSetting type of : " + key + " : " + key.GetType()); break; } } } //CallBacks============================================================================================= void gbxCallBack(object sender, GbxCallbackEventArgs args) { switch (args.Response.MethodName) { //Race & Map infos #region "Server" case "ManiaPlanet.ServerStart": break; case "ManiaPlanet.ServerStop": break; case "ManiaPlanet.StatusChanged": break; case "ManiaPlanet.TunnelDataReceived": break; case "ManiaPlanet.Echo": break; case "ManiaPlanet.BillUpdated": break; #endregion #region "Scripts" case "ModeScriptCallback": break; case "ModeScriptCallbackArray": break; case "ScriptCloud.LoadData": break; case "ScriptCloud.SaveData": break; #endregion #region "ManiaPlanetMap" case "ManiaPlanet.BeginMap": setLabelColor(l_map, Color.Green); break; case "ManiaPlanet.BaginMatch": setLabelColor(l_map, Color.Green); break; case "ManiaPlanet.EndMap": setLabelColor(l_map, Color.Red); break; case "ManiaPlanet.EndMatch": setLabelColor(l_map, Color.Orange); break; #endregion #region "Race" case "TrackMania.EndRace": setLabelColor(l_map, Color.Orange); break; case "TrackMania.EndRound": break; case "TrackMania.ChallengeListModified": break; case "TrackMania.EndChallenge": setLabelColor(l_map, Color.Red); break; case "TrackMania.StatusChanged": int statusCode = (int)args.Response.Params[0]; setLabel(this.l_server, "Status : " + getStatus(statusCode)); break; case "TrackMania.BeginChallenge": setLabelColor(l_map, Color.Green); var ht = (Hashtable)args.Response.Params[0]; setLabel(l_map, "GameInfo : " + ManiaColors.getText((string)ht["Name"])); asyncRequest("GetCurrentMapIndex"); break; case "TrackMania.BeginRace": break; #endregion #region "Player" case "TrackMania.PlayerConnect": asyncRequest("GetPlayerList", this.maxPlayers + this.maxSpectators, 0); break; case "TrackMania.PlayerDisconnect": asyncRequest("GetPlayerList", this.maxPlayers + this.maxSpectators, 0); break; case "ManiaPlanet.PlayerChat": case "TrackMania.PlayerChat": var htPlayerChat = args.Response.Params; chatColors.write(htPlayerChat[1] + "$fff : " + htPlayerChat[2] + "\n"); break; case "TrackMania.PlayerInoChanged": break; case "TrackMania.PlayerAllies": break; case "TrackMania.PlayerManialinkPageAnswer": break; case "TrackMania.PlayerCheckpoint": break; case "TrackMania.PlayerFinish": break; case "TrackMania.PlayerIncoherence": break; #endregion } //Send to plugins---------------------------------------------------------------------- foreach (InGamePlugin plug in Lama.inGamePlugins) { plug.onGbxCallBack(sender, args); } } void gbxDisconnect(object sender) { FlatButton but = (FlatButton)getControl(this.b_xmlrpcConnect); but.BaseColor = Color.Green; enableControl(but, true); but.Enabled = true; but = (FlatButton)getControl(this.b_serverStarted); but.BaseColor = Color.Green; enableControl(but, true); this.netStatsTimer.Stop(); } #endregion ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Autres Methodes ///////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////// #region "Other Methods" string getStatus(int code) { switch (code) { case 3: return("Running - Synchronisation"); case 4: return("Running - Play"); default: return(code.ToString()); } }
void loadDedicated() { Lama.log("NOTICE", "Load Dedicated config"); this.dedicated_config = new XmlDocument(serverPath + @"UserData\Config\dedicated_cfg.txt", true, true); XmlNode root = this.dedicated_config[0]; //dedicated //Authorisations -------------------------------------------------------------------------- XmlNode auth = root["authorization_levels"]; foreach (XmlNode node in auth.getChildList("level")) { switch (node["name"].Value) { case "SuperAdmin": tb_superPass.Text = node["password"].Value; break; case "Admin": tb_adminPass.Text = node["password"].Value; break; case "User": tb_userPass.Text = node["password"].Value; break; } } //Master Account -------------------------------------------------------------------------- XmlNode master = root["masterserver_account"]; tb_serverLogin.Text = master["login"].Value; tb_ServerPass.Text = master["password"].Value; tb_validKey.Text = master["validation_key"].Value; //Server Options -------------------------------------------------------------------------- XmlNode servOptions = root["server_options"]; tb_ingameName.Text = servOptions["name"].Value; tb_description.Text = servOptions["comment"].Value; cb_hiddenServer.SelectedIndex = (int)servOptions["hide_server"].LValue; tb_playerPass.Text = servOptions["password"].Value; tb_specPass.Text = servOptions["password_spectator"].Value; tb_refereePass.Text = servOptions["referee_password"].Value; tb_voteRatio.Text = servOptions["callvote_ratio"].Value; n_voteTimeout.Value = servOptions["callvote_timeout"].LValue; n_playersLimit.Value = servOptions["max_players"].LValue; n_specsLimit.Value = servOptions["max_spectators"].LValue; n_maxLat.Value = servOptions["clientinputs_maxlatency"].LValue; ch_keepPlayerSlot.Checked = servOptions["keep_player_slots"].BValue; ch_ladder.Checked = (servOptions["ladder_mode"].Value.Equals("forced")); ch_p2pUp.Checked = servOptions["enable_p2p_upload"].BValue; ch_p2pDown.Checked = servOptions["enable_p2p_download"].BValue; ch_mapDown.Checked = servOptions["allow_map_download"].BValue; ch_autoSaveReplay.Checked = servOptions["autosave_replays"].BValue; ch_saveValReplay.Checked = servOptions["autosave_validation_replays"].BValue; cb_refereeValid.SelectedIndex = (int)servOptions["referee_validation_mode"].LValue; ch_horns.Checked = servOptions["disable_horns"].BValue; //System Config -------------------------------------------------------------------------- XmlNode systemConfig = root["system_config"]; n_UpRate.Value = systemConfig["connection_uploadrate"].LValue; n_DownRate.Value = systemConfig["connection_downloadrate"].LValue; n_paThreadCount.Value = systemConfig["packetassembly_threadcount"].LValue; n_p2pCacheSize.Value = systemConfig["p2p_cache_size"].LValue; tb_ServerPort.Text = systemConfig["server_port"].Value; tb_p2pPort.Text = systemConfig["server_p2p_port"].Value; tb_XmlRpcPort.Text = systemConfig["xmlrpc_port"].Value; tb_proxy.Text = systemConfig["proxy_url"].Value; ch_xmlRpcRemote.Checked = systemConfig["xmlrpc_allowremote"].BValue; ch_proxy.Checked = systemConfig["use_proxy"].BValue; ch_allowSpecRelay.Checked = systemConfig["allow_spectator_relays"].BValue; tb_title.Text = systemConfig["title"].Value; this.title = tb_title.Text; }
void loadMatchSettings(string path) { Lama.log("NOTICE", "Load matchSettings"); this.matchSettings = new XmlDocument(path, true, true); //Mode Script------------------------------------------------- try { cb_gameMode.Text = subsep(this.matchSettings["playlist"]["gameinfos"]["script_name"].Value, 0, ".Script"); } catch (Exception e) { Lama.log("ERROR", "Unable to load script name from matchSettings ! :\n" + e.Message); } //Map Playlist------------------------------------------------ this.mapFiles.Clear(); this.l_mapsMatch.Items.Clear(); XmlNode root = this.matchSettings["playlist"]; foreach (XmlNode map in root.getChildList("map")) { string mpath = this.mapPath + map["file"].Value; l_mapsMatch.Items.Add(Path.GetFileName(mpath)); mapFiles.Add(Path.GetFileName(mpath), Path.GetFullPath(mpath)); } //Script Settings----------------------------------------------- foreach (XmlNode setting in root["mode_script_settings"].getChildList("setting")) { switch (setting.getAttibuteV("name")) { case "S_TimeLimit": int time = int.Parse(setting.getAttibuteV("value")); int h, m, s; parseTime(time, out h, out m, out s); n_time_h.Value = h; n_time_m.Value = m; n_time_s.Value = s; break; case "S_WarmUpNb": n_nbwarm.Value = int.Parse(setting.getAttibuteV("value")); break; case "S_WarmUpDuration": int timew = int.Parse(setting.getAttibuteV("value")); int hw, mw, sw; parseTime(timew, out hw, out mw, out sw); n_warm_h.Value = hw; n_warm_m.Value = mw; n_warm_s.Value = sw; break; case "S_ForceLapsNb": n_forcelaps.Value = int.Parse(setting.getAttibuteV("value")); break; } } }
void loadMaps() { Lama.log("NOTICE", "Load maps folder"); makeTreeview(new DirectoryInfo(mapPath), treeView1.Nodes.Add("Maps")); }
/// <summary> /// /// </summary> public void load() { Lama.log("NOTICE", "Read main config"); Lama.mainConfig = new XmlDocument(@"Config\Main.xml"); XmlNode root = Lama.mainConfig[0]; while (root.read()) { var node = root.getNode(); switch (node.Name) { case "startMode": if (!node.Value.ToUpper().Equals("SELECT")) { Lama.startMode = int.Parse(node.Value); } break; case "lang": switch (node.Value) { case "FR": // Lama.lang = new BaseFR(); break; case "EN": // Lama.lang = new BaseEN(); break; default: //TODO: Manage dll List <BaseLang> lstLang = new List <BaseLang>(); DirectoryInfo pluginsDir = new DirectoryInfo(Path.GetDirectoryName(Application.ExecutablePath) + @"\Plugins\"); foreach (FileInfo file in pluginsDir.GetFiles()) { DllLoader loader = new DllLoader(file.FullName); lstLang.AddRange(loader.getAllInstances <BaseLang>()); } break; } if (Lama.lang != null) { loadLang(); } break; case "servers": Lama.log("NOTICE", "Read server list"); Lama.servers.Clear(); flatComboBox1.Items.Clear(); foreach (XmlNode n in node.Childs) { Lama.servers.Add(int.Parse(n.getAttibuteV("id")), n["name"].Value); flatComboBox1.Items.Add(n["name"].Value); } break; } } if (Lama.startMode >= 0) { start(Lama.startMode); } }
void commonConstructor() { //Launch XmlRpcClient--------------------------------------------------------------------------------- Lama.log("NOTICE", "XmlRpcConnect"); connectXmlRpc(); Lama.loadForm.Close(); if (Lama.connected) { Lama.log("NOTICE", "XmlRPC : Connected"); //Affichage this.b_serverStarted.Enabled = false; this.b_xmlrpcConnect.Enabled = false; this.b_uasecoStop.Enabled = false; this.b_usaecoStart.Enabled = false; //Requêtes startupRequests(); Lama.log("NOTICE", "Init inGamePlugins ..."); //Init plugins if (!Lama.remote) { List <InGamePlugin> removeLST = new List <InGamePlugin>(); foreach (InGamePlugin plug in Lama.inGamePlugins) { bool badRequirement = false; string brInfos = ""; LamaConfig conf2plug = new LamaConfig() { connected = true, scriptName = "", remote = Lama.remote, configFiles = new Dictionary <string, XmlDocument>() }; foreach (Requirement r in plug.Requirements) { switch (r.Type) { case RequirementType.PLUGIN: if (getPluginByName(r.Value) == null) { badRequirement = true; brInfos = "Requiredplugin '" + r.Value + "does not exists"; } break; case RequirementType.FILE: try { conf2plug.configFiles.Add(r.Value, new XmlDocument(@"Config\Servers\" + Lama.serverIndex + @"\" + r.Value)); } catch (Exception) { badRequirement = true; brInfos = @"Unable to load Config\Servers\" + Lama.serverIndex + @"\" + r.Value; } break; case RequirementType.DATABASE: conf2plug.dbConnected = false; break; } } if (!badRequirement) { badRequirement = !plug.onLoad(conf2plug); brInfos = "onLoad method returned false"; } if (badRequirement) { Lama.log("ERROR", "Unable to init [" + plug.PluginName + "] Plugin, " + brInfos); removeLST.Add(plug); } else { Lama.log("NOTICE", "[" + plug.PluginName + "] Plugin loaded"); } } foreach (InGamePlugin plug in removeLST) { Lama.inGamePlugins.Remove(plug); } } } else { if (Lama.launched) { Lama.onError(this, "Unable to connect", "Unable to connect to " + this.adrs + ":" + this.port + "\nPlease check server and/or Lama configuration"); this.Close(); } else { Lama.onError(this, "Server exited", "Server exited \nPlease check server logs and configuration"); this.Close(); } } }
void saveDedicated() { Lama.log("NOTICE", "Save Dedicated"); try { XmlNode root = this.dedicated_config[0]; //dedicated //Authorisations -------------------------------------------------------------------------- XmlNode auth = root["authorization_levels"]; foreach (XmlNode lvl in auth.getChildList("level")) { switch (lvl["name"].Value) { case "SuperAdmin": lvl["password"].Value = tb_superPass.Text; break; case "Admin": lvl["password"].Value = tb_adminPass.Text; break; case "User": lvl["password"].Value = tb_userPass.Text; break; } } //Master Account -------------------------------------------------------------------------- XmlNode master = root["masterserver_account"]; master["login"].Value = tb_serverLogin.Text; master["password"].Value = tb_ServerPass.Text; master["validation_key"].Value = tb_validKey.Text; //Server Options -------------------------------------------------------------------------- XmlNode servOptions = root["server_options"]; servOptions["name"].Value = tb_ingameName.Text; servOptions["comment"].Value = tb_description.Text; servOptions["hide_server"].Value = cb_hiddenServer.SelectedIndex.ToString(); servOptions["password"].Value = tb_playerPass.Text; servOptions["password_spectator"].Value = tb_specPass.Text; servOptions["referee_password"].Value = tb_refereePass.Text; servOptions["callvote_ratio"].Value = tb_voteRatio.Text; servOptions["callvote_timeout"].Value = n_voteTimeout.Value.ToString(); servOptions["max_players"].Value = n_playersLimit.Value.ToString(); servOptions["max_spectators"].Value = n_specsLimit.Value.ToString(); servOptions["clientinputs_maxlatency"].Value = n_maxLat.Value.ToString(); servOptions["keep_player_slots"].Value = ch_keepPlayerSlot.Checked.ToString(); if (ch_ladder.Checked) { servOptions["ladder_mode"].Value = "forced"; } else { servOptions["ladder_mode"].Value = "incative"; } servOptions["enable_p2p_upload"].Value = ch_p2pUp.Checked.ToString(); servOptions["enable_p2p_download"].Value = ch_p2pDown.Checked.ToString(); servOptions["allow_map_download"].Value = ch_mapDown.Checked.ToString(); servOptions["autosave_replays"].Value = ch_autoSaveReplay.Checked.ToString(); servOptions["autosave_validation_replays"].Value = ch_saveValReplay.Checked.ToString(); servOptions["referee_validation_mode"].Value = cb_refereeValid.SelectedIndex.ToString(); servOptions["disable_horns"].Value = ch_horns.Checked.ToString(); //System Config -------------------------------------------------------------------------- XmlNode systemConfig = root["system_config"]; systemConfig["connection_uploadrate"].Value = n_UpRate.Value.ToString(); systemConfig["connection_downloadrate"].Value = n_DownRate.Value.ToString(); systemConfig["packetassembly_threadcount"].Value = n_paThreadCount.Value.ToString(); systemConfig["allow_spectator_relays"].Value = ch_allowSpecRelay.Checked.ToString(); systemConfig["p2p_cache_size"].Value = n_p2pCacheSize.Value.ToString(); systemConfig["server_port"].Value = tb_ServerPort.Text; systemConfig["server_p2p_port"].Value = tb_p2pPort.Text; systemConfig["xmlrpc_port"].Value = tb_XmlRpcPort.Text; systemConfig["proxy_url"].Value = tb_proxy.Text; systemConfig["xmlrpc_allowremote"].Value = ch_xmlRpcRemote.Checked.ToString(); systemConfig["use_proxy"].Value = ch_proxy.Checked.ToString(); systemConfig["title"].Value = tb_title.Text; this.dedicated_config.save(); } catch (Exception er) { Lama.log("ERROR", "[ConfigServ]Unable to save dedicated : " + er.Message); Lama.onError(this, "Error", "Unable to save dedicated\n" + er.Message + "\n" + er.StackTrace); } }