Changeset 676
- Timestamp:
- May 16, 2011, 2:37:51 AM (11 years ago)
- Location:
- abuse/trunk/src
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
abuse/trunk/src/ant.cpp
r668 r676 173 173 if (player_list->next) 174 174 b=current_level->attacker(current_object); 175 else b=player_list-> focus;175 else b=player_list->m_focus; 176 176 if (abs(b->x-o->x)<130 && (o->y<b->y)) 177 177 fall=1; … … 205 205 if (player_list->next) 206 206 b=current_level->attacker(current_object); 207 else b=player_list-> focus;207 else b=player_list->m_focus; 208 208 if (abs(b->x-o->x)<130 && (o->y<b->y)) 209 209 fall=1; … … 224 224 if (player_list->next) 225 225 b=current_level->attacker(current_object); 226 else b=player_list-> focus;226 else b=player_list->m_focus; 227 227 228 228 scream_check(o,b); … … 258 258 if (player_list->next) 259 259 b=current_level->attacker(current_object); 260 else b=player_list-> focus;260 else b=player_list->m_focus; 261 261 scream_check(o,b); 262 262 … … 350 350 if (player_list->next) 351 351 b=current_level->attacker(current_object); 352 else b=player_list-> focus;352 else b=player_list->m_focus; 353 353 fire_at_player(o,b); 354 354 o->set_state(stopped); … … 386 386 if (player_list->next) 387 387 b=current_level->attacker(current_object); 388 else b=player_list-> focus;388 else b=player_list->m_focus; 389 389 scream_check(o,b); 390 390 if (((jrand()%8)==0 && abs(o->x-b->x)<10 && o->y<b->y) || … … 425 425 if (player_list->next) 426 426 b=current_level->attacker(current_object); 427 else b=player_list-> focus;427 else b=player_list->m_focus; 428 428 fire_at_player(o,b); 429 429 o->set_state((character_state)S_top_walk); -
abuse/trunk/src/clisp.cpp
r674 r676 615 615 { if (player_list->next) 616 616 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; 618 618 case 5 : return LPointer::Create(current_level->find_closest(current_object->x, 619 619 current_object->y, … … 664 664 } break; 665 665 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; 667 667 case 10 : 668 668 { 669 669 view *v=((game_object *)lpointer_value(CAR(args)->Eval()))->controller()->next; 670 670 if (v) 671 return LPointer::Create(v-> focus);671 return LPointer::Create(v->m_focus); 672 672 else return NULL; 673 673 } break; … … 1256 1256 { 1257 1257 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; 1261 1260 } break; 1262 1261 case 78 : 1263 1262 { 1264 1263 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; 1268 1266 } break; 1269 1267 case 79 : current_object->set_gravity(lnumber_value(CAR(args))); return 1; break; … … 1819 1817 } break; 1820 1818 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; 1822 1820 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; 1824 1822 case 213 : 1825 1823 { view *v=lget_view(CAR(args),"set_no_scroll_range"); args=CDR(args); … … 1870 1868 view *v=current_object->controller(); 1871 1869 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)); 1873 1871 } break; 1874 1872 case 222 : … … 2273 2271 v->kills=0; 2274 2272 game_object *o=current_object; 2275 current_object=v-> focus;2273 current_object=v->m_focus; 2276 2274 2277 2275 ((LSymbol *)l_restart_player)->EvalFunction(NULL); 2278 2276 v->reset_player(); 2279 v-> focus->set_aistate(0);2277 v->m_focus->set_aistate(0); 2280 2278 current_object=o; 2281 2279 } -
abuse/trunk/src/cop.cpp
r674 r676 502 502 { 503 503 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; 506 506 o->set_state(stopped); 507 507 } … … 581 581 o->y+=28; 582 582 o->controller()->pan_y-=28; 583 o->controller()-> last_y+=28;583 o->controller()->m_lastpos.y += 28; 584 584 o->set_state((character_state)S_climb_on); 585 585 } … … 700 700 for (; f; f=f->next) 701 701 { 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; 704 704 705 705 if (o->x<=mex && o->y<=mey && other->x>=mex && other->y>=mey) 706 706 { 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; 710 710 } 711 711 } -
abuse/trunk/src/demo.cpp
r658 r676 144 144 145 145 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(); } 147 147 148 148 last_demo_mpos = vec2i(0, 0); … … 215 215 view *v=player_list; 216 216 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); } } 218 218 delete current_level; 219 219 current_level=NULL; -
abuse/trunk/src/dev.cpp
r674 r676 1016 1016 if (!strcmp(fword,"reload")) 1017 1017 { 1018 if (current_level && player_list && player_list-> focus)1018 if (current_level && player_list && player_list->m_focus) 1019 1019 { 1020 1020 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; 1022 1022 1023 1023 // save the old weapon array … … 1033 1033 the_game->draw(); 1034 1034 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; 1037 1037 1038 1038 memcpy(player_list->weapons,w,total_weapons*sizeof(int32_t)); … … 2828 2828 case 'j' : 2829 2829 { 2830 if (current_level && player_list && player_list-> focus)2830 if (current_level && player_list && player_list->m_focus) 2831 2831 { 2832 2832 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; 2835 2835 do_command("center",ev); 2836 2836 the_game->need_refresh(); -
abuse/trunk/src/extend.cpp
r555 r676 153 153 if (tobjs) free(objs); 154 154 if (Controller) 155 Controller-> focus=NULL;155 Controller->m_focus=NULL; 156 156 } 157 157 -
abuse/trunk/src/game.cpp
r674 r676 209 209 f->suggest.cy1 = (yres - 31) / 2 + 5 - h / 2; 210 210 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; 213 212 f->suggest.pan_x = f->pan_x; 214 213 f->suggest.pan_y = f->pan_y; … … 230 229 f->suggest.cx2=(f->m_bb.x + amount); 231 230 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; 234 232 f->suggest.pan_x = f->pan_x; 235 233 f->suggest.pan_y = f->pan_y; … … 315 313 if (dev & EDIT_MODE) 316 314 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() 319 317 - (v->m_bb.x - v->m_aa.x) / AUTOTILE_WIDTH / 2, 320 v-> focus->y / ftile_height()318 v->m_focus->y / ftile_height() 321 319 - (v->m_bb.y - v->m_aa.y) / AUTOTILE_HEIGHT / 2); 322 320 else … … 331 329 - tmp.y * AUTOTILE_HEIGHT + v->m_aa.y); 332 330 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()) 334 332 % AUTOTILE_WIDTH; 335 333 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()) 337 335 % AUTOTILE_HEIGHT; 338 336 … … 385 383 if(player_list) 386 384 { 387 first_view = new view(player_list-> focus, NULL, -1);385 first_view = new view(player_list->m_focus, NULL, -1); 388 386 first_view->pan_x = player_list->xoff(); 389 387 first_view->pan_y = player_list->yoff(); … … 777 775 } else 778 776 { 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; 783 781 } else x1 = y1 = 0; 784 782 } 785 783 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); 787 785 else xo = v->m_aa.x; 788 786 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); 790 788 else yo = v->m_aa.y; 791 789 } else … … 1450 1448 for(; f; f = f->next) 1451 1449 { 1452 if(f-> focus)1450 if(f->m_focus) 1453 1451 { 1454 1452 int w, h; … … 1762 1760 v->suggest.pan_x = v->pan_x; 1763 1761 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; 1766 1763 } 1767 1764 } … … 1827 1824 1828 1825 1829 if(!player_list-> focus)1826 if(!player_list->m_focus) 1830 1827 { 1831 1828 dprintf("Players have not been created\ncall create_players"); … … 1886 1883 for(view *f = first_view; f; f = f->next) 1887 1884 { 1888 if(f-> focus)1885 if(f->m_focus) 1889 1886 { 1890 1887 f->update_scroll(); … … 1949 1946 { 1950 1947 view *p = player_list; 1951 game_object *o = p-> focus;1948 game_object *o = p->m_focus; 1952 1949 player_list = player_list->next; 1953 1950 delete p; -
abuse/trunk/src/level.cpp
r668 r676 53 53 for (; f; f=f->next) 54 54 { 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); 58 58 if (tmp_d<d) 59 59 { 60 60 d=tmp_d; 61 c=f-> focus;61 c=f->m_focus; 62 62 } 63 63 } … … 77 77 game_object *level::main_character() 78 78 { 79 return the_game->first_view-> focus;79 return the_game->first_view->m_focus; 80 80 } 81 81 … … 89 89 view *f=player_list; 90 90 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); 93 93 94 94 while (first) … … 131 131 for (o=first; f && o; o=o->next) 132 132 { 133 while (f && !f-> focus) f=f->next;133 while (f && !f->m_focus) f=f->next; 134 134 if (f) 135 135 { … … 137 137 { 138 138 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); 143 143 f=f->next; 144 144 } … … 147 147 while (f) 148 148 { 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); 155 155 } 156 156 f=f->next; … … 163 163 /* int i; 164 164 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) 166 166 { 167 167 int tries=total_objs; … … 171 171 if (i==total_objs) 172 172 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--); 176 176 return ; 177 177 } */ … … 310 310 { 311 311 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); 314 314 j++; 315 315 last_start=o; … … 324 324 if (startable) 325 325 { 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); 327 327 f=new view(o,f,num); num++; 328 f-> focus->set_controller(f);328 f->m_focus->set_controller(f); 329 329 add_object_after(o,last_start); 330 330 } … … 1667 1667 1668 1668 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)); 1670 1670 1671 1671 int tv=total_view_vars(); … … 1721 1721 { 1722 1722 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; 1728 1728 } 1729 1729 … … 1829 1829 for (f=player_list; f; f=f->next) 1830 1830 { 1831 if (f-> focus)1832 { 1833 current_object = f-> focus;1831 if (f->m_focus) 1832 { 1833 current_object = f->m_focus; 1834 1834 void *m = LSpace::Tmp.Mark(); 1835 1835 fun->EvalFunction(NULL); … … 3094 3094 if (st) 3095 3095 { 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); 3100 3100 } 3101 3101 -
abuse/trunk/src/menu.cpp
r670 r676 446 446 view *v; 447 447 for (v=player_list; v; v=v->next) 448 if (v-> focus)448 if (v->m_focus) 449 449 v->reset_player(); 450 450 -
abuse/trunk/src/sensor.cpp
r555 r676 33 33 if (player_list->next) // find closest player 34 34 b=current_level->attacker(current_object); 35 else b=player_list-> focus;35 else b=player_list->m_focus; 36 36 if (abs(b->x-o->x)<o->xvel() && abs(b->y-o->y)<o->yvel()) // inside area? 37 37 { … … 49 49 if (player_list->next) 50 50 b=current_level->attacker(current_object); 51 else b=player_list-> focus;51 else b=player_list->m_focus; 52 52 if (abs(o->x-b->x)>o->xacel() || abs(o->y-b->y)>o->yacel()) 53 53 o->set_aistate(0); -
abuse/trunk/src/statbar.cpp
r674 r676 135 135 scale_put(sb,screen,sx,sy,sb_w,sb_h); 136 136 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); 139 139 140 140 int ammo_x,ammo_y; -
abuse/trunk/src/view.cpp
r675 r676 44 44 view::~view() 45 45 { 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 } 54 54 } 55 55 … … 116 116 int32_t view::xoff() 117 117 { 118 if (! focus)118 if (!m_focus) 119 119 return pan_x; 120 120 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); 122 122 } 123 123 124 124 int32_t view::interpolated_xoff() 125 125 { 126 if (! focus)126 if (!m_focus) 127 127 return pan_x; 128 128 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 } 133 132 134 133 int32_t view::yoff() 135 134 { 136 if (! focus)135 if (!m_focus) 137 136 return pan_y; 138 137 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 } 142 140 143 141 int32_t view::interpolated_yoff() 144 142 { 145 if (! focus)143 if (!m_focus) 146 144 return pan_y; 147 145 148 return Max(0, ( last_last_y + last_y) / 2149 - (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); 150 148 } 151 149 … … 153 151 void view::update_scroll() 154 152 { 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); 178 167 } 179 168 … … 199 188 } 200 189 201 view::view(game_object * Focus, view *Next, int number)202 { 203 chat_buf[0]=0;190 view::view(game_object *focus, view *Next, int number) 191 { 192 m_chat_buf[0] = 0; 204 193 205 194 draw_solid=-1; … … 208 197 no_ytop=0; 209 198 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); 221 200 last_hp=last_ammo=-1; 222 201 last_type=-1; … … 239 218 m_aa = vec2i(0); 240 219 m_bb = vec2i(100); 241 focus=Focus;220 m_focus = focus; 242 221 next=Next; 243 shift_down=SHIFT_DOWN_DEFAULT; 244 shift_right=SHIFT_RIGHT_DEFAULT; 222 m_shift = vec2i(SHIFT_RIGHT_DEFAULT, SHIFT_DOWN_DEFAULT); 245 223 x_suggestion=0; 246 224 y_suggestion=0; … … 276 254 int32_t view::x_center() 277 255 { 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; 279 257 } 280 258 281 259 int32_t view::y_center() 282 260 { 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; 284 262 } 285 263 286 264 void view::draw_character_damage() 287 265 { 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(); 291 269 int i; 292 270 for (i=0; i<total_weapons; i++) … … 310 288 for (; f; f=f->next) 311 289 { 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); 316 294 } 317 295 } … … 368 346 { 369 347 get_movement( 0, sug_x, sug_y, sug_b1, sug_b2, sug_b3, sug_b4 ); 370 if( focus )348 if( m_focus ) 371 349 { 372 350 sug_p = the_game->MouseToGame(last_demo_mpos); … … 389 367 base->packet.write_uint32( suggest.pan_x ); 390 368 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 ); 393 371 } 394 372 … … 431 409 void view::add_chat_key(int key) // return string if buf is complete 432 410 { 433 int len=strlen(chat_buf);411 int len = strlen(m_chat_buf); 434 412 if (key==JK_BACKSPACE) 435 413 { 436 414 if (len) 437 415 { 438 chat_buf[len-1]=0;416 m_chat_buf[len-1]=0; 439 417 if (local_player() && chat) 440 chat->draw_user( chat_buf);418 chat->draw_user(m_chat_buf); 441 419 } 442 420 } else if (key!=JK_ENTER) 443 421 { 444 chat_buf[len]=key;445 chat_buf[len+1]=0;422 m_chat_buf[len]=key; 423 m_chat_buf[len+1]=0; 446 424 if (local_player() && chat) 447 chat->draw_user( chat_buf);425 chat->draw_user(m_chat_buf); 448 426 } 449 427 … … 453 431 { 454 432 game_object *o=current_object; 455 current_object= focus;433 current_object=m_focus; 456 434 457 435 void *m = LSpace::Tmp.Mark(); 458 436 void *list=NULL; 459 push_onto_list(LString::Create( chat_buf),list);437 push_onto_list(LString::Create(m_chat_buf),list); 460 438 ((LSymbol *)l_chat_input)->EvalFunction(list); 461 439 LSpace::Tmp.Restore(m); … … 466 444 { 467 445 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; 471 449 if (local_player() && chat) 472 chat->draw_user( chat_buf);450 chat->draw_user(m_chat_buf); 473 451 } 474 452 } … … 491 469 pan_x=lltl(x[4]); 492 470 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])); 495 472 if (small_render) 496 473 small_render->Scale(m_bb - m_aa + vec2i(1)); … … 689 666 void view::draw_hp() 690 667 { 691 if ( focus)692 { 693 int h = focus->hp();668 if (m_focus) 669 { 670 int h = m_focus->hp(); 694 671 last_hp=h; 695 sbar.draw_health( main_screen, focus->hp() );672 sbar.draw_health( main_screen, m_focus->hp() ); 696 673 } 697 674 else … … 734 711 f->suggest.cy2=h-(total_weapons ? 33 : 0); 735 712 736 f->suggest.shift_down=f->shift_down; 737 f->suggest.shift_right=f->shift_right; 713 f->suggest.shift = f->m_shift; 738 714 f->suggest.pan_x=f->pan_x; 739 715 f->suggest.pan_y=f->pan_y; … … 799 775 v->m_aa = vec2i(320 / 2 - 155, 200 / 2 - 95); 800 776 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); 802 778 total--; 803 779 rdw=1; … … 832 808 void view::reset_player() 833 809 { 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(); 839 815 if (start) 840 816 { 841 focus->x=start->x;842 focus->y=start->y;817 m_focus->x=start->x; 818 m_focus->y=start->y; 843 819 dprintf("reset player position to %d %d\n",start->x,start->y); 844 820 } 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); 848 824 memset(weapons,0xff,total_weapons*sizeof(int32_t)); 849 825 memset(last_weapons,0xff,total_weapons*sizeof(int32_t)); 850 826 851 shift_down=SHIFT_DOWN_DEFAULT; 852 shift_right=SHIFT_RIGHT_DEFAULT; 827 m_shift = vec2i(SHIFT_RIGHT_DEFAULT, SHIFT_DOWN_DEFAULT); 853 828 854 829 if (total_weapons) … … 856 831 current_weapon=0; 857 832 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)) 861 836 { 862 837 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); 865 840 current_object=o; 866 841 } … … 868 843 869 844 int i; 870 for (i=0; i< focus->total_objects(); i++) // reset the vars for the attached objects871 { 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); 873 848 memset(o->lvars,0,figures[o->otype]->tv*4); 874 849 } … … 886 861 for (view *o=player_list; o; o=o->next) 887 862 { 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); 893 868 if (first) 894 869 last->next=q; … … 896 871 last=q; 897 872 } 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); 901 876 902 877 if (!object_to_number_in_list(p,first)) … … 977 952 case V_CX2 : return m_bb.x; break; 978 953 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; 981 956 case V_GOD : return god; break; 982 957 case V_PLAYER_NUMBER : return player_number; break; … … 997 972 case V_NO_YTOP : return no_ytop; break; 998 973 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; 1001 976 case V_LAST_LEFT : return last_left; break; 1002 977 case V_LAST_RIGHT : return last_right; break; … … 1015 990 case V_POINTER_X : return pointer_x; break; 1016 991 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; 1019 994 case V_FREEZE_TIME : return freeze_time; break; 1020 995 } … … 1032 1007 case V_CX2 : m_bb.x = x; break; 1033 1008 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; 1036 1011 case V_GOD : god=x; break; 1037 1012 case V_PLAYER_NUMBER : { player_number=x; if (local_player()) sbar.associate(this); } break; … … 1052 1027 case V_NO_YTOP : no_ytop=x; break; 1053 1028 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; 1056 1031 case V_LAST_LEFT : last_left=x; break; 1057 1032 case V_LAST_RIGHT : last_right=x; break; … … 1071 1046 case V_POINTER_X : pointer_x=x; break; 1072 1047 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; 1075 1050 case V_FREEZE_TIME : freeze_time=x; break; 1076 1051 } … … 1222 1197 } 1223 1198 1224 v-> focus=NULL;1199 v->m_focus=NULL; 1225 1200 if (last) 1226 1201 last->next=v->next; … … 1242 1217 tint = 0; 1243 1218 _tint = tint; 1244 focus->set_tint(tint);1219 m_focus->set_tint(tint); 1245 1220 } 1246 1221 … … 1255 1230 team = 0; 1256 1231 _team = team; 1257 focus->set_team(team);1232 m_focus->set_team(team); 1258 1233 } 1259 1234 -
abuse/trunk/src/view.h
r674 r676 22 22 struct suggest_struct 23 23 { 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 }; 28 29 29 30 … … 37 38 ~view(); 38 39 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)); elsekeymap[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)); } 42 43 void add_chat_key(int key); 43 44 44 45 char name[100]; 45 46 struct suggest_struct suggest; 46 int32_t shift_down,shift_right; // shift of view47 47 48 48 int god; // :) if you believe in such things … … 57 57 58 58 59 game_object *focus; // object we are focusing on (player)60 59 int x_suggestion, // input from the player at the current time 61 60 y_suggestion, … … 71 70 short ambient; // ambient lighting setting, used by draw 72 71 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; 75 73 76 74 int32_t last_left,last_right,last_up,last_down, // how many frames ago were these pressed (<=0) … … 113 111 114 112 void reset_player(); 115 int receive_failed() { return focus==NULL; }113 int receive_failed() { return m_focus==NULL; } 116 114 int32_t get_view_var_value(int num); 117 115 int32_t set_view_var_value(int num, int32_t x); … … 124 122 125 123 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) 126 128 127 129 private: 128 uint8_t keymap[512 / 8];129 char chat_buf[60];130 uint8_t m_keymap[512 / 8]; 131 char m_chat_buf[60]; 130 132 }; 131 133
Note: See TracChangeset
for help on using the changeset viewer.