if () statement jumping to 0x00000000

Started by
10 comments, last by -Thork- 21 years, 10 months ago
You know you can just send the gmh without copying it:

SendData((char*) &gmh, sizeof(GAMEMSGHEADER));

Then you don''t have to worry about clobbering memory, which is probably what you were doing when you set:

transmit[sizeof(GAMEMSGHEADER)] = 1;
Advertisement
// this statment is ILLEGAL and smashes the stack
transmit[sizeof(GAMEMSGHEADER)] = 0;

no matter what transmit''s size is, you should not depend
on it being the correct size ocmpared to yoru GAMESGHEADER
struct.

instead you should actually use your struct correctly
if it requires a "type" in it, then it should be part of
the struct. if you happen to change the GAMESGHEADER struct
for any reason you will break your code

if your smart you will modify your code to not rely on knowing the exact size of GAMESGHEADER when using sizeof(). VERY bad practice in this case (since you are using it for indexing into something).

also running the client and server on the same pc should work perfectly (with exception to udp if the server and client are supposed to listen on the same port which they should not). the only thing you lose is latency, and bandwidth restrictions associated with being on a network. though i agree it can sometimes be a bother if the game and server are fighting for the cpu.

This topic is closed to new replies.

Advertisement