private function ValidateResponse($json_array, $func_log_id, $request_id) { // These statuses will trigger an error state but not kill the program $response_whitelist = array('EVENT_QUEUE_EXECUTE_NOW_FAILED'); // Validate that the request completed successfully if ($json_array['status'] == 'OK' && array_key_exists(0, $json_array['responses']) && array_key_exists('status', $json_array['responses'][0])) { if ($json_array['responses'][0]['status'] == 'OK') { DataLoadLogDAO::completeFunction($this->db, $func_log_id, 'Request Successful'); } elseif (in_array($json_array['responses'][0]['status'], $response_whitelist)) { $status_str = "Statuses: [{$json_array['status']}], [{$json_array['responses'][0]['status']}]"; echo "Request Failed. {$status_str}\nContinuing...\n"; DataLoadLogDAO::webServiceStatusFailure($this->db, $request_id); DataLoadLogDAO::completeFunction($this->db, $func_log_id, "Request Failed. {$status_str}", 1); return 'retry'; } else { $status_str = "Statuses: [{$json_array['status']}], [{$json_array['responses'][0]['status']}]"; DataLoadLogDAO::webServiceStatusFailure($this->db, $request_id); DataLoadLogDAO::completeFunction($this->db, $func_log_id, "Request Failed. {$status_str}", 1); DataLoadDAO::loadFailed($this->db, $this->data_load_id); die("Data Load Failed. {$status_str}\n"); } } elseif (array_key_exists(0, $json_array['responses']) && substr($json_array['responses'][0], 0, 9) === 'EXCEPTION') { $status_str = "Statuses: [{$json_array['status']}], [{$json_array['responses'][0]}]"; echo "Request Failed. {$status_str}\nContinuing...\n"; DataLoadLogDAO::webServiceStatusFailure($this->db, $request_id); DataLoadLogDAO::completeFunction($this->db, $func_log_id, "Request Failed. {$status_str}", 1); return 'retry'; } else { $status_str = "Statuses: [{$json_array['status']}], [{$json_array['responses'][0]}]"; DataLoadLogDAO::webServiceStatusFailure($this->db, $request_id); DataLoadLogDAO::completeFunction($this->db, $func_log_id, "Request Failed. {$status_str}", 1); DataLoadDAO::loadFailed($this->db, $this->data_load_id); die("Data Load Failed. {$status_str}\n"); } return true; }
*/ $won = new WarOfNations(); $won->setDataLoadId(DataLoadDAO::initNewLoad($won->db, 'WORLD_MAP', 0, "World {$world}")); DataLoadDAO::startLoad($won->db, $won->data_load_id); $won->Authenticate(); // Check if we're in the correct world if ($won->auth->world_id != $world) { // Switch world if not if ($won->SwitchWorld($world) === false) { // If we didn't switch successfully, join a new world $won->JoinNewWorld($world); } } // If we're still not in the right world, quit if ($won->auth->world_id != $world) { DataLoadDAO::loadFailed($won->db, $won->data_load_id); die("ERROR: Not Authenticated to World {$world}"); } /* ======================================================= ===================== Do Stuff ======================== ======================================================= */ $start = microtime(true); // Break the world into 4 quadrants // 0 => -, - // 1 => +, - // 2 => +, + // 3 => -, + while ($cur_quadrant <= 3) { // This loop controls our position on the Y axis