Lines 23-42
Link Here
|
23 |
#include <sys/stat.h> |
23 |
#include <sys/stat.h> |
24 |
#endif |
24 |
#endif |
25 |
|
25 |
|
|
|
26 |
#include <limits.h> |
26 |
#include <time.h> |
27 |
#include <time.h> |
27 |
|
28 |
|
28 |
level *current_level; |
29 |
level *current_level; |
29 |
|
30 |
|
30 |
game_object *level::attacker(game_object *who) |
31 |
game_object *level::attacker(game_object *who) |
31 |
{ |
32 |
{ |
32 |
long d=0x7fffffff; |
33 |
int32_t d=0x7fffffff; |
33 |
game_object *c=NULL; |
34 |
game_object *c=NULL; |
34 |
view *f=the_game->first_view; |
35 |
view *f=the_game->first_view; |
35 |
for (;f;f=f->next) |
36 |
for (;f;f=f->next) |
36 |
{ |
37 |
{ |
37 |
if (f->focus) |
38 |
if (f->focus) |
38 |
{ |
39 |
{ |
39 |
long tmp_d=abs(f->focus->x-who->x)+abs(f->focus->y-who->y); |
40 |
int32_t tmp_d=abs(f->focus->x-who->x)+abs(f->focus->y-who->y); |
40 |
if (tmp_d<d) |
41 |
if (tmp_d<d) |
41 |
{ |
42 |
{ |
42 |
d=tmp_d; |
43 |
d=tmp_d; |
Lines 197-203
Link Here
|
197 |
} |
198 |
} |
198 |
} |
199 |
} |
199 |
|
200 |
|
200 |
int level::add_actives(long x1, long y1, long x2, long y2) |
201 |
int level::add_actives(int32_t x1, int32_t y1, int32_t x2, int32_t y2) |
201 |
{ |
202 |
{ |
202 |
int t=0; |
203 |
int t=0; |
203 |
game_object *last_active=NULL; |
204 |
game_object *last_active=NULL; |
Lines 209-215
Link Here
|
209 |
{ |
210 |
{ |
210 |
if (!o->active) |
211 |
if (!o->active) |
211 |
{ |
212 |
{ |
212 |
long xr=figures[o->otype]->rangex, |
213 |
int32_t xr=figures[o->otype]->rangex, |
213 |
yr=figures[o->otype]->rangey; |
214 |
yr=figures[o->otype]->rangey; |
214 |
|
215 |
|
215 |
if (o->x+xr>=x1 && o->x-xr<=x2 && o->y+yr>=y1 && o->y-yr<=y2) |
216 |
if (o->x+xr>=x1 && o->x-xr<=x2 && o->y+yr>=y1 && o->y-yr<=y2) |
Lines 241-247
Link Here
|
241 |
} |
242 |
} |
242 |
|
243 |
|
243 |
|
244 |
|
244 |
int level::add_drawables(long x1, long y1, long x2, long y2) |
245 |
int level::add_drawables(int32_t x1, int32_t y1, int32_t x2, int32_t y2) |
245 |
{ |
246 |
{ |
246 |
int t=0,ft=0; |
247 |
int t=0,ft=0; |
247 |
game_object *last_active=NULL; |
248 |
game_object *last_active=NULL; |
Lines 255-261
Link Here
|
255 |
{ |
256 |
{ |
256 |
if (ft || !o->active) |
257 |
if (ft || !o->active) |
257 |
{ |
258 |
{ |
258 |
long xr=figures[o->otype]->draw_rangex, |
259 |
int32_t xr=figures[o->otype]->draw_rangex, |
259 |
yr=figures[o->otype]->draw_rangey; |
260 |
yr=figures[o->otype]->draw_rangey; |
260 |
|
261 |
|
261 |
if (o->x+xr>=x1 && o->x-xr<=x2 && o->y+yr>=y1 && o->y-yr<=y2) |
262 |
if (o->x+xr>=x1 && o->x-xr<=x2 && o->y+yr>=y1 && o->y-yr<=y2) |
Lines 321-327
Link Here
|
321 |
|
322 |
|
322 |
void level::wall_push() |
323 |
void level::wall_push() |
323 |
{ |
324 |
{ |
324 |
long sx1,sy1,sx2,sy2,xv,yv; |
325 |
int32_t sx1,sy1,sx2,sy2,xv,yv; |
325 |
game_object *o=first_active; |
326 |
game_object *o=first_active; |
326 |
for (;o;o=o->next_active) |
327 |
for (;o;o=o->next_active) |
327 |
{ |
328 |
{ |
Lines 361-367
Link Here
|
361 |
int b1=subject->push_range(),b2=target->push_range(); |
362 |
int b1=subject->push_range(),b2=target->push_range(); |
362 |
if (abs(subject->x-target->x)<b1+b2) |
363 |
if (abs(subject->x-target->x)<b1+b2) |
363 |
{ |
364 |
{ |
364 |
long tmove=b1+b2-abs(subject->x-target->x),xv,yv=0,xv2; |
365 |
int32_t tmove=b1+b2-abs(subject->x-target->x),xv,yv=0,xv2; |
365 |
if (subject->x>target->x) |
366 |
if (subject->x>target->x) |
366 |
xv=tmove/2; |
367 |
xv=tmove/2; |
367 |
else xv=-tmove/2; |
368 |
else xv=-tmove/2; |
Lines 381-387
Link Here
|
381 |
void level::check_collisions() |
382 |
void level::check_collisions() |
382 |
{ |
383 |
{ |
383 |
game_object *target,*reciever=NULL; |
384 |
game_object *target,*reciever=NULL; |
384 |
long sx1,sy1,sx2,sy2,tx1,ty1,tx2,ty2,hitx,hity, |
385 |
int32_t sx1,sy1,sx2,sy2,tx1,ty1,tx2,ty2,hitx,hity, |
385 |
s_centerx,t_centerx; |
386 |
s_centerx,t_centerx; |
386 |
|
387 |
|
387 |
for (game_object *subject=first_active;subject;subject=subject->next_active) |
388 |
for (game_object *subject=first_active;subject;subject=subject->next_active) |
Lines 415-421
Link Here
|
415 |
{ |
416 |
{ |
416 |
for (t_dat=t_damage->data,j=(int)t_damage->tot-1;j>0 && !hit;j--) |
417 |
for (t_dat=t_damage->data,j=(int)t_damage->tot-1;j>0 && !hit;j--) |
417 |
{ |
418 |
{ |
418 |
long x1,y1,x2,y2, // define the two line segments to check |
419 |
int32_t x1,y1,x2,y2, // define the two line segments to check |
419 |
xp1,yp1,xp2,yp2; |
420 |
xp1,yp1,xp2,yp2; |
420 |
|
421 |
|
421 |
xp1=target->x+target->tx(*t_dat); t_dat++; |
422 |
xp1=target->x+target->tx(*t_dat); t_dat++; |
Lines 458-467
Link Here
|
458 |
} |
459 |
} |
459 |
*/ |
460 |
*/ |
460 |
|
461 |
|
461 |
game_object *level::boundary_setback(game_object *subject, long x1, long y1, long &x2, long &y2) |
462 |
game_object *level::boundary_setback(game_object *subject, int32_t x1, int32_t y1, int32_t &x2, int32_t &y2) |
462 |
{ |
463 |
{ |
463 |
game_object *l=NULL; |
464 |
game_object *l=NULL; |
464 |
long tx1,ty1,tx2,ty2,t_centerx; |
465 |
int32_t tx1,ty1,tx2,ty2,t_centerx; |
465 |
game_object *target=first_active; |
466 |
game_object *target=first_active; |
466 |
game_object **blist=block_list; |
467 |
game_object **blist=block_list; |
467 |
int t=block_total; |
468 |
int t=block_total; |
Lines 484-493
Link Here
|
484 |
int iter=t_damage->tot-1; |
485 |
int iter=t_damage->tot-1; |
485 |
while(iter-->0) |
486 |
while(iter-->0) |
486 |
{ |
487 |
{ |
487 |
long xp1=target->x+target->tx(*t_dat); t_dat++; |
488 |
int32_t xp1=target->x+target->tx(*t_dat); t_dat++; |
488 |
long yp1=target->y+target->ty(*t_dat); t_dat++; |
489 |
int32_t yp1=target->y+target->ty(*t_dat); t_dat++; |
489 |
long xp2=target->x+target->tx(*t_dat); |
490 |
int32_t xp2=target->x+target->tx(*t_dat); |
490 |
long yp2=target->y+target->ty(t_dat[1]); |
491 |
int32_t yp2=target->y+target->ty(t_dat[1]); |
491 |
|
492 |
|
492 |
// now check to see if (x1,y1-x2,y2) intercest with (xp1,yp1-xp2,yp2) |
493 |
// now check to see if (x1,y1-x2,y2) intercest with (xp1,yp1-xp2,yp2) |
493 |
if (*ins) |
494 |
if (*ins) |
Lines 510-519
Link Here
|
510 |
} |
511 |
} |
511 |
|
512 |
|
512 |
|
513 |
|
513 |
game_object *level::all_boundary_setback(game_object *subject, long x1, long y1, long &x2, long &y2) |
514 |
game_object *level::all_boundary_setback(game_object *subject, int32_t x1, int32_t y1, int32_t &x2, int32_t &y2) |
514 |
{ |
515 |
{ |
515 |
game_object *l=NULL; |
516 |
game_object *l=NULL; |
516 |
long tx1,ty1,tx2,ty2,t_centerx; |
517 |
int32_t tx1,ty1,tx2,ty2,t_centerx; |
517 |
game_object *target=first_active; |
518 |
game_object *target=first_active; |
518 |
game_object **blist=all_block_list; |
519 |
game_object **blist=all_block_list; |
519 |
int t=all_block_total; |
520 |
int t=all_block_total; |
Lines 536-545
Link Here
|
536 |
int iter=t_damage->tot-1; |
537 |
int iter=t_damage->tot-1; |
537 |
while(iter-->0) |
538 |
while(iter-->0) |
538 |
{ |
539 |
{ |
539 |
long xp1=target->x+target->tx(*t_dat); t_dat++; |
540 |
int32_t xp1=target->x+target->tx(*t_dat); t_dat++; |
540 |
long yp1=target->y+target->ty(*t_dat); t_dat++; |
541 |
int32_t yp1=target->y+target->ty(*t_dat); t_dat++; |
541 |
long xp2=target->x+target->tx(*t_dat); |
542 |
int32_t xp2=target->x+target->tx(*t_dat); |
542 |
long yp2=target->y+target->ty(t_dat[1]); |
543 |
int32_t yp2=target->y+target->ty(t_dat[1]); |
543 |
|
544 |
|
544 |
// now check to see if (x1,y1-x2,y2) intercest with (xp1,yp1-xp2,yp2) |
545 |
// now check to see if (x1,y1-x2,y2) intercest with (xp1,yp1-xp2,yp2) |
545 |
if (*ins) |
546 |
if (*ins) |
Lines 565-571
Link Here
|
565 |
|
566 |
|
566 |
void level::interpolate_draw_objects(view *v) |
567 |
void level::interpolate_draw_objects(view *v) |
567 |
{ |
568 |
{ |
568 |
long old_x,old_y; |
569 |
int32_t old_x,old_y; |
569 |
current_view=v; |
570 |
current_view=v; |
570 |
|
571 |
|
571 |
game_object *o=first_active; |
572 |
game_object *o=first_active; |
Lines 606-612
Link Here
|
606 |
if (current_demo_mode()==DEMO_PLAY) |
607 |
if (current_demo_mode()==DEMO_PLAY) |
607 |
{ |
608 |
{ |
608 |
if (!rcheck) rcheck=open_file("rcheck","rb"); |
609 |
if (!rcheck) rcheck=open_file("rcheck","rb"); |
609 |
long x=rcheck->read_long(); |
610 |
int32_t x=rcheck->read_uint32(); |
610 |
if (x!=rand_on) |
611 |
if (x!=rand_on) |
611 |
dprintf("off!\n"); |
612 |
dprintf("off!\n"); |
612 |
} else if (current_demo_mode()==DEMO_RECORD) |
613 |
} else if (current_demo_mode()==DEMO_RECORD) |
Lines 616-622
Link Here
|
616 |
rcheck=open_file("rcheck","wb"); |
617 |
rcheck=open_file("rcheck","wb"); |
617 |
rcheck_lp=open_file("rcheck.lp","wb"); |
618 |
rcheck_lp=open_file("rcheck.lp","wb"); |
618 |
} |
619 |
} |
619 |
rcheck->write_long(rand_on); |
620 |
rcheck->write_uint32(rand_on); |
620 |
} else |
621 |
} else |
621 |
{ |
622 |
{ |
622 |
if (rcheck) |
623 |
if (rcheck) |
Lines 644-654
Link Here
|
644 |
if (c) |
645 |
if (c) |
645 |
{ |
646 |
{ |
646 |
area_controller *a,*smallest=NULL; |
647 |
area_controller *a,*smallest=NULL; |
647 |
long smallest_size=0xfffffff; |
648 |
int32_t smallest_size=0xffffffff; |
648 |
for (a=area_list;a;a=a->next) |
649 |
for (a=area_list;a;a=a->next) |
649 |
if (o->x>=a->x && o->y>=a->y && o->x<=a->x+a->w && o->y<=a->y+a->h) |
650 |
if (o->x>=a->x && o->y>=a->y && o->x<=a->x+a->w && o->y<=a->y+a->h) |
650 |
{ |
651 |
{ |
651 |
long size=a->w*a->h; |
652 |
int32_t size=a->w*a->h; |
652 |
if (size<smallest_size) |
653 |
if (size<smallest_size) |
653 |
{ |
654 |
{ |
654 |
smallest=a; |
655 |
smallest=a; |
Lines 692-698
Link Here
|
692 |
|
693 |
|
693 |
if (o->otype!=current_start_type) |
694 |
if (o->otype!=current_start_type) |
694 |
{ |
695 |
{ |
695 |
long fmp=o->fmp(); |
696 |
int32_t fmp=o->fmp(); |
696 |
int reduce=figures[o->otype]->morph_power; |
697 |
int reduce=figures[o->otype]->morph_power; |
697 |
if (reduce) |
698 |
if (reduce) |
698 |
{ |
699 |
{ |
Lines 759-772
Link Here
|
759 |
return ret; |
760 |
return ret; |
760 |
} |
761 |
} |
761 |
|
762 |
|
762 |
void level::set_tick_counter(ulong x) |
763 |
void level::set_tick_counter(uint32_t x) |
763 |
{ |
764 |
{ |
764 |
ctick=x; |
765 |
ctick=x; |
765 |
} |
766 |
} |
766 |
|
767 |
|
767 |
void level::draw_areas(view *v) |
768 |
void level::draw_areas(view *v) |
768 |
{ |
769 |
{ |
769 |
long sx1,sy1,sx2,sy2; |
770 |
int32_t sx1,sy1,sx2,sy2; |
770 |
area_controller *a=area_list; |
771 |
area_controller *a=area_list; |
771 |
for (;a;a=a->next) |
772 |
for (;a;a=a->next) |
772 |
{ |
773 |
{ |
Lines 806-812
Link Here
|
806 |
clear_tmp(); |
807 |
clear_tmp(); |
807 |
} |
808 |
} |
808 |
|
809 |
|
809 |
void calc_bgsize(unsigned short fgw, unsigned short fgh, unsigned short &bgw, unsigned short &bgh) |
810 |
void calc_bgsize(uint16_t fgw, uint16_t fgh, uint16_t &bgw, uint16_t &bgh) |
810 |
{ |
811 |
{ |
811 |
bgw=fgw/ASPECT+8; |
812 |
bgw=fgw/ASPECT+8; |
812 |
bgh=fgh/ASPECT+8; |
813 |
bgh=fgh/ASPECT+8; |
Lines 821-837
Link Here
|
821 |
return ; |
822 |
return ; |
822 |
} |
823 |
} |
823 |
|
824 |
|
824 |
unsigned short *new_fg,*new_bg; |
825 |
uint16_t *new_fg,*new_bg; |
825 |
new_fg=(unsigned short *)jmalloc(w*h*sizeof(short),"Map fg : resized"); |
826 |
new_fg=(uint16_t *)jmalloc(w*h*sizeof(int16_t),"Map fg : resized"); |
826 |
memset(new_fg,0,w*h*sizeof(short)); |
827 |
memset(new_fg,0,w*h*sizeof(int16_t)); |
827 |
|
828 |
|
828 |
int x,y,miny=(h<fg_height)? h : fg_height,minx=(w<fg_width)? w : fg_width; |
829 |
int x,y,miny=(h<fg_height)? h : fg_height,minx=(w<fg_width)? w : fg_width; |
829 |
|
830 |
|
830 |
unsigned short nbw,nbh; |
831 |
uint16_t nbw,nbh; |
831 |
calc_bgsize(w,h,nbw,nbh); |
832 |
calc_bgsize(w,h,nbw,nbh); |
832 |
|
833 |
|
833 |
new_bg=(unsigned short *)jmalloc((int)nbw*(int)nbh*sizeof(short),"map bg : resized"); |
834 |
new_bg=(uint16_t *)jmalloc((int)nbw*(int)nbh*sizeof(int16_t),"map bg : resized"); |
834 |
memset(new_bg,0,(int)nbw*(int)nbh*sizeof(short)); |
835 |
memset(new_bg,0,(int)nbw*(int)nbh*sizeof(int16_t)); |
835 |
|
836 |
|
836 |
for (y=0;y<miny;y++) |
837 |
for (y=0;y<miny;y++) |
837 |
for (x=0;x<minx;x++) |
838 |
for (x=0;x<minx;x++) |
Lines 865-871
Link Here
|
865 |
if (se) |
866 |
if (se) |
866 |
{ |
867 |
{ |
867 |
fp->seek(se->offset,0); |
868 |
fp->seek(se->offset,0); |
868 |
if (RC_type_size(fp->read_byte())!=size) |
869 |
if (RC_type_size(fp->read_uint8())!=size) |
869 |
return 0; |
870 |
return 0; |
870 |
else return 1; |
871 |
else return 1; |
871 |
} |
872 |
} |
Lines 884-895
Link Here
|
884 |
{ |
885 |
{ |
885 |
fp->seek(se->offset,0); |
886 |
fp->seek(se->offset,0); |
886 |
/******************************* Read debug info ******************************/ |
887 |
/******************************* Read debug info ******************************/ |
887 |
short old_tot=fp->read_short(); |
888 |
int16_t old_tot=fp->read_uint16(); |
888 |
unsigned short *o_remap=(unsigned short *)jmalloc(old_tot*2,"obj remap array"); |
889 |
uint16_t *o_remap=(uint16_t *)jmalloc(old_tot*2,"obj remap array"); |
889 |
char old_name[150]; |
890 |
char old_name[150]; |
890 |
for (i=0;i<old_tot;i++) |
891 |
for (i=0;i<old_tot;i++) |
891 |
{ |
892 |
{ |
892 |
fp->read(old_name,fp->read_byte()); // read the name |
893 |
fp->read(old_name,fp->read_uint8()); // read the name |
893 |
for (o_remap[i]=0xffff,j=0;j<total_objects;j++) // check for matching current name |
894 |
for (o_remap[i]=0xffff,j=0;j<total_objects;j++) // check for matching current name |
894 |
{ |
895 |
{ |
895 |
if (!strcmp(old_name,object_names[j])) |
896 |
if (!strcmp(old_name,object_names[j])) |
Lines 899-926
Link Here
|
899 |
|
900 |
|
900 |
|
901 |
|
901 |
/***************************** Read state names *********************************/ |
902 |
/***************************** Read state names *********************************/ |
902 |
int old_stot=fp->read_short(); |
903 |
int old_stot=fp->read_uint16(); |
903 |
unsigned char *s_remap=(unsigned char *)jmalloc(old_stot,"state remap array"); |
904 |
unsigned char *s_remap=(unsigned char *)jmalloc(old_stot,"state remap array"); |
904 |
for (i=0;i<old_stot;i++) |
905 |
for (i=0;i<old_stot;i++) |
905 |
{ |
906 |
{ |
906 |
fp->read(old_name,fp->read_byte()); |
907 |
fp->read(old_name,fp->read_uint8()); |
907 |
s_remap[i]=stopped; // non exsitant states get mapped into stopped state |
908 |
s_remap[i]=stopped; // non exsitant states get mapped into stopped state |
908 |
for (j=0;j<MAX_STATE;j++) // see if old state exist now |
909 |
for (j=0;j<MAX_STATE;j++) // see if old state exist now |
909 |
if (!strcmp(state_names[j],old_name)) |
910 |
if (!strcmp(state_names[j],old_name)) |
910 |
s_remap[i]=j; |
911 |
s_remap[i]=j; |
911 |
} |
912 |
} |
912 |
total_objs=fp->read_long(); |
913 |
total_objs=fp->read_uint32(); |
913 |
|
914 |
|
914 |
se=sd->find("type"); |
915 |
se=sd->find("type"); |
915 |
if (se) |
916 |
if (se) |
916 |
{ |
917 |
{ |
917 |
fp->seek(se->offset,0); |
918 |
fp->seek(se->offset,0); |
918 |
last=NULL; |
919 |
last=NULL; |
919 |
if (fp->read_byte()==RC_S) // read type array, this should be type RC_S |
920 |
if (fp->read_uint8()==RC_16) // read type array, this should be type RC_16 |
920 |
{ |
921 |
{ |
921 |
for (i=0;i<total_objs;i++) |
922 |
for (i=0;i<total_objs;i++) |
922 |
{ |
923 |
{ |
923 |
ushort t=fp->read_short(); |
924 |
uint16_t t=fp->read_uint16(); |
924 |
game_object *p=new game_object(o_remap[t],1); |
925 |
game_object *p=new game_object(o_remap[t],1); |
925 |
clear_tmp(); |
926 |
clear_tmp(); |
926 |
if (!first) first=p; else last->next=p; |
927 |
if (!first) first=p; else last->next=p; |
Lines 932-943
Link Here
|
932 |
if (se) |
933 |
if (se) |
933 |
{ |
934 |
{ |
934 |
fp->seek(se->offset,0); |
935 |
fp->seek(se->offset,0); |
935 |
if (fp->read_byte()==RC_S) // read state array, this should be type RC_S |
936 |
if (fp->read_uint8()==RC_16) // read state array, this should be type RC_16 |
936 |
{ |
937 |
{ |
937 |
game_object *l=first; |
938 |
game_object *l=first; |
938 |
for (i=0;i<total_objs;i++,l=l->next) |
939 |
for (i=0;i<total_objs;i++,l=l->next) |
939 |
{ |
940 |
{ |
940 |
character_state s=(character_state)s_remap[fp->read_short()]; |
941 |
character_state s=(character_state)s_remap[fp->read_uint16()]; |
941 |
if (l->otype!=0xffff) |
942 |
if (l->otype!=0xffff) |
942 |
{ |
943 |
{ |
943 |
if (l->has_sequence((character_state)s)) |
944 |
if (l->has_sequence((character_state)s)) |
Lines 963-969
Link Here
|
963 |
{ |
964 |
{ |
964 |
fp->seek(se->offset,0); |
965 |
fp->seek(se->offset,0); |
965 |
int t=object_descriptions[j].type; |
966 |
int t=object_descriptions[j].type; |
966 |
if (fp->read_byte()!=t) |
967 |
if (fp->read_uint8()!=t) |
967 |
dprintf("Warning : load level -> var '%s' size changed\n"); |
968 |
dprintf("Warning : load level -> var '%s' size changed\n"); |
968 |
else |
969 |
else |
969 |
{ |
970 |
{ |
Lines 972-980
Link Here
|
972 |
{ |
973 |
{ |
973 |
switch (t) |
974 |
switch (t) |
974 |
{ |
975 |
{ |
975 |
case RC_C : f->set_var(j,fp->read_byte()); break; |
976 |
case RC_8 : f->set_var(j,fp->read_uint8()); break; |
976 |
case RC_S : f->set_var(j,fp->read_short()); break; |
977 |
case RC_16 : f->set_var(j,fp->read_uint16()); break; |
977 |
case RC_L : f->set_var(j,fp->read_long()); break; |
978 |
case RC_32 : f->set_var(j,fp->read_uint32()); break; |
978 |
} |
979 |
} |
979 |
|
980 |
|
980 |
// check to make sure the frame number is not out of bounds from the time |
981 |
// check to make sure the frame number is not out of bounds from the time |
Lines 1016-1033
Link Here
|
1016 |
else if (se) |
1017 |
else if (se) |
1017 |
{ |
1018 |
{ |
1018 |
fp->seek(se->offset,0); |
1019 |
fp->seek(se->offset,0); |
1019 |
short old_tot=fp->read_short(); |
1020 |
int16_t old_tot=fp->read_uint16(); |
1020 |
se=sd->find("describe_names"); |
1021 |
se=sd->find("describe_names"); |
1021 |
if (!se || !old_tot) |
1022 |
if (!se || !old_tot) |
1022 |
return ; |
1023 |
return ; |
1023 |
|
1024 |
|
1024 |
unsigned short *o_remap=(unsigned short *)jmalloc(old_tot*2,"obj remap array"); |
1025 |
uint16_t *o_remap=(uint16_t *)jmalloc(old_tot*2,"obj remap array"); |
1025 |
unsigned short *o_backmap=(unsigned short *)jmalloc(total_objects*2,"obj remap array"); |
1026 |
uint16_t *o_backmap=(uint16_t *)jmalloc(total_objects*2,"obj remap array"); |
1026 |
memset(o_backmap,0xff,total_objects*2); |
1027 |
memset(o_backmap,0xff,total_objects*2); |
1027 |
char old_name[150]; |
1028 |
char old_name[150]; |
1028 |
for (i=0;i<old_tot;i++) |
1029 |
for (i=0;i<old_tot;i++) |
1029 |
{ |
1030 |
{ |
1030 |
fp->read(old_name,fp->read_byte()); // read the name |
1031 |
fp->read(old_name,fp->read_uint8()); // read the name |
1031 |
for (o_remap[i]=0xffff,j=0;j<total_objects;j++) // check for matching current name |
1032 |
for (o_remap[i]=0xffff,j=0;j<total_objects;j++) // check for matching current name |
1032 |
{ |
1033 |
{ |
1033 |
if (!strcmp(old_name,object_names[j])) |
1034 |
if (!strcmp(old_name,object_names[j])) |
Lines 1040-1056
Link Here
|
1040 |
|
1041 |
|
1041 |
se=sd->find("describe_states"); |
1042 |
se=sd->find("describe_states"); |
1042 |
if (!se) { jfree(o_remap); jfree(o_backmap); return ; } |
1043 |
if (!se) { jfree(o_remap); jfree(o_backmap); return ; } |
1043 |
short **s_remap=(short **)jmalloc(old_tot*sizeof(short *),"big state remap array"); |
1044 |
int16_t **s_remap=(int16_t **)jmalloc(old_tot*sizeof(int16_t *),"big state remap array"); |
1044 |
short *s_remap_totals=(short *)jmalloc(old_tot*sizeof(short),"big state rmp totals"); |
1045 |
int16_t *s_remap_totals=(int16_t *)jmalloc(old_tot*sizeof(int16_t),"big state rmp totals"); |
1045 |
fp->seek(se->offset,0); |
1046 |
fp->seek(se->offset,0); |
1046 |
int i=0; |
1047 |
int i=0; |
1047 |
for (;i<old_tot;i++) |
1048 |
for (;i<old_tot;i++) |
1048 |
{ |
1049 |
{ |
1049 |
short t=fp->read_short(); |
1050 |
int16_t t=fp->read_uint16(); |
1050 |
s_remap_totals[i]=t; |
1051 |
s_remap_totals[i]=t; |
1051 |
if (t) |
1052 |
if (t) |
1052 |
{ |
1053 |
{ |
1053 |
s_remap[i]=(short *)jmalloc(t*sizeof(short),"state remap"); |
1054 |
s_remap[i]=(int16_t *)jmalloc(t*sizeof(int16_t),"state remap"); |
1054 |
int j=0; |
1055 |
int j=0; |
1055 |
for (;j<t;j++) |
1056 |
for (;j<t;j++) |
1056 |
*(s_remap[i]+j)=stopped; // if no remap found, then go to stopped state |
1057 |
*(s_remap[i]+j)=stopped; // if no remap found, then go to stopped state |
Lines 1060-1066
Link Here
|
1060 |
int j=0; |
1061 |
int j=0; |
1061 |
for (;j<t;j++) |
1062 |
for (;j<t;j++) |
1062 |
{ |
1063 |
{ |
1063 |
fp->read(old_name,fp->read_byte()); |
1064 |
fp->read(old_name,fp->read_uint8()); |
1064 |
int new_type=o_remap[i]; |
1065 |
int new_type=o_remap[i]; |
1065 |
if (new_type<total_objects) // make sure old object still exsist |
1066 |
if (new_type<total_objects) // make sure old object still exsist |
1066 |
{ |
1067 |
{ |
Lines 1075-1104
Link Here
|
1075 |
} |
1076 |
} |
1076 |
} |
1077 |
} |
1077 |
|
1078 |
|
1078 |
short **v_remap=NULL; |
1079 |
int16_t **v_remap=NULL; |
1079 |
short *v_remap_totals=NULL; |
1080 |
int16_t *v_remap_totals=NULL; |
1080 |
int load_vars=1; |
1081 |
int load_vars=1; |
1081 |
se=sd->find("describe_lvars"); |
1082 |
se=sd->find("describe_lvars"); |
1082 |
if (se) |
1083 |
if (se) |
1083 |
{ |
1084 |
{ |
1084 |
v_remap=(short **)jmalloc(old_tot*sizeof(short *),"big var remap array"); |
1085 |
v_remap=(int16_t **)jmalloc(old_tot*sizeof(int16_t *),"big var remap array"); |
1085 |
v_remap_totals=(short *)jmalloc(old_tot*sizeof(short),"big var rmp totals"); |
1086 |
v_remap_totals=(int16_t *)jmalloc(old_tot*sizeof(int16_t),"big var rmp totals"); |
1086 |
|
1087 |
|
1087 |
fp->seek(se->offset,0); |
1088 |
fp->seek(se->offset,0); |
1088 |
int i=0; |
1089 |
int i=0; |
1089 |
for (;i<old_tot;i++) |
1090 |
for (;i<old_tot;i++) |
1090 |
{ |
1091 |
{ |
1091 |
short t=fp->read_short(); |
1092 |
int16_t t=fp->read_uint16(); |
1092 |
v_remap_totals[i]=t; |
1093 |
v_remap_totals[i]=t; |
1093 |
if (t) |
1094 |
if (t) |
1094 |
{ |
1095 |
{ |
1095 |
v_remap[i]=(short *)jmalloc(t*sizeof(short),"var remap"); |
1096 |
v_remap[i]=(int16_t *)jmalloc(t*sizeof(int16_t),"var remap"); |
1096 |
memset(v_remap[i],0xff,t*sizeof(short)); |
1097 |
memset(v_remap[i],0xff,t*sizeof(int16_t)); |
1097 |
} else { v_remap[i]=NULL; } |
1098 |
} else { v_remap[i]=NULL; } |
1098 |
int j=0; |
1099 |
int j=0; |
1099 |
for (;j<t;j++) |
1100 |
for (;j<t;j++) |
1100 |
{ |
1101 |
{ |
1101 |
fp->read(old_name,fp->read_byte()); |
1102 |
fp->read(old_name,fp->read_uint8()); |
1102 |
int new_type=o_remap[i]; |
1103 |
int new_type=o_remap[i]; |
1103 |
if (new_type!=0xffff) // make sure old object still exsist |
1104 |
if (new_type!=0xffff) // make sure old object still exsist |
1104 |
{ |
1105 |
{ |
Lines 1120-1138
Link Here
|
1120 |
se=sd->find("object_list"); |
1121 |
se=sd->find("object_list"); |
1121 |
if (se) |
1122 |
if (se) |
1122 |
{ |
1123 |
{ |
1123 |
total_objs=fp->read_long(); |
1124 |
total_objs=fp->read_uint32(); |
1124 |
|
1125 |
|
1125 |
se=sd->find("type"); |
1126 |
se=sd->find("type"); |
1126 |
if (se) |
1127 |
if (se) |
1127 |
{ |
1128 |
{ |
1128 |
fp->seek(se->offset,0); |
1129 |
fp->seek(se->offset,0); |
1129 |
last=NULL; |
1130 |
last=NULL; |
1130 |
if (fp->read_byte()==RC_S) // read type array, this should be type RC_S |
1131 |
if (fp->read_uint8()==RC_16) // read type array, this should be type RC_16 |
1131 |
{ |
1132 |
{ |
1132 |
int i=0; |
1133 |
int i=0; |
1133 |
for (;i<total_objs;i++) |
1134 |
for (;i<total_objs;i++) |
1134 |
{ |
1135 |
{ |
1135 |
ushort t=fp->read_short(); |
1136 |
uint16_t t=fp->read_uint16(); |
1136 |
game_object *p=new game_object(o_remap[t],1); |
1137 |
game_object *p=new game_object(o_remap[t],1); |
1137 |
clear_tmp(); |
1138 |
clear_tmp(); |
1138 |
if (!first) first=p; else last->next=p; |
1139 |
if (!first) first=p; else last->next=p; |
Lines 1143-1154
Link Here
|
1143 |
if (se) |
1144 |
if (se) |
1144 |
{ |
1145 |
{ |
1145 |
fp->seek(se->offset,0); |
1146 |
fp->seek(se->offset,0); |
1146 |
if (fp->read_byte()==RC_S) // read state array, this should be type RC_S |
1147 |
if (fp->read_uint8()==RC_16) // read state array, this should be type RC_16 |
1147 |
{ |
1148 |
{ |
1148 |
game_object *l=first; |
1149 |
game_object *l=first; |
1149 |
for (i=0;i<total_objs;i++,l=l->next) |
1150 |
for (i=0;i<total_objs;i++,l=l->next) |
1150 |
{ |
1151 |
{ |
1151 |
int st=fp->read_short(); |
1152 |
int st=fp->read_uint16(); |
1152 |
if (l->otype==0xffff) |
1153 |
if (l->otype==0xffff) |
1153 |
l->state=stopped; |
1154 |
l->state=stopped; |
1154 |
else |
1155 |
else |
Lines 1171-1184
Link Here
|
1171 |
game_object *o=first; |
1172 |
game_object *o=first; |
1172 |
for (;o && !abort;o=o->next) |
1173 |
for (;o && !abort;o=o->next) |
1173 |
{ |
1174 |
{ |
1174 |
short ot=fp->read_short(); |
1175 |
int16_t ot=fp->read_uint16(); |
1175 |
int k=0; |
1176 |
int k=0; |
1176 |
for (;k<ot;k++) |
1177 |
for (;k<ot;k++) |
1177 |
{ |
1178 |
{ |
1178 |
if (fp->read_byte()!=RC_L) abort=1; |
1179 |
if (fp->read_uint8()!=RC_32) abort=1; |
1179 |
else |
1180 |
else |
1180 |
{ |
1181 |
{ |
1181 |
long v=fp->read_long(); |
1182 |
int32_t v=fp->read_uint32(); |
1182 |
if (o->otype!=0xffff) // non-exstant object |
1183 |
if (o->otype!=0xffff) // non-exstant object |
1183 |
{ |
1184 |
{ |
1184 |
int remap=*(v_remap[o_backmap[o->otype]]+k); |
1185 |
int remap=*(v_remap[o_backmap[o->otype]]+k); |
Lines 1206-1212
Link Here
|
1206 |
{ |
1207 |
{ |
1207 |
fp->seek(se->offset,0); |
1208 |
fp->seek(se->offset,0); |
1208 |
int t=object_descriptions[j].type; |
1209 |
int t=object_descriptions[j].type; |
1209 |
if (fp->read_byte()!=t) |
1210 |
if (fp->read_uint8()!=t) |
1210 |
dprintf("Warning : load level -> var '%s' size changed\n"); |
1211 |
dprintf("Warning : load level -> var '%s' size changed\n"); |
1211 |
else |
1212 |
else |
1212 |
{ |
1213 |
{ |
Lines 1215-1226
Link Here
|
1215 |
{ |
1216 |
{ |
1216 |
switch (t) |
1217 |
switch (t) |
1217 |
{ |
1218 |
{ |
1218 |
case RC_C : |
1219 |
case RC_8 : |
1219 |
{ f->set_var(j,fp->read_byte()); } break; |
1220 |
{ f->set_var(j,fp->read_uint8()); } break; |
1220 |
case RC_S : |
1221 |
case RC_16 : |
1221 |
{ f->set_var(j,fp->read_short()); } break; |
1222 |
{ f->set_var(j,fp->read_uint16()); } break; |
1222 |
case RC_L : |
1223 |
case RC_32 : |
1223 |
{ f->set_var(j,fp->read_long()); } break; |
1224 |
{ f->set_var(j,fp->read_uint32()); } break; |
1224 |
} |
1225 |
} |
1225 |
|
1226 |
|
1226 |
// check to make sure the frame number is not out of bounds from the time |
1227 |
// check to make sure the frame number is not out of bounds from the time |
Lines 1291-1297
Link Here
|
1291 |
if (e) |
1292 |
if (e) |
1292 |
{ |
1293 |
{ |
1293 |
fp->seek(e->offset,0); |
1294 |
fp->seek(e->offset,0); |
1294 |
int len=fp->read_byte(); // read the length of the string |
1295 |
int len=fp->read_uint8(); // read the length of the string |
1295 |
first_name=(char *)jmalloc(len,"level first name"); |
1296 |
first_name=(char *)jmalloc(len,"level first name"); |
1296 |
fp->read(first_name,len); // read the string |
1297 |
fp->read(first_name,len); // read the string |
1297 |
} else |
1298 |
} else |
Lines 1306-1317
Link Here
|
1306 |
if (e) |
1307 |
if (e) |
1307 |
{ |
1308 |
{ |
1308 |
fp->seek(e->offset,0); |
1309 |
fp->seek(e->offset,0); |
1309 |
fg_width=fp->read_long(); |
1310 |
fg_width=fp->read_uint32(); |
1310 |
fg_height=fp->read_long(); |
1311 |
fg_height=fp->read_uint32(); |
1311 |
map_fg=(unsigned short *)jmalloc(2*fg_width*fg_height,"Map fg : loaded"); |
1312 |
map_fg=(uint16_t *)jmalloc(2*fg_width*fg_height,"Map fg : loaded"); |
1312 |
fp->read((char *)map_fg,2*fg_width*fg_height); |
1313 |
fp->read((char *)map_fg,2*fg_width*fg_height); |
1313 |
int t=fg_width*fg_height; |
1314 |
int t=fg_width*fg_height; |
1314 |
unsigned short *map=map_fg; |
1315 |
uint16_t *map=map_fg; |
1315 |
while (t) { *map=lstl(*map); map++; t--; } |
1316 |
while (t) { *map=lstl(*map); map++; t--; } |
1316 |
} else |
1317 |
} else |
1317 |
{ |
1318 |
{ |
Lines 1324-1335
Link Here
|
1324 |
if (e) |
1325 |
if (e) |
1325 |
{ |
1326 |
{ |
1326 |
fp->seek(e->offset,0); |
1327 |
fp->seek(e->offset,0); |
1327 |
bg_width=fp->read_long(); |
1328 |
bg_width=fp->read_uint32(); |
1328 |
bg_height=fp->read_long(); |
1329 |
bg_height=fp->read_uint32(); |
1329 |
map_bg=(unsigned short *)jmalloc(2*bg_width*bg_height,"Map bg : loaded"); |
1330 |
map_bg=(uint16_t *)jmalloc(2*bg_width*bg_height,"Map bg : loaded"); |
1330 |
fp->read((char *)map_bg,2*bg_width*bg_height); |
1331 |
fp->read((char *)map_bg,2*bg_width*bg_height); |
1331 |
int t=bg_width*bg_height; |
1332 |
int t=bg_width*bg_height; |
1332 |
unsigned short *map=map_bg; |
1333 |
uint16_t *map=map_bg; |
1333 |
while (t) { *map=lstl(*map); map++; t--; } |
1334 |
while (t) { *map=lstl(*map); map++; t--; } |
1334 |
} else |
1335 |
} else |
1335 |
{ |
1336 |
{ |
Lines 1341-1347
Link Here
|
1341 |
{ |
1342 |
{ |
1342 |
fg_width=bg_width; |
1343 |
fg_width=bg_width; |
1343 |
fg_height=bg_height; |
1344 |
fg_height=bg_height; |
1344 |
map_fg=(unsigned short *)jmalloc(2*fg_width*fg_height,"Map fg : loaded"); |
1345 |
map_fg=(uint16_t *)jmalloc(2*fg_width*fg_height,"Map fg : loaded"); |
1345 |
memset(map_fg,0,2*fg_width*fg_height); |
1346 |
memset(map_fg,0,2*fg_width*fg_height); |
1346 |
} |
1347 |
} |
1347 |
|
1348 |
|
Lines 1349-1362
Link Here
|
1349 |
{ |
1350 |
{ |
1350 |
bg_width=fg_width/8+8; |
1351 |
bg_width=fg_width/8+8; |
1351 |
bg_height=fg_height/8+8; |
1352 |
bg_height=fg_height/8+8; |
1352 |
map_bg=(unsigned short *)jmalloc(2*bg_width*bg_height,"Map bg : loaded"); |
1353 |
map_bg=(uint16_t *)jmalloc(2*bg_width*bg_height,"Map bg : loaded"); |
1353 |
memset(map_bg,0,2*bg_width*bg_height); |
1354 |
memset(map_bg,0,2*bg_width*bg_height); |
1354 |
} |
1355 |
} |
1355 |
stat_man->update(10); |
1356 |
stat_man->update(10); |
1356 |
|
1357 |
|
1357 |
/***************** Check map for non exsistant tiles **************************/ |
1358 |
/***************** Check map for non exsistant tiles **************************/ |
1358 |
long i,w; |
1359 |
int32_t i,w; |
1359 |
unsigned short *m; |
1360 |
uint16_t *m; |
1360 |
spec_entry *load_all=sd->find("player_info"); |
1361 |
spec_entry *load_all=sd->find("player_info"); |
1361 |
for (i=0,w=fg_width*fg_height,m=map_fg;i<w;i++,m++) |
1362 |
for (i=0,w=fg_width*fg_height,m=map_fg;i<w;i++,m++) |
1362 |
{ |
1363 |
{ |
Lines 1568-1577
Link Here
|
1568 |
|
1569 |
|
1569 |
|
1570 |
|
1570 |
|
1571 |
|
1571 |
// how many objects are we goint to save, use a long to specify how many |
1572 |
// how many objects are we goint to save, use a int32_t to specify how many |
1572 |
sd.add_by_hand(new spec_entry(SPEC_DATA_ARRAY,"object_list",NULL,4,0)); |
1573 |
sd.add_by_hand(new spec_entry(SPEC_DATA_ARRAY,"object_list",NULL,4,0)); |
1573 |
|
1574 |
|
1574 |
long t=0; |
1575 |
int32_t t=0; |
1575 |
object_node *o=save_list; |
1576 |
object_node *o=save_list; |
1576 |
for (;o;o=o->next) |
1577 |
for (;o;o=o->next) |
1577 |
t++; |
1578 |
t++; |
Lines 1642-1649
Link Here
|
1642 |
strftime(buf,80,"%T %A %B %d",localtime(&t)); |
1643 |
strftime(buf,80,"%T %A %B %d",localtime(&t)); |
1643 |
eh->font()->put_string(i,80-strlen(buf)*eh->font()->width()/2,100+eh->font()->height(),buf); |
1644 |
eh->font()->put_string(i,80-strlen(buf)*eh->font()->width()/2,100+eh->font()->height(),buf); |
1644 |
|
1645 |
|
1645 |
fp->write_short(i->width()); |
1646 |
fp->write_uint16(i->width()); |
1646 |
fp->write_short(i->height()); |
1647 |
fp->write_uint16(i->height()); |
1647 |
int y=0; |
1648 |
int y=0; |
1648 |
for (;y<i->height();y++) |
1649 |
for (;y<i->height();y++) |
1649 |
fp->write(i->scan_line(y),i->width()); |
1650 |
fp->write(i->scan_line(y),i->width()); |
Lines 1653-1688
Link Here
|
1653 |
|
1654 |
|
1654 |
void level::write_player_info(bFILE *fp, object_node *save_list) |
1655 |
void level::write_player_info(bFILE *fp, object_node *save_list) |
1655 |
{ |
1656 |
{ |
1656 |
long t=0; |
1657 |
int32_t t=0; |
1657 |
view *v=player_list; |
1658 |
view *v=player_list; |
1658 |
for (;v;v=v->next) t++; |
1659 |
for (;v;v=v->next) t++; |
1659 |
fp->write_long(t); |
1660 |
fp->write_uint32(t); |
1660 |
|
1661 |
|
1661 |
for (v=player_list;v;v=v->next) |
1662 |
for (v=player_list;v;v=v->next) |
1662 |
fp->write_long(object_to_number_in_list(v->focus,save_list)); |
1663 |
fp->write_uint32(object_to_number_in_list(v->focus,save_list)); |
1663 |
|
1664 |
|
1664 |
int tv=total_view_vars(); |
1665 |
int tv=total_view_vars(); |
1665 |
int i=0; |
1666 |
int i=0; |
1666 |
for (;i<tv;i++) |
1667 |
for (;i<tv;i++) |
1667 |
{ |
1668 |
{ |
1668 |
fp->write_byte(RC_L); |
1669 |
fp->write_uint8(RC_32); |
1669 |
for (v=player_list;v;v=v->next) |
1670 |
for (v=player_list;v;v=v->next) |
1670 |
fp->write_long(v->get_view_var_value(i)); |
1671 |
fp->write_uint32(v->get_view_var_value(i)); |
1671 |
} |
1672 |
} |
1672 |
|
1673 |
|
1673 |
fp->write_byte(RC_L); |
1674 |
fp->write_uint8(RC_32); |
1674 |
fp->write_long(rand_on); |
1675 |
fp->write_uint32(rand_on); |
1675 |
|
1676 |
|
1676 |
fp->write_byte(RC_L); |
1677 |
fp->write_uint8(RC_32); |
1677 |
fp->write_long(total_weapons); |
1678 |
fp->write_uint32(total_weapons); |
1678 |
for (v=player_list;v;v=v->next) |
1679 |
for (v=player_list;v;v=v->next) |
1679 |
for (i=0;i<total_weapons;i++) |
1680 |
for (i=0;i<total_weapons;i++) |
1680 |
fp->write_long(v->weapons[i]); |
1681 |
fp->write_uint32(v->weapons[i]); |
1681 |
|
1682 |
|
1682 |
for (v=player_list;v;v=v->next) |
1683 |
for (v=player_list;v;v=v->next) |
1683 |
{ |
1684 |
{ |
1684 |
int len=strlen(v->name)+1; |
1685 |
int len=strlen(v->name)+1; |
1685 |
fp->write_byte(len); |
1686 |
fp->write_uint8(len); |
1686 |
fp->write(v->name,len); |
1687 |
fp->write(v->name,len); |
1687 |
} |
1688 |
} |
1688 |
} |
1689 |
} |
Lines 1724-1735
Link Here
|
1724 |
delete v; |
1725 |
delete v; |
1725 |
} |
1726 |
} |
1726 |
|
1727 |
|
1727 |
long total_players=fp->read_long(); |
1728 |
int32_t total_players=fp->read_uint32(); |
1728 |
view *last=NULL; |
1729 |
view *last=NULL; |
1729 |
int i=0; |
1730 |
int i=0; |
1730 |
for (;i<total_players;i++) |
1731 |
for (;i<total_players;i++) |
1731 |
{ |
1732 |
{ |
1732 |
game_object *o=number_to_object_in_list(fp->read_long(),save_list); |
1733 |
game_object *o=number_to_object_in_list(fp->read_uint32(),save_list); |
1733 |
v=new view(o,NULL,0); |
1734 |
v=new view(o,NULL,0); |
1734 |
if (o) o->set_controller(v); |
1735 |
if (o) o->set_controller(v); |
1735 |
if (player_list) |
1736 |
if (player_list) |
Lines 1748-1757
Link Here
|
1748 |
if (se) |
1749 |
if (se) |
1749 |
{ |
1750 |
{ |
1750 |
fp->seek(se->offset,0); |
1751 |
fp->seek(se->offset,0); |
1751 |
if (fp->read_byte()==RC_L) |
1752 |
if (fp->read_uint8()==RC_32) |
1752 |
{ |
1753 |
{ |
1753 |
for (v=player_list;v;v=v->next) |
1754 |
for (v=player_list;v;v=v->next) |
1754 |
v->set_view_var_value(i,fp->read_long()); |
1755 |
v->set_view_var_value(i,fp->read_uint32()); |
1755 |
} |
1756 |
} |
1756 |
} else |
1757 |
} else |
1757 |
{ |
1758 |
{ |
Lines 1764-1786
Link Here
|
1764 |
if (se) |
1765 |
if (se) |
1765 |
{ |
1766 |
{ |
1766 |
fp->seek(se->offset,0); |
1767 |
fp->seek(se->offset,0); |
1767 |
if (fp->read_byte()==RC_L) |
1768 |
if (fp->read_uint8()==RC_32) |
1768 |
rand_on=fp->read_long(); |
1769 |
rand_on=fp->read_uint32(); |
1769 |
} else rand_on=0; |
1770 |
} else rand_on=0; |
1770 |
|
1771 |
|
1771 |
se=sd->find("weapon_array"); |
1772 |
se=sd->find("weapon_array"); |
1772 |
if (se) |
1773 |
if (se) |
1773 |
{ |
1774 |
{ |
1774 |
fp->seek(se->offset,0); |
1775 |
fp->seek(se->offset,0); |
1775 |
if (fp->read_byte()==RC_L) |
1776 |
if (fp->read_uint8()==RC_32) |
1776 |
{ |
1777 |
{ |
1777 |
long m=fp->read_long(); // read how many weapons exsisted when last saved |
1778 |
int32_t m=fp->read_uint32(); // read how many weapons exsisted when last saved |
1778 |
int i; |
1779 |
int i; |
1779 |
for (v=player_list;v;v=v->next) |
1780 |
for (v=player_list;v;v=v->next) |
1780 |
{ |
1781 |
{ |
1781 |
for (i=0;i<m;i++) |
1782 |
for (i=0;i<m;i++) |
1782 |
{ |
1783 |
{ |
1783 |
long x=fp->read_long(); |
1784 |
int32_t x=fp->read_uint32(); |
1784 |
if (i<total_weapons) |
1785 |
if (i<total_weapons) |
1785 |
{ |
1786 |
{ |
1786 |
v->weapons[i]=x; |
1787 |
v->weapons[i]=x; |
Lines 1793-1800
Link Here
|
1793 |
{ |
1794 |
{ |
1794 |
for (v=player_list;v;v=v->next) |
1795 |
for (v=player_list;v;v=v->next) |
1795 |
{ |
1796 |
{ |
1796 |
memset(v->last_weapons,0xff,total_weapons*sizeof(long)); |
1797 |
memset(v->last_weapons,0xff,total_weapons*sizeof(int32_t)); |
1797 |
memset(v->weapons,0xff,total_weapons*sizeof(long)); |
1798 |
memset(v->weapons,0xff,total_weapons*sizeof(int32_t)); |
1798 |
} |
1799 |
} |
1799 |
} |
1800 |
} |
1800 |
|
1801 |
|
Lines 1804-1810
Link Here
|
1804 |
fp->seek(se->offset,0); |
1805 |
fp->seek(se->offset,0); |
1805 |
for (v=player_list;v;v=v->next) |
1806 |
for (v=player_list;v;v=v->next) |
1806 |
{ |
1807 |
{ |
1807 |
uchar len=fp->read_byte(); |
1808 |
uint8_t len=fp->read_uint8(); |
1808 |
fp->read(v->name,len); |
1809 |
fp->read(v->name,len); |
1809 |
} |
1810 |
} |
1810 |
} |
1811 |
} |
Lines 1852-1863
Link Here
|
1852 |
{ |
1853 |
{ |
1853 |
// record information in the file about what the data structures look like |
1854 |
// record information in the file about what the data structures look like |
1854 |
// right now, so if they change later, they don't get get screwed up |
1855 |
// right now, so if they change later, they don't get get screwed up |
1855 |
fp->write_short(total_objects); // mark how many objects we know about right now |
1856 |
fp->write_uint16(total_objects); // mark how many objects we know about right now |
1856 |
|
1857 |
|
1857 |
int i=0; |
1858 |
int i=0; |
1858 |
for (;i<total_objects;i++) // loop through all the object types we know of |
1859 |
for (;i<total_objects;i++) // loop through all the object types we know of |
1859 |
{ |
1860 |
{ |
1860 |
fp->write_byte(strlen(object_names[i])+1); // sizeof name |
1861 |
fp->write_uint8(strlen(object_names[i])+1); // sizeof name |
1861 |
fp->write(object_names[i],strlen(object_names[i])+1); // write object name |
1862 |
fp->write(object_names[i],strlen(object_names[i])+1); // write object name |
1862 |
} |
1863 |
} |
1863 |
|
1864 |
|
Lines 1869-1881
Link Here
|
1869 |
int j=0; |
1870 |
int j=0; |
1870 |
for (;j<figures[i]->ts;j++) |
1871 |
for (;j<figures[i]->ts;j++) |
1871 |
if (figures[i]->seq[j]) total++; |
1872 |
if (figures[i]->seq[j]) total++; |
1872 |
fp->write_short(total); |
1873 |
fp->write_uint16(total); |
1873 |
|
1874 |
|
1874 |
for (j=0;j<figures[i]->ts;j++) |
1875 |
for (j=0;j<figures[i]->ts;j++) |
1875 |
if (figures[i]->seq[j]) |
1876 |
if (figures[i]->seq[j]) |
1876 |
{ |
1877 |
{ |
1877 |
char *state_name=lstring_value(symbol_name(figures[i]->seq_syms[j])); |
1878 |
char *state_name=lstring_value(symbol_name(figures[i]->seq_syms[j])); |
1878 |
fp->write_byte(strlen(state_name)+1); |
1879 |
fp->write_uint8(strlen(state_name)+1); |
1879 |
fp->write(state_name,strlen(state_name)+1); |
1880 |
fp->write(state_name,strlen(state_name)+1); |
1880 |
} |
1881 |
} |
1881 |
} |
1882 |
} |
Lines 1884-1890
Link Here
|
1884 |
// write object lvar names |
1885 |
// write object lvar names |
1885 |
for (i=0;i<total_objects;i++) |
1886 |
for (i=0;i<total_objects;i++) |
1886 |
{ |
1887 |
{ |
1887 |
fp->write_short(figures[i]->tv); |
1888 |
fp->write_uint16(figures[i]->tv); |
1888 |
int j,x; |
1889 |
int j,x; |
1889 |
|
1890 |
|
1890 |
for (x=0;x<figures[i]->tv;x++) |
1891 |
for (x=0;x<figures[i]->tv;x++) |
Lines 1894-1959
Link Here
|
1894 |
if (figures[i]->vars[j] && figures[i]->var_index[j]==x) |
1895 |
if (figures[i]->vars[j] && figures[i]->var_index[j]==x) |
1895 |
{ |
1896 |
{ |
1896 |
char *var_name=lstring_value(symbol_name(figures[i]->vars[j])); |
1897 |
char *var_name=lstring_value(symbol_name(figures[i]->vars[j])); |
1897 |
fp->write_byte(strlen(var_name)+1); |
1898 |
fp->write_uint8(strlen(var_name)+1); |
1898 |
fp->write(var_name,strlen(var_name)+1); |
1899 |
fp->write(var_name,strlen(var_name)+1); |
1899 |
} |
1900 |
} |
1900 |
} |
1901 |
} |
1901 |
} |
1902 |
} |
1902 |
} |
1903 |
} |
1903 |
|
1904 |
|
1904 |
long t=0; |
1905 |
int32_t t=0; |
1905 |
object_node *o=save_list; |
1906 |
object_node *o=save_list; |
1906 |
for (;o;o=o->next) t++; |
1907 |
for (;o;o=o->next) t++; |
1907 |
fp->write_long(t); |
1908 |
fp->write_uint32(t); |
1908 |
|
1909 |
|
1909 |
|
1910 |
|
1910 |
fp->write_byte(RC_S); // save type info for each record |
1911 |
fp->write_uint8(RC_16); // save type info for each record |
1911 |
for (o=save_list;o;o=o->next) fp->write_short(o->me->type()); |
1912 |
for (o=save_list;o;o=o->next) fp->write_uint16(o->me->type()); |
1912 |
|
1913 |
|
1913 |
fp->write_byte(RC_S); // save state info for each record |
1914 |
fp->write_uint8(RC_16); // save state info for each record |
1914 |
for (o=save_list;o;o=o->next) fp->write_short(o->me->reduced_state()); |
1915 |
for (o=save_list;o;o=o->next) fp->write_uint16(o->me->reduced_state()); |
1915 |
|
1916 |
|
1916 |
for (o=save_list;o;o=o->next) // save lvars |
1917 |
for (o=save_list;o;o=o->next) // save lvars |
1917 |
{ |
1918 |
{ |
1918 |
fp->write_short(figures[o->me->otype]->tv); |
1919 |
fp->write_uint16(figures[o->me->otype]->tv); |
1919 |
for (i=0;i<figures[o->me->otype]->tv;i++) |
1920 |
for (i=0;i<figures[o->me->otype]->tv;i++) |
1920 |
{ |
1921 |
{ |
1921 |
fp->write_byte(RC_L); // for now the only type allowed is long |
1922 |
fp->write_uint8(RC_32); // for now the only type allowed is int32_t |
1922 |
fp->write_long(o->me->lvars[i]); |
1923 |
fp->write_uint32(o->me->lvars[i]); |
1923 |
} |
1924 |
} |
1924 |
} |
1925 |
} |
1925 |
|
1926 |
|
1926 |
for (i=0;i<default_simple.total_vars();i++) |
1927 |
for (i=0;i<default_simple.total_vars();i++) |
1927 |
{ |
1928 |
{ |
1928 |
int t=object_descriptions[i].type; |
1929 |
int t=object_descriptions[i].type; |
1929 |
fp->write_byte(t); |
1930 |
fp->write_uint8(t); |
1930 |
for (o=save_list;o;o=o->next) |
1931 |
for (o=save_list;o;o=o->next) |
1931 |
{ |
1932 |
{ |
1932 |
switch (t) |
1933 |
switch (t) |
1933 |
{ |
1934 |
{ |
1934 |
case RC_C : |
1935 |
case RC_8 : |
1935 |
{ fp->write_byte(o->me->get_var(i)); } break; |
1936 |
{ fp->write_uint8(o->me->get_var(i)); } break; |
1936 |
case RC_S : |
1937 |
case RC_16 : |
1937 |
{ fp->write_short(o->me->get_var(i)); } break; |
1938 |
{ fp->write_uint16(o->me->get_var(i)); } break; |
1938 |
case RC_L : |
1939 |
case RC_32 : |
1939 |
{ fp->write_long(o->me->get_var(i)); } break; |
1940 |
{ fp->write_uint32(o->me->get_var(i)); } break; |
1940 |
} |
1941 |
} |
1941 |
} |
1942 |
} |
1942 |
} |
1943 |
} |
1943 |
} |
1944 |
} |
1944 |
|
1945 |
|
1945 |
|
1946 |
|
1946 |
long level::total_object_links(object_node *list) |
1947 |
int32_t level::total_object_links(object_node *list) |
1947 |
{ |
1948 |
{ |
1948 |
long tl=0; |
1949 |
int32_t tl=0; |
1949 |
for (object_node *o=list;o;o=o->next) |
1950 |
for (object_node *o=list;o;o=o->next) |
1950 |
tl+=o->me->total_objects(); |
1951 |
tl+=o->me->total_objects(); |
1951 |
return tl; |
1952 |
return tl; |
1952 |
} |
1953 |
} |
1953 |
|
1954 |
|
1954 |
long level::total_light_links(object_node *list) |
1955 |
int32_t level::total_light_links(object_node *list) |
1955 |
{ |
1956 |
{ |
1956 |
long tl=0; |
1957 |
int32_t tl=0; |
1957 |
for (object_node *o=list;o;o=o->next) |
1958 |
for (object_node *o=list;o;o=o->next) |
1958 |
tl+=o->me->total_lights(); |
1959 |
tl+=o->me->total_lights(); |
1959 |
return tl; |
1960 |
return tl; |
Lines 1961-1968
Link Here
|
1961 |
|
1962 |
|
1962 |
void level::write_links(bFILE *fp, object_node *save_list, object_node *exclude_list) |
1963 |
void level::write_links(bFILE *fp, object_node *save_list, object_node *exclude_list) |
1963 |
{ |
1964 |
{ |
1964 |
fp->write_byte(RC_L); |
1965 |
fp->write_uint8(RC_32); |
1965 |
fp->write_long(total_object_links(save_list)); |
1966 |
fp->write_uint32(total_object_links(save_list)); |
1966 |
|
1967 |
|
1967 |
int x=1; |
1968 |
int x=1; |
1968 |
object_node *o=save_list; |
1969 |
object_node *o=save_list; |
Lines 1972-1988
Link Here
|
1972 |
int i=0; |
1973 |
int i=0; |
1973 |
for (;i<o->me->total_objects();i++) |
1974 |
for (;i<o->me->total_objects();i++) |
1974 |
{ |
1975 |
{ |
1975 |
fp->write_long(x); |
1976 |
fp->write_uint32(x); |
1976 |
long x=object_to_number_in_list(o->me->get_object(i),save_list); |
1977 |
int32_t x=object_to_number_in_list(o->me->get_object(i),save_list); |
1977 |
if (x) |
1978 |
if (x) |
1978 |
fp->write_long(x); |
1979 |
fp->write_uint32(x); |
1979 |
else // save links to excluded items as negative |
1980 |
else // save links to excluded items as negative |
1980 |
fp->write_long((long)(-(object_to_number_in_list(o->me,exclude_list)))); |
1981 |
fp->write_uint32((int32_t)(-(object_to_number_in_list(o->me,exclude_list)))); |
1981 |
} |
1982 |
} |
1982 |
} |
1983 |
} |
1983 |
|
1984 |
|
1984 |
fp->write_byte(RC_L); |
1985 |
fp->write_uint8(RC_32); |
1985 |
fp->write_long(total_light_links(save_list)); |
1986 |
fp->write_uint32(total_light_links(save_list)); |
1986 |
|
1987 |
|
1987 |
x=1; |
1988 |
x=1; |
1988 |
for (o=save_list;o;o=o->next,x++) |
1989 |
for (o=save_list;o;o=o->next,x++) |
Lines 1990-1997
Link Here
|
1990 |
int i=0; |
1991 |
int i=0; |
1991 |
for (;i<o->me->total_lights();i++) |
1992 |
for (;i<o->me->total_lights();i++) |
1992 |
{ |
1993 |
{ |
1993 |
fp->write_long(x); |
1994 |
fp->write_uint32(x); |
1994 |
fp->write_long(light_to_number(o->me->get_light(i))); |
1995 |
fp->write_uint32(light_to_number(o->me->get_light(i))); |
1995 |
} |
1996 |
} |
1996 |
} |
1997 |
} |
1997 |
|
1998 |
|
Lines 2005-2018
Link Here
|
2005 |
if (se) |
2006 |
if (se) |
2006 |
{ |
2007 |
{ |
2007 |
fp->seek(se->offset,0); |
2008 |
fp->seek(se->offset,0); |
2008 |
if (fp->read_byte()==RC_L) |
2009 |
if (fp->read_uint8()==RC_32) |
2009 |
{ |
2010 |
{ |
2010 |
long t=fp->read_long(); |
2011 |
int32_t t=fp->read_uint32(); |
2011 |
while (t) |
2012 |
while (t) |
2012 |
{ |
2013 |
{ |
2013 |
long x1=fp->read_long(); |
2014 |
int32_t x1=fp->read_uint32(); |
2014 |
CONDITION(x1>=0,"expected x1 for object link to be > 0\n"); |
2015 |
CONDITION(x1>=0,"expected x1 for object link to be > 0\n"); |
2015 |
long x2=fp->read_long(); |
2016 |
int32_t x2=fp->read_uint32(); |
2016 |
game_object *p,*q=number_to_object_in_list(x1,save_list); |
2017 |
game_object *p,*q=number_to_object_in_list(x1,save_list); |
2017 |
if (x2>0) |
2018 |
if (x2>0) |
2018 |
p=number_to_object_in_list(x2,save_list); |
2019 |
p=number_to_object_in_list(x2,save_list); |
Lines 2030-2042
Link Here
|
2030 |
if (se) |
2031 |
if (se) |
2031 |
{ |
2032 |
{ |
2032 |
fp->seek(se->offset,0); |
2033 |
fp->seek(se->offset,0); |
2033 |
if (fp->read_byte()==RC_L) |
2034 |
if (fp->read_uint8()==RC_32) |
2034 |
{ |
2035 |
{ |
2035 |
long t=fp->read_long(); |
2036 |
int32_t t=fp->read_uint32(); |
2036 |
while (t) |
2037 |
while (t) |
2037 |
{ |
2038 |
{ |
2038 |
long x1=fp->read_long(); |
2039 |
int32_t x1=fp->read_uint32(); |
2039 |
long x2=fp->read_long(); |
2040 |
int32_t x2=fp->read_uint32(); |
2040 |
game_object *p=number_to_object_in_list(x1,save_list); |
2041 |
game_object *p=number_to_object_in_list(x1,save_list); |
2041 |
if (p) |
2042 |
if (p) |
2042 |
p->add_light(number_to_light(x2)); |
2043 |
p->add_light(number_to_light(x2)); |
Lines 2052-2085
Link Here
|
2052 |
void level::write_options(bFILE *fp) |
2053 |
void level::write_options(bFILE *fp) |
2053 |
{ |
2054 |
{ |
2054 |
// save background scroll rate |
2055 |
// save background scroll rate |
2055 |
fp->write_byte(RC_L); |
2056 |
fp->write_uint8(RC_32); |
2056 |
fp->write_long(bg_xmul); |
2057 |
fp->write_uint32(bg_xmul); |
2057 |
fp->write_long(bg_xdiv); |
2058 |
fp->write_uint32(bg_xdiv); |
2058 |
fp->write_long(bg_ymul); |
2059 |
fp->write_uint32(bg_ymul); |
2059 |
fp->write_long(bg_ydiv); |
2060 |
fp->write_uint32(bg_ydiv); |
2060 |
|
2061 |
|
2061 |
fp->write_byte(RC_L); |
2062 |
fp->write_uint8(RC_32); |
2062 |
int ta=0; |
2063 |
int ta=0; |
2063 |
area_controller *a=area_list; |
2064 |
area_controller *a=area_list; |
2064 |
for (;a;a=a->next) ta++; |
2065 |
for (;a;a=a->next) ta++; |
2065 |
fp->write_long(ta); |
2066 |
fp->write_uint32(ta); |
2066 |
for (a=area_list;a;a=a->next) |
2067 |
for (a=area_list;a;a=a->next) |
2067 |
{ |
2068 |
{ |
2068 |
fp->write_long(a->x); |
2069 |
fp->write_uint32(a->x); |
2069 |
fp->write_long(a->y); |
2070 |
fp->write_uint32(a->y); |
2070 |
fp->write_long(a->w); |
2071 |
fp->write_uint32(a->w); |
2071 |
fp->write_long(a->h); |
2072 |
fp->write_uint32(a->h); |
2072 |
fp->write_long(a->active); |
2073 |
fp->write_uint32(a->active); |
2073 |
|
2074 |
|
2074 |
fp->write_long(a->ambient); |
2075 |
fp->write_uint32(a->ambient); |
2075 |
fp->write_long(a->view_xoff); |
2076 |
fp->write_uint32(a->view_xoff); |
2076 |
fp->write_long(a->view_yoff); |
2077 |
fp->write_uint32(a->view_yoff); |
2077 |
fp->write_long(a->ambient_speed); |
2078 |
fp->write_uint32(a->ambient_speed); |
2078 |
fp->write_long(a->view_xoff_speed); |
2079 |
fp->write_uint32(a->view_xoff_speed); |
2079 |
fp->write_long(a->view_yoff_speed); |
2080 |
fp->write_uint32(a->view_yoff_speed); |
2080 |
} |
2081 |
} |
2081 |
fp->write_byte(RC_L); |
2082 |
fp->write_uint8(RC_32); |
2082 |
fp->write_long(tick_counter()); |
2083 |
fp->write_uint32(tick_counter()); |
2083 |
} |
2084 |
} |
2084 |
|
2085 |
|
2085 |
void level::load_options(spec_directory *sd, bFILE *fp) |
2086 |
void level::load_options(spec_directory *sd, bFILE *fp) |
Lines 2088-2101
Link Here
|
2088 |
if (se) |
2089 |
if (se) |
2089 |
{ |
2090 |
{ |
2090 |
fp->seek(se->offset,0); |
2091 |
fp->seek(se->offset,0); |
2091 |
if (fp->read_byte()!=RC_L) |
2092 |
if (fp->read_uint8()!=RC_32) |
2092 |
{ bg_xmul=bg_ymul=1; bg_xdiv=bg_ydiv=8; } |
2093 |
{ bg_xmul=bg_ymul=1; bg_xdiv=bg_ydiv=8; } |
2093 |
else |
2094 |
else |
2094 |
{ |
2095 |
{ |
2095 |
bg_xmul=fp->read_long(); |
2096 |
bg_xmul=fp->read_uint32(); |
2096 |
bg_xdiv=fp->read_long(); |
2097 |
bg_xdiv=fp->read_uint32(); |
2097 |
bg_ymul=fp->read_long(); |
2098 |
bg_ymul=fp->read_uint32(); |
2098 |
bg_ydiv=fp->read_long(); |
2099 |
bg_ydiv=fp->read_uint32(); |
2099 |
} |
2100 |
} |
2100 |
} else { bg_xmul=bg_ymul=1; bg_xdiv=bg_ydiv=8; } |
2101 |
} else { bg_xmul=bg_ymul=1; bg_xdiv=bg_ydiv=8; } |
2101 |
|
2102 |
|
Lines 2103-2131
Link Here
|
2103 |
if (se) |
2104 |
if (se) |
2104 |
{ |
2105 |
{ |
2105 |
fp->seek(se->offset,0); |
2106 |
fp->seek(se->offset,0); |
2106 |
if (fp->read_byte()==RC_L) |
2107 |
if (fp->read_uint8()==RC_32) |
2107 |
{ |
2108 |
{ |
2108 |
area_controller *l=NULL,*p; |
2109 |
area_controller *l=NULL,*p; |
2109 |
long ta=fp->read_long(); |
2110 |
int32_t ta=fp->read_uint32(); |
2110 |
int i=0; |
2111 |
int i=0; |
2111 |
for (;i<ta;i++) |
2112 |
for (;i<ta;i++) |
2112 |
{ |
2113 |
{ |
2113 |
long x,y,w,h; |
2114 |
int32_t x,y,w,h; |
2114 |
x=fp->read_long(); |
2115 |
x=fp->read_uint32(); |
2115 |
y=fp->read_long(); |
2116 |
y=fp->read_uint32(); |
2116 |
w=fp->read_long(); |
2117 |
w=fp->read_uint32(); |
2117 |
h=fp->read_long(); |
2118 |
h=fp->read_uint32(); |
2118 |
p=new area_controller(x,y,w,h,NULL); |
2119 |
p=new area_controller(x,y,w,h,NULL); |
2119 |
if (l) l->next=p; |
2120 |
if (l) l->next=p; |
2120 |
else area_list=p; |
2121 |
else area_list=p; |
2121 |
l=p; |
2122 |
l=p; |
2122 |
p->active=fp->read_long(); |
2123 |
p->active=fp->read_uint32(); |
2123 |
p->ambient=fp->read_long(); |
2124 |
p->ambient=fp->read_uint32(); |
2124 |
p->view_xoff=fp->read_long(); |
2125 |
p->view_xoff=fp->read_uint32(); |
2125 |
p->view_yoff=fp->read_long(); |
2126 |
p->view_yoff=fp->read_uint32(); |
2126 |
p->ambient_speed=fp->read_long(); |
2127 |
p->ambient_speed=fp->read_uint32(); |
2127 |
p->view_xoff_speed=fp->read_long(); |
2128 |
p->view_xoff_speed=fp->read_uint32(); |
2128 |
p->view_yoff_speed=fp->read_long(); |
2129 |
p->view_yoff_speed=fp->read_uint32(); |
2129 |
} |
2130 |
} |
2130 |
} |
2131 |
} |
2131 |
} |
2132 |
} |
Lines 2134-2141
Link Here
|
2134 |
if (se) |
2135 |
if (se) |
2135 |
{ |
2136 |
{ |
2136 |
fp->seek(se->offset,0); |
2137 |
fp->seek(se->offset,0); |
2137 |
if (fp->read_byte()==RC_L) |
2138 |
if (fp->read_uint8()==RC_32) |
2138 |
set_tick_counter(fp->read_long()); |
2139 |
set_tick_counter(fp->read_uint32()); |
2139 |
else set_tick_counter(0); |
2140 |
else set_tick_counter(0); |
2140 |
} else set_tick_counter(0); |
2141 |
} else set_tick_counter(0); |
2141 |
} |
2142 |
} |
Lines 2202-2209
Link Here
|
2202 |
dprintf("unable to open backup file %s\n", bkname ); |
2203 |
dprintf("unable to open backup file %s\n", bkname ); |
2203 |
else |
2204 |
else |
2204 |
{ |
2205 |
{ |
2205 |
long size = fp->file_size(); |
2206 |
int32_t size = fp->file_size(); |
2206 |
uchar *buf = (uchar *)jmalloc(0x1000,"copy buf"); |
2207 |
uint8_t *buf = (uint8_t *)jmalloc(0x1000,"copy buf"); |
2207 |
int tr = 1; |
2208 |
int tr = 1; |
2208 |
while( size && tr ) |
2209 |
while( size && tr ) |
2209 |
{ |
2210 |
{ |
Lines 2246-2268
Link Here
|
2246 |
{ |
2247 |
{ |
2247 |
if( first_name ) |
2248 |
if( first_name ) |
2248 |
{ |
2249 |
{ |
2249 |
fp->write_byte( strlen( first_name ) + 1 ); |
2250 |
fp->write_uint8( strlen( first_name ) + 1 ); |
2250 |
fp->write( first_name, strlen( first_name ) + 1 ); |
2251 |
fp->write( first_name, strlen( first_name ) + 1 ); |
2251 |
} |
2252 |
} |
2252 |
else |
2253 |
else |
2253 |
{ |
2254 |
{ |
2254 |
fp->write_byte( 1 ); |
2255 |
fp->write_uint8( 1 ); |
2255 |
fp->write_byte( 0 ); |
2256 |
fp->write_uint8( 0 ); |
2256 |
} |
2257 |
} |
2257 |
|
2258 |
|
2258 |
fp->write_long( fg_width ); |
2259 |
fp->write_uint32( fg_width ); |
2259 |
fp->write_long( fg_height ); |
2260 |
fp->write_uint32( fg_height ); |
2260 |
|
2261 |
|
2261 |
int t = fg_width * fg_height; |
2262 |
int t = fg_width * fg_height; |
2262 |
ushort *rm = map_fg; |
2263 |
uint16_t *rm = map_fg; |
2263 |
for (;t;t--,rm++) |
2264 |
for (;t;t--,rm++) |
2264 |
{ |
2265 |
{ |
2265 |
ushort x = *rm; |
2266 |
uint16_t x = *rm; |
2266 |
x = lstl(x); // convert to intel endianess |
2267 |
x = lstl(x); // convert to intel endianess |
2267 |
*rm = x; |
2268 |
*rm = x; |
2268 |
} |
2269 |
} |
Lines 2272-2290
Link Here
|
2272 |
rm = map_fg; |
2273 |
rm = map_fg; |
2273 |
for (;t;t--,rm++) |
2274 |
for (;t;t--,rm++) |
2274 |
{ |
2275 |
{ |
2275 |
ushort x = *rm; |
2276 |
uint16_t x = *rm; |
2276 |
x = lstl( x ); // convert to intel endianess |
2277 |
x = lstl( x ); // convert to intel endianess |
2277 |
*rm = x; |
2278 |
*rm = x; |
2278 |
} |
2279 |
} |
2279 |
|
2280 |
|
2280 |
fp->write_long( bg_width ); |
2281 |
fp->write_uint32( bg_width ); |
2281 |
fp->write_long( bg_height ); |
2282 |
fp->write_uint32( bg_height ); |
2282 |
t = bg_width * bg_height; |
2283 |
t = bg_width * bg_height; |
2283 |
rm = map_bg; |
2284 |
rm = map_bg; |
2284 |
|
2285 |
|
2285 |
for (;t;t--,rm++) |
2286 |
for (;t;t--,rm++) |
2286 |
{ |
2287 |
{ |
2287 |
ushort x=*rm; |
2288 |
uint16_t x=*rm; |
2288 |
x = lstl( x ); // convert to intel endianess |
2289 |
x = lstl( x ); // convert to intel endianess |
2289 |
*rm = x; |
2290 |
*rm = x; |
2290 |
} |
2291 |
} |
Lines 2295-2301
Link Here
|
2295 |
|
2296 |
|
2296 |
for (;t;t--,rm++) |
2297 |
for (;t;t--,rm++) |
2297 |
{ |
2298 |
{ |
2298 |
ushort x = *rm; |
2299 |
uint16_t x = *rm; |
2299 |
x = lstl( x ); // convert to intel endianess |
2300 |
x = lstl( x ); // convert to intel endianess |
2300 |
*rm = x; |
2301 |
*rm = x; |
2301 |
} |
2302 |
} |
Lines 2366-2378
Link Here
|
2366 |
fg_height=height; |
2367 |
fg_height=height; |
2367 |
calc_bgsize(fg_width,fg_height,bg_width,bg_height); |
2368 |
calc_bgsize(fg_width,fg_height,bg_width,bg_height); |
2368 |
|
2369 |
|
2369 |
map_bg=(unsigned short *)jmalloc(sizeof(short)*bg_width*bg_height,"map bg"); |
2370 |
map_bg=(uint16_t *)jmalloc(sizeof(int16_t)*bg_width*bg_height,"map bg"); |
2370 |
map_fg=(unsigned short *)jmalloc(sizeof(short)*fg_width*fg_height,"map fg"); |
2371 |
map_fg=(uint16_t *)jmalloc(sizeof(int16_t)*fg_width*fg_height,"map fg"); |
2371 |
|
2372 |
|
2372 |
|
2373 |
|
2373 |
|
2374 |
|
2374 |
memset(map_bg,0,sizeof(short)*bg_width*bg_height); |
2375 |
memset(map_bg,0,sizeof(int16_t)*bg_width*bg_height); |
2375 |
memset(map_fg,0,sizeof(short)*fg_width*fg_height); |
2376 |
memset(map_fg,0,sizeof(int16_t)*fg_width*fg_height); |
2376 |
|
2377 |
|
2377 |
int i; |
2378 |
int i; |
2378 |
for (i=0;i<fg_width;i++) |
2379 |
for (i=0;i<fg_width;i++) |
Lines 2575-2583
Link Here
|
2575 |
return me; |
2576 |
return me; |
2576 |
} |
2577 |
} |
2577 |
|
2578 |
|
2578 |
game_object *level::find_object(long x, long y) |
2579 |
game_object *level::find_object(int32_t x, int32_t y) |
2579 |
{ |
2580 |
{ |
2580 |
long x1,y1,x2,y2; |
2581 |
int32_t x1,y1,x2,y2; |
2581 |
game_object *o=first; |
2582 |
game_object *o=first; |
2582 |
for (;o;o=o->next) |
2583 |
for (;o;o=o->next) |
2583 |
{ |
2584 |
{ |
Lines 2588-2610
Link Here
|
2588 |
return NULL; |
2589 |
return NULL; |
2589 |
} |
2590 |
} |
2590 |
|
2591 |
|
2591 |
long last_tile_hit_x,last_tile_hit_y; |
2592 |
int32_t last_tile_hit_x,last_tile_hit_y; |
2592 |
|
2593 |
|
2593 |
#define remapx(x) (x==0 ? -1 : x==tl-1 ? tl+1 : x) |
2594 |
#define remapx(x) (x==0 ? -1 : x==tl-1 ? tl+1 : x) |
2594 |
#define remapy(y) (y==0 ? -1 : y==th-1 ? th+1 : y) |
2595 |
#define remapy(y) (y==0 ? -1 : y==th-1 ? th+1 : y) |
2595 |
|
2596 |
|
2596 |
void level::foreground_intersect(long x1, long y1, long &x2, long &y2) |
2597 |
void level::foreground_intersect(int32_t x1, int32_t y1, int32_t &x2, int32_t &y2) |
2597 |
{ |
2598 |
{ |
2598 |
/* if (x1==x2) |
2599 |
/* if (x1==x2) |
2599 |
{ vforeground_intersect(x1,y1,y2); |
2600 |
{ vforeground_intersect(x1,y1,y2); |
2600 |
return ; |
2601 |
return ; |
2601 |
} */ |
2602 |
} */ |
2602 |
|
2603 |
|
2603 |
long tl=the_game->ftile_width(),th=the_game->ftile_height(), |
2604 |
int32_t tl=the_game->ftile_width(),th=the_game->ftile_height(), |
2604 |
j, |
2605 |
j, |
2605 |
xp1,yp1,xp2,yp2, // starting and ending points of block line segment |
2606 |
xp1,yp1,xp2,yp2, // starting and ending points of block line segment |
2606 |
swap; // temp var |
2607 |
swap; // temp var |
2607 |
long blockx1,blocky1,blockx2,blocky2,block,bx,by; |
2608 |
int32_t blockx1,blocky1,blockx2,blocky2,block,bx,by; |
2608 |
point_list *block_list; |
2609 |
point_list *block_list; |
2609 |
unsigned char *bdat; |
2610 |
unsigned char *bdat; |
2610 |
|
2611 |
|
Lines 2641-2647
Link Here
|
2641 |
unsigned char total=block_list->tot; |
2642 |
unsigned char total=block_list->tot; |
2642 |
bdat=block_list->data; |
2643 |
bdat=block_list->data; |
2643 |
unsigned char *ins=f->points->inside; |
2644 |
unsigned char *ins=f->points->inside; |
2644 |
long xo=bx*tl,yo=by*th; |
2645 |
int32_t xo=bx*tl,yo=by*th; |
2645 |
for (j=0;j<total-1;j++,ins++) |
2646 |
for (j=0;j<total-1;j++,ins++) |
2646 |
{ |
2647 |
{ |
2647 |
// find the starting and ending points for this segment |
2648 |
// find the starting and ending points for this segment |
Lines 2655-2661
Link Here
|
2655 |
yp2=yo+remapy(bdat[1]); |
2656 |
yp2=yo+remapy(bdat[1]); |
2656 |
|
2657 |
|
2657 |
|
2658 |
|
2658 |
long ox2=x2,oy2=y2; |
2659 |
int32_t ox2=x2,oy2=y2; |
2659 |
if (*ins) |
2660 |
if (*ins) |
2660 |
setback_intersect(x1,y1,x2,y2,xp1,yp1,xp2,yp2,1); |
2661 |
setback_intersect(x1,y1,x2,y2,xp1,yp1,xp2,yp2,1); |
2661 |
else |
2662 |
else |
Lines 2673-2684
Link Here
|
2673 |
} |
2674 |
} |
2674 |
|
2675 |
|
2675 |
|
2676 |
|
2676 |
void level::vforeground_intersect(long x1, long y1, long &y2) |
2677 |
void level::vforeground_intersect(int32_t x1, int32_t y1, int32_t &y2) |
2677 |
{ |
2678 |
{ |
2678 |
long tl=f_wid,th=f_hi, |
2679 |
int32_t tl=f_wid,th=f_hi, |
2679 |
j, |
2680 |
j, |
2680 |
xp1,yp1,xp2,yp2; // starting and ending points of block line segment temp var |
2681 |
xp1,yp1,xp2,yp2; // starting and ending points of block line segment temp var |
2681 |
long blocky1,blocky2,block,bx,by,checkx; |
2682 |
int32_t blocky1,blocky2,block,bx,by,checkx; |
2682 |
point_list *block_list; |
2683 |
point_list *block_list; |
2683 |
unsigned char *bdat; |
2684 |
unsigned char *bdat; |
2684 |
|
2685 |
|
Lines 2716-2722
Link Here
|
2716 |
bdat=block_list->data; |
2717 |
bdat=block_list->data; |
2717 |
unsigned char *ins=f->points->inside; |
2718 |
unsigned char *ins=f->points->inside; |
2718 |
|
2719 |
|
2719 |
// long xo=bx*tl,yo=by*th; |
2720 |
// int32_t xo=bx*tl,yo=by*th; |
2720 |
for (j=0;j<total-1;j++,ins++) |
2721 |
for (j=0;j<total-1;j++,ins++) |
2721 |
{ |
2722 |
{ |
2722 |
// find the starting and ending points for this segment |
2723 |
// find the starting and ending points for this segment |
Lines 2730-2736
Link Here
|
2730 |
yp2=remapy(bdat[1]); |
2731 |
yp2=remapy(bdat[1]); |
2731 |
|
2732 |
|
2732 |
|
2733 |
|
2733 |
long oy2=y2; |
2734 |
int32_t oy2=y2; |
2734 |
if (*ins) |
2735 |
if (*ins) |
2735 |
setback_intersect(checkx,y1,checkx,y2,xp1,yp1,xp2,yp2,1); |
2736 |
setback_intersect(checkx,y1,checkx,y2,xp1,yp1,xp2,yp2,1); |
2736 |
else |
2737 |
else |
Lines 2747-2753
Link Here
|
2747 |
|
2748 |
|
2748 |
|
2749 |
|
2749 |
|
2750 |
|
2750 |
void level::send_signal(long signal) |
2751 |
void level::send_signal(int32_t signal) |
2751 |
{ |
2752 |
{ |
2752 |
if (signal) // signal 0 is never sent! |
2753 |
if (signal) // signal 0 is never sent! |
2753 |
{ |
2754 |
{ |
Lines 2760-2766
Link Here
|
2760 |
|
2761 |
|
2761 |
int level::crush(game_object *by_who, int xamount, int yamount) |
2762 |
int level::crush(game_object *by_who, int xamount, int yamount) |
2762 |
{ |
2763 |
{ |
2763 |
long xv,yv,crushed=0; |
2764 |
int32_t xv,yv,crushed=0; |
2764 |
game_object *o=first_active; |
2765 |
game_object *o=first_active; |
2765 |
for (;o;o=o->next_active) |
2766 |
for (;o;o=o->next_active) |
2766 |
{ |
2767 |
{ |
Lines 2797-2810
Link Here
|
2797 |
int level::platform_push(game_object *by_who, int xamount, int yamount) |
2798 |
int level::platform_push(game_object *by_who, int xamount, int yamount) |
2798 |
{ |
2799 |
{ |
2799 |
int failed=0; |
2800 |
int failed=0; |
2800 |
long xv,yv; |
2801 |
int32_t xv,yv; |
2801 |
game_object *o=first_active; |
2802 |
game_object *o=first_active; |
2802 |
for (;o;o=o->next_active) |
2803 |
for (;o;o=o->next_active) |
2803 |
{ |
2804 |
{ |
2804 |
if (o->is_playable() && o->state!=dieing && o->state!=dead) |
2805 |
if (o->is_playable() && o->state!=dieing && o->state!=dead) |
2805 |
{ |
2806 |
{ |
2806 |
// check to see if the platform is going up and will run into us. |
2807 |
// check to see if the platform is going up and will run into us. |
2807 |
long tvx,tvy; |
2808 |
int32_t tvx,tvy; |
2808 |
if (yamount<0) |
2809 |
if (yamount<0) |
2809 |
{ |
2810 |
{ |
2810 |
tvx=-xamount; |
2811 |
tvx=-xamount; |
Lines 2847-2853
Link Here
|
2847 |
|
2848 |
|
2848 |
int level::push_characters(game_object *by_who, int xamount, int yamount) |
2849 |
int level::push_characters(game_object *by_who, int xamount, int yamount) |
2849 |
{ |
2850 |
{ |
2850 |
long xv,yv; |
2851 |
int32_t xv,yv; |
2851 |
int failed=0; |
2852 |
int failed=0; |
2852 |
game_object *o=first_active; |
2853 |
game_object *o=first_active; |
2853 |
for (;o;o=o->next_active) |
2854 |
for (;o;o=o->next_active) |
Lines 2856-2862
Link Here
|
2856 |
{ |
2857 |
{ |
2857 |
xv=-xamount; |
2858 |
xv=-xamount; |
2858 |
yv=-yamount; |
2859 |
yv=-yamount; |
2859 |
long tvx,tvy; |
2860 |
int32_t tvx,tvy; |
2860 |
if (xv>0) tvx=xv+1; else if (xv<0) tvx=xv-1; else tvx=0; |
2861 |
if (xv>0) tvx=xv+1; else if (xv<0) tvx=xv-1; else tvx=0; |
2861 |
if (yv>0) tvy=yv+1; else if (yv<0) tvx=yv-1; else tvy=0; |
2862 |
if (yv>0) tvy=yv+1; else if (yv<0) tvx=yv-1; else tvy=0; |
2862 |
if (o->try_move(o->x+xamount,o->y+yamount,tvx,tvy,3)==by_who) |
2863 |
if (o->try_move(o->x+xamount,o->y+yamount,tvx,tvy,3)==by_who) |
Lines 2876-2882
Link Here
|
2876 |
|
2877 |
|
2877 |
game_object *level::find_xrange(int x, int y, int type, int xd) |
2878 |
game_object *level::find_xrange(int x, int y, int type, int xd) |
2878 |
{ |
2879 |
{ |
2879 |
long find_ydist=100000; |
2880 |
int32_t find_ydist=100000; |
2880 |
game_object *find=NULL; |
2881 |
game_object *find=NULL; |
2881 |
game_object *o=first_active; |
2882 |
game_object *o=first_active; |
2882 |
for (;o;o=o->next_active) |
2883 |
for (;o;o=o->next_active) |
Lines 2899-2905
Link Here
|
2899 |
|
2900 |
|
2900 |
game_object *level::find_xclosest(int x, int y, int type, game_object *who) |
2901 |
game_object *level::find_xclosest(int x, int y, int type, game_object *who) |
2901 |
{ |
2902 |
{ |
2902 |
long find_ydist=100000,find_xdist=0xffffff; |
2903 |
int32_t find_ydist=100000,find_xdist=0xffffff; |
2903 |
game_object *find=NULL; |
2904 |
game_object *find=NULL; |
2904 |
game_object *o=first_active; |
2905 |
game_object *o=first_active; |
2905 |
for (;o;o=o->next_active) |
2906 |
for (;o;o=o->next_active) |
Lines 2929-2935
Link Here
|
2929 |
|
2930 |
|
2930 |
game_object *level::find_closest(int x, int y, int type, game_object *who) |
2931 |
game_object *level::find_closest(int x, int y, int type, game_object *who) |
2931 |
{ |
2932 |
{ |
2932 |
long find_dist=100000; |
2933 |
int32_t find_dist=100000; |
2933 |
game_object *find=NULL; |
2934 |
game_object *find=NULL; |
2934 |
game_object *o=first_active; |
2935 |
game_object *o=first_active; |
2935 |
for (;o;o=o->next_active) |
2936 |
for (;o;o=o->next_active) |
Lines 2984-2990
Link Here
|
2984 |
return l; |
2985 |
return l; |
2985 |
} |
2986 |
} |
2986 |
|
2987 |
|
2987 |
void level::hurt_radius(long x, long y,long r, long m, game_object *from, game_object *exclude, |
2988 |
void level::hurt_radius(int32_t x, int32_t y,int32_t r, int32_t m, game_object *from, game_object *exclude, |
2988 |
int max_push) |
2989 |
int max_push) |
2989 |
{ |
2990 |
{ |
2990 |
if (r<1) return ; // avoid dev vy zero |
2991 |
if (r<1) return ; // avoid dev vy zero |
Lines 2993-3000
Link Here
|
2993 |
{ |
2994 |
{ |
2994 |
if (o!=exclude && o->hurtable()) |
2995 |
if (o!=exclude && o->hurtable()) |
2995 |
{ |
2996 |
{ |
2996 |
long y1=o->y,y2=o->y-o->picture()->height(); |
2997 |
int32_t y1=o->y,y2=o->y-o->picture()->height(); |
2997 |
long cx=abs(o->x-x),cy1=abs(y1-y),d1,d2,cy2=abs(y2-y); |
2998 |
int32_t cx=abs(o->x-x),cy1=abs(y1-y),d1,d2,cy2=abs(y2-y); |
2998 |
if (cx<cy1) |
2999 |
if (cx<cy1) |
2999 |
d1=cx+cy1-(cx>>1); |
3000 |
d1=cx+cy1-(cx>>1); |
3000 |
else d1=cx+cy1-(cy1>>1); |
3001 |
else d1=cx+cy1-(cy1>>1); |
Lines 3055-3061
Link Here
|
3055 |
{ |
3056 |
{ |
3056 |
if (v!=exclude) |
3057 |
if (v!=exclude) |
3057 |
{ |
3058 |
{ |
3058 |
long cx=abs(v->x_center()-o->x),cy=abs(v->y_center()-o->y),d; |
3059 |
int32_t cx=abs(v->x_center()-o->x),cy=abs(v->y_center()-o->y),d; |
3059 |
if (cx<cy) |
3060 |
if (cx<cy) |
3060 |
d=cx+cy-(cx>>1); |
3061 |
d=cx+cy-(cx>>1); |
3061 |
else d=cx+cy-(cy>>1); |
3062 |
else d=cx+cy-(cy>>1); |
Lines 3151-3165
Link Here
|
3151 |
} |
3152 |
} |
3152 |
|
3153 |
|
3153 |
|
3154 |
|
3154 |
game_object *level::find_object_in_area(long x, long y, long x1, long y1, long x2, long y2, |
3155 |
game_object *level::find_object_in_area(int32_t x, int32_t y, int32_t x1, int32_t y1, int32_t x2, int32_t y2, |
3155 |
Cell *list, game_object *exclude) |
3156 |
Cell *list, game_object *exclude) |
3156 |
{ |
3157 |
{ |
3157 |
game_object *closest=NULL; |
3158 |
game_object *closest=NULL; |
3158 |
long closest_distance=0xfffffff,distance,xo,yo; |
3159 |
int32_t closest_distance=0xfffffff,distance,xo,yo; |
3159 |
game_object *o=first_active; |
3160 |
game_object *o=first_active; |
3160 |
for (;o;o=o->next_active) |
3161 |
for (;o;o=o->next_active) |
3161 |
{ |
3162 |
{ |
3162 |
long xp1,yp1,xp2,yp2; |
3163 |
int32_t xp1,yp1,xp2,yp2; |
3163 |
o->picture_space(xp1,yp1,xp2,yp2); |
3164 |
o->picture_space(xp1,yp1,xp2,yp2); |
3164 |
|
3165 |
|
3165 |
|
3166 |
|
Lines 3187-3201
Link Here
|
3187 |
|
3188 |
|
3188 |
|
3189 |
|
3189 |
|
3190 |
|
3190 |
game_object *level::find_object_in_angle(long x, long y, long start_angle, long end_angle, |
3191 |
game_object *level::find_object_in_angle(int32_t x, int32_t y, int32_t start_angle, int32_t end_angle, |
3191 |
void *list, game_object *exclude) |
3192 |
void *list, game_object *exclude) |
3192 |
{ |
3193 |
{ |
3193 |
game_object *closest=NULL; |
3194 |
game_object *closest=NULL; |
3194 |
long closest_distance=0xfffffff,distance,xo,yo; |
3195 |
int32_t closest_distance=0xfffffff,distance,xo,yo; |
3195 |
game_object *o=first_active; |
3196 |
game_object *o=first_active; |
3196 |
for (;o;o=o->next_active) |
3197 |
for (;o;o=o->next_active) |
3197 |
{ |
3198 |
{ |
3198 |
long angle=lisp_atan2(o->y-y,o->x-x); |
3199 |
int32_t angle=lisp_atan2(o->y-y,o->x-x); |
3199 |
if (((start_angle<=end_angle && (angle>=start_angle && angle<=end_angle)) |
3200 |
if (((start_angle<=end_angle && (angle>=start_angle && angle<=end_angle)) |
3200 |
|| (start_angle>end_angle && (angle>=start_angle || angle<=end_angle))) |
3201 |
|| (start_angle>end_angle && (angle>=start_angle || angle<=end_angle))) |
3201 |
&& o!=exclude) |
3202 |
&& o!=exclude) |
Lines 3249-3263
Link Here
|
3249 |
game_object *o=first; |
3250 |
game_object *o=first; |
3250 |
for (;o;o=o->next) |
3251 |
for (;o;o=o->next) |
3251 |
{ |
3252 |
{ |
3252 |
fprintf(fp,"%3d %s %4ld %4ld %4ld %4ld %04d\n",i++,object_names[o->otype],o->x,o->y, |
3253 |
fprintf(fp,"%3d %s %4ld %4ld %4ld %4ld %04d\n",i++,object_names[o->otype],(long)o->x,(long)o->y, |
3253 |
o->xvel(),o->yvel(),o->current_frame); |
3254 |
(long)o->xvel(),(long)o->yvel(),o->current_frame); |
3254 |
} |
3255 |
} |
3255 |
fclose(fp); |
3256 |
fclose(fp); |
3256 |
} |
3257 |
} |
3257 |
} |
3258 |
} |
3258 |
|
3259 |
|
3259 |
|
3260 |
|
3260 |
area_controller::area_controller(long X, long Y, long W, long H, area_controller *Next) |
3261 |
area_controller::area_controller(int32_t X, int32_t Y, int32_t W, int32_t H, area_controller *Next) |
3261 |
{ |
3262 |
{ |
3262 |
x=X; y=Y; w=W; h=H; |
3263 |
x=X; y=Y; w=W; h=H; |
3263 |
next=Next; active=0; |
3264 |
next=Next; active=0; |