Permalink
Browse files

Logging part 5

  • Loading branch information...
1 parent e823edd commit 044d0b0da0c4b877a33485e1ea7045f042d572c6 @TimePath TimePath committed with Kangz Jan 21, 2016
@@ -86,6 +86,7 @@ namespace VM {
QVM_COMMON_PARSE_SOURCE_FILE_AND_LINE,
};
+ /** @deprecated */
using PrintMsg = IPC::Message<IPC::Id<VM::QVM_COMMON, QVM_COMMON_PRINT>, std::string>;
using ErrorMsg = IPC::SyncMessage<
IPC::Message<IPC::Id<VM::QVM_COMMON, QVM_COMMON_ERROR>, std::string>
@@ -372,3 +372,22 @@ void operator delete(void* p) NOEXCEPT
free(p);
}
}
+
+/**
+ * Both client and server can use this, and it will
+ * do the appropriate things.
+ */
+void QDECL PRINTF_LIKE(2) Com_Error(errorParm_t code, const char *fmt, ...)
+{
+ char buf[4096];
+ va_list argptr;
+
+ va_start(argptr, fmt);
+ Q_vsnprintf(buf, sizeof(buf), fmt, argptr);
+ va_end(argptr);
+
+ if (code == errorParm_t::ERR_FATAL)
+ Sys::Error(buf);
+ else
+ Sys::Drop(buf);
+}
@@ -120,8 +120,6 @@ enum class MouseMode
SystemCursor, // The input is sent as positions, the cursor should be rendered by the system
};
-void trap_Print( const char *string );
-void NORETURN trap_Error( const char *string );
int trap_Milliseconds();
void trap_Cvar_Register( vmCvar_t *vmCvar, const char *varName, const char *defaultValue, int flags );
void trap_Cvar_Update( vmCvar_t *vmCvar );
@@ -114,30 +114,6 @@ void CIN_CloseAllVideos();
//============================================================================
-/*
-=============
-Com_Error
-
-Both client and server can use this, and it will
-do the appropriate things.
-=============
-*/
-// *INDENT-OFF*
-void QDECL PRINTF_LIKE(2) Com_Error( errorParm_t code, const char *fmt, ... )
-{
- char buf[ 4096 ];
- va_list argptr;
-
- va_start( argptr, fmt );
- Q_vsnprintf( buf, sizeof( buf ), fmt, argptr );
- va_end( argptr );
-
- if ( code == errorParm_t::ERR_FATAL )
- Sys::Error( buf );
- else
- Sys::Drop( buf );
-}
-
// *INDENT-OFF*
//bani - moved
void CL_ShutdownCGame();
@@ -507,16 +507,6 @@ namespace VM {
// Definition of some additional trap_* that are common to all VMs
-void trap_Print(const char *string)
-{
- VM::SendMsg<VM::PrintMsg>(string);
-}
-
-void NORETURN trap_Error(const char *string)
-{
- Sys::Drop(string);
-}
-
void trap_SendConsoleCommand(const char *text)
{
VM::SendMsg<VM::SendConsoleCommandMsg>(text);
@@ -141,13 +141,13 @@ void VM::VMHandleSyscall(uint32_t id, Util::Reader reader) {
break;
default:
- CG_Error("VMMain(): unknown cgame command %i", minor);
+ Com_Error(errorParm_t::ERR_DROP, "VMMain(): unknown cgame command %i", minor);
}
} else if (major < VM::LAST_COMMON_SYSCALL) {
VM::HandleCommonSyscall(major, minor, std::move(reader), VM::rootChannel);
} else {
- CG_Error("unhandled VM major syscall number %i", major);
+ Com_Error(errorParm_t::ERR_DROP, "unhandled VM major syscall number %i", major);
}
}
@@ -865,7 +865,7 @@ static void CG_SetBuildableLerpFrameAnimation( buildable_t buildable, lerpFrame_
if ( newAnimation < 0 || newAnimation >= MAX_BUILDABLE_ANIMATIONS )
{
- CG_Error( "Bad animation number: %i", newAnimation );
+ Com_Error(errorParm_t::ERR_DROP, "Bad animation number: %i", newAnimation );
}
if ( cg_buildables[ buildable ].md5 )
@@ -939,7 +939,7 @@ static void CG_InterpolateEntityPosition( centity_t *cent )
// a snapshot ahead of the current one
if ( cg.nextSnap == nullptr )
{
- CG_Error( "CG_InterpoateEntityPosition: cg.nextSnap == NULL" );
+ Com_Error(errorParm_t::ERR_DROP, "CG_InterpoateEntityPosition: cg.nextSnap == NULL" );
}
f = cg.frameInterpolation;
@@ -1193,7 +1193,7 @@ static void CG_AddCEntity( centity_t *cent )
switch ( cent->currentState.eType )
{
default:
- CG_Error( "Bad entity type: %s", Util::enum_str(cent->currentState.eType));
+ Com_Error(errorParm_t::ERR_DROP, "Bad entity type: %s", Util::enum_str(cent->currentState.eType));
case entityType_t::ET_INVISIBLE:
case entityType_t::ET_PUSHER:
@@ -122,7 +122,7 @@ static void CG_Obituary( entityState_t *ent )
if ( target < 0 || target >= MAX_CLIENTS )
{
- CG_Error( "CG_Obituary: target out of range" );
+ Com_Error(errorParm_t::ERR_DROP, "CG_Obituary: target out of range" );
}
ci = &cgs.clientinfo[ target ];
@@ -1348,7 +1348,7 @@ void CG_EntityEvent( centity_t *cent, vec3_t position )
break;
default:
- CG_Error( "Unknown event: %i", event );
+ Com_Error(errorParm_t::ERR_DROP, "Unknown event: %i", event );
}
}
@@ -1965,8 +1965,6 @@ const char *CG_ConfigString( int index );
const char *CG_Argv( int arg );
const char *CG_Args();
-void QDECL NORETURN CG_Error( const char *msg, ... ) PRINTF_LIKE(1);
-
void CG_StartMusic();
void CG_NotifyHooks();
View
@@ -765,32 +765,6 @@ void CG_AddNotifyText()
cg.numConsoleLines++;
}
-void QDECL PRINTF_LIKE(1) NORETURN CG_Error( const char *msg, ... )
-{
- va_list argptr;
- char text[ 1024 ];
-
- va_start( argptr, msg );
- Q_vsnprintf( text, sizeof( text ), msg, argptr );
- va_end( argptr );
-
- trap_Error( text );
-}
-
-void QDECL PRINTF_LIKE(2) NORETURN Com_Error( errorParm_t level, const char *error, ... )
-{
- va_list argptr;
- char text[ 1024 ];
-
- Q_UNUSED(level);
-
- va_start( argptr, error );
- Q_vsnprintf( text, sizeof( text ), error, argptr );
- va_end( argptr );
-
- trap_Error( text );
-}
-
/*
================
CG_Argv
@@ -1341,7 +1315,7 @@ static void CG_RegisterGraphics()
if ( cgs.numInlineModels > MAX_SUBMODELS )
{
- CG_Error( "MAX_SUBMODELS (%d) exceeded by %d", MAX_SUBMODELS, cgs.numInlineModels - MAX_SUBMODELS );
+ Com_Error(errorParm_t::ERR_DROP, "MAX_SUBMODELS (%d) exceeded by %d", MAX_SUBMODELS, cgs.numInlineModels - MAX_SUBMODELS );
}
for ( i = 1; i < cgs.numInlineModels; i++ )
@@ -1538,7 +1512,7 @@ const char *CG_ConfigString( int index )
{
if ( index < 0 || index >= MAX_CONFIGSTRINGS )
{
- CG_Error( "CG_ConfigString: bad index: %i", index );
+ Com_Error(errorParm_t::ERR_DROP, "CG_ConfigString: bad index: %i", index );
}
return cgs.gameState[index].c_str();
@@ -1657,7 +1631,7 @@ void CG_Init( int serverMessageNum, int clientNum, glconfig_t gl, GameStateCSs g
s = CG_ConfigString( CS_GAME_VERSION );
// if( strcmp( s, GAME_VERSION ) )
-// CG_Error( "Client/Server game mismatch: %s/%s", GAME_VERSION, s );
+// Com_Error(errorParm_t::ERR_DROP, "Client/Server game mismatch: %s/%s", GAME_VERSION, s );
s = CG_ConfigString( CS_LEVEL_START_TIME );
cgs.levelStartTime = atoi( s );
@@ -70,7 +70,7 @@ void CG_FreeMarkPoly( markPoly_t *le )
{
if ( !le->prevMark )
{
- CG_Error( "CG_FreeLocalEntity: not active" );
+ Com_Error(errorParm_t::ERR_DROP, "CG_FreeLocalEntity: not active" );
}
// remove from the doubly linked active list
@@ -162,7 +162,7 @@ void CG_ImpactMark( qhandle_t markShader, const vec3_t origin, const vec3_t dir,
if ( radius <= 0 )
{
- CG_Error( "CG_ImpactMark called with <= 0 radius" );
+ Com_Error(errorParm_t::ERR_DROP, "CG_ImpactMark called with <= 0 radius" );
}
//if ( markTotal >= MAX_MARK_POLYS ) {
@@ -92,7 +92,7 @@ sfxHandle_t CG_CustomSound( int clientNum, const char *soundName )
}
}
- CG_Error( "Unknown custom sound: %s", soundName );
+ Com_Error(errorParm_t::ERR_DROP, "Unknown custom sound: %s", soundName );
return 0;
}
@@ -1331,7 +1331,7 @@ static void CG_LoadClientInfo( clientInfo_t *ci )
if ( !CG_RegisterClientModelname( ci, ci->modelName, ci->skinName ) )
{
- CG_Error( "CG_RegisterClientModelname( %s, %s ) failed", ci->modelName, ci->skinName );
+ Com_Error(errorParm_t::ERR_DROP, "CG_RegisterClientModelname( %s, %s ) failed", ci->modelName, ci->skinName );
}
// sounds
@@ -1708,7 +1708,7 @@ static void CG_SetLerpFrameAnimation( clientInfo_t *ci, lerpFrame_t *lf, int new
if ( newAnimation < 0 || newAnimation >= MAX_PLAYER_TOTALANIMATIONS )
{
- CG_Error( "Bad animation number: %i", newAnimation );
+ Com_Error(errorParm_t::ERR_DROP, "Bad animation number: %i", newAnimation );
}
anim = &ci->animations[ newAnimation ];
@@ -2214,7 +2214,7 @@ static void CG_PlayerAngles( centity_t *cent, const vec3_t srcAngles,
if ( dir < 0 || dir > 7 )
{
- CG_Error( "Bad player movement angle" );
+ Com_Error(errorParm_t::ERR_DROP, "Bad player movement angle" );
}
}
@@ -2486,7 +2486,7 @@ static void CG_PlayerNonSegAxis( centity_t *cent, vec3_t srcAngles, vec3_t nonSe
if ( dir < 0 || dir > 7 )
{
- CG_Error( "Bad player movement angle" );
+ Com_Error(errorParm_t::ERR_DROP, "Bad player movement angle" );
}
}
@@ -2557,7 +2557,7 @@ static void CG_JetpackAnimation( centity_t *cent, int *old, int *now, float *bac
lf->animationNumber = cent->jetpackAnim;
if( cent->jetpackAnim < 0 || cent->jetpackAnim >= MAX_JETPACK_ANIMATIONS )
- CG_Error( "Bad animation number: %i", cent->jetpackAnim );
+ Com_Error(errorParm_t::ERR_DROP, "Bad animation number: %i", cent->jetpackAnim );
if( JETPACK_USES_SKELETAL_ANIMATION )
@@ -3155,7 +3155,7 @@ void CG_Player( centity_t *cent )
if ( clientNum < 0 || clientNum >= MAX_CLIENTS )
{
- CG_Error( "Bad clientNum on player entity" );
+ Com_Error(errorParm_t::ERR_DROP, "Bad clientNum on player entity" );
}
ci = &cgs.clientinfo[ clientNum ];
@@ -3690,7 +3690,7 @@ void CG_Corpse( centity_t *cent )
if ( corpseNum < 0 || corpseNum >= MAX_CLIENTS )
{
- CG_Error( "Bad corpseNum on corpse entity: %d", corpseNum );
+ Com_Error(errorParm_t::ERR_DROP, "Bad corpseNum on corpse entity: %d", corpseNum );
}
ci = &cgs.corpseinfo[ corpseNum ];
@@ -952,7 +952,7 @@ class WeaponIconElement : public HudElement
if ( weapon < WP_NONE || weapon >= WP_NUM_WEAPONS )
{
- CG_Error( "CG_DrawWeaponIcon: weapon out of range: %d", weapon );
+ Com_Error(errorParm_t::ERR_DROP, "CG_DrawWeaponIcon: weapon out of range: %d", weapon );
}
if ( !cg_weapons[ weapon ].registered )
@@ -146,12 +146,12 @@ static void CG_TransitionSnapshot()
if ( !cg.snap )
{
- CG_Error( "CG_TransitionSnapshot: NULL cg.snap" );
+ Com_Error(errorParm_t::ERR_DROP, "CG_TransitionSnapshot: NULL cg.snap" );
}
if ( !cg.nextSnap )
{
- CG_Error( "CG_TransitionSnapshot: NULL cg.nextSnap" );
+ Com_Error(errorParm_t::ERR_DROP, "CG_TransitionSnapshot: NULL cg.nextSnap" );
}
// execute any server string commands before transitioning entities
@@ -379,7 +379,7 @@ void CG_ProcessSnapshots()
if ( n < cg.latestSnapshotNum )
{
// this should never happen
- CG_Error( "CG_ProcessSnapshots: n (%i) < cg.latestSnapshotNum (%i)", n, cg.latestSnapshotNum );
+ Com_Error(errorParm_t::ERR_DROP, "CG_ProcessSnapshots: n (%i) < cg.latestSnapshotNum (%i)", n, cg.latestSnapshotNum );
}
cg.latestSnapshotNum = n;
@@ -428,7 +428,7 @@ void CG_ProcessSnapshots()
// if time went backwards, we have a level restart
if ( cg.nextSnap->serverTime < cg.snap->serverTime )
{
- CG_Error( "CG_ProcessSnapshots: Server time went backwards" );
+ Com_Error(errorParm_t::ERR_DROP, "CG_ProcessSnapshots: Server time went backwards" );
}
}
@@ -446,7 +446,7 @@ void CG_ProcessSnapshots()
// assert our valid conditions upon exiting
if ( cg.snap == nullptr )
{
- CG_Error( "CG_ProcessSnapshots: cg.snap == NULL" );
+ Com_Error(errorParm_t::ERR_DROP, "CG_ProcessSnapshots: cg.snap == NULL" );
}
if ( cg.time < cg.snap->serverTime )
@@ -457,6 +457,6 @@ void CG_ProcessSnapshots()
if ( cg.nextSnap != nullptr && cg.nextSnap->serverTime <= cg.time )
{
- CG_Error( "CG_ProcessSnapshots: cg.nextSnap->serverTime <= cg.time" );
+ Com_Error(errorParm_t::ERR_DROP, "CG_ProcessSnapshots: cg.nextSnap->serverTime <= cg.time" );
}
}
Oops, something went wrong.

0 comments on commit 044d0b0

Please sign in to comment.