IMG

 
IMG
IMG   IMG
  Welcome to GTAForums! Be sure to check out the Grand Theft Auto V Forum.

You are not registered! (If you are, click here to login) Registering is fast, free and easy and allows you to instantly reply to any topic on GTAForums.
Why wait? Click here to register your own unique username and become part of the ever-growing community!


( Log In | Register | Revalidate Validation E-mail )
Quick Log-In:
  IMG
       
>
Forum Rules GTA Modification Forums

Help and Discussion of IV modding only. Please post mod releases in the Mod Showroom

GTAGarage.com
free mod hosting from GTANet, simply login with your GTAForums account details

GTAModding.com
GTANet's modding wiki

GTA Modding Chatroom
provided by irc.gtanet.com (Don't have an IRC client? Click here)


  Reply to this topicStart new topicStart Poll

 IV Paths Format

 Encryption topic
 
Aschratt  
Posted: Tuesday, Dec 30 2008, 19:53
Quote Post


Three Headed Monkey
Group Icon
Group: Members
Joined: Apr 12, 2006

anarchist.gif

Member Award




Hi,

yesterday I took a quick look over the paths format of IV. It looks like it is nearly the same like SA. A bit less complex and easy, but all in all the same.

Paths are located in "%Grand Theft Auto IV%\pc\data\cdimages\nodes.img". They are stored in 64 .nod files (like in SA with the difference that SA nodes hat the ending .dat). Here is the format I got 'till now:
CODE
Header:
4b - UINT32 - Number of Nodes
4b - UINT32  - Number of Car-Nodes
4b - UINT32  - Number of PED-Nodes
4b - UINT32 - Links

Nodes (0x20/32b):
4b - UINT32 - MemAddress?
4b - UINT32 - Zero?
2b - UINT16 - Area ID
2b - UINT16 - Node ID
4b - UINT32 - Zero (Not allways...)
2b - UINT32 - Allways 0x7FFE
6b - INT16[3] - Position (XYZ) /8
4b - UINT32 - Flags?
4b - UINT16  - Unknown

Links (0x08/08b):
2b - UINT16 - Area ID
2b - UINT16 - Node ID
4b - UINT32 - Flags
Structures (C-Syntax):
CODE
struct pathsNodesFileHeader
{
   unsigned int numNodes;
   unsigned int numCarNodes;
   unsigned int numPedNodes;
   unsigned int numLinks;
};

struct pathsNode
{
   unsigned int memAddress;
   unsigned short areaId;
   unsigned short nodeId;
   float posX;    // divide by 8 to get floating point value
   float posY;    // divide by 8 to get floating point value
   float posZ;    // divide by 8 to get floating point value
   unsigned int flags;
   unsigned short unknown;
};

struct pathsLinks
{
   unsigned short areaId;
   unsigned short nodeId;
   unsigned int linkFlags;
};
Some SA information is outdated, like NaviNodes and LinkLength. Lanes, TrafficLight behaviour and so on appear to be stored in the link flag value. I have no idea yet, wheather the nodes are interpolated or where/how interpolation information like normalized vectors or so are stored. Also I don't know if the flags are stored where I think they are, or what meaning the bits have.

I wrote some kind of viewer, which is keept very simple. Here is an screen:
user posted image
(You have to turn this image by 180 dagrees... haven't recognized this yet tounge.gif)
Perhaps those information may help anyone.

Greetings,
- Aschratt!

This post has been edited by Aschratt on Tuesday, Dec 30 2008, 19:57
Users WebsitePMMSNAOLYahooICQ
  Top
 

 
Intosia  
Posted: Tuesday, Dec 30 2008, 20:13
Quote Post


I'm random! ^^
Group Icon
Group: Members
Joined: Dec 11, 2008

nl.gif

XXXXX



Good job smile.gif Although what are Paths?
Users WebsitePM
  Top
 

 
Aschratt  
Posted: Tuesday, Dec 30 2008, 20:22
Quote Post


Three Headed Monkey
Group Icon
Group: Members
Joined: Apr 12, 2006

anarchist.gif

Member Award




tounge.gif

NPC cars and pedestriants driving/walking around are spawned along paths and influenced in their behaviour by them. Click
Users WebsitePMMSNAOLYahooICQ
  Top
 

 
REspawn  
Posted: Tuesday, Dec 30 2008, 20:25
Quote Post


REgent
Group Icon
Group: Members
Joined: Jul 6, 2002

il.gif

Member Award




Excellent work Aschratt
PMICQ
  Top
 

 
JKM  
Posted: Wednesday, Dec 31 2008, 00:08
Quote Post


[BM] Projectleader
Group Icon
Group: Members
Joined: Jul 16, 2005

gr.gif

XXXXX



good news cookie.gif cookie.gif ... nice to see you working on 4 aschratt xD
PMICQ
  Top
 

 
xmen  
Posted: Wednesday, Dec 31 2008, 15:23
Quote Post


Foot Soldier
Group Icon
Group: Members
Joined: Jun 2, 2005

jolly-roger.gif

Member Award




wow, once again mate...nice work on path. Keep it up icon14.gif
Users WebsitePMMSNYahoo
  Top
 

 
Aschratt  
Posted: Sunday, Jan 4 2009, 17:47
Quote Post


Three Headed Monkey
Group Icon
Group: Members
Joined: Apr 12, 2006

anarchist.gif

Member Award




Hi,

I've took a deeper look into paths again and got some new rudiments. First of all the structures are nearly as I guessed. I am pretty sure that it looks like that:
CODE
Nodes (0x20/32b):
4b - UINT32 - MemAddress
4b - UINT32 - Zero (Allways)
2b - UINT16 - Area ID
2b - UINT16 - Node ID
4b - UINT32 - Unknown
2b - UINT16 - Allways 0x7FFE
2b - UINT16 - LinkID
6b - INT16[3] - Position (XYZ)
2b - UINT16  - Path Type (0x100 for Boats)
4b - UINT32 - Flags
I have not yet tested linking, but I will, after I got an IDE back running here.
Position values appear to be calculated by dividing them with 8 (like in SA). Just Y-position must be divided with -8 (unlike SA). But I am not sure about this yet.

But there is one more thing I found out about this theme. The values I supposed to be ped noes aren't ped nodes. Which means, somehow they are, but not all ped nodes are indexed by the number in the header. In general there are 2522 of those nodes. The special thing about them is that they are located around intersections (But allways on the pavement). I guess they are special nodes which are used to let npc's wait at pedestrian crossings (Pic 1). This means that ped nodes are identified by some kind of flag. My researches about that showed that the flag seems to be a part of the flag-number of the nodes structure, because all other unknown values appear to be some kind of randomly. However I think I will find out more about that when I managed some linking tests.

Flags are nearly the same as in SA. I will create an table like in the wiki for that. The first part (A - M) seems to be identical or very similar to SA, but I only had a short look to that.

Pictures:
user posted image user posted image

I'll keep you up-to-date, greetings so far,
- Aschratt.

//EDIT (07.01.2009):

I managed it to seperate vehicle from pedestriant and boat nodes (Pic 3). However it is pretty simple and I don't know why I haven't seen this detail a bit earlier, because it is kept from San Andreas. blush.gif

The unknown value come's before the flags are paths width (which seems to take affect in IV... unlike SA where it did not have any affect) and path type. Path type defines wheather the node is an ped/vehicle/boat/different node. Yes there are different nodes (You can't see them in the picture, because I painted them white, too). Their paths type is always 0x0C. They are located at the Hove Beach harbor, where the player starts in the original game. I have no idea what they are exactly, but I guess I will find out, when I managed some linking.
However you can filter out the path type pretty easy:
CODE
if(pathType == 0x01)
{
   // Boats
}
else (((pathType >> 4) & 0x0E) == 0)
{
   // Cars
}
else
{
   // Ped's
}


Intersection nodes appear to be checked with 0x0D, but there also seem to be some nodes with 0x0B or 0x0F. I haven't yet found out what's their difference, but it seems to be some number of the current city circuit (Or village what they were in SA.) I think that they are used for some kind of borders or filters. Pedestriants are only walking along paths with the same number. I got to check this later on. Also the rest of the byte is a bit mysterious. It seems to increment by each node (0-F) in saturate arithmetics.

However here is the structure I am using at the moment:
CODE
Nodes (0x20/32b):
4b - UINT32 - MemAddress
4b - UINT32 - Zero (Allways)
2b - UINT16 - Area ID
2b - UINT16 - Node ID
4b - UINT32 - Unknown
2b - UINT16 - Allways 0x7FFE
2b - UINT16 - LinkID
6b - INT16[3] - Position (XYZ)
1b - BYTE  - Path Width (divide it by 8 to get the floating point value)
1b - BYTE  - Path Type (0x100 for Boats)
4b - UINT32 - Flags


user posted image

//EDIT (08.01.2009):

I found out that my seperation for car and ped nodes does not allways work, but I also found out for what the first unknown value seems to stand. However it is only used for highways and/or big roads/tunnels. All nodes which are not zero there are vehicle node, unless this does not mean that all vehicle nodes are not zero there.

//EDIT (10.01.2009 #1):

Here is the flag table. I know it is not very nice, but it shows that the flags are averanged nearly like in San Andreas, which let's me come to the conclusion that they are used pretty identical:
CODE
04: 2681
05: 2559
06: 27
07: 7790
08: 17606
09: 11473
10: 11634
11: 11571
12: 11714
13: 11622
14: 11681
15: 5290
16: 3098
17: 23654
18: 302
19: 0
20: 27943
21: 1601
22: 1090
23: 4918
24: 7915
25: 1202
26: 4918
27: 0
28: 0
29: 9402
30: 0
31: 7419
I will create colored flag maps which show the averange of the flags on the nodes map. Perhaps I found out wheather real PED-Node seperation works with flags.

//EDIT (10.01.2009 #2):

All right... it's nice to have his own online-log tounge.gif
Whatever... Nodetypes realy seem to be influenced by flags. Flag 25 is 100% for boats, flag 29 is an special flag type just for Alderney. I guess it influences appeareance of cars and pedestriants for the "city core": more traffic jams, slower traffic, and so on... But I haven't found an flag type that 100 % matches for all ped or car nodes. I guess R* itself did some bugs there (I already recognized some path bugs ingame, but I could not say if they are on the same locations).

//EDIT: (10.01.2009 #3):

Damn, I made a mistake. I calculated flags into the wrong direction. Here are my results (Now they are exact):
CODE
0-4: Unknown... Not link count, as I guessed... somehow related to traffic level. 3 is only set for Alderney, 0 is only set for some nodes, the other values are allways 0.

Flag 05: Emergency only
Flag 06: Boats
Flag 07: Unknown
Flag 08: Exactly the same as 05
Flag 09: Intersection central node
Flag 10: Is highway (See SA's node flags)
Flag 11: Is not highway (See SA's node flags)
Flag 12: zero/unused
Flag 13: Identical to 09, but not set for all nodes which have 09. Somehow else related into intersections.
Flag 14: Set for almost any vehicle node
Flag 15: Set for those vehicle nodes without 14, and some PED nodes
Flag 16: Set for those PED nodes without 15 and some vehicle nodes

17-23: apparently randomly set, perhaps some counter

Flag 24: Set for most PED nodes
Flag 25: Rarely used, police controls or roadblocks?
Flag 26: Used for intersection nodes (those which are defined in the header), but also some more
Flag 27: The same as 26, even used a bit more

28-31: Apparently 1 for most nodes, but not for all. Almost never 0, and if so the other 3 flags aren't set, too.
Perhaps some of the flag stuff is used for navi-nodes (I guess some of the flags 17 - 23), we know from SA. Rockstar uses them for interpolation. I did not have a look to the link flags yet, but I think Rockstar simply put things from the sections 3, 5 and 6 together into one.

//EDIT (11.01.2009):

I checked those flags which do not make any sense again. Still they do not make any sense, lol.
Flags 28-31 are almost everytime 1111 or 0000, except for 3488 nodes. Flags 17-23 do not appear to be any counter. I don't know, what they are. Also I took a look at the link flags. I don't know what the first byte is, but the second appears to be the link length. 3rd and 4th byte are interesting, too. They are sometimes completely zero, but sometimes not. So first I guessed that they are related into interpolation, but after some thinking, I do not think so.

However, still I have no idea from where to gain the link id... I will try to figure this out and do some linking, when I was successfull... perhaps I can say more then.

This post has been edited by Aschratt on Sunday, Jan 11 2009, 10:34
Users WebsitePMMSNAOLYahooICQ
  Top
 

 
Aschratt  
Posted: Sunday, Jan 11 2009, 12:39
Quote Post


Three Headed Monkey
Group Icon
Group: Members
Joined: Apr 12, 2006

anarchist.gif

Member Award




All right, I will create a new reply, because the old one is getting more and more confusing.

I found out some more stuff about paths, espcially how they are linked. New with IV is that ped nodes apparently are not linked, except those which are marked as intersection nodes. I guess that's also the way ped nodes are seperated from others. However the link count is stored somewhere in the middle of the flags (bits 12-15). For getting the links you have to loop the link count from the link id (which is an address into section 2). It's like in SA, just the link count is formed by different bits (Pic 1).

I also found out many things about flags. First of all I mixed up Alderney with Algoquin ( blush.gif ). Flag 3 is only set for Algoquin, not Alderney. But some more interesting stuff I found out about the other flags: Flag 16 seems to mark ped nodes, but I am not sure, because the intersection nodes are not marked by flag 16. So correctly flag 16 seems to disable node linking. I will check link id's of those nodes marked with flag 16. If I am right they are 0, or ignored. However the link count of those nodes must be zero. Flag 24 is set for those nodes with flag 16 and the intersection nodes, so flag 24 apparently marks ped nodes. But flag 24 seems to be also set for a small group of vehicle nodes in Alderney (^^). But it also can be just ped nodes, drawed above some vehicle nodes... I am not sure. Flag 26 is the opposite to flag 16. It seems to enable linking for ped nodes. However all intersection nodes are marked with this flag, but also a small group of nodes in Algoquin (near the paint and spray at the small road next to the bridge to Bohan, under the railway). For them it is the same as flag 24, descriped above. I have to check this. Flag 27 is also somehow related into this, but I have no idea how. However with flag 27 there comes another small group of ped nodes to the ones above: The one's on broker, where the player starts.

So the flag table is looking like that now:

CODE
0-4: Unknown... Not link count, as I guessed... somehow related to traffic level. 3 is only set for Algoquin, 0 is only set for some nodes, the other values are allways 0.

Flag 05: Emergency only
Flag 06: Boats
Flag 07: Unknown
Flag 08: Exactly the same as 05
Flag 09: Intersection central node
Flag 10: Is highway (See SA's node flags)
Flag 11: Is not highway (See SA's node flags)

12-15: Link count (Number of Links, starting with the link id)

Flag 16: Disable linking (for PED nodes, as descriped above)

17-23: apparently randomly set, perhaps some counter

Flag 24: Is ped node (see above)
Flag 25: Rarely used, police controls or roadblocks?
Flag 26: Enable linking for ped nodes (see above)
Flag 27: Not sure (see above)

28-31: Apparently 1 for most nodes, but not for all. Almost never 0, and if so the other 3 flags aren't set, too.


user posted image
(Crossfliedlinking disabled, but it works too... I am just too lazy to code it tounge.gif)

Also I took a look to the link format. I am not 100 % sure about it, but this is one major point I will take a look at the next time. Here is the structure:
CODE
2b - UINT16  - Target area id
2b - UINT16  - Target node id
1b - BYTE    - Unknown
1b - BYTE    - Link length
2b - UINT16  - Flags?


What's still left to say?
Oh yea, I still have no idea about this unknown 32-bit value in the nodes structure. Also I have no idea about interpolation yet.
But I still got 2 thoughts about linking:
1st I guess the number of lanes is set somehow in the link flags (which I guess are link flags). In San Andreas they were set in the navi node flags, but in IV there are no such flags, just as there are no navi nodes. This leads me to the conclusion that interpolation is done by the game (perhaps with parsing the nodes) - we will find out.
2nd the link flags are very often simply zero. I guess only for boat nodes, but I am not sure.

Greetings,
- Aschratt.
Users WebsitePMMSNAOLYahooICQ
  Top
 

 
Intosia  
Posted: Sunday, Jan 11 2009, 12:46
Quote Post


I'm random! ^^
Group Icon
Group: Members
Joined: Dec 11, 2008

nl.gif

XXXXX



Wow! You've been cracking! Good job smile.gif So basicly you could let cars drive where they normaly wouldnt go? Like letting drive into the ocean lol.gif
Users WebsitePM
  Top
 

 
Aschratt  
Posted: Sunday, Jan 11 2009, 12:56
Quote Post


Three Headed Monkey
Group Icon
Group: Members
Joined: Apr 12, 2006

anarchist.gif

Member Award




QUOTE (Intosia @ Jan 11 2009, 13:46)
Wow! You've been cracking! Good job smile.gif So basicly you could let cars drive where they normaly wouldnt go? Like letting drive into the ocean lol.gif

Basicly yes, but the tool I am writing is a (sh*tty-coded, by scratch made) viewer, so I cannot yet edit them (only by entering every info by hand...). But it seems like R* did a lot of crappy bugs in there (Just drive over the bridges, you will see, what I mean...). Perhaps sometime we can fix them. Also this may be useful for future total conversions. smile.gif
Users WebsitePMMSNAOLYahooICQ
  Top
 

 
_Charger_  
Posted: Saturday, Jul 9 2011, 00:44
Quote Post


Germany
Group Icon
Group: Members
Joined: Apr 1, 2010

gr.gif

XXXXX



Pathtypes of IV:

IV uses only 38 different pathtypes:

CODE

1: 1 (Boats)
2: 226
3: 227
4: 228
5: 229
6: 230
7: 231
8: 232
9: 233
10: 234
11: 235
12: 236
13: 237
14: 238
15: 239
16: 240
17: 241
18: 242
19: 243
20: 244
21: 245
22: 246
23: 247
24: 248
25: 249
26: 250
27: 251
28: 252
29: 253
30: 254
31: 255
32: 225
33: 211
34: 19 (Cars)
35: 224
36: 179
37: 12
38: 147


Flags of IV:

CODE
Total Flags used: 30906
Distinct Flags used: 4083


Linkflags of IV:

CODE
Total Linkflags used: 51638
Distinct Linkflags used: 242


Information created with tool made by Charger for research. Tool is part of PathScripts by Charger and GTARandom

This post has been edited by _Charger_ on Sunday, Aug 7 2011, 15:08
PM
  Top
 

 

0 User(s) are reading this topic (0 Guests and 0 Anonymous Users)

0 Members:

Topic Options Reply to this topicStart new topicStart Poll
Search topic for posted by (exact match)



 
IMG IMG