private static void OnModsDownloaded(bool needsReload) { if (needsReload) { ModLoader.OnSuccessfulLoad = NetReload(); ModLoader.Reload(); return; } // 3 cases: Needs reload because different mod sets, needs reload because config, config matches up. foreach (var config in pendingConfigs) { var configInstance = ConfigManager.GetConfig(ModLoader.GetMod(config.modname), config.configname); JsonConvert.PopulateObject(config.json, configInstance, ConfigManager.serializerSettingsCompact); } if (ConfigManager.AnyModNeedsReload()) { ModLoader.OnSuccessfulLoad = NetReload(); ModLoader.Reload(); return; } downloadingMod = null; netMods = null; foreach (var mod in ModLoader.Mods) { mod.netID = -1; } new ModPacket(MessageID.SyncMods).Send(); }
private static void DownloadNextMod() { downloadingHeader = downloadQueue.Dequeue(); var p = new ModPacket(MessageID.ModFile); p.Write(downloadingHeader.name); p.Send(); }
private static void DownloadNextMod() { downloadingMod = downloadQueue.Dequeue(); downloadingFile = null; var p = new ModPacket(MessageID.ModFile); p.Write(downloadingMod.name); p.Send(); }
private static void CancelDownload() { try { downloadingFile?.Close(); File.Delete(downloadingMod.path); } catch { } downloadingMod = null; Netplay.disconnect = true; }
private void ObterConteudo() { IdConteudo = Convert.ToInt32(this.Parent.ID.Replace("CTT_", string.Empty)); IdIdioma = 1; HttpCookie cookie = Request.Cookies["_culture"]; if (cookie != null) { IdIdioma = Convert.ToInt32(cookie.Value); } ModHeader objModHeader = DOModHeader.Obter(IdConteudo); if (objModHeader.Arquivo != null) { imgImagemModulo.ImageUrl = String.Format("{0}/{1}/{2}", ConfigurationManager.AppSettings["BradescoRI.Path.Imagens.ModHeader"], IdConteudo, objModHeader.Arquivo); lblTitulo.CssClass = "tit-header2"; lblSubtitulo.CssClass = "c"; } if (Request.QueryString["paginaId"] != null) { Breadcrumb objBreadcrumb = DOPagina.ObterBreadcrumb(Convert.ToInt32(Utilitarios.EnCryptDecrypt.CryptorEngine.Decrypt(Request.QueryString["paginaId"]))); if (objBreadcrumb == null || string.IsNullOrEmpty(objBreadcrumb.Titulo)) { divSemConteudo.Visible = true; divConteudo.Visible = false; } else { lblTitulo.Text = objBreadcrumb.Titulo; lblSubtitulo.Text = objBreadcrumb.Descricao; litBreadcrumb.Text = string.Format("<li class=\"breadcrumb-item\"><a class=\"{0}\" href=\"Default.aspx\">Home</a></li>", (objModHeader.Arquivo != null ? "tit - header2": string.Empty)); string[] itens; foreach (string breads in objBreadcrumb.Breadcrumbs.Split('|')) { if (!string.IsNullOrEmpty(breads)) { itens = breads.Split('_'); litBreadcrumb.Text += string.Format("<li class=\"breadcrumb-item\"><a class=\"{0}\" href=\"{1}\">{2}</a></li>", (objModHeader.Arquivo != null ? "tit - header2" : string.Empty), itens[1], itens[0]); } } divSemConteudo.Visible = false; divConteudo.Visible = true; } } }
/// <summary> /// Initialises a new instance of the Mod class. Must be inherited (abstract). /// </summary> public Mod() { textTemplateReadOnly = true; Header = new ModHeader(); Header.Authors = new ModAuthors(); Header.History = new ModHistory(); Header.IncludedFiles = new StringCollection(); Header.FilesToEdit = new StringCollection(); Actions = new ModActions(); Header.EasyModCompatibility = new ModVersion(); Header.Version = new ModVersion(); }
public static void FillModTypes( IBinaryReadStream stream, ModTypeFillWrapper fill, BinaryOverlayFactoryPackage package) { int? lastParsed = null; ModHeader headerMeta = stream.GetModHeader(package); var minimumFinalPos = checked ((int)(stream.Position + headerMeta.TotalLength)); fill( stream: stream, finalPos: minimumFinalPos, offset: 0, type: headerMeta.RecordType, lastParsed: lastParsed, recordTypeConverter: null); stream.Position = (int)headerMeta.TotalLength; while (!stream.Complete) { GroupHeader groupMeta = stream.GetGroup(package); if (!groupMeta.IsGroup) { throw new ArgumentException("Did not see GRUP header as expected."); } if (groupMeta.ContentLength == 0) { stream.Position += groupMeta.TotalLength; continue; } minimumFinalPos = checked ((int)(stream.Position + groupMeta.TotalLength)); var parsed = fill( stream: stream, finalPos: minimumFinalPos, offset: 0, type: groupMeta.ContainedRecordType, lastParsed: lastParsed, recordTypeConverter: null); if (!parsed.KeepParsing) { break; } if (!parsed.KeepParsing) { break; } if (minimumFinalPos > stream.Position) { stream.Position = checked ((int)minimumFinalPos); } lastParsed = parsed.ParsedIndex; } }
public static byte[] Pack() { var ms = new MemoryStream(); //We write in front of the header so that the zip can't be read //or flagged by AV software ms.WriteByte(7); ms.WriteByte(0); ms.WriteByte(7); var zipFile = new ZipOutputStream(ms); zipFile.IsStreamOwner = false; zipFile.SetLevel(9); var header = new ModHeader(); header.Name = Program.name; header.Major = DependencyResolver.ParseVersionMajor(Program.version); header.Minor = DependencyResolver.ParseVersionMinor(Program.version); header.Tag = DependencyResolver.ParseVersionTag(Program.version); header.CodeFiles = Archive(zipFile, Program.srcFiles); header.ImageFiles = ArchiveImages(zipFile, Program.imageAssets); header.ComponentFiles = ArchiveComponents(zipFile, Program.components); header.DLLFiles = Archive(zipFile, Program.dlls); header.SoundFiles = ArchiveAudio(zipFile, Program.soundAssets); header.MapFiles = Archive(zipFile, Program.maps); header.DatabaseUrl = DependencyResolver.GetModUrl(Program.name); header.Description = Program.description; header.Dependencies = BuildDependencies(); var headerString = JsonConvert.SerializeObject(header, Formatting.Indented); WriteFile(zipFile, "mod.json", headerString); zipFile.Close(); zipFile.Dispose(); ms.Seek(0, SeekOrigin.Begin); var data = ms.ToArray(); ms.Dispose(); return(ms.ToArray()); }
private static void OnModsDownloaded(bool needsReload) { if (needsReload) { ModLoader.OnSuccessfulLoad = NetReload(); ModLoader.Reload(); return; } downloadingMod = null; netMods = null; foreach (var mod in ModLoader.Mods) { mod.netID = -1; } new ModPacket(MessageID.SyncMods).Send(); }
public static ModHeader Obter(int pintIdConteudo) { string strConectionString = ConfigurationManager.ConnectionStrings["BradescoRI"].ConnectionString; SqlConnection objConexao = new SqlConnection(strConectionString); SqlCommand objComando = new SqlCommand("SPE_L_MODULO_HEADER"); objComando.Connection = objConexao; objComando.CommandType = CommandType.StoredProcedure; objComando.Parameters.Add("@conteudoId", SqlDbType.Int).Value = pintIdConteudo; try { objConexao.Open(); ModHeader obj = new ModHeader(); IDataReader idrReader = default(IDataReader); idrReader = objComando.ExecuteReader(); while ((idrReader.Read())) { obj.FromIDataReader(idrReader); } return(obj); } catch (Exception ex) { throw ex; } finally { //Fecha a conexao se aberta if (objConexao.State != ConnectionState.Closed) { objConexao.Close(); } } }
private void CarregarObjetos(Utilitarios.TipoTransacao objTipoTransacao) { switch (objTipoTransacao) { //Carregar Dados do Usuario case Utilitarios.TipoTransacao.Salvar: if (gobjModHeader == null) { gobjModHeader = new ModHeader(); } if (fupArquivo.HasFile) { gobjModHeader.Arquivo = String.Format("{0}_{1}", IdConteudo, fupArquivo.PostedFile.FileName); } gobjModHeader.IdConteudo = IdConteudo; break; //Descarregar Dados do Usuario case Utilitarios.TipoTransacao.Carregar: if (String.IsNullOrWhiteSpace(gobjModHeader.Arquivo)) { divUpload.Visible = true; divImagem.Visible = false; } else { imgImagem.ImageUrl = String.Format("{0}/{1}/{2}", ConfigurationManager.AppSettings["BradescoRI.Path.Imagens.ModHeader"], gobjModHeader.IdConteudo, gobjModHeader.Arquivo); divUpload.Visible = false; divImagem.Visible = true; } break; } }
public static int Inserir(ModHeader pobjModHeader) { string strConectionString = ConfigurationManager.ConnectionStrings["BradescoRI"].ConnectionString; SqlConnection objConexao = new SqlConnection(strConectionString); SqlCommand objComando = new SqlCommand("SPE_I_MODULO_HEADER"); objComando.Connection = objConexao; objComando.CommandType = CommandType.StoredProcedure; //Define parametros da procedure objComando.Parameters.Add("@conteudoId", SqlDbType.Int).Value = pobjModHeader.IdConteudo; objComando.Parameters.Add("@arquivo", SqlDbType.VarChar, 200).Value = pobjModHeader.Arquivo; try { //Abre conexão com o banco de dados objConexao.Open(); //Declara variavel de retorno int intRetorno = 0; //Executa comando no banco de dados intRetorno = objComando.ExecuteNonQuery(); return(intRetorno); } catch (Exception ex) { throw ex; } finally { //Fecha a conexao se aberta if (objConexao.State != ConnectionState.Closed) { objConexao.Close(); } } }
internal static void ReceiveMod(BinaryReader reader) { if (downloadingMod == null) return; try { if (downloadingFile == null) { Interface.downloadMod.SetDownloading(reader.ReadString()); Interface.downloadMod.SetCancel(() => { downloadingFile?.Close(); downloadingMod = null; Netplay.disconnect = true; Main.menuMode = 0; }); Main.menuMode = Interface.downloadModID; downloadingLength = reader.ReadInt64(); downloadingFile = new FileStream(downloadingMod.path, FileMode.Create); return; } var bytes = reader.ReadBytes((int) Math.Min(downloadingLength - downloadingFile.Position, CHUNK_SIZE)); downloadingFile.Write(bytes, 0, bytes.Length); Interface.downloadMod.SetProgress(downloadingFile.Position, downloadingLength); if (downloadingFile.Position == downloadingLength) { downloadingFile.Close(); var mod = new TmodFile(downloadingMod.path); mod.Read(); var ex = mod.ValidMod(); if (ex != null) throw ex; if (!downloadingMod.Matches(mod)) throw new Exception("Hash mismatch"); if (downloadingMod.signed && !mod.ValidModBrowserSignature) throw new Exception("Mod was not signed by the Mod Browser"); ModLoader.EnableMod(mod); if (downloadQueue.Count > 0) DownloadNextMod(); else OnModsDownloaded(true); } } catch (Exception e) { try { downloadingFile?.Close(); } catch {} File.Delete(downloadingMod.path); ErrorLogger.LogException(e, "An error occured while downloading "+downloadingMod.name); downloadingMod = null; } }
// Receive a mod when connecting to server internal static void ReceiveMod(BinaryReader reader) { if (downloadingMod == null) { return; } try { if (downloadingFile == null) { Interface.progress.Show(displayText: reader.ReadString(), cancel: CancelDownload); ModLoader.GetMod(downloadingMod.name)?.Close(); downloadingLength = reader.ReadInt64(); downloadingFile = new FileStream(downloadingMod.path, FileMode.Create); return; } var bytes = reader.ReadBytes((int)Math.Min(downloadingLength - downloadingFile.Position, CHUNK_SIZE)); downloadingFile.Write(bytes, 0, bytes.Length); Interface.progress.Progress = downloadingFile.Position / (float)downloadingLength; if (downloadingFile.Position == downloadingLength) { downloadingFile.Close(); var mod = new TmodFile(downloadingMod.path); using (mod.Open()) { } if (!downloadingMod.Matches(mod)) { throw new Exception(Language.GetTextValue("tModLoader.MPErrorModHashMismatch")); } if (downloadingMod.signed && !mod.ValidModBrowserSignature) { throw new Exception(Language.GetTextValue("tModLoader.MPErrorModNotSigned")); } ModLoader.EnableMod(mod.name); if (downloadQueue.Count > 0) { DownloadNextMod(); } else { OnModsDownloaded(true); } } } catch (Exception e) { try { downloadingFile?.Close(); File.Delete(downloadingMod.path); } catch (Exception exc2) { Logging.tML.Error("Unknown error during mod sync", exc2); } var msg = Language.GetTextValue("tModLoader.MPErrorModDownloadError", downloadingMod.name); Logging.tML.Error(msg, e); Interface.errorMessage.Show(msg + e, 0); Netplay.disconnect = true; downloadingMod = null; } }
// This method is split so that the local variables aren't held by the GC when reloading internal static bool SyncClientMods(BinaryReader reader, out bool needsReload) { AllowVanillaClients = reader.ReadBoolean(); Logging.tML.Info($"Server reports AllowVanillaClients set to {AllowVanillaClients}"); Main.statusText = Language.GetTextValue("tModLoader.MPSyncingMods"); var clientMods = ModLoader.Mods; var modFiles = ModOrganizer.FindMods(); needsReload = false; downloadQueue.Clear(); pendingConfigs.Clear(); var syncSet = new HashSet <string>(); var blockedList = new List <ModHeader>(); int n = reader.ReadInt32(); for (int i = 0; i < n; i++) { var header = new ModHeader(reader.ReadString(), new Version(reader.ReadString()), reader.ReadBytes(20), reader.ReadBoolean()); syncSet.Add(header.name); int configCount = reader.ReadInt32(); for (int c = 0; c < configCount; c++) { pendingConfigs.Add(new NetConfig(header.name, reader.ReadString(), reader.ReadString())); } var clientMod = clientMods.SingleOrDefault(m => m.Name == header.name); if (clientMod != null && header.Matches(clientMod.File)) { continue; } needsReload = true; var localVersions = modFiles.Where(m => m.Name == header.name).ToArray(); var matching = Array.Find(localVersions, mod => header.Matches(mod.modFile)); if (matching != null) { matching.Enabled = true; continue; } // overwrite an existing version of the mod if there is one if (localVersions.Length > 0) { header.path = localVersions[0].modFile.path; } if (downloadModsFromServers && (header.signed || !onlyDownloadSignedMods)) { downloadQueue.Enqueue(header); } else { blockedList.Add(header); } } foreach (var mod in clientMods) { if (mod.Side == ModSide.Both && !syncSet.Contains(mod.Name)) { ModLoader.DisableMod(mod.Name); needsReload = true; } } if (blockedList.Count > 0) { var msg = Language.GetTextValue("tModLoader.MPServerModsCantDownload"); msg += downloadModsFromServers ? Language.GetTextValue("tModLoader.MPServerModsCantDownloadReasonSigned") : Language.GetTextValue("tModLoader.MPServerModsCantDownloadReasonAutomaticDownloadDisabled"); msg += ".\n" + Language.GetTextValue("tModLoader.MPServerModsCantDownloadChangeSettingsHint") + "\n"; foreach (var mod in blockedList) { msg += "\n " + mod; } Logging.tML.Warn(msg); Interface.errorMessage.Show(msg, 0); return(false); } // ready to connect, apply configs. Config manager will apply the configs on reload automatically if (!needsReload) { foreach (var pendingConfig in pendingConfigs) { JsonConvert.PopulateObject(pendingConfig.json, ConfigManager.GetConfig(pendingConfig), ConfigManager.serializerSettingsCompact); } if (ConfigManager.AnyModNeedsReload()) { needsReload = true; } else { foreach (var pendingConfig in pendingConfigs) { ConfigManager.GetConfig(pendingConfig).OnChanged(); } } } return(true); }
internal static void SyncClientMods(BinaryReader reader) { AllowVanillaClients = reader.ReadBoolean(); Main.statusText = Language.GetTextValue("tModLoader.MPSyncingMods"); var clientMods = ModLoader.Mods; var modFiles = ModOrganizer.FindMods(); var needsReload = false; downloadQueue.Clear(); var syncSet = new HashSet <string>(); var blockedList = new List <ModHeader>(); int n = reader.ReadInt32(); for (int i = 0; i < n; i++) { var header = new ModHeader(reader.ReadString(), new Version(reader.ReadString()), reader.ReadBytes(20), reader.ReadBoolean()); syncSet.Add(header.name); var clientMod = clientMods.SingleOrDefault(m => m.Name == header.name); if (clientMod != null) { if (header.Matches(clientMod.File)) { continue; } header.path = clientMod.File.path; } else { var disabledVersions = modFiles.Where(m => m.Name == header.name).ToArray(); var matching = disabledVersions.FirstOrDefault(mod => header.Matches(mod.modFile)); if (matching != null) { matching.Enabled = true; needsReload = true; continue; } if (disabledVersions.Length > 0) { header.path = disabledVersions[0].modFile.path; } } if (downloadModsFromServers && (header.signed || !onlyDownloadSignedMods)) { downloadQueue.Enqueue(header); } else { blockedList.Add(header); } } foreach (var mod in clientMods) { if (mod.Side == ModSide.Both && !syncSet.Contains(mod.Name)) { ModLoader.DisableMod(mod.Name); needsReload = true; } } if (blockedList.Count > 0) { var msg = Language.GetTextValue("tModLoader.MPServerModsCantDownload"); msg += downloadModsFromServers ? Language.GetTextValue("tModLoader.MPServerModsCantDownloadReasonSigned") : Language.GetTextValue("tModLoader.MPServerModsCantDownloadReasonAutomaticDownloadDisabled"); msg += ".\n" + Language.GetTextValue("tModLoader.MPServerModsCantDownloadChangeSettingsHint") + "\n"; foreach (var mod in blockedList) { msg += "\n " + mod; } Logging.tML.Warn(msg); Interface.errorMessage.SetMessage(msg); Interface.errorMessage.SetGotoMenu(0); Main.gameMenu = true; Main.menuMode = Interface.errorMessageID; return; } if (downloadQueue.Count > 0) { DownloadNextMod(); } else { OnModsDownloaded(needsReload); } }
internal static void ReceiveMod(BinaryReader reader) { if (downloadingMod == null) { return; } try { if (downloadingFile == null) { Interface.downloadMod.SetDownloading(reader.ReadString()); Interface.downloadMod.SetCancel(() => { downloadingFile?.Close(); downloadingMod = null; Netplay.disconnect = true; Main.menuMode = 0; }); Main.menuMode = Interface.downloadModID; downloadingLength = reader.ReadInt64(); downloadingFile = new FileStream(downloadingMod.path, FileMode.Create); return; } var bytes = reader.ReadBytes((int)Math.Min(downloadingLength - downloadingFile.Position, CHUNK_SIZE)); downloadingFile.Write(bytes, 0, bytes.Length); Interface.downloadMod.SetProgress(downloadingFile.Position, downloadingLength); if (downloadingFile.Position == downloadingLength) { downloadingFile.Close(); var mod = new TmodFile(downloadingMod.path); mod.Read(TmodFile.LoadedState.Info); if (!downloadingMod.Matches(mod)) { throw new Exception(Language.GetTextValue("tModLoader.MPErrorModHashMismatch")); } if (downloadingMod.signed && !mod.ValidModBrowserSignature) { throw new Exception(Language.GetTextValue("tModLoader.MPErrorModNotSigned")); } ModLoader.EnableMod(mod.name); if (downloadQueue.Count > 0) { DownloadNextMod(); } else { OnModsDownloaded(true); } } } catch (Exception e) { try { downloadingFile?.Close(); } catch { } File.Delete(downloadingMod.path); ErrorLogger.LogException(e, Language.GetTextValue("tModLoader.MPErrorModDownloadError", downloadingMod.name)); downloadingMod = null; } }
public void UpdateFileModHeader(string path, ModHeader modSet) { filesMod.Add(path, modSet); }
internal static void ReceiveMod(BinaryReader reader) { if (downloadingMod == null) { return; } try { if (downloadingFile == null) { // TODO migrate to download UI, create new StreamingDownloadRequest // TODO I hope this works fine without UI for the moment... //Interface.downloadMod.SetDownloading(reader.ReadString()); //Interface.downloadMod.SetCancel(CancelDownload); Main.menuMode = Interface.downloadModID; ModLoader.GetMod(downloadingMod.name)?.File?.Close(); downloadingLength = reader.ReadInt64(); downloadingFile = new FileStream(downloadingMod.path, FileMode.Create); return; } var bytes = reader.ReadBytes((int)Math.Min(downloadingLength - downloadingFile.Position, CHUNK_SIZE)); downloadingFile.Write(bytes, 0, bytes.Length); //Interface.downloadMod.SetProgress(downloadingFile.Position, downloadingLength); if (downloadingFile.Position == downloadingLength) { downloadingFile.Close(); var mod = new TmodFile(downloadingMod.path); mod.Read(); mod.Close(); if (!downloadingMod.Matches(mod)) { throw new Exception(Language.GetTextValue("tModLoader.MPErrorModHashMismatch")); } if (downloadingMod.signed && !mod.ValidModBrowserSignature) { throw new Exception(Language.GetTextValue("tModLoader.MPErrorModNotSigned")); } ModLoader.EnableMod(mod.name); if (downloadQueue.Count > 0) { DownloadNextMod(); } else { OnModsDownloaded(true); } } } catch (Exception e) { try { downloadingFile?.Close(); File.Delete(downloadingMod.path); } catch { } var msg = Language.GetTextValue("tModLoader.MPErrorModDownloadError", downloadingMod.name); Logging.tML.Error(msg, e); Interface.errorMessage.Show(msg + e, 0); Netplay.disconnect = true; downloadingMod = null; } }
internal static void SyncClientMods(BinaryReader reader) { AllowVanillaClients = reader.ReadBoolean(); Main.statusText = "Syncing Mods"; var clientMods = ModLoader.LoadedMods; var modFiles = ModLoader.FindMods(); var needsReload = false; downloadQueue.Clear(); var syncSet = new HashSet <string>(); var blockedList = new List <ModHeader>(); int n = reader.ReadInt32(); for (int i = 0; i < n; i++) { var header = new ModHeader(reader.ReadString(), new Version(reader.ReadString()), reader.ReadBytes(20), reader.ReadBoolean()); syncSet.Add(header.name); var clientMod = clientMods.SingleOrDefault(m => m.Name == header.name); if (clientMod != null) { if (header.Matches(clientMod.File)) { continue; } header.path = clientMod.File.path; } else { var disabledVersions = modFiles.Where(m => m.name == header.name).ToArray(); var matching = disabledVersions.FirstOrDefault(header.Matches); if (matching != null) { ModLoader.EnableMod(matching); needsReload = true; continue; } if (disabledVersions.Length > 0) { header.path = disabledVersions[0].path; } } if (downloadModsFromServers && (header.signed || !onlyDownloadSignedMods)) { downloadQueue.Enqueue(header); } else { blockedList.Add(header); } } foreach (var mod in clientMods) { if (mod.Side == ModSide.Both && !syncSet.Contains(mod.Name)) { ModLoader.DisableMod(mod.File); needsReload = true; } } if (blockedList.Count > 0) { var msg = "The following mods are installed on the server but cannot be downloaded "; msg += downloadModsFromServers ? "because you only accept mods signed by the mod browser" : "because you have disabled automatic mod downloading"; msg += ".\nYou will need to change your settings or acquire the mods from the server owner.\n"; foreach (var mod in blockedList) { msg += "\n " + mod; } ErrorLogger.LogMissingMods(msg); return; } if (downloadQueue.Count > 0) { DownloadNextMod(); } else { OnModsDownloaded(needsReload); } }
internal static void SyncClientMods(BinaryReader reader) { AllowVanillaClients = reader.ReadBoolean(); Main.statusText = "Syncing Mods"; var clientMods = ModLoader.LoadedMods; var modFiles = ModLoader.FindMods(); var needsReload = false; downloadQueue.Clear(); var syncSet = new HashSet<string>(); var blockedList = new List<ModHeader>(); int n = reader.ReadInt32(); for (int i = 0; i < n; i++) { var header = new ModHeader(reader.ReadString(), new Version(reader.ReadString()), reader.ReadBytes(20), reader.ReadBoolean()); syncSet.Add(header.name); var clientMod = clientMods.SingleOrDefault(m => m.Name == header.name); if (clientMod != null) { if (header.Matches(clientMod.File)) continue; header.path = clientMod.File.path; } else { var disabledVersions = modFiles.Where(m => m.name == header.name).ToArray(); var matching = disabledVersions.FirstOrDefault(header.Matches); if (matching != null) { ModLoader.EnableMod(matching); needsReload = true; continue; } if (disabledVersions.Length > 0) header.path = disabledVersions[0].path; } if (downloadModsFromServers && (header.signed || !onlyDownloadSignedMods)) downloadQueue.Enqueue(header); else blockedList.Add(header); } foreach (var mod in clientMods) if (mod.Side == ModSide.Both && !syncSet.Contains(mod.Name)) { ModLoader.DisableMod(mod.File); needsReload = true; } if (blockedList.Count > 0) { var msg = "The following mods are installed on the server but cannot be downloaded "; msg += downloadModsFromServers ? "because you only accept mods signed by the mod browser" : "because you have disabled automatic mod downloading"; msg += ".\nYou will need to change your settings or acquire the mods from the server owner.\n"; foreach (var mod in blockedList) msg += "\n " + mod; ErrorLogger.LogMissingMods(msg); return; } if (downloadQueue.Count > 0) DownloadNextMod(); else OnModsDownloaded(needsReload); }
static void AllocModObj(Nso nso) { nso.RwdataSegment.BssOrAlign += 0x100; ModHeader.CreateModHeader(nso, nso.GetModAddr(), nso.ModSection.DynamicAddr, nso.ModSection.EhStartAddr, nso.ModSection.EhEndAddr, nso.ModSection.BssEndAddr); }
private static void OnModsDownloaded(bool needsReload) { if (needsReload) { ModLoader.PostLoad = NetReload; ModLoader.Reload(); return; } downloadingMod = null; netMods = null; foreach (var mod in ModLoader.LoadedMods) mod.netID = -1; new ModPacket(MessageID.SyncMods).Send(); }
static void Main() { InitDllMap(); //SetProcessDPIAware(); //TODO: figure out how to set this switch in appconfig AppContext.SetSwitch("Switch.System.Runtime.Serialization.SerializationGuard.AllowFileWrites", true); Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; Thread.CurrentThread.CurrentUICulture = CultureInfo.InvariantCulture; string[] args = Environment.GetCommandLineArgs(); PathMod.InitExePath(args[0]); DiagManager.InitInstance(); DiagManager.Instance.CurSettings = DiagManager.Instance.LoadSettings(); DiagManager.Instance.LoadModSettings(); DiagManager.Instance.UpgradeBinder = new UpgradeBinder(); try { DiagManager.Instance.LogInfo("========================================="); DiagManager.Instance.LogInfo(String.Format("SESSION STARTED: {0}", String.Format("{0:yyyy/MM/dd HH:mm:ss}", DateTime.Now))); DiagManager.Instance.LogInfo("Version: " + Versioning.GetVersion().ToString()); DiagManager.Instance.LogInfo(Versioning.GetDotNetInfo()); DiagManager.Instance.LogInfo("========================================="); bool logInput = true; bool guideBook = false; bool guideCsv = false; GraphicsManager.AssetType convertAssets = GraphicsManager.AssetType.None; DataManager.DataType convertIndices = DataManager.DataType.None; DataManager.DataType reserializeIndices = DataManager.DataType.None; string langArgs = ""; bool dev = false; string quest = ""; List <string> mod = new List <string>(); bool buildQuest = false; string playInputs = null; for (int ii = 1; ii < args.Length; ii++) { if (args[ii] == "-dev") { dev = true; } else if (args[ii] == "-play" && args.Length > ii + 1) { playInputs = args[ii + 1]; ii++; } else if (args[ii] == "-lang" && args.Length > ii + 1) { langArgs = args[ii + 1]; ii++; } else if (args[ii] == "-nolog") { logInput = false; } else if (args[ii] == "-guide") { guideBook = true; } else if (args[ii] == "-csv") { guideCsv = true; } else if (args[ii] == "-asset") { PathMod.ASSET_PATH = Path.GetFullPath(args[ii + 1]); ii++; } else if (args[ii] == "-raw") { PathMod.DEV_PATH = Path.GetFullPath(args[ii + 1]); ii++; } else if (args[ii] == "-quest") { quest = args[ii + 1]; ii++; } else if (args[ii] == "-mod") { int jj = 1; while (args.Length > ii + jj) { if (args[ii + jj].StartsWith("-")) { break; } else { mod.Add(args[ii + jj]); } jj++; } ii += jj - 1; } else if (args[ii] == "-build") { buildQuest = true; ii++; } else if (args[ii] == "-convert") { int jj = 1; while (args.Length > ii + jj) { GraphicsManager.AssetType conv = GraphicsManager.AssetType.None; foreach (GraphicsManager.AssetType type in Enum.GetValues(typeof(GraphicsManager.AssetType))) { if (args[ii + jj].ToLower() == type.ToString().ToLower()) { conv = type; break; } } if (conv != GraphicsManager.AssetType.None) { convertAssets |= conv; } else { break; } jj++; } ii += jj - 1; } else if (args[ii] == "-index") { int jj = 1; while (args.Length > ii + jj) { DataManager.DataType conv = DataManager.DataType.None; foreach (DataManager.DataType type in Enum.GetValues(typeof(DataManager.DataType))) { if (args[ii + jj].ToLower() == type.ToString().ToLower()) { conv = type; break; } } if (conv != DataManager.DataType.None) { convertIndices |= conv; } else { break; } jj++; } ii += jj - 1; } else if (args[ii] == "-reserialize") { int jj = 1; while (args.Length > ii + jj) { DataManager.DataType conv = DataManager.DataType.None; foreach (DataManager.DataType type in Enum.GetValues(typeof(DataManager.DataType))) { if (args[ii + jj].ToLower() == type.ToString().ToLower()) { conv = type; break; } } if (conv != DataManager.DataType.None) { reserializeIndices |= conv; } else { break; } jj++; } ii += jj - 1; } } DiagManager.Instance.SetupGamepad(); GraphicsManager.InitParams(); DiagManager.Instance.DevMode = dev; if (quest != "") { ModHeader header = PathMod.GetModDetails(Path.Combine(PathMod.MODS_PATH, quest)); if (header.IsValid()) { PathMod.Quest = header; DiagManager.Instance.LogInfo(String.Format("Loaded quest \"{0}\".", quest)); } else { DiagManager.Instance.LogInfo(String.Format("Cannot find quest \"{0}\" in {1}. Falling back to base game.", quest, PathMod.MODS_PATH)); } } if (mod.Count > 0) { List <ModHeader> workingMods = new List <ModHeader>(); for (int ii = 0; ii < mod.Count; ii++) { ModHeader header = PathMod.GetModDetails(Path.Combine(PathMod.MODS_PATH, mod[ii])); if (header.IsValid()) { workingMods.Add(header); DiagManager.Instance.LogInfo(String.Format("Loaded mod \"{0}\".", String.Join(", ", mod[ii]))); } else { DiagManager.Instance.LogInfo(String.Format("Cannot find mod \"{0}\" in {1}. It will be ignored.", mod, PathMod.MODS_PATH)); mod.RemoveAt(ii); ii--; } } PathMod.Mods = workingMods.ToArray(); } if (playInputs != null) { DiagManager.Instance.LoadInputs(playInputs); } Text.Init(); if (langArgs != "" && DiagManager.Instance.CurSettings.Language == "") { if (langArgs.Length > 0) { DiagManager.Instance.CurSettings.Language = langArgs.ToLower(); Text.SetCultureCode(langArgs.ToLower()); } else { DiagManager.Instance.CurSettings.Language = "en"; } } Text.SetCultureCode(DiagManager.Instance.CurSettings.Language == "" ? "" : DiagManager.Instance.CurSettings.Language.ToString()); if (buildQuest) { if (!PathMod.Quest.IsValid()) { DiagManager.Instance.LogInfo("No quest specified to build."); return; } RogueEssence.Dev.DevHelper.MergeQuest(quest); return; } if (convertAssets != GraphicsManager.AssetType.None) { //run conversions using (GameBase game = new GameBase()) { GraphicsManager.InitSystem(game.GraphicsDevice); GraphicsManager.RunConversions(convertAssets); } return; } if (reserializeIndices != DataManager.DataType.None) { DiagManager.Instance.LogInfo("Beginning Reserialization"); using (GameBase game = new GameBase()) { GraphicsManager.InitSystem(game.GraphicsDevice); GraphicsManager.RebuildIndices(GraphicsManager.AssetType.All); } //we need the datamanager for this, but only while data is hardcoded //TODO: remove when data is no longer hardcoded LuaEngine.InitInstance(); DataManager.InitInstance(); DataManager.InitDataDirs(PathMod.ModPath("")); RogueEssence.Dev.DevHelper.ReserializeBase(); DiagManager.Instance.LogInfo("Reserializing main data"); RogueEssence.Dev.DevHelper.Reserialize(reserializeIndices); DiagManager.Instance.LogInfo("Reserializing map data"); if ((reserializeIndices & DataManager.DataType.Zone) != DataManager.DataType.None) { RogueEssence.Dev.DevHelper.ReserializeData <Map>(DataManager.DATA_PATH + "Map/", DataManager.MAP_EXT); RogueEssence.Dev.DevHelper.ReserializeData <GroundMap>(DataManager.DATA_PATH + "Ground/", DataManager.GROUND_EXT); } DiagManager.Instance.LogInfo("Reserializing indices"); RogueEssence.Dev.DevHelper.RunIndexing(reserializeIndices); DataManager.Instance.UniversalData = (TypeDict <BaseData>)RogueEssence.Dev.DevHelper.LoadWithLegacySupport(PathMod.ModPath(DataManager.MISC_PATH + "Index.bin"), typeof(TypeDict <BaseData>)); RogueEssence.Dev.DevHelper.RunExtraIndexing(reserializeIndices); return; } if (convertIndices != DataManager.DataType.None) { //we need the datamanager for this, but only while data is hardcoded //TODO: remove when data is no longer hardcoded LuaEngine.InitInstance(); DataManager.InitInstance(); DiagManager.Instance.LogInfo("Reserializing indices"); DataManager.InitDataDirs(PathMod.ModPath("")); RogueEssence.Dev.DevHelper.RunIndexing(convertIndices); DataManager.Instance.UniversalData = (TypeDict <BaseData>)RogueEssence.Dev.DevHelper.LoadWithLegacySupport(PathMod.ModPath(DataManager.MISC_PATH + "Index.bin"), typeof(TypeDict <BaseData>)); RogueEssence.Dev.DevHelper.RunExtraIndexing(convertIndices); return; } if (guideBook || guideCsv) { //print the guidebook in the chosen language //we need the datamanager for this LuaEngine.InitInstance(); DataManager.InitInstance(); DataManager.Instance.InitData(); //just print a guidebook and exit StrategyGuide.PrintMoveGuide(guideCsv); StrategyGuide.PrintItemGuide(guideCsv); StrategyGuide.PrintAbilityGuide(guideCsv); StrategyGuide.PrintEncounterGuide(guideCsv); return; } //Dev.ImportManager.PrintMoveUsers(PathMod.DEV_PATH+"moves.txt"); //Dev.ImportManager.PrintAbilityUsers(PathMod.DEV_PATH+"abilities.txt"); logInput = false; //this feature is disabled for now... if (DiagManager.Instance.ActiveDebugReplay == null && logInput) { DiagManager.Instance.BeginInput(); } if (DiagManager.Instance.DevMode) { InitDataEditor(); AppBuilder builder = RogueEssence.Dev.Program.BuildAvaloniaApp(); builder.StartWithClassicDesktopLifetime(args); } else { DiagManager.Instance.DevEditor = new EmptyEditor(); using (GameBase game = new GameBase()) game.Run(); } } catch (Exception ex) { DiagManager.Instance.LogError(ex); throw; } }