void redraw_asteroids(void) { int x, y, minx, miny, maxx, maxy; struct _clearzone *cz; int lx, ly, frame; W_Image *topleft, *topright, *bottomleft, *bottomright, *image; static W_Image *topleftsquare = NULL, *toprightsquare, *bottomleftsquare, *bottomrightsquare, *topleftrounded, *toprightrounded, *bottomleftrounded, *bottomrightrounded; if (!paradise) return; if(received_terrain_info) { int conv = blk_gwidth / 250; if(rounded_asteroids) { if(topleftsquare == NULL) { topleftsquare = getImage(I_ASTEROIDS_TOPLEFTSQUARE), toprightsquare = getImage(I_ASTEROIDS_TOPRIGHTSQUARE), bottomleftsquare = getImage(I_ASTEROIDS_BOTTOMLEFTSQUARE), bottomrightsquare = getImage(I_ASTEROIDS_BOTTOMRIGHTSQUARE), topleftrounded = getImage(I_ASTEROIDS_TOPLEFTROUNDED), toprightrounded = getImage(I_ASTEROIDS_TOPRIGHTROUNDED), bottomleftrounded = getImage(I_ASTEROIDS_BOTTOMLEFTROUNDED), bottomrightrounded = getImage(I_ASTEROIDS_BOTTOMRIGHTROUNDED); } /* draw asteroids [BDyess] */ minx = (me->p_x - view) / conv; miny = (me->p_y - view) / conv; maxx = (me->p_x + view) / conv + 1; maxy = (me->p_y + view) / conv + 1; /* only check the asteroids visible [BDyess] */ for(x = minx;x <= maxx; x++) { for(y = miny;y <= maxy; y++) { if(terrainInfo[x*250+y].types) { /* draw rounded corners if there are no adjacent squares. Otherwise draw square corners [BDyess] */ /* topleft */ if (terrainInfo[(x-1)*250+y].types || terrainInfo[x*250+y-1].types) { topleft = topleftsquare; } else { topleft = topleftrounded; } /* topright */ if (terrainInfo[(x+1)*250+y].types || terrainInfo[x*250+y-1].types) { topright = toprightsquare; } else { topright = toprightrounded; } /* bottomleft */ if (terrainInfo[(x-1)*250+y].types || terrainInfo[x*250+y+1].types) { bottomleft = bottomleftsquare; } else { bottomleft = bottomleftrounded; } /* bottomright */ if (terrainInfo[(x+1)*250+y].types || terrainInfo[x*250+y+1].types) { bottomright = bottomrightsquare; } else { bottomright = bottomrightrounded; } lx = scaleLocal(x*conv - me->p_x); ly = scaleLocal(y*conv - me->p_y); frame = udcounter + y*conv + x; W_DrawImageNoClip(w, lx, ly, frame, topleft, W_Grey); W_DrawImageNoClip(w, lx+topleft->width, ly, frame, topright,W_Grey); W_DrawImageNoClip(w, lx, ly+topleft->height, frame, bottomleft,W_Grey); W_DrawImageNoClip(w, lx+topleft->width, ly+topleft->height, frame, bottomright, W_Grey); cz = new_czone(); cz->x = lx; cz->y = ly; cz->width = topleft->width + topright->width; cz->height = topleft->height + bottomleft->height; } } } } else { /* draw asteroids [BDyess] */ minx = (me->p_x - view) / conv; miny = (me->p_y - view) / conv; maxx = (me->p_x + view) / conv + 1; maxy = (me->p_y + view) / conv + 1; image = getImage(I_ASTEROIDS_ALL); /* only check the asteroids visible [BDyess] */ for(x = minx;x <= maxx; x++) { for(y = miny;y <= maxy; y++) { if(terrainInfo[x*250+y].types) { lx = scaleLocal(x*conv - me->p_x + 400) - image->width/2; ly = scaleLocal(y*conv - me->p_y + 400) - image->height/2; frame = udcounter + y*conv + x; W_DrawImageNoClip(w, lx, ly, frame, image, W_Grey); cz = new_czone(); cz->x = lx; cz->y = ly; cz->width = image->width; cz->height = image->height; } } } } } }