Changeset 527
- Timestamp:
- Apr 22, 2011, 4:13:04 AM (12 years ago)
- Location:
- abuse/trunk/src
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
abuse/trunk/src/clisp.cpp
r524 r527 1351 1351 case 123 : current_object->set_fxacel(lnumber_value(CAR(args))); break; 1352 1352 case 124 : current_object->set_fyacel(lnumber_value(CAR(args))); break; 1353 case 125 : return current_object->picture()-> width(); break;1354 case 126 : return current_object->picture()-> height(); break;1353 case 125 : return current_object->picture()->Size().x; break; 1354 case 126 : return current_object->picture()->Size().y; break; 1355 1355 case 127 : { dprintf("trap\n"); } break; // I use this to set gdb break points 1356 1356 case 128 : { return current_level->platform_push(current_object,lnumber_value(CAR(args)), … … 1500 1500 game_object *o=(game_object *)lpointer_value(CAR(args)); 1501 1501 int32_t x=o->x-current_object->x, 1502 y=-(o->y-o->picture()-> height()/2-(current_object->y-(current_object->picture()->height()/2)));1502 y=-(o->y-o->picture()->Size().y/2-(current_object->y-(current_object->picture()->Size().y/2))); 1503 1503 return lisp_atan2(y,x); 1504 1504 } break; -
abuse/trunk/src/cop.cpp
r512 r527 183 183 184 184 o->x=q->x; 185 o->y=q->y+29-q->picture()-> height();185 o->y=q->y+29-q->picture()->Size().y; 186 186 187 187 rand_on+=o->lvars[point_angle]; … … 653 653 ret=player_move(o,xm,ym,but); 654 654 top->x=o->x; 655 top->y=o->y+29-top->picture()-> height();655 top->y=o->y+29-top->picture()->Size().y; 656 656 657 657 if ((but&2) && !o->lvars[is_teleporting] && o->state!=S_climbing && o->state!=S_climb_off) … … 753 753 if (bot->direction<0) 754 754 o->x+=4; 755 o->y=bot->y+29-bot->picture()-> height();755 o->y=bot->y+29-bot->picture()->Size().y; 756 756 757 757 void *ret=NULL; -
abuse/trunk/src/dev.cpp
r518 r527 3327 3327 if (figures[type]->has_sequence((character_state)j)) 3328 3328 { 3329 int s=figures[type]->get_sequence((character_state)j)-> size();3329 int s=figures[type]->get_sequence((character_state)j)->MemUsage(); 3330 3330 if (print) 3331 3331 dprintf("(%s=%d)",state_names[j],s); -
abuse/trunk/src/devsel.cpp
r513 r527 33 33 case SPEC_FORETILE : 34 34 { 35 return cache.foret(foretiles[0])->im-> width()/scale;35 return cache.foret(foretiles[0])->im->Size().x/scale; 36 36 } break; 37 37 case SPEC_BACKTILE : … … 50 50 case SPEC_FORETILE : 51 51 { 52 return cache.foret(foretiles[0])->im-> height()/scale;52 return cache.foret(foretiles[0])->im->Size().y/scale; 53 53 } break; 54 54 case SPEC_BACKTILE : -
abuse/trunk/src/imlib/supmorph.cpp
r518 r527 28 28 int aneal_steps, void (*stat_fun)(int)) 29 29 { 30 int x,y,w1=hint1-> width(),31 h1=hint1-> height(),32 w2=hint2-> width(),33 h2=hint2-> height();30 int x,y,w1=hint1->Size().x, 31 h1=hint1->Size().y, 32 w2=hint2->Size().x, 33 h2=hint2->Size().y; 34 34 if (w1>w2) w=w1; else w=w2; 35 35 if (h1>h2) h=h1; else h=h2; … … 41 41 memset(hints2,0,256*2); 42 42 43 dp=hint1-> t_data();43 dp=hint1->Data(); 44 44 for (y=0; y<h1; y++) 45 45 { … … 58 58 59 59 // hint2 image2 60 dp=hint2-> t_data();60 dp=hint2->Data(); 61 61 for (y=0; y<h2; y++) 62 62 { … … 102 102 103 103 /**************** Now scan the images again setup hints *********************/ 104 dp=hint1-> t_data();104 dp=hint1->Data(); 105 105 for (y=0; y<h1; y++) 106 106 { … … 124 124 } 125 125 126 dp=hint2-> t_data();126 dp=hint2->Data(); 127 127 for (y=0; y<h2; y++) 128 128 { -
abuse/trunk/src/imlib/timage.cpp
r521 r527 17 17 image *trans_image::make_image() 18 18 { 19 image *im =new image(vec2i(w,h));19 image *im = new image(m_size); 20 20 21 21 im->Lock(); 22 uint8_t *d=im->scan_line(0),*dp= data,*dline;22 uint8_t *d=im->scan_line(0),*dp=m_data,*dline; 23 23 int y,x; 24 for (y=0; y< h; y++)24 for (y=0; y<m_size.y; y++) 25 25 { 26 26 x=0; 27 27 dline=d; 28 memset(dline,0, w);29 while(x< w)28 memset(dline,0,m_size.x); 29 while(x<m_size.x) 30 30 { 31 31 int skip=*(dp++); 32 32 dline+=skip; 33 33 x+=skip; 34 if (x< w)34 if (x<m_size.x) 35 35 { 36 36 int run=*(dp++); … … 51 51 int size=0,x,y; 52 52 uint8_t *sl,*datap,*marker; 53 w=im->Size().x; 54 h=im->Size().y; 53 m_size = im->Size(); 55 54 56 55 im->Lock(); … … 61 60 sl=im->scan_line(y); 62 61 x=0; 63 while (x< w)62 while (x<m_size.x) 64 63 { 65 64 size++; 66 while (x< w&& *sl==0) { sl++; x++; }67 68 if (x< w)65 while (x<m_size.x && *sl==0) { sl++; x++; } 66 67 if (x<m_size.x) 69 68 { 70 69 size++; // byte for the size of the run 71 while (x< w&& (*sl)!=0)70 while (x<m_size.x && (*sl)!=0) 72 71 { 73 72 size++; … … 79 78 } 80 79 81 data=(uint8_t *)malloc(size);80 m_data=(uint8_t *)malloc(size); 82 81 int ww=im->Size().x,hh=im->Size().y; 83 datap= data;82 datap=m_data; 84 83 if (!datap) 85 84 { printf("size = %d %d (%d)\n",im->Size().x,im->Size().y,size); } 86 CONDITION(datap,"malloc error for trans_image:: data");85 CONDITION(datap,"malloc error for trans_image::m_data"); 87 86 88 87 for (y=0; y<hh; y++) // now actually make the runs … … 116 115 } 117 116 117 trans_image::~trans_image() 118 { 119 free(m_data); 120 } 121 118 122 void trans_image::put_scan_line(image *screen, int x, int y, int line) // always transparent 119 123 { 120 124 int x1, y1, x2, y2; 121 125 screen->GetClip(x1, y1, x2, y2); 122 if (y + line < y1 || y + line >= y2 || x >= x2 || x + w- 1 < x1)126 if (y + line < y1 || y + line >= y2 || x >= x2 || x + m_size.x - 1 < x1) 123 127 return; // clipped off completely? 124 128 125 uint8_t *datap= data;129 uint8_t *datap=m_data; 126 130 int ix; 127 131 while (line) // skip scan line data until we get to the line of interest 128 132 { 129 for (ix=0; ix< w; )133 for (ix=0; ix<m_size.x; ) 130 134 { 131 135 ix+=*datap; // skip blank space 132 136 datap++; 133 if (ix< w)137 if (ix<m_size.x) 134 138 { 135 139 int run_length=*datap; // skip run … … 147 151 uint8_t *screen_line=screen->scan_line(y)+x; 148 152 149 for (ix=0; ix< w; )153 for (ix=0; ix<m_size.x; ) 150 154 { 151 155 int skip=*datap; // how much space to skip? … … 154 158 ix+=skip; 155 159 156 if (ix< w)160 if (ix<m_size.x) 157 161 { 158 162 int run_length=*datap; … … 204 208 { 205 209 // check to see if it is totally clipped out first 206 if (y + h <= y1 || y >= y2 || x >= x2 || x + w<= x1)210 if (y + m_size.y <= y1 || y >= y2 || x >= x2 || x + m_size.x <= x1) 207 211 return NULL; 208 212 209 uint8_t *parser = data;213 uint8_t *parser = m_data; 210 214 211 215 int skiplines = Max(y1 - y, 0); // number of lines to skip 212 ysteps = Min(y2 - y, height()- skiplines); // number of lines to draw216 ysteps = Min(y2 - y, m_size.y - skiplines); // number of lines to draw 213 217 y += skiplines; // first line to draw 214 218 215 219 while (skiplines--) 216 220 { 217 for (int ix = 0; ix < w; )221 for (int ix = 0; ix < m_size.x; ) 218 222 { 219 223 ix += *parser++; // skip over empty space 220 224 221 if (ix >= w)225 if (ix >= m_size.x) 222 226 break; 223 227 … … 227 231 } 228 232 229 screen->AddDirty(Max(x, x1), y, Min(x + width(), x2), y + h);233 screen->AddDirty(Max(x, x1), y, Min(x + m_size.x, x2), y + m_size.y); 230 234 return parser; 231 235 } … … 246 250 247 251 screen_line=screen->scan_line(y)+x; 248 int sw=screen->Size().x- w;252 int sw=screen->Size().x-m_size.x; 249 253 x1 -= x; x2 -= x; 250 254 for (; ysteps>0; ysteps--) 251 255 { 252 256 int ix,slam_length; 253 for (ix=0; ix< w; )257 for (ix=0; ix<m_size.x; ) 254 258 { 255 259 int blank=(*datap); … … 259 263 260 264 datap++; 261 if (ix< w)265 if (ix<m_size.x) 262 266 { 263 267 slam_length=*datap; // find the length of this run … … 310 314 void trans_image::put_image_offseted(image *screen, uint8_t *s_off) // if screen x & y offset already calculated save a mul 311 315 { 312 int ix,ysteps= height();316 int ix,ysteps=m_size.y; 313 317 int screen_skip; 314 uint8_t skip,*datap= data;318 uint8_t skip,*datap=m_data; 315 319 316 320 screen->Lock(); 317 screen_skip = screen->Size().x - w;321 screen_skip = screen->Size().x - m_size.x; 318 322 for (; ysteps; ysteps--) 319 323 { 320 for (ix=0; ix< w; )324 for (ix=0; ix<m_size.x; ) 321 325 { 322 326 skip=*datap; // skip leading blank space … … 329 333 330 334 331 if (ix< w)335 if (ix<m_size.x) 332 336 { 333 337 skip=*datap; … … 364 368 { 365 369 int ix,slam_length; 366 for (ix=0; ix< w; )370 for (ix=0; ix<m_size.x; ) 367 371 { 368 372 ix+=(*datap); // skip over empty space 369 373 datap++; 370 if (ix< w)374 if (ix<m_size.x) 371 375 { 372 376 slam_length=*datap; // find the length of this run … … 430 434 { 431 435 int ix,slam_length; 432 for (ix=0; ix< w; )436 for (ix=0; ix<m_size.x; ) 433 437 { 434 438 ix+=(*datap); // skip over empty space 435 439 datap++; 436 if (ix< w)440 if (ix<m_size.x) 437 441 { 438 442 slam_length=*datap; // find the length of this run … … 509 513 { 510 514 int ix,slam_length; 511 for (ix=0; ix< w; )515 for (ix=0; ix<m_size.x; ) 512 516 { 513 517 ix+=(*datap); // skip over empty space 514 518 datap++; 515 if (ix< w)519 if (ix<m_size.x) 516 520 { 517 521 slam_length=*datap; // find the length of this run … … 592 596 screen_line=screen->scan_line(y); 593 597 594 for (ix=0; ix< w; )598 for (ix=0; ix<m_size.x; ) 595 599 { 596 600 ix+=(*datap); // skip over empty space 597 601 datap++; 598 if (ix< w)602 if (ix<m_size.x) 599 603 { 600 604 slam_length=*datap; // find the length of this run … … 687 691 screen_line=screen->scan_line(y); 688 692 689 for (ix=0; ix< w; )693 for (ix=0; ix<m_size.x; ) 690 694 { 691 695 ix+=(*datap); // skip over empty space 692 696 datap++; 693 if (ix< w)697 if (ix<m_size.x) 694 698 { 695 699 slam_length=*datap; // find the length of this run … … 771 775 screen_line=screen->scan_line(y); 772 776 773 for (ix=0; ix< w; )777 for (ix=0; ix<m_size.x; ) 774 778 { 775 779 ix+=(*datap); // skip over empty space 776 780 datap++; 777 if (ix< w)781 if (ix<m_size.x) 778 782 { 779 783 slam_length=*datap; // find the length of this run … … 844 848 845 849 846 for (ix=0; ix< w; )850 for (ix=0; ix<m_size.x; ) 847 851 { 848 852 ix+=(*datap); // skip over empty space 849 853 datap++; 850 if (ix< w)854 if (ix<m_size.x) 851 855 { 852 856 slam_length=*datap; // find the length of this run … … 935 939 936 940 // see if the last scanline is clipped off 937 if (y + ysteps == y2 - 1) ysteps -= 2; 938 else if (y + ysteps == y2 - 2) ysteps--; 939 /* { 940 for (int x=0; x<w; ) 941 { 942 int skip=*datap; datap++; 943 x+=skip; 944 if (x<w) 945 { 946 int run_size=*datap; 947 datap+=run_size+1; 948 x+=run_size; 949 } 950 } 951 if (y==y2 - 1) 952 return; 953 else 954 y++; 955 }*/ 941 ysteps = Min(ysteps, y2 - 1 - y - 2); 956 942 957 943 screen->Lock(); … … 962 948 { 963 949 int ix,slam_length; 964 for (ix=0; ix< w; )950 for (ix=0; ix<m_size.x; ) 965 951 { 966 952 ix+=(*datap); // skip over empty space 967 953 datap++; 968 if (ix< w)954 if (ix<m_size.x) 969 955 { 970 956 slam_length=*datap; // find the length of this run … … 1011 997 } 1012 998 1013 int trans_image::size()1014 { 1015 uint8_t *d=data;1016 int t=0;1017 for (int y=0; y<h; y++) 1018 {1019 int x=0;1020 while (x<w)1021 {1022 x+=*d; d++; t++;1023 if (x<w) 1024 {1025 int s=*d; d++; t+=s+1;1026 d+=s; 1027 x+=s;1028 }1029 } 1030 }1031 return t+4+4; 1032 } 999 size_t trans_image::MemUsage() 1000 { 1001 uint8_t *d = m_data; 1002 size_t t = 0; 1003 1004 for (int y = 0; y < m_size.y; y++) 1005 { 1006 for (int x = 0; x < m_size.x; x++) 1007 { 1008 x += *d; d++; t++; 1009 1010 if (x >= m_size.x) 1011 break; 1012 1013 int s = *d; d++; t += s + 1; d += s; x += s; 1014 } 1015 } 1016 return t + 4 + 4; 1017 } 1018 -
abuse/trunk/src/imlib/timage.h
r524 r527 25 25 class trans_image // transpernet image 26 26 { 27 unsigned char *data; 28 short w,h;27 public: 28 trans_image(image *im, char const *name); // name has no meaning if MEM_CHECK is off 29 29 30 public : 31 short height() { return h; } 32 short width() { return w; } 33 trans_image(image *im, char const *name); // name has no meaning if MEM_CHECK is off 30 inline vec2i Size() { return m_size; } 31 uint8_t *Data() { return m_data; } 32 34 33 void put_image(image *screen, int x, int y); // always transparent 35 34 … … 54 53 void put_predator(image *screen, int x, int y); 55 54 void put_scan_line(image *screen, int x, int y, int line); // always transparent 56 unsigned char *t_data() { return data; } 57 int size(); 55 size_t MemUsage(); 58 56 image *make_image(); 59 ~trans_image() { free(data); }57 ~trans_image(); 60 58 61 59 private: 62 60 uint8_t *ClipToLine(image *screen, int x1, int y1, int x2, int y2, 63 61 int x, int &y, int &ysteps); 64 } ;65 62 63 vec2i m_size; 64 uint8_t *m_data; 65 }; 66 66 67 67 #endif 68 68 69 70 71 72 -
abuse/trunk/src/items.cpp
r526 r527 273 273 } 274 274 275 int figure::size() 276 { 277 return forward->size()+backward->size()+ 278 hit->size()+ 279 f_damage->size()+ 280 b_damage->size()+sizeof(figure); 275 size_t figure::MemUsage() 276 { 277 return forward->MemUsage() + backward->MemUsage() + hit->size() 278 + f_damage->size() + b_damage->size() + sizeof(figure); 281 279 } 282 280 -
abuse/trunk/src/items.h
r512 r527 54 54 55 55 foretile(bFILE *fp); 56 int32_t size() { return im-> width()*im->height()+4+2+1+points->size(); }56 int32_t size() { return im->Size().x*im->Size().y+4+2+1+points->size(); } 57 57 ~foretile() { delete im; delete points; delete micro_image; } 58 58 } ; … … 66 66 point_list *hit; 67 67 boundary *f_damage,*b_damage; 68 int size();68 size_t MemUsage(); 69 69 70 70 figure(bFILE *fp, int type); 71 int width() { return forward-> width(); }72 int height() { return forward-> height(); }71 int width() { return forward->Size().x; } 72 int height() { return forward->Size().y; } 73 73 74 /* int32_t size(int type) // taken from spaint items 75 { 76 if 77 return forward->width()*backward->height()+4+ 78 1+1+ // hit & xcfg 79 touch->size()+ 80 hit->size()+ 81 damage->size(); 82 }*/ 83 84 ~figure() { delete forward; delete backward; 85 delete hit; 86 delete f_damage; delete b_damage; } 74 ~figure() { delete forward; delete backward; delete hit; 75 delete f_damage; delete b_damage; } 87 76 } ; 88 77 -
abuse/trunk/src/level.cpp
r524 r527 3007 3007 if (o!=exclude && o->hurtable()) 3008 3008 { 3009 int32_t y1=o->y,y2=o->y-o->picture()-> height();3009 int32_t y1=o->y,y2=o->y-o->picture()->Size().y; 3010 3010 int32_t cx=abs(o->x-x),cy1=abs(y1-y),d1,d2,cy2=abs(y2-y); 3011 3011 if (cx<cy1) -
abuse/trunk/src/loader2.cpp
r523 r527 455 455 ERROR(big_font_pict!=-1 || small_font_pict!=-1, 456 456 "No font loaded (use load_big_font or load_small_font)!"); 457 f_wid=cache.foret(foretiles[0])->im-> width();458 f_hi=cache.foret(foretiles[0])->im-> height();457 f_wid=cache.foret(foretiles[0])->im->Size().x; 458 f_hi=cache.foret(foretiles[0])->im->Size().y; 459 459 b_wid=cache.backt(backtiles[0])->im->Size().x; 460 460 b_hi=cache.backt(backtiles[0])->im->Size().y; -
abuse/trunk/src/objects.cpp
r519 r527 587 587 void game_object::picture_space(int32_t &x1, int32_t &y1,int32_t &x2, int32_t &y2) 588 588 { 589 int xc=x_center(),w=picture()-> width(),h=picture()->height();589 int xc=x_center(),w=picture()->Size().x,h=picture()->Size().y; 590 590 if (direction>0) 591 591 x1=x-xc; … … 682 682 trans_image *cpict=picture(); 683 683 cpict->put_fade(screen, 684 (direction<0 ? x-(cpict-> width()-x_center()-1) : x-x_center())-current_vxadd,685 y-cpict-> height()+1-current_vyadd,684 (direction<0 ? x-(cpict->Size().x-x_center()-1) : x-x_center())-current_vxadd, 685 y-cpict->Size().y+1-current_vyadd, 686 686 count,max, 687 687 color_table,the_game->current_palette()); … … 694 694 if (fade_count()) 695 695 cpict->put_fade_tint(screen, 696 (direction<0 ? x-(cpict-> width()-x_center()-1) : x-x_center())-current_vxadd,697 y-cpict-> height()+1-current_vyadd,696 (direction<0 ? x-(cpict->Size().x-x_center()-1) : x-x_center())-current_vxadd, 697 y-cpict->Size().y+1-current_vyadd, 698 698 fade_count(),fade_max(), 699 699 cache.ctint(tint_id)->data, … … 703 703 else 704 704 cpict->put_remaped(screen, 705 (direction<0 ? x-(cpict-> width()-x_center()-1) : x-x_center())-current_vxadd,706 y-cpict-> height()+1-current_vyadd,705 (direction<0 ? x-(cpict->Size().x-x_center()-1) : x-x_center())-current_vxadd, 706 y-cpict->Size().y+1-current_vyadd, 707 707 cache.ctint(tint_id)->data); 708 708 } … … 714 714 if (fade_count()) 715 715 cpict->put_fade_tint(screen, 716 (direction<0 ? x-(cpict-> width()-x_center()-1) : x-x_center())-current_vxadd,717 y-cpict-> height()+1-current_vyadd,716 (direction<0 ? x-(cpict->Size().x-x_center()-1) : x-x_center())-current_vxadd, 717 y-cpict->Size().y+1-current_vyadd, 718 718 fade_count(),fade_max(), 719 719 cache.ctint(tint_id)->data, … … 723 723 else 724 724 cpict->put_double_remaped(screen, 725 (direction<0 ? x-(cpict-> width()-x_center()-1) : x-x_center())-current_vxadd,726 y-cpict-> height()+1-current_vyadd,725 (direction<0 ? x-(cpict->Size().x-x_center()-1) : x-x_center())-current_vxadd, 726 y-cpict->Size().y+1-current_vyadd, 727 727 cache.ctint(tint_id)->data, 728 728 cache.ctint(tint2)->data); … … 735 735 trans_image *cpict=picture(); 736 736 cpict->put_predator(screen, 737 (direction<0 ? x-(cpict-> width()-x_center()-1) : x-x_center())-current_vxadd,738 y-cpict-> height()+1-current_vyadd);737 (direction<0 ? x-(cpict->Size().x-x_center()-1) : x-x_center())-current_vxadd, 738 y-cpict->Size().y+1-current_vyadd); 739 739 740 740 } … … 758 758 trans_image *cpict=picture(); 759 759 cpict->put_image(screen, 760 (direction<0 ? x-(cpict-> width()-x_center()-1) : x-x_center())-current_vxadd,761 y-cpict-> height()+1-current_vyadd);760 (direction<0 ? x-(cpict->Size().x-x_center()-1) : x-x_center())-current_vxadd, 761 y-cpict->Size().y+1-current_vyadd); 762 762 } 763 763 } … … 787 787 if (checks&2) 788 788 { 789 h=picture()-> height();789 h=picture()->Size().y; 790 790 x2=x+xv; 791 791 y2=y-h+1+yv; -
abuse/trunk/src/objects.h
r494 r527 127 127 void picture_space(int32_t &x1, int32_t &y1,int32_t &x2, int32_t &y2); 128 128 int tx(int x) { if (direction>0) return x-x_center(); else return x_center()-x; } 129 int ty(int y) { return y-picture()-> height()+1; }129 int ty(int y) { return y-picture()->Size().y+1; } 130 130 void defaults(); 131 131 -
abuse/trunk/src/seq.cpp
r524 r527 16 16 #include "lisp.h" 17 17 18 int sequence::size()18 size_t sequence::MemUsage() 19 19 { 20 int t=0; 21 for (int i=0; i<total; i++) 22 { 23 if (cache.loaded(seq[i])) 24 t+=cache.fig(seq[i])->size(); 25 } 26 return t; 20 size_t t = 0; 21 for (int i = 0; i < total; i++) 22 if (cache.loaded(seq[i])) 23 t += cache.fig(seq[i])->MemUsage(); 24 return t; 27 25 } 28 26 -
abuse/trunk/src/seq.h
r494 r527 38 38 int length() { return total; } 39 39 int get_advance(int current) { return cache.fig(seq[current])->advance; } 40 int size();40 size_t MemUsage(); 41 41 ~sequence(); 42 42 };
Note: See TracChangeset
for help on using the changeset viewer.