Esempio n. 1
0
        public static void GetVersionInts(ref int major, ref int minor, ref int revision)
        {
            ApplicationVersion applicationVersion = ApplicationVersion.FromParametersFile(ApplicationVersionGameType.Singleplayer);

            major    = applicationVersion.Major;
            minor    = applicationVersion.Minor;
            revision = applicationVersion.Revision;
        }
        private static MetaData GetSaveMetaData(CampaignSaveMetaDataArgs data)
        {
            MetaData          metaData = new MetaData();
            List <ModuleInfo> modules  = MBSaveLoad.GetModules(data.ModuleNames);

            metaData["Modules"] = string.Join(";", modules.Select <ModuleInfo, string>((Func <ModuleInfo, string>)(q => q.Name)));
            foreach (ModuleInfo moduleInfo in modules)
            {
                metaData["Module_" + moduleInfo.Name] = moduleInfo.Version.ToString();
            }
            metaData.Add("ApplicationVersion", ApplicationVersion.FromParametersFile(ApplicationVersionGameType.Singleplayer).ToString());
            metaData.Add("CreationTime", DateTime.Now.ToString());
            foreach (KeyValuePair <string, string> keyValuePair in data.OtherData)
            {
                metaData.Add(keyValuePair.Key, keyValuePair.Value);
            }
            return(metaData);
        }
Esempio n. 3
0
 public static void Initialize()
 {
     Debug.Print("Initializing NetworkMain");
     MBCommon.CurrentGameType = MBCommon.GameType.Single;
     GameNetwork.InitializeCompressionInfos();
     if (!NetworkMain.IsInitialized)
     {
         NetworkMain.IsInitialized = true;
         GameNetwork.Initialize((IGameNetworkHandler) new GameNetworkHandler());
         if (!GameNetwork.IsDedicatedServer)
         {
             NetworkMain._diamondClientApplication = new DiamondClientApplication(ApplicationVersion.FromParametersFile(ApplicationVersionGameType.Multiplayer));
             NetworkMain._diamondClientApplication.Initialize(NetworkMain._lobbyClientApplicationConfiguration);
             NetworkMain.GameClient = NetworkMain._diamondClientApplication.GetClient <LobbyClient>("LobbyClient");
             MachineId.Initialize();
         }
     }
     Debug.Print("NetworkMain Initialized");
 }
        static Scripts()
        {
            using (var writer = File.CreateText(RspFilePath)) {
                writer.WriteLine("# DO NOT EDIT THIS FILE!");
                writer.WriteLine("# It is automatically generated by the C# Scripting mod, and will be overwritten.");
                writer.WriteLine();

                writer.WriteLine($"/r:\"{typeof(ScriptGlobals).Assembly.Location}\"");
                writer.WriteLine($"/r:\"{typeof(Microsoft.CSharp.RuntimeBinder.RuntimeBinderException).Assembly.Location}\"");
                var nss = new HashSet <string>();
                foreach (var asm in AppDomain.CurrentDomain.GetAssemblies())
                {
                    if (asm.IsDynamic || string.IsNullOrEmpty(asm.Location))
                    {
                        continue;
                    }
                    writer.WriteLine($"/r:\"{asm.Location}\"");
                    foreach (var type in asm.GetExportedTypes())
                    {
                        var ns = type.Namespace;
                        if (ns != null && (ns.StartsWith("TaleWorlds") || ns.StartsWith("SandBox")))
                        {
                            nss.Add(ns);
                        }
                    }
                }
                writer.WriteLine();

                writer.WriteLine("/u:System");
                writer.WriteLine("/u:System.Collections.Generic");
                writer.WriteLine("/u:System.Linq");
                writer.WriteLine("/u:System.Reflection");
                writer.WriteLine("/u:System.Text");
                foreach (var ns in nss)
                {
                    writer.WriteLine($"/u:{ns}");
                }
                writer.WriteLine($"/u:{typeof(ScriptGlobals).FullName}");
                writer.WriteLine();

                foreach (var loadPath in GetSearchPaths())
                {
                    writer.WriteLine($"/loadpath:\"{loadPath}\"");
                }
                writer.WriteLine();

                var gameAppVer = ApplicationVersion.FromParametersFile(ApplicationVersionGameType.Singleplayer);
                var gameVer    = new Version(gameAppVer.Major, gameAppVer.Minor, gameAppVer.Revision);
                for (var major = 1; major < 10; ++major)
                {
                    for (var minor = 6; minor < 10; ++minor)
                    {
                        for (var release = 0; release < 20; ++release)
                        {
                            var ver = new Version(major, minor, release);
                            if (ver <= gameVer)
                            {
                                writer.WriteLine($"/d:BANNERLORD_{major}_{minor}_{release}");
                            }
                        }
                    }
                }
            }
        }