Permalink
Browse files

Logging part 4

  • Loading branch information...
1 parent 2bf1076 commit e823edda1a5ffb5b0b70d21945cf2a2963d2e688 @TimePath TimePath committed with Kangz Jan 21, 2016
@@ -125,14 +125,14 @@ static void CG_LoadArenasFromFile( char *filename )
if ( !f )
{
- trap_Print( va( "%sfile not found: %s\n", Color::CString( Color::Red ), filename ) );
+ Log::Warn( "%sfile not found: %s", Color::CString( Color::Red ), filename );
return;
}
if ( len >= MAX_ARENAS_TEXT )
{
- trap_Print( va( "%sfile too large: %s is %i, max allowed is %i\n",
- Color::CString( Color::Red ), filename, len, MAX_ARENAS_TEXT ) );
+ Log::Warn( "%sfile too large: %s is %i, max allowed is %i",
+ Color::CString( Color::Red ), filename, len, MAX_ARENAS_TEXT );
trap_FS_FCloseFile( f );
return;
}
@@ -186,7 +186,7 @@ void CG_LoadArenas()
CG_LoadArenasFromFile( filename );
}
- trap_Print( va( S_SKIPNOTIFY "%i arenas parsed\n", cg_numArenas ) );
+ Log::Warn( S_SKIPNOTIFY "%i arenas parsed\n", cg_numArenas );
for ( n = 0; n < cg_numArenas; n++ )
{
@@ -1527,10 +1527,10 @@ bool G_admin_ban_check( gentity_t *ent, char *reason, int rlen )
// and don't fill the console
else if ( ban->warnCount < 10 )
{
- trap_Print( va( "%s%s\n", warningMessage,
+ Log::Warn( "%s%s\n", warningMessage,
ban->warnCount + 1 == 10 ?
"^7 — future messages for this ban will be suppressed" :
- "" ) );
+ "" );
}
return true;
@@ -220,7 +220,7 @@ bool G_BotAdd( char *name, team_t team, int skill, const char *behavior )
if ( !navMeshLoaded )
{
- trap_Print( "No Navigation Mesh file is available for this map\n" );
+ Log::Warn( "No Navigation Mesh file is available for this map" );
return false;
}
@@ -229,7 +229,7 @@ bool G_BotAdd( char *name, team_t team, int skill, const char *behavior )
if ( clientNum < 0 )
{
- trap_Print( "no more slots for bot\n" );
+ Log::Warn( "no more slots for bot" );
return false;
}
bot = &g_entities[ clientNum ];
@@ -267,7 +267,7 @@ bool G_BotAdd( char *name, team_t team, int skill, const char *behavior )
if ( ( s = ClientBotConnect( clientNum, true, team ) ) )
{
// won't let us join
- trap_Print( s );
+ Log::Warn( s );
okay = false;
}
@@ -295,7 +295,7 @@ void G_BotDel( int clientNum )
if ( !( bot->r.svFlags & SVF_BOT ) || !bot->botMind )
{
- trap_Print( va( "'^7%s^7' is not a bot\n", bot->client->pers.netname ) );
+ Log::Warn( "'^7%s^7' is not a bot\n", bot->client->pers.netname );
return;
}
@@ -1254,7 +1254,7 @@ AINodeStatus_t BotActionBuy( gentity_t *self, AIGenericNode_t *node )
if ( weapon < WP_NONE || weapon >= WP_NUM_WEAPONS )
{
- BotDPrintf( "^3WARNING: parameter 1 to action buy out of range\n" );
+ Log::Warn("parameter 1 to action buy out of range" );
weapon = WP_NONE;
}
@@ -1267,7 +1267,7 @@ AINodeStatus_t BotActionBuy( gentity_t *self, AIGenericNode_t *node )
if ( upgrades[ numUpgrades ] <= UP_NONE || upgrades[ numUpgrades ] >= UP_NUM_UPGRADES )
{
- BotDPrintf( "^3WARNING: parameter %d to action buy out of range\n", i + 1 );
+ Log::Warn("parameter %d to action buy out of range", i + 1 );
continue;
}
@@ -435,7 +435,7 @@ bool BotShouldJump( gentity_t *self, gentity_t *blocker, const vec3_t dir )
playerMins[2] += STEPSIZE;
playerMaxs[2] += STEPSIZE;
- //trap_Print(vtos(self->movedir));
+ //Log::Debug(vtos(self->movedir));
VectorMA( self->s.origin, TRACE_LENGTH, dir, end );
//make sure we are moving into a block
@@ -30,13 +30,13 @@ static bool expectToken( const char *s, pc_token_list **list, bool next )
if ( !current )
{
- BotError( "Expected token %s but found end of file\n", s );
+ Log::Warn( "Expected token %s but found end of file", s );
return false;
}
if ( Q_stricmp( current->token.string, s ) != 0 )
{
- BotError( "Expected token %s but found %s on line %d\n", s, current->token.string, current->token.line );
+ Log::Warn( "Expected token %s but found %s on line %d", s, current->token.string, current->token.line );
return false;
}
@@ -496,7 +496,7 @@ static AIValue_t *parseFunctionParameters( pc_token_list **list, int *nparams, i
if ( !parenEnd )
{
- BotError( "could not find matching ')' for '(' on line %d", parenBegin->token.line );
+ Log::Warn( "could not find matching ')' for '(' on line %d", parenBegin->token.line );
*list = parenBegin->next;
return nullptr;
}
@@ -512,7 +512,7 @@ static AIValue_t *parseFunctionParameters( pc_token_list **list, int *nparams, i
}
else if ( parse->token.string[ 0 ] != ',' )
{
- BotError( "Invalid token %s in parameter list on line %d\n", parse->token.string, parse->token.line );
+ Log::Warn( "Invalid token %s in parameter list on line %d", parse->token.string, parse->token.line );
*list = parenEnd->next; // skip invalid function expression
return nullptr;
}
@@ -522,14 +522,14 @@ static AIValue_t *parseFunctionParameters( pc_token_list **list, int *nparams, i
// warn if too many or too few parameters
if ( numParams < minparams )
{
- BotError( "too few parameters for %s on line %d\n", current->token.string, current->token.line );
+ Log::Warn( "too few parameters for %s on line %d", current->token.string, current->token.line );
*list = parenEnd->next;
return nullptr;
}
if ( numParams > maxparams )
{
- BotError( "too many parameters for %s on line %d\n", current->token.string, current->token.line );
+ Log::Warn( "too many parameters for %s on line %d", current->token.string, current->token.line );
*list = parenEnd->next;
return nullptr;
}
@@ -571,7 +571,7 @@ static AIValueFunc_t *newValueFunc( pc_token_list **list )
if ( !f )
{
- BotError( "Unknown function: %s on line %d\n", current->token.string, current->token.line );
+ Log::Warn( "Unknown function: %s on line %d", current->token.string, current->token.line );
*list = current->next;
return nullptr;
}
@@ -634,7 +634,7 @@ static AIExpType_t *ReadConditionExpression( pc_token_list **list, AIOpType_t op
if ( !*list )
{
- BotError( "Unexpected end of file\n" );
+ Log::Warn( "Unexpected end of file" );
return nullptr;
}
@@ -657,7 +657,7 @@ static AIExpType_t *ReadConditionExpression( pc_token_list **list, AIOpType_t op
if ( !t1 )
{
- BotError( "Missing right operand for %s on line %d\n", opTypeToString( op ), prev->token.line );
+ Log::Warn( "Missing right operand for %s on line %d", opTypeToString( op ), prev->token.line );
FreeExpression( t );
FreeOp( exp );
return nullptr;
@@ -685,7 +685,7 @@ static AIExpType_t *Primary( pc_token_list **list )
if ( !t )
{
- BotError( "Missing right operand for %s on line %d\n", opTypeToString( op->opType ), current->token.line );
+ Log::Warn( "Missing right operand for %s on line %d", opTypeToString( op->opType ), current->token.line );
FreeOp( op );
return nullptr;
}
@@ -711,7 +711,7 @@ static AIExpType_t *Primary( pc_token_list **list )
}
else
{
- BotError( "token %s on line %d is not valid\n", current->token.string, current->token.line );
+ Log::Warn( "token %s on line %d is not valid", current->token.string, current->token.line );
}
return tree;
}
@@ -760,7 +760,7 @@ AIGenericNode_t *ReadConditionNode( pc_token_list **tokenlist )
if ( !current )
{
*tokenlist = current;
- BotError( "Unexpected end of file\n" );
+ Log::Warn( "Unexpected end of file" );
FreeConditionNode( condition );
return nullptr;
}
@@ -785,7 +785,7 @@ AIGenericNode_t *ReadConditionNode( pc_token_list **tokenlist )
if ( !condition->child )
{
- BotError( "Failed to parse child node of condition on line %d\n", (*tokenlist)->token.line );
+ Log::Warn( "Failed to parse child node of condition on line %d", (*tokenlist)->token.line );
*tokenlist = current;
FreeConditionNode( condition );
return nullptr;
@@ -830,7 +830,7 @@ AIGenericNode_t *ReadDecoratorNode( pc_token_list **list )
if ( !current )
{
- BotError( "Unexpected end of file after line %d\n", (*list)->token.line );
+ Log::Warn( "Unexpected end of file after line %d", (*list)->token.line );
*list = current;
return nullptr;
}
@@ -839,7 +839,7 @@ AIGenericNode_t *ReadDecoratorNode( pc_token_list **list )
if ( !dec )
{
- BotError( "%s on line %d is not a valid decorator\n", current->token.string, current->token.line );
+ Log::Warn( "%s on line %d is not a valid decorator", current->token.string, current->token.line );
*list = current;
return nullptr;
}
@@ -877,7 +877,7 @@ AIGenericNode_t *ReadDecoratorNode( pc_token_list **list )
if ( !node.child )
{
- BotError( "Failed to parse child node of decorator on line %d\n", (*list)->token.line );
+ Log::Warn( "Failed to parse child node of decorator on line %d", (*list)->token.line );
*list = current;
return nullptr;
}
@@ -957,15 +957,15 @@ AIGenericNode_t *ReadActionNode( pc_token_list **tokenlist )
if ( !current )
{
- BotError( "Unexpected end of file after line %d\n", (*tokenlist)->token.line );
+ Log::Warn( "Unexpected end of file after line %d", (*tokenlist)->token.line );
return nullptr;
}
action = (struct AIActionMap_s*) bsearch( current->token.string, AIActions, ARRAY_LEN( AIActions ), sizeof( *AIActions ), cmdcmp );
if ( !action )
{
- BotError( "%s on line %d is not a valid action\n", current->token.string, current->token.line );
+ Log::Warn( "%s on line %d is not a valid action", current->token.string, current->token.line );
*tokenlist = current;
return nullptr;
}
@@ -1077,7 +1077,7 @@ AIGenericNode_t *ReadNodeList( pc_token_list **tokenlist )
if ( node && list->numNodes >= MAX_NODE_LIST )
{
- BotError( "Max selector children limit exceeded at line %d\n", (*tokenlist)->token.line );
+ Log::Warn( "Max selector children limit exceeded at line %d", (*tokenlist)->token.line );
FreeNode( node );
FreeNodeList( list );
*tokenlist = current;
@@ -1123,7 +1123,7 @@ AIGenericNode_t *ReadBehaviorTreeInclude( pc_token_list **tokenlist )
if ( !current )
{
- BotError( "Unexpected end of file after line %d\n", first->token.line );
+ Log::Warn( "Unexpected end of file after line %d", first->token.line );
*tokenlist = current;
return nullptr;
}
@@ -1132,14 +1132,14 @@ AIGenericNode_t *ReadBehaviorTreeInclude( pc_token_list **tokenlist )
if ( !behavior )
{
- BotError( "Could not load behavior %s on line %d\n", current->token.string, current->token.line );
+ Log::Warn( "Could not load behavior %s on line %d", current->token.string, current->token.line );
*tokenlist = current->next;
return nullptr;
}
if ( !behavior->root )
{
- BotError( "Recursive behavior %s on line %d\n", current->token.string, current->token.line );
+ Log::Warn( "Recursive behavior %s on line %d", current->token.string, current->token.line );
*tokenlist = current->next;
return nullptr;
}
@@ -1195,7 +1195,7 @@ AIGenericNode_t *ReadNode( pc_token_list **tokenlist )
}
else
{
- BotError( "Invalid token on line %d found: %s\n", current->token.line, current->token.string );
+ Log::Warn( "Invalid token on line %d found: %s", current->token.line, current->token.string );
node = nullptr;
}
@@ -23,36 +23,6 @@
#include "sg_bot_util.h"
#include "CBSE.h"
-void BotDPrintf( const char* fmt, ... )
-{
- if ( g_bot_debug.integer )
- {
- va_list argptr;
- char text[ 1024 ];
-
- va_start( argptr, fmt );
- Q_vsnprintf( text, sizeof( text ), fmt, argptr );
- va_end( argptr );
-
- trap_Print( text );
- }
-}
-
-void BotError( const char* fmt, ... )
-{
- va_list argptr;
- size_t len;
- char text[ 1024 ] = "^1ERROR: ";
-
- len = strlen( text );
-
- va_start( argptr, fmt );
- Q_vsnprintf( text + len, sizeof( text ) - len, fmt, argptr );
- va_end( argptr );
-
- trap_Print( text );
-}
-
/*
= *======================
Scoring functions for logic
@@ -27,8 +27,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include "sg_bot.h"
//g_bot.c
-void BotError( const char* fmt, ... ) PRINTF_LIKE(1);
-void BotDPrintf( const char* fmt, ... ) PRINTF_LIKE(1);
bool PlayersBehindBotInSpawnQueue( gentity_t *self );
void BotSetSkillLevel( gentity_t *self, int skill );

0 comments on commit e823edd

Please sign in to comment.