% (for someone clever)

Posted by b-tone 
% (for someone clever)
Date: August 13, 2003 11:40PM
Posted by: b-tone
in the exe theres lots of variables like %i, %d, %s.
where are these defined?
the bg music files for instance uses %i. can i set %i to any number so there would be more or less bg music files?
well, i could do less, but not more.

i changed one so it only uses lod_0.
and tried cockpit_%s but ctd.

ta.



____
Tony

Re: % (for someone clever)
Date: August 14, 2003 02:56AM
Posted by: Lo2k
Those generic variables are calling a type of variable defined elsewhere.
the char used after the % declare variable type used, d is for integer, some are for strings (s ?) or float values.

They are often used with labels using a same format as file names, you will see that cars textures names are defined in the exe with such %, one for the team name, one for the driver and one for the lod i think.



Re: % (for someone clever)
Date: August 14, 2003 03:53AM
Posted by: b-tone
yeah the car is car_%s_car%d_lod_%d
and cockpit_%2d.
i changed the %2d to %s hoping it would find cockpit_ferrari etc but it didn't.
changing lod_%d to lod_0 you can selete all the lower lods.

but where are these variables set?

for the sound it has
..\tk1.st1
..\tk%i.st1
..\tk%i.st1

where does it define i?

i know i'm probably out of my depth, but some things i've changed work, and some dont.

%s for instance.
just above the lod_ settings it has the teams listed. and changing those will mean you can change the carshape filenames.
but somewhere it must say %s=array(team names) or something??

and i imagine deleting prost form that list won't give 20 cars :)
actually i tried it. it puts a jag there, as jag is some kind of default.



____
Tony

Re: % (for someone clever)
Date: August 14, 2003 09:14AM
Posted by: Madman271
It was used for string formatting. On C/C++ this is commonly used with printf() or scanf() functions. %d is for signed integer, %u is for unsigned integer, %s id for string, %f is for floating-point, etc.

If you change, e.g. %d to %s then output might be unknown depending on value parameters passed to format the string. Look at this instruction:

int intvalue = 1;
char strvalue[] = 'one';
printf('number %d is equivalent with \"%s\" text', &intvalue, &strvalue);

The output will be:
number 1 is equivalent with "one" text

If you swap the formatting string, like this:
printf('number %s is equivalent with \"%d\" symbol', intvalue, strvalue);

The result will be incorrect, and output will be like this:
number %s is equivalent with "1" text

So be careful when changing formatting string from binary codes. The results may unpredictable, unless you also change the order of value parameters passed to string formatting function.




In reality, doesn't matter who's right but most important is who's left.
Re: % (for someone clever)
Date: August 14, 2003 09:59AM
Posted by: tux
i was just about to say that ;)





Re: % (for someone clever)
Date: August 14, 2003 10:01AM
Posted by: Ellis
That made so much sense to me :|




Racing Is Life. Anything that happens before or after is just waiting
Jesus may be able to heal the sick and bring the dead back to life, but he can't do shît for low fps
Re: % (for someone clever)
Date: August 14, 2003 10:15AM
Posted by: Madman271
Oh, I just forgot to say, we cannot just put additional %s then we get additional "feature" to get team list number, as suggested by b-tone. :)

In simple way, string formatting is help programmers to define compact template string rather than define many string which look nearly equal. e.g. define like this:

char stringformat[] = 'this is number %i';
for (loop = 0; loop < 5; loop++) printf(&stringformat, &loop);

is much simpler and save bytes space, rather than:

char string0[] = 'this is number 0';
char string1[] = 'this is number 1';
char string2[] = 'this is number 2';
char string3[] = 'this is number 3';
char string4[] = 'this is number 4';

cout(string0);
cout(string1);
cout(string2);
cout(string3);
cout(string4);

I hope b-tone understand what I mean. :)




In reality, doesn't matter who's right but most important is who's left.
Re: % (for someone clever)
Date: August 14, 2003 10:20AM
Posted by: tux
*cough* newbie programmer ways *cough* :)


ahh, the good ole days of ilke 100 strings holding near the same info :) ;)





Re: % (for someone clever)
Date: August 14, 2003 10:27AM
Posted by: Madman271
100 strings? :-o




In reality, doesn't matter who's right but most important is who's left.
Re: % (for someone clever)
Date: August 14, 2003 10:39AM
Posted by: tux
hmm, i think when most delphi progammers start, they make a blank form and use EditBox.Text instead of define a string :)

i remember in Carset Creator beta 1 (my very first ever program!!! :):):)) doing excatly that :) hehe

that was only in like july 2001/2 i think :) not sure what year, might be 2001 or 2002 ;)





Re: % (for someone clever)
Date: August 14, 2003 10:59AM
Posted by: b-tone
yeah, i understand.

fully.





*goes to concentrate on other things*



____
Tony

Re: % (for someone clever)
Date: August 14, 2003 11:04AM
Posted by: Madman271
Oooooooh...
What a brilliant idea. ;)

@b-tone:
really? :)




In reality, doesn't matter who's right but most important is who's left.
Re: % (for someone clever)
Date: August 14, 2003 12:01PM
Posted by: b-tone
i understand enough to know i dont understand :)

but i sill want to know :

but where are these variables set?

for the sound it has
..\tk1.st1
..\tk%i.st1
..\tk%i.st1

where does it define i?


there must be &i=3 somewhere right?



____
Tony

Re: % (for someone clever)
Date: August 14, 2003 12:03PM
Posted by: tux
yes :) that will be the loop





Re: % (for someone clever)
Date: August 14, 2003 12:16PM
Posted by: Madman271
The instruction may look like this:

int iSoundIndex;
for (iSoundIndex=0; iSoundIndex < MAX_SOUND_INDEX; iSoundIndex++)
{
szSoundTrackFile = printf('..\tk&i.st1', &iSoundIndex);
hFile = fOpen(szSoundTrackFile);
if (hFile)
{
...
fClose(hFile);
}
}




In reality, doesn't matter who's right but most important is who's left.
Re: % (for someone clever)
Date: August 14, 2003 12:22PM
Posted by: tux
may or does? ;) jk





Re: % (for someone clever)
Date: August 14, 2003 12:25PM
Posted by: Madman271
What? :)




In reality, doesn't matter who's right but most important is who's left.
Re: % (for someone clever)
Date: August 14, 2003 12:27PM
Posted by: tux
lol :)



i just had an idea :)


would it be possible to overwrite gp4's default sky message system and replace it with d3d?





Re: % (for someone clever)
Date: August 14, 2003 12:44PM
Posted by: Madman271
Could be, as long as we can get variables to iDirect3d and iDirect3dDevice. Also we had found a location of beginRender() and endRender() block.




In reality, doesn't matter who's right but most important is who's left.
Re: % (for someone clever)
Date: August 14, 2003 12:51PM
Posted by: tux
thats good then :) so its possible?





Sorry, only registered users may post in this forum.

Click here to login

Maintainer: mortal, stephan | Design: stephan, Lo2k | Moderatoren: mortal, TomMK, Noog, stephan | Downloads: Lo2k | Supported by: Atlassian Experts Berlin | Forum Rules | Policy