View Single Post
Re: Post your funny code comments!
Old
  (#2)
Pierre-Marie Baty
Roi de France
 
Pierre-Marie Baty's Avatar
 
Status: Offline
Posts: 5,049
Join Date: Nov 2003
Location: 46°43'60N 0°43'0W 0.187A
Default Re: Post your funny code comments! - 08-01-2004

funny thing when you're two coders on the same project and the only way you communicate is through code comments
Code:
   // is the bot controlled by the player ? (for debugging)
   if (pPlayer->Bot.is_controlled)
   {
	  BotIsBewitched (pPlayer); // OMG, this is witchery !
	  return; // let the player steer this bot
   }
Code:
	  BotWalkPath (pBot); // walk the path, Neo.
^^ hinting Stefan on this one
Code:
   // is our bot's goal to reach a rescue zone ?
   if (pBot->bot_goal & BOT_GOAL_REACHSAFETYZONE)
   {
	  // bot already knows where the site to reach is (v_goal), so first off it needs to get
	  // there, and then... uhhh... well... well then, he has won =)
Code:
	  // is bot NOT finding a path yet NOR walking it ?
	  if ((pBot->bot_task != BOT_TASK_FINDPATH) && (pBot->bot_task != BOT_TASK_WALKPATH))
	  {
		 // grmbl, this lazy bot is doing nothing. Is it far from the site ?
Code:
   // else do we want to kick one bot ?
   else if (strcmp (pcmd, "kick") == 0)
   {
	  // cycle through all bot slots and kick the first we find
	  for (bot_index = 0; bot_index < RACC_MAX_CLIENTS; bot_index++)
		 if (IsValidPlayer (&players[bot_index]) && players[bot_index].is_racc_bot)
		 {
			sprintf (server_cmd, "kick \"%s\"\n", players[bot_index].connection_name); // build the kick command string
			SERVER_COMMAND (server_cmd); // boot the bot out
			server.bot_check_time = *server.time + 0.5; // delay a while before checking the bot counts
			break; // stop looping (don't kick the whole population, you idiot)
		 }
   }
Code:
   // else does the bot want to laugh at a dead enemy ?
   else if (pPlayer->Bot.BotChat.bot_saytext == BOT_SAYTEXT_LAUGH)
   {
	  pPlayer->Bot.BotChat.bot_saytext = 0;
	  if (&players[pPlayer->Bot.victim_index] == pPlayer)
		 return; // don't laugh at self, eh...
the one belows come from a complicated function Cheeseh helped me to work out
Code:
	  // else segment is neither horizontal nor vertical, but just bent (grr)
	  else
	  {
		 // we have to compute the bastard's equation.
Code:
void pfnClientPrintf (edict_t *pEdict, PRINT_TYPE ptype, const char *szMsg)
{
   // this function prints the text message string pointed to by szMsg by the client side of
   // the client entity pointed to by pEntity, in a manner depending of ptype (print_console,
   // print_center or print_chat). Be certain never to try to feed a bot with this function,
   // as it will crash your server. Why would you, anyway ? bots have no client DLL as far as
   // we know, right ? But since stupidity rules this world, we do a preventive check :)
   if ((pEdict->v.flags & FL_FAKECLIENT) || players[ENTINDEX (pEdict) - 1].is_racc_bot)
	  return; // disallow client printings for bots
   (*g_engfuncs.pfnClientPrintf) (pEdict, ptype, szMsg);
}
here's a snippet of a long comment in pfnClientCommand()
Code:
   // make the server crash. Since hordes of uncautious, not to say stupid, programmers don't
   // even imagine some players on their servers could be bots, this check is performed less than
   // sometimes actually by their side, that's why we strongly recommend to check it here too. In
Code:
				  pBot->bot_goal |= BOT_GOAL_PLANTBOMB; // bot's goal is to blow stuff up, haha!
and I kept the best one for the end
Code:
bool IsMyBirthday (void)
{
   // hahaha :D big grin to @$3.1415rin for the idea !!!
 time_t now = time (NULL);
 tm *tm_now = localtime (&now);
 
   // is it my birthday ?
 if ((tm_now->tm_mon == 1) && (tm_now->tm_mday == 28))
  return (TRUE); // w00t, today is 28 february, it's my birthday ! :D
   // bah crap
   return (FALSE);
}



RACC home - Bots-United: beer, babies & bots (especially the latter)
"Learn to think by yourself, else others will do it for you."
  
Reply With Quote