Add new cvar `com_showTracers` to aid in debugging tracelines.
This commit is contained in:
parent
a79ffd77b0
commit
dd492c7822
|
@ -130,6 +130,40 @@ EV_Shake(void)
|
|||
pSeat->m_flShakeTime = pSeat->m_flShakeDuration;
|
||||
}
|
||||
|
||||
void
|
||||
EV_TraceDebug(void)
|
||||
{
|
||||
static void EV_TraceDebug_Draw(void) {
|
||||
R_BeginPolygon("", 0, 0);
|
||||
R_PolygonVertex(self.origin, [0,1], [0,1,0], 1.0f);
|
||||
R_PolygonVertex(self.angles, [1,1], [1,0,0], 1.0f);
|
||||
R_EndPolygon();
|
||||
}
|
||||
static void EV_TraceDebug_Destroy(void) {
|
||||
remove(self);
|
||||
}
|
||||
|
||||
vector startOrg, endOrg;
|
||||
entity traceRep;
|
||||
|
||||
startOrg[0] = readcoord();
|
||||
startOrg[1] = readcoord();
|
||||
startOrg[2] = readcoord();
|
||||
|
||||
endOrg[0] = readcoord();
|
||||
endOrg[1] = readcoord();
|
||||
endOrg[2] = readcoord();
|
||||
|
||||
traceRep = spawn();
|
||||
traceRep.predraw = EV_TraceDebug_Draw;
|
||||
traceRep.drawmask = MASK_ENGINE;
|
||||
traceRep.think = EV_TraceDebug_Destroy;
|
||||
traceRep.nextthink = time + 4.0f;
|
||||
|
||||
traceRep.origin = startOrg;
|
||||
traceRep.angles = endOrg;
|
||||
}
|
||||
|
||||
void
|
||||
Event_Parse(float type)
|
||||
{
|
||||
|
@ -196,6 +230,9 @@ Event_Parse(float type)
|
|||
case EV_BREAKMODEL:
|
||||
BreakModel_Receive();
|
||||
break;
|
||||
case EV_TRACEDEBUG:
|
||||
EV_TraceDebug();
|
||||
break;
|
||||
default:
|
||||
error(sprintf("event id %d not recognized. abort immediately.\n", type));
|
||||
}
|
||||
|
|
|
@ -513,3 +513,17 @@ void NSMonster_ReadEntity(bool);
|
|||
void NSMonster_AlertEnemyAlliance(vector pos, float radius, int alliance);
|
||||
entity NSMonster_FindClosestPlayer(entity);
|
||||
#endif
|
||||
|
||||
.float baseframe2;
|
||||
.float baseframe1time;
|
||||
.float baseframe2time;
|
||||
.float baselerpfrac;
|
||||
.float bonecontrol1;
|
||||
.float bonecontrol2;
|
||||
.float bonecontrol3;
|
||||
.float bonecontrol4;
|
||||
.float bonecontrol5;
|
||||
.float subblendfrac;
|
||||
.float subblend2frac;
|
||||
.float basesubblendfrac;
|
||||
.float basesubblend2frac;
|
||||
|
|
|
@ -506,7 +506,7 @@ NSTalkMonster::FollowPlayer(void)
|
|||
input_angles[0] = 0;
|
||||
input_angles[1] = Math_FixDelta(input_angles[1]);
|
||||
input_angles[2] = 0;
|
||||
_LerpTurnToYaw(input_angles[1]);
|
||||
_LerpTurnToYaw(input_angles);
|
||||
|
||||
/* for best results, we want to ignore the Z plane
|
||||
this avoids the problem of a follower spinning
|
||||
|
@ -547,7 +547,7 @@ NSTalkMonster::FollowPlayer(void)
|
|||
input_angles[0] = 0;
|
||||
input_angles[1] = Math_FixDelta(input_angles[1]);
|
||||
input_angles[2] = 0;
|
||||
_LerpTurnToYaw(input_angles[1]);
|
||||
_LerpTurnToYaw(input_angles);
|
||||
} else {
|
||||
m_vecLastUserPos = m_eFollowingChain.origin;
|
||||
}
|
||||
|
|
|
@ -254,6 +254,30 @@ remove(entity target)
|
|||
prior(target);
|
||||
}
|
||||
|
||||
__wrap void
|
||||
traceline(vector v1, vector v2, float flags, entity ent)
|
||||
{
|
||||
#ifdef SERVER
|
||||
if (autocvar(com_showTracers, 0) == 1) {
|
||||
WriteByte(MSG_MULTICAST, SVC_CGAMEPACKET);
|
||||
WriteByte(MSG_MULTICAST, EV_TRACEDEBUG);
|
||||
WriteCoord(MSG_MULTICAST, v1[0]);
|
||||
WriteCoord(MSG_MULTICAST, v1[1]);
|
||||
WriteCoord(MSG_MULTICAST, v1[2]);
|
||||
WriteCoord(MSG_MULTICAST, v2[0]);
|
||||
WriteCoord(MSG_MULTICAST, v2[1]);
|
||||
WriteCoord(MSG_MULTICAST, v2[2]);
|
||||
msg_entity = world;
|
||||
multicast(v1, MULTICAST_PVS_R);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CLIENT
|
||||
// TODO
|
||||
#endif
|
||||
prior(v1, v2, flags, ent);
|
||||
}
|
||||
|
||||
void
|
||||
setorigin_safe(entity target, vector testorg)
|
||||
{
|
||||
|
|
|
@ -55,5 +55,6 @@ enum
|
|||
EV_SURFIMPACTID,
|
||||
EV_DECALGROUP,
|
||||
EV_BREAKMODEL,
|
||||
EV_TRACEDEBUG,
|
||||
EV_SEPARATOR
|
||||
};
|
||||
|
|
|
@ -72,3 +72,40 @@ Platform_GetPlatform(void)
|
|||
|
||||
return g_platform;
|
||||
}
|
||||
|
||||
bool
|
||||
Platform_FileInGamedir(string fileName, string gameDir)
|
||||
{
|
||||
searchhandle fileSearch;
|
||||
int fileCount = 0i;
|
||||
|
||||
fileSearch = search_begin(fileName, SEARCH_FULLPACKAGE, TRUE);
|
||||
fileCount = search_getsize(fileSearch);
|
||||
|
||||
print(sprintf("looking for %S in %S\n", fileName, gameDir));
|
||||
|
||||
/* doesn't exist */
|
||||
if (fileCount <= 0)
|
||||
return false;
|
||||
|
||||
for (int i = 0; i < fileCount; i++) {
|
||||
string fileDir;
|
||||
string fullPath = search_getpackagename(fileSearch, i);
|
||||
fileDir = substring(fullPath, 0, strlen(gameDir)); /* only need to check same-ness */
|
||||
|
||||
if (fileDir == gameDir) {
|
||||
print("found it\n");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/* file exists but is in a different gamedir */
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
Platform_FileInCurrentGamedir(string fileName)
|
||||
{
|
||||
string gameDir = cvar_string("game");
|
||||
return Platform_FileInGamedir(fileName, gameDir);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue