Как получить путь до цели?

coldest

Новичок
Автор темы
4
7
Помогите разобраться с переводом структуры с plugin-sdk на lua.
Нужно получить путь следования до цели на примере GPS.
Я так понимаю за это отвечает функция
C++:
ThePaths.DoPathSearch(0, FindPlayerCoors(0), CNodeAddress(), destPosn, resultNodes, &nodesCount, MAX_NODE_POINTS, &gpsDistance, 999999.0f, NULL, 999999.0f, false, CNodeAddress(), false, playa->m_pVehicle->m_nVehicleSubClass == VEHICLE_BOAT);
, она находится в CPathFind.cpp.

Lua:
ffi.cdef[[
    struct CVector {
    float x, y, z;
    };
    
    struct CNodeAddress {
    short m_nAreaId;
    short m_nNodeId;
    };
    
    struct CompressedVector {
    short x;
    short y;
    short z;
    };
    
    struct CPathNode {
    void *ptr;
    void *ptr2;
    struct CompressedVector m_vecPosn;
    unsigned short m_nSearchList; //!< search list id
    short m_nBaseLinkId;
    short m_nAreaId;
    short m_nNodeId;
    unsigned char m_nPathWidth;
    unsigned char m_nFloodFill;
    
    unsigned char m_nNumLinks : 4;
    unsigned char m_nTrafficLevel : 2;
    unsigned char m_bRoadBlocks : 1;
    unsigned char m_bWaterNode : 1;

    unsigned char m_bEmergencyVehiclesOnly : 1;
    unsigned char unk1 : 1;   //!< not used in paths data files
    unsigned char m_bDontWander : 1;
    unsigned char unk2 : 1;   //!< not used in paths data files
    unsigned char m_bNotHighway : 1;
    unsigned char m_bHighway : 1;
    unsigned char unk3 : 1;     //!< not used in paths data files
    unsigned char unk4 : 1;     //!< not used in paths data files

    unsigned char m_nSpawnProbability : 4;
    unsigned char m_nBehaviourType : 4; //!< 1 - roadblock, 2 - parking node
    };
    
    struct CompressedVector2D {
    short x;
    short y;
    };
    
    struct CCarPathLink {
    struct CompressedVector2D m_vecPosn;
    struct CNodeAddress m_address;
    char m_nDirX;
    char m_nDirY;
    char m_nPathNodeWidth;
    };
    
    struct CPathIntersectionInfo {
    unsigned char m_bRoadCross : 1;
    unsigned char m_bPedTrafficLight : 1;
    };
    
    struct CCarPathLinkAddress {
    short m_nCarPathLinkId : 10;
    short m_nAreaId : 6;
    };
    
    struct CForbiddenArea {
    float m_fX1;
    float m_fX2;
    float m_fY1;
    float m_fY2;
    float m_fZ1;
    float m_fZ2;
    bool m_bEnable;
    unsigned char m_nType;
    };
    
    struct CPathFind {
    struct CNodeAddress info;
    struct CPathNode *m_apNodesSearchLists[512];
    struct CPathNode *m_pPathNodes[64 + 8];
    struct CCarPathLink *m_pNaviNodes[64 + 8];
    struct CNodeAddress *m_pNodeLinks[64 + 8];
    unsigned char *m_pLinkLengths[64 + 8];
    struct CPathIntersectionInfo *m_pPathIntersections[64 + 8];
    struct CCarPathLinkAddress *m_pNaviLinks[64];
    void *field_EA4[64];
    unsigned int m_dwNumNodes[64 + 8];
    unsigned int m_dwNumVehicleNodes[64 + 8];
    unsigned int m_dwNumPedNodes[64 + 8];
    unsigned int m_dwNumCarPathLinks[64 + 8];
    unsigned int m_dwNumAddresses[64 + 8];
    int field_1544[2048];
    unsigned int m_dwTotalNumNodesInSearchList;
    struct CNodeAddress char3548[8];
    unsigned int m_dwNumForbiddenAreas;
    struct CForbiddenArea m_aForbiddenAreas[64];
    bool m_bForbiddenForScriptedCarsEnabled;
    char _padding[3];
    float m_fForbiddenForScrCarsX1;
    float m_fForbiddenForScrCarsX2;
    float m_fForbiddenForScrCarsY1;
    float m_fForbiddenForScrCarsY2;
    };
]]

local getPath = ffi.cast("void (__thiscall *)(struct CPathFind *, unsigned char, struct CVector, CNodeAddress, struct CVector, struct CNodeAddress *, short *, int, float *, float, struct CNodeAddress *, float, bool, struct CNodeAddress, bool, bool", 0x4515D0)
getPath(this, pathType, origin, originAddr, target, pResultNodes, pNodesCount, maxNodesToFind, pDistance, maxSearchDistance, targetAddr, maxUnkLimit, oneSideOnly, forbiddenNodeAddr, includeNodesWithoutLinks, waterPath)
, как и в какой форме передавать и получать?