Server Help Forum Index Server Help
Community forums for Subgame, ASSS, and bots
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   StatisticsStatistics   RegisterRegister 
 ProfileProfile   Login to check your private messagesLogin to check your private messages   LoginLogin (SSL) 

Server Help | ASSS Wiki (0) | Shanky.com
Bug: Overlapping Regions (I hope)

 
Post new topic   Reply to topic Printable version
 View previous topic  Thanks for Windows build Post :: Post TCP Billing Protocol Stuff  View next topic  
Author Message
Bak
?ls -s
0 in


Age:26
Gender:Gender:Male
Joined: Jun 11 2004
Posts: 1826
Location: USA
Offline

PostPosted: Mon Jan 03, 2005 2:01 pm    Post subject: Bug: Overlapping Regions (I hope) Reply to topic Reply with quote

There's a bug with eLVL files and overlapping regions.

Here's you can detect it:

download the attached overlapping.lvl file. It defines two regions(testRegion and then overlappingRegion) that are identical, as you can tell by the hex:



They are both encode one tile (0,0), while every other tile is not in either region.

Then you make a module using the attached (testModule.c) source... here's the part that matters from the source:

Code: Show/Hide

local void PlayerAction(Player *p, int action, Arena *arena)
{
   if (action == PA_ENTERGAME)
   {
      Region *test = md->FindRegionByName(arena,"testRegion");
      Region *over = md->FindRegionByName(arena,"overlappingRegion");
      int x = 0;
      int y = 0;

      if (test && over)
      {
         if (md->Contains(test,x,y))
         {
            printf("point is in the test region.\n");
         }
         else
         {
            printf("point is NOT in the test region\n");
         }

         if (md->Contains(over,x,y))
         {
            printf("point is in the overlapping region.\n");
         }
         else
         {
            printf("point is NOT in the overlapping region\n");
         }
      }
      else
         printf("one of our regions is null\n");
   }
}


so when a player enters the game it will look for the two regions and check for point (0,0) in both of them. Here's the output when it's run (and a player enters the arena):

Quote:
point is NOT in the test region
point is in the overlapping region.


I'm lead to beleive that this is a bug in mapdata.c, and I guess what's happening is that when the regions are being loaded a single sparse array is used and the second encoded region (overlappingRegion) overwrites the first region (testRegions), entry in the sparse array. That's just a guess, however.

I'd debug it myself, but I'm still a little shaky on the exact details of the implemented sparse array, and the code isn't the easiest to read:

Quote:
static inline unsigned char lookup_sparse(sparse_arr c_3, int x, int y)
{
sparse_chunk_2_t *c_2 = (*c_3)[(x>>5)&31][(y>>5)&31];
if (c_2)
{
sparse_chunk_1_t *c_1 = (*c_2)[(x>>3)&3][(y>>3)&3];
if (c_1)
{
return (*c_1)[(x>>0)&7][(y>>0)&7];
}
else
return 0x00;

}
else
return 0x00;

}


I'd really like a fix for mapdata.c which handles overlapping regions correctly.

MGB: I still can't have two code block in one post icon_sad.gif




the module source you can detect the bug with

testModule.c - 1.49 KB
File downloaded or viewed 23 time(s)

hexSS.PNG - 11.02 KB
File downloaded or viewed 22 time(s)

The .lvl with overlapping regions at (0,0)

overlapping.lvl - 48.66 KB
LVL Preview: Full Size - Half Size
File downloaded or viewed 19 time(s)
Back to top
View users profile Send private message Add User to Ignore List AIM Address
Grelminar
Creator of Asss


Joined: Feb 26 2003
Posts: 378
Offline

PostPosted: Thu Jan 06, 2005 1:05 am    Post subject: Reply to topic Reply with quote

Don't try to read the sparse array code directly. It's generated by a script, gensparse.py, which can customize it for different sizes and time/space tradeoffs. The script isn't much easier to read, though. I'll bet the problem isn't in the sparse array stuff, though, but in how mapdata uses it. It's not as simple as overwriting a value, though: I tried to be clever and associate sets of overlapping regions with values in the sparse array. The cleverness saves about 30% of memory for region stuff, but is sort of complicated. I'lll take a look at this case in a minute.

Btw, are you using 1.3.2 or stuff from CVS? I fixed a rather serious bug in mapdata.c a week or two after 1.3.2.
Back to top
View users profile Send private message Add User to Ignore List Send email Visit posters website
Bak
?ls -s
0 in


Age:26
Gender:Gender:Male
Joined: Jun 11 2004
Posts: 1826
Location: USA
Offline

PostPosted: Thu Jan 06, 2005 1:51 am    Post subject: Reply to topic Reply with quote

I'm using 1.3.2, can you post the new mapdata.c (or location of the CVS + how to access it).
Back to top
View users profile Send private message Add User to Ignore List AIM Address
Grelminar
Creator of Asss


Joined: Feb 26 2003
Posts: 378
Offline

PostPosted: Thu Jan 06, 2005 2:02 am    Post subject: Reply to topic Reply with quote

This was definitely a bug, and it's fixed. I've attached the updated file. You might have to add '#include "settings/game.h"' to make it compile with 1.3.2, though.



mapdata.c - 22.07 KB
File downloaded or viewed 13 time(s)
Back to top
View users profile Send private message Add User to Ignore List Send email Visit posters website
Bak
?ls -s
0 in


Age:26
Gender:Gender:Male
Joined: Jun 11 2004
Posts: 1826
Location: USA
Offline

PostPosted: Thu Jan 06, 2005 2:35 am    Post subject: Reply to topic Reply with quote

no dice? It doesn't seem to work; I get the same output with the testModule:

Quote:
point is NOT in the test region
point is in the overlapping region


Did you change any other files?

On another note, it would be nice if findRegionByName returned an empty region instead of NULL if it couldn't find a region, if it didn't take up too much space... or if the contains function checked for null... basicly I want to be able to do:

md->Contains(md->FindRegionByName(arena,"anyname"),512,512)

and not have the server crash, but I can see why it's done the way it is... and this isn't a pressing issue.
Back to top
View users profile Send private message Add User to Ignore List AIM Address
Grelminar
Creator of Asss


Joined: Feb 26 2003
Posts: 378
Offline

PostPosted: Thu Jan 06, 2005 3:13 am    Post subject: Reply to topic Reply with quote

It works fine for me. Are you sure the new one is compiling and getting loaded?

Yes, I did change lots of other files since 1.3.2. I'll try to make a new release soon.

I'd rather have it return NULL so that you can tell the difference between a region that doesn't exist, and a region that exists but is empty. You can easily write your own function to take an arena and a name and coords and return what you want.
Back to top
View users profile Send private message Add User to Ignore List Send email Visit posters website
Bak
?ls -s
0 in


Age:26
Gender:Gender:Male
Joined: Jun 11 2004
Posts: 1826
Location: USA
Offline

PostPosted: Thu Jan 06, 2005 11:42 am    Post subject: Reply to topic Reply with quote

You're right, I had the wrong one loading. Works great, thanks grel.
Back to top
View users profile Send private message Add User to Ignore List AIM Address
Display posts from previous:   
Post new topic   Reply to topic    Server Help Forum Index -> ASSS Questions All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
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
View online users | View Statistics | View Ignored List


Software by php BB © php BB Group
Server Load: 40 page(s) served in previous 5 minutes.

phpBB Created this page in 0.523026 seconds : 34 queries executed (83.0%): GZIP compression disabled