Changeset 674


Ignore:
Timestamp:
May 16, 2011, 2:37:43 AM (10 years ago)
Author:
Sam Hocevar
Message:

game: convert a few View members to vec2i.

Location:
abuse/trunk
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • abuse/trunk/TODO

    r673 r674  
    7373refactor image::Line to merge loops
    7474
    75 view::cx1,cx2...
    76 
  • abuse/trunk/src/clisp.cpp

    r672 r674  
    18461846      view *v=current_object->controller();
    18471847      if (!v) lbreak("object has no view : view_x1");
    1848       else return v->cx1;
     1848      else return v->m_aa.x;
    18491849    } break;
    18501850    case 218 :
     
    18521852      view *v=current_object->controller();
    18531853      if (!v) lbreak("object has no view : view_x1");
    1854       else return v->cy1;
     1854      else return v->m_aa.y;
    18551855    } break;
    18561856    case 219 :
     
    18581858      view *v=current_object->controller();
    18591859      if (!v) lbreak("object has no view : view_x1");
    1860       else return v->cx2;
     1860      else return v->m_bb.x;
    18611861    } break;
    18621862    case 220 :
     
    18641864      view *v=current_object->controller();
    18651865      if (!v) lbreak("object has no view : view_x1");
    1866       else return v->cy2;
     1866      else return v->m_bb.y;
    18671867    } break;
    18681868    case 221 :
  • abuse/trunk/src/cop.cpp

    r668 r674  
    830830    if (o->controller() && o->controller()->local_player())
    831831      main_screen->PutImage(cache.img(S_health_image),
    832                             vec2i(o->controller()->cx2-20,
    833                                   o->controller()->cy1+5), 1);
     832                            vec2i(o->controller()->m_bb.x - 20,
     833                                  o->controller()->m_aa.y + 5), 1);
    834834      } break;
    835835      case FAST_POWER :
     
    852852    if (o->controller() && o->controller()->local_player())
    853853      main_screen->PutImage(cache.img(S_fast_image),
    854                             vec2i(o->controller()->cx2-20,
    855                                   o->controller()->cy1+5), 1);
     854                            vec2i(o->controller()->m_bb.x - 20,
     855                                  o->controller()->m_aa.y + 5), 1);
    856856      } break;
    857857      case FLY_POWER :
     
    874874    if (o->controller() && o->controller()->local_player())
    875875      main_screen->PutImage(cache.img(S_fly_image),
    876                             vec2i(o->controller()->cx2-20,
    877                                   o->controller()->cy1+5), 1);
     876                            vec2i(o->controller()->m_bb.x - 20,
     877                                  o->controller()->m_aa.y + 5), 1);
    878878      } break;
    879879      case SNEAKY_POWER :
     
    888888    if (o->controller() && o->controller()->local_player())
    889889      main_screen->PutImage(cache.img(S_sneaky_image),
    890                             vec2i(o->controller()->cx2-20,
    891                                   o->controller()->cy1+5), 1);
     890                            vec2i(o->controller()->m_bb.x - 20,
     891                                  o->controller()->m_aa.y + 5), 1);
    892892      } break;
    893893    }
     
    10231023    qsort(sorted_players,tp,sizeof(view *),compare_players);
    10241024
    1025     int x=local->cx1;
    1026     int y=local->cy1;
     1025    vec2i pos = local->m_aa;
    10271026    char msg[100];
    10281027
     
    10351034        strcat(msg," <<");
    10361035
    1037       fnt->PutString(main_screen, vec2i(x, y), msg, color);
    1038       y += fnt->Size().y;
     1036      fnt->PutString(main_screen, pos, msg, color);
     1037      pos.y += fnt->Size().y;
    10391038    }
    10401039  }
  • abuse/trunk/src/dev.cpp

    r671 r674  
    230230static void single_render()
    231231{
    232   // enlarge clip area
    233   the_game->first_view->cx2=the_game->first_view->cx1+
    234                             (the_game->first_view->cx2-the_game->first_view->cx1+1)*2;
    235   the_game->first_view->cy2=the_game->first_view->cy1+
    236                             (the_game->first_view->cy2-the_game->first_view->cy1+1)*2;
    237   delete small_render;
    238   small_render=NULL;
    239   small_render_on=0;
     232    // enlarge clip area
     233    view *v = the_game->first_view;
     234    v->m_bb = v->m_aa + 2 * (v->m_bb - v->m_aa + vec2i(1));
     235    delete small_render;
     236    small_render = NULL;
     237    small_render_on = 0;
    240238}
    241239
    242240static void double_render()
    243241{
    244   small_render_on=1;
    245   // reduce clip area
    246   the_game->first_view->cx2=the_game->first_view->cx1+
    247                             (the_game->first_view->cx2-the_game->first_view->cx1+1)/2;
    248   the_game->first_view->cy2=the_game->first_view->cy1+
    249                             (the_game->first_view->cy2-the_game->first_view->cy1+1)/2;
    250 
    251   small_render=new image(vec2i(the_game->first_view->cx2-the_game->first_view->cx1+1, the_game->first_view->cy2-the_game->first_view->cy1+1),NULL,2);
     242    // reduce clip area
     243    view *v = the_game->first_view;
     244    v->m_bb = v->m_aa + (v->m_bb - v->m_aa + vec2i(1)) / 2;
     245    small_render = new image(v->m_bb - v->m_aa + vec2i(1), NULL, 2);
     246    small_render_on = 1;
    252247}
    253248
     
    478473      for (light_source *f=first_light_source; f; f=f->next)
    479474      {
    480     if (f->x-vx>=0 && f->x-vx<=(v->cx2-v->cx1+1) && f->y-vy>=0 && f->y-vy<=(v->cy2-v->cy1+1))
     475    if (f->x-vx>=0 && f->x-vx<=(v->m_bb.x-v->m_aa.x+1) && f->y-vy>=0 && f->y-vy<=(v->m_bb.y-v->m_aa.y+1))
    481476    {
    482477      image *im = cache.img(light_buttons[f->type]);
    483       main_screen->PutImage(im, vec2i(f->x - vx + v->cx1 - im->Size().x / 2,
    484                                       f->y - vy + v->cy1 - im->Size().y / 2), 1);
    485       main_screen->Rectangle(vec2i(f->x1 - vx + v->cx1, f->y1 - vy + v->cy1),
    486                              vec2i(f->x2 - vx + v->cx1, f->y2 - vy + v->cy1),
     478      main_screen->PutImage(im, vec2i(f->x - vx, f->y - vy)
     479                                  + v->m_aa - im->Size() / 2);
     480      main_screen->Rectangle(vec2i(f->x1 - vx, f->y1 - vy) + v->m_aa,
     481                             vec2i(f->x2 - vx, f->y2 - vy) + v->m_aa,
    487482                             wm->medium_color());
    488483    }
  • abuse/trunk/src/director.cpp

    r668 r674  
    2424void director::scroll_text(char *Text)
    2525{ text=Text;
    26   text_y=the_game->first_view->cy2-the_game->first_view->cy1+1;
     26  text_y = the_game->first_view->m_bb.y - the_game->first_view->m_aa.y + 1;
    2727}
    2828
     
    155155    {
    156156      if (text_draw(text_y,
    157             the_game->first_view->cx1+tleft,
    158             the_game->first_view->cy1+ttop,
    159             the_game->first_view->cx2-tright,
    160             the_game->first_view->cy2-tbottom,text,font,
    161             white_light+32*256,
    162             wm->bright_color()
     157                    the_game->first_view->m_aa.x + tleft,
     158                    the_game->first_view->m_aa.y + ttop,
     159                    the_game->first_view->m_bb.x - tright,
     160                    the_game->first_view->m_bb.y - tbottom,
     161                    text, font, white_light + 32 * 256, wm->bright_color()
    163162
    164163            ))
  • abuse/trunk/src/game.cpp

    r673 r674  
    226226            continue;
    227227
    228         f->suggest.cx1=(f->cx1 - amount);
    229         f->suggest.cy1 = f->cy1 - amount / 2;
    230         f->suggest.cx2=(f->cx2 + amount);
    231         f->suggest.cy2 = f->cy2 + amount / 2;
     228        f->suggest.cx1=(f->m_aa.x - amount);
     229        f->suggest.cy1 = f->m_aa.y - amount / 2;
     230        f->suggest.cx2=(f->m_bb.x + amount);
     231        f->suggest.cy2 = f->m_bb.y + amount / 2;
    232232        f->suggest.shift_down = f->shift_down;
    233233        f->suggest.shift_right = f->shift_right;
     
    249249
    250250        if(f->next && f->next->local_player()
    251            && f->suggest.cy2 >= f->next->cy1)
     251           && f->suggest.cy2 >= f->next->m_aa.y)
    252252            f->suggest.send_view = 0;
    253253    }
     
    263263{
    264264    for(view *f = first_view; f; f = f->next)
    265         if(f->drawable() && pos.x >= f->cx1 && pos.y >= f->cy1
    266            && pos.x <= f->cx2 && pos.y <= f->cy2)
     265        if(f->drawable() && pos >= f->m_aa && pos <= f->m_bb)
    267266            return f;
    268267    return NULL;
     
    285284        return vec2i(-1, -1);
    286285
    287     return vec2i((pos.x - f->cx1 + f->xoff() * bg_xmul / bg_xdiv) / b_wid,
    288                  (pos.y - f->cy1 + f->yoff() * bg_ymul / bg_ydiv) / b_hi);
     286    return vec2i((pos.x - f->m_aa.x + f->xoff() * bg_xmul / bg_xdiv) / b_wid,
     287                 (pos.y - f->m_aa.y + f->yoff() * bg_ymul / bg_ydiv) / b_hi);
    289288}
    290289
     
    299298
    300299    if(dev & MAP_MODE)
    301         return vec2i((pos.x - v->cx1) * ftile_width()
     300        return vec2i((pos.x - v->m_aa.x) * ftile_width()
    302301                           / AUTOTILE_WIDTH + map_xoff * ftile_width(),
    303                      (pos.y - v->cy1) * ftile_height()
     302                     (pos.y - v->m_aa.y) * ftile_height()
    304303                           / AUTOTILE_HEIGHT + map_yoff * ftile_height());
    305304
    306     return pos - vec2i(v->cx1 - v->xoff(), v->cy1 - v->yoff());
     305    return pos - v->m_aa + vec2i(v->xoff(), v->yoff());
    307306}
    308307
     
    310309{
    311310    if (!(dev & MAP_MODE))
    312         return pos + vec2i(v->cx1 - v->xoff(), v->cy1 - v->yoff());
     311        return pos + v->m_aa - vec2i(v->xoff(), v->yoff());
    313312
    314313    vec2i tmp;
     
    318317    else if(v->focus)
    319318        tmp = vec2i(v->focus->x / ftile_width()
    320                        - (v->cx2 - v->cx1) / AUTOTILE_WIDTH / 2,
     319                       - (v->m_bb.x - v->m_aa.x) / AUTOTILE_WIDTH / 2,
    321320                    v->focus->y / ftile_height()
    322                        - (v->cy2 - v->cy1) / AUTOTILE_HEIGHT / 2);
     321                       - (v->m_bb.y - v->m_aa.y) / AUTOTILE_HEIGHT / 2);
    323322    else
    324323        tmp = vec2i(0, 0);
     
    328327
    329328    vec2i ret(pos.x * AUTOTILE_WIDTH / ftile_width()
    330                  - tmp.x * AUTOTILE_WIDTH + v->cx1,
     329                 - tmp.x * AUTOTILE_WIDTH + v->m_aa.x,
    331330              pos.y * AUTOTILE_HEIGHT / ftile_height()
    332                  - tmp.y * AUTOTILE_HEIGHT + v->cy1);
     331                 - tmp.y * AUTOTILE_HEIGHT + v->m_aa.y);
    333332    if (tmp.x > 0)
    334333        ret.x -= (v->focus->x * AUTOTILE_WIDTH / ftile_width())
     
    392391        else
    393392            first_view = new view(NULL, NULL, 0);
    394         first_view->cx1 = (xres + 1) / 2 - 155;
    395         first_view->cy1 = (yres + 1) / 2 - 95;
    396         first_view->cx2 = (xres + 1) / 2 + 155;
    397         if(total_weapons)
    398             first_view->cy2 = (yres + 1) / 2 + 68;
    399         else
    400             first_view->cy2 = (yres + 1) / 2 + 95;
     393        first_view->m_aa.x = (xres + 1) / 2 - 155;
     394        first_view->m_aa.y = (yres + 1) / 2 - 95;
     395        first_view->m_bb.x = (xres + 1) / 2 + 155;
     396        first_view->m_bb.y = (yres + 1) / 2 + (total_weapons ? 68 : 95);
    401397        d = 1;
    402398    }
     
    415411
    416412    if(playing_state(state) &&  !(dev & EDIT_MODE))
    417         wm->SetMouseShape(cache.img(c_target)->copy(), vec2i(8, 8));
     413        wm->SetMouseShape(cache.img(c_target)->copy(), vec2i(8));
    418414    else
    419         wm->SetMouseShape(cache.img(c_normal)->copy(), vec2i(1, 1));
     415        wm->SetMouseShape(cache.img(c_normal)->copy(), vec2i(1));
    420416
    421417    if(old_state == SCENE_STATE && new_state != SCENE_STATE)
     
    650646    {
    651647      if(state == SCENE_STATE)
    652         main_screen->SetClip(vec2i(v->cx1, v->cy1), vec2i(v->cx2 + 1, v->cy2 + 1));
     648        main_screen->SetClip(v->m_aa, v->m_bb + vec2i(1));
    653649      image *tit = cache.img(title_screen);
    654650      main_screen->PutImage(tit, main_screen->Size() / 2 - tit->Size() / 2);
     
    667663
    668664  if(small_render)
    669     main_screen->AddDirty(vec2i(v->cx1, v->cy1), vec2i((v->cx2 - v->cx1 + 1)*2 + v->cx1 + 1, v->cy1+(v->cy2 - v->cy1 + 1)*2 + 1));
     665    main_screen->AddDirty(v->m_aa, (v->m_bb - v->m_aa + vec2i(1)) * 2 + vec2i(v->m_aa.x, 0) + vec2i(1));
    670666  else
    671     main_screen->AddDirty(vec2i(v->cx1, v->cy1), vec2i(v->cx2 + 1, v->cy2 + 1));
     667    main_screen->AddDirty(v->m_aa, v->m_bb + vec2i(1));
    672668
    673669  if(v->draw_solid != -1)      // fill the screen and exit..
     
    675671    int c = v->draw_solid;
    676672    main_screen->Lock();
    677     for(int y = v->cy1; y <= v->cy2; y++)
    678       memset(main_screen->scan_line(y)+v->cx1, c, v->cx2 - v->cx1 + 1);
     673    for(int y = v->m_aa.y; y <= v->m_bb.y; y++)
     674      memset(main_screen->scan_line(y)+v->m_aa.x, c, v->m_bb.x - v->m_aa.x + 1);
    679675    main_screen->Unlock();
    680676    v->draw_solid = -1;
     
    682678  }
    683679
    684   int32_t old_cx1 = 0, old_cy1 = 0, old_cx2 = 0, old_cy2 = 0;   // if we do a small render, we need to restore these
    685   image *old_screen = NULL;
     680    // if we do a small render, we need to restore these
     681    vec2i old_aa(0), old_bb(0);
     682    image *old_screen = NULL;
     683
    686684  if(small_render && (dev & DRAW_LIGHTS))  // cannot do this if we skip lighting
    687685  {
    688     old_cx1 = v->cx1;
    689     old_cy1 = v->cy1;
    690     old_cx2 = v->cx2;
    691     old_cy2 = v->cy2;
    692 
    693     v->cx1 = 0;
    694     v->cy1 = 0;
    695     v->cx2 = small_render->Size().x-1;
    696     v->cy2 = small_render->Size().y-1;
     686    old_aa = v->m_aa;
     687    old_bb = v->m_bb;
     688
     689    v->m_aa = vec2i(0);
     690    v->m_bb = small_render->Size() - vec2i(1);
    697691
    698692    old_screen = main_screen;
     
    716710//  if(yoff > max_yoff) yoff = max_yoff;
    717711
    718   current_vxadd = xoff - v->cx1;
    719   current_vyadd = yoff - v->cy1;
    720 
    721   main_screen->SetClip(vec2i(v->cx1, v->cy1), vec2i(v->cx2 + 1, v->cy2 + 1));
     712  current_vxadd = xoff - v->m_aa.x;
     713  current_vyadd = yoff - v->m_aa.y;
     714
     715  main_screen->SetClip(v->m_aa, v->m_bb + vec2i(1));
    722716
    723717  nxoff = xoff * bg_xmul / bg_xdiv;
     
    725719
    726720
    727   x1 = nxoff / btile_width(); y1 = nyoff / btile_height();
    728   x2 = x1+(v->cx2 - v->cx1 + btile_width())/btile_width();
    729   y2 = y1+(v->cy2 - v->cy1 + btile_height())/btile_height();
    730 
    731 
    732   xo = v->cx1 - nxoff % btile_width();
    733   yo = v->cy1 - nyoff % btile_height();
     721  x1 = nxoff / btile_width();
     722  y1 = nyoff / btile_height();
     723  x2 = x1 + (v->m_bb.x - v->m_aa.x + btile_width()) / btile_width();
     724  y2 = y1 + (v->m_bb.y - v->m_aa.y + btile_height()) / btile_height();
     725
     726  xo = v->m_aa.x - nxoff % btile_width();
     727  yo = v->m_aa.y - nyoff % btile_height();
    734728
    735729  int xinc, yinc, draw_x, draw_y;
     
    785779    if(v->focus)
    786780    {
    787       x1 = v->focus->x / ftile_width()-(v->cx2 - v->cx1)/fw / 2;
    788       y1 = v->focus->y / ftile_height()-(v->cy2 - v->cy1)/fh / 2;
     781      x1 = v->focus->x / ftile_width() - (v->m_bb.x - v->m_aa.x) / fw / 2;
     782      y1 = v->focus->y / ftile_height() - (v->m_bb.y - v->m_aa.y) / fh / 2;
    789783    } else x1 = y1 = 0;
    790784      }
    791785      if(x1 > 0)
    792         xo = v->cx1-((v->focus->x * fw / ftile_width()) %fw);
    793       else xo = v->cx1;
     786        xo = v->m_aa.x - ((v->focus->x * fw / ftile_width()) % fw);
     787      else xo = v->m_aa.x;
    794788      if(y1 > 0)
    795         yo = v->cy1-((v->focus->y * fh / ftile_height()) %fh);
    796       else yo = v->cy1;
     789        yo = v->m_aa.y - ((v->focus->y * fh / ftile_height()) % fh);
     790      else yo = v->m_aa.y;
    797791    } else
    798792    {
    799793      fw = ftile_width();
    800794      fh = ftile_height();
    801       x1=(xoff)/fw; y1=(yoff)/fh;
    802       xo = v->cx1 - xoff % fw;
    803       yo = v->cy1 - yoff % fh;
     795      x1 = xoff / fw;
     796      y1 = yoff / fh;
     797      xo = v->m_aa.x - xoff % fw;
     798      yo = v->m_aa.y - yoff % fh;
    804799
    805800    }
     
    807802    if(y1 < 0) y1 = 0;
    808803
    809     x2 = x1+(v->cx2 - v->cx1 + fw)/fw;
    810     y2 = y1+(v->cy2 - v->cy1 + fh)/fh;
    811     if(x2 >= current_level->foreground_width())
    812       x2 = current_level->foreground_width()-1;
    813     if(y2 >= current_level->foreground_height())
    814       y2 = current_level->foreground_height()-1;
    815 
     804      x2 = x1 + (v->m_bb.x - v->m_aa.x + fw) / fw;
     805      y2 = y1 + (v->m_bb.y - v->m_aa.y + fh) / fh;
     806      x2 = Min(x2, current_level->foreground_width() - 1);
     807      y2 = Min(y2, current_level->foreground_height() - 1);
    816808
    817809    xinc = fw;
     
    987979      if(help_text_frames >= 0)
    988980      {
    989     int color;
    990 
    991     if(help_text_frames < 10)
    992         color = 2;
    993     else
    994         color = 2+(help_text_frames - 10);
    995 
    996     int x1 = v->cx1, y1 = v->cy1, x2 = v->cx2, y2 = v->cy1 + wm->font()->Size().y+10;
    997 
    998     remap_area(main_screen, x1, y1, x2, y2, white_light + 40 * 256);
    999     main_screen->Bar(vec2i(x1, y1), vec2i(x2, y1), color);
    1000     main_screen->Bar(vec2i(x1, y2), vec2i(x2, y2), color);
    1001 
    1002     wm->font()->PutString(main_screen, vec2i(x1 + 5, y1 + 5),
    1003                           help_text, color);
     981    int color = 2 + Max(0, help_text_frames - 10);
     982
     983    vec2i aa = v->m_aa;
     984    vec2i bb(v->m_bb.x, v->m_aa.y + wm->font()->Size().y + 10);
     985
     986    remap_area(main_screen, aa.x, aa.y, bb.x, bb.y, white_light + 40 * 256);
     987    main_screen->Bar(aa, vec2i(bb.x, aa.y), color);
     988    main_screen->Bar(vec2i(aa.x, bb.y), bb, color);
     989
     990    wm->font()->PutString(main_screen, aa + vec2i(5), help_text, color);
    1004991    if(color > 30)
    1005992        help_text_frames = -1;
     
    1012999    dev_cont->dev_draw(v);
    10131000    if(cache.in_use())
    1014     main_screen->PutImage(cache.img(vmm_image), vec2i(v->cx1, v->cy2 - cache.img(vmm_image)->Size().y+1));
     1001    main_screen->PutImage(cache.img(vmm_image), vec2i(v->m_aa.x, v->m_bb.y - cache.img(vmm_image)->Size().y+1));
    10151002
    10161003    if(dev & DRAW_LIGHTS)
     
    10181005      if(small_render)
    10191006      {
    1020     double_light_screen(main_screen, xoff, yoff, white_light, v->ambient, old_screen, old_cx1, old_cy1);
    1021 
    1022     v->cx1 = old_cx1;
    1023     v->cy1 = old_cy1;
    1024     v->cx2 = old_cx2;
    1025     v->cy2 = old_cy2;
     1007    double_light_screen(main_screen, xoff, yoff, white_light, v->ambient, old_screen, old_aa.x, old_aa.y);
     1008
     1009    v->m_aa = old_aa;
     1010    v->m_bb = old_bb;
    10261011    main_screen = old_screen;
    10271012      } else
     
    14471432    char str[16];
    14481433    sprintf(str, "%ld", (long)(10000.0f / avg_ms));
    1449     console_font->PutString(main_screen, vec2i(first_view->cx1, first_view->cy1), str);
     1434    console_font->PutString(main_screen, first_view->m_aa, str);
    14501435
    14511436    sprintf(str, "%d", total_active);
    1452     console_font->PutString(main_screen, vec2i(first_view->cx1, first_view->cy1 + 10), str);
     1437    console_font->PutString(main_screen, first_view->m_aa + vec2i(0, 10), str);
    14531438}
    14541439
     
    14691454      int w, h;
    14701455
    1471       w=(f->cx2 - f->cx1 + 1);
    1472       h=(f->cy2 - f->cy1 + 1);
     1456      w = (f->m_bb.x - f->m_aa.x + 1);
     1457      h = (f->m_bb.y - f->m_aa.y + 1);
    14731458
    14741459      total_active += current_level->add_drawables(f->xoff()-w / 4, f->yoff()-h / 4,
     
    14961481    {
    14971482      for(view *f = first_view; f; f = f->next)
    1498         main_screen->PutImage(cache.img(pause_image), vec2i((f->cx1 + f->cx2)/2 - cache.img(pause_image)->Size().x/2,
    1499                    f->cy1 + 5), 1);
     1483        main_screen->PutImage(cache.img(pause_image), vec2i((f->m_aa.x + f->m_bb.x) / 2 - cache.img(pause_image)->Size().x/2, f->m_aa.y + 5), 1);
    15001484    }
    15011485
     
    19071891    int w, h;
    19081892
    1909     w=(f->cx2 - f->cx1 + 1);
    1910     h=(f->cy2 - f->cy1 + 1);
     1893    w = (f->m_bb.x - f->m_aa.x + 1);
     1894    h = (f->m_bb.y - f->m_aa.y + 1);
    19111895        total_active += current_level->add_actives(f->xoff()-w / 4, f->yoff()-h / 4,
    19121896                         f->xoff()+w + w / 4, f->yoff()+h + h / 4);
  • abuse/trunk/src/innet.cpp

    r671 r674  
    549549                current_level->add_object(o);
    550550
    551                 view *v=f->next;
    552 
    553                 v->cx1=5;
    554                 v->cy1=5;
    555                 v->cx2=319-5;
    556                 v->cy2=199-5;
    557                 join_list=join_list->next;
     551                view *v = f->next;
     552                v->m_aa = vec2i(5);
     553                v->m_bb = vec2i(319, 199) - vec2i(5);
     554                join_list = join_list->next;
    558555      }
    559556      base->join_list=NULL;
  • abuse/trunk/src/objects.cpp

    r657 r674  
    382382
    383383  vec2i pos1 = the_game->GameToMouse(vec2i(x1, y1), v);
    384   if (pos1.y >= v->cy1)
    385   {
    386     int32_t draw_to = y1 - (pos1.y - v->cy1), tmp = x;
     384  if (pos1.y >= v->m_aa.y)
     385  {
     386    int32_t draw_to = y1 - (pos1.y - v->m_aa.y), tmp = x;
    387387    current_level->foreground_intersect(x, y1, tmp, draw_to);
    388388    // calculate pos2.y
    389389    vec2i pos2 = the_game->GameToMouse(vec2i(x1, draw_to), v);
    390390
    391     pos2.y = Max(v->cy1, pos2.y);
    392     pos1.y = Min(v->cy2, pos1.y);
     391    pos2.y = Max(v->m_aa.y, pos2.y);
     392    pos1.y = Min(v->m_bb.y, pos1.y);
    393393    TransImage *p = picture();
    394394
  • abuse/trunk/src/particle.cpp

    r672 r674  
    165165  for (part_animation *p=first_anim; p; p=p->next)
    166166  {
    167     cache.part(p->seq->frames[p->frame])->draw(main_screen,p->x-v->xoff()+v->cx1,p->y-v->yoff()+v->cy1,p->dir);
     167    cache.part(p->seq->frames[p->frame])->draw(main_screen,p->x-v->xoff()+v->m_aa.x,p->y-v->yoff()+v->m_aa.y,p->dir);
    168168  }
    169169}
  • abuse/trunk/src/statbar.cpp

    r658 r674  
    229229  if (small_render)
    230230  {
    231     mx=(v->pointer_x-v->cx1)*2+v->cx1;
    232     my=(v->pointer_y-v->cy1)*2+v->cy1;
     231    mx = v->pointer_x * 2 - v->m_aa.x;
     232    my = v->pointer_y * 2 - v->m_aa.y;
    233233  } else
    234234  {
    235     mx=v->pointer_x;
    236     my=v->pointer_y;
     235    mx = v->pointer_x;
     236    my = v->pointer_y;
    237237  }
    238238
     
    288288  area(sx1,sy1,sx2,sy2);
    289289
    290   int view_y2=small_render ? (v->cy2-v->cy1+1)*2+v->cy1 : v->cy2;
     290  int view_y2=small_render ? (v->m_bb.y-v->m_aa.y+1)*2+v->m_aa.y : v->m_bb.y;
    291291  if (sy1<view_y2)     // tell view to shrink if it is overlapping the status bar
    292292  {
    293293    v->suggest.send_view=1;
    294     v->suggest.cx1=v->cx1;
    295     v->suggest.cy1=v->cy1;
    296     v->suggest.cx2=v->cx2;
    297     v->suggest.cy2=small_render ? (sy1-v->cy1-2)/2+v->cy1 : sy1-2;
     294    v->suggest.cx1 = v->m_aa.x;
     295    v->suggest.cy1 = v->m_aa.y;
     296    v->suggest.cx2 = v->m_bb.x;
     297    v->suggest.cy2 = small_render ? (sy1 - v->m_aa.y - 2) / 2 + v->m_aa.y : sy1 - 2;
    298298  }
    299299
    300300  if (sbar<=0 || !total_weapons) return ;
    301301
    302 
    303   int mx=small_render ? (last_demo_mpos.x-v->cx1)*2+v->cx1 : last_demo_mpos.x;
    304   int my=small_render ? (last_demo_mpos.y-v->cy1)*2+v->cy1 : last_demo_mpos.y;
    305 
     302  int mx = small_render ? last_demo_mpos.x * 2 - v->m_aa.x : last_demo_mpos.x;
     303  int my = small_render ? last_demo_mpos.y * 2 - v->m_aa.y : last_demo_mpos.y;
    306304
    307305  if (mx>sx1 && my>sy1 && mx<sx2 && my<sy2)
  • abuse/trunk/src/view.cpp

    r658 r674  
    116116int32_t view::xoff()
    117117{
    118   if (focus)
    119   {
    120     int x=last_x-(cx2-cx1+1)/2+shift_right+pan_x;
    121     if (x<0) return 0;
    122     else return x;
    123   } else return pan_x;
     118    if (!focus)
     119        return pan_x;
     120
     121    return Max(0, last_x - (m_bb.x - m_aa.x + 1) / 2 + shift_right + pan_x);
    124122}
    125123
    126124int32_t view::interpolated_xoff()
    127125{
    128   if (focus)
    129   {
    130     int x=(last_last_x+last_x)/2-(cx2-cx1+1)/2+shift_right+pan_x;
    131     if (x<0) return 0;
    132     else return x;
    133   } else return pan_x;
     126    if (!focus)
     127        return pan_x;
     128
     129    return Max(0, (last_last_x + last_x) / 2
     130                    - (m_bb.x - m_aa.x + 1) / 2 + shift_right + pan_x);
    134131}
    135132
     
    137134int32_t view::yoff()
    138135{
    139   if (focus)
    140   {
    141     int y=last_y-(cy2-cy1+1)/2-shift_down+pan_y;
    142     if (y<0) return 0;
    143     else return y;
    144   } else return pan_y;
     136    if (!focus)
     137        return pan_y;
     138
     139    return Max(0, last_y - (m_bb.y - m_aa.y + 1) / 2 - shift_down + pan_y);
    145140}
    146141
     
    148143int32_t view::interpolated_yoff()
    149144{
    150   if (focus)
    151   {
    152     int y=(last_y+last_last_y)/2-(cy2-cy1+1)/2-shift_down+pan_y;
    153     if (y<0) return 0;
    154     else return y;
    155   } else return pan_y;
     145    if (!focus)
     146        return pan_y;
     147
     148    return Max(0, (last_last_y + last_y) / 2
     149                    - (m_bb.y - m_aa.y + 1) / 2 - shift_down + pan_y);
    156150}
    157151
     
    243237
    244238  player_number=number;
    245   cx1=0;
    246   cy1=0;
    247   cx2=100;
    248   cy2=100;
     239    m_aa = vec2i(0);
     240    m_bb = vec2i(100);
    249241  focus=Focus;
    250242  next=Next;
     
    284276int32_t view::x_center()
    285277{
    286   if (!focus)
    287     return (cx1+cx2)/2;
    288   else
    289     return focus->x;
     278    return focus ? focus->x : (m_aa.x + m_bb.x) / 2;
    290279}
    291280
    292281int32_t view::y_center()
    293282{
    294   if (!focus)
    295     return (cy1+cy2)/2;
    296   else
    297     return focus->y;
     283    return focus ? focus->y : (m_aa.y + m_bb.y) / 2;
    298284}
    299285
     
    500486      int32_t x[8];
    501487      memcpy(x,pk,8*4);  pk+=8*4;
    502       cx1=lltl(x[0]);
    503       cy1=lltl(x[1]);
    504       cx2=lltl(x[2]);
    505       cy2=lltl(x[3]);
     488      m_aa = vec2i(lltl(x[0]), lltl(x[1]));
     489      m_bb = vec2i(lltl(x[2]), lltl(x[3]));
    506490
    507491      pan_x=lltl(x[4]);
     
    510494      shift_right=lltl(x[7]);
    511495      if (small_render)
    512       {
    513         small_render->Scale(vec2i(cx2 - cx1 + 1, cy2 - cy1 + 1));
    514       }
     496          small_render->Scale(m_bb - m_aa + vec2i(1));
    515497
    516498      suggest.send_view=0;
     
    760742    if (!player_list->next)
    761743    {
    762       f->cx1=f->suggest.cx1;
    763       f->cy1=f->suggest.cy1;
    764       f->cx2=f->suggest.cx2;
    765       f->cy2=f->suggest.cy2;
    766       f->suggest.send_view=0;
     744      f->m_aa = vec2i(f->suggest.cx1, f->suggest.cy1);
     745      f->m_bb = vec2i(f->suggest.cx2, f->suggest.cy2);
     746      f->suggest.send_view = 0;
    767747    }
    768748    y+=h;
     
    817797      v=f->next;
    818798    }
    819     v->cx1=320/2-155; v->cy1=200/2-95; v->cx2=320/2+155; v->cy2=200/2+(total_weapons ? 60 : 95);
     799    v->m_aa = vec2i(320 / 2 - 155, 200 / 2 - 95);
     800    v->m_bb = vec2i(320 / 2 + 155, 200 / 2 + total_weapons ? 60 : 95);
    820801    v->focus->set_controller(v);
    821802    total--;
     
    834815  return t;
    835816}
    836 
    837 
    838 void view::resize_view(int32_t Cx1, int32_t Cy1, int32_t Cx2, int32_t Cy2)
    839 {
    840   if (cx1!=Cx1 || cx2!=Cx2 || cy1!=Cy1 || cy2!=Cy2)
    841   {
    842     cx1=Cx1; cy1=Cy1;
    843     cx2=Cx2; cy2=Cy2;
    844     if (playing_state(the_game->state) && local_player())
    845       the_game->draw(0);
    846   }
    847 }
    848 
    849817
    850818void view::set_input(int cx, int cy, int b1, int b2, int b3, int b4, int px, int py)
     
    1005973  switch (num)
    1006974  {
    1007     case V_CX1 : return cx1; break;
    1008     case V_CY1 : return cy1; break;
    1009     case V_CX2 : return cx2; break;
    1010     case V_CY2 : return cy2; break;
     975    case V_CX1 : return m_aa.x; break;
     976    case V_CY1 : return m_aa.y; break;
     977    case V_CX2 : return m_bb.x; break;
     978    case V_CY2 : return m_bb.y; break;
    1011979    case V_SHIFT_DOWN : return shift_down; break;
    1012980    case V_SHIFT_RIGHT : return shift_right; break;
     
    10601028  switch (num)
    10611029  {
    1062     case V_CX1 : cx1=x; break;
    1063     case V_CY1 : cy1=x; break;
    1064     case V_CX2 : cx2=x; break;
    1065     case V_CY2 : cy2=x; break;
     1030    case V_CX1 : m_aa.x = x; break;
     1031    case V_CY1 : m_aa.y = x; break;
     1032    case V_CX2 : m_bb.x = x; break;
     1033    case V_CY2 : m_bb.y = x; break;
    10661034    case V_SHIFT_DOWN : shift_down=x; break;
    10671035    case V_SHIFT_RIGHT : shift_right=x; break;
  • abuse/trunk/src/view.h

    r643 r674  
    3333class view
    3434{
    35   uint8_t keymap[512/8];
    36   char chat_buf[60];
    37   public :
     35public:
     36    view(game_object *Focus, view *Next, int number);
     37    ~view();
     38
    3839  int key_down(int key) { return keymap[key/8]&(1<<(key%8)); }
    3940  void set_key_down(int key, int x) { if (x) keymap[key/8]|=(1<<(key%8)); else keymap[key/8]&=~(1<<(key%8)); }
     
    4344  char name[100];
    4445  struct suggest_struct suggest;
    45   int32_t cx1,cy1,cx2,cy2,                    // view area to show
    46       shift_down,shift_right;             // shift of view
     46  int32_t shift_down,shift_right;             // shift of view
    4747
    4848  int god;                                // :) if you believe in such things
     
    7878  int32_t secrets,kills,tsecrets,tkills;
    7979
    80   view(game_object *Focus, view *Next, int number);
    81   ~view();
    82 
    8380  void draw_character_damage();           // draws the characters 'status' on the viewer
    8481
     
    108105  void draw_ammo();
    109106  void draw_logo();
    110   void resize_view(int32_t Cx1, int32_t Cy1, int32_t Cx2, int32_t Cy2);
    111107  void set_input(int cx, int cy, int b1, int b2, int b3, int b4, int px, int py);
    112108  int view_changed() { return suggest.send_view; }
     
    126122  void set_team(int);
    127123  int get_team();
     124
     125    vec2i m_aa, m_bb; // view area to show
     126
     127private:
     128    uint8_t keymap[512 / 8];
     129    char chat_buf[60];
    128130};
    129131
Note: See TracChangeset for help on using the changeset viewer.