Ignore:
Timestamp:
Nov 10, 2005, 8:08:09 PM (17 years ago)
Author:
Sam Hocevar
Message:
  • shitloads of long -> int32_t changes for 64 bit safety.
File:
1 edited

Legend:

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

    r4 r16  
    8282                              };
    8383 
    84 long game_object::get_var_by_name(char *name, int &error)
     84int32_t game_object::get_var_by_name(char *name, int &error)
    8585{
    8686  error=0;
     
    112112}
    113113
    114 int game_object::set_var_by_name(char *name, long value)
     114int game_object::set_var_by_name(char *name, int32_t value)
    115115{
    116116  int i=0;
     
    144144
    145145
    146 void simple_object::set_var(int xx, ulong v)
     146void simple_object::set_var(int xx, uint32_t v)
    147147{
    148148  switch (xx)
     
    184184}
    185185
    186 long simple_object::get_var(int xx)
     186int32_t simple_object::get_var(int xx)
    187187{
    188188  switch (xx)
     
    370370void game_object::draw_above(view *v)
    371371{
    372   long x1,y1,x2,y2,sy1,sy2,sx,i;
     372  int32_t x1,y1,x2,y2,sy1,sy2,sx,i;
    373373  picture_space(x1,y1,x2,y2);   
    374374
     
    376376  if (sy2>=v->cy1)
    377377  {
    378     long draw_to=y1-(sy2-v->cy1),tmp=x;
     378    int32_t draw_to=y1-(sy2-v->cy1),tmp=x;
    379379    current_level->foreground_intersect(x,y1,tmp,draw_to);     
    380380    the_game->game_to_mouse(x1,draw_to,v,i,sy1);     // calculate sy1
     
    456456
    457457   
    458 void game_object::do_damage(int amount, game_object *from, long hitx, long hity,
    459                             long push_xvel, long push_yvel)
     458void game_object::do_damage(int amount, game_object *from, int32_t hitx, int32_t hity,
     459                            int32_t push_xvel, int32_t push_yvel)
    460460{
    461461
     
    527527}
    528528
    529 void game_object::damage_fun(int amount, game_object *from, long hitx, long hity,
    530                             long push_xvel, long push_yvel)
     529void game_object::damage_fun(int amount, game_object *from, int32_t hitx, int32_t hity,
     530                            int32_t push_xvel, int32_t push_yvel)
    531531{
    532532  if (!hurtable() || !alive()) return ;
     
    569569
    570570
    571 void game_object::picture_space(long &x1, long &y1,long &x2, long &y2)
     571void game_object::picture_space(int32_t &x1, int32_t &y1,int32_t &x2, int32_t &y2)
    572572{
    573573  int xc=x_center(),w=picture()->width(),h=picture()->height(); 
     
    605605
    606606
    607 long game_object::x_center()
     607int32_t game_object::x_center()
    608608{
    609609  return current_sequence()->x_center(current_frame);   
     
    748748}
    749749
    750 game_object *game_object::try_move(long x, long y, long &xv, long &yv, int checks)
     750game_object *game_object::try_move(int32_t x, int32_t y, int32_t &xv, int32_t &yv, int checks)
    751751{
    752752  if (xv || yv)  // make sure they are suggesting movement
    753753  {   
    754754    game_object *who1=NULL,*who2=NULL;      // who did we intersect? 
    755     long x2,y2,h; 
     755    int32_t x2,y2,h; 
    756756
    757757    if (checks&1)
     
    791791void *game_object::float_tick()  // returns 1 if you hit something, 0 otherwise
    792792{
    793   long ret=0;
     793  int32_t ret=0;
    794794  if (hp()<=0)
    795795  {
     
    816816  }
    817817
    818   long fxv=sfxvel()+sfxacel(),fyv=sfyvel()+sfyacel();
    819   long xv=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);
    820820
    821821  if (xv!=xvel() || yv!=yvel())   // only store vel's if changed so we don't increase object size
     
    834834  if (fxv || fyv || xv || yv)   // don't even try if there is no velocity
    835835  {
    836     long ffx=fx()+sfxvel(),ffy=fy()+sfyvel();
    837     long nxv=xvel()+(ffx>>8);
    838     long nyv=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);
    839839    set_fx(ffx&0xff);
    840840    set_fy(ffy&0xff);
    841841   
    842     long old_nxv=nxv,old_nyv=nyv;
     842    int32_t old_nxv=nxv,old_nyv=nyv;
    843843    game_object *hit_object=try_move(x,y,nxv,nyv,3);   // now find out what velocity is safe to use
    844844   
     
    853853    if (old_nxv!=nxv || old_nyv!=nyv)
    854854    {
    855       long lx=last_tile_hit_x,ly=last_tile_hit_y;
     855      int32_t lx=last_tile_hit_x,ly=last_tile_hit_y;
    856856      stop();
    857857      if (old_nxv==0)
     
    865865      } else
    866866      {
    867         long tx=(old_nxv>0 ? 1 : -1),ty=0;
     867        int32_t tx=(old_nxv>0 ? 1 : -1),ty=0;
    868868        try_move(x,y,tx,ty,3);
    869869        if (!tx)       
     
    906906  int blocked=0;
    907907
    908   long xt=0,yt=2;
     908  int32_t xt=0,yt=2;
    909909  try_move(x,y-2,xt,yt,1);    // make sure we are not falling through the floor
    910910  y=y-2+yt;
     
    926926 
    927927  // first let's move the guy acording to his physics
    928   long xa=xacel(),ya=yacel(),fxa=sfxacel(),fya=sfyacel();
     928  int32_t xa=xacel(),ya=yacel(),fxa=sfxacel(),fya=sfyacel();
    929929  if (xa || ya || fxa || fya)
    930930  {
    931931    int fxv=sfxvel(),fyv=sfyvel();
    932932    fxv+=fxa;  fyv+=fya;   
    933     long xv=xvel()+xa+(fxv>>8);
     933    int32_t xv=xvel()+xa+(fxv>>8);
    934934    set_xvel(xvel()+xa+(fxv>>8));
    935935    set_yvel(yvel()+ya+(fyv>>8));
     
    939939 
    940940  // check to see if this advancement causes him to collide with objects
    941   long old_vy=yvel(),old_vx=xvel();  // save the correct veloicties
     941  int32_t old_vy=yvel(),old_vx=xvel();  // save the correct veloicties
    942942
    943943  if (old_vx || old_vy)
     
    946946    if (yvel()<=0)  // if we are going up or a strait across check up and down
    947947    up=2;
    948     long xv=xvel(),yv=yvel();
     948    int32_t xv=xvel(),yv=yvel();
    949949    game_object *h=try_move(x,y,xv,yv,1|up);       // now find out what velocity is safe to use
    950950    set_xvel(xv);
     
    959959      if (gravity())                         // was he going up or down?
    960960      {                       
    961         long fall_xv=0,old_fall_vy,fall_vy;
     961        int32_t fall_xv=0,old_fall_vy,fall_vy;
    962962        old_fall_vy=fall_vy=old_vy-yvel();             // make sure he gets all of his yvel
    963963        try_move(x,y,fall_xv,fall_vy,1|up);
     
    10011001          if (old_vy!=0)
    10021002          {
    1003             long testx=old_vx<0 ? -1 : 1,testy=0;    // see if we were stopped left/right
     1003            int32_t testx=old_vx<0 ? -1 : 1,testy=0;    // see if we were stopped left/right
    10041004                                                     // or just up down
    10051005            try_move(x,y,testx,testy,1|up);
     
    10321032      else                  // see if we can make him 'climb' the hill
    10331033      {
    1034         long ox=x,oy=y;       // rember orginal position in case climb doesn't work
    1035 
    1036         long climb_xvel=0,climb_yvel=-5;            // try to move up one pixel to step over the
     1034        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
    10371037        try_move(x,y,climb_xvel,climb_yvel,3);  // jutting polygon line
    10381038        y+=climb_yvel;
     
    10821082  if (yacel()==0 && !gravity())       // he is not falling, make sure he can't
    10831083  {
    1084     long nvx=0,nvy=yvel()+12;  // check three pixels below for ground
     1084    int32_t nvx=0,nvy=yvel()+12;  // check three pixels below for ground
    10851085    try_move(x,y,nvx,nvy,1);
    10861086    if (nvy>11)                    // if he falls more than 2 pixels, then he falls
     
    11171117  if (ad && current_level)
    11181118  {
    1119     long xv;
     1119    int32_t xv;
    11201120    if (direction>0) xv=ad; else xv=-ad;
    1121     long yv=0;
     1121    int32_t yv=0;
    11221122    try_move(x,y,xv,yv,3);
    11231123    x+=xv;
     
    11391139
    11401140
    1141 game_object *create(int type, long x, long y, int skip_constructor, int aitype)
     1141game_object *create(int type, int32_t x, int32_t y, int skip_constructor, int aitype)
    11421142{
    11431143  game_object *g=new game_object(type,skip_constructor);
     
    12991299  else if (!gravity() && state!=start_run_jump)
    13001300  {   
    1301     long stop_acel;
     1301    int32_t stop_acel;
    13021302    if (xvel()<0)                                    // he was going left
    13031303    {
     
    14481448
    14491449  // first let's move the guy acording to his physics
    1450   long xa=xacel(),ya=yacel(),fxa=sfxacel(),fya=sfyacel();
     1450  int32_t xa=xacel(),ya=yacel(),fxa=sfxacel(),fya=sfyacel();
    14511451  if (xa || ya || fxa || fya)
    14521452  {
    14531453    int fxv=sfxvel(),fyv=sfyvel();
    14541454    fxv+=fxa;  fyv+=fya;   
    1455     long xv=xvel()+xa+(fxv>>8);
     1455    int32_t xv=xvel()+xa+(fxv>>8);
    14561456    set_xvel(xvel()+xa+(fxv>>8));
    14571457    set_yvel(yvel()+ya+(fyv>>8));
     
    14601460  }
    14611461 
    1462   long ox2,oy2;
    1463 
    1464   long nx=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();
    14651465  nx+=nfx>>8;
    14661466  ny+=nfy>>8;
     
    15061506}
    15071507
    1508 game_object *number_to_object_in_list(long x, object_node *list)
     1508game_object *number_to_object_in_list(int32_t x, object_node *list)
    15091509{
    15101510  if (!x) return NULL; x--;
     
    15261526
    15271527
    1528 long object_list_length(object_node *list)
    1529 {
    1530   long x=0;
     1528int32_t object_list_length(object_node *list)
     1529{
     1530  int32_t x=0;
    15311531  while (list) { list=list->next; x++; }
    15321532  return x;
     
    15431543    if (t)
    15441544    {
    1545       lvars=(long *)jmalloc(t*4,"object vars");
     1545      lvars=(int32_t *)jmalloc(t*4,"object vars");
    15461546      memset(lvars,0,t*4);
    15471547    }
     
    15561556int game_object::reduced_state()
    15571557{
    1558   long x=0;
     1558  int32_t x=0;
    15591559  for (int i=0;i<figures[otype]->ts;i++)
    15601560  {
     
    16071607    if (t)
    16081608    {
    1609       lvars=(long *)jmalloc(t*4,"object vars");
     1609      lvars=(int32_t *)jmalloc(t*4,"object vars");
    16101610      memset(lvars,0,t*4);
    16111611    }
Note: See TracChangeset for help on using the changeset viewer.