Пример #1
0
		/*!
		 * \brief
		 * Loads the server list from the user settings.
		 * 
		 * \param xml_element
		 * Pointer to an xml element that parents the version checkers settings.
		 * 
		 * Loads the server list and the date the available version was last checked on, from the users settings.
		 */
		void		c_version_check_manager_base::LoadSettings(TiXmlElement* xml_element)
		{
			m_states.last_checked_day = 0;
			m_states.last_checked_month = 0;
			m_states.last_checked_year = 0;

			for(int i = 0; i < NUMBEROF(m_version_xml.urls); i++)
				m_version_xml.urls[i][0] = 0;

			// if there is no settings element, we still want to set the default
			// xml location
			if(xml_element == NULL)
			{
				m_version_xml.list_version = 0;
				strcpy_s(m_version_xml.urls[0], sizeof(HTTP::t_http_url), c_version_check_manager_base::g_fallback_xml_location);
				return;
			}

			//do-while-false for easy fall-through
			do
			{
				//get the last date the version was checked
				if(!xml_element->Attribute("day", &m_states.last_checked_day)) { m_states.last_checked_day = 0; break; }
				if(!xml_element->Attribute("month", &m_states.last_checked_month)) { m_states.last_checked_month = 0; break; }
				if(!xml_element->Attribute("year", &m_states.last_checked_year)) { m_states.last_checked_year = 0; break; }
			}while(false);

			UpdateDateState();

			//get the xml locations from the user settings
			TiXmlElement* server_list = xml_element->FirstChildElement("server_list");
			if(!server_list)
				return;

			if(!server_list->Attribute("version", &m_version_xml.list_version))
				return;

			TiXmlElement* server = server_list->FirstChildElement("server");
			if(!server)
				return;

			for(int i = 0; server && (i < NUMBEROF(m_version_xml.urls)); i++)
			{
				const char* url = server->GetText();
				if(!is_null_or_empty(url))
					strcpy_s(m_version_xml.urls[i], sizeof(HTTP::t_http_url), url);

				server = server->NextSiblingElement("server");
			}
		}
Пример #2
0
		/*!
		* \brief
		* Runs the update check if needed.
		*
		* Updates the date condition to see if a check has been performed today.
		* If it hasn't, an update check will be run. This check is not blocking,
		* so that normal running is not paused. If there is a new version available
		* The versions will be printed to the console when each map is loaded.
		*
		* \remarks
		* Since servers can be running for longer than 24 hours it's necessary
		* for the server to automatically check for updates at some point. Currently
		* this happens when a new map is loaded, however, if the server is running a
		* gametype that can run for a VERY long time, updates will be missed.
		*/
		void		c_version_check_manager_dedi::InitializeForNewMap()
		{
			// update the date state
			UpdateDateState();

			// if the version hasn't been checked today, check it without blocking
			// although, considering this is map load time a little delay for
			// getting the update might be ok
			if(m_states.is_request_in_progress) return;

			if(!m_states.checked_today)
				CheckForUpdates();
			else
				DisplayVersions(m_states.is_new_version_available);
		}