code question(c++)

Discussion about Pre-THUG1 things can go here, such as modding, etc
Post Reply
Vadru
VIP
Posts: 42
Joined: Wed Jul 07, 2010 2:39 pm

code question(c++)

Post by Vadru »

I'm sorry this is a bit offtopic but Idk where else to post since it's a prog to make it easier to read th3 levels i post it under th3 modding:).

anyway here is the piece of my code that I need help with.

Code: Select all

FILE *l_file;
unsigned char rgbstart[8];
unsigned int start;
float vertexx;
float vertexy;
float vertexz;

while(rgbstart[3] != 0xFF ||rgbstart[7] != 0xFF) //while data != RGBdata
{
	start = ftell(l_file); //put current pos in start
fread (&vertexx, 4,1, l_file); //read 4 byte
fread (&vertexy, 4,1, l_file);
fread (&vertexz, 4,1, l_file);
printf("vertex %d: %fx %fy %fz pos: 0x%x\n",numvert+1,vertexx,vertexy,vertexz,start);
fread(rgbstart, 8,1, l_file); //read 8 byte to check if RGB data
fseek (l_file, -8, SEEK_CUR); //going back 8 byte to not miss data
numvert++;  //adding 1 to number of vertices each while loop
getche(); //wait for user input
}              
what I want now is to print a specific vertex
wich doesn't work with this code cause
the old vertexx, vertexy and vertexz data
is replaced each while loop so what I need is
eather a code to get back that data or
a new while loop code

CHC
Site Admin
Posts: 54
Joined: Sun Feb 28, 2010 9:43 pm

Re: code question(c++)

Post by CHC »

please be more specific of the problem

Vadru
VIP
Posts: 42
Joined: Wed Jul 07, 2010 2:39 pm

Re: code question(c++)

Post by Vadru »

hmm well each while loop vertexx, vertexy, &vertexz gets replaced with new data. So when I afterwards printf"%x\n", vertexx); for example then I only get the last vertex obviusly but I want to be able to tell wich vertex I want to print so eather I need a code that put the data in a new each loop like first loop vertexx1 or I need a code to get back the data that was replaced from vertexx, y and z, or maybe some code that would put vertexx y and z in a temp file.

%.gone.
Global Moderator
Posts: 391
Joined: Sun Mar 07, 2010 5:12 pm

Re: code question(c++)

Post by %.gone. »

You would need to store the data like in the registry or in an .ini file which you could then query later to print whichever value you want to the screen. If you choose this method you could easily set the values as vertexX_* vertexY_*, vertexZ_* where * would be the value of "numvert" and format a string to fill in * and set its value to the registry or an .ini file each loop.

Vadru
VIP
Posts: 42
Joined: Wed Jul 07, 2010 2:39 pm

Re: code question(c++)

Post by Vadru »

Thx that was what I wanted I'll try that and come back and tell if I got it to work or not :P.

jestemkaspi
Posts: 1
Joined: Sun Sep 05, 2010 5:21 am

Re: code question(c++)

Post by jestemkaspi »

Hello!
Since it's my first post in here.. I'm not sure if I'm correct.

Why not just use Array?
Here is a good example:
http://augustcouncil.com/~tgibson/tutorial/arr.html

Even if it's quite old topic, it could help someone ;)

Post Reply