Changeset 16 for abuse/trunk/src/objects.cpp
- Timestamp:
- Nov 10, 2005, 8:08:09 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
abuse/trunk/src/objects.cpp
r4 r16 82 82 }; 83 83 84 longgame_object::get_var_by_name(char *name, int &error)84 int32_t game_object::get_var_by_name(char *name, int &error) 85 85 { 86 86 error=0; … … 112 112 } 113 113 114 int game_object::set_var_by_name(char *name, longvalue)114 int game_object::set_var_by_name(char *name, int32_t value) 115 115 { 116 116 int i=0; … … 144 144 145 145 146 void simple_object::set_var(int xx, u longv)146 void simple_object::set_var(int xx, uint32_t v) 147 147 { 148 148 switch (xx) … … 184 184 } 185 185 186 longsimple_object::get_var(int xx)186 int32_t simple_object::get_var(int xx) 187 187 { 188 188 switch (xx) … … 370 370 void game_object::draw_above(view *v) 371 371 { 372 longx1,y1,x2,y2,sy1,sy2,sx,i;372 int32_t x1,y1,x2,y2,sy1,sy2,sx,i; 373 373 picture_space(x1,y1,x2,y2); 374 374 … … 376 376 if (sy2>=v->cy1) 377 377 { 378 longdraw_to=y1-(sy2-v->cy1),tmp=x;378 int32_t draw_to=y1-(sy2-v->cy1),tmp=x; 379 379 current_level->foreground_intersect(x,y1,tmp,draw_to); 380 380 the_game->game_to_mouse(x1,draw_to,v,i,sy1); // calculate sy1 … … 456 456 457 457 458 void game_object::do_damage(int amount, game_object *from, long hitx, longhity,459 long push_xvel, longpush_yvel)458 void game_object::do_damage(int amount, game_object *from, int32_t hitx, int32_t hity, 459 int32_t push_xvel, int32_t push_yvel) 460 460 { 461 461 … … 527 527 } 528 528 529 void game_object::damage_fun(int amount, game_object *from, long hitx, longhity,530 long push_xvel, longpush_yvel)529 void game_object::damage_fun(int amount, game_object *from, int32_t hitx, int32_t hity, 530 int32_t push_xvel, int32_t push_yvel) 531 531 { 532 532 if (!hurtable() || !alive()) return ; … … 569 569 570 570 571 void game_object::picture_space( long &x1, long &y1,long &x2, long&y2)571 void game_object::picture_space(int32_t &x1, int32_t &y1,int32_t &x2, int32_t &y2) 572 572 { 573 573 int xc=x_center(),w=picture()->width(),h=picture()->height(); … … 605 605 606 606 607 longgame_object::x_center()607 int32_t game_object::x_center() 608 608 { 609 609 return current_sequence()->x_center(current_frame); … … 748 748 } 749 749 750 game_object *game_object::try_move( long x, long y, long &xv, long&yv, int checks)750 game_object *game_object::try_move(int32_t x, int32_t y, int32_t &xv, int32_t &yv, int checks) 751 751 { 752 752 if (xv || yv) // make sure they are suggesting movement 753 753 { 754 754 game_object *who1=NULL,*who2=NULL; // who did we intersect? 755 longx2,y2,h;755 int32_t x2,y2,h; 756 756 757 757 if (checks&1) … … 791 791 void *game_object::float_tick() // returns 1 if you hit something, 0 otherwise 792 792 { 793 longret=0;793 int32_t ret=0; 794 794 if (hp()<=0) 795 795 { … … 816 816 } 817 817 818 longfxv=sfxvel()+sfxacel(),fyv=sfyvel()+sfyacel();819 longxv=xvel()+xacel()+(fxv>>8),yv=yvel()+yacel()+(fyv>>8);818 int32_t fxv=sfxvel()+sfxacel(),fyv=sfyvel()+sfyacel(); 819 int32_t xv=xvel()+xacel()+(fxv>>8),yv=yvel()+yacel()+(fyv>>8); 820 820 821 821 if (xv!=xvel() || yv!=yvel()) // only store vel's if changed so we don't increase object size … … 834 834 if (fxv || fyv || xv || yv) // don't even try if there is no velocity 835 835 { 836 longffx=fx()+sfxvel(),ffy=fy()+sfyvel();837 longnxv=xvel()+(ffx>>8);838 longnyv=yvel()+(ffy>>8);836 int32_t ffx=fx()+sfxvel(),ffy=fy()+sfyvel(); 837 int32_t nxv=xvel()+(ffx>>8); 838 int32_t nyv=yvel()+(ffy>>8); 839 839 set_fx(ffx&0xff); 840 840 set_fy(ffy&0xff); 841 841 842 longold_nxv=nxv,old_nyv=nyv;842 int32_t old_nxv=nxv,old_nyv=nyv; 843 843 game_object *hit_object=try_move(x,y,nxv,nyv,3); // now find out what velocity is safe to use 844 844 … … 853 853 if (old_nxv!=nxv || old_nyv!=nyv) 854 854 { 855 longlx=last_tile_hit_x,ly=last_tile_hit_y;855 int32_t lx=last_tile_hit_x,ly=last_tile_hit_y; 856 856 stop(); 857 857 if (old_nxv==0) … … 865 865 } else 866 866 { 867 longtx=(old_nxv>0 ? 1 : -1),ty=0;867 int32_t tx=(old_nxv>0 ? 1 : -1),ty=0; 868 868 try_move(x,y,tx,ty,3); 869 869 if (!tx) … … 906 906 int blocked=0; 907 907 908 longxt=0,yt=2;908 int32_t xt=0,yt=2; 909 909 try_move(x,y-2,xt,yt,1); // make sure we are not falling through the floor 910 910 y=y-2+yt; … … 926 926 927 927 // first let's move the guy acording to his physics 928 longxa=xacel(),ya=yacel(),fxa=sfxacel(),fya=sfyacel();928 int32_t xa=xacel(),ya=yacel(),fxa=sfxacel(),fya=sfyacel(); 929 929 if (xa || ya || fxa || fya) 930 930 { 931 931 int fxv=sfxvel(),fyv=sfyvel(); 932 932 fxv+=fxa; fyv+=fya; 933 longxv=xvel()+xa+(fxv>>8);933 int32_t xv=xvel()+xa+(fxv>>8); 934 934 set_xvel(xvel()+xa+(fxv>>8)); 935 935 set_yvel(yvel()+ya+(fyv>>8)); … … 939 939 940 940 // check to see if this advancement causes him to collide with objects 941 longold_vy=yvel(),old_vx=xvel(); // save the correct veloicties941 int32_t old_vy=yvel(),old_vx=xvel(); // save the correct veloicties 942 942 943 943 if (old_vx || old_vy) … … 946 946 if (yvel()<=0) // if we are going up or a strait across check up and down 947 947 up=2; 948 longxv=xvel(),yv=yvel();948 int32_t xv=xvel(),yv=yvel(); 949 949 game_object *h=try_move(x,y,xv,yv,1|up); // now find out what velocity is safe to use 950 950 set_xvel(xv); … … 959 959 if (gravity()) // was he going up or down? 960 960 { 961 longfall_xv=0,old_fall_vy,fall_vy;961 int32_t fall_xv=0,old_fall_vy,fall_vy; 962 962 old_fall_vy=fall_vy=old_vy-yvel(); // make sure he gets all of his yvel 963 963 try_move(x,y,fall_xv,fall_vy,1|up); … … 1001 1001 if (old_vy!=0) 1002 1002 { 1003 longtestx=old_vx<0 ? -1 : 1,testy=0; // see if we were stopped left/right1003 int32_t testx=old_vx<0 ? -1 : 1,testy=0; // see if we were stopped left/right 1004 1004 // or just up down 1005 1005 try_move(x,y,testx,testy,1|up); … … 1032 1032 else // see if we can make him 'climb' the hill 1033 1033 { 1034 longox=x,oy=y; // rember orginal position in case climb doesn't work1035 1036 longclimb_xvel=0,climb_yvel=-5; // try to move up one pixel to step over the1034 int32_t ox=x,oy=y; // rember orginal position in case climb doesn't work 1035 1036 int32_t climb_xvel=0,climb_yvel=-5; // try to move up one pixel to step over the 1037 1037 try_move(x,y,climb_xvel,climb_yvel,3); // jutting polygon line 1038 1038 y+=climb_yvel; … … 1082 1082 if (yacel()==0 && !gravity()) // he is not falling, make sure he can't 1083 1083 { 1084 longnvx=0,nvy=yvel()+12; // check three pixels below for ground1084 int32_t nvx=0,nvy=yvel()+12; // check three pixels below for ground 1085 1085 try_move(x,y,nvx,nvy,1); 1086 1086 if (nvy>11) // if he falls more than 2 pixels, then he falls … … 1117 1117 if (ad && current_level) 1118 1118 { 1119 longxv;1119 int32_t xv; 1120 1120 if (direction>0) xv=ad; else xv=-ad; 1121 longyv=0;1121 int32_t yv=0; 1122 1122 try_move(x,y,xv,yv,3); 1123 1123 x+=xv; … … 1139 1139 1140 1140 1141 game_object *create(int type, long x, longy, int skip_constructor, int aitype)1141 game_object *create(int type, int32_t x, int32_t y, int skip_constructor, int aitype) 1142 1142 { 1143 1143 game_object *g=new game_object(type,skip_constructor); … … 1299 1299 else if (!gravity() && state!=start_run_jump) 1300 1300 { 1301 longstop_acel;1301 int32_t stop_acel; 1302 1302 if (xvel()<0) // he was going left 1303 1303 { … … 1448 1448 1449 1449 // first let's move the guy acording to his physics 1450 longxa=xacel(),ya=yacel(),fxa=sfxacel(),fya=sfyacel();1450 int32_t xa=xacel(),ya=yacel(),fxa=sfxacel(),fya=sfyacel(); 1451 1451 if (xa || ya || fxa || fya) 1452 1452 { 1453 1453 int fxv=sfxvel(),fyv=sfyvel(); 1454 1454 fxv+=fxa; fyv+=fya; 1455 longxv=xvel()+xa+(fxv>>8);1455 int32_t xv=xvel()+xa+(fxv>>8); 1456 1456 set_xvel(xvel()+xa+(fxv>>8)); 1457 1457 set_yvel(yvel()+ya+(fyv>>8)); … … 1460 1460 } 1461 1461 1462 longox2,oy2;1463 1464 longnx=x+xvel(),nfx=fx()+fxvel(),ny=y+yvel(),nfy=fy()+fyvel();1462 int32_t ox2,oy2; 1463 1464 int32_t nx=x+xvel(),nfx=fx()+fxvel(),ny=y+yvel(),nfy=fy()+fyvel(); 1465 1465 nx+=nfx>>8; 1466 1466 ny+=nfy>>8; … … 1506 1506 } 1507 1507 1508 game_object *number_to_object_in_list( longx, object_node *list)1508 game_object *number_to_object_in_list(int32_t x, object_node *list) 1509 1509 { 1510 1510 if (!x) return NULL; x--; … … 1526 1526 1527 1527 1528 longobject_list_length(object_node *list)1529 { 1530 longx=0;1528 int32_t object_list_length(object_node *list) 1529 { 1530 int32_t x=0; 1531 1531 while (list) { list=list->next; x++; } 1532 1532 return x; … … 1543 1543 if (t) 1544 1544 { 1545 lvars=( long*)jmalloc(t*4,"object vars");1545 lvars=(int32_t *)jmalloc(t*4,"object vars"); 1546 1546 memset(lvars,0,t*4); 1547 1547 } … … 1556 1556 int game_object::reduced_state() 1557 1557 { 1558 longx=0;1558 int32_t x=0; 1559 1559 for (int i=0;i<figures[otype]->ts;i++) 1560 1560 { … … 1607 1607 if (t) 1608 1608 { 1609 lvars=( long*)jmalloc(t*4,"object vars");1609 lvars=(int32_t *)jmalloc(t*4,"object vars"); 1610 1610 memset(lvars,0,t*4); 1611 1611 }
Note: See TracChangeset
for help on using the changeset viewer.