Support Forums

Full Version: Online game, coding problems.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I ran an online game since about 2002, Coded with c, java, perl and cgi.

When Linux updated higher than Linux Kernel 2.6.17 My game started posing errors. Then it started crashing. I have about 3 out of 4 problems fixed, If I post my examples of problems can I get assistance in probably fixing the last one?

My game ran the function, gettip to gettid to make this function look like this

Now this one. Everytime I suspended a bad member to the "Wizard Channel", and they tried talking in it, the game would crash.

Now my last issue That I cannot seem to resolve is, when players go together in ITCombat. Meaning they land on the same coordinates the game crashes automatically. I cannot seem to figure out why that is
Here is the code.


I would appreciate any help you can give me. Thank you.
What do you use to program with?

I'm guessing the crash you're getting is related to memory access problems, since you're using a lot of array's and pointers. These are pretty easy to correct with a good debugger. Sadly, I can only help if you're using Visual Studio or Visual Express. I don't like Microsoft, but there debuggers are really easy to work with (and the sole reason why I use Visual Studio)

What you could try (if you're running something from MS):
- run the program inside the IDE
- force a crash. When it happens, you need to "debug and view the call stack" or something along those line. The stack contains all data at the moment of execution, and is the easiest way of catching your bug.
- if you're using Visual Express/Studio, it'll show all the variables in the stack and highlight where it went wrong. It always boils down to the same problem: a pointer is being used which points to some random location instead of the proper object.

This might be because the object it's supposed to point to A) never got created B) was created inside a function, without using "new" to reserve space on the stack (and thus it got destroyed when the function ended) C) got lost in translating pointers to references to pointers to references etc etc.

If you actually look at the stack at the moment of the crash, it should become clear which data is missing. Then you just track down where you create the troubled object (and in 99% of all cases, smack yourself against the head because you forgot to reserve space with "new")

If you're not using a debugger, put "cout << somenumber << endl;" every even/odd line to locate the exact moment stuff starts crashing.
your last error 4/4
wut is going on with the flags?



/* if our flag is set, there is a problem */
if (!theCombat->opponentFlag[1]) {

theCombat->opponentFlag[0] = TRUE;
theCombat->opponentFlag[1] = FALSE;

Do_opponent_struct(c, &theCombat->opponent[1]);

if (c->player.energy <= 0) {

theCombat->message = IT_JUST_DIED;
Do_unlock_mutex(&theCombat->theLock);
kill(theCombat->opponent[0].processID ,SIGIO);
Do_lock_mutex(&c->realm->realm_lock);
c->game->it_combat = NULL;
Do_unlock_mutex(&c->realm->realm_lock);[/code]




Now I am not the most avid C++ coder which btw I must give you sum serious coodos for such a nice program.. But I dont beleive the BOLD sentences are legitimate arguments, even though your IDE may let you get away with this, I dont beleive that those two lines actually do something. maybe if you proceded with an "if" statement and capped the arguments in braces it "MIGHT" work. I was hesitant to awnser with a reply cause I didnt want to fail/seam like a dumbass offering null advice, but who knows maybe it might work? and at the very least a bump to the thread
lol, i have never seen that before, goodluck Smile
Oh, there maybe a problem with something, I'm still learning, so no opinions. Sorry.