Good multiplayer game design?

Hmm… Weird, the error seems to be on the size() method of
std::vector… But how can it cause errors? :-/

There is nothing wrong in your code snippet. I guess that you have a
problem with the vector itself: does this->players realy exist @ this
specific moment? Because if not, you will definitly get this segfault.
This would be the simpler case. Another possibility is, that you write in
the address region of your reference and point it to another (protected)
memory region.

In both cases, try using valgrind to check your memory management.
http://valgrind.org/

good luck,
patrick> ===============

Find
if (this->players.size() >= MAXPLAYERS)
Find again
for (int p = 0; p < this->players.size(); p++)
Find again
for (int p = 0; p < this->players.size(); p++)
No more

What the heck is wrong? :frowning: I’m sure this is one of those errors you
can’t figure out but then when you do, you say “Heck! I’m so stupid!”.
Can anyone see what’s wrong? Thanks! :wink:


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Hmm… :-/ Alright, the network variable (SockHnd pointer) was a global
variable, now I made a local in main() func, and I passed that to the
threads. Now, the error is the same, only it occurs on the begin()
function, not the size() function… :frowning:

I’m not messing with memory in this program, so it shouldn’t be a memory
problem… What else could it be? Thanks! :wink:

Hmm… :-/ Alright, the network variable (SockHnd pointer) was a global
variable, now I made a local in main() func, and I passed that to the
threads. Now, the error is the same, only it occurs on the begin()
function, not the size() function… :frowning:

I’m not messing with memory in this program, so it shouldn’t be a memory
problem… What else could it be? Thanks! :wink:

The problem does sound like a memory issue. You probably should check the
value of the this pointer in a debugger before the fatal call to see if it
is any good. As already mentioned, valgrind is an awesome tool to help
track down these problems.

Don’t forget that just by running your program you are messing with
memory. The question is one of messing up memory. It is very easy to do.On Wed, 29 Mar 2006, Leo M. Cabrera wrote:


Jeff Jackowski
http://ro.com/~jeffj/

HOOOOOOOOOLD up a minute! =-O
Both threads are running at the same time… The TradePlayers thread
runs before any player was found… Let me try fixing that… :stuck_out_tongue:
Thanks! :wink:

I came to this window twice to say I found the bug, but both times I
realized that I hadn’t half way thru the message… :frowning:

I found one thing though: My send and receive functions both receive
data! Is that the problem? :stuck_out_tongue:
I also wanted to ask, does the char pointer for SDLNet_TCP_Recv need to
be initialized? I just declared the variables with their lengths…
Thanks! :wink: