Changeset 676


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

game: prefix a few class members with m_ to avoid confusion.

Location:
abuse/trunk/src
Files:
13 edited

Legend:

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

    r668 r676  
    173173    if (player_list->next)
    174174      b=current_level->attacker(current_object);
    175     else b=player_list->focus;
     175    else b=player_list->m_focus;
    176176    if (abs(b->x-o->x)<130 && (o->y<b->y))
    177177      fall=1;
     
    205205      if (player_list->next)
    206206        b=current_level->attacker(current_object);
    207       else b=player_list->focus;
     207      else b=player_list->m_focus;
    208208      if (abs(b->x-o->x)<130 && (o->y<b->y))
    209209      fall=1;
     
    224224      if (player_list->next)
    225225      b=current_level->attacker(current_object);
    226       else b=player_list->focus;
     226      else b=player_list->m_focus;
    227227
    228228      scream_check(o,b);
     
    258258      if (player_list->next)
    259259      b=current_level->attacker(current_object);
    260       else b=player_list->focus;
     260      else b=player_list->m_focus;
    261261      scream_check(o,b);
    262262
     
    350350        if (player_list->next)
    351351        b=current_level->attacker(current_object);
    352         else b=player_list->focus;
     352        else b=player_list->m_focus;
    353353        fire_at_player(o,b);
    354354        o->set_state(stopped);
     
    386386      if (player_list->next)
    387387      b=current_level->attacker(current_object);
    388       else b=player_list->focus;
     388      else b=player_list->m_focus;
    389389      scream_check(o,b);
    390390      if (((jrand()%8)==0 && abs(o->x-b->x)<10 && o->y<b->y) ||
     
    425425    if (player_list->next)
    426426      b=current_level->attacker(current_object);
    427     else b=player_list->focus;
     427    else b=player_list->m_focus;
    428428    fire_at_player(o,b);
    429429    o->set_state((character_state)S_top_walk);
  • abuse/trunk/src/clisp.cpp

    r674 r676  
    615615    { if (player_list->next)
    616616        return LPointer::Create(current_level->attacker(current_object));
    617       else return LPointer::Create(player_list->focus); } break;
     617      else return LPointer::Create(player_list->m_focus); } break;
    618618    case 5 : return LPointer::Create(current_level->find_closest(current_object->x,
    619619                                 current_object->y,
     
    664664    } break;
    665665
    666     case 9 : return LPointer::Create(the_game->first_view->focus); break;
     666    case 9 : return LPointer::Create(the_game->first_view->m_focus); break;
    667667    case 10 :
    668668    {
    669669      view *v=((game_object *)lpointer_value(CAR(args)->Eval()))->controller()->next;
    670670      if (v)
    671         return LPointer::Create(v->focus);
     671        return LPointer::Create(v->m_focus);
    672672      else return NULL;
    673673    } break;
     
    12561256    {
    12571257      game_object *o=(game_object *)lpointer_value(CAR(args));
    1258       if (!o->controller())
    1259     printf("set shift : object is not a focus\n");
    1260       else o->controller()->shift_down=lnumber_value(CAR(CDR(args))); return 1;
     1258      if (!o->controller()) printf("set shift: object is not a focus\n");
     1259      else o->controller()->m_shift.y=lnumber_value(CAR(CDR(args))); return 1;
    12611260    } break;
    12621261    case 78 :
    12631262    {
    12641263      game_object *o=(game_object *)lpointer_value(CAR(args));
    1265       if (!o->controller())
    1266     printf("set shift : object is not a focus\n");
    1267       else o->controller()->shift_right=lnumber_value(CAR(CDR(args))); return 1;
     1264      if (!o->controller()) printf("set shift: object is not a focus\n");
     1265      else o->controller()->m_shift.x=lnumber_value(CAR(CDR(args))); return 1;
    12681266    } break;
    12691267    case 79 : current_object->set_gravity(lnumber_value(CAR(args))); return 1; break;
     
    18191817    } break;
    18201818    case 211:
    1821     { return lget_view(CAR(args),"shift_down")->shift_right; } break;
     1819    { return lget_view(CAR(args),"shift_down")->m_shift.y; } break;
    18221820    case 212:
    1823     { return lget_view(CAR(args),"shift_right")->shift_down; } break;
     1821    { return lget_view(CAR(args),"shift_right")->m_shift.x; } break;
    18241822    case 213 :
    18251823    { view *v=lget_view(CAR(args),"set_no_scroll_range"); args=CDR(args);
     
    18701868      view *v=current_object->controller();
    18711869      if (!v) lbreak("object has no view : view_push_down");
    1872       else v->last_y-=lnumber_value(CAR(args));
     1870      else v->m_lastpos.y-=lnumber_value(CAR(args));
    18731871    } break;
    18741872    case 222 :
     
    22732271        v->kills=0;
    22742272    game_object *o=current_object;
    2275     current_object=v->focus;
     2273    current_object=v->m_focus;
    22762274
    22772275    ((LSymbol *)l_restart_player)->EvalFunction(NULL);
    22782276    v->reset_player();
    2279     v->focus->set_aistate(0);
     2277    v->m_focus->set_aistate(0);
    22802278    current_object=o;
    22812279      }
  • abuse/trunk/src/cop.cpp

    r674 r676  
    502502  {
    503503    o->y-=28;
    504     o->controller()->pan_y+=28;
    505     o->controller()->last_y-=28;
     504    o->controller()->pan_y += 28;
     505    o->controller()->m_lastpos.y -= 28;
    506506    o->set_state(stopped);
    507507  }
     
    581581      o->y+=28;
    582582      o->controller()->pan_y-=28;
    583       o->controller()->last_y+=28;
     583      o->controller()->m_lastpos.y += 28;
    584584      o->set_state((character_state)S_climb_on);
    585585    }
     
    700700    for (; f; f=f->next)
    701701    {
    702       int mex=f->focus->x;
    703       int mey=f->focus->y;
     702      int mex=f->m_focus->x;
     703      int mey=f->m_focus->y;
    704704
    705705      if (o->x<=mex && o->y<=mey && other->x>=mex && other->y>=mey)
    706706      {
    707     if (f->focus->state==S_climbing)
    708       f->focus->x=(o->x+other->x)/2;
    709         f->focus->lvars[in_climbing_area]=mey-o->y;
     707    if (f->m_focus->state==S_climbing)
     708      f->m_focus->x=(o->x+other->x)/2;
     709        f->m_focus->lvars[in_climbing_area]=mey-o->y;
    710710      }
    711711    }
  • abuse/trunk/src/demo.cpp

    r658 r676  
    144144
    145145  view *v=player_list;
    146   for (; v; v=v->next) { if (v->focus) v->reset_player(); }
     146  for (; v; v=v->next) { if (v->m_focus) v->reset_player(); }
    147147
    148148  last_demo_mpos = vec2i(0, 0);
     
    215215      view *v=player_list;
    216216      for (; v; v=v->next)  // reset all the players
    217       { if (v->focus) { v->reset_player(); v->focus->set_aistate(0); } }
     217      { if (v->m_focus) { v->reset_player(); v->m_focus->set_aistate(0); } }
    218218      delete current_level;
    219219      current_level=NULL;
  • abuse/trunk/src/dev.cpp

    r674 r676  
    10161016  if (!strcmp(fword,"reload"))
    10171017  {
    1018     if (current_level && player_list && player_list->focus)
     1018    if (current_level && player_list && player_list->m_focus)
    10191019    {
    10201020      edit_object=selected_object=NULL;
    1021       int32_t cx=player_list->focus->x,cy=player_list->focus->y;
     1021      int32_t cx=player_list->m_focus->x,cy=player_list->m_focus->y;
    10221022
    10231023      // save the old weapon array
     
    10331033        the_game->draw();
    10341034      player_list->reset_player();
    1035       player_list->focus->x=cx;
    1036       player_list->focus->y=cy;
     1035      player_list->m_focus->x=cx;
     1036      player_list->m_focus->y=cy;
    10371037
    10381038      memcpy(player_list->weapons,w,total_weapons*sizeof(int32_t));
     
    28282828      case 'j' :
    28292829      {
    2830         if (current_level && player_list && player_list->focus)
     2830        if (current_level && player_list && player_list->m_focus)
    28312831        {
    28322832          vec2i pos = the_game->MouseToGame(dlast);
    2833           player_list->focus->x = pos.x;
    2834           player_list->focus->y = pos.y;
     2833          player_list->m_focus->x = pos.x;
     2834          player_list->m_focus->y = pos.y;
    28352835          do_command("center",ev);
    28362836          the_game->need_refresh();
  • abuse/trunk/src/extend.cpp

    r555 r676  
    153153  if (tobjs)   free(objs);
    154154  if (Controller)
    155     Controller->focus=NULL;
     155    Controller->m_focus=NULL;
    156156}
    157157
  • abuse/trunk/src/game.cpp

    r674 r676  
    209209        f->suggest.cy1 = (yres - 31) / 2 + 5 - h / 2;
    210210        f->suggest.cy2 = (yres - 51) / 2 + 5 + h / 2;
    211         f->suggest.shift_down = f->shift_down;
    212         f->suggest.shift_right = f->shift_right;
     211        f->suggest.shift = f->m_shift;
    213212        f->suggest.pan_x = f->pan_x;
    214213        f->suggest.pan_y = f->pan_y;
     
    230229        f->suggest.cx2=(f->m_bb.x + amount);
    231230        f->suggest.cy2 = f->m_bb.y + amount / 2;
    232         f->suggest.shift_down = f->shift_down;
    233         f->suggest.shift_right = f->shift_right;
     231        f->suggest.shift = f->m_shift;
    234232        f->suggest.pan_x = f->pan_x;
    235233        f->suggest.pan_y = f->pan_y;
     
    315313    if (dev & EDIT_MODE)
    316314        tmp = vec2i(map_xoff, map_yoff);
    317     else if(v->focus)
    318         tmp = vec2i(v->focus->x / ftile_width()
     315    else if(v->m_focus)
     316        tmp = vec2i(v->m_focus->x / ftile_width()
    319317                       - (v->m_bb.x - v->m_aa.x) / AUTOTILE_WIDTH / 2,
    320                     v->focus->y / ftile_height()
     318                    v->m_focus->y / ftile_height()
    321319                       - (v->m_bb.y - v->m_aa.y) / AUTOTILE_HEIGHT / 2);
    322320    else
     
    331329                 - tmp.y * AUTOTILE_HEIGHT + v->m_aa.y);
    332330    if (tmp.x > 0)
    333         ret.x -= (v->focus->x * AUTOTILE_WIDTH / ftile_width())
     331        ret.x -= (v->m_focus->x * AUTOTILE_WIDTH / ftile_width())
    334332                     % AUTOTILE_WIDTH;
    335333    if(tmp.y > 0)
    336         ret.y -= (v->focus->y * AUTOTILE_HEIGHT / ftile_height())
     334        ret.y -= (v->m_focus->y * AUTOTILE_HEIGHT / ftile_height())
    337335                     % AUTOTILE_HEIGHT;
    338336
     
    385383        if(player_list)
    386384        {
    387             first_view = new view(player_list->focus, NULL, -1);
     385            first_view = new view(player_list->m_focus, NULL, -1);
    388386            first_view->pan_x = player_list->xoff();
    389387            first_view->pan_y = player_list->yoff();
     
    777775      } else
    778776      {
    779     if(v->focus)
    780     {
    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;
     777    if(v->m_focus)
     778    {
     779      x1 = v->m_focus->x / ftile_width() - (v->m_bb.x - v->m_aa.x) / fw / 2;
     780      y1 = v->m_focus->y / ftile_height() - (v->m_bb.y - v->m_aa.y) / fh / 2;
    783781    } else x1 = y1 = 0;
    784782      }
    785783      if(x1 > 0)
    786         xo = v->m_aa.x - ((v->focus->x * fw / ftile_width()) % fw);
     784        xo = v->m_aa.x - ((v->m_focus->x * fw / ftile_width()) % fw);
    787785      else xo = v->m_aa.x;
    788786      if(y1 > 0)
    789         yo = v->m_aa.y - ((v->focus->y * fh / ftile_height()) % fh);
     787        yo = v->m_aa.y - ((v->m_focus->y * fh / ftile_height()) % fh);
    790788      else yo = v->m_aa.y;
    791789    } else
     
    14501448      for(; f; f = f->next)
    14511449      {
    1452     if(f->focus)
     1450    if(f->m_focus)
    14531451    {
    14541452      int w, h;
     
    17621760                                        v->suggest.pan_x = v->pan_x;
    17631761                                        v->suggest.pan_y = v->pan_y;
    1764                                         v->suggest.shift_down = v->shift_down;
    1765                                         v->suggest.shift_right = v->shift_right;
     1762                                        v->suggest.shift = v->m_shift;
    17661763                                    }
    17671764                                }
     
    18271824
    18281825
    1829       if(!player_list->focus)
     1826      if(!player_list->m_focus)
    18301827      {
    18311828    dprintf("Players have not been created\ncall create_players");
     
    18861883    for(view *f = first_view; f; f = f->next)
    18871884    {
    1888       if(f->focus)
     1885      if(f->m_focus)
    18891886      {
    18901887    f->update_scroll();
     
    19491946  {
    19501947    view *p = player_list;
    1951     game_object *o = p->focus;
     1948    game_object *o = p->m_focus;
    19521949    player_list = player_list->next;
    19531950    delete p;
  • abuse/trunk/src/level.cpp

    r668 r676  
    5353  for (; f; f=f->next)
    5454  {
    55     if (f->focus)
    56     {
    57       int32_t tmp_d=abs(f->focus->x-who->x)+abs(f->focus->y-who->y);
     55    if (f->m_focus)
     56    {
     57      int32_t tmp_d=abs(f->m_focus->x-who->x)+abs(f->m_focus->y-who->y);
    5858      if (tmp_d<d)
    5959      {
    6060    d=tmp_d;
    61     c=f->focus;
     61    c=f->m_focus;
    6262      }
    6363    }
     
    7777game_object *level::main_character()
    7878{
    79   return the_game->first_view->focus;
     79  return the_game->first_view->m_focus;
    8080}
    8181
     
    8989  view *f=player_list;
    9090  for (; f; f=f->next)
    91     if (f->focus)
    92       current_level->remove_object(f->focus);
     91    if (f->m_focus)
     92      current_level->remove_object(f->m_focus);
    9393
    9494  while (first)
     
    131131  for (o=first; f && o; o=o->next)
    132132  {
    133     while (f && !f->focus) f=f->next;
     133    while (f && !f->m_focus) f=f->next;
    134134    if (f)
    135135    {
     
    137137      {
    138138    if (!found) found=o;
    139     f->focus->x=o->x;
    140     f->focus->y=o->y;
    141     f->focus->set_hp(get_ability(f->focus->otype,start_hp));
    142     f->focus->set_state(stopped);
     139    f->m_focus->x=o->x;
     140    f->m_focus->y=o->y;
     141    f->m_focus->set_hp(get_ability(f->m_focus->otype,start_hp));
     142    f->m_focus->set_state(stopped);
    143143    f=f->next;
    144144      }
     
    147147  while (f)
    148148  {
    149     if (f->focus)
    150     {
    151       f->focus->x=found->x;
    152       f->focus->y=found->y;
    153       f->focus->set_hp(get_ability(f->focus->otype,start_hp));
    154       f->focus->set_state(stopped);
     149    if (f->m_focus)
     150    {
     151      f->m_focus->x=found->x;
     152      f->m_focus->y=found->y;
     153      f->m_focus->set_hp(get_ability(f->m_focus->otype,start_hp));
     154      f->m_focus->set_state(stopped);
    155155    }
    156156    f=f->next;
     
    163163/*  int i;
    164164  for (i=0; i<total_objs; i++)
    165     if (obj[i]==the_game->first_view->focus)
     165    if (obj[i]==the_game->first_view->m_focus)
    166166    {
    167167      int tries=total_objs;
     
    171171    if (i==total_objs)
    172172      i=0;
    173     the_game->first_view->focus=obj[i];
    174       }  while ((!the_game->first_view->focus->is_playable() ||
    175          the_game->first_view->focus->hp<=0) && tries--);
     173    the_game->first_view->m_focus=obj[i];
     174      }  while ((!the_game->first_view->m_focus->is_playable() ||
     175         the_game->first_view->m_focus->hp<=0) && tries--);
    176176      return ;
    177177    }            */
     
    310310    {
    311311      f=new view(create(use_type,o->x,o->y),f,num); num++;
    312       f->focus->set_controller(f);
    313       add_object_after(f->focus,o);
     312      f->m_focus->set_controller(f);
     313      add_object_after(f->m_focus,o);
    314314      j++;
    315315      last_start=o;
     
    324324    if (startable)
    325325    {
    326       game_object *o=create(use_type,f->focus->x,f->focus->y);
     326      game_object *o=create(use_type,f->m_focus->x,f->m_focus->y);
    327327      f=new view(o,f,num); num++;
    328       f->focus->set_controller(f);
     328      f->m_focus->set_controller(f);
    329329      add_object_after(o,last_start);
    330330    }
     
    16671667
    16681668  for (v=player_list; v; v=v->next)
    1669     fp->write_uint32(object_to_number_in_list(v->focus,save_list));
     1669    fp->write_uint32(object_to_number_in_list(v->m_focus,save_list));
    16701670
    16711671  int tv=total_view_vars();
     
    17211721    {
    17221722      v=player_list;
    1723       if (v->focus)
    1724       {
    1725         if (v->focus->controller())
    1726          v->focus->set_controller(NULL);
    1727     delete v->focus;
     1723      if (v->m_focus)
     1724      {
     1725        if (v->m_focus->controller())
     1726         v->m_focus->set_controller(NULL);
     1727    delete v->m_focus;
    17281728      }
    17291729
     
    18291829      for (f=player_list; f; f=f->next)
    18301830      {
    1831     if (f->focus)
    1832     {
    1833       current_object = f->focus;
     1831    if (f->m_focus)
     1832    {
     1833      current_object = f->m_focus;
    18341834      void *m = LSpace::Tmp.Mark();
    18351835      fun->EvalFunction(NULL);
     
    30943094    if (st)
    30953095    {
    3096       f->focus->x=st->x;
    3097       f->focus->y=st->y;
    3098     }
    3099     add_object_after(f->focus,st);
     3096      f->m_focus->x=st->x;
     3097      f->m_focus->y=st->y;
     3098    }
     3099    add_object_after(f->m_focus,st);
    31003100  }
    31013101
  • abuse/trunk/src/menu.cpp

    r670 r676  
    446446      view *v;
    447447      for (v=player_list; v; v=v->next)
    448         if (v->focus)
     448        if (v->m_focus)
    449449          v->reset_player();
    450450
  • abuse/trunk/src/sensor.cpp

    r555 r676  
    3333    if (player_list->next)                 // find closest player
    3434      b=current_level->attacker(current_object);
    35     else b=player_list->focus;
     35    else b=player_list->m_focus;
    3636    if (abs(b->x-o->x)<o->xvel() && abs(b->y-o->y)<o->yvel())  // inside area?
    3737    {
     
    4949      if (player_list->next)
    5050        b=current_level->attacker(current_object);
    51       else b=player_list->focus;
     51      else b=player_list->m_focus;
    5252      if (abs(o->x-b->x)>o->xacel() || abs(o->y-b->y)>o->yacel())
    5353        o->set_aistate(0);
  • abuse/trunk/src/statbar.cpp

    r674 r676  
    135135    scale_put(sb,screen,sx,sy,sb_w,sb_h);
    136136
    137     if (v->focus)
    138       draw_num(screen,sx+(small_render ? 17*2 : 17),sy+(small_render ? 11*2 : 11),v->focus->hp(),bnum);
     137    if (v->m_focus)
     138      draw_num(screen,sx+(small_render ? 17*2 : 17),sy+(small_render ? 11*2 : 11),v->m_focus->hp(),bnum);
    139139
    140140    int ammo_x,ammo_y;
  • abuse/trunk/src/view.cpp

    r675 r676  
    4444view::~view()
    4545{
    46   if (local_player())
    47     sbar.associate(NULL);
    48 
    49   if (total_weapons)
    50   {
    51     free(weapons);
    52     free(last_weapons);
    53   }
     46    if (local_player())
     47        sbar.associate(NULL);
     48
     49    if (total_weapons)
     50    {
     51        free(weapons);
     52        free(last_weapons);
     53    }
    5454}
    5555
     
    116116int32_t view::xoff()
    117117{
    118     if (!focus)
     118    if (!m_focus)
    119119        return pan_x;
    120120
    121     return Max(0, last_x - (m_bb.x - m_aa.x + 1) / 2 + shift_right + pan_x);
     121    return Max(0, m_lastpos.x - (m_bb.x - m_aa.x + 1) / 2 + m_shift.x + pan_x);
    122122}
    123123
    124124int32_t view::interpolated_xoff()
    125125{
    126     if (!focus)
     126    if (!m_focus)
    127127        return pan_x;
    128128
    129     return Max(0, (last_last_x + last_x) / 2
    130                     - (m_bb.x - m_aa.x + 1) / 2 + shift_right + pan_x);
    131 }
    132 
     129    return Max(0, (m_lastlastpos.x + m_lastpos.x) / 2
     130                    - (m_bb.x - m_aa.x + 1) / 2 + m_shift.x + pan_x);
     131}
    133132
    134133int32_t view::yoff()
    135134{
    136     if (!focus)
     135    if (!m_focus)
    137136        return pan_y;
    138137
    139     return Max(0, last_y - (m_bb.y - m_aa.y + 1) / 2 - shift_down + pan_y);
    140 }
    141 
     138    return Max(0, m_lastpos.y - (m_bb.y - m_aa.y + 1) / 2 - m_shift.y + pan_y);
     139}
    142140
    143141int32_t view::interpolated_yoff()
    144142{
    145     if (!focus)
     143    if (!m_focus)
    146144        return pan_y;
    147145
    148     return Max(0, (last_last_y + last_y) / 2
    149                     - (m_bb.y - m_aa.y + 1) / 2 - shift_down + pan_y);
     146    return Max(0, (m_lastlastpos.y + m_lastpos.y) / 2
     147                    - (m_bb.y - m_aa.y + 1) / 2 - m_shift.y + pan_y);
    150148}
    151149
     
    153151void view::update_scroll()
    154152{
    155   if (focus)
    156   {
    157     last_last_x=last_x;
    158     last_last_y=last_y;
    159     if (focus->x>last_x)
    160     {
    161       if (focus->x-last_x>=no_xright)
    162         last_x=focus->x-no_xright;
    163     } else if (focus->x<last_x)
    164     {
    165       if (last_x-focus->x>=no_xleft)
    166         last_x=focus->x+no_xleft;
    167     }
    168     if (focus->y>last_y)
    169     {
    170       if (focus->y-last_y>=no_ybottom)
    171         last_y=focus->y-no_ybottom;
    172     } else if (focus->y<last_y)
    173     {
    174       if (last_y-focus->y>=no_ytop)
    175         last_y=focus->y+no_ytop;
    176     }
    177   }
     153    if (!m_focus)
     154        return;
     155
     156    m_lastlastpos = m_lastpos;
     157
     158    if (m_focus->x > m_lastpos.x)
     159        m_lastpos.x = Max(m_lastpos.x, m_focus->x - no_xright);
     160    else if (m_focus->x < m_lastpos.x)
     161        m_lastpos.x = Min(m_lastpos.x, m_focus->x + no_xleft);
     162
     163    if (m_focus->y > m_lastpos.y)
     164        m_lastpos.y = Max(m_lastpos.y, m_focus->y - no_ybottom);
     165    else if (m_focus->y < m_lastpos.y)
     166        m_lastpos.y = Min(m_lastpos.y, m_focus->y + no_ytop);
    178167}
    179168
     
    199188}
    200189
    201 view::view(game_object *Focus, view *Next, int number)
    202 {
    203   chat_buf[0]=0;
     190view::view(game_object *focus, view *Next, int number)
     191{
     192    m_chat_buf[0] = 0;
    204193
    205194  draw_solid=-1;
     
    208197  no_ytop=0;
    209198  no_ybottom=0;
    210   if (Focus)
    211   {
    212     last_x=Focus->x;
    213     last_y=Focus->y;
    214   } else
    215   {
    216     last_x=last_y=0;
    217   }
    218 
    219   last_last_x=last_x;
    220   last_last_y=last_y;
     199    m_lastlastpos = m_lastpos = focus ? vec2i(focus->x, focus->y) : vec2i(0);
    221200  last_hp=last_ammo=-1;
    222201  last_type=-1;
     
    239218    m_aa = vec2i(0);
    240219    m_bb = vec2i(100);
    241   focus=Focus;
     220    m_focus = focus;
    242221  next=Next;
    243   shift_down=SHIFT_DOWN_DEFAULT;
    244   shift_right=SHIFT_RIGHT_DEFAULT;
     222    m_shift = vec2i(SHIFT_RIGHT_DEFAULT, SHIFT_DOWN_DEFAULT);
    245223  x_suggestion=0;
    246224  y_suggestion=0;
     
    276254int32_t view::x_center()
    277255{
    278     return focus ? focus->x : (m_aa.x + m_bb.x) / 2;
     256    return m_focus ? m_focus->x : (m_aa.x + m_bb.x) / 2;
    279257}
    280258
    281259int32_t view::y_center()
    282260{
    283     return focus ? focus->y : (m_aa.y + m_bb.y) / 2;
     261    return m_focus ? m_focus->y : (m_aa.y + m_bb.y) / 2;
    284262}
    285263
    286264void view::draw_character_damage()
    287265{
    288   if (focus && drawable())
    289   {
    290     if (last_hp!=focus->hp()) draw_hp();
     266  if (m_focus && drawable())
     267  {
     268    if (last_hp!=m_focus->hp()) draw_hp();
    291269    int i;
    292270    for (i=0; i<total_weapons; i++)
     
    310288    for (; f; f=f->next)
    311289    {
    312       if (f->focus)
    313       {
    314     x^=(f->focus->x&0xffff);
    315     x^=(f->focus->y&0xffff);
     290      if (f->m_focus)
     291      {
     292    x^=(f->m_focus->x&0xffff);
     293    x^=(f->m_focus->y&0xffff);
    316294      }
    317295    }
     
    368346    {
    369347        get_movement( 0, sug_x, sug_y, sug_b1, sug_b2, sug_b3, sug_b4 );
    370         if( focus )
     348        if( m_focus )
    371349        {
    372350            sug_p = the_game->MouseToGame(last_demo_mpos);
     
    389367        base->packet.write_uint32( suggest.pan_x );
    390368        base->packet.write_uint32( suggest.pan_y );
    391         base->packet.write_uint32( suggest.shift_down );
    392         base->packet.write_uint32( suggest.shift_right );
     369        base->packet.write_uint32( suggest.shift.y );
     370        base->packet.write_uint32( suggest.shift.x );
    393371    }
    394372
     
    431409void view::add_chat_key(int key)  // return string if buf is complete
    432410{
    433   int len=strlen(chat_buf);
     411    int len = strlen(m_chat_buf);
    434412  if (key==JK_BACKSPACE)
    435413  {
    436414    if (len)
    437415    {
    438       chat_buf[len-1]=0;
     416      m_chat_buf[len-1]=0;
    439417      if (local_player() && chat)
    440         chat->draw_user(chat_buf);
     418        chat->draw_user(m_chat_buf);
    441419    }
    442420  } else if (key!=JK_ENTER)
    443421  {
    444     chat_buf[len]=key;
    445     chat_buf[len+1]=0;
     422    m_chat_buf[len]=key;
     423    m_chat_buf[len+1]=0;
    446424    if (local_player() && chat)
    447       chat->draw_user(chat_buf);
     425      chat->draw_user(m_chat_buf);
    448426  }
    449427
     
    453431    {
    454432      game_object *o=current_object;
    455       current_object=focus;
     433      current_object=m_focus;
    456434
    457435      void *m = LSpace::Tmp.Mark();
    458436      void *list=NULL;
    459       push_onto_list(LString::Create(chat_buf),list);
     437      push_onto_list(LString::Create(m_chat_buf),list);
    460438      ((LSymbol *)l_chat_input)->EvalFunction(list);
    461439      LSpace::Tmp.Restore(m);
     
    466444    {
    467445      if (chat)
    468         chat->put_all(chat_buf);
    469     }
    470     chat_buf[0]=0;
     446        chat->put_all(m_chat_buf);
     447    }
     448    m_chat_buf[0]=0;
    471449    if (local_player() && chat)
    472       chat->draw_user(chat_buf);
     450      chat->draw_user(m_chat_buf);
    473451  }
    474452}
     
    491469      pan_x=lltl(x[4]);
    492470      pan_y=lltl(x[5]);
    493       shift_down=lltl(x[6]);
    494       shift_right=lltl(x[7]);
     471      m_shift = vec2i(lltl(x[7]), lltl(x[6]));
    495472      if (small_render)
    496473          small_render->Scale(m_bb - m_aa + vec2i(1));
     
    689666void view::draw_hp()
    690667{
    691     if (focus)
    692     {
    693         int h = focus->hp();
     668    if (m_focus)
     669    {
     670        int h = m_focus->hp();
    694671        last_hp=h;
    695         sbar.draw_health( main_screen, focus->hp() );
     672        sbar.draw_health( main_screen, m_focus->hp() );
    696673    }
    697674    else
     
    734711    f->suggest.cy2=h-(total_weapons ? 33 : 0);
    735712
    736     f->suggest.shift_down=f->shift_down;
    737     f->suggest.shift_right=f->shift_right;
     713    f->suggest.shift = f->m_shift;
    738714    f->suggest.pan_x=f->pan_x;
    739715    f->suggest.pan_y=f->pan_y;
     
    799775    v->m_aa = vec2i(320 / 2 - 155, 200 / 2 - 95);
    800776    v->m_bb = vec2i(320 / 2 + 155, 200 / 2 + total_weapons ? 60 : 95);
    801     v->focus->set_controller(v);
     777    v->m_focus->set_controller(v);
    802778    total--;
    803779    rdw=1;
     
    832808void view::reset_player()
    833809{
    834   if (focus)
    835   {
    836 
    837     game_object *start=current_level ? current_level->get_random_start(320,focus->controller()) : 0;
    838     focus->defaults();
     810  if (m_focus)
     811  {
     812
     813    game_object *start=current_level ? current_level->get_random_start(320,m_focus->controller()) : 0;
     814    m_focus->defaults();
    839815    if (start)
    840816    {
    841       focus->x=start->x;
    842       focus->y=start->y;
     817      m_focus->x=start->x;
     818      m_focus->y=start->y;
    843819      dprintf("reset player position to %d %d\n",start->x,start->y);
    844820    }
    845     focus->set_state(stopped);
    846     focus->set_tint(_tint);
    847     focus->set_team(_team);
     821    m_focus->set_state(stopped);
     822    m_focus->set_tint(_tint);
     823    m_focus->set_team(_team);
    848824    memset(weapons,0xff,total_weapons*sizeof(int32_t));
    849825    memset(last_weapons,0xff,total_weapons*sizeof(int32_t));
    850826
    851     shift_down=SHIFT_DOWN_DEFAULT;
    852     shift_right=SHIFT_RIGHT_DEFAULT;
     827    m_shift = vec2i(SHIFT_RIGHT_DEFAULT, SHIFT_DOWN_DEFAULT);
    853828
    854829    if (total_weapons)
     
    856831    current_weapon=0;
    857832
    858     memset(focus->lvars,0,figures[focus->otype]->tv*4);
    859     focus->set_aistate(0);
    860     if (figures[focus->otype]->get_fun(OFUN_CONSTRUCTOR))
     833    memset(m_focus->lvars,0,figures[m_focus->otype]->tv*4);
     834    m_focus->set_aistate(0);
     835    if (figures[m_focus->otype]->get_fun(OFUN_CONSTRUCTOR))
    861836    {
    862837      game_object *o=current_object;
    863       current_object=focus;
    864       ((LSymbol *)figures[focus->otype]->get_fun(OFUN_CONSTRUCTOR))->EvalUserFunction(NULL);
     838      current_object=m_focus;
     839      ((LSymbol *)figures[m_focus->otype]->get_fun(OFUN_CONSTRUCTOR))->EvalUserFunction(NULL);
    865840      current_object=o;
    866841    }
     
    868843
    869844    int i;
    870     for (i=0; i<focus->total_objects(); i++)   // reset the vars for the attached objects
    871     {
    872       game_object *o=focus->get_object(i);
     845    for (i=0; i<m_focus->total_objects(); i++)   // reset the vars for the attached objects
     846    {
     847      game_object *o=m_focus->get_object(i);
    873848      memset(o->lvars,0,figures[o->otype]->tv*4);
    874849    }
     
    886861  for (view *o=player_list; o; o=o->next)
    887862  {
    888     if (o->focus && (player_num==-1 || o->player_number==player_num))
    889     {
    890       if (!object_to_number_in_list(o->focus,first))
    891       {
    892     object_node *q=new object_node(o->focus,NULL);
     863    if (o->m_focus && (player_num==-1 || o->player_number==player_num))
     864    {
     865      if (!object_to_number_in_list(o->m_focus,first))
     866      {
     867    object_node *q=new object_node(o->m_focus,NULL);
    893868    if (first)
    894869      last->next=q;
     
    896871    last=q;
    897872      }
    898       for (int i=0; i<o->focus->total_objects(); i++)
    899       {
    900     game_object *p=o->focus->get_object(i);
     873      for (int i=0; i<o->m_focus->total_objects(); i++)
     874      {
     875    game_object *p=o->m_focus->get_object(i);
    901876
    902877    if (!object_to_number_in_list(p,first))
     
    977952    case V_CX2 : return m_bb.x; break;
    978953    case V_CY2 : return m_bb.y; break;
    979     case V_SHIFT_DOWN : return shift_down; break;
    980     case V_SHIFT_RIGHT : return shift_right; break;
     954    case V_SHIFT_DOWN : return m_shift.y; break;
     955    case V_SHIFT_RIGHT : return m_shift.x; break;
    981956    case V_GOD : return god; break;
    982957    case V_PLAYER_NUMBER : return player_number; break;
     
    997972    case V_NO_YTOP : return no_ytop; break;
    998973    case V_NO_YBOTTOM : return no_ybottom; break;
    999     case V_LAST_X : return last_x; break;
    1000     case V_LAST_Y : return last_y; break;
     974    case V_LAST_X : return m_lastpos.x; break;
     975    case V_LAST_Y : return m_lastpos.y; break;
    1001976    case V_LAST_LEFT : return last_left; break;
    1002977    case V_LAST_RIGHT : return last_right; break;
     
    1015990    case V_POINTER_X : return pointer_x; break;
    1016991    case V_POINTER_Y : return pointer_y; break;
    1017     case V_LAST_LAST_X : return last_last_x; break;
    1018     case V_LAST_LAST_Y : return last_last_y; break;
     992    case V_LAST_LAST_X : return m_lastlastpos.x; break;
     993    case V_LAST_LAST_Y : return m_lastlastpos.y; break;
    1019994    case V_FREEZE_TIME : return freeze_time; break;
    1020995  }
     
    10321007    case V_CX2 : m_bb.x = x; break;
    10331008    case V_CY2 : m_bb.y = x; break;
    1034     case V_SHIFT_DOWN : shift_down=x; break;
    1035     case V_SHIFT_RIGHT : shift_right=x; break;
     1009    case V_SHIFT_DOWN : m_shift.y = x; break;
     1010    case V_SHIFT_RIGHT : m_shift.x = x; break;
    10361011    case V_GOD : god=x; break;
    10371012    case V_PLAYER_NUMBER : { player_number=x; if (local_player()) sbar.associate(this); }  break;
     
    10521027    case V_NO_YTOP : no_ytop=x; break;
    10531028    case V_NO_YBOTTOM : no_ybottom=x; break;
    1054     case V_LAST_X : last_x=x; break;
    1055     case V_LAST_Y : last_y=x; break;
     1029    case V_LAST_X : m_lastpos.x=x; break;
     1030    case V_LAST_Y : m_lastpos.y=x; break;
    10561031    case V_LAST_LEFT : last_left=x; break;
    10571032    case V_LAST_RIGHT : last_right=x; break;
     
    10711046    case V_POINTER_X : pointer_x=x; break;
    10721047    case V_POINTER_Y : pointer_y=x; break;
    1073     case V_LAST_LAST_X : last_last_x=x; break;
    1074     case V_LAST_LAST_Y : last_last_y=x; break;
     1048    case V_LAST_LAST_X : m_lastlastpos.x = x; break;
     1049    case V_LAST_LAST_Y : m_lastlastpos.y = x; break;
    10751050    case V_FREEZE_TIME : freeze_time=x; break;
    10761051  }
     
    12221197      }
    12231198
    1224       v->focus=NULL;
     1199      v->m_focus=NULL;
    12251200      if (last)
    12261201      last->next=v->next;
     
    12421217        tint = 0;
    12431218    _tint = tint;
    1244     focus->set_tint(tint);
     1219    m_focus->set_tint(tint);
    12451220}
    12461221
     
    12551230        team = 0;
    12561231    _team = team;
    1257     focus->set_team(team);
     1232    m_focus->set_team(team);
    12581233}
    12591234
  • abuse/trunk/src/view.h

    r674 r676  
    2222struct suggest_struct
    2323{
    24   int32_t cx1,cy1,cx2,cy2,shift_down,shift_right,pan_x,pan_y;
    25   int32_t new_weapon;
    26   uint8_t send_view,send_weapon_change;
    27 } ;
     24    int32_t cx1,cy1,cx2,cy2,pan_x,pan_y;
     25    vec2i shift;
     26    int32_t new_weapon;
     27    uint8_t send_view,send_weapon_change;
     28};
    2829
    2930
     
    3738    ~view();
    3839
    39   int key_down(int key) { return keymap[key/8]&(1<<(key%8)); }
    40   void set_key_down(int key, int x) { if (x) keymap[key/8]|=(1<<(key%8)); else keymap[key/8]&=~(1<<(key%8)); }
    41   void reset_keymap() { memset(keymap,0,sizeof(keymap)); }
     40  int key_down(int key) { return m_keymap[key/8]&(1<<(key%8)); }
     41  void set_key_down(int key, int x) { if (x) m_keymap[key/8]|=(1<<(key%8)); else m_keymap[key/8]&=~(1<<(key%8)); }
     42  void reset_keymap() { memset(m_keymap,0,sizeof(m_keymap)); }
    4243  void add_chat_key(int key);
    4344
    4445  char name[100];
    4546  struct suggest_struct suggest;
    46   int32_t shift_down,shift_right;             // shift of view
    4747
    4848  int god;                                // :) if you believe in such things
     
    5757
    5858
    59   game_object *focus;                     // object we are focusing on (player)
    6059  int x_suggestion,                      // input from the player at the current time
    6160      y_suggestion,
     
    7170  short ambient;                        // ambient lighting setting, used by draw
    7271
    73   int32_t pan_x,pan_y,no_xleft,no_xright,no_ytop,no_ybottom,
    74        last_x,last_y,last_last_x,last_last_y,view_percent;
     72  int32_t pan_x,pan_y,no_xleft,no_xright,no_ytop,no_ybottom, view_percent;
    7573
    7674  int32_t last_left,last_right,last_up,last_down,   // how many frames ago were these pressed (<=0)
     
    113111
    114112  void reset_player();
    115   int receive_failed() { return focus==NULL; }
     113  int receive_failed() { return m_focus==NULL; }
    116114  int32_t get_view_var_value(int num);
    117115  int32_t set_view_var_value(int num, int32_t x);
     
    124122
    125123    vec2i m_aa, m_bb; // view area to show
     124    vec2i m_shift; // shift of view
     125    vec2i m_lastpos, m_lastlastpos;
     126
     127    game_object *m_focus; // object we are focusing on (player)
    126128
    127129private:
    128     uint8_t keymap[512 / 8];
    129     char chat_buf[60];
     130    uint8_t m_keymap[512 / 8];
     131    char m_chat_buf[60];
    130132};
    131133
Note: See TracChangeset for help on using the changeset viewer.