|
[A6.60] Random problem with str_for_num
#269635
06/03/09 21:30
06/03/09 21:30
|
Joined: Feb 2006
Posts: 2,185
mpdeveloper_B
OP
Expert
|
OP
Expert
Joined: Feb 2006
Posts: 2,185
|
I've tested, and tested, and tested some more....this is really starting to get to me. Another odd, random bug. I have a string 'dipswtxt' which is used to write out text on the screen, and shows things like volumes and other things. I use a Text to show it on the screen, there are multiple lines, dipswtxt is defined like this: string dipswtxt[9999]; which is fine, that means that dipswtxt has 9999 characters it can hold. Now, sample code: str_cat(dipswtxt, "\n Sound Volume -> ");
////put sound volume code here
str_for_num(tmp_str3, sfx_volume);
str_cat(dipswtxt, tmp_str3); simple enough, right? It should output something like this: '25' being the number of the sfx_volume. Well here's the thing, most of the time it shows up like that, but sometimes it shows up like this: .....T? Where the hell did T come from? Before you ask, yes sfx_volume is a number, no it is not a vector, and yes this is the only code partaining to turning that particular variable into a string. I have no idea why there is a problem. This bug is soooo random, and it doesn't only happen on one system, on another system instead of a 'T', there is a '\'. How do I fix this? It's random and I have no way of testing it, I've noticed this problem with str_for_num or multiple occasions, is there a way to fix it? (don't say get A7)
- aka Manslayer101
|
|
|
Re: [A6.60] Random problem with str_for_num
[Re: jcl]
#269790
06/04/09 16:13
06/04/09 16:13
|
Joined: Feb 2006
Posts: 2,185
mpdeveloper_B
OP
Expert
|
OP
Expert
Joined: Feb 2006
Posts: 2,185
|
Well see here's the thing.
@Helghast: I made tmp_str3 specifically for these lines of code. The reason I made a new string is because I thought this might be it. Believe me, there is no way that the string is being rewritten before it shows on screen.
@jcl: I'm not so sure, the bug just randomly popped up one day. Then it went away for a few months, and now it's back...magically. See, not all my strings mess up, just a few of them. Originally the problem was only with a timer, I tried to fix it by making a new string that is specifically for that timer and a new variable that held the proper number. It worked for a while, but that can't be the problem because it changed again.
I also thought it might be a plugin we were using, but I removed it and there was no change. I also don't think it's a corrupt file because if it were any of the files we use, models, levels, images, or scripts, the engine would crash. As of now, these are the only files being used in the game.
See the thing is that like I said, not all the functions that use str_to_num do it. I had a similar problem with another str_ function recently, although I cannot remember the function. Once I made my own variation of the function it worked perfectly.
By the way, I tested copying the actual text to a txt file, and i tested it with a TrueType font, the characters it's actually giving me is a T and two odd symbols.
The only thing I can think of is that while it's trying to convert the number to a string, the string becomes corrupt and inputs the wrong string info.
- aka Manslayer101
|
|
|
Re: [A6.60] Random problem with str_for_num
[Re: mpdeveloper_B]
#269805
06/04/09 18:14
06/04/09 18:14
|
Joined: Feb 2008
Posts: 3,232 Australia
EvilSOB
Expert
|
Expert
Joined: Feb 2008
Posts: 3,232
Australia
|
Is there any way you can "booby-trap" the code so you can find out the actual value of sfx_volume when the output goes wonky? The actual value mayt give us a clue...
"There is no fate but what WE make." - CEO Cyberdyne Systems Corp. A8.30.5 Commercial
|
|
|
Re: [A6.60] Random problem with str_for_num
[Re: EvilSOB]
#269832
06/04/09 19:46
06/04/09 19:46
|
Joined: Feb 2006
Posts: 2,185
mpdeveloper_B
OP
Expert
|
OP
Expert
Joined: Feb 2006
Posts: 2,185
|
the actual value is between 10 and 100. I am 100% sure the variable is outputting correctly. The problem is not in the variable. I have a slider for adjusting the volume, which is then set to the actual variable (sfx_volume = int(sfx_volume);) so that the variable is set to an absolute number, and the number does not have decimals, and is not set into a vector.
I can set the variable exactly, using the console and would get the same problem.
I think that something is causing the str_for_num function to go crazy, but only in specific things.
For instance, recently I was setting a variable for a level to load, once you finish a game it loads the next level. The levels are named level01.wmb - level10.wmb . Now, the level loading worked perfect until it got to level 10, which, when i checked the code, was something like this:
level-----.wmb
the ----- being odd symbols that don't make any sense. there was no number or anything, and the problem is not the variable or the actual string...the problem lies somewhere in the str_for_num turnover. I'm not blaming this on the function, but there is something that is causing it to go awry.
And also, I've checked my list of functions and variables, there is no variable or function that i named str_for_num, so that's not it.
Believe me, I've tested this many times, I know for sure that the variables and actual strings are not the cause.
I have thought of one thing that may lead to it. Is there a limit to the amount of strings that you can have defined? I think if this is possible than it may be the culprit, I may have too many strings defined. ( I have around 180 or so defined )
edit: to confirm that the variables are correct, I used a watch and debug mode. They are set properly.
edit2: I'm starting to debate about writing a function that copies the variable to a text file and copies that to a string, it would possibly eliminate the problem, but I don't want to have to do that to fix it :P
Last edited by mpdeveloper_B; 06/04/09 20:00.
- aka Manslayer101
|
|
|
Re: [A6.60] Random problem with str_for_num
[Re: jcl]
#270021
06/05/09 15:25
06/05/09 15:25
|
Joined: Feb 2006
Posts: 2,185
mpdeveloper_B
OP
Expert
|
OP
Expert
Joined: Feb 2006
Posts: 2,185
|
It doesn't. That's what's so odd about it.
- aka Manslayer101
|
|
|
Re: [A6.60] Random problem with str_for_num
[Re: mpdeveloper_B]
#270597
06/08/09 22:43
06/08/09 22:43
|
Joined: Feb 2006
Posts: 2,185
mpdeveloper_B
OP
Expert
|
OP
Expert
Joined: Feb 2006
Posts: 2,185
|
I never found what the problem was so I just made my own function for converting variables to strings :P.
You can close the thread.
- aka Manslayer101
|
|
|
|