From bf37df807b2bccfd6ba5bde0d2f1ddd902cbc05d Mon Sep 17 00:00:00 2001 From: Walter Julius Hennecke Date: Sun, 11 Nov 2012 00:36:17 +0100 Subject: [PATCH] see description ... * Fixed repair function for func_breakables * Added possibility to visualize traces (add flag 2 to value of g_developer) * Removed debug message for func_breakables --- code/cgame/cg_event.c | 4 ++++ code/game/bg_public.h | 2 ++ code/game/g_combat.c | 4 ---- code/game/g_syscalls.c | 16 +++++++++++----- code/game/g_weapon.c | 9 ++++++--- 5 files changed, 23 insertions(+), 12 deletions(-) diff --git a/code/cgame/cg_event.c b/code/cgame/cg_event.c index fdbdcf8..ba34923 100644 --- a/code/cgame/cg_event.c +++ b/code/cgame/cg_event.c @@ -1838,6 +1838,10 @@ case EV_SHAKE_SOUND: CG_Borg_Bolt_static( cent ); break; + case EV_DEBUG_TRACE: + FX_AddLine(cent->currentState.origin, cent->currentState.origin2, 0.5, 0.5, 0.5, 1.0, 1.0, 1000, cgs.media.laserShader); + break; + // Default default: diff --git a/code/game/bg_public.h b/code/game/bg_public.h index 0c37fd8..080ee34 100644 --- a/code/game/bg_public.h +++ b/code/game/bg_public.h @@ -798,6 +798,8 @@ typedef enum { EV_STASIS_DOOR_OPENING, EV_STASIS_DOOR_CLOSING, + + EV_DEBUG_TRACE } entity_event_t; //RPG-X: J2J - Moved animation enum list so that the string list can see it, Note special case for cg_players.c. diff --git a/code/game/g_combat.c b/code/game/g_combat.c index 459cf2f..93ac6d7 100644 --- a/code/game/g_combat.c +++ b/code/game/g_combat.c @@ -1841,10 +1841,6 @@ void G_Repair(gentity_t *ent, gentity_t *tr_ent, float rate) { } } - DEVELOPER( - G_Printf("G_Repair: target=%d, goodDist=%f, curDist=%f\n", tr_ent-g_entities, 80+max, distance); - ); - if(distance > 80 + max) { return; } diff --git a/code/game/g_syscalls.c b/code/game/g_syscalls.c index ebbdd3e..529c2cf 100644 --- a/code/game/g_syscalls.c +++ b/code/game/g_syscalls.c @@ -132,6 +132,12 @@ void trap_SetBrushModel( gentity_t *ent, const char *name ) { void trap_Trace( trace_t *results, const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, int passEntityNum, int contentmask ) { syscall( G_TRACE, results, start, mins, maxs, end, passEntityNum, contentmask ); + if(g_developer.integer & 2) { // Debug trace + vec3_t s; + VectorCopy(start, s); + gentity_t* tmp = G_TempEntity(s, EV_DEBUG_TRACE); + VectorCopy(end, tmp->s.origin2); + } } int trap_PointContents( const vec3_t point, int passEntityNum ) { @@ -140,11 +146,11 @@ int trap_PointContents( const vec3_t point, int passEntityNum ) { qboolean trap_InPVS( const vec3_t p1, const vec3_t p2 ) { - return syscall( G_IN_PVS, p1, p2 ); + return (qboolean)syscall( G_IN_PVS, p1, p2 ); } qboolean trap_InPVSIgnorePortals( const vec3_t p1, const vec3_t p2 ) { - return syscall( G_IN_PVS_IGNORE_PORTALS, p1, p2 ); + return (qboolean)syscall( G_IN_PVS_IGNORE_PORTALS, p1, p2 ); } void trap_AdjustAreaPortalState( gentity_t *ent, qboolean open ) { @@ -152,7 +158,7 @@ void trap_AdjustAreaPortalState( gentity_t *ent, qboolean open ) { } qboolean trap_AreasConnected( int area1, int area2 ) { - return syscall( G_AREAS_CONNECTED, area1, area2 ); + return (qboolean)syscall( G_AREAS_CONNECTED, area1, area2 ); } void trap_LinkEntity( gentity_t *ent ) { @@ -169,7 +175,7 @@ int trap_EntitiesInBox( const vec3_t mins, const vec3_t maxs, int *list, int max } qboolean trap_EntityContact( const vec3_t mins, const vec3_t maxs, const gentity_t *ent ) { - return syscall( G_ENTITY_CONTACT, mins, maxs, ent ); + return (qboolean)syscall( G_ENTITY_CONTACT, mins, maxs, ent ); } int trap_BotAllocateClient( void ) { @@ -185,7 +191,7 @@ void trap_GetUsercmd( int clientNum, usercmd_t *cmd ) { } qboolean trap_GetEntityToken( char *buffer, int bufferSize ) { - return syscall( G_GET_ENTITY_TOKEN, buffer, bufferSize ); + return (qboolean)syscall( G_GET_ENTITY_TOKEN, buffer, bufferSize ); } int trap_DebugPolygonCreate(int color, int numPoints, vec3_t *points) { diff --git a/code/game/g_weapon.c b/code/game/g_weapon.c index 0e0471c..44bf0d3 100644 --- a/code/game/g_weapon.c +++ b/code/game/g_weapon.c @@ -114,7 +114,8 @@ static void WP_FireHyperspanner(gentity_t *ent, qboolean alt_fire) { gentity_t *validEnts[MAX_GENTITIES]; int count = 0; int i, nearest = -1, nearestd = 512; - vec3_t dVec; + vec3_t dVec, end; + vec3_t mins = { -40, -40, -40 }, maxs = { 40, 40, 40 }; /* find all vlaid entities in range */ count = G_RadiusListOfType("func_breakable", ent->s.origin, 512, NULL, validEnts); @@ -122,9 +123,11 @@ static void WP_FireHyperspanner(gentity_t *ent, qboolean alt_fire) { if(count) { trace_t tr; for(i = 0; i < count; i++) { + VectorSubtract(ent->r.currentOrigin, validEnts[i]->s.origin, dVec); + VectorMA(validEnts[i]->s.origin, 1024, dVec, end); //G_Printf("Checking entity: %d\n", i); - trap_Trace(&tr, ent->s.origin, NULL, NULL, validEnts[i]->s.origin, ent->s.number, MASK_SHOT); - if(tr.entityNum != validEnts[i]->s.number && tr.entityNum != ENTITYNUM_WORLD) { + trap_Trace(&tr, validEnts[i]->s.origin, mins, maxs, end, validEnts[i]->s.number, MASK_SHOT); + if(tr.entityNum != ent->s.number) { continue; } //G_Printf("Nothing is blocking view ...\n");