Advertisement
fastman92

PathStructures.h

Mar 14th, 2015
769
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.82 KB | None | 0 0
  1. /*
  2. * Copyright (C) 2014-2016  fastman92 <fastman92@gmail.com>, website: http://fastman92.ml
  3. * Licensed under the MIT License, see LICENSE at top level directory.
  4. *
  5. */
  6.  
  7. #pragma once
  8. #include "Assertions.h"
  9. #include "CompressedVector.h"
  10. #include "CVector.h"
  11. #include <stdint.h>
  12.  
  13. #ifdef IS_ARCHITECTURE_32_BIT
  14. namespace Game_GTASA
  15. {
  16.     // path structures
  17.     const int PATH_COORD_MULTIPLIER = 8;
  18.  
  19.     struct tStandardPathFileHeader
  20.     {
  21.         union
  22.         {
  23.             uint32_t numberOfPathNodes;
  24.             uint32_t magicID;   // magicID = 0xFFFFFFFF when different path format.
  25.         };
  26.  
  27.         uint32_t numberOfPathVehicleNodes;
  28.         uint32_t numberOfPathPedNodes;
  29.  
  30.         uint32_t numberOfNaviNodes;
  31.  
  32.         uint32_t numberOfLinks;
  33.     };
  34.  
  35.     VALIDATE_SIZE(tStandardPathFileHeader, 20);
  36.  
  37.     // fastman92 path header
  38.     struct tFastman92PathFileHeaderFirstPart
  39.     {
  40.         uint32_t magicID;   // magicID = 0xFFFFFFFF
  41.         uint32_t format;    // should have a value "FM92"
  42.     };
  43.  
  44.     VALIDATE_SIZE(tFastman92PathFileHeaderFirstPart, 8);
  45.  
  46.     #pragma warning ( push )
  47.     #pragma warning ( disable: 4200 )
  48.     struct tFastman92PathFileSecondPart
  49.     {
  50.         uint8_t sizeofNextValue;
  51.         char value[];   // number of bytes depends on sizeofNextValue
  52.     };
  53.     #pragma warning ( pop )
  54.  
  55.     VALIDATE_SIZE(tFastman92PathFileSecondPart, 1);
  56.  
  57.     struct tFastman92PathFileHeaderThirdPart
  58.     {
  59.         uint32_t formatVersion; // should have a value "VER2"
  60.         uint32_t numberOfPathNodes;
  61.        
  62.         uint32_t numberOfPathVehicleNodes;
  63.         uint32_t numberOfPathPedNodes;
  64.  
  65.         uint32_t numberOfNaviNodes;
  66.  
  67.         uint32_t numberOfLinks;
  68.     };
  69.  
  70.     VALIDATE_SIZE(tFastman92PathFileHeaderThirdPart, 24);
  71.  
  72.     ////////////////////// 
  73.  
  74.     #pragma pack(push, 1)
  75.     struct CNodeAddress
  76.     {
  77.       uint16_t areaId;
  78.       uint16_t nodeId;
  79.     };
  80.     #pragma pack(pop)
  81.  
  82.     VALIDATE_SIZE(CNodeAddress, 4);
  83.  
  84.     #pragma pack(push, 1)
  85.     struct CPathNode    // standard GTA SA
  86.     {
  87.         CPathNode *m_pPrev;
  88.         CPathNode **m_ppNext;
  89.         CompressedVector m_posn;
  90.         int16_t m_wSearchList;
  91.         int16_t m_wConnectedNodesStartId;   // ID into link array
  92.         CNodeAddress m_nodeInfo;
  93.  
  94.         char m_nPathWidth;
  95.         uint8_t m_nFloodID;     // unused when fastman92 path format VER3 is used
  96.         uint32_t m_dwFlags;
  97.  
  98.         // Returns number of links
  99.         int GetNumberOfLinks() { return this -> m_dwFlags & 0xF; }
  100.     };
  101.     #pragma pack(pop)
  102.  
  103.     VALIDATE_SIZE(CPathNode, 0x1C);
  104.  
  105.     // fastman92 path format VER2
  106.     struct CPathNode_extended : public CPathNode
  107.     {
  108.         CompressedVector_extended m_extended_posn;
  109.  
  110.         // Sets the position in vector
  111.         void GetExPosition(CVector& out)
  112.         {
  113.             out.x = (float)this->m_extended_posn.x / PATH_COORD_MULTIPLIER;
  114.             out.y = (float)this->m_extended_posn.y / PATH_COORD_MULTIPLIER;
  115.             out.z = (float)this -> m_extended_posn.z / PATH_COORD_MULTIPLIER;
  116.         }
  117.     };
  118.  
  119.     VALIDATE_SIZE(CPathNode_extended, 0x28);
  120.  
  121.     // fastman92 path format VER3
  122.     #pragma pack(push, 1)
  123.     struct CPathNode_extended2 : public CPathNode_extended
  124.     {
  125.         int16_t m_nExFloodID;
  126.     };
  127.     #pragma pack(pop)
  128.  
  129.     VALIDATE_SIZE(CPathNode_extended2, 0x2A);
  130.  
  131.     #pragma pack(push, 1)
  132.     struct CCarPathLink
  133.     {
  134.         int16_t posX;   // unused when path limit hacked
  135.         int16_t posY;   // unused when path limit hacked
  136.         CNodeAddress attachedPathNode;
  137.         int8_t dirX;
  138.         int8_t dirY;
  139.         uint32_t m_dwFlags;
  140.     };
  141.     #pragma pack(pop)
  142.  
  143.     VALIDATE_SIZE(CCarPathLink, 0xE);
  144.  
  145.     #pragma pack(push, 1)
  146.     struct CCarPathLink_extended : public CCarPathLink
  147.     {
  148.         int32_t extended_posX;
  149.         int32_t extended_posY;
  150.     };
  151.     #pragma pack(pop)
  152.  
  153.     VALIDATE_SIZE(CCarPathLink_extended, 0x16);
  154.  
  155.     // other
  156.     #pragma pack(push, 1)
  157.     struct CForbiddenArea
  158.     {
  159.       float x1;
  160.       float x2;
  161.       float y1;
  162.       float y2;
  163.       float z1;
  164.       float z2;
  165.       char bEnable;
  166.       char type;
  167.       char _padding[2];
  168.     };
  169.     #pragma pack(pop)
  170.  
  171.     VALIDATE_SIZE(CForbiddenArea, 0x1C);
  172.  
  173.     // path type
  174.     enum ePathType
  175.     {
  176.         PATH_TYPE_UNDEFINED,
  177.  
  178.         PATH_TYPE_VEHICLE,
  179.         PATH_TYPE_PED
  180.     };
  181. }
  182. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement