public static void TestMultipleThreads(int i_iNumThreads, int i_iNumIterations, int i_iSleep, string i_sPath) { Console.WriteLine("Starting test on {0} threads with {1} iterations to '{2}'...", i_iNumThreads, i_iNumIterations, i_sPath); ILegacyLogger log = new LegacyLogger(); Thread[] aThreads = new Thread[i_iNumThreads]; LoggingThread[] aLTs = new LoggingThread[i_iNumThreads]; string sThreadName = Thread.CurrentThread.Name = "LoggingTestsT"; // string sThreadName = Thread.CurrentThread.Name = ""; // log.Init("", "", sThreadName, "", "LogTester", i_sPath); log.Init("", "", sThreadName, "", "", i_sPath); // Let logger look up the component name log.Open(); log.Log(Level.Debug, "Starting threads..."); for (int ii = 0; ii < i_iNumThreads; ii++) { aLTs[ii] = new LoggingThread(log, ii, i_iNumIterations, i_iSleep); aThreads[ii] = new Thread(new ThreadStart(aLTs[ii].ThreadProc)); aThreads[ii].Start(); } foreach (Thread tThread in aThreads) { tThread.Join(); } log.Log(Level.Debug, "Done."); log.Close(); }
public void Load(SaveGameData p_data) { m_items.Clear(); Int32 num = p_data.Get <Int32>("ItemCount", 0); for (Int32 i = 0; i < num; i++) { EDataType p_type = (EDataType)p_data.Get <Int32>("Type" + i, 0); SaveGameData saveGameData = p_data.Get <SaveGameData>("Item" + i, null); if (saveGameData != null) { try { BaseItem baseItem = ItemFactory.CreateItem(p_type); baseItem.Load(saveGameData); m_items.Add(baseItem); } catch (Exception ex) { LegacyLogger.Log(ex.ToString()); } } } SaveGameData saveGameData2 = p_data.Get <SaveGameData>("UpdateTime", null); if (saveGameData2 != null) { m_updateTime.Load(saveGameData2); } m_initialItemUpdateDone = p_data.Get <Boolean>("InitialItemUpdateDone", false); }
public override void DoEffect(Monster p_monster, Character p_target, SpellEventArgs p_spellArgs) { m_grid = LegacyLogic.Instance.MapLoader.Grid; Party party = LegacyLogic.Instance.WorldManager.Party; GridSlot gridSlot = CheckSlot(party.Position); if (gridSlot == null) { gridSlot = FindTargetSlot(p_monster.Position); } if (gridSlot != null) { if (gridSlot.Position != party.Position) { MoveParty(gridSlot); } SpawnCagePiece(gridSlot.Position + EDirection.WEST, true); SpawnCagePiece(gridSlot.Position + EDirection.NORTH, false); SpawnCagePiece(gridSlot.Position + EDirection.EAST, false); SpawnCagePiece(gridSlot.Position + EDirection.SOUTH, false); } else { LegacyLogger.Log("FOUND no slot :("); } }
protected override void DoExecute() { ShrineStaticData staticData = StaticDataHandler.GetStaticData <ShrineStaticData>(EDataType.SHRINES, m_shrineID); if (staticData != null) { TokenStaticData staticData2 = StaticDataHandler.GetStaticData <TokenStaticData>(EDataType.TOKEN, staticData.TokenID); if (LegacyLogic.Instance.WorldManager.Party.TokenHandler.GetTokens(staticData.TokenID) > 0 || (staticData2.Replacement > 0 && LegacyLogic.Instance.WorldManager.Party.TokenHandler.GetTokens(staticData2.Replacement) > 0)) { CustomPopupEventArgs p_eventArgs = new CustomPopupEventArgs(Localization.Instance.GetText(staticData.Caption), Localization.Instance.GetText("GAMEMESSAGE_NOTHING_HAPPENS")); LegacyLogic.Instance.EventManager.InvokeEvent(null, EEventType.CUSTOM_POPUP, p_eventArgs); FinishExecution(); } else if (LegacyLogic.Instance.GameTime.Time.Days % 7 == (Int32)staticData.WeekDay) { m_parent.State = EInteractiveObjectState.ON; LegacyLogic.Instance.EventManager.InvokeEvent(m_parent, EEventType.OBJECT_STATE_CHANGED, EventArgs.Empty); LegacyLogic.Instance.WorldManager.Party.TokenHandler.AddToken(staticData.TokenID); CustomPopupEventArgs p_eventArgs = new CustomPopupEventArgs(Localization.Instance.GetText(staticData.Caption), Localization.Instance.GetText(staticData.RightText)); LegacyLogic.Instance.EventManager.InvokeEvent(null, EEventType.CUSTOM_POPUP, p_eventArgs); FinishExecution(); } else { m_stateMachine.ChangeState(3); } } else { LegacyLogger.Log("Shrine with ID " + m_shrineID + " doesn't exist"); FinishExecution(); } }
public List <ModInfo> GetModList() { String[] directories = Directory.GetDirectories(GamePaths.ModsRootPath); List <ModInfo> list = new List <ModInfo>(directories.Length); for (Int32 i = 0; i < directories.Length; i++) { String text = Path.Combine(directories[i], "modinfo.xml"); try { ModInfo modInfo; if (Helper.Xml.OpenRead <ModInfo>(text, ModInfo.XmlRoot, out modInfo)) { modInfo.RootPath = Path.Combine(GamePaths.ModsRootPath, directories[i]); list.Add(modInfo); } else { LegacyLogger.Log("ModLoader: ParseError " + text); } } catch (Exception ex) { LegacyLogger.Log(ex.ToString()); } } return(list); }
private static void AddLocaData(String fileOrigin, LocaData[] data, Dictionary <String, String> p_target) { try { HashSet <String> processedIds = new HashSet <String>(); for (Int32 i = 0; i < data.Length; i++) { LocaData item = data[i]; if (!processedIds.Add(item.ID)) { LegacyLogger.Log("Double LocaID '" + item.ID + "' in " + fileOrigin); continue; } if (String.IsNullOrEmpty(item.Text)) { LegacyLogger.Log("LocaID '" + item.ID + "' has no text", false); continue; } p_target[item.ID] = item.Text.Trim(); } } catch (Exception ex) { LegacyLogger.Log("Error initializing LocaTexts: " + fileOrigin + " " + ex); } }
public override void ExecutionBreak() { Party party = LegacyLogic.Instance.WorldManager.Party; StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendLine("PartyTurnActor execution aborded!"); try { stringBuilder.AppendLine("Left state: " + m_stateMachine.CurrentState.Id); foreach (BaseAction baseAction in m_activeActions) { stringBuilder.AppendLine("Active action: " + baseAction.ToString()); } if (party.SelectedCharacter != null) { stringBuilder.AppendLine("Selected character: " + party.SelectedCharacter.Name); } if (party.SelectedMonster != null) { stringBuilder.AppendLine("Selected monster: " + party.SelectedMonster.Name); } stringBuilder.AppendLine("Height: " + party.Height); stringBuilder.AppendLine("Gold: " + party.Gold); stringBuilder.AppendLine("Supplies: " + party.Supplies); stringBuilder.AppendLine("Movement done: " + party.MovementDone.IsTriggered); stringBuilder.AppendLine(String.Concat(new Object[] { "Position: x=", party.Position.X, " y=", party.Position.Y })); stringBuilder.AppendLine("Direction: " + party.Direction); stringBuilder.AppendLine("-----characters-----"); foreach (Character character in party.Members) { stringBuilder.AppendLine("Character: name " + character.Name); stringBuilder.AppendLine("Character: class " + character.Class.Class); stringBuilder.AppendLine("Character: attribute destiny " + character.CurrentAttributes.Destiny); stringBuilder.AppendLine("Character: attribute magic " + character.CurrentAttributes.Magic); stringBuilder.AppendLine("Character: attribute might " + character.CurrentAttributes.Might); stringBuilder.AppendLine("Character: attribute perception " + character.CurrentAttributes.Perception); stringBuilder.AppendLine("Character: health points " + character.HealthPoints); stringBuilder.AppendLine("Character: mana points " + character.ManaPoints); stringBuilder.AppendLine("Character: level " + character.Level); stringBuilder.AppendLine("Character: turn done " + character.DoneTurn); stringBuilder.AppendLine("Character: Can do anything " + character.ConditionHandler.CantDoAnything()); stringBuilder.AppendLine("Character: Conditions: " + character.ConditionHandler.Condition); stringBuilder.AppendLine("-----------"); } LegacyLogger.Log(stringBuilder.ToString(), false); LegacyLogic.Instance.CommandManager.ClearContiniousQueue(); } catch (Exception ex) { stringBuilder.AppendLine("Error during dump generation: " + ex.StackTrace); } m_stateMachine.ChangeState(EState.FINISHED); party.StartTurn(); }
public static SaveGameMeta ReadMetaData(BinaryReader p_reader, Boolean p_getDifficulty) { String text = p_reader.ReadString(); Int64 value = p_reader.ReadInt64(); Int32 p_saveNumber = p_reader.ReadInt32(); Int32 p_type = p_reader.ReadInt32(); DateTime p_time; if (!DateTime.TryParseExact(text, "yyyy-MM-dd HH:mm", null, DateTimeStyles.None, out p_time)) { LegacyLogger.Log("Cannot parse Time: " + text); return(default(SaveGameMeta)); } SaveGameMeta result; if (p_getDifficulty) { result = new SaveGameMeta(p_time, TimeSpan.FromTicks(value), p_saveNumber, (ESaveGameType)p_type, GetDifficulty(p_reader)); } else { result = new SaveGameMeta(p_time, TimeSpan.FromTicks(value), p_saveNumber, (ESaveGameType)p_type); } result.Loaded = true; return(result); }
public override void ExecutionBreak() { base.ExecutionBreak(); try { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendLine("Entity count " + m_entities.Count); stringBuilder.AppendLine("-----Not finish turn entities-----"); foreach (MovingEntity movingEntity in m_entities) { if (!movingEntity.IsFinishTurn) { stringBuilder.AppendLine(String.Concat(new Object[] { "StaticID=", movingEntity.StaticID, "; SpawnerID=", movingEntity.SpawnerID })); stringBuilder.AppendLine(movingEntity.ToString()); stringBuilder.AppendLine(); } } LegacyLogger.Log(stringBuilder.ToString(), false); } catch (Exception arg) { LegacyLogger.Log("Error during dump generation: " + arg, false); } }
public override void Execute(Grid p_grid) { if (Commands.Count > 0) { LegacyLogger.Log("Place-Holder cannot execute any Commands"); } }
public override void ExecutionBreak() { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendLine("SpawnTurnActor execution aborded!"); stringBuilder.AppendLine("Left state: " + m_stateMachine.CurrentState.Id); stringBuilder.AppendLine("-----spawn objects-----"); foreach (Spawn spawn in m_spawnObjects) { stringBuilder.AppendLine("Spawn object: " + spawn.ID); stringBuilder.AppendLine("Spawn object: direction " + spawn.Direction); stringBuilder.AppendLine(String.Concat(new Object[] { "Spawn object: position x=", spawn.Position.X, "y=", spawn.Position.Y })); stringBuilder.AppendLine("Spawn object: object id " + spawn.ObjectID); stringBuilder.AppendLine("Spawn object: state " + spawn.State); stringBuilder.AppendLine("-----------"); spawn.TurnIdle.Trigger(); } stringBuilder.AppendLine("Left state: " + m_stateMachine.CurrentState); LegacyLogger.Log(stringBuilder.ToString(), false); m_stateMachine.ChangeState(EState.FINISHED); }
public static void LoadData <T>(EDataType p_type, String p_filePath) where T : BaseStaticData { T[] array; if (File.Exists(p_filePath)) { using (FileStream fileStream = File.OpenRead(p_filePath)) array = CSVParser <T> .Deserialize(fileStream); } else { array = new T[0]; } Dictionary <Int32, T> dic = new Dictionary <Int32, T>(array.Length); foreach (T item in array) { if (!dic.ContainsKey(item.StaticID)) { item.PostDeserialization(); dic.Add(item.StaticID, item); } else { LegacyLogger.Log(String.Concat(new Object[] { "StaticData already loaded; SID=", item.StaticID, "; Type=", p_type })); } } String directory = Path.GetDirectoryName(p_filePath); if (directory != null) { String mask = Path.ChangeExtension(Path.GetFileName(p_filePath), null) + "_*.csv"; foreach (String filePath in Directory.GetFiles(directory, mask, SearchOption.AllDirectories)) { using (FileStream fileStream = File.OpenRead(filePath)) CSVParser <T> .Deserialize(fileStream, dic); } } Dictionary <Int32, BaseStaticData> result = new Dictionary <Int32, BaseStaticData>(dic.Count); foreach (KeyValuePair <Int32, T> pair in dic) { Int32 key = pair.Key; T value = pair.Value; value.PostDeserialization(); result.Add(key, value); } m_staticDataMap[(Int32)p_type] = result; }
public void Load(ConfigReader p_reader) { if (m_onlyChineseAvailable) { Language = "cn"; } else { Language = "en"; using (RegistryKey registryKey = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Ubisoft\\Might & Magic X Legacy", true)) { if (registryKey != null) { Language = registryKey.GetValue("GameLanguageCustom", String.Empty).ToString(); if (Language == String.Empty) { Language = registryKey.GetValue("GameLanguage", "en").ToString(); } } else { LegacyLogger.Log("Cant open RegistryKey 'SOFTWARE\\Ubisoft\\Might & Magic X Legacy"); } } } SubTitles = p_reader["language"]["subtitles"].GetBool(true); MonsterHPBarsVisible = p_reader["gameplay"]["monsterHPBarVisible"].GetBool(true); ShowHints = p_reader["gameplay"]["showHints"].GetBool(true); HideMinimapTooltips = p_reader["gameplay"]["hideMinimapTooltips"].GetBool(false); ShowAlternativeMonsterModel = p_reader["gameplay"]["showAlternativeMonsterModel"].GetBool(false); EnemyOutlineOpacity = p_reader["gameplay"]["enemyOutlineOpacity"].GetFloat(1f); ObjectOutlineOpacity = p_reader["gameplay"]["objectOutlineOpacity"].GetFloat(1f); ShowViewport = p_reader["gameplay"]["showViewport"].GetBool(true); LockActionBar = p_reader["gameplay"]["lockActionBar"].GetBool(false); MonsterMovementSpeed = p_reader["gameplay"]["monsterMovementSpeed"].GetFloat(1f); FadeLogs = p_reader["gameplay"]["fadeLogs"].GetBool(false); FadeLogsDelay = p_reader["gameplay"]["fadeLogsDelay"].GetFloat(5f); IsLeftActionBarShowingArrows = p_reader["gameplay"]["isLeftActionBarWithArrows"].GetBool(false); TriggerBarks = p_reader["gameplay"]["triggerBarks"].GetBool(true); ShowGameMessages = p_reader["gameplay"]["showMessages"].GetBool(true); LogOpacity = p_reader["gameplay"]["logOpacity"].GetFloat(1f); TooltipOpacity = p_reader["gameplay"]["tooltipOpacity"].GetFloat(1f); ShowFloatingDamageMonsters = p_reader["gameplay"]["showFloatingDamageMonsters"].GetBool(true); ShowFloatingDamageCharacters = p_reader["gameplay"]["showFloatingDamageChars"].GetBool(true); QuestLogSize = p_reader["gameplay"]["questLogSize"].GetFloat(220f); ActionLogSize = p_reader["gameplay"]["actionLogSize"].GetInt(8); LockCharacterOrder = p_reader["gameplay"]["lockCharacterOrder"].GetBool(false); TooltipDelay = p_reader["gameplay"]["tooltipDelay"].GetFloat(0.2f); VideoDecoder = p_reader["general"]["videodecoder"].GetEnum <EVideoDecoder>(EVideoDecoder.System); RetroMode = p_reader["general"]["retroMode"].GetBool(false); RetroScreenDivisor = p_reader["general"]["retroScreenDivisor"].GetInt(4); ViewAlignedMinimap = p_reader["gameplay"]["viewAlignedMinimap"].GetBool(false); MinimapGirdOpacity = p_reader["gameplay"]["minimapGirdOpacity"].GetFloat(1f); ShowMinimap = p_reader["gameplay"]["showMinimap"].GetBool(true); }
public override void PrewarmAfterCreate() { base.PrewarmAfterCreate(); if (m_spawnTarget == null) { LegacyLogger.Log("ERROR: Will try to spawn a monster into an invalid target! SpawnMonsterInteraction: PrewarmAfterCreate skipped!"); } else if (m_activateCount != 0) { LegacyLogic.Instance.EventManager.InvokeEvent(this, EEventType.ANNOUNCE_LATE_MONSTER_SPAWN, new AnnounceLateMonsterSpawnArgs(MonsterID, GetSpawnerID(), m_spawnTarget.Position)); } }
public static T GetStaticData(String p_id) { T t; if (!s_staticDataMap.TryGetValue(p_id, out t)) { t = LoadData(p_id); if (t == null) { LegacyLogger.Log("XmlStaticData not found! ID=" + p_id); } } return(t); }
private static EDifficulty GetDifficulty(BinaryReader p_reader) { p_reader.ReadInt32(); String text = p_reader.ReadString(); if (text != "MainData") { LegacyLogger.Log("Not MainData: " + text); return(EDifficulty.NORMAL); } SaveGameData saveGameData = new SaveGameData(text); saveGameData.Read(p_reader); return(saveGameData.Get <EDifficulty>("Difficulty", EDifficulty.NORMAL)); }
public override void ExecutionBreak() { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendLine("InteractionTurnActor execution aborded!"); stringBuilder.AppendLine("Left state: " + m_stateMachine.CurrentState); stringBuilder.AppendLine("Number of open interactive objects: " + m_interactiveObjects.Count); foreach (InteractiveObject interactiveObject in m_interactiveObjects) { interactiveObject.ExecutionBreak(stringBuilder); } LegacyLogger.Log(stringBuilder.ToString(), false); m_stateMachine.ChangeState(EState.FINISHED); m_interactiveObjects.Clear(); }
public static T GetStaticData <T>(EDataType p_type, Int32 p_staticId) where T : BaseStaticData { Dictionary <Int32, BaseStaticData> dictionary = m_staticDataMap[(Int32)p_type]; BaseStaticData baseStaticData = null; if (dictionary != null && !dictionary.TryGetValue(p_staticId, out baseStaticData)) { LegacyLogger.Log(String.Concat(new Object[] { "StaticData not found! Type=", p_type, "; ID=", p_staticId })); } return(baseStaticData as T); }
public override void ExecutionBreak() { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendLine("MonsterTurnActor execution aborded!"); try { stringBuilder.AppendLine("Left state: " + m_stateMachine.CurrentState.Id); stringBuilder.AppendLine("Monster count: " + m_monsters.Count); stringBuilder.AppendLine("-----monsters-----"); foreach (Monster monster in m_monsters) { stringBuilder.AppendLine("Monster: " + monster.Name); stringBuilder.AppendLine("Monster: State " + monster.State); stringBuilder.AppendLine("Monster: Has aggro " + monster.IsAggro); stringBuilder.AppendLine("Monster: Is movement skipped " + monster.SkipMovement.IsTriggered); stringBuilder.AppendLine("Monster: Is movement started " + monster.StartMovement.IsTriggered); stringBuilder.AppendLine("Monster: Is attacking done " + monster.AttackingDone.IsTriggered); stringBuilder.AppendLine("Monster: Is direction " + monster.Direction); stringBuilder.AppendLine(String.Concat(new Object[] { "Position: x=", monster.Position.X, " y=", monster.Position.Y })); stringBuilder.AppendLine("Monster: Spawner id " + monster.SpawnerID); stringBuilder.AppendLine("Movement done: " + monster.MovementDone.IsTriggered); stringBuilder.AppendLine("Monster: Health " + monster.CurrentHealth); stringBuilder.AppendLine("Monster: Distance to party " + monster.DistanceToParty); stringBuilder.AppendLine("Monster: General block attempts " + monster.GeneralBlockAttempts); stringBuilder.AppendLine("Monster: Move prio " + monster.MovePrio); stringBuilder.AppendLine("Monster: Can cast spell " + monster.CombatHandler.CanCastSpell); stringBuilder.AppendLine("Monster: Can move " + monster.CombatHandler.CanMove); stringBuilder.AppendLine("-----------"); } } catch (Exception ex) { stringBuilder.AppendLine("Error during dump generation: " + ex.StackTrace); } LegacyLogger.Log(stringBuilder.ToString(), false); LegacyLogic.Instance.EventManager.InvokeEvent(this, EEventType.MONSTER_ROUND_FINISHED, EventArgs.Empty); m_stateMachine.ChangeState(EState.FINISHED); }
public Boolean AllowedPeriodicity(Npc p_npc, ETargetCondition p_targetEffect) { if (p_npc == null) { return(false); } NpcEffect npcEffect = p_npc.GetNpcEffect(p_targetEffect); if (npcEffect.TargetEffect == ETargetCondition.NONE) { LegacyLogger.Log("This target cant have periodicity"); return(false); } switch (npcEffect.EffectPeriodicity) { case EEffectPeriodicity.PERMANENT: return(true); case EEffectPeriodicity.ON_DEMAND: return(true); case EEffectPeriodicity.ONCE_A_REST: return(p_npc.GetRestCount(p_targetEffect) < LegacyLogic.Instance.WorldManager.Party.RestCount); case EEffectPeriodicity.ONCE_A_DAY: { Int32 dayCount = p_npc.GetDayCount(p_targetEffect); Int32 num = LegacyLogic.Instance.GameTime.Time.Days; if (LegacyLogic.Instance.GameTime.Time.Hours < ConfigManager.Instance.Game.DayStartHours) { num--; } return(dayCount < num); } case EEffectPeriodicity.ONCE_A_TURN: return(p_npc.GetTurnCount(p_targetEffect) < (Int32)npcEffect.EffectValue); default: return(false); } }
private static void ParseLocaFile(String filePath, Dictionary <String, String> p_target) { try { LocaData[] array; Helper.Xml.OpenRead <LocaData[]>(filePath, LocaData.XmlRoot, out array); if (array != null) { AddLocaData(filePath, array, p_target); } else { LegacyLogger.Log("root Element is null"); } } catch (Exception ex) { LegacyLogger.Log("Error in the " + filePath + ": " + ex.ToString()); } }
protected override void LoadStaticData() { m_staticData = StaticDataHandler.GetStaticData <NpcStaticData>(EDataType.NPC, StaticID); if (m_staticData == null) { LegacyLogger.Log("npc staticdata id " + StaticID + " not found"); } try { NpcConversationStaticData staticData = XmlStaticDataHandler <NpcConversationStaticData> .GetStaticData(StaticData.ConversationKey); if (staticData == null) { LegacyLogger.Log(String.Concat(new Object[] { "npc staticdata id: ", StaticID, ", Conversation staticdata ", StaticData.ConversationKey, " not found" })); } m_conversation = new NpcConversation(staticData); m_tradingInventory = new TradingInventoryController(staticData, this); m_tradingSpells = new TradingSpellController(staticData, this); } catch (Exception ex) { LegacyLogger.LogError(String.Concat(new Object[] { "Error load NPC data\nStaticId: ", StaticID, ", ConversationKey: ", StaticData.ConversationKey, "\n", ex })); } m_identifyController = new IdentifyInventoryController(this); m_repairController = new RepairInventoryController(); }
protected override void DoExecute() { if (m_teleporter == null) { throw new InvalidOperationException("Tried to teleport to invalif object"); } Party party = LegacyLogic.Instance.WorldManager.Party; if (!m_ignoreTargetDirection && m_teleporter.Location != EDirection.CENTER) { party.Direction = m_teleporter.Location; } Position position = party.Position; if (Grid.AddMovingEntity(m_teleporter.Position, party)) { GridSlot slot = Grid.GetSlot(m_teleporter.Position); if (!slot.VisitedByParty) { slot.VisitedByParty = true; LegacyLogic.Instance.EventManager.InvokeEvent(this, EEventType.UNCOVERED_TILES, EventArgs.Empty); } Grid.GetSlot(position).RemoveEntity(party); party.SelectedInteractiveObject = null; BaseObjectEventArgs p_eventArgs = new BaseObjectEventArgs(party, party.Position); LegacyLogic.Instance.EventManager.InvokeEvent(party, EEventType.TELEPORT_ENTITY, p_eventArgs); LegacyLogic.Instance.EventManager.InvokeEvent(this, EEventType.PARTY_TELEPORTER_USED, EventArgs.Empty); } else { LegacyLogger.Log(String.Concat(new Object[] { "Could not move party ", m_teleporter.SpawnerID, " ", m_teleporter.Position.ToString() })); } FinishExecution(); }
protected override void DoExecute() { Monster monster = LegacyLogic.Instance.WorldManager.FindObjectBySpawnerId <Monster>(m_targetSpawnID); if (monster == null) { LegacyLogger.Log("Tried to move something that is not a monster " + m_targetSpawnID); } else { Position position = monster.Position; Position position2 = new Position(m_posX, m_posY); GridSlot slot = Grid.GetSlot(monster.Position); if (Grid.GetSlot(position2).AddEntity(monster)) { slot.RemoveEntity(monster); } MoveEntityEventArgs p_eventArgs = new MoveEntityEventArgs(position, position2); LegacyLogic.Instance.EventManager.InvokeEvent(monster, EEventType.MOVE_ENTITY, p_eventArgs); FinishExecution(); } }
static void Main(string[] args) { bool bRes = true; string sPrompt = "> ", sCmd = "", sLogPath = ""; AudioEngine_srv amSrv = null; ILegacyLogger logger = null; string sDisableKeyboard = "", sVer = ""; AssemblyName asmName = null; //Name the main thread Thread.CurrentThread.Name = "AudioMgrMainT"; // Set up the logger(s) sLogPath = ConfigurationManager.AppSettings[cs_LogFilePath]; if (!(sLogPath.EndsWith("/") || sLogPath.EndsWith("\\"))) { sLogPath = sLogPath + "/"; } logger = new LegacyLogger(); logger.Init("", "", Thread.CurrentThread.Name, "", "", sLogPath); bRes = logger.Open(); if (!bRes) { Console.Error.WriteLine("AudioMgr failed to open the logger!"); } else { asmName = Assembly.GetAssembly(typeof(AudioMgr.AudioEngine)).GetName(); sVer = asmName.Version.ToString(); logger.Log(Level.Info, "AudioMgr v" + sVer); bRes = RemotingConfig(logger); amSrv = new AudioEngine_srv(logger); bRes = RegisterEventHandlers(amSrv); if (!bRes) { logger.Log(Level.Exception, " AudioMgr failed registering event handlers!"); } else { bRes = amSrv.LoadASR(logger); if (!bRes) { logger.Log(Level.Exception, " AudioMgr failed to load ASR(s)!"); } else { bRes = amSrv.CreateWorkerThreads(sLogPath); if (!bRes) { logger.Log(Level.Exception, " AudioMgr failed to create worker threads!"); } else { //Console.WriteLine("AudioMgr startup successful."); logger.Log(Level.Info, "AudioMgr startup successful."); sDisableKeyboard = ConfigurationManager.AppSettings[cs_DisableKeyboard]; sDisableKeyboard = (sDisableKeyboard == null) ? "" : sDisableKeyboard; if (sDisableKeyboard == "false") { Console.Write(sPrompt); sCmd = Console.ReadLine(); while (bRes) { bRes = amSrv.ProcessCmdString(sCmd); if (bRes) { Console.Write(sPrompt); sCmd = Console.ReadLine(); } } } // Join worker threads before exiting amSrv.JoinWorkerThreads(); UnregisterEventHandlers(amSrv); } } } logger.Log(Level.Info, "AudioMgr shutdown."); logger.Close(); } }
static void Main(string[] args) { bool bRes; DialogMgr_srv.eDMResult eRes = DialogMgr_srv.eDMResult.eUnknown; DialogMgr_srv dmSrv = null; string sPath; string sDisableKeyboard = "", sVer = ""; AssemblyName asmName = null; ILegacyLogger logger = null; // Name the main thread Thread.CurrentThread.Name = "DialogMgrMainT"; // Set up the logger(s) sPath = ConfigurationManager.AppSettings["LogFilePath"]; logger = new LegacyLogger(); logger.Init("", "", Thread.CurrentThread.Name, "", "", sPath); bRes = logger.Open(); if (!bRes) { Console.Error.WriteLine("DialogMgr failed to open the logger!"); } else { asmName = Assembly.GetAssembly(typeof(DialogMgr_Console.DialogMgr)).GetName(); sVer = asmName.Version.ToString(); logger.Log(Level.Info, "DialogMgr v" + sVer); bRes = LoadCustomAssemblies(logger); bRes = RemotingConfig(logger); dmSrv = new DialogMgr_srv(logger); bRes = RegisterEventHandlers(dmSrv); if (bRes) { bRes = dmSrv.CreateWorkerThreads(""); //Console.WriteLine("DialogMgr_Console startup successful."); logger.Log(Level.Info, "DialogMgr_Console startup successful."); sDisableKeyboard = ConfigurationManager.AppSettings["DisableKeyboard"]; sDisableKeyboard = (sDisableKeyboard == null) ? "" : sDisableKeyboard; if (sDisableKeyboard == "false") { // Start processing messages eRes = dmSrv.ProcessKbMsgLoop(); } // Join worker threads before exiting dmSrv.JoinWorkerThreads(); // Clean up UnregisterEventHandlers(dmSrv); } else { //Console.WriteLine("DialogMgr_Console startup unsuccessful!!!"); logger.Log(Level.Exception, "DialogMgr_Console startup unsuccessful!!!"); } logger.Log(Level.Info, "DialogMgr_Console shutdown."); logger.Close(); } }
static void Main(string[] args) { ILegacyLogger logger = null; bool bRes = true; string sAsr = "", sGramPath = "", sUttPath = ""; int iRes, iNumIt = 0, iPause = 0, iNumArgsExpected = 5, iAsrIdx = 0, iGramIdx = 1, iUttIdx = 2, iItIdx = 3, iPauseIdx = 4; eAsrType eAsr = eAsrType.unknown; try { for (int ii = 0; ii < args.Length; ii++) { Console.Error.WriteLine("Arg {0}: '{1}'", ii, args[ii].ToString()); } Thread.CurrentThread.Name = "asrtest"; logger = new LegacyLogger(); logger.Init("", "", Thread.CurrentThread.Name, "", "", "/opt/speechbridge/logs"); bRes = logger.Open(); if (!bRes || (args.Length != iNumArgsExpected)) { if (!bRes) { Console.Error.WriteLine("Unable to open the console logger!"); } else { logger.Log(Level.Warning, "Usage: asrtest AsrType GrammarFile UttWav NumIterations PauseInSecs"); logger.Log(Level.Warning, " AsrType can be: lumenvox, lumenvox2, OR vestec"); } return; } else { sAsr = args[iAsrIdx]; sGramPath = args[iGramIdx]; sUttPath = args[iUttIdx]; iNumIt = int.Parse(args[iItIdx]); iPause = int.Parse(args[iPauseIdx]); if ((sAsr == eAsrType.julius.ToString()) || (sAsr == eAsrType.loquendo.ToString()) || (sAsr == eAsrType.pocketsphinx.ToString())) { logger.Log(Level.Exception, "That AsrType is not yet supported."); } else if (sAsr == eAsrType.lumenvox.ToString()) { eAsr = eAsrType.lumenvox; } else if (sAsr == eAsrType.lumenvox2.ToString()) { eAsr = eAsrType.lumenvox2; } else if (sAsr == eAsrType.vestec.ToString()) { eAsr = eAsrType.vestec; } if (eAsr != eAsrType.unknown) { iRes = RunTestBuffer(logger, eAsr, sGramPath, sUttPath, iNumIt, iPause); logger.Log(Level.Info, "Successfully completed " + iRes.ToString() + " iterations."); } } logger.Close(); } catch (Exception exc) { logger.Log(Level.Exception, "Main caught exception: " + exc.ToString()); } return; }
public virtual void ExecutionBreak() { LegacyLogger.Log(GetType().Name + " execution aborded!", false); m_stateMachine.ChangeState(EState.FINISHED); }
protected override List <AttackResult> MeleeAttackMonster(Character p_attacker, Monster p_target) { LegacyLogger.Log(p_attacker.ManaPoints * m_staticData.AdditionalValue * 100f + "%"); return(p_attacker.FightHandler.ExecuteMeleeAttack(false, p_attacker.ManaPoints * m_staticData.AdditionalValue, false, false, true)); }