Renegade Public Forums
C&C: Renegade --> Dying since 2003™, resurrected in 2024!
Home » Tiberian Technologies / Blackhand Studios » Tiberian Technologies Forum » CommandLineParser::getInt() doesn't work with negative integers
CommandLineParser::getInt() doesn't work with negative integers [message #471791] Tue, 17 July 2012 04:56 Go to next message
iRANian is currently offline  iRANian
Messages: 4299
Registered: April 2011
Karma: 0
General (4 Stars)
To get it to work, the digit checking loop needs to be changed to:

					if (*s < '0' || *s > '9')
					{
						if (*s == '-') continue;


But if that's done the function will still return '-1' (a valid negative number) when a non-valid number (e.g. text) is passed to the function, therefor you can't do error checking if you want to support '-1' as a value.


Long time and well respected Renegade community member, programmer, modder and tester.

Scripts 4.0 private beta tester since May 2011.

My Renegade server plugins releases
Re: CommandLineParser::getInt() doesn't work with negative integers [message #471793 is a reply to message #471791] Tue, 17 July 2012 05:18 Go to previous messageGo to next message
Omar007 is currently offline  Omar007
Messages: 1711
Registered: December 2007
Location: Amsterdam
Karma: 0
General (1 Star)
I guess you could change the function to return true/false and make it take a variable as parameter to store the value in.

http://tiberiumredux.omarpakker.nl/Old Unused Parts/Plaatjes/PromoteBanner_Hades_small.jpg
Re: CommandLineParser::getInt() doesn't work with negative integers [message #471795 is a reply to message #471791] Tue, 17 July 2012 05:44 Go to previous messageGo to next message
iRANian is currently offline  iRANian
Messages: 4299
Registered: April 2011
Karma: 0
General (4 Stars)
My thought exactly.

Long time and well respected Renegade community member, programmer, modder and tester.

Scripts 4.0 private beta tester since May 2011.

My Renegade server plugins releases
Re: CommandLineParser::getInt() doesn't work with negative integers [message #471804 is a reply to message #471791] Tue, 17 July 2012 08:27 Go to previous message
Gen_Blacky is currently offline  Gen_Blacky
Messages: 3250
Registered: September 2006
Karma: 1
General (3 Stars)
yea I noticed that earlier. I was like why isn't this working until I looked at the function.

http://s18.postimage.org/jc6qbn4k9/bricks3.png
Previous Topic: PowerupGameObj::Grant() and C4GameObj::Detonate()
Next Topic: Slow loading
Goto Forum:
  


Current Time: Thu Apr 18 03:36:57 MST 2024

Total time taken to generate the page: 0.00625 seconds