Skip to content
This repository has been archived by the owner. It is now read-only.

CPedPath complete #416

Merged
merged 4 commits into from Apr 15, 2020
Merged

CPedPath complete #416

merged 4 commits into from Apr 15, 2020

Conversation

@ghost
Copy link

@ghost ghost commented Apr 14, 2020

This is an unused function. There is an opcode for it, but I confirmed that it's not being used. I tested the code. It works, or at least it behaves the same way as the original function. I also tried calling the original function from memory and saw how this function affects the ped. If the point is closer to the ped, then the ped starts moving towards the point and after a while the ped starts moving in a different direction. floating-point comparisons were completely messed up in CPedPath::AddBlockade, I used the android IDB and ghidra to fix it.

CVector vecPos = (position + destination) * 0.5f;
CVector vecSectorStartPos (vecPos.x - 14.0f, vecPos.y - 14.0f, vecPos.z);
CVector2D vecSectorEndPos (vecPos.x + 28.0f, vecPos.x + 28.0f);
const int16 nodeStartX = (position.x - vecSectorStartPos.x) * 1.4286f;

This comment has been minimized.

@aap

aap Apr 14, 2020
Member

/ 0.7f probably

for (*pointsFound = 0; pPathNode != pEndPathNode && *pointsFound < maxPoints; ++ *pointsFound) {
const uint8 nodeIdX = pPathNode->nodeIdX;
const uint8 nodeIdY = pPathNode->nodeIdY;
if (nodeIdX <= 0 || pathNodes[nodeIdX - 1][nodeIdY].id + 5 != pPathNode->id) {

This comment has been minimized.

@aap

aap Apr 14, 2020
Member

flip all those ifs. it's just an else if ladder

@ghost ghost marked this pull request as ready for review Apr 14, 2020
@aap
Copy link
Member

@aap aap commented Apr 14, 2020

You can actually remove the (float) casts. they're implicit.

for (int32 x = 0; x < 40; x++) {
for (int32 y = 0; y < 40; y++) {
pathNodes[x][y].bBlockade = false;
pathNodes[x][y].id = 0x7FFF;

This comment has been minimized.

@erorcun

erorcun Apr 14, 2020
Collaborator

INT16_MAX

{
*pointsFound = 0;
CVector vecDistance = destination - position;
if (Abs(vecDistance.x) > 23.8f || Abs(vecDistance.y) > 23.8f || Abs(vecDistance.z) > 23.8f)

This comment has been minimized.

@erorcun

erorcun Apr 14, 2020
Collaborator

adding define for that number would be cool

CPedPath::AddNodeToPathList(CPedPathNode *pNodeToAdd, int16 id, CPedPathNode *pNodeList)
{
if (!pNodeToAdd->bBlockade && id < pNodeToAdd->id) {
if (pNodeToAdd->id != 0x7FFF)

This comment has been minimized.

@erorcun

erorcun Apr 14, 2020
Collaborator

INT16_MAX

@erorcun
Copy link
Collaborator

@erorcun erorcun commented Apr 14, 2020

lgtm except comments

@erorcun erorcun merged commit e132c3f into GTAmodding:master Apr 15, 2020
1 check passed
1 check passed
@appveyor
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants