Anybody know why this snippit from gtk/maps.c works:
void display_mapscroll(int dx,int dy)
{
int x,y;
int local_mapx= 0, local_mapy= 0;
/* We don't need to memcopy any of this stuff around cause
* we are keeping it in memory. We do need to update our
* virtual position though
*/
if( need_recenter_map( dx, dy) == TRUE)
recenter_virtual_map_view( &the_map);
pl_pos.x+= dx;
pl_pos.y+= dy;
local_mapx= pl_pos.x + use_config[CONFIG_MAPWIDTH];
local_mapy= pl_pos.y + use_config[CONFIG_MAPHEIGHT];
/*
* For cells about to enter the view, mark them as
* needing an update. Cells that are already in
* view don't need to be updated since we just memcpy
* the image data around. This is needed for proper
* drawing of blank or black tiles coming into view
*/
for( x= pl_pos.x; x < pl_pos.x + use_config[CONFIG_MAPWIDTH]; x++) {
for( y= pl_pos.y; y < pl_pos.y + use_config[CONFIG_MAPHEIGHT]; y++) {
if( (x + dx) < pl_pos.x || (x + dx) >= (use_config[CONFIG_MAPWIDTH] + pl_pos.x) ||
(y + dy) < pl_pos.y || (y + dy) >= (use_config[CONFIG_MAPHEIGHT] + pl_pos.y) )
{
if( x < 0 || y < 0 || x >= the_map.x || y >= the_map.y)
continue;
the_map.cells[x][y].need_update= 1;
the_map.cells[x][y].cleared= 1;
-----------------------------------------------------------
And this python that should do the same thing isn't working:
elif (data[0] == "map_scroll"):
#data format: (plaintextint) (plaintextint)
#print "map_scroll: " + data[1]
vals = data[1].split(" ")
oldcurx = self.curx
oldcury = self.cury
self.curx += int(vals[0]) #unlike in the normal client curx and cury are the location of the player, not the location of the top left corner of view
self.cury += int(vals[1])
self.leftbound = (self.curx-12) #assumes the 25x25 mapsize
self.rightbound = (self.curx+12)
self.topbound = (self.curx-12)
self.bottombound = (self.curx+12)
xtilerange = range(self.leftbound, self.rightbound)
ytilerange = range(self.topbound, self.bottombound)
for x in xtilerange:
for y in ytilerange:
if ((x+int(vals[0])) < self.leftbound) or ((x+int(vals[0])) >= self.rightbound) or ((y+int(vals[1])) < self.topbound) or ((y+int(vals[1])) >= self.bottombound):
packloc2 = struct.pack("!3h",x,y,0)+"b"
if (not mapfaces.has_key(packloc2)):
mapfaces[packloc2]=True #same meaning as mapcells.cleared=1 in the normal client