Ignore:
Timestamp:
Apr 20, 2011, 12:39:27 AM (11 years ago)
Author:
Sam Hocevar
Message:

imlib: use vec2i for image::size and unroll all necessary changes
everywhere else in the code.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • abuse/trunk/src/endgame.cpp

    r494 r512  
    1212
    1313#include <math.h>
     14
     15#include "common.h"
    1416
    1517#include "menu.h"
     
    4345static mask_line *make_mask_lines(image *mask, int map_width)
    4446{
    45   mask_line *p=(mask_line *)malloc(mask->height()*sizeof(mask_line));
    46   for (int y=0; y<mask->height(); y++)
     47  mask_line *p=(mask_line *)malloc(mask->Size().y*sizeof(mask_line));
     48  for (int y=0; y<mask->Size().y; y++)
    4749  {
    4850    // find the start of the run..
     
    5658    int size=0;
    5759    uint8_t *sl_start=sl;
    58     while (*sl!=0 && x<mask->width()) { sl++; x++; size++; }
     60    while (*sl!=0 && x<mask->Size().x) { sl++; x++; size++; }
    5961    p[y].size=size;
    6062
     
    7577        *rem=map_width/2-(int)(sqrt((size-x)/(double)(size*2.0))*map_width/2.0);
    7678
    77 //      (int)(mask->width()-(sqrt((size-x)/(double)size)*map_width/2.0)+mask->width()/2);
     79//      (int)(mask->Size().x-(sqrt((size-x)/(double)size)*map_width/2.0)+mask->Size().x/2);
    7880    }
    7981  }
     
    8688{
    8789  int x1=10000,x2=0;
    88   int iw=im1->width();
     90  int iw=im1->Size().x;
    8991  uint16_t r,off;
    9092  int y=0;
     
    159161
    160162
    161   mask_line *p=make_mask_lines(cache.img(mask),cache.img(planet)->width());
     163  mask_line *p=make_mask_lines(cache.img(mask),cache.img(planet)->Size().x);
    162164
    163165  int explo_frames1[8],explo_frames2[7];
     
    175177  int eoff=0,coff=0;
    176178
    177   int ex=xres/2-cache.img(mask)->width()/2;
    178   int ey=yres/2-cache.img(mask)->height()/2;
     179  int ex=xres/2-cache.img(mask)->Size().x/2;
     180  int ey=yres/2-cache.img(mask)->Size().y/2;
    179181  fade_out(16);
    180182
     
    212214
    213215
    214   scan_map(screen,ex,ey,cache.img(planet),cache.img(planet2),0,paddr,p,cache.img(mask)->height(),eoff,coff);
     216  scan_map(screen,ex,ey,cache.img(planet),cache.img(planet2),0,paddr,p,cache.img(mask)->Size().y,eoff,coff);
    215217  image *tcopy=cache.img(planet)->copy();
    216218  fade_in(NULL,32);
     
    241243           cache.img(planet2),
    242244           0,paddr,
    243            p,cache.img(mask)->height(),eoff,coff);
     245           p,cache.img(mask)->Size().y,eoff,coff);
    244246      }
    245247      else
     
    247249           cache.img(planet2),
    248250           0,paddr,
    249            p,cache.img(mask)->height(),eoff,coff);
     251           p,cache.img(mask)->Size().y,eoff,coff);
    250252      if (i>38)
    251253      {
    252254    int t=i-38;
    253255    image *s=cache.img(ship);
    254     int nw=s->width()*(t+2)/16,
    255         nh=s->height()*(t+2)/16;
    256 
    257 
    258         scale_put_trans(s,screen,ex-(i-38)*5,ey+cache.img(mask)->height()/2+t*4,nw,nh);
     256    int nw=s->Size().x*(t+2)/16,
     257        nh=s->Size().y*(t+2)/16;
     258
     259
     260        scale_put_trans(s,screen,ex-(i-38)*5,ey+cache.img(mask)->Size().y/2+t*4,nw,nh);
    259261    if (i==77)
    260262      if (sound_avail&SFX_INITIALIZED)
     
    288290
    289291      scan_map(screen,ex,ey,cache.img(planet),
    290            cache.img(planet2),i*256/200,paddr,p,cache.img(mask)->height(),eoff,coff);
     292           cache.img(planet2),i*256/200,paddr,p,cache.img(mask)->Size().y,eoff,coff);
    291293
    292294      eoff+=2; if (eoff>=320) eoff-=320;
     
    296298      if (i<150 || (i<170 && ((i-149)%2)==0) || (i<180 && ((i-149)%4)==0) || (i<190 && ((i-149)%8)==0))
    297299      {
    298         clist=new ex_char(ex+jrand()%(cache.img(mask)->width()-cache.img(mask)->width()/3),
    299             ey+jrand()%(cache.img(mask)->height()-cache.img(mask)->height()/3),0,1,clist);
     300        clist=new ex_char(ex+jrand()%(cache.img(mask)->Size().x-cache.img(mask)->Size().x/3),
     301            ey+jrand()%(cache.img(mask)->Size().y-cache.img(mask)->Size().y/3),0,1,clist);
    300302    if (sound_avail&SFX_INITIALIZED)
    301303          cache.sfx(explo_snd)->play(127);
    302304      }
    303305
    304 //      clist=new ex_char(ex+jrand()%(cache.img(mask)->width(),
    305 //            ey+jrand()%(cache.img(mask)->height(),0,1,clist);
     306//      clist=new ex_char(ex+jrand()%(cache.img(mask)->Size().x,
     307//            ey+jrand()%(cache.img(mask)->Size().y,0,1,clist);
    306308
    307309      ex_char *c=clist,*last=NULL;
     
    354356           cache.img(planet2),
    355357           256,paddr,
    356            p,cache.img(mask)->height(),eoff,coff);
     358           p,cache.img(mask)->Size().y,eoff,coff);
    357359      eoff+=2; if (eoff>=320) eoff-=320;
    358360      coff+=1; if (coff>=320) coff-=320;
     
    387389         cache.img(planet2),
    388390         256,paddr,
    389          p,cache.img(mask)->height(),eoff,coff);
     391         p,cache.img(mask)->Size().y,eoff,coff);
    390392    text_draw(205-i,dx+10,dy,dx+319-10,dy+199,lstring_value(end_plot),wm->font(),cmap,wm->bright_color());
    391393    wm->flush_screen();
     
    397399
    398400
    399   for (i=0; i<cache.img(mask)->height(); i++)
     401  for (i=0; i<cache.img(mask)->Size().y; i++)
    400402  {
    401403    free(p[i].remap);
     
    434436  PtrRef r2(mid_plot);
    435437
    436   int dx=(xres+1)/2-im->width()/2,dy=(yres+1)/2-im->height()/2;
     438  int dx=(xres+1)/2-im->Size().x/2,dy=(yres+1)/2-im->Size().y/2;
    437439  im->put_image(screen,dx,dy);
    438440  console_font->put_string(screen,xres/2+35,yres/2+100-console_font->height()-2,
Note: See TracChangeset for help on using the changeset viewer.