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

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

File:
1 edited

Legend:

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