|
Possible data change after file_str_read?
#306284
01/20/10 23:15
01/20/10 23:15
|
Joined: Jan 2004
Posts: 3,023 The Netherlands
Helghast
OP
Expert
|
OP
Expert
Joined: Jan 2004
Posts: 3,023
The Netherlands
|
Hello, I'm trying to get data out of a text file to read out player movement keys. I'm using the following code (relevant piece) to do so:
var fhandle_n = file_open_read("keyMapping.ini"); // open file
STRING* tempStr = str_create("");
STRING* getCurrentKey = str_create("");
// get player number from file
str_cpy(tempStr, "player");
str_cat(tempStr, str_for_int(NULL, playerStoreNumber+1));
error(tempStr);
file_str_read(fhandle_n, tempStr);
error(tempStr);
file_close(fhandle_n); // close file
now, playerStoreNumber is a global variable, that gets increased upon every player that is placed in the level. Currently, I have 2 player models, and thus, this piece of code gets executed twice. I've put in error's to see what my string outputs. So the first time it says: player1, then the second one again after the file_str_read says player1 as well... Nothing wrong yet, but when i run this function again (to initialise the key setup for the 2nd player; the first time i get player2, but right after the file_str_read, it displays player1 again... I cant see why this should be a bug for me; since i only do a engine function call... Hope this info is usefull, but to be certain im not doing anything wrong, here's how my keyMapping.ini file looks like:
player1,w,a,s,d,q,e,c,r
player2,i,j,k,l,u,o,m,y
like I said, both times, I get the data from player1 only, even though the string appended does state player2 the second time, but get's reset after a file_str_read call. regards,
|
|
|
Re: Possible data change after file_str_read?
[Re: jcl]
#306339
01/21/10 10:01
01/21/10 10:01
|
Joined: Jan 2004
Posts: 3,023 The Netherlands
Helghast
OP
Expert
|
OP
Expert
Joined: Jan 2004
Posts: 3,023
The Netherlands
|
because that's what it outputs... look at my script, when this script is running the 2nd time i call it, the first error outputs "player2", which at that point in time, is fine to me... however, after the file_str_read, i do another error (after isolating it to that point), and it output "player1" to me... means that after the engine function call, the string got edited or reverted somehow.
That's why i flagged it as a possible bug.
regards,
|
|
|
Re: Possible data change after file_str_read?
[Re: jcl]
#306343
01/21/10 10:55
01/21/10 10:55
|
Joined: Jan 2004
Posts: 3,023 The Netherlands
Helghast
OP
Expert
|
OP
Expert
Joined: Jan 2004
Posts: 3,023
The Netherlands
|
LOL! like I said, it was very late, my brain was as dead as it could be... I assumed file_str_read set's the file read pointer to the position in the file to after the string i passed in there. instead i needed file_find for that... Again, very sorry for this stupid bug report, and for wasting your time on this *i feel very very dumb now, hahaha, maybe my title shouldnt say "Expert" :P* thanks for the help PS: Now let's see if the bug report of the model crashing gives such a weird user failure as well
|
|
|
|