logo logo

 Back to main page

The NWNX Community Forum

 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
Solved: Yet another memory thread (lists)

 
Post new topic   Reply to topic    nwnx.org Forum Index -> Windows development
View previous topic :: View next topic  
Author Message
chrono



Joined: 03 Jun 2005
Posts: 2

PostPosted: Fri Jun 03, 2005 11:05    Post subject: Solved: Yet another memory thread (lists) Reply with quote

Hi

I'm trying to decode the NWN memory, but without too much luck. As of now, I'm working with triggers and have successfully extracted data such as the location of it and some other things, but what I also am looking for is the geometry nodes and their positions. This is where my problem comes in as they are stored in lists and I can't seem to figure them out. I've read the "Decoding NWN memory - Part I" about lists, but somehow it doesn't work, most likely since I'm not too experienced with this kind of programming Razz

That guide says:
Quote:
SListPointer:
int pointerToSPreList
int NumberOfListElements


and I know I have 4 nodes in my trigger (04 00 00 00) and I find two occourences at 0x214 and 0x224 (relative from pGameObject and both of these changes to the right amount of nodes (I've tested it)) but no preceeding pointer (only 00 00 00 00). So, either I got the wrong address or something.

Anyway, what I wanted to ask is if anyone got some example code on how to work with lists (which has entries, and elements below that) or if someone else has worked with this? I'm starting to lose hair... Wink

Thanks in advance
Back to top
View user's profile Send private message
chrono



Joined: 03 Jun 2005
Posts: 2

PostPosted: Fri Jun 03, 2005 17:53    Post subject: Reply with quote

Hehe, finally solved it. I was so close all of the time...

0x214 is where the amount of nodes are saved, and the following four bytes at 0x218 is the address to where all the nodes are saved (starting with the first one). They are all stored in the format of "PositionX, PositionY, PositionZ" and the absolute coordinates are those who are stored, not the relative ones. So the first 12 bytes of the first node comes at that address, followed by the next 12, etc. Here's a little snipper to illustrate (sorry for my not-so-good C++ skills):

Code:

   float fPosX = *(float*)(pGameObject + 0x78);
   float fPosY = *(float*)(pGameObject + 0x7C);
   float fPosZ = *(float*)(pGameObject + 0x80);
   int nNodes = *(int*)(pGameObject + 0x214);
   
   Log(0, "fPosX: %f\n", fPosX);
   Log(0, "fPosY: %f\n", fPosY);
   Log(0, "fPosZ: %f\n", fPosZ);
   Log(0, "Geometry Nodes: %d\n", nNodes);
   Log(0, "--------\n");

   char* pNodes = (char*)(*(int*)(pGameObject + 0x218));
   int iNode;
   
   for (iNode = 0; iNode < nNodes; iNode++)
   {
      float fNodeX = *(float*)(pNodes + (0x0C * iNode));
      float fNodeY = *(float*)(pNodes + (0x0C * iNode) + 0x04);
      float fNodeZ = *(float*)(pNodes + (0x0C * iNode) + 0x08);
      Log(0, "#%d fNodeX: %f\n", iNode, fNodeX);
      Log(0, "#%d fNodeY: %f\n", iNode, fNodeY);
      Log(0, "#%d fNodeZ: %f\n", iNode, fNodeZ);
   }


This outputs something like this:

Code:

fPosX: 33.000000
fPosY: 57.000000
fPosZ: 5.000000
Geometry Nodes: 4
--------
#0 fNodeX: 34.000000
#0 fNodeY: 58.000000
#0 fNodeZ: 6.000000
#1 fNodeX: 34.000000
#1 fNodeY: 59.000000
#1 fNodeZ: 7.000000
#2 fNodeX: 35.000000
#2 fNodeY: 59.000000
#2 fNodeZ: 8.000000
#3 fNodeX: 35.000000
#3 fNodeY: 58.000000
#3 fNodeZ: 9.000000


Which is correct. The coordinates of the trigger is (33, 57, 5) and the 4 nodes are:
Code:
(1, 1, 1)
(1, 2, 2)
(2, 2, 3)
(2, 1, 4)

which makes a rather funny shape, but good for testing. These values were set with Leto to ensure accuracy. So, as mentioned above, the coordinates stored in memory are the absolute coordinates, not the relative ones.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    nwnx.org Forum Index -> Windows development All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group