Last change
on this file since 475 was
49,
checked in by Sam Hocevar, 15 years ago
|
- Imported original public domain release, for future reference.
|
File size:
1.2 KB
|
Rev | Line | |
---|
[49] | 1 | class tile |
---|
| 2 | { |
---|
| 3 | uchar *im_data; |
---|
| 4 | uchar *run_data; |
---|
| 5 | boundary *points; |
---|
| 6 | ushort next; |
---|
| 7 | public : |
---|
| 8 | tile(bFILE *fp, int type); |
---|
| 9 | } ; |
---|
| 10 | |
---|
| 11 | |
---|
| 12 | tile::tile(bFILE *fp, int type, int w, int h) |
---|
| 13 | { |
---|
| 14 | int cw=fp->read_short(),ch=fp->read_short(); |
---|
| 15 | if (cw!=w || ch!=h) |
---|
| 16 | { |
---|
| 17 | lbreak("load_tiles : expecting tile size to be %dx%d, got %dx%d\n",w,h,cw,ch); |
---|
| 18 | exit(0); |
---|
| 19 | } |
---|
| 20 | |
---|
| 21 | im_data=(uchar *)jmalloc(w*h,"tile image"); |
---|
| 22 | fp->read(im_data,w*h); |
---|
| 23 | |
---|
| 24 | if (type==SPEC_FORETILE) |
---|
| 25 | { |
---|
| 26 | next=fp->read_short(); // next |
---|
| 27 | fp->read_byte(); // skip damage, not implemented |
---|
| 28 | points=new boundary(fp,"tile boundary"); |
---|
| 29 | uchar *c=im_data; |
---|
| 30 | int need_runs=0; |
---|
| 31 | |
---|
| 32 | if (need_runs) |
---|
| 33 | run_data=make_runs(im_data,w,h); |
---|
| 34 | } else run_data=NULL; |
---|
| 35 | } else { points=NULL; run_data=NULL; } |
---|
| 36 | } |
---|
| 37 | |
---|
| 38 | class tile_set |
---|
| 39 | { |
---|
| 40 | public : |
---|
| 41 | int w,h,t; |
---|
| 42 | int *id; |
---|
| 43 | tile_set *next; |
---|
| 44 | tile_set(int width, int height); |
---|
| 45 | void add(int tile_id, int tile_number); |
---|
| 46 | } ; |
---|
| 47 | |
---|
| 48 | |
---|
| 49 | tile_set::tile_set(int width, int height, tile_set *Next) |
---|
| 50 | { |
---|
| 51 | w=width; |
---|
| 52 | h=height; |
---|
| 53 | t=0; |
---|
| 54 | next=Next; |
---|
| 55 | id=NULL; |
---|
| 56 | } |
---|
| 57 | |
---|
| 58 | |
---|
| 59 | void tile_set::add(int tile_id, int tile_number) |
---|
| 60 | { |
---|
| 61 | if (tile_number>=t) |
---|
| 62 | { |
---|
| 63 | id=(int *)jrealloc(id,sizeof(int)*tile_number,"tile set list"); |
---|
| 64 | t=tile_number; |
---|
| 65 | } |
---|
| 66 | id[tile_number]=tile_id; |
---|
| 67 | } |
---|
| 68 | |
---|
| 69 | |
---|
| 70 | |
---|
Note: See
TracBrowser
for help on using the repository browser.