 |
Server Help Community forums for Subgame, ASSS, and bots
|
Author |
Message |
gilder Novice

Age:36 Gender: Joined: Sep 02 2006 Posts: 35 Location: Finland Offline
|
Posted: Fri Dec 08, 2006 1:20 pm Post subject: A hidden bug in my module |
 |
|
|
|
I have been trying to fix this bug for a few days now and I just can't find it. The code is about 650 rows long so I don't know if anyone is willing to help. I'll try to explain my problem as well as I can.
When I enter commando arena, go in, right and enter the commando region, bots will appear. When I spec, while bots are still in, and enter again, zone crashes. Bots will appear before I even can get in and server acts like I was in warbird. If I leave the arena and come back, I can enter again without crashing my zone.
To give you better idea what's going on, I put level file, arena.conf, dll and .c file in this zip.
Thanks _________________ Hockey Zone
commando.zip - 46.25 KB
File downloaded or viewed 13 time(s)
|
|
Back to top |
|
 |
Cyan~Fire I'll count you!

Age:37 Gender: Joined: Jul 14 2003 Posts: 4608 Location: A Dream Offline
|
Posted: Sat Dec 09, 2006 11:51 am Post subject: |
 |
|
|
|
Looking at it... I'll edit this post if I find anything.
const char tracknames[TRACKS][10]; |
I don't think this is related to your bug, but I believe the [TRACKS] and [10] should be reversed. (And store this in a linked-list or something dynamically-sized anyway for goodness sake.)
Not a bug, just a suggestion for less typing (and better reliability):
strcpy(str, "Track");
strcat(str, myitoa(i+1));
strcat(str, "Name"); | could and should be
_snprintf(str, sizeof(str), "Track%dName", i+1); |
_________________ This help is informational only. No representation is made or warranty given as to its content. User assumes all risk of use. Cyan~Fire assumes no responsibility for any loss or delay resulting from such use.
Wise men STILL seek Him.
|
|
Back to top |
|
 |
gilder Novice

Age:36 Gender: Joined: Sep 02 2006 Posts: 35 Location: Finland Offline
|
Posted: Sat Dec 09, 2006 3:50 pm Post subject: |
 |
|
|
|
Thanks for your time.
I started to work with this project more and now it doesn't crash when i spec and re-enter, and i have no idea why.. May be even a small conf value change. Who knows.
|
|
Back to top |
|
 |
Smong Server Help Squatter

Joined: 1043048991 Posts: 0x91E Offline
|
Posted: Sun Dec 10, 2006 12:36 pm Post subject: |
 |
|
|
|
md->FindRegionByName(arena, tracknames[i]) can fail, you should check whether what it returns is NULL or not, also tracknames[i] may be unset depending on what's in your conf.
game->SetFreqAndShip(), if you aren't changing the freq just use SetShip().
Unpacking settings: (Track#Bot#Point#: coordinates are in pixels)
char buf[64];
const char *s;
int a, b;
snprintf(buf, sizeof(buf), "Track%dBot%dPoint%d", event+1, part+1, point+1);
s = cfg->GetStr(arena->cfg, "Commando", buf);
if (s)
{
a = b = 0;
sscanf(s, "%d , %d", &a, &b);
*x = a;
*y = b;
} |
If you enable compiler warnings (such as -Wall in gcc) it will tell you myitoa() is returning an address to a local variable. If you read the settings how I demonstrated above you can get rid of the myitoa function.
As for the crashing problem, it did happen to me too. But then it kinda stopped, so it may be something to do with reading from unitialised memory. _________________ ss news
|
|
Back to top |
|
 |
Cyan~Fire I'll count you!

Age:37 Gender: Joined: Jul 14 2003 Posts: 4608 Location: A Dream Offline
|
Posted: Sun Dec 10, 2006 1:43 pm Post subject: |
 |
|
|
|
Ooh, I didn't even catch that bug with myitoa(). So that was actually a bug, not just a suggestion.
|
|
Back to top |
|
 |
Smong Server Help Squatter

Joined: 1043048991 Posts: 0x91E Offline
|
Posted: Sun Dec 10, 2006 5:26 pm Post subject: |
 |
|
|
|
Also "const char tracknames[TRACKS][10]" shouldn't be reversed, but you need to remove the const keyword. I also notice some other place in your code you put Botdata instead of BotData, not sure what compiler you are using but I can't imagine many allowing that.
|
|
Back to top |
|
 |
Cyan~Fire I'll count you!

Age:37 Gender: Joined: Jul 14 2003 Posts: 4608 Location: A Dream Offline
|
Posted: Sun Dec 10, 2006 9:34 pm Post subject: |
 |
|
|
|
Smong's right about the reversing, my bad.
|
|
Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You can attach files in this forum You can download files in this forum
|
Software by php BB © php BB Group Server Load: 324 page(s) served in previous 5 minutes.
|