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

game: convert a few integer pairs to vec2i variables.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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        {
Note: See TracChangeset for help on using the changeset viewer.