CFuncTrackTrain::Next
0x00b0fe70 · 1977 bytes · __thiscall
_ZN15CFuncTrackTrain4NextEv
Decompiled
undefined (1 param)
/* CFuncTrackTrain::Next() */
void __thiscall CFuncTrackTrain::Next(CFuncTrackTrain *this)
{
Vector *pVVar1;
float fVar2;
float fVar3;
float fVar4;
float fVar5;
CBaseEntity *this_00;
CPathTrack *pCVar6;
undefined4 uVar7;
CPathTrack *pCVar8;
float fVar9;
undefined1 local_54 [16];
CPathTrack *local_44;
float local_40;
float local_3c;
float local_38;
undefined4 local_34;
undefined4 local_30;
undefined4 local_2c;
float local_28;
float local_24;
float local_20;
if (*(float *)(this + 0x11c) == 0.0) {
uVar7 = CBaseEntity::GetDebugName((CBaseEntity *)this);
DevMsg(2,"TRAIN(%s): Speed is 0\n",uVar7);
SoundStop(this);
return;
}
if (*(int *)(this + 0x440) == 0) {
uVar7 = CBaseEntity::GetDebugName((CBaseEntity *)this);
DevMsg(2,"TRAIN(%s): Lost path\n",uVar7);
SoundStop(this);
*(undefined4 *)(this + 0x11c) = 0;
return;
}
SoundUpdate(this);
local_40 = *(float *)(this + 0x39c);
local_44 = (CPathTrack *)0x0;
fVar2 = *(float *)(this + 0x11c);
local_3c = *(float *)(this + 0x3a0);
local_38 = *(float *)(this + 0x3a4) - *(float *)(this + 0x480);
this_00 = (CBaseEntity *)
CPathTrack::LookAhead
(*(CPathTrack **)(this + 0x440),(Vector *)&local_40,fVar2 * 0.1,1,&local_44);
if ((this[0x4ec] == (CFuncTrackTrain)0x0) ||
((*(float *)(this + 0x4f0) <= 0.0 && *(float *)(this + 0x4f0) != 0.0) == fVar2 < 0.0)) {
LAB_00b0ff80:
if (((byte)this[0x110] & 4) != 0) {
if (this_00 != (CBaseEntity *)0x0) goto LAB_00b0ff95;
goto LAB_00b100e4;
}
}
else {
if (this_00 == (CBaseEntity *)0x0) {
this_00 = *(CBaseEntity **)(this + 0x440);
goto LAB_00b0ff80;
}
if (((byte)this[0x110] & 4) == 0) {
local_38 = local_38 + *(float *)(this + 0x480);
goto LAB_00b1026c;
}
LAB_00b0ff95:
if (((byte)this_00[0x14d] & 8) != 0) {
CBaseEntity::CalcAbsolutePosition(this_00);
}
pVVar1 = (Vector *)(this_00 + 0x2e0);
if (((byte)this[0x14d] & 8) != 0) {
CBaseEntity::CalcAbsolutePosition((CBaseEntity *)this);
}
NDebugOverlay::Line((Vector *)(this + 0x2e0),pVVar1,0xff,0,0,true,0.1);
if (((byte)this_00[0x14d] & 8) == 0) {
local_28 = *(float *)(this_00 + 0x2e0);
local_24 = *(float *)(this_00 + 0x2e4);
local_20 = *(float *)(this_00 + 0x2e8) + 32.0;
}
else {
CBaseEntity::CalcAbsolutePosition(this_00);
local_28 = *(float *)(this_00 + 0x2e0);
local_24 = *(float *)(this_00 + 0x2e4);
local_20 = *(float *)(this_00 + 0x2e8) + 32.0;
if ((*(uint *)(this_00 + 0x14c) & 0x800) != 0) {
CBaseEntity::CalcAbsolutePosition(this_00);
}
}
NDebugOverlay::Line(pVVar1,(Vector *)&local_28,0xff,0,0,true,0.1);
local_28 = 8.0;
local_24 = 8.0;
local_20 = 8.0;
local_34 = 0xc1000000;
local_30 = 0xc1000000;
local_2c = 0xc1000000;
if (((byte)this_00[0x14d] & 8) != 0) {
CBaseEntity::CalcAbsolutePosition(this_00);
}
NDebugOverlay::Box(pVVar1,(Vector *)&local_34,(Vector *)&local_28,0xff,0,0,0,0.1);
LAB_00b100e4:
pCVar6 = local_44;
if (local_44 != (CPathTrack *)0x0) {
if (((byte)*(CBaseEntity *)(local_44 + 0x14d) & 8) != 0) {
CBaseEntity::CalcAbsolutePosition((CBaseEntity *)local_44);
}
if (((byte)this[0x14d] & 8) != 0) {
CBaseEntity::CalcAbsolutePosition((CBaseEntity *)this);
}
NDebugOverlay::Line((Vector *)(this + 0x2e0),(Vector *)(pCVar6 + 0x2e0),0,0xff,0,true,0.1);
pCVar6 = local_44;
if (((byte)*(CBaseEntity *)(local_44 + 0x14d) & 8) == 0) {
local_28 = *(float *)(local_44 + 0x2e0);
local_24 = *(float *)(local_44 + 0x2e4);
local_20 = *(float *)(local_44 + 0x2e8) + 32.0;
pCVar8 = local_44;
}
else {
CBaseEntity::CalcAbsolutePosition((CBaseEntity *)local_44);
pCVar8 = local_44;
local_28 = *(float *)(pCVar6 + 0x2e0);
local_24 = *(float *)(pCVar6 + 0x2e4);
local_20 = *(float *)(pCVar6 + 0x2e8) + 32.0;
if ((*(uint *)(local_44 + 0x14c) & 0x800) != 0) {
CBaseEntity::CalcAbsolutePosition((CBaseEntity *)local_44);
}
}
NDebugOverlay::Line((Vector *)(pCVar8 + 0x2e0),(Vector *)&local_28,0,0xff,0,true,0.1);
pCVar6 = local_44;
local_28 = 8.0;
local_24 = 8.0;
local_20 = 8.0;
local_34 = 0xc1000000;
local_30 = 0xc1000000;
local_2c = 0xc1000000;
if (((byte)*(CBaseEntity *)(local_44 + 0x14d) & 8) != 0) {
CBaseEntity::CalcAbsolutePosition((CBaseEntity *)local_44);
}
NDebugOverlay::Box((Vector *)(pCVar6 + 0x2e0),(Vector *)&local_34,(Vector *)&local_28,0,0xff,0
,0,0.1);
}
}
local_38 = local_38 + *(float *)(this + 0x480);
if (this_00 == (CBaseEntity *)0x0) {
SoundStop(this);
local_28 = local_40 - *(float *)(this + 0x39c);
local_24 = local_3c - *(float *)(this + 0x3a0);
local_20 = local_38 - *(float *)(this + 0x3a4);
CBaseEntity::SetLocalVelocity((CBaseEntity *)this,(Vector *)&local_28);
CBaseEntity::SetLocalAngularVelocity((CBaseEntity *)this,(QAngle *)&vec3_angle);
fVar2 = *(float *)(this + 0x2ec);
fVar3 = *(float *)(this + 0x2f0);
fVar4 = *(float *)(this + 0x2f4);
fVar5 = *(float *)(this + 0x11c);
*(undefined4 *)(this + 0x11c) = 0;
*(float *)(this + 0x478) = fVar5;
fVar9 = SQRT(fVar2 * fVar2 + fVar3 * fVar3 + fVar4 * fVar4);
if (0.0 < fVar9) {
local_20 = fVar5 / fVar9;
local_28 = fVar2 * local_20;
local_24 = fVar3 * local_20;
local_20 = local_20 * fVar4;
CBaseEntity::SetLocalVelocity((CBaseEntity *)this,(Vector *)&local_28);
*(code **)(this + 0x14) = DeadEnd;
*(undefined4 *)(this + 0x18) = 0;
CBaseEntity::SetNextThink((CBaseEntity *)this,-1.0,(char *)0x0);
CBaseEntity::SetMoveDoneTime((CBaseEntity *)this,fVar9 / ABS(fVar5));
return;
}
DeadEnd(this);
return;
}
LAB_00b1026c:
UpdateTrainVelocity((CPathTrack *)this,(CPathTrack *)this_00,(Vector *)local_44,(float)&local_40);
UpdateTrainOrientation
(this,(CPathTrack *)this_00,local_44,(Vector *)&local_40,*(float *)(gpGlobals + 0x10));
if (*(CPathTrack **)(this + 0x440) != (CPathTrack *)this_00) {
*(CBaseEntity **)(this + 0x440) = this_00;
ArriveAtNode(this,(CPathTrack *)this_00);
pCVar6 = (CPathTrack *)CPathTrack::GetNext((CPathTrack *)this_00);
if ((pCVar6 != (CPathTrack *)0x0) && (((byte)pCVar6[0x148] & 0x10) != 0)) {
TeleportToPathTrack(this,pCVar6);
}
}
COutputEvent::FireOutput((COutputEvent *)(this + 0x4d4),this_00,(CBaseEntity *)this,0.0);
CBaseEntity::ThinkSet((_func_void *)local_54,(float)this,(char *)Next);
CBaseEntity::SetMoveDoneTime((CBaseEntity *)this,0.5);
CBaseEntity::SetNextThink((CBaseEntity *)this,*(float *)(gpGlobals + 0xc),(char *)0x0);
*(undefined4 *)(this + 0x14) = 0;
*(undefined4 *)(this + 0x18) = 0;
return;
}
SourceMod gamedata
paste intoaddons/sourcemod/gamedata/<your_plugin>.txt
used as the SourceMod key — change to fit your plugin's convention
SourceMod library name (server / engine / matchmaking)
Just a Signatures{} block, ready to drop into a gamedata
file. Wire it up in your plugin however you like - SDKCall, DHooks,
raw memory ops, or anything else.
Signatures + Functions block. The plugin uses
DHookCreateFromConf - DHooks reads return type, this-type,
calling convention, and argument types straight from the gamedata. Less
boilerplate in the plugin, types travel with the gamedata.
Gamedata KeyValues
DHooks plugin example
Type inference is best-effort from the C signature - sanity-check the DHooks types before shipping.