Exemple #1
0
void CheckVersionReturnance ()
{
	if (VersionCheckReady)
	{
		if (VersionReturnance == VERSION_NEWER)
			ServerPrintf (
			"==================================\n"
			"*****************************\n"
			"There is an update available for Cl	eanCode!\n"
			"Please go to http://code.google.com/p/cleancodequake2 and update accordingly.\n"
			"Your version:   "CLEANCODE_VERSION_PRINT"\n"
			"Update version: "CLEANCODE_VERSION_PRINT"\n"
			"*****************************\n"
			"==================================\n",
			CLEANCODE_VERSION_PRINT_ARGS,
			VersionPrefix.CString(), VersionMajor, VersionMinor, VersionBuild);
		else
			ServerPrint ("Your version of CleanCode is up to date.\n");

		VersionReturnance = VERSION_SAME;
		VersionCheckReady = false;

		CloseHandle (hThread);

		hThread = NULL;
		iID = 0;
	}
}
Exemple #2
0
/**
\fn	void InitVersion ()

\brief	Initialises the version system. 

\author	Paril
\date	25/05/2010
**/
void InitVersion ()
{
#if (VERSION_CHECKING != VC_NONE)
	ServerPrint ("Checking for new version...\n");

	if (!CFile::Exists(VERSION_PATH))
	{
		ServerPrint ("Version file non-existant, writing... ");
		WriteVersion ();
		ServerPrint ("done\n");
	}
	else
		VerifyVersionFile ();
	
	CheckNewVersion ();
#endif
}
Exemple #3
0
void VerifyVersionFile ()
{
	CFileBuffer Buffer (VERSION_PATH, true);
	CParser Parser (Buffer.GetBuffer<char> (), PSP_COMMENT_LINE);

	String prefix;
	Parser.ParseToken (PSF_ALLOW_NEWLINES, prefix);

	uint8 minor;
	uint16 major;
	uint32 build;
	Parser.ParseDataType<uint16> (PSF_ALLOW_NEWLINES, &major, 1);
	Parser.ParseDataType<uint8> (PSF_ALLOW_NEWLINES, &minor, 1);
	Parser.ParseDataType<uint32> (PSF_ALLOW_NEWLINES, &build, 1);

	if (CompareVersion (prefix.CString(), major, minor, build))
	{
		ServerPrint ("Version file out of date; updating...\n");
		WriteVersion ();
	}
}
Exemple #4
0
void RoundInit (void)
{
   // this is called at the start of each round

   g_roundEnded = false;

   // SyPB Pro P.35 - Game Mode Setting
   if (GetGameMod() == 0)
   {
	   // check team economics
	   g_botManager->CheckTeamEconomics(TEAM_TERRORIST);
	   g_botManager->CheckTeamEconomics(TEAM_COUNTER);
   }

   for (int i = 0; i < engine->GetMaxClients (); i++)
   {
      if (g_botManager->GetBot (i))
         g_botManager->GetBot (i)->NewRound ();

      g_radioSelect[i] = 0;
   }
   g_waypoint->SetBombPosition (true);
   g_waypoint->ClearGoalScore ();

   // SyPB Pro P.38 - Zombie Mode Human Camp 
   g_waypoint->InitTypes(1);

   g_bombSayString = false;
   g_timeBombPlanted = 0.0f;
   g_timeNextBombUpdate = 0.0f;

   g_leaderChoosen[TEAM_COUNTER] = false;
   g_leaderChoosen[TEAM_TERRORIST] =  false;

   g_lastRadioTime[0] = 0.0f;
   g_lastRadioTime[1] = 0.0f;
   g_botsCanPause = false;

   g_entityIdAPI.RemoveAll();
   g_entityTeamAPI.RemoveAll();
   g_entityActionAPI.RemoveAll();

   // SyPB Pro P.15
   char *Plugin_INI = FormatBuffer("%s/addons/amxmodx/configs/plugins-dmkd.ini", GetModName());
   if (TryFileOpen(Plugin_INI))
   {
	   if (CVAR_GET_FLOAT("HsK_Deathmatch_Plugin_load_SyPB") == 1)
		   sypb_gamemod.SetInt(1);
	   else
		   sypb_gamemod.SetInt(0);
   }

   // SyPB Pro P.35 - ZP5.0 Fixed
   char *zpGameVersion[] =
   {
	   "plugins-zplague",  // ZP4.3
	   "plugins-zp50_ammopacks", // ZP5.0
	   "plugins-zp50_money" //ZP5.0
   };

   for (int i = 0; i < 3; i++)
   {
	   Plugin_INI = FormatBuffer("%s/addons/amxmodx/configs/%s.ini", GetModName(), zpGameVersion[i]);
	   if (TryFileOpen(Plugin_INI))
	   {
		   float delayTime = CVAR_GET_FLOAT("zp_delay") + 2.0f;
		   if (i != 0)
			   delayTime = CVAR_GET_FLOAT("zp_gamemode_delay") + 0.2f;

		   if (delayTime > 0)
		   {
			   sypb_gamemod.SetInt(2);
			   sypb_walkallow.SetInt(0);
			   //g_DelayTimer = engine->GetTime() + delayTime + 6.0f;

			   // SyPB Pro P.34 - ZP TIME FIXED
			   g_DelayTimer = engine->GetTime() + delayTime;// +1.99f;
			   break;
		   }
	   }
   }

   // SyPB Pro P.11
   Plugin_INI = FormatBuffer("%s/addons/amxmodx/configs/zombiehell.cfg", GetModName());
   if (TryFileOpen(Plugin_INI) && CVAR_GET_FLOAT("zh_zombie_maxslots") > 0)
   {
	   sypb_gamemod.SetInt(4);
	   sypb_walkallow.SetInt(0);

	   extern ConVar sypb_quota;
	   sypb_quota.SetInt(static_cast <int> (CVAR_GET_FLOAT("zh_zombie_maxslots")));
   }

   // SyPB Pro P.29 - Support CSBTE Final
   Plugin_INI = FormatBuffer("%s/addons/amxmodx/configs/bte_player.ini", GetModName());
   if (TryFileOpen(Plugin_INI))
   {
	   const int Const_GameModes = 13;
	   int bteGameModAi[Const_GameModes] =
	   {
		   0, 0, 1, 3, 0, 2, 2, 2, 2, 4, 2, 3, 2
	   };//1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13

	   char *bteGameINI[Const_GameModes] =
	   {
		   "plugins-none", //1
		   "plugins-td",   //2
		   "plugins-dm",   //3
		   "plugins-dr",   //4
		   "plugins-gd",   //5
		   "plugins-ghost",//6
		   "plugins-zb1",  //7
		   "plugins-zb3",  //8
		   "plugins-zb4",  //9 
		   "plugins-ze",   //10
		   "plugins-zse",  //11
		   "plugins-npc",  //12
		   "plugins-zb5"   //13
	   };

	   for (int i = 0; i < Const_GameModes; i++)
	   {
		   if (TryFileOpen(FormatBuffer("%s/addons/amxmodx/configs/%s.ini", GetModName(), bteGameINI[i])))
		   {
			   //sypb_gamemod.SetInt(bteGameModAi[i]);

			   if (bteGameModAi[i] == 2 && i != 5)
			   {
				   sypb_walkallow.SetInt(0);
				   g_DelayTimer = engine->GetTime() + 20.0f + CVAR_GET_FLOAT("mp_freezetime");
			   }

			   ServerPrint("*** CS:BTE [%s] - GameMod Setting [%d] ***", bteGameINI[i], bteGameModAi[i]);
			   ServerPrint("*** CS:BTE [%s] - GameMod Setting [%d] ***", bteGameINI[i], bteGameModAi[i]);
			   ServerPrint("*** CS:BTE [%s] - GameMod Setting [%d] ***", bteGameINI[i], bteGameModAi[i]);
			   if (i == 3 || i == 9)
			   {
				   ServerPrint("***** SyPB not support the mode now :( *****");
				   ServerPrint("***** SyPB not support the mode now :( *****");
				   ServerPrint("***** SyPB not support the mode now :( *****");
				   ServerPrint("***** SyPB not support the mode now :( *****");
				   ServerPrint("***** SyPB not support the mode now :( *****");

				   sypb_gamemod.SetInt(10);
			   }
			   else
				   sypb_gamemod.SetInt(bteGameModAi[i]);

			   // SyPB Pro P.36 - bte support 
			   g_gameVersion = CSVER_CZERO;

			   break;
		   }
	   }
   }

   // SyPB Pro P.38 - Base Change 
   if (GetGameMod() != 0)
	   g_mapType |= MAP_DE;

   // SyPB Pro P.35 - Game Mode Setting
   if (GetGameMod () == 0)
	   g_exp.UpdateGlobalKnowledge (); // update experience data on round start

   // calculate the round mid/end in world time
   g_timeRoundStart = engine->GetTime () + engine->GetFreezeTime ();
   g_timeRoundMid = g_timeRoundStart + engine->GetRoundTime () * 60 / 2;
   g_timeRoundEnd = g_timeRoundStart + engine->GetRoundTime () * 60;
}
Exemple #5
0
int BotControl::CreateBot (String name, int skill, int personality, int team, int member)
{
   // this function completely prepares bot entity (edict) for creation, creates team, skill, sets name etc, and
   // then sends result to bot constructor

   edict_t *bot = null;
   char outputName[33];

   if (g_numWaypoints < 1) // don't allow creating bots with no waypoints loaded
   {
      CenterPrint ("Map not waypointed. Can't Create Bot");
      return 0;
   }
   else if (g_waypointsChanged) // don't allow creating bots with changed waypoints (distance tables are messed up)
   {
      CenterPrint ("Waypoints has been changed. Load waypoints again...");
      return 0;
   }


   if (skill < 0 || skill > 100)
      skill = engine->RandomInt (yb_minskill.GetInt (), yb_maxskill.GetInt ());

   if (skill > 100 || skill < 0)
      skill = engine->RandomInt (0, 100);

   if (personality < 0 || personality > 2)
   {
      int randomPrecent = engine->RandomInt (0, 100);

      if (randomPrecent < 50)
         personality = PERSONALITY_NORMAL;
      else
      {
         if (engine->RandomInt (0, randomPrecent) < randomPrecent * 0.5)
            personality = PERSONALITY_CAREFUL;
         else
            personality = PERSONALITY_RUSHER;
      }
   }

   // setup name
   if (name.IsEmpty ())
   {
      if (!g_botNames.IsEmpty ())
      {
         bool nameFound = false;

         for (int i = 0; i < 8; i++)
         {
            if (nameFound)
               break;

            NameItem &botName = g_botNames.GetRandomElement ();

            if (botName.isUsed)
               continue;

            botName.isUsed = nameFound = true;
            strcpy (outputName, botName.name);
         }
      }
      else
         sprintf (outputName, "bot%i", engine->RandomInt (0, 100)); // just pick ugly random name
   }
   else
      strncpy (outputName, name, 21);

   if (!IsNullString (yb_nameprefix.GetString ()) || yb_skilltags.GetBool ())
   {
      char prefixedName[33]; // temp buffer for storing modified name

      if (!IsNullString (yb_nameprefix.GetString ()))
         sprintf (prefixedName, "%s %s", yb_nameprefix.GetString (), outputName);

      else if (yb_skilltags.GetBool ())
         sprintf  (prefixedName, "%s (%d)", outputName, skill);

      else if (!IsNullString (yb_nameprefix.GetString ()) && yb_skilltags.GetBool ())
         sprintf  (prefixedName, "%s %s (%d)", yb_nameprefix.GetString (), outputName, skill);

      // buffer has been modified, copy to real name
      if (!IsNullString (prefixedName))
         sprintf (outputName, prefixedName);
   }

   if (FNullEnt ((bot = (*g_engfuncs.pfnCreateFakeClient) (outputName))))
   {
      CenterPrint ("Maximum players reached (%d/%d). Unable to create Bot.", engine->GetMaxClients (), engine->GetMaxClients ());
      return 2;
   }

   int index = ENTINDEX (bot) - 1;

   InternalAssert (index >= 0 && index <= 32); // check index
   InternalAssert (m_bots[index] == null); // check bot slot

   m_bots[index] = new Bot (bot, skill, personality, team, member);
 
   if (m_bots == null)
      TerminateOnMalloc ();

   if (engine->GetDeveloperLevel () > 0)
      ServerPrint ("Connecting '%s'... (Skill %d)", STRING (bot->v.netname), skill);
   else
      ServerPrint ("Connecting YaPB... (Skill %d)", skill);

   return 1;
}
Exemple #6
0
Bot::Bot (edict_t *bot, int skill, int personality, int team, int member)
{
   // this function does core operation of creating bot, it's called by CreateBot (),
   // when bot setup completed, (this is a bot class constructor)

   char rejectReason[128];
   int clientIndex = ENTINDEX (bot);

   memset (this, 0, sizeof (Bot));

   pev = VARS (bot);

   if (bot->pvPrivateData != null)
      FREE_PRIVATE (bot);

   bot->pvPrivateData = null;
   bot->v.frags = 0;

   // create the player entity by calling MOD's player function
   BotControl::CallGameEntity (&bot->v);

   // set all info buffer keys for this bot
   char *buffer = GET_INFOKEYBUFFER (bot);

   SET_CLIENT_KEYVALUE (clientIndex, buffer, "model", "");
   SET_CLIENT_KEYVALUE (clientIndex, buffer, "rate", "3500.000000");
   SET_CLIENT_KEYVALUE (clientIndex, buffer, "cl_updaterate", "20");
   SET_CLIENT_KEYVALUE (clientIndex, buffer, "cl_lw", "1");
   SET_CLIENT_KEYVALUE (clientIndex, buffer, "cl_lc", "1");
   SET_CLIENT_KEYVALUE (clientIndex, buffer, "tracker", "0");
   SET_CLIENT_KEYVALUE (clientIndex, buffer, "cl_dlmax", "128");
   SET_CLIENT_KEYVALUE (clientIndex, buffer, "friends", "0");
   SET_CLIENT_KEYVALUE (clientIndex, buffer, "dm", "0");
   SET_CLIENT_KEYVALUE (clientIndex, buffer, "_ah", "0");

   if (yb_tagbots.GetBool ())
      SET_CLIENT_KEYVALUE (clientIndex, buffer, "*bot", "1");

   SET_CLIENT_KEYVALUE (clientIndex, buffer, "_vgui_menus", "0");

   memset (rejectReason, 0, sizeof (rejectReason)); // reset the reject reason template string
   MDLL_ClientConnect (bot, "fakeclient", FormatBuffer ("192.168.1.%d", ENTINDEX (bot) + 100), rejectReason);

   if (!IsNullString (rejectReason))
   {
      AddLogEntry (true, LOG_WARNING, "Server refused '%s' connection (%s)", STRING (bot->v.netname), rejectReason);
      ServerCommand ("kick \"%s\"", STRING (bot->v.netname)); // kick the bot player if the server refused it

      bot->v.flags |= FL_KILLME;
   }

   if (IsDedicatedServer () && engine->GetDeveloperLevel () > 0)
   {
      if (engine->GetDeveloperLevel () == 2)
      {
          ServerPrint ("Server requiring authentication");
          ServerPrint ("Client '%s' connected", STRING (bot->v.netname));
          ServerPrint ("Adr: 127.0.0.%d:27005", ENTINDEX (bot) + 100);
      }

      ServerPrint ("Verifying and uploading resources...");
      ServerPrint ("Custom resources total 0 bytes");
      ServerPrint ("  Decals:  0 bytes");
      ServerPrint ("----------------------");
      ServerPrint ("Resources to request: 0 bytes");
   }

   MDLL_ClientPutInServer (bot);

   bot->v.flags = 0;
   bot->v.flags |= FL_FAKECLIENT | FL_CLIENT; // set this player as fakeclient

   // initialize all the variables for this bot...
   m_notStarted = true;  // hasn't joined game yet

   m_startAction = CMENU_IDLE;
   m_moneyAmount = 0;
   m_logotypeIndex = engine->RandomInt (0, 5);


   // initialize msec value
   m_msecNum = m_msecDel = 0.0f;
   m_msecInterval = engine->GetTime ();
   m_msecVal = static_cast <uint8_t> (g_pGlobals->frametime * 1000.0f);
   m_msecBuiltin = engine->RandomInt (1, 4);

   // assign how talkative this bot will be
   m_sayTextBuffer.chatDelay = engine->RandomFloat (3.8f, 10.0f);
   m_sayTextBuffer.chatProbability = engine->RandomInt (1, 100);

   m_notKilled = false;
   m_skill = skill;
   m_weaponBurstMode = BURST_DISABLED;

   m_lastThinkTime = engine->GetTime ();
   m_frameInterval = engine->GetTime ();

   bot->v.idealpitch = bot->v.v_angle.x;
   bot->v.ideal_yaw = bot->v.v_angle.y;

   bot->v.yaw_speed = engine->RandomFloat (g_skillTab[m_skill / 20].minTurnSpeed, g_skillTab[m_skill / 20].maxTurnSpeed);
   bot->v.pitch_speed = engine->RandomFloat (g_skillTab[m_skill / 20].minTurnSpeed, g_skillTab[m_skill / 20].maxTurnSpeed);

   switch (personality)
   {
   case 1:
      m_personality = PERSONALITY_RUSHER;
      m_baseAgressionLevel = engine->RandomFloat (0.7f, 1.0f);
      m_baseFearLevel = engine->RandomFloat (0.0f, 0.4f);
      break;

   case 2:
      m_personality = PERSONALITY_CAREFUL;
      m_baseAgressionLevel = engine->RandomFloat (0.0f, 0.4f);
      m_baseFearLevel = engine->RandomFloat (0.7f, 1.0f);
      break;

   default:
      m_personality = PERSONALITY_NORMAL;
      m_baseAgressionLevel = engine->RandomFloat (0.4f, 0.7f);
      m_baseFearLevel = engine->RandomFloat (0.4f, 0.7f);
      break;
   }

   memset (&m_ammoInClip, 0, sizeof (m_ammoInClip));
   memset (&m_ammo, 0, sizeof (m_ammo));

   m_currentWeapon = 0; // current weapon is not assigned at start
   m_voicePitch = engine->RandomInt (166, 250) / 2; // assign voice pitch

   // copy them over to the temp level variables
   m_agressionLevel = m_baseAgressionLevel;
   m_fearLevel = m_baseFearLevel;
   m_nextEmotionUpdate = engine->GetTime () + 0.5f;

   // just to be sure
   m_actMessageIndex = 0;
   m_pushMessageIndex = 0;

   // assign team and class
   m_wantedTeam = team;
   m_wantedClass = member;

   NewRound ();
}
Exemple #7
0
void RoundInit (void)
{
   // this is called at the start of each round

   g_roundEnded = false;

   // check team economics
   g_botManager->CheckTeamEconomics (TEAM_TERRORIST);
   g_botManager->CheckTeamEconomics (TEAM_COUNTER);

   for (int i = 0; i < engine->GetMaxClients (); i++)
   {
      if (g_botManager->GetBot (i))
         g_botManager->GetBot (i)->NewRound ();

      g_radioSelect[i] = 0;
   }
   g_waypoint->SetBombPosition (true);
   g_waypoint->ClearGoalScore ();

   g_bombSayString = false;
   g_timeBombPlanted = 0.0f;
   g_timeNextBombUpdate = 0.0f;

   g_leaderChoosen[TEAM_COUNTER] = false;
   g_leaderChoosen[TEAM_TERRORIST] =  false;

   g_lastRadioTime[0] = 0.0f;
   g_lastRadioTime[1] = 0.0f;
   g_botsCanPause = false;

   // SyPB Pro P.15
   char *Plugin_INI = FormatBuffer("%s/addons/amxmodx/configs/plugins-dmkd.ini", GetModName());
   if (TryFileOpen(Plugin_INI))
   {
	   if (CVAR_GET_FLOAT("HsK_Deathmatch_Plugin_load_SyPB") == 1)
		   sypb_gamemod.SetInt(1);
	   else
		   sypb_gamemod.SetInt(0);
   }

   // SyPB Pro P.2 // SyPB Pro P.15
   Plugin_INI = FormatBuffer("%s/addons/amxmodx/configs/plugins-zplague.ini", GetModName());
   if (TryFileOpen(Plugin_INI)) // Getting GameMod
   {
	   float delayTime = (CVAR_GET_FLOAT("zp_delay") >0) ? CVAR_GET_FLOAT("zp_delay") : CVAR_GET_FLOAT("zp_gamemode_delay");

	   if (delayTime > 0)
	   {
		   sypb_gamemod.SetInt(2);
		   sypb_walkallow.SetInt(0);
		   g_DelayTimer = engine->GetTime() + delayTime + (CVAR_GET_FLOAT("mp_freezetime") / 2);
	   }
   }

   // SyPB Pro P.11
   Plugin_INI = FormatBuffer("%s/addons/amxmodx/configs/zombiehell.cfg", GetModName());
   if (TryFileOpen(Plugin_INI) && CVAR_GET_FLOAT("zh_zombie_maxslots") > 0)
   {
	   sypb_gamemod.SetInt(4);
	   sypb_walkallow.SetInt(0);

	   extern ConVar sypb_quota;
	   sypb_quota.SetInt(static_cast <int> (CVAR_GET_FLOAT("zh_zombie_maxslots")));
   }

   // SyPB Pro P.29 - Support CSBTE Final
   Plugin_INI = FormatBuffer("%s/addons/amxmodx/configs/bte_player.ini", GetModName());
   if (TryFileOpen(Plugin_INI))
   {
	   const int Const_GameModes = 12;
	   int bteGameModAi[Const_GameModes] =
	   {
		   0, 0, 1, 3, 0, 2, 2, 2, 2, 4, 2, 3
	   };//n, t, d, d, g, g, z, z, z, z, z, n

	   char *bteGameINI[Const_GameModes] =
	   {
		   "plugins-none",
		   "plugins-td",
		   "plugins-dm",
		   "plugins-dr",
		   "plugins-gd",
		   "plugins-ghost",
		   "plugins-zb1",
		   "plugins-zb3",
		   "plugins-zb4",
		   "plugins-ze",
		   "plugins-zse",
		   "plugins-npc"
	   };

	   for (int i = 0; i < Const_GameModes; i++)
	   {
		   if (TryFileOpen(FormatBuffer("%s/addons/amxmodx/configs/%s.ini", GetModName(), bteGameINI[i])))
		   {
			   sypb_gamemod.SetInt(bteGameModAi[i]);

			   if (bteGameModAi[i] == 2 && i != 5)
			   {
				   sypb_walkallow.SetInt(0);
				   g_DelayTimer = engine->GetTime() + 20.0f;
			   }

			   ServerPrint("*** CS:BTE [%s] - GameMod Setting [%d] ***", bteGameINI[i], bteGameModAi[i]);
			   ServerPrint("*** CS:BTE [%s] - GameMod Setting [%d] ***", bteGameINI[i], bteGameModAi[i]);
			   ServerPrint("*** CS:BTE [%s] - GameMod Setting [%d] ***", bteGameINI[i], bteGameModAi[i]);
			   if (i == 3 || i == 9 || i == 10)
			   {
				   ServerPrint("***** SyPB not support the mode now :( *****");
				   ServerPrint("***** SyPB not support the mode now :( *****");
				   ServerPrint("***** SyPB not support the mode now :( *****");
				   ServerPrint("***** SyPB not support the mode now :( *****");
				   ServerPrint("***** SyPB not support the mode now :( *****");
			   }

			   break;
		   }
	   }
   }

   // SyPB Pro P.25 - Zombie Ai
   if (GetGameMod() == 2 || GetGameMod() == 4)
	   g_mapType |= MAP_DE;

   g_exp.UpdateGlobalKnowledge (); // update experience data on round start

   // calculate the round mid/end in world time
   g_timeRoundStart = engine->GetTime () + engine->GetFreezeTime ();
   g_timeRoundMid = g_timeRoundStart + engine->GetRoundTime () * 60 / 2;
   g_timeRoundEnd = g_timeRoundStart + engine->GetRoundTime () * 60;
}
Exemple #8
0
void InitMapCounter ()
{
	mapWarnings = mapErrors = 0;
	ServerPrint ("======================\nSpawning entities...\n");
}
Exemple #9
0
void CheckNewVersion ()
#endif
{
	CURL *curl_handle;

	struct MemoryStruct chunk;

	chunk.memory=NULL; /* we expect realloc(NULL, size) to work */
	chunk.size = 0;    /* no data at this point */

	curl_global_init(CURL_GLOBAL_ALL);

	/* init the curl session */
	curl_handle = curl_easy_init();

	/* specify URL to get */
	curl_easy_setopt(curl_handle, CURLOPT_URL, "http://cleancodequake2.googlecode.com/svn/trunk/version.ver");

	/* send all data to this function  */
	curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, WriteMemoryCallback);

	/* we pass our 'chunk' struct to the callback function */
	curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, (void *)&chunk);

	/* some servers don't like requests that are made without a user-agent
	field, so we provide one */
	curl_easy_setopt(curl_handle, CURLOPT_USERAGENT, "libcurl-agent/1.0");

	/* get it! */
	curl_easy_perform(curl_handle);

	/* cleanup curl stuff */
	curl_easy_cleanup(curl_handle);

	/*
	* Now, our chunk.memory points to a memory block that is chunk.size
	* bytes big and contains the remote file.
	*
	* Do something nice with it!
	*
	* You should be aware of the fact that at this point we might have an
	* allocated data block, and nothing has yet deallocated that data. So when
	* you're done with it, you should free() it as a nice application.
	*/

	if(chunk.memory)
	{
		CParser Parser (chunk.memory, PSP_COMMENT_LINE);

		const char *token;

		String prefix;
		Parser.ParseToken (PSF_ALLOW_NEWLINES, &token);
		prefix = token;

		uint8 minor;
		uint16 major;
		uint32 build;
		Parser.ParseDataType<uint16> (PSF_ALLOW_NEWLINES, &major, 1);
		Parser.ParseDataType<uint8> (PSF_ALLOW_NEWLINES, &minor, 1);
		Parser.ParseDataType<uint32> (PSF_ALLOW_NEWLINES, &build, 1);

#if defined(WIN32) && !defined(NO_MULTITHREAD_VERSION_CHECK)
		VersionReturnance = CompareVersion (prefix.CString(), major, minor, build);
		VersionPrefix = prefix;
		VersionMinor = minor;
		VersionMajor = major;
		VersionBuild = build;
		VersionCheckReady = true;
#else
		if (CompareVersion (prefix.CString(), minor, major, build) == VERSION_NEWER)
			ServerPrintf (
			"==================================\n"
			"*****************************\n"
			"There is an update available for CleanCode!\n"
			"Please go to http://code.google.com/p/cleancodequake2 and update accordingly.\n"
			"Your version:   "CLEANCODE_VERSION_PRINT"\n"
			"Update version: "CLEANCODE_VERSION_PRINT"\n"
			"*****************************\n"
			"==================================\n",
			CLEANCODE_VERSION_PRINT_ARGS,
			prefix.CString(), major, minor, build);
		else
			ServerPrint ("Your version of CleanCode is up to date.\n");
#endif

		Mem_Free (chunk.memory);
	}

	/* we're done with libcurl, so clean it up */
	curl_global_cleanup();

	return 0;
}
Exemple #10
0
void CheckVersionReturnance ()
{
#if defined(WIN32) && !defined(NO_MULTITHREAD_VERSION_CHECK)
	if (VersionCheckReady)
	{
		if (!receiveBuffer.IsNullOrEmpty() && (receiveBuffer[0] != '<'))
		{
			CParser Parser (receiveBuffer.CString(), PSP_COMMENT_LINE);

			String prefix;
			Parser.ParseToken (PSF_ALLOW_NEWLINES, prefix);

			uint8 minor;
			uint16 major;
			uint32 build;
			Parser.ParseDataType<uint16> (PSF_ALLOW_NEWLINES, &major, 1);
			Parser.ParseDataType<uint8> (PSF_ALLOW_NEWLINES, &minor, 1);
			Parser.ParseDataType<uint32> (PSF_ALLOW_NEWLINES, &build, 1);

	#if defined(WIN32) && !defined(NO_MULTITHREAD_VERSION_CHECK)
			VersionReturnance = CompareVersion (prefix.CString(), major, minor, build);
			VersionPrefix = prefix;
			VersionMinor = minor;
			VersionMajor = major;
			VersionBuild = build;
			VersionCheckReady = true;
	#else
			if (CompareVersion (prefix.CString(), minor, major, build) == VERSION_NEWER)
				ServerPrintf (
				"==================================\n"
				"*****************************\n"
				"There is an update available for CleanCode!\n"
				"Please go to http://code.google.com/p/cleancodequake2 and update accordingly.\n"
				"Your version:   "CLEANCODE_VERSION_PRINT"\n"
				"Update version: "CLEANCODE_VERSION_PRINT"\n"
				"*****************************\n"
				"==================================\n",
				CLEANCODE_VERSION_PRINT_ARGS,
				prefix.CString(), major, minor, build);
			else
				ServerPrint ("Your version of CleanCode is up to date.\n");
	#endif
		}

		if (VersionReturnance == VERSION_NEWER)
			ServerPrintf (
			"==================================\n"
			"*****************************\n"
			"There is an update available for CleanCode!\n"
			"Please go to http://code.google.com/p/cleancodequake2 and update accordingly\nor run the auto updater."
			"Your version:   "CLEANCODE_VERSION_PRINT"\n"
			"Update version: "CLEANCODE_VERSION_PRINT"\n"
			"*****************************\n"
			"==================================\n",
			CLEANCODE_VERSION_PRINT_ARGS,
			VersionPrefix.CString(), VersionMajor, VersionMinor, VersionBuild);
		else
			ServerPrint ("Your version of CleanCode is up to date.\n");

		VersionReturnance = VERSION_SAME;
		VersionCheckReady = false;

		CloseHandle (hThread);

		hThread = NULL;
		iID = 0;
	}
#endif
}