Changeset 658


Ignore:
Timestamp:
May 15, 2011, 6:22:21 AM (9 years ago)
Author:
Sam Hocevar
Message:

game: convert a few integer pairs to vec2i variables.

Location:
abuse/trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • abuse/trunk/TODO

    r657 r658  
    5656REFACTOR
    5757--------
    58 game_to_mouse : utiliser vec2i, ftile_on btile_on
    59 console::draw_char : pareil
     58console::draw_char : vec2i
    6059VolumeWindow::draw_vol plus grand !!
    6160
    62 dlastx, dlasty, x, y (apparemment des membres de object)
    63 last_demo_mx, last_demo_my
     61x, y (apparemment des membres de object)
    6462get_fg ?
    6563snap_x() snap_y()
  • abuse/trunk/src/clisp.cpp

    r657 r658  
    899899    push_onto_list(LNumber::Create((last_demo_mbut&2)==2),ret);
    900900    push_onto_list(LNumber::Create((last_demo_mbut&1)==1),ret);
    901     push_onto_list(LNumber::Create(last_demo_my),ret);
    902     push_onto_list(LNumber::Create(last_demo_mx),ret);
     901    push_onto_list(LNumber::Create(last_demo_mpos.y),ret);
     902    push_onto_list(LNumber::Create(last_demo_mpos.x),ret);
    903903      }
    904904      return ret;
  • abuse/trunk/src/demo.cpp

    r657 r658  
    2929
    3030demo_manager demo_man;
    31 int last_demo_mx,last_demo_my,last_demo_mbut;
     31vec2i last_demo_mpos;
     32int last_demo_mbut;
    3233extern base_memory_struct *base;   // points to shm_addr
    3334extern int idle_ticks;
     
    5455  }
    5556
    56   last_demo_mx=ev.mouse_move.x;
    57   last_demo_my=ev.mouse_move.y;
    58   last_demo_mbut=ev.mouse_button;
     57  last_demo_mpos = ev.mouse_move;
     58  last_demo_mbut = ev.mouse_button;
    5959  idle_ticks=0;
    6060}
     
    146146  for (; v; v=v->next) { if (v->focus) v->reset_player(); }
    147147
    148   last_demo_mx=last_demo_my=last_demo_mbut=0;
     148  last_demo_mpos = vec2i(0, 0);
     149  last_demo_mbut = 0;
    149150  current_level->set_tick_counter(0);
    150151
  • abuse/trunk/src/demo.h

    r643 r658  
    4343extern int event_waiting();
    4444
     45extern vec2i last_demo_mpos;
     46extern int last_demo_mbut;
    4547
    46 
    47 extern int32_t last_demo_mx,last_demo_my,last_demo_mbut;
    4848//extern ulong demo_tick_on;
    4949#endif
  • abuse/trunk/src/dev.cpp

    r657 r658  
    9595image *small_render=NULL;
    9696
    97 int scale_mult,scale_div,dlastx,dlasty;
     97vec2i dlast;
     98int scale_mult,scale_div;
    9899int last_created_type=-1;
    99100char level_file[100]="levels/level00.spe";
     
    492493    {
    493494      vec2i pos = the_game->GameToMouse(vec2i(link_object->x, link_object->y), v);
    494       main_screen->Line(pos, vec2i(dlastx, dlasty), yellow);
     495      main_screen->Line(pos, dlast, yellow);
    495496    }
    496497
     
    10461047  if (!strcmp(fword,"unchop"))
    10471048  {
    1048     vec2i tile = the_game->GetBgTile(vec2i(dlastx, dlasty));
     1049    vec2i tile = the_game->GetBgTile(dlast);
    10491050    if (tile.x>=0 && tile.y>=0)
    10501051    {
     
    11671168    if (t>=0)                                 // did we find it?
    11681169    {
    1169       vec2i pos = the_game->MouseToGame(vec2i(dlastx, dlasty));
     1170      vec2i pos = the_game->MouseToGame(dlast);
    11701171      edit_object=create(t, pos.x, pos.y);
    11711172      current_level->add_object(edit_object);
     
    12111212  if (!strcmp(fword,"fg_select"))
    12121213  {
    1213     vec2i tile = the_game->GetFgTile(vec2i(dlastx, dlasty));
     1214    vec2i tile = the_game->GetFgTile(dlast);
    12141215    if (tile.x >= 0 && tile.y >= 0 &&
    12151216        tile.x < current_level->foreground_width() &&
     
    12251226  if (!strcmp(fword,"toggle_fg_raise"))
    12261227  {
    1227     vec2i tile = the_game->GetFgTile(vec2i(dlastx, dlasty));
     1228    vec2i tile = the_game->GetFgTile(dlast);
    12281229    if (tile.x >= 0 && tile.y >= 0 &&
    12291230        tile.x < current_level->foreground_width() &&
     
    15141515  if (ev.type==EV_MOUSE_BUTTON && ev.mouse_button)
    15151516  {
    1516     vec2i pos = the_game->MouseToGame(vec2i(last_demo_mx, last_demo_my));
     1517    vec2i pos = the_game->MouseToGame(last_demo_mpos);
    15171518    if (!current_level) return ;
    15181519    current_area=current_level->area_list=new area_controller(pos.x, pos.y,
     
    15531554  if (ev.type==EV_MOUSE_BUTTON && ev.mouse_button)
    15541555  {
    1555     int32_t mx=last_demo_mx,my=last_demo_my;
    1556     view *v = the_game->GetView(vec2i(mx, my));
     1556    vec2i m = last_demo_mpos;
     1557    view *v = the_game->GetView(m);
    15571558    for (area_controller *a=current_level->area_list; a; a=a->next)
    15581559    {
    15591560      vec2i pos1 = the_game->GameToMouse(vec2i(a->x, a->y), v);
    15601561      vec2i pos2 = the_game->GameToMouse(vec2i(a->x + a->w, a->y + a->h), v);
    1561       if (abs(pos1.x - mx) < 2 && abs(pos1.y - my) < 2)
     1562      if (abs(pos1.x - m.x) < 2 && abs(pos1.y - m.y) < 2)
    15621563      { find = a; find_top = 1; }
    1563       else if (abs(pos2.x - mx) < 2 && abs(pos2.y - my) < 2)
     1564      else if (abs(pos2.x - m.x) < 2 && abs(pos2.y - m.y) < 2)
    15641565      { find = a; find_top = 0; }
    15651566    }
     
    16211622{
    16221623  int32_t x,y;
    1623   if (link_object && (dlastx!=last_link_x || dlasty!=last_link_y))
    1624   {
    1625     last_link_x=dlastx;
    1626     last_link_y=dlasty;
     1624  if (link_object && (dlast.x!=last_link_x || dlast.y!=last_link_y))
     1625  {
     1626    last_link_x=dlast.x;
     1627    last_link_y=dlast.y;
    16271628    the_game->need_refresh();
    16281629  }
     
    16351636    pal_wins[x]->handle_event(ev);
    16361637  if (ev.type==EV_MOUSE_MOVE)
    1637   {
    1638     dlastx=last_demo_mx;
    1639     dlasty=last_demo_my;
    1640   }
     1638    dlast = last_demo_mpos;
    16411639  if (dev_console && dev_console->handle_event(ev))
    16421640    return;
     
    16861684    if (ev.type==EV_MOUSE_MOVE)
    16871685    {
    1688       vec2i pos = the_game->MouseToGame(vec2i(last_demo_mx, last_demo_my));
     1686      vec2i pos = the_game->MouseToGame(last_demo_mpos);
    16891687      edit_object->x = snap_x(pos.x);
    16901688      edit_object->y = snap_y(pos.y);
     
    17141712    if (ev.type==EV_MOUSE_MOVE)
    17151713    {
    1716       vec2i pos = the_game->MouseToGame(vec2i(last_demo_mx, last_demo_my));
     1714      vec2i pos = the_game->MouseToGame(last_demo_mpos);
    17171715      edit_light->x = snap_x(pos.x);
    17181716      edit_light->y = snap_y(pos.y);
     
    17961794      if (current_area)
    17971795      {
    1798     vec2i pos = the_game->MouseToGame(vec2i(last_demo_mx, last_demo_my));
     1796    vec2i pos = the_game->MouseToGame(last_demo_mpos);
    17991797    if (pos.x>current_area->x && pos.y>current_area->y)
    18001798    {
     
    18181816      if (current_area)
    18191817      {
    1820     vec2i pos = the_game->MouseToGame(vec2i(last_demo_mx, last_demo_my));
     1818    vec2i pos = the_game->MouseToGame(last_demo_mpos);
    18211819    if (pos.x<current_area->x+current_area->w && pos.y<current_area->y+current_area->h)
    18221820    {
     
    18441842    if (ev.window==NULL)
    18451843    {
    1846       vec2i pos = the_game->MouseToGame(vec2i(last_demo_mx, last_demo_my));
     1844      vec2i pos = the_game->MouseToGame(last_demo_mpos);
    18471845
    18481846      if (!(dev & MAP_MODE))
     
    18611859        if (ev.mouse_button==1 && !selected_object && !selected_light)
    18621860        {
    1863           vec2i tile = the_game->GetFgTile(vec2i(last_demo_mx, last_demo_my));
     1861          vec2i tile = the_game->GetFgTile(last_demo_mpos);
    18641862          if (tile.x>=0 && tile.y>=0 && tile.x<current_level->foreground_width() &&
    18651863          tile.y<current_level->foreground_height())
     
    18681866        } else if (ev.mouse_button==1 && !selected_object && !selected_light)
    18691867        {
    1870           vec2i tile = the_game->GetBgTile(vec2i(last_demo_mx, last_demo_my));
     1868          vec2i tile = the_game->GetBgTile(last_demo_mpos);
    18711869          if (tile.x>=0 && tile.y>=0 && tile.x<current_level->background_width() &&
    18721870          tile.y<current_level->background_height())
     
    19491947      else if (ev.window==NULL)
    19501948      {
    1951         if (dlastx>=0 && dlasty>=0 && edit_mode==ID_DMODE_DRAW)
     1949        if (dlast.x>=0 && dlast.y>=0 && edit_mode==ID_DMODE_DRAW)
    19521950        {
    19531951          if ((dev & DRAW_FG_LAYER) && ev.mouse_button==1)
    19541952          {
    1955         vec2i tile = the_game->GetFgTile(vec2i(last_demo_mx, last_demo_my));
     1953        vec2i tile = the_game->GetFgTile(last_demo_mpos);
    19561954        if (tile.x>=0 && tile.y>=0 && tile.x<current_level->foreground_width() &&
    19571955            tile.y<current_level->foreground_height())
     
    19601958          if ((dev & DRAW_BG_LAYER) && ev.mouse_button==2)
    19611959          {
    1962         vec2i tile = the_game->GetBgTile(vec2i(last_demo_mx, last_demo_my));
     1960        vec2i tile = the_game->GetBgTile(last_demo_mpos);
    19631961        if (tile.x>=0 && tile.y>=0 && tile.x<current_level->background_width() &&
    19641962            tile.y<current_level->background_height())
     
    24852483    case DEV_LIGHT9 :
    24862484    {
    2487       vec2i pos = the_game->MouseToGame(vec2i(last_demo_mx, last_demo_my));
     2485      vec2i pos = the_game->MouseToGame(last_demo_mpos);
    24882486      edit_light = add_light_source(ev.message.id - DEV_LIGHT0,
    24892487                                    snap_x(pos.x), snap_y(pos.y),
     
    27322730        if (ev.window==NULL || ev.window==forew)
    27332731        {
    2734           vec2i tile = the_game->GetFgTile(vec2i(last_demo_mx, last_demo_my));
     2732          vec2i tile = the_game->GetFgTile(last_demo_mpos);
    27352733          fg_fill(cur_fg, tile.x, tile.y, NULL);
    27362734        }
     
    28182816      case 'w' :
    28192817      {
    2820         vec2i pos = the_game->MouseToGame(vec2i(dlastx, dlasty));
     2818        vec2i pos = the_game->MouseToGame(dlast);
    28212819        char msg[100]; sprintf(msg, symbol_str("mouse_at"), pos.x, pos.y);
    28222820        the_game->show_help(msg);
     
    28392837        if (current_level && player_list && player_list->focus)
    28402838        {
    2841           vec2i pos = the_game->MouseToGame(vec2i(dlastx, dlasty));
     2839          vec2i pos = the_game->MouseToGame(dlast);
    28422840          player_list->focus->x = pos.x;
    28432841          player_list->focus->y = pos.y;
     
    28482846      case 'z' : do_command("clear_weapons",ev); break;
    28492847      case 'Z' : if (dev&EDIT_MODE)
    2850       { view *v = the_game->GetView(vec2i(last_demo_mx, last_demo_my));
     2848      { view *v = the_game->GetView(last_demo_mpos);
    28512849        if (v)
    28522850        {
     
    30303028        if (ev.mouse_button==1)
    30313029    {
    3032       int selx=(last_demo_mx-me->x-me->x1())/(the_game->ftile_width()/scale),
    3033           sely=(last_demo_my-me->y-me->y1())/(the_game->ftile_height()/scale);
     3030      int selx=(last_demo_mpos.x-me->x-me->x1())/(the_game->ftile_width()/scale),
     3031          sely=(last_demo_mpos.y-me->y-me->y1())/(the_game->ftile_height()/scale);
    30343032      if (selx>=0 && sely>=0 && selx<w && sely<h)
    30353033      {
     
    30453043      else
    30463044      {
    3047         int selx=(last_demo_mx-me->x-me->x1())/(the_game->ftile_width()/scale),
    3048             sely=(last_demo_my-me->y-me->y1())/(the_game->ftile_height()/scale);
     3045        int selx=(last_demo_mpos.x-me->x-me->x1())/(the_game->ftile_width()/scale),
     3046            sely=(last_demo_mpos.y-me->y-me->y1())/(the_game->ftile_height()/scale);
    30493047        if (selx>=0 && sely>=0 && selx<w && sely<h)
    30503048        {
  • abuse/trunk/src/game.cpp

    r657 r658  
    11251125int Game::in_area(Event &ev, int x1, int y1, int x2, int y2)
    11261126{
    1127   return (last_demo_mx >= x1 && last_demo_mx <= x2 &&
    1128       last_demo_my >= y1 && last_demo_my <= y2);
     1127  return (last_demo_mpos.x >= x1 && last_demo_mpos.x <= x2 &&
     1128      last_demo_mpos.y >= y1 && last_demo_mpos.y <= y2);
    11291129}
    11301130
     
    16861686
    16871687            help_handle_event(ev);
    1688             mousex = last_demo_mx;
    1689             mousey = last_demo_my;
     1688            mousex = last_demo_mpos.x;
     1689            mousey = last_demo_mpos.y;
    16901690
    16911691            if(ev.type == EV_MESSAGE)
  • abuse/trunk/src/loadgame.cpp

    r650 r658  
    107107
    108108  int w=cache.img(save_buts[0])->Size().x;
    109   int mx=last_demo_mx-w/2;
     109  int mx=last_demo_mpos.x-w/2;
    110110  if(mx + w + 10 > xres) mx = xres - w - 10;
    111111  if(mx < 0) mx = 0;
  • abuse/trunk/src/statbar.cpp

    r656 r658  
    301301
    302302
    303   int mx=small_render ? (last_demo_mx-v->cx1)*2+v->cx1 : last_demo_mx;
    304   int my=small_render ? (last_demo_my-v->cy1)*2+v->cy1 : last_demo_my;
     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;
    305305
    306306
  • abuse/trunk/src/view.cpp

    r657 r658  
    384384        if( focus )
    385385        {
    386             sug_p = the_game->MouseToGame(vec2i(last_demo_mx, last_demo_my));
     386            sug_p = the_game->MouseToGame(last_demo_mpos);
    387387            if(last_demo_mbut & 1)
    388388                sug_b2 = 1;
Note: See TracChangeset for help on using the changeset viewer.