Esempio n. 1
0
        public override bool onLoad(LamaConfig lamaConfig)
        {
            bool ret = (lamaConfig.connected &&
                        lamaConfig.dbConnected &&
                        lamaConfig.game == Game.TrackMania &&
                        lamaConfig.configFiles.ContainsKey("locales.xml") &&
                        lamaConfig.configFiles["locales.xml"] != null &&
                        lamaConfig.configFiles.ContainsKey("admins.xml") &&
                        lamaConfig.configFiles["admins.xml"] != null);

            if (ret)
            {
                try
                {
                    this.locales = lamaConfig.configFiles["locales.xml"];
                    XmlDocument admins = lamaConfig.configFiles["admins.xml"];
                    foreach (XmlNode node in admins[0]["logins"].getChildList("login"))
                    {
                        adminLogins.Add(node.Value);
                    }
                }
                catch (Exception)
                {
                    ret = false;
                }
            }

            return(ret);
        }
Esempio n. 2
0
        public override bool onLoad(LamaConfig lamaConfig)
        {
            bool ret = (lamaConfig.configFiles.ContainsKey("exemple.xml")); //&& lamaConfig.scriptName == "TimeAttack");

            if (ret)
            {
                config = lamaConfig.configFiles["exemple.xml"];

                /*       int param2 = 2;
                 *     asyncRequest("MethodName", "param1", param2);
                 *     asyncRequest("GetMethodName", checkError); //checkError is GbxCallCallBackHandler delegate
                 *     asyncRequest("methodName", res =>{
                 *         //do something
                 *     });
                 *     asyncRequest(checkError, "MethodName", "param1", "param2");*/
            }
            return(ret);
        }
Esempio n. 3
0
        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();
                }
            }
        }