Page 1 of 1

Trying to parse GetAccountNum() into a string! GRR

Posted: Tue Jan 20, 2009 8:16 pm
by Jediman
Perhaps Giwo or someone could shed some light onto this..

While writing the code for the player pages output, I'm proposing that the directory format be:

(html_path_definied_in_ini)\players\(account_#)\
Under that would be the player page belonging to that account e.g Jediman.

The problem is GetAccountNum() is a UI16...where as I need it to be a string to append to my path parsing parameters (say THAT three times fast XD).

I can't seem to find a way to copy that UI16 or parse it over to a string format, and was hoping someone could shed light onto the matter.

Right now I'm using (html_path_definied_in_ini)\players\(account_name)\ and it's really a security hole!

Posted: Tue Jan 20, 2009 9:18 pm
by Jediman
AHA
Solved it!

UI16 playerActID;
playerActID += tChar->GetAccountNum();

UString pAccountId = UString::number(playerActID);


:-D *does the happy dance*

Posted: Wed Jan 21, 2009 9:59 am
by Maarc

Code: Select all

				UI16 playerActID;
				playerActID += tChar->GetAccountNum();

				UString pAccountId = UString::number(playerActID);
You can simplify

Code: Select all

				UString pAccountId = UString::number( tChar->GetAccountNum() );
Unless, of course, you want to reuse. But if you don't want to reuse, don't use += operator. Something like:

Code: Select all

				UI16 playerActID = 0;
...
...
...
				playerActID = tChar->GetAccountNum();
or

Code: Select all

				UI16 playerActID = tChar->GetAccountNum();
VC debug builds do nice things like initialising your vars to 0 and such. In release, you've no such safeguards :) Tracking such bugs can be annoying.

Posted: Wed Jan 21, 2009 3:13 pm
by Jediman
Maarc, great point!

Thats something I think I've forgotten to do over the years thanks to dirty coding with C# :)

Once I get the framework layed out i'll be going through with a fine toothed comb to optimise the code and fix things to ensure it works with the release and not just debug :-D