/// <summary> /// Destructs this instance. /// </summary> public override void Destruct() { base.Destruct(); this._clientHome = null; this._clientAvatar = null; this._npcAvatar = null; }
public override void Decode() { base.Decode(); this.m_secondsSinceLastSave = this.m_stream.ReadInt(); this.m_secondsSinceLastMaintenance = this.m_stream.ReadInt(); this.m_currentTimestamp = this.m_stream.ReadInt(); this.m_logicClientHome = new LogicClientHome(); this.m_logicClientHome.Decode(this.m_stream); this.m_logicClientAvatar = new LogicClientAvatar(); this.m_logicClientAvatar.Decode(this.m_stream); this.m_mapId = this.m_stream.ReadInt(); this.m_layoutId = this.m_stream.ReadInt(); /* sub_36BCBC - START */ this.m_stream.ReadInt(); this.m_stream.ReadInt(); this.m_stream.ReadInt(); this.m_stream.ReadInt(); this.m_stream.ReadInt(); this.m_stream.ReadInt(); /* sub_36BCBC - END */ this.m_reengagementSeconds = this.m_stream.ReadInt(); }
public override void Destruct() { base.Destruct(); this.m_logicClientHome = null; this.m_logicClientAvatar = null; }
public void LoadNpcDuelState(LogicClientHome home, LogicAvatar homeOwnerAvatar, LogicAvatar visitorAvatar, int currentTimestamp, int secondsSinceLastSave) { if (this.m_state != 0) { Debugger.Error("loadNpcDuelState called from invalid state"); } else { this.m_state = 2; this.m_startTimestamp = currentTimestamp; this.m_configuration.Load((LogicJSONObject)LogicJSONParser.Parse(home.GetGlobalJSON())); this.m_calendar.Load(home.GetCalendarJSON(), currentTimestamp); if (this.m_battleTimer != null) { this.m_battleTimer.Destruct(); this.m_battleTimer = null; } this.m_level.SetMatchType(9, null); this.m_level.SetVillageType(1); this.m_level.SetHome(home, false); this.m_level.SetHomeOwnerAvatar(homeOwnerAvatar); this.m_level.SetVisitorAvatar(visitorAvatar); this.m_level.FastForwardTime(secondsSinceLastSave); this.m_level.LoadingFinished(); this.m_replay = new LogicReplay(this.m_level); } }
public LogicClientHome RemoveLogicClientHome() { LogicClientHome tmp = this.m_logicClientHome; this.m_logicClientHome = null; return(tmp); }
/// <summary> /// Decodes this instance. /// </summary> public override void Decode() { base.Decode(); this._secondsSinceLastSave = this.Stream.ReadInt(); this._secondsSinceLastMaintenance = this.Stream.ReadInt(); this._currentTimestamp = this.Stream.ReadInt(); this._logicClientHome = new LogicClientHome(); this._logicClientHome.Decode(this.Stream); this._logicClientAvatar = new LogicClientAvatar(); this._logicClientAvatar.Decode(this.Stream); this.Stream.ReadInt(); this.Stream.ReadInt(); /* sub_36BCBC - START */ this.Stream.ReadInt(); this.Stream.ReadInt(); this.Stream.ReadInt(); this.Stream.ReadInt(); this.Stream.ReadInt(); this.Stream.ReadInt(); /* sub_36BCBC - END */ this.Stream.ReadInt(); }
public static LogicClientHome CloneHome(LogicClientHome home) { LogicClientHome copy = new LogicClientHome(); ByteStream stream = new ByteStream(512); home.Encode(stream); copy.Decode(stream); return(copy); }
public override void Destruct() { base.Destruct(); this.m_logicClientHome = null; this.m_logicClientAvatar = null; this.m_attackerLogicClientAvatar = null; this.m_AvatarStreamEntryId = null; }
public static GameMode LoadMatchedAttackState(HomeSession session, GameMatchedAttackState state) { LogicClientHome home = state.Home; LogicClientAvatar homeOwnerAvatar = state.HomeOwnerAvatar; LogicClientAvatar attackerLogicClientAvatar = state.PlayerAvatar; int currentTimestamp = TimeUtil.GetTimestamp(); int secondsSinceLastSave = state.SaveTime != -1 ? currentTimestamp - state.SaveTime : 0; int secondsSinceLastMaintenance = state.MaintenanceTime != -1 ? currentTimestamp - state.MaintenanceTime : 0; EnemyHomeDataMessage enemyHomeDataMessage = new EnemyHomeDataMessage(); enemyHomeDataMessage.SetCurrentTimestamp(currentTimestamp); enemyHomeDataMessage.SetSecondsSinceLastSave(secondsSinceLastSave); enemyHomeDataMessage.SetSecondsSinceLastMaintenance(secondsSinceLastMaintenance); enemyHomeDataMessage.SetLogicClientHome(home); enemyHomeDataMessage.SetLogicClientAvatar(homeOwnerAvatar); enemyHomeDataMessage.SetAttackerLogicClientAvatar(attackerLogicClientAvatar); enemyHomeDataMessage.SetAttackSource(3); enemyHomeDataMessage.Encode(); CompressibleStringHelper.Uncompress(home.GetCompressibleHomeJSON()); CompressibleStringHelper.Uncompress(home.GetCompressibleCalendarJSON()); CompressibleStringHelper.Uncompress(home.GetCompressibleGlobalJSON()); try { GameMode gameMode = new GameMode(session); gameMode.m_avatarChangeListener = new AvatarChangeListener(gameMode, attackerLogicClientAvatar); attackerLogicClientAvatar.SetChangeListener(gameMode.m_avatarChangeListener); gameMode.m_logicGameMode.LoadMatchedAttackState(home, homeOwnerAvatar, attackerLogicClientAvatar, currentTimestamp, secondsSinceLastSave, secondsSinceLastMaintenance); gameMode.m_gameDefenderLocked = state.GameDefenderLocked; gameMode.m_liveReplayId = state.LiveReplayId; ZLibHelper.CompressInZLibFormat(LogicStringUtil.GetBytes(LogicJSONParser.CreateJSONString(gameMode.m_logicGameMode.GetReplay().GetJson())), out byte[] streamJSON); ServerMessageManager.SendMessage(new InitializeLiveReplayMessage { AccountId = gameMode.m_liveReplayId, StreamData = streamJSON }, 9); session.SendPiranhaMessage(enemyHomeDataMessage, 1); return(gameMode); } catch (Exception exception) { Logging.Error("GameMode.loadMatchedAttackState: exception while the loading of attack state: " + exception); } return(null); }
public override void Decode() { base.Decode(); this.m_logicClientAvatar = new LogicClientAvatar(); this.m_logicClientAvatar.Decode(this.m_stream); this.m_logicClientHome = new LogicClientHome(); this.m_logicClientHome.Decode(this.m_stream); this.m_enemyId = this.m_stream.ReadLong(); this.m_timestamp = this.m_stream.ReadInt(); }
public static GameMode LoadHomeState(HomeSession session, GameHomeState state) { LogicClientHome home = state.Home; LogicClientAvatar homeOwnerAvatar = state.PlayerAvatar; int currentTimestamp = TimeUtil.GetTimestamp(); int secondsSinceLastSave = state.SaveTime != -1 ? currentTimestamp - state.SaveTime : 0; int secondsSinceLastMaintenance = state.MaintenanceTime != -1 ? currentTimestamp - state.MaintenanceTime : 0; int reengagementSeconds = secondsSinceLastSave >= 86400 ? secondsSinceLastSave - 86400 : 0; OwnHomeDataMessage ownHomeDataMessage = new OwnHomeDataMessage(); ownHomeDataMessage.SetCurrentTimestamp(currentTimestamp); ownHomeDataMessage.SetReengagementSeconds(reengagementSeconds); ownHomeDataMessage.SetSecondsSinceLastSave(secondsSinceLastSave); ownHomeDataMessage.SetSecondsSinceLastMaintenance(secondsSinceLastMaintenance); ownHomeDataMessage.SetLogicClientHome(home); ownHomeDataMessage.SetLogicClientAvatar(homeOwnerAvatar); ownHomeDataMessage.SetLayoutId(state.LayoutId); ownHomeDataMessage.SetMapId(state.MapId); ownHomeDataMessage.Encode(); CompressibleStringHelper.Uncompress(home.GetCompressibleHomeJSON()); CompressibleStringHelper.Uncompress(home.GetCompressibleCalendarJSON()); CompressibleStringHelper.Uncompress(home.GetCompressibleGlobalJSON()); try { GameMode gameMode = new GameMode(session); gameMode.m_avatarChangeListener = new AvatarChangeListener(gameMode, homeOwnerAvatar); home.SetChangeListener(new HomeChangeListener(gameMode)); homeOwnerAvatar.SetChangeListener(gameMode.m_avatarChangeListener); gameMode.m_logicGameMode.LoadHomeState(home, homeOwnerAvatar, secondsSinceLastSave, -1, currentTimestamp, secondsSinceLastMaintenance, reengagementSeconds); session.SendPiranhaMessage(ownHomeDataMessage, 1); for (int i = 0; i < state.ServerCommands.Size(); i++) { gameMode.AddServerCommand(state.ServerCommands[i]); } return(gameMode); } catch (Exception exception) { Logging.Error("GameMode.loadHomeState: exception while the loading of attack state: " + exception); } return(null); }
/// <summary> /// Decodes this instance. /// </summary> public override void Decode() { base.Decode(); this._secondsSinceLastSave = this.Stream.ReadInt(); this._currentTimestamp = this.Stream.ReadInt(); this._clientHome = new LogicClientHome(); this._clientHome.Decode(this.Stream); this._clientAvatar = new LogicClientAvatar(); this._clientAvatar.Decode(this.Stream); this._npcAvatar = new LogicNpcAvatar(); this._npcAvatar.Decode(this.Stream); this._npcDuel = this.Stream.ReadBoolean(); }
public static LogicClientAvatar LoadHomeOwnerAvatarFromHome(LogicClientHome home) { string json = home.GetCompressibleHomeJSON().Get(); if (json == null) { ZLibHelper.DecompressInMySQLFormat(home.GetCompressibleHomeJSON().GetCompressed(), out byte[] output); json = LogicStringUtil.CreateString(output, 0, output.Length); } LogicClientAvatar logicClientAvatar = new LogicClientAvatar(); logicClientAvatar.LoadForReplay(LogicJSONParser.ParseObject(json), true); return(logicClientAvatar); }
public void LoadDirectAttackState(LogicClientHome home, LogicAvatar homeOwnerAvatar, LogicAvatar visitorAvatar, int secondsSinceLastSave, bool war, bool village2, int currentTimestamp) { if (this.m_state != 0) { Debugger.Error("loadAttackState called from invalid state"); } this.m_state = 2; this.m_startTimestamp = currentTimestamp; this.m_configuration.Load((LogicJSONObject)LogicJSONParser.Parse(home.GetGlobalJSON())); this.m_calendar.Load(home.GetCalendarJSON(), currentTimestamp); if (this.m_battleTimer != null) { this.m_battleTimer.Destruct(); this.m_battleTimer = null; } this.m_battleTimer = new LogicTimer(); this.m_battleTimer.StartTimer( LogicDataTables.GetGlobals().GetAttackLengthSecs() + (village2 ? LogicDataTables.GetGlobals().GetAttackVillage2PreparationLengthSecs() : LogicDataTables.GetGlobals().GetAttackPreparationLengthSecs()), this.m_level.GetLogicTime(), false, -1); if (!homeOwnerAvatar.IsClientAvatar()) { Debugger.Error("loadDirectAttackState called and home owner is not client avatar"); } this.m_level.SetMatchType(village2 ? 8 : war ? 7 : 3, null); if (village2) { this.m_level.SetVillageType(1); } this.m_level.SetHome(home, false); this.m_level.SetHomeOwnerAvatar(homeOwnerAvatar); homeOwnerAvatar.SetLevel(this.m_level); this.m_level.SetVisitorAvatar(visitorAvatar); this.m_level.FastForwardTime(secondsSinceLastSave); this.m_level.LoadingFinished(); this.m_replay = new LogicReplay(this.m_level); }
public static void Init() { GameResourceManager.CompressedStartingHomeJSON = GameResourceManager.Compress(ServerHttpClient.DownloadBytes("data/level/starting_home.json")); GameResourceManager.NpcHomes = new LogicClientHome[LogicDataTables.GetTable(LogicDataType.NPC).GetItemCount()]; LogicDataTable table = LogicDataTables.GetTable(LogicDataType.NPC); for (int i = 0; i < table.GetItemCount(); i++) { LogicNpcData data = (LogicNpcData)table.GetItemAt(i); LogicClientHome logicClientHome = new LogicClientHome(); logicClientHome.GetCompressibleHomeJSON().Set(GameResourceManager.Compress(ServerHttpClient.DownloadBytes("data/" + data.GetLevelFile()))); GameResourceManager.NpcHomes[i] = logicClientHome; } }
public static GameMode LoadVisitAttackState(HomeSession session, GameVisitState state) { LogicClientHome home = state.Home; LogicClientAvatar homeOwnerAvatar = state.HomeOwnerAvatar; LogicClientAvatar visitorAvatar = state.PlayerAvatar; int currentTimestamp = TimeUtil.GetTimestamp(); int secondsSinceLastSave = state.SaveTime != -1 ? currentTimestamp - state.SaveTime : 0; int visitType = state.VisitType; VisitedHomeDataMessage visitedHomeDataMessage = new VisitedHomeDataMessage(); visitedHomeDataMessage.SetCurrentTimestamp(currentTimestamp); visitedHomeDataMessage.SetSecondsSinceLastSave(secondsSinceLastSave); visitedHomeDataMessage.SetLogicClientHome(home); visitedHomeDataMessage.SetOwnerLogicClientAvatar(homeOwnerAvatar); visitedHomeDataMessage.SetVisitorLogicClientAvatar(visitorAvatar); visitedHomeDataMessage.Encode(); CompressibleStringHelper.Uncompress(home.GetCompressibleHomeJSON()); CompressibleStringHelper.Uncompress(home.GetCompressibleCalendarJSON()); CompressibleStringHelper.Uncompress(home.GetCompressibleGlobalJSON()); try { GameMode gameMode = new GameMode(session); gameMode.m_avatarChangeListener = new AvatarChangeListener(gameMode, visitorAvatar); visitorAvatar.SetChangeListener(gameMode.m_avatarChangeListener); gameMode.m_logicGameMode.LoadVisitState(home, homeOwnerAvatar, visitorAvatar, secondsSinceLastSave, currentTimestamp); session.SendPiranhaMessage(visitedHomeDataMessage, 1); return(gameMode); } catch (Exception exception) { Logging.Error("GameMode.loadVisitAttackState: exception while the loading of visit state: " + exception); } return(null); }
public override void Decode() { base.Decode(); this.m_currentTimestamp = this.m_stream.ReadInt(); this.m_avatarId = this.m_stream.ReadLong(); this.m_accountId = this.m_stream.ReadLong(); this.m_logicClientHome = new LogicClientHome(); this.m_logicClientHome.Decode(this.m_stream); this.m_mapId = this.m_stream.ReadInt(); if (this.m_stream.ReadBoolean()) { this.m_logicClientAvatar = new LogicClientAvatar(); this.m_logicClientAvatar.Decode(this.m_stream); } this.m_streamId = this.m_stream.ReadLong(); }
public override void Decode() { base.Decode(); this.m_secondsSinceLastSave = this.m_stream.ReadInt(); this.m_currentTimestamp = this.m_stream.ReadInt(); this.m_logicClientHome = new LogicClientHome(); this.m_logicClientHome.Decode(this.m_stream); this.m_ownerLogicClientAvatar = new LogicClientAvatar(); this.m_ownerLogicClientAvatar.Decode(this.m_stream); this.m_stream.ReadInt(); if (this.m_stream.ReadBoolean()) { this.m_visitorLogicClientAvatar = new LogicClientAvatar(); this.m_visitorLogicClientAvatar.Decode(this.m_stream); } }
/// <summary> /// Loads the npc attack state. /// </summary> public void LoadNpcAttackState(LogicClientHome home, LogicAvatar homeOwnerAvatar, LogicAvatar visitorAvatar, int currentTimestamp, int secondsSinceLastSave) { if (this._state == 1) { Debugger.Error("loadAttackState called from invalid state"); } else { this._state = 2; this._currentTimestamp = currentTimestamp; this._calendar.Load(home.GetCalendarJSON(), currentTimestamp); if (this._battleTimer != null) { this._battleTimer.Destruct(); this._battleTimer = null; } if (homeOwnerAvatar.IsNpcAvatar()) { LogicNpcAvatar npcAvatar = (LogicNpcAvatar)homeOwnerAvatar; LogicNpcData npcData = npcAvatar.GetNpcData(); homeOwnerAvatar.SetResourceCount(LogicDataTables.GetGoldData(), LogicMath.Max(npcData.Gold - visitorAvatar.GetLootedNpcGold(npcData), 0)); homeOwnerAvatar.SetResourceCount(LogicDataTables.GetElixirData(), LogicMath.Max(npcData.Elixir - visitorAvatar.GetLootedNpcElixir(npcData), 0)); this._level.SetMatchType(2, 0); this._level.SetHome(home, false); this._level.SetHomeOwnerAvatar(homeOwnerAvatar); this._level.SetVisitorAvatar(visitorAvatar); this._level.FastForwardTime(secondsSinceLastSave); this._level.LoadingFinished(); } else { Debugger.Error("loadNpcAttackState called and home owner is not npc avatar"); } } }
public static GameMode LoadFakeAttackState(BattleSession session, GameFakeAttackState state) { LogicClientHome home = state.Home; LogicClientAvatar homeOwnerAvatar = state.HomeOwnerAvatar; LogicClientAvatar playerAvatar = state.PlayerAvatar; int currentTimestamp = TimeUtil.GetTimestamp(); int secondsSinceLastSave = state.SaveTime != -1 ? currentTimestamp - state.SaveTime : 0; int secondsSinceLastMaintenance = state.MaintenanceTime != -1 ? currentTimestamp - state.MaintenanceTime : 0; EnemyHomeDataMessage enemyHomeDataMessage = new EnemyHomeDataMessage(); enemyHomeDataMessage.SetCurrentTimestamp(currentTimestamp); enemyHomeDataMessage.SetSecondsSinceLastSave(secondsSinceLastSave); enemyHomeDataMessage.SetSecondsSinceLastMaintenance(secondsSinceLastMaintenance); enemyHomeDataMessage.SetLogicClientHome(home); enemyHomeDataMessage.SetLogicClientAvatar(homeOwnerAvatar); enemyHomeDataMessage.SetAttackerLogicClientAvatar(playerAvatar); enemyHomeDataMessage.SetAttackSource(1); enemyHomeDataMessage.Encode(); CompressibleStringHelper.Uncompress(home.GetCompressibleHomeJSON()); CompressibleStringHelper.Uncompress(home.GetCompressibleCalendarJSON()); CompressibleStringHelper.Uncompress(home.GetCompressibleGlobalJSON()); try { GameMode gameMode = new GameMode(session); gameMode.m_logicGameMode.LoadDirectAttackState(home, homeOwnerAvatar, playerAvatar, secondsSinceLastSave, false, false, currentTimestamp); session.SendPiranhaMessage(enemyHomeDataMessage, 1); return(gameMode); } catch (Exception exception) { Logging.Error("GameMode.loadFakeAttackState: exception while the loading of attack state: " + exception); } return(null); }
public void LoadVisitState(LogicClientHome home, LogicAvatar homeOwnerAvatar, LogicAvatar visitorAvatar, int currentTimestamp, int secondsSinceLastSave) { if (this.m_state != 0) { Debugger.Error("loadVisitState called from invalid state"); } else { this.m_state = 4; this.m_startTimestamp = currentTimestamp; this.m_configuration.Load((LogicJSONObject)LogicJSONParser.Parse(home.GetGlobalJSON())); this.m_calendar.Load(home.GetCalendarJSON(), currentTimestamp); this.m_level.SetNpcVillage(homeOwnerAvatar.IsNpcAvatar()); this.m_level.SetHome(home, false); this.m_level.SetHomeOwnerAvatar(homeOwnerAvatar); this.m_level.SetVisitorAvatar(visitorAvatar); this.m_level.FastForwardTime(secondsSinceLastSave); homeOwnerAvatar.SetLevel(this.m_level); this.m_level.LoadingFinished(); } }
public override void Decode() { base.Decode(); this.m_secondsSinceLastSave = this.m_stream.ReadInt(); this.m_secondsSinceLastMaintenance = this.m_stream.ReadInt(); this.m_currentTimestamp = this.m_stream.ReadInt(); this.m_logicClientHome = new LogicClientHome(); this.m_logicClientHome.Decode(this.m_stream); this.m_logicClientAvatar = new LogicClientAvatar(); this.m_logicClientAvatar.Decode(this.m_stream); this.m_attackerLogicClientAvatar = new LogicClientAvatar(); this.m_attackerLogicClientAvatar.Decode(this.m_stream); this.m_attackSource = this.m_stream.ReadInt(); this.m_mapId = this.m_stream.ReadInt(); if (this.m_stream.ReadBoolean()) { this.m_AvatarStreamEntryId = this.m_stream.ReadLong(); } }
private static void OnGameFriendlyScoutMessageReceived(GameFriendlyScoutMessage message) { if (GameSessionManager.TryGet(message.SessionId, out GameSession session)) { session.DestructGameState(); FriendlyScoutHomeDataMessage friendlyScoutHomeDataMessage = new FriendlyScoutHomeDataMessage(); LogicClientHome logicClientHome = new LogicClientHome(); logicClientHome.GetCompressibleHomeJSON().Set(message.HomeJSON); logicClientHome.GetCompressibleGlobalJSON().Set(ResourceManager.SERVER_SAVE_FILE_GLOBAL); logicClientHome.GetCompressibleCalendarJSON().Set(ResourceManager.SERVER_SAVE_FILE_CALENDAR); friendlyScoutHomeDataMessage.SetAccountId(message.AccountId); friendlyScoutHomeDataMessage.SetAvatarId(message.AccountId); friendlyScoutHomeDataMessage.SetCurrentTimestamp(TimeUtil.GetTimestamp()); friendlyScoutHomeDataMessage.SetLogicClientHome(logicClientHome); friendlyScoutHomeDataMessage.SetLogicClientAvatar(session.GameAvatar.LogicClientAvatar); friendlyScoutHomeDataMessage.SetMapId(message.MapId); friendlyScoutHomeDataMessage.SetStreamId(message.StreamId); session.SendPiranhaMessage(friendlyScoutHomeDataMessage, 1); } }
public void SetLogicClientHome(LogicClientHome logicClientHome) { this.m_logicClientHome = logicClientHome; }
/// <summary> /// Sets the <see cref="LogicClientAvatar"/> instance. /// </summary> public void SetLogicClientHome(LogicClientHome instance) { this._clientHome = instance; }
public void LoadHomeState(LogicClientHome logicClientHome, LogicClientAvatar logicClientAvatar, int currentTimestamp, int passedSeconds, int secondsSinceLastMaintenance, int reengagementSeconds) { this.m_logicGameMode.LoadHomeState(logicClientHome, logicClientAvatar, passedSeconds, 0, currentTimestamp, secondsSinceLastMaintenance, reengagementSeconds); }
private static void OnChangeGameStateMessageReceived(ChangeGameStateMessage message) { if (GameSessionManager.TryGet(message.SessionId, out GameSession session)) { GameAvatar document = session.GameAvatar; switch (message.StateType) { case GameStateType.HOME: session.DestructGameState(); session.LoadGameState(new GameHomeState { PlayerAvatar = document.LogicClientAvatar, Home = document.LogicClientHome, SaveTime = document.SaveTime, MaintenanceTime = document.MaintenanceTime, ServerCommands = document.ServerCommands, LayoutId = message.LayoutId, MapId = message.MapId }); break; case GameStateType.NPC_ATTACK: session.DestructGameState(); session.LoadGameState(new GameNpcAttackState { PlayerAvatar = document.LogicClientAvatar, Home = GameResourceManager.NpcHomes[message.NpcData.GetInstanceID()], NpcAvatar = LogicNpcAvatar.GetNpcAvatar(message.NpcData), SaveTime = -1 }); break; case GameStateType.NPC_DUEL: session.DestructGameState(); session.LoadGameState(new GameNpcDuelState { PlayerAvatar = document.LogicClientAvatar, Home = GameResourceManager.NpcHomes[message.NpcData.GetInstanceID()], NpcAvatar = LogicNpcAvatar.GetNpcAvatar(message.NpcData), SaveTime = -1 }); break; case GameStateType.VISIT: ServerRequestManager.Create(new GameAvatarRequestMessage { AccountId = message.HomeId }, ServerManager.GetDocumentSocket(9, message.HomeId), 5).OnComplete = args => { if (!session.IsDestructed()) { if (args.ErrorCode == ServerRequestError.Success && args.ResponseMessage.Success) { GameAvatarResponseMessage gameAvatarResponseMessage = (GameAvatarResponseMessage)args.ResponseMessage; session.DestructGameState(); session.LoadGameState(new GameVisitState { Home = gameAvatarResponseMessage.Document.LogicClientHome, HomeOwnerAvatar = gameAvatarResponseMessage.Document.LogicClientAvatar, SaveTime = gameAvatarResponseMessage.Document.SaveTime, PlayerAvatar = session.GameAvatar.LogicClientAvatar }); } else { session.SendPiranhaMessage(new VisitFailedMessage(), 1); } } }; break; case GameStateType.CHALLENGE_ATTACK: session.DestructGameState(); LogicLong liveReplayId = LiveReplayManager.Create(session, message.ChallengeAllianceId, message.ChallengeStreamId); LogicClientHome logicClientHome = new LogicClientHome(); logicClientHome.SetHomeId(message.ChallengeHomeId); logicClientHome.GetCompressibleHomeJSON().Set(message.ChallengeHomeJSON); session.LoadGameState(new GameChallengeAttackState { Home = logicClientHome, PlayerAvatar = document.LogicClientAvatar, SaveTime = -1, LiveReplayId = liveReplayId, AllianceId = message.ChallengeAllianceId, StreamId = message.ChallengeStreamId, MapId = message.ChallengeMapId }); ServerMessageManager.SendMessage(new AllianceChallengeLiveReplayIdMessage { AccountId = message.ChallengeStreamId, LiveReplayId = liveReplayId }, 11); break; } } }
/// <summary> /// Loads the npc duel state. /// </summary> public void LoadNpcDuelState(LogicClientHome home, LogicAvatar homeOwnerAvatar, LogicAvatar visitorAvatar, int currentTimestamp, int secondsSinceLastSave) { }
public static void SaveHomeOwnerAvatarInHome(LogicClientAvatar logicClientAvatar, LogicClientHome logicClientHome) { CompressibleStringHelper.Uncompress(logicClientHome.GetCompressibleHomeJSON()); LogicJSONObject jsonObject = LogicJSONParser.ParseObject(logicClientHome.GetCompressibleHomeJSON().Get()); logicClientAvatar.SaveToDirect(jsonObject); logicClientHome.SetHomeJSON(LogicJSONParser.CreateJSONString(jsonObject, 512)); CompressibleStringHelper.Compress(logicClientHome.GetCompressibleHomeJSON()); }
/// <summary> /// Loads the home state. /// </summary> public void LoadHomeState(LogicClientHome home, LogicAvatar homeOwnerAvatar, int currentTimestamp, int secondsSinceLastSave, int secondsSinceLastMaintenance) { if (home != null) { this._state = 1; if (LogicDataTables.GetGlobals().StartInLastUsedVillage()) { int lastUsedVillage = homeOwnerAvatar.GetVillageToGoTo(); if (!this._level.GetMissionManager().HasTravel(homeOwnerAvatar)) { lastUsedVillage = 0; } if (lastUsedVillage < 0) { Debugger.Warning("VillageToGoTo<0"); } else { if (lastUsedVillage > 1) { Debugger.Warning("VillageToGoTo too big"); } else { this._level.SetVillageType(lastUsedVillage); } } } this._secondsSinceLastMaintenance = secondsSinceLastMaintenance; this._currentTimestamp = currentTimestamp; this._configuration.Load((LogicJSONObject)LogicJSONParser.Parse(home.GetGlobalJSON())); this._calendar.Load(home.GetCalendarJSON(), currentTimestamp); if (this._battleTimer != null) { this._battleTimer.Destruct(); this._battleTimer = null; } this._level.SetHome(home, true); this._level.SetHomeOwnerAvatar(homeOwnerAvatar); this._level.FastForwardTime(secondsSinceLastSave); homeOwnerAvatar.SetLevel(this._level); this._level.LoadingFinished(); this._shieldTime = LogicTime.GetSecondsInTicks(home.GetShieldDurationSeconds()); this._guardTime = LogicTime.GetSecondsInTicks(home.GetGuardDurationSeconds()); this._maintenanceTime = LogicTime.GetSecondsInTicks(home.GetNextMaintenanceSeconds()); int logicTime = this._level.GetLogicTime(); int startGuardTime = logicTime; if (this._shieldTime >= logicTime) { startGuardTime = this._shieldTime; } this._startGuardTime = startGuardTime; if (LogicDataTables.GetGlobals().UseVillageObjects()) { this._level.LoadVillageObjects(); } } }