Skip to content

Fix param 4 and 5 for GET_NTH_CLOSEST_VEHICLE_NODE_ID_WITH_HEADING#255

Merged
alloc8or merged 6 commits into
alloc8or:masterfrom
CreepyQuietWeirdo:master
Jun 13, 2026
Merged

Fix param 4 and 5 for GET_NTH_CLOSEST_VEHICLE_NODE_ID_WITH_HEADING#255
alloc8or merged 6 commits into
alloc8or:masterfrom
CreepyQuietWeirdo:master

Conversation

@CreepyQuietWeirdo

Copy link
Copy Markdown
Contributor

See Freemode where the 5th argument being used, var4, couldn't be a Vector3, but must be float, and Var5 declared directly below it is being used as an int. These variables shouldn't overlap. Freemode @v3788:

int func_1119(Vector3* vParam0, Vector3* vParam1, var* uParam2)//Position - 0x8376F
{
[...]
	Vector3 vVar4; // <-- Impossible, can't be a struct size  of 3 with iVar5 following it immediately
	int iVar5;
[...]
	iVar5 = 0;
[...]
		iVar5 += 2;
		iVar5++;
[...]
	iVar5 += 4;
[...]
		iVar8 = PATHFIND::GET_NTH_CLOSEST_VEHICLE_NODE_ID_WITH_HEADING(*vParam0, (iVar0 * iVar17), &vVar4, &fVar9, iVar5, fVar13, fVar14);

If you reverse the native, it is clear that this parameter is filled with the heading in 0.0 to 360.0 degrees as a float pointer, not as a Vector3 pointer. (If it were, a wrapper would also be present to convert from 3 consecutive floats to 3 script floats with 8-byte alignment and there is none.) Furthermore the 6th argument is used internally as an int pointer, for numLanes. It seems the only difference between this function and GET_NTH_CLOSEST_VEHICLE_NODE_WITH_HEADING is that the Vector3* outHeading is omitted, instead of the numLanes parameter.

This also explains why in Freemode func_1119 v3788 PATHFIND::GET_VEHICLE_NODE_POSITION is called immediately after calling PATHFIND::GET_NTH_CLOSEST_VEHICLE_NODE_ID_WITH_HEADING, this wouldn't make sense otherwise.

@alloc8or

alloc8or commented Jun 6, 2026

Copy link
Copy Markdown
Owner

Looks like someone fixed this for rdr3-nativedb-data already: https://alloc8or.re/rdr3/nativedb/?n=0x4114EAA8A7F7766D
Maybe we should just copy that signature for consistency?

@alloc8or
alloc8or merged commit 5e293e7 into alloc8or:master Jun 13, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants