private void m_Controller_versionInfoUpdated(object sender, CustomArgs ca) { new Thread(new ParameterizedThreadStart(versionInfoCrossThread)).Start(ca.getMessage()); }
private void setToTownProcessedStateEvent() { CustomArgs l_CustomArgs = new CustomArgs(""); townProcessedStateChanged(this, l_CustomArgs); }
private void updateRefreshTimerEvent() { Settings l_Settings = Settings.Instance; m_RefreshTimer.InternalTimer.Stop(); CustomArgs l_CustomArgs = new CustomArgs(m_RefreshTimer.getTimeLeft()); refreshTimerUpdated(this, l_CustomArgs); if (m_RefreshTimer.isTimerDone()) { m_RefreshTimer.stop(); m_QueueTimer.stop(); //m_TradeTimer.stop(); if (m_QueueTimer.isTimerDone()) m_TimeoutOnQueueTimer = true; else m_TimeoutOnQueueTimer = false; if (m_TradeTimer.isTimerDone()) m_TimeoutOnTradeTimer = true; else m_TimeoutOnTradeTimer = false; m_RequestingServerData = true; if (l_Settings.AdvSchedulerBot) { if (l_Settings.FarmerScheduler.Split(';')[DateTime.Now.Hour].Equals("False")) { if (!m_IgnoreScheduler) { logEvent("Bot is disabled by scheduler."); m_CurrentTownIntern = m_Player.Towns.Count; m_CurrentTownTradeIntern = m_Player.Towns.Count; } else { //Ignore schuler during first update, need when scheduler disables bot at startup m_IgnoreScheduler = false; } } } //Captcha check pre cycle. Helps detecting captcha's that occured during idle period. CustomArgs l_CustomArgs2 = new CustomArgs(""); captchaCheckPreCycle(this, l_CustomArgs2); //switchTown(); } else m_RefreshTimer.InternalTimer.Start(); }
//-->Events #region Events private void setStatusBarEvent(string p_Message) { CustomArgs l_CustomArgs = new CustomArgs(p_Message); statusBarUpdated(this, l_CustomArgs); }
private void setGuiToTimeoutProcessedStateEvent() { CustomArgs l_CustomArgs = new CustomArgs(""); timeoutProcessedStateChanged(this, l_CustomArgs); if (!m_RequestedToPauseBot) m_CurrentTownIntern = 0; else { if (m_CurrentTownIntern >= m_Player.Towns.Count) m_CurrentTownIntern = 0; } m_RequestingServerData = false; }
public void captchaSendToGrepolisResponse(string p_Response) { IOHandler l_IOHandler = IOHandler.Instance; Parser l_Parser = Parser.Instance; string l_Search = ""; string l_Error = ""; int l_Index = -1; if (!p_Response.Contains("{\"error\":\"")) { //Captcha answer correct m_CaptchaAnswerCorrect = true; m_CaptchaAnswerInCorrectCount = 0; CustomArgs l_CustomArgs = new CustomArgs(""); captchaAnswerSendToGrepolisCorrect(this, l_CustomArgs); } else { //Captcha answer incorrect m_CaptchaAnswerCorrect = false; m_CaptchaAnswerInCorrectCount++; CustomArgs l_CustomArgs = new CustomArgs(""); captchaAnswerSendToGrepolisInCorrect(this, l_CustomArgs); l_Search = "{\"error\":\""; l_Index = p_Response.IndexOf(l_Search, 0); l_Error = p_Response.Substring(l_Index + l_Search.Length, p_Response.IndexOf("\"", l_Index + l_Search.Length) - (l_Index + l_Search.Length)); l_Error = l_Parser.fixSpecialCharacters(l_Error); l_IOHandler.debug("Ingame error in captchaSendToGrepolisResponse(): " + l_Error + " (#" + m_CaptchaAnswerInCorrectCount + ")"); logEvent(l_Error + " (#"+m_CaptchaAnswerInCorrectCount+")"); } }
/* * This method is called after every server response (CAPTCHA related). * It adds a short delay before starting the next server request. */ private void stateManagerDelayCaptcha() { Settings l_Settings = Settings.Instance; if (m_State.Equals("captchaSubmitCaptcha") || m_State.Equals("captchaCaptchaData")) m_RequestTimerCaptcha.Interval = 5000; else m_RequestTimerCaptcha.Interval = 1000; if (m_State.Equals("captcha9kwServiceStatus")) { if ((m_CaptchaCurrentWorkers < l_Settings.CaptchaMinWorkers || m_CaptchaCurrentQueue > l_Settings.CaptchaMaxQueue) && m_CaptchaCurrentWorkers < l_Settings.CaptchaMinWorkersALT) { m_State = "captcha9kwServiceStatusRetry"; m_RequestTimerCaptcha.Interval = l_Settings.CaptchaExtraDelay * 1000; } } else if (m_State.Equals("captchaCaptchaDataERROR")) { m_RequestTimerCaptcha.Interval = l_Settings.CaptchaExtraDelay * 1000; } else if (m_State.Equals("captchaSubmitCaptchaERROR")) { m_RequestTimerCaptcha.Interval = l_Settings.CaptchaExtraDelay * 1000; } CustomArgs l_CustomArgs = new CustomArgs(""); serverRequestCaptchaDelayRequested(this, l_CustomArgs); }
private void m_Controller_captchaAnswerSendToGrepolisInCorrect(object sender, CustomArgs ca) { //Create new thread new Thread(new ThreadStart(captchaAnswerSendToGrepolisInCorrectCrossThread)).Start(); }
private void m_Controller_captchaSolver9kwDown(object sender, CustomArgs ca) { //Create new thread new Thread(new ThreadStart(captchaSolver9kwDownCrossThread)).Start(); }
private void m_Controller_captchaCheckPreCycle(object sender, CustomArgs ca) { //Create new thread new Thread(new ThreadStart(captchaCheckPreCycleCrossThread)).Start(); }
private void m_Controller_captchaAnswerModerated(object sender, CustomArgs ca) { //Create new thread new Thread(new ThreadStart(captchaAnswerModeratedCrossThread)).Start(); }
private void m_Controller_startCaptchaCheckTimerRequest(object sender, CustomArgs ca) { //Create new thread new Thread(new ThreadStart(startCaptchaCheckTimerRequestCrossThread)).Start(); }
private void m_Controller_pauseBotRequestCaptcha(object sender, CustomArgs ca) { //Create new thread new Thread(new ThreadStart(pauseBotRequestCaptchaCrossThread)).Start(); }
private void m_Controller_serverRequestCaptchaDelayRequested(object sender, CustomArgs ca) { //Create new thread new Thread(new ThreadStart(serverRequestCaptchaDelayRequestCrossThread)).Start(); }
private void captchaCaptchaDataResponse(string p_Response) { /* 0001 API key doesn't exist 0002 API key not found 0003 Active API key not found 0004 API key deactivated by owner 0005 No user found 0006 No data found 0007 No ID found 0008 No captcha found 0009 No image found 0010 Image size not allowed 0011 Balance insufficient 0012 Already done. 0013 No answer found. 0014 Captcha already answered. */ if (p_Response.StartsWith("00")) { logEvent("Unable to get captcha data: " + p_Response); } else if (p_Response.Contains("ERROR NO USER")) { logEvent("No user available to solve captcha: " + p_Response); //Restart Captcha sequence //startCaptchaSequence(m_CaptchaImage, m_CaptchaType); m_CaptchaAnswer = ""; m_State = "captchaCaptchaDataERROR"; stateManagerDelayCaptcha(); } else { if (p_Response.Equals("")) { logEvent("Captcha answer not ready."); stateManagerDelayCaptcha(); } else { logEvent("Captcha answer received: " + p_Response); m_CaptchaAnswer = p_Response; CustomArgs l_CustomArgs = new CustomArgs(""); captchaAnswerReady(this, l_CustomArgs); } } }
private void m_Controller_townListUpdated(object sender, CustomArgs ca) { //Create new thread new Thread(new ThreadStart(setGuiToLoggedInStateCrossThread)).Start(); }
private void captchaCaptchaCorrectResponse(string p_Response) { CustomArgs l_CustomArgs = new CustomArgs(""); captchaAnswerModerated(this, l_CustomArgs); }
private void updateTradeTimerEvent() { m_TradeTimer.InternalTimer.Stop(); CustomArgs l_CustomArgs = new CustomArgs(m_TradeTimer.getTimeLeft()); tradeTimerUpdated(this, l_CustomArgs); //if (!m_RefreshTimer.isTimerDone()) //{ if (m_TradeTimer.isTimerDone()) { m_TradeTimer.stop(); m_TimeoutOnTradeTimer = true; } else { m_TimeoutOnTradeTimer = false; m_TradeTimer.InternalTimer.Start(); } //} }
/* * This method is called after every server response. * It adds a short delay before starting the next server request. */ private void stateManagerDelay() { Settings l_Settings = Settings.Instance; IOHandler l_IOHandler = IOHandler.Instance; //Cancels active request if (m_HttpHandler.IsBusy) { m_HttpHandler.CancelAsync(); l_IOHandler.debug("Active request canceled. (stateManagerDelay)"); } Random l_Random = new Random(); int l_DelayFarmers = l_Random.Next(l_Settings.AdvMinDelayFarmers, l_Settings.AdvMaxDelayFarmers); int l_Delay = l_Random.Next(l_Settings.AdvMinDelayRequests, l_Settings.AdvMaxDelayRequests); if (m_State.Equals("attackfarmers1") || m_State.Equals("attackfarmers2") || m_State.Equals("attackfarmersnext") || m_State.Equals("attackfarmersall1") || m_State.Equals("attackfarmersall2") || m_State.Equals("attackfarmersall3")) m_RequestTimer.Interval = l_DelayFarmers; else m_RequestTimer.Interval = l_Delay; CustomArgs l_CustomArgs = new CustomArgs(""); serverRequestDelayRequested(this, l_CustomArgs); }
private void updateReconnectTimerEvent() { m_ReconnectTimer.InternalTimer.Stop(); CustomArgs l_CustomArgs = new CustomArgs(m_ReconnectTimer.getTimeLeft()); reconnectTimerUpdated(this, l_CustomArgs); }
/* * Handles all the server responses from the 9kw server requested as GET */ private void m_HttpHandlerCaptcha_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e) { IOHandler l_IOHandler = IOHandler.Instance; Settings l_Settings = Settings.Instance; if (e.Error == null && !e.Cancelled) { string l_Response = e.Result; m_CaptchaRetryCounter = 0; responseManager(l_Response); if (l_Settings.AdvOutputAllMode) l_IOHandler.saveServerResponse2(m_State, l_Response); } else if (e.Cancelled) { l_IOHandler.debug("Exception in m_HttpHandlerCaptcha_DownloadStringCompleted(): " + "(" + m_State + ") Request canceled."); } else { l_IOHandler.debug("Exception in m_HttpHandlerCaptcha_DownloadStringCompleted(): " + "(" + m_State + ") " + e.Error.Message); if (m_CaptchaRetryCounter < 5) { m_CaptchaRetryCounter++; switch (m_State) { case "captcha9kwServiceStatus": captcha9kwServiceStatus(); break; case "captchaBalanceQuery": captchaBalanceQuery(); break; case "captchaSubmitCaptcha": captchaSubmitCaptcha(); break; case "captchaCaptchaData": captchaCaptchaData(); break; case "captchaCaptchaCorrect": captchaCaptchaCorrect(); break; } } else { //Retries failed logEvent("Can't connect to 9kw. Bot paused."); CustomArgs l_CustomArgs = new CustomArgs(""); captchaSolver9kwDown(this, l_CustomArgs); } } }
private void updateForcedReconnectTimerEvent() { m_ForcedReconnectTimer.InternalTimer.Stop(); CustomArgs l_CustomArgs = new CustomArgs(m_ForcedReconnectTimer.getTimeLeft()); forcedReconnectTimerUpdated(this, l_CustomArgs); m_ForcedReconnectTimer.InternalTimer.Start(); }
private void versionInfoEvent(string p_VersionInfo) { CustomArgs l_CustomArgs = new CustomArgs(p_VersionInfo); versionInfoUpdated(this, l_CustomArgs); }
private void updateConnectedTimerEvent() { m_ConnectedTimer.InternalTimer.Stop(); CustomArgs l_CustomArgs = new CustomArgs(m_ConnectedTimer.getElapsedTime()); connectedTimerUpdated(this, l_CustomArgs); m_ConnectedTimer.InternalTimer.Start(); }
private void setToTradeProcessedStateEvent() { CustomArgs l_CustomArgs = new CustomArgs(""); tradeProcessedStateChanged(this, l_CustomArgs); m_CurrentTownTradeIntern = 0; m_CurrentTownTradeIntern2 = 0; m_RequestingServerData = false; }
public void captchaDetectedSequence(bool p_RealCaptcha) { m_CaptchaDetected = true; if (p_RealCaptcha) soundCaptchaWarning(); else m_CaptchaMassMailDetected = true; //Pause game CustomArgs l_CustomArgs = new CustomArgs(""); pauseBotRequestCaptcha(this, l_CustomArgs); if (p_RealCaptcha) { //Start captcha check timer startCaptchaCheckTimerRequest(this, l_CustomArgs); } }
public void logEvent(string p_Message) { CustomArgs l_CustomArgs = new CustomArgs(p_Message); logUpdated(this, l_CustomArgs); }
/* * Handles the server response of updateGameData(). */ public void updateGameDataResponse(string p_Response) { IOHandler l_IOHandler = IOHandler.Instance; Settings l_Settings = Settings.Instance; Parser l_Parser = Parser.Instance; //p_Response = l_IOHandler.loadError(); try { string l_Search = ""; string l_Error = ""; int l_Index = -1; int l_IndexEnd = -1; int l_IndexSub = -1; int l_ValidCode = validateResponse(p_Response, "updateGameDataResponse"); if (l_ValidCode == 1) { if (!p_Response.Contains("{\"error\":\"")) { //Map.Player int l_CulturalLevel = 2; int l_CulturalPointsNext = 0; string l_CulturalPoints = ""; string l_Villages = ""; string l_CulturalLevelStr = ""; string l_CitiesStr = ""; string l_CulturalPointsStr = ""; l_Search = "\"villages\":"; l_Index = p_Response.IndexOf(l_Search, 0); l_Villages = p_Response.Substring(l_Index + l_Search.Length, p_Response.IndexOf(",", l_Index + l_Search.Length) - (l_Index + l_Search.Length)); l_Search = "\"cultural_points\":"; l_Index = p_Response.IndexOf(l_Search, 0); l_CulturalPoints = p_Response.Substring(l_Index + l_Search.Length, p_Response.IndexOf(",", l_Index + l_Search.Length) - (l_Index + l_Search.Length)); l_CulturalPointsNext = (int)((3.0 / 2.0) * (Math.Pow(l_CulturalLevel + 1, 2.0) + (-3.0 * (l_CulturalLevel + 1) + 2.0))); while (int.Parse(l_CulturalPoints) >= l_CulturalPointsNext) { l_CulturalLevel++; l_CulturalPointsNext = (int)((3.0 / 2.0) * (Math.Pow(l_CulturalLevel + 1, 2.0) + (-3.0 * (l_CulturalLevel + 1) + 2.0))); } l_CulturalLevelStr = "Cultural Level: " + l_CulturalLevel;//Localisation available in cultural request m_Player.CulturalLevelStr = l_CulturalLevelStr; l_CitiesStr = "Cities: " + l_Villages + "/" + l_CulturalLevel;//Localisation available in cultural request m_Player.CulturalCitiesStr = l_CitiesStr; l_CulturalPointsStr = l_CulturalPoints + "/" + l_CulturalPointsNext; m_Player.CulturalPointsStr = l_CulturalPointsStr; m_Player.CulturalPointsCurrent = int.Parse(l_CulturalPoints); m_Player.CulturalPointsMax = l_CulturalPointsNext; //PlayerLedger l_Search = "{\"model_class_name\":\"PlayerLedger\",\"data\":{"; l_Index = p_Response.IndexOf(l_Search, 0); l_Search = "\"gold\":"; l_Index = p_Response.IndexOf(l_Search, l_Index); string l_Gold = p_Response.Substring(l_Index + l_Search.Length, p_Response.IndexOf(",", l_Index + l_Search.Length) - (l_Index + l_Search.Length)); m_Player.Gold = int.Parse(l_Gold); //PlayerGods int l_IndexPlayerGods = -1; string l_Favor = ""; l_Search = "{\"model_class_name\":\"PlayerGods\",\"data\":{"; l_IndexPlayerGods = p_Response.IndexOf(l_Search, 0); //zeus l_Search = "\"zeus\":{\"current\":"; l_Index = p_Response.IndexOf(l_Search, l_IndexPlayerGods); l_Favor = p_Response.Substring(l_Index + l_Search.Length, p_Response.IndexOf(",", l_Index + l_Search.Length) - (l_Index + l_Search.Length)); m_Player.FavorZeus = int.Parse(l_Favor.Split('.')[0]); l_Search = "\"production\":"; l_Index = p_Response.IndexOf(l_Search, l_Index); m_Player.FavorZeusProduction = p_Response.Substring(l_Index + l_Search.Length, p_Response.IndexOf(",", l_Index + l_Search.Length) - (l_Index + l_Search.Length)); //poseidon l_Search = "\"poseidon\":{\"current\":"; l_Index = p_Response.IndexOf(l_Search, l_IndexPlayerGods); l_Favor = p_Response.Substring(l_Index + l_Search.Length, p_Response.IndexOf(",", l_Index + l_Search.Length) - (l_Index + l_Search.Length)); m_Player.FavorPoseidon = int.Parse(l_Favor.Split('.')[0]); l_Search = "\"production\":"; l_Index = p_Response.IndexOf(l_Search, l_Index); m_Player.FavorPoseidonProduction = p_Response.Substring(l_Index + l_Search.Length, p_Response.IndexOf(",", l_Index + l_Search.Length) - (l_Index + l_Search.Length)); //hera l_Search = "\"hera\":{\"current\":"; l_Index = p_Response.IndexOf(l_Search, l_IndexPlayerGods); l_Favor = p_Response.Substring(l_Index + l_Search.Length, p_Response.IndexOf(",", l_Index + l_Search.Length) - (l_Index + l_Search.Length)); m_Player.FavorHera = int.Parse(l_Favor.Split('.')[0]); l_Search = "\"production\":"; l_Index = p_Response.IndexOf(l_Search, l_Index); m_Player.FavorHeraProduction = p_Response.Substring(l_Index + l_Search.Length, p_Response.IndexOf(",", l_Index + l_Search.Length) - (l_Index + l_Search.Length)); //athena l_Search = "\"athena\":{\"current\":"; l_Index = p_Response.IndexOf(l_Search, l_IndexPlayerGods); l_Favor = p_Response.Substring(l_Index + l_Search.Length, p_Response.IndexOf(",", l_Index + l_Search.Length) - (l_Index + l_Search.Length)); m_Player.FavorAthena = int.Parse(l_Favor.Split('.')[0]); l_Search = "\"production\":"; l_Index = p_Response.IndexOf(l_Search, l_Index); m_Player.FavorAthenaProduction = p_Response.Substring(l_Index + l_Search.Length, p_Response.IndexOf(",", l_Index + l_Search.Length) - (l_Index + l_Search.Length)); //athena l_Search = "\"hades\":{\"current\":"; l_Index = p_Response.IndexOf(l_Search, l_IndexPlayerGods); l_Favor = p_Response.Substring(l_Index + l_Search.Length, p_Response.IndexOf(",", l_Index + l_Search.Length) - (l_Index + l_Search.Length)); m_Player.FavorHades = int.Parse(l_Favor.Split('.')[0]); l_Search = "\"production\":"; l_Index = p_Response.IndexOf(l_Search, l_Index); m_Player.FavorHadesProduction = p_Response.Substring(l_Index + l_Search.Length, p_Response.IndexOf(",", l_Index + l_Search.Length) - (l_Index + l_Search.Length)); //artemis l_Search = "\"artemis\":{\"current\":"; l_Index = p_Response.IndexOf(l_Search, l_IndexPlayerGods); if (l_Index != -1) { l_Favor = p_Response.Substring(l_Index + l_Search.Length, p_Response.IndexOf(",", l_Index + l_Search.Length) - (l_Index + l_Search.Length)); m_Player.FavorArtemis = int.Parse(l_Favor.Split('.')[0]); l_Search = "\"production\":"; l_Index = p_Response.IndexOf(l_Search, l_Index); m_Player.FavorArtemisProduction = p_Response.Substring(l_Index + l_Search.Length, p_Response.IndexOf(",", l_Index + l_Search.Length) - (l_Index + l_Search.Length)); } //CommandsMenuBubble string l_IncomingAttacksTotal = ""; l_Search = "{\"model_class_name\":\"CommandsMenuBubble\""; l_Index = p_Response.IndexOf(l_Search, 0); l_Search = "\"incoming_attacks_total\":"; l_Index = p_Response.IndexOf(l_Search, l_Index); l_IncomingAttacksTotal = p_Response.Substring(l_Index + l_Search.Length, p_Response.IndexOf(",", l_Index + l_Search.Length) - (l_Index + l_Search.Length)); m_Player.IncomingAttacks = int.Parse(l_IncomingAttacksTotal); //Towns l_Search = "{\"class_name\":\"Towns\",\"data\":["; l_Index = p_Response.IndexOf(l_Search, 0); l_IndexEnd = p_Response.IndexOf("]", l_Index + l_Search.Length); string l_TownID = ""; string l_TownName = ""; string l_IslandX = "000"; string l_IslandY = "000"; string l_Plenty = ""; string l_Rare = ""; //string l_Population = ""; string l_PopulationAvailable = ""; string l_PopulationExtra = ""; string l_God = ""; string l_Points = ""; string l_EspionageStorage = ""; string l_Storage = ""; string l_HasConqueror = ""; string l_Wood = ""; string l_Stone = ""; string l_Iron = ""; string l_WoodProduction = ""; string l_StoneProduction = ""; string l_IronProduction = ""; string l_AvailableTradeCapacity = ""; string l_ResourcesLastUpdate = ""; string l_ResponseSub = ""; l_Search = "player_id"; l_Index = p_Response.IndexOf(l_Search, l_Index); while (l_Index < l_IndexEnd && l_Index != -1) { l_ResponseSub = p_Response.Substring(l_Index, p_Response.IndexOf("}}", l_Index) - l_Index); l_Search = "\"name\":\""; l_IndexSub = l_ResponseSub.IndexOf(l_Search, 0); l_TownName = l_ResponseSub.Substring(l_IndexSub + l_Search.Length, l_ResponseSub.IndexOf("\"", l_IndexSub + l_Search.Length) - (l_IndexSub + l_Search.Length)); l_TownName = l_Parser.fixSpecialCharacters(l_TownName); l_Search = "\"island_x\":"; l_IndexSub = l_ResponseSub.IndexOf(l_Search, 0); l_IslandX = l_ResponseSub.Substring(l_IndexSub + l_Search.Length, l_ResponseSub.IndexOf(",", l_IndexSub + l_Search.Length) - (l_IndexSub + l_Search.Length)); l_Search = "\"island_y\":"; l_IndexSub = l_ResponseSub.IndexOf(l_Search, 0); l_IslandY = l_ResponseSub.Substring(l_IndexSub + l_Search.Length, l_ResponseSub.IndexOf(",", l_IndexSub + l_Search.Length) - (l_IndexSub + l_Search.Length)); l_Search = "\"resources_last_update\":"; l_IndexSub = l_ResponseSub.IndexOf(l_Search, 0); l_ResourcesLastUpdate = l_ResponseSub.Substring(l_IndexSub + l_Search.Length, l_ResponseSub.IndexOf(",", l_IndexSub + l_Search.Length) - (l_IndexSub + l_Search.Length)); l_Search = "\"resource_rare\":\""; l_IndexSub = l_ResponseSub.IndexOf(l_Search, 0); l_Rare = l_ResponseSub.Substring(l_IndexSub + l_Search.Length, l_ResponseSub.IndexOf("\"", l_IndexSub + l_Search.Length) - (l_IndexSub + l_Search.Length)); l_Search = "\"resource_plenty\":\""; l_IndexSub = l_ResponseSub.IndexOf(l_Search, 0); l_Plenty = l_ResponseSub.Substring(l_IndexSub + l_Search.Length, l_ResponseSub.IndexOf("\"", l_IndexSub + l_Search.Length) - (l_IndexSub + l_Search.Length)); //l_Search = "\"population\":"; //Example "population":{"max":1457, //l_IndexSub = l_ResponseSub.IndexOf(l_Search, 0); //l_Population = l_ResponseSub.Substring(l_IndexSub + l_Search.Length, l_ResponseSub.IndexOf(",", l_IndexSub + l_Search.Length) - (l_IndexSub + l_Search.Length)); l_Search = "\"god\":\""; l_IndexSub = l_ResponseSub.IndexOf(l_Search, 0); if (l_IndexSub != -1) l_God = l_ResponseSub.Substring(l_IndexSub + l_Search.Length, l_ResponseSub.IndexOf("\"", l_IndexSub + l_Search.Length) - (l_IndexSub + l_Search.Length)); else { l_Search = "\"god\":"; l_IndexSub = l_ResponseSub.IndexOf(l_Search, 0); l_God = l_ResponseSub.Substring(l_IndexSub + l_Search.Length, l_ResponseSub.IndexOf(",", l_IndexSub + l_Search.Length) - (l_IndexSub + l_Search.Length)); } l_Search = "\"points\":"; l_IndexSub = l_ResponseSub.IndexOf(l_Search, 0); l_Points = l_ResponseSub.Substring(l_IndexSub + l_Search.Length, l_ResponseSub.IndexOf(",", l_IndexSub + l_Search.Length) - (l_IndexSub + l_Search.Length)); l_Search = "\"espionage_storage\":"; l_IndexSub = l_ResponseSub.IndexOf(l_Search, 0); l_EspionageStorage = l_ResponseSub.Substring(l_IndexSub + l_Search.Length, l_ResponseSub.IndexOf(",", l_IndexSub + l_Search.Length) - (l_IndexSub + l_Search.Length)); l_Search = "\"population_extra\":"; l_IndexSub = l_ResponseSub.IndexOf(l_Search, 0); l_PopulationExtra = l_ResponseSub.Substring(l_IndexSub + l_Search.Length, l_ResponseSub.IndexOf(",", l_IndexSub + l_Search.Length) - (l_IndexSub + l_Search.Length)); l_Search = "\"id\":"; l_IndexSub = l_ResponseSub.IndexOf(l_Search, 0); l_TownID = l_ResponseSub.Substring(l_IndexSub + l_Search.Length, l_ResponseSub.IndexOf(",", l_IndexSub + l_Search.Length) - (l_IndexSub + l_Search.Length)); l_Search = "\"available_population\":"; l_IndexSub = l_ResponseSub.IndexOf(l_Search, 0); l_PopulationAvailable = l_ResponseSub.Substring(l_IndexSub + l_Search.Length, l_ResponseSub.IndexOf(",", l_IndexSub + l_Search.Length) - (l_IndexSub + l_Search.Length)); l_Search = "\"has_conqueror\":"; l_IndexSub = l_ResponseSub.IndexOf(l_Search, 0); l_HasConqueror = l_ResponseSub.Substring(l_IndexSub + l_Search.Length, l_ResponseSub.IndexOf(",", l_IndexSub + l_Search.Length) - (l_IndexSub + l_Search.Length)); l_Search = "\"last_wood\":"; l_IndexSub = l_ResponseSub.IndexOf(l_Search, 0); l_Wood = l_ResponseSub.Substring(l_IndexSub + l_Search.Length, l_ResponseSub.IndexOf(",", l_IndexSub + l_Search.Length) - (l_IndexSub + l_Search.Length)); l_Search = "\"last_stone\":"; l_IndexSub = l_ResponseSub.IndexOf(l_Search, 0); l_Stone = l_ResponseSub.Substring(l_IndexSub + l_Search.Length, l_ResponseSub.IndexOf(",", l_IndexSub + l_Search.Length) - (l_IndexSub + l_Search.Length)); l_Search = "\"last_iron\":"; l_IndexSub = l_ResponseSub.IndexOf(l_Search, 0); l_Iron = l_ResponseSub.Substring(l_IndexSub + l_Search.Length, l_ResponseSub.IndexOf(",", l_IndexSub + l_Search.Length) - (l_IndexSub + l_Search.Length)); l_Search = "\"available_trade_capacity\":"; l_IndexSub = l_ResponseSub.IndexOf(l_Search, 0); l_AvailableTradeCapacity = l_ResponseSub.Substring(l_IndexSub + l_Search.Length, l_ResponseSub.IndexOf(",", l_IndexSub + l_Search.Length) - (l_IndexSub + l_Search.Length)); l_Search = "\"storage\":"; l_IndexSub = l_ResponseSub.IndexOf(l_Search, 0); l_Storage = l_ResponseSub.Substring(l_IndexSub + l_Search.Length, l_ResponseSub.IndexOf(",", l_IndexSub + l_Search.Length) - (l_IndexSub + l_Search.Length)); l_Search = "\"production\":"; l_IndexSub = l_ResponseSub.IndexOf(l_Search, 0); l_Search = "\"wood\":"; l_IndexSub = l_ResponseSub.IndexOf(l_Search, l_IndexSub); l_WoodProduction = l_ResponseSub.Substring(l_IndexSub + l_Search.Length, l_ResponseSub.IndexOf(",", l_IndexSub + l_Search.Length) - (l_IndexSub + l_Search.Length)); l_Search = "\"stone\":"; l_IndexSub = l_ResponseSub.IndexOf(l_Search, l_IndexSub); l_StoneProduction = l_ResponseSub.Substring(l_IndexSub + l_Search.Length, l_ResponseSub.IndexOf(",", l_IndexSub + l_Search.Length) - (l_IndexSub + l_Search.Length)); l_Search = "\"iron\":"; l_IndexSub = l_ResponseSub.IndexOf(l_Search, l_IndexSub); l_IronProduction = l_ResponseSub.Substring(l_IndexSub + l_Search.Length, l_ResponseSub.IndexOf("}", l_IndexSub + l_Search.Length) - (l_IndexSub + l_Search.Length)); if (m_Player.isUniqueTown(l_TownID)) { m_Player.Towns.Add(new Town(l_TownID, l_TownName, l_IslandX, l_IslandY)); m_TownsSorted = false; } m_Player.Towns[m_Player.getTownIndexByID(l_TownID)].ResourcesLastUpdate = l_ResourcesLastUpdate; m_Player.Towns[m_Player.getTownIndexByID(l_TownID)].ResourceRare = l_Rare; m_Player.Towns[m_Player.getTownIndexByID(l_TownID)].ResourcePlenty = l_Plenty; //m_Player.Towns[m_Player.getTownIndexByID(l_TownID)].PopulationMax = int.Parse(l_Population); m_Player.Towns[m_Player.getTownIndexByID(l_TownID)].God = l_God; m_Player.Towns[m_Player.getTownIndexByID(l_TownID)].Points = l_Points; m_Player.Towns[m_Player.getTownIndexByID(l_TownID)].EspionageStorage = int.Parse(l_EspionageStorage); m_Player.Towns[m_Player.getTownIndexByID(l_TownID)].PopulationExtra = int.Parse(l_PopulationExtra); m_Player.Towns[m_Player.getTownIndexByID(l_TownID)].PopulationAvailable = int.Parse(l_PopulationAvailable); m_Player.Towns[m_Player.getTownIndexByID(l_TownID)].HasConqueror = l_HasConqueror; m_Player.Towns[m_Player.getTownIndexByID(l_TownID)].Wood = int.Parse(l_Wood); m_Player.Towns[m_Player.getTownIndexByID(l_TownID)].Stone = int.Parse(l_Stone); m_Player.Towns[m_Player.getTownIndexByID(l_TownID)].Iron = int.Parse(l_Iron); m_Player.Towns[m_Player.getTownIndexByID(l_TownID)].FreeTradeCapacity = int.Parse(l_AvailableTradeCapacity); m_Player.Towns[m_Player.getTownIndexByID(l_TownID)].Storage = int.Parse(l_Storage); //m_Player.Towns[m_Player.getTownIndexByID(l_TownID)].WoodProduction = int.Parse(l_WoodProduction); m_Player.Towns[m_Player.getTownIndexByID(l_TownID)].WoodProduction = int.Parse(l_WoodProduction.Split('.')[0]); //m_Player.Towns[m_Player.getTownIndexByID(l_TownID)].StoneProduction = int.Parse(l_StoneProduction); m_Player.Towns[m_Player.getTownIndexByID(l_TownID)].StoneProduction = int.Parse(l_StoneProduction.Split('.')[0]); //m_Player.Towns[m_Player.getTownIndexByID(l_TownID)].IronProduction = int.Parse(l_IronProduction); m_Player.Towns[m_Player.getTownIndexByID(l_TownID)].IronProduction = int.Parse(l_IronProduction.Split('.')[0]); //next town l_Search = "player_id"; l_Index = p_Response.IndexOf(l_Search, l_Index + l_Search.Length); } //Collections.RunningPowers string l_CastedPower = ""; m_Player.resetCastedPowers(); l_Search = "{\"class_name\":\"RunningPowers\""; l_Index = p_Response.IndexOf(l_Search, 0); l_IndexEnd = p_Response.IndexOf("]}", l_Index); l_Search = "\"power_id\":\""; l_Index = p_Response.IndexOf(l_Search, l_Index); while (l_Index < l_IndexEnd && l_Index != -1) { l_CastedPower = p_Response.Substring(l_Index + l_Search.Length, p_Response.IndexOf("\"", l_Index + l_Search.Length) - (l_Index + l_Search.Length)); l_Index = p_Response.IndexOf(l_Search, l_Index); l_Search = "\"town_id\":"; l_Index = p_Response.IndexOf(l_Search, l_Index); l_TownID = p_Response.Substring(l_Index + l_Search.Length, p_Response.IndexOf(",", l_Index + l_Search.Length) - (l_Index + l_Search.Length)); m_Player.Towns[m_Player.getTownIndexByID(l_TownID)].CastedPowers += l_CastedPower + ";"; //next power l_Search = "\"power_id\":\""; l_Index = p_Response.IndexOf(l_Search, l_Index); } //Collections.BuildingOrders string l_Building = ""; l_Search = "{\"class_name\":\"BuildingOrders\",\"data\":["; l_Index = p_Response.IndexOf(l_Search, 0); l_IndexEnd = p_Response.IndexOf("]", l_Index + l_Search.Length); l_Search = "\"town_id\":"; l_Index = p_Response.IndexOf(l_Search, l_Index); m_Player.resetBuildingQueue(); while (l_Index < l_IndexEnd && l_Index != -1) { l_TownID = p_Response.Substring(l_Index + l_Search.Length, p_Response.IndexOf(",", l_Index + l_Search.Length) - (l_Index + l_Search.Length)); l_Search = "\"building_type\":\""; l_Index = p_Response.IndexOf(l_Search, l_Index); l_Building = p_Response.Substring(l_Index + l_Search.Length, p_Response.IndexOf("\"", l_Index + l_Search.Length) - (l_Index + l_Search.Length)); m_Player.Towns[m_Player.getTownIndexByID(l_TownID)].IngameBuildingQueueParsed += l_Building + ";"; //next building order l_Search = "\"town_id\":"; l_Index = p_Response.IndexOf(l_Search, l_Index); } m_Player.updateBuildingQueue(); //Collections.Trades l_Search = "{\"class_name\":\"Trades\",\"data\":["; l_Index = p_Response.IndexOf(l_Search, 0); l_IndexEnd = p_Response.IndexOf("]", l_Index + l_Search.Length); l_Search = "\"origin_town_id\":"; l_Index = p_Response.IndexOf(l_Search, l_Index); int l_IndexStart = l_Index; string l_origin_town_id = ""; //string l_origin_town_name = ""; //string l_origin_ix = ""; //string l_origin_iy = ""; //string l_origin_town_player_id = ""; //string l_origin_farm_town_name = ""; string l_destination_town_id = ""; //string l_destination_town_name = ""; //string l_destination_ix = ""; //string l_destination_iy = ""; //string l_destination_town_player_id = ""; //string l_destination_farm_town_name = ""; //string l_wonder_type = ""; //string l_wonder_ix = ""; //string l_wonder_iy = ""; string l_id = ""; //string l_started_at = ""; //string l_arrival_at = ""; //string l_origin_town_type = ""; //string l_destination_town_type = ""; string l_in_exchange = ""; //string l_arrival_seconds_left = ""; //string l_cancelable = ""; //string l_origin_town_link = ""; //string l_destination_town_link = ""; m_Player.resetTrades(); while (l_Index < l_IndexEnd && l_Index != -1) { l_origin_town_id = p_Response.Substring(l_Index + l_Search.Length, p_Response.IndexOf(",", l_Index + l_Search.Length) - (l_Index + l_Search.Length)); l_Search = "\"destination_town_id\":"; l_Index = p_Response.IndexOf(l_Search, l_IndexStart); l_destination_town_id = p_Response.Substring(l_Index + l_Search.Length, p_Response.IndexOf(",", l_Index + l_Search.Length) - (l_Index + l_Search.Length)); l_Search = "\"id\":"; l_Index = p_Response.IndexOf(l_Search, l_IndexStart); l_id = p_Response.Substring(l_Index + l_Search.Length, p_Response.IndexOf(",", l_Index + l_Search.Length) - (l_Index + l_Search.Length)); l_Search = "\"wood\":"; l_Index = p_Response.IndexOf(l_Search, l_IndexStart); l_Wood = p_Response.Substring(l_Index + l_Search.Length, p_Response.IndexOf(",", l_Index + l_Search.Length) - (l_Index + l_Search.Length)); l_Search = "\"stone\":"; l_Index = p_Response.IndexOf(l_Search, l_IndexStart); l_Stone = p_Response.Substring(l_Index + l_Search.Length, p_Response.IndexOf(",", l_Index + l_Search.Length) - (l_Index + l_Search.Length)); l_Search = "\"iron\":"; l_Index = p_Response.IndexOf(l_Search, l_IndexStart); l_Iron = p_Response.Substring(l_Index + l_Search.Length, p_Response.IndexOf(",", l_Index + l_Search.Length) - (l_Index + l_Search.Length)); l_Search = "\"in_exchange\":"; l_Index = p_Response.IndexOf(l_Search, l_IndexStart); l_in_exchange = p_Response.Substring(l_Index + l_Search.Length, p_Response.IndexOf(",", l_Index + l_Search.Length) - (l_Index + l_Search.Length)); //add trade m_Player.Trades.Add(new Trade(l_id)); m_Player.Trades[m_Player.getTradeById(l_id)].Origin_town_id = l_origin_town_id; m_Player.Trades[m_Player.getTradeById(l_id)].Destination_town_id = l_destination_town_id; m_Player.Trades[m_Player.getTradeById(l_id)].Wood = l_Wood; m_Player.Trades[m_Player.getTradeById(l_id)].Stone = l_Stone; m_Player.Trades[m_Player.getTradeById(l_id)].Iron = l_Iron; m_Player.Trades[m_Player.getTradeById(l_id)].In_exchange = l_in_exchange; //next trade l_Search = "\"origin_town_id\":"; l_Index = p_Response.IndexOf(l_Search, l_IndexStart + l_Search.Length); l_IndexStart = l_Index; } //Collections.RemainingUnitOrders l_Search = "{\"class_name\":\"RemainingUnitOrders\",\"data\":["; l_Index = p_Response.IndexOf(l_Search, 0); l_IndexEnd = p_Response.IndexOf("]", l_Index + l_Search.Length); l_Search = "\"UnitOrder\""; l_Index = p_Response.IndexOf(l_Search, l_Index); l_IndexStart = l_Index; string l_UnitType = ""; string l_Kind = ""; string l_UnitsLeft = ""; int l_UnitIndex = -1; m_Player.resetUnitQueue(); while (l_Index < l_IndexEnd && l_Index != -1) { l_Search = "\"town_id\":"; l_Index = p_Response.IndexOf(l_Search, l_IndexStart); l_TownID = p_Response.Substring(l_Index + l_Search.Length, p_Response.IndexOf(",", l_Index + l_Search.Length) - (l_Index + l_Search.Length)); l_Search = "\"unit_type\":\""; l_Index = p_Response.IndexOf(l_Search, l_IndexStart); l_UnitType = p_Response.Substring(l_Index + l_Search.Length, p_Response.IndexOf("\",", l_Index + l_Search.Length) - (l_Index + l_Search.Length)); l_Search = "\"kind\":\""; l_Index = p_Response.IndexOf(l_Search, l_IndexStart); l_Kind = p_Response.Substring(l_Index + l_Search.Length, p_Response.IndexOf("\",", l_Index + l_Search.Length) - (l_Index + l_Search.Length)); l_Search = "\"units_left\":"; l_Index = p_Response.IndexOf(l_Search, l_IndexStart); l_UnitsLeft = p_Response.Substring(l_Index + l_Search.Length, p_Response.IndexOf(",", l_Index + l_Search.Length) - (l_Index + l_Search.Length)); l_UnitIndex = m_Player.Towns[m_CurrentTownIntern].getUnitIndex(l_UnitType); if (l_UnitIndex != -1) { m_Player.Towns[m_Player.getTownIndexByID(l_TownID)].ArmyUnits[l_UnitIndex].QueueGame += int.Parse(l_UnitsLeft); if (l_Kind.Equals("ground")) m_Player.Towns[m_Player.getTownIndexByID(l_TownID)].SizeOfLandUnitQueue += 1; else if (l_Kind.Equals("naval")) m_Player.Towns[m_Player.getTownIndexByID(l_TownID)].SizeOfNavyUnitQueue += 1; } //next queue order l_Search = "\"UnitOrder\""; l_Index = p_Response.IndexOf(l_Search, l_IndexStart + l_Search.Length); l_IndexStart = l_Index; } //Collections.Units string l_CurrentTownID = ""; string l_HomeTownID = ""; string l_Unit = ""; string l_Count = ""; l_Search = "{\"class_name\":\"Units\",\"data\":["; l_Index = p_Response.IndexOf(l_Search, 0); l_Search = "\"home_town_id\":"; l_Index = p_Response.IndexOf(l_Search, l_Index); m_Player.resetUnits(); while (l_Index != -1) { l_HomeTownID = p_Response.Substring(l_Index + l_Search.Length, p_Response.IndexOf(",", l_Index + l_Search.Length) - (l_Index + l_Search.Length)); l_Search = "\"current_town_id\":"; l_Index = p_Response.IndexOf(l_Search, l_Index); l_CurrentTownID = p_Response.Substring(l_Index + l_Search.Length, p_Response.IndexOf(",", l_Index + l_Search.Length) - (l_Index + l_Search.Length)); for (int i = 0; i < 27; i++) { l_Search = ",\"";//,"unit":1,"unit_next"..... l_Index = p_Response.IndexOf(l_Search, l_Index); l_Unit = p_Response.Substring(l_Index + l_Search.Length, p_Response.IndexOf("\"", l_Index + l_Search.Length) - (l_Index + l_Search.Length)); l_Search = ":"; l_Index = p_Response.IndexOf(l_Search, l_Index); l_Count = p_Response.Substring(l_Index + l_Search.Length, p_Response.IndexOf(",", l_Index + l_Search.Length) - (l_Index + l_Search.Length)); m_Player.setUnitCount(l_Unit, l_Count, l_HomeTownID, l_CurrentTownID); } //next unit data set l_Search = "\"home_town_id\":"; l_Index = p_Response.IndexOf(l_Search, l_Index + l_Search.Length); } //Collections.TownResearches l_Search = "{\"class_name\":\"TownResearches\",\"data\":["; l_Index = p_Response.IndexOf(l_Search, 0); l_IndexEnd = p_Response.IndexOf("]}", l_Index); l_Search = "Researches"; l_Index = p_Response.IndexOf(l_Search, l_Index); l_ResponseSub = p_Response.Substring(l_Index, p_Response.IndexOf("}}", l_Index) - l_Index); while (l_Index != -1 && l_Index < l_IndexEnd) { l_Search = "\"id\":"; l_IndexSub = l_ResponseSub.IndexOf(l_Search, 0); l_TownID = l_ResponseSub.Substring(l_IndexSub + l_Search.Length); //Update research status m_Player.Towns[m_Player.getTownIndexByID(l_TownID)].Research.setResearchStatus("slinger", l_ResponseSub.Contains("\"slinger\":true")); m_Player.Towns[m_Player.getTownIndexByID(l_TownID)].Research.setResearchStatus("archer", l_ResponseSub.Contains("\"archer\":true")); m_Player.Towns[m_Player.getTownIndexByID(l_TownID)].Research.setResearchStatus("hoplite", l_ResponseSub.Contains("\"hoplite\":true")); m_Player.Towns[m_Player.getTownIndexByID(l_TownID)].Research.setResearchStatus("town_guard", l_ResponseSub.Contains("\"town_guard\":true")); m_Player.Towns[m_Player.getTownIndexByID(l_TownID)].Research.setResearchStatus("diplomacy", l_ResponseSub.Contains("\"diplomacy\":true")); m_Player.Towns[m_Player.getTownIndexByID(l_TownID)].Research.setResearchStatus("espionage", l_ResponseSub.Contains("\"espionage\":true")); m_Player.Towns[m_Player.getTownIndexByID(l_TownID)].Research.setResearchStatus("booty", l_ResponseSub.Contains("\"booty\":true")); m_Player.Towns[m_Player.getTownIndexByID(l_TownID)].Research.setResearchStatus("pottery", l_ResponseSub.Contains("\"pottery\":true")); m_Player.Towns[m_Player.getTownIndexByID(l_TownID)].Research.setResearchStatus("rider", l_ResponseSub.Contains("\"rider\":true")); m_Player.Towns[m_Player.getTownIndexByID(l_TownID)].Research.setResearchStatus("architecture", l_ResponseSub.Contains("\"architecture\":true")); m_Player.Towns[m_Player.getTownIndexByID(l_TownID)].Research.setResearchStatus("instructor", l_ResponseSub.Contains("\"instructor\":true")); m_Player.Towns[m_Player.getTownIndexByID(l_TownID)].Research.setResearchStatus("bireme", l_ResponseSub.Contains("\"bireme\":true")); m_Player.Towns[m_Player.getTownIndexByID(l_TownID)].Research.setResearchStatus("building_crane", l_ResponseSub.Contains("\"building_crane\":true")); m_Player.Towns[m_Player.getTownIndexByID(l_TownID)].Research.setResearchStatus("meteorology", l_ResponseSub.Contains("\"meteorology\":true")); m_Player.Towns[m_Player.getTownIndexByID(l_TownID)].Research.setResearchStatus("chariot", l_ResponseSub.Contains("\"chariot\":true")); m_Player.Towns[m_Player.getTownIndexByID(l_TownID)].Research.setResearchStatus("attack_ship", l_ResponseSub.Contains("\"attack_ship\":true")); m_Player.Towns[m_Player.getTownIndexByID(l_TownID)].Research.setResearchStatus("conscription", l_ResponseSub.Contains("\"conscription\":true")); m_Player.Towns[m_Player.getTownIndexByID(l_TownID)].Research.setResearchStatus("shipwright", l_ResponseSub.Contains("\"shipwright\":true")); m_Player.Towns[m_Player.getTownIndexByID(l_TownID)].Research.setResearchStatus("demolition_ship", l_ResponseSub.Contains("\"demolition_ship\":true")); m_Player.Towns[m_Player.getTownIndexByID(l_TownID)].Research.setResearchStatus("catapult", l_ResponseSub.Contains("\"catapult\":true")); m_Player.Towns[m_Player.getTownIndexByID(l_TownID)].Research.setResearchStatus("cryptography", l_ResponseSub.Contains("\"cryptography\":true")); m_Player.Towns[m_Player.getTownIndexByID(l_TownID)].Research.setResearchStatus("colonize_ship", l_ResponseSub.Contains("\"colonize_ship\":true")); m_Player.Towns[m_Player.getTownIndexByID(l_TownID)].Research.setResearchStatus("small_transporter", l_ResponseSub.Contains("\"small_transporter\":true")); m_Player.Towns[m_Player.getTownIndexByID(l_TownID)].Research.setResearchStatus("plow", l_ResponseSub.Contains("\"plow\":true")); m_Player.Towns[m_Player.getTownIndexByID(l_TownID)].Research.setResearchStatus("berth", l_ResponseSub.Contains("\"berth\":true")); m_Player.Towns[m_Player.getTownIndexByID(l_TownID)].Research.setResearchStatus("trireme", l_ResponseSub.Contains("\"trireme\":true")); m_Player.Towns[m_Player.getTownIndexByID(l_TownID)].Research.setResearchStatus("phalanx", l_ResponseSub.Contains("\"phalanx\":true")); m_Player.Towns[m_Player.getTownIndexByID(l_TownID)].Research.setResearchStatus("breach", l_ResponseSub.Contains("\"breach\":true")); m_Player.Towns[m_Player.getTownIndexByID(l_TownID)].Research.setResearchStatus("mathematics", l_ResponseSub.Contains("\"mathematics\":true")); m_Player.Towns[m_Player.getTownIndexByID(l_TownID)].Research.setResearchStatus("ram", l_ResponseSub.Contains("\"ram\":true")); m_Player.Towns[m_Player.getTownIndexByID(l_TownID)].Research.setResearchStatus("cartography", l_ResponseSub.Contains("\"cartography\":true")); m_Player.Towns[m_Player.getTownIndexByID(l_TownID)].Research.setResearchStatus("take_over", l_ResponseSub.Contains("\"take_over\":true")); //m_Player.Towns[m_Player.getTownIndexByID(l_TownID)].Research.setResearchStatus("stone_storm", l_ResponseSub.Contains("\"stone_storm\":true")); //m_Player.Towns[m_Player.getTownIndexByID(l_TownID)].Research.setResearchStatus("temple_looting", l_ResponseSub.Contains("\"temple_looting\":true")); //m_Player.Towns[m_Player.getTownIndexByID(l_TownID)].Research.setResearchStatus("divine_selection", l_ResponseSub.Contains("\"divine_selection\":true")); //m_Player.Towns[m_Player.getTownIndexByID(l_TownID)].Research.setResearchStatus("combat_experience", l_ResponseSub.Contains("\"combat_experience\":true")); //m_Player.Towns[m_Player.getTownIndexByID(l_TownID)].Research.setResearchStatus("strong_wine", l_ResponseSub.Contains("\"strong_wine\":true")); //m_Player.Towns[m_Player.getTownIndexByID(l_TownID)].Research.setResearchStatus("set_sail", l_ResponseSub.Contains("\"set_sail\":true")); //Next l_Search = "Researches"; l_Index = p_Response.IndexOf(l_Search, l_Index + l_Search.Length); l_ResponseSub = p_Response.Substring(l_Index, p_Response.IndexOf("}}", l_Index) - l_Index); } //Militia //Found at {"class_name":"Militias","data":[]} //However, not useful because this method (updateGameData) is only called at startup and reconnects. //Translation data - Buildings string l_LocalName = ""; string l_DevName = ""; l_Search = "\"buildings\":{\"data\":"; l_Index = p_Response.IndexOf(l_Search); l_IndexEnd = p_Response.IndexOf("\"mtime\":", l_Index); l_Search = "{\\\"name\\\":\\\""; l_Index = p_Response.IndexOf(l_Search, l_Index); while (l_Index != -1 && l_Index < l_IndexEnd) { l_LocalName = p_Response.Substring(l_Index + l_Search.Length, p_Response.IndexOf("\\", l_Index + l_Search.Length) - (l_Index + l_Search.Length)); l_LocalName = l_Parser.fixSpecialCharacters(l_LocalName); l_Search = "\\\"id\\\":\\\""; l_Index = p_Response.IndexOf(l_Search, l_Index); l_DevName = p_Response.Substring(l_Index + l_Search.Length, p_Response.IndexOf("\\", l_Index + l_Search.Length) - (l_Index + l_Search.Length)); if (!l_DevName.Equals("place")) m_Player.setLocalBuildingName(l_DevName, l_LocalName); //Search next l_Search = "{\\\"name\\\":\\\""; l_Index = p_Response.IndexOf(l_Search, l_Index); } //Translation data - Units l_LocalName = ""; l_DevName = ""; l_Search = "\"units\":{\"data\":"; l_Index = p_Response.IndexOf(l_Search); l_IndexEnd = p_Response.IndexOf("\"mtime\":", l_Index); l_Search = "\\\"id\\\":\\\""; l_Index = p_Response.IndexOf(l_Search, l_Index); l_Search = "\\\"name\\\":\\\""; l_Index = p_Response.IndexOf(l_Search, l_Index);//Skip militia l_Index = p_Response.IndexOf(l_Search, l_Index + l_Search.Length); while (l_Index != -1 && l_Index < l_IndexEnd) { l_LocalName = p_Response.Substring(l_Index + l_Search.Length, p_Response.IndexOf("\\", l_Index + l_Search.Length) - (l_Index + l_Search.Length)); l_LocalName = l_Parser.fixSpecialCharacters(l_LocalName); l_Search = "\\\"id\\\":\\\""; l_Index = p_Response.IndexOf(l_Search, l_Index); l_DevName = p_Response.Substring(l_Index + l_Search.Length, p_Response.IndexOf("\\", l_Index + l_Search.Length) - (l_Index + l_Search.Length)); m_Player.setLocalUnitName(l_DevName, l_LocalName); //Search next l_Search = "\\\"name\\\":\\\""; l_Index = p_Response.IndexOf(l_Search, l_Index); } //Groups information - Groups require the Grepolis premium feature "Administrator" //Collections.TownGroups string l_GroupName = ""; string l_GroupID = ""; int l_GroupIndex = 0; l_Search = "{\"class_name\":\"TownGroups\",\"data\":["; l_Index = p_Response.IndexOf(l_Search, 0); l_IndexEnd = p_Response.IndexOf("]}", l_Index); l_Search = "TownGroup"; l_Index = p_Response.IndexOf(l_Search, l_Index); l_ResponseSub = p_Response.Substring(l_Index, p_Response.IndexOf("}}", l_Index) - l_Index); while (l_Index != -1 && l_Index < l_IndexEnd) { l_Search = "\"name\":\""; l_IndexSub = l_ResponseSub.IndexOf(l_Search, 0); l_GroupName = l_ResponseSub.Substring(l_IndexSub + l_Search.Length, l_ResponseSub.IndexOf("\",", l_IndexSub + l_Search.Length) - (l_IndexSub + l_Search.Length)); l_GroupName = l_Parser.fixSpecialCharacters(l_GroupName); l_Search = "\"id\":"; l_IndexSub = l_ResponseSub.IndexOf(l_Search, 0); l_GroupID = l_ResponseSub.Substring(l_IndexSub + l_Search.Length); //Add if (m_Player.isUniqueGroup(l_GroupID)) { //Ignore default groups (No group, All) if (!l_GroupID.Equals("-1") && !l_GroupID.Equals("0")) m_Player.Groups.Add(new Group(l_GroupID, l_GroupName, true)); } else { //reset l_GroupIndex = m_Player.getGroupIndexByID(l_GroupID); m_Player.Groups[l_GroupIndex].Towns.Clear(); } //Next l_Search = "TownGroup"; l_Index = p_Response.IndexOf(l_Search, l_Index + l_Search.Length); l_ResponseSub = p_Response.Substring(l_Index, p_Response.IndexOf("}}", l_Index) - l_Index); } //Groups information - Groups require the Grepolis premium feature "Administrator" //Collections.TownGroupTowns l_TownID = ""; l_GroupID = ""; l_Search = "{\"class_name\":\"TownGroupTowns\",\"data\":["; l_Index = p_Response.IndexOf(l_Search, 0); l_IndexEnd = p_Response.IndexOf("]}", l_Index); l_Search = "\"TownGroupTown\""; l_Index = p_Response.IndexOf(l_Search, l_Index); l_ResponseSub = p_Response.Substring(l_Index, p_Response.IndexOf("}}", l_Index) - l_Index); while (l_Index != -1 && l_Index < l_IndexEnd) { l_Search = "\"group_id\":"; l_IndexSub = l_ResponseSub.IndexOf(l_Search, 0); l_GroupID = l_ResponseSub.Substring(l_IndexSub + l_Search.Length, l_ResponseSub.IndexOf(",", l_IndexSub + l_Search.Length) - (l_IndexSub + l_Search.Length)); l_Search = "\"town_id\":"; l_IndexSub = l_ResponseSub.IndexOf(l_Search, 0); l_TownID = l_ResponseSub.Substring(l_IndexSub + l_Search.Length, l_ResponseSub.IndexOf(",", l_IndexSub + l_Search.Length) - (l_IndexSub + l_Search.Length)); //Add //Ignore default groups (No group, All) if (!l_GroupID.Equals("-1") && !l_GroupID.Equals("0")) { l_GroupIndex = m_Player.getGroupIndexByID(l_GroupID); m_Player.Groups[l_GroupIndex].Towns.Add(l_TownID); } //Next l_Search = "\"TownGroupTown\""; l_Index = p_Response.IndexOf(l_Search, l_Index + l_Search.Length); if (l_Index != -1) l_ResponseSub = p_Response.Substring(l_Index, p_Response.IndexOf("}}", l_Index) - l_Index); } //End //Add here new stuff to extract; } else { if (l_Settings.AdvDebugMode) { l_Search = "{\"error\":\""; l_Index = p_Response.IndexOf(l_Search, 0); l_Error = p_Response.Substring(l_Index + l_Search.Length, p_Response.IndexOf("\"", l_Index + l_Search.Length) - (l_Index + l_Search.Length)); l_Error = l_Parser.fixSpecialCharacters(l_Error); l_IOHandler.debug("Ingame error in updateGameDataResponse(): " + l_Error); if (m_RetryCountServerError < 1) { m_RetryCountServerError++; retryManager(); } else { m_RetryCountServerError = 0; startReconnect(1); } } }//end error } else { processValidatedResponse(l_ValidCode); } m_RetryCountServerError = 0; //Server time updateServerTime("_srvtime", p_Response); for (int i = 0; i < m_Player.Towns.Count; i++) { m_Player.Towns[i].ServerTime = m_ServerTime; } addNotifications(p_Response); if (!m_TownListInitialized)//set to false at reconnect { m_TownListInitialized = true; //Finish login sequence CustomArgs l_CustomArgs = new CustomArgs(""); townListUpdated(this, l_CustomArgs); } else { stateManagerDelay(); } } catch (Exception e) { setStatusBarEvent("(#" + m_RetryCountServerError + ")Critical error occurred. Server response saved in Response dir."); l_IOHandler.debug("(#" + m_RetryCountServerError + ")Critical error occurred. Server response saved in Response dir."); if (l_Settings.AdvDebugMode) l_IOHandler.saveServerResponse("updateGameDataResponse", e.Message + "\n" + p_Response); if (m_RetryCountServerError < 1) { m_RetryCountServerError++; retryManager(); } else { m_RetryCountServerError = 0; startReconnect(1); } } }
private void updateQueueTimerEvent() { m_QueueTimer.InternalTimer.Stop(); CustomArgs l_CustomArgs = new CustomArgs(m_QueueTimer.getTimeLeft()); queueTimerUpdated(this, l_CustomArgs); if (!m_RefreshTimer.isTimerDone()) { if (m_QueueTimer.isTimerDone()) { m_QueueTimer.stop(); m_TimeoutOnQueueTimer = true; } else { m_TimeoutOnQueueTimer = false; m_QueueTimer.InternalTimer.Start(); } } }
private void m_Controller_logUpdated(object sender, CustomArgs ca) { //Create new thread new Thread(new ParameterizedThreadStart(logCrossThread)).Start(ca.getMessage()); }