TremZ/Unvanquished — pull request #37 by computerquip (2012-03-07 23:17:52+00:00)
Title: q_shared.?, cl_main: Fixed warnings and proposed removal of Q_isanumber()

1) Removed an unused local variable "pc" from within a function of q_shared.c.
2) Removed Q_isanumber for the sake of both removing a warning and optimizing. More reason below.

Q_isanumber was used a single time throughout the entire engine/game which was in cl_main.c
Not only that, it's also an inefficient method of going about it's purpose.
Essentially, any time you want to know if a string is a number, you always want the numerical value attached as well.
Otherwise, there's no reason for you to ask if the string had numerical value in the first place.
So simply making a method that asks if a string has numerical value is bad design.

In implementation, Q_isanumber used strtod to see if it match a float.
After it was called, cl_main would then call atoi to convert the string into an integer.
This means that the string was actually converted twice and twice as many function calls are made.
While keeping type-safety and the convention of returning a bool, I've provide a solution to these issues.

Also, you'll notice there's no double counterpart for the alternative functions.
This wasn't done on purpose. I just saw no reason to add a function that probably won't be used.
If any other parsing functions are needed, they are easily made using the same function implementation and different types.