is it possible? ( warnings with VS.net 2003)

Started by
12 comments, last by graveyard filla 19 years, 3 months ago
Quote:Original post by Solias
Quote:Original post by graveyard filla
...anyway, basically when i write to a packet i do something like packet.write((Player_NetID)some_player->Get_NetID()). anyway, when i switched from it saying "Uint8" to "Player_NetID", i just wanted to turn on a warning so i could make sure i didnt screw up anywhere and forget to change it in some place.

also, some_player->Get_NetID() actually returns an integer, but Player_NetID is typedef'd to be an unsigned char.


Maybe make Get_NetID() return a Player_NetID instead of an int? That would make more sense to me anyway. The purpose of the type Player_NetID is to hold a player net ID, so any place you are going to have one of those just go ahead and use that type. Then if you need to change it in the future it will change everywhere. It seems like it's a bad idea to store it anywhere as an int if you aren't going to make it an int everywhere.


yes, but the problem is that some_player->Get_NetID() is a member of a parent class. this parent has a member called Mem_NetID which is a typedef to an int. Get_NetID() returns this..

Drew, thanks, ill look at that page.
FTA, my 2D futuristic action MMORPG
Advertisement
Quote:Original post by graveyard filla
anyway, basically when i write to a packet i do something like packet.write((Player_NetID)some_player->Get_NetID()). anyway, when i switched from it saying "Uint8" to "Player_NetID", i just wanted to turn on a warning so i could make sure i didnt screw up anywhere and forget to change it in some place.


This is a great example of why type casting is evil and should be avoided.

One of the nice things about C++-style casts is that you can search for "static_cast", "reinterpret_cast", etc. and find every type cast in your code.
John BoltonLocomotive Games (THQ)Current Project: Destroy All Humans (Wii). IN STORES NOW!
boost::numeric_cast and the improved version.
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
thanks Fruny.. this is exactly what i needed.
FTA, my 2D futuristic action MMORPG

This topic is closed to new replies.

Advertisement