Free Hero Mesh

Diff
Login
This is a mirror of the main repository for Free Hero Mesh. New tickets and changes will not be accepted at this mirror.

Differences From Artifact [d2b7e53c78]:

To Artifact [009b283128]:


732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750

751
752
753
754

755
756
757
758
759
760
761
762
763
764
765

766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
static int move_dir(Uint32 from,Uint32 obj,Uint32 dir) {
  // This function is complicated, and there may be mistakes.
  Object*o;
  Object*oE;
  Object*oF;
  Uint32 objE,objF,objLF,objRF;
  Uint32 hit=0;
  Uint32 hF,vol;
  Value v;
  if(StackProtection()) Throw("Call stack overflow during movement");
  if(obj==VOIDLINK) return 0;
  o=objects[obj];
  o->dir=dir=resolve_dir(obj,dir);
  if(o->weight>o->inertia) goto fail;
  o->inertia-=o->weight;
  restart:
  if(hit&0x100000) dir=o->dir;
  objF=obj_dir(obj,dir);
  if(objF==VOIDLINK) goto fail;

  oF=objects[objF];
  hF=oF?height_at(oF->x,oF->y):0;
  if(dir&1) {
    // Diagonal movement

    objLF=obj_dir(obj,(dir+1)&7);
    objRF=obj_dir(obj,(dir-1)&7);
    vol=o->volume;
    if(objLF!=VOIDLINK) vol+=volume_at(objects[objLF]->x,objects[objLF]->y);
    if(objRF!=VOIDLINK) vol+=volume_at(objects[objRF]->x,objects[objRF]->y);
    if(vol<=max_volume) {
      objE=objF;
      while(objE!=VOIDLINK) {
        if(o->oflags&(OF_DESTROYED|OF_VISUALONLY)) break;
        oE=objects[objE];
        if(oE->height>0) {

          v=send_message(objE,obj,MSG_HIT,NVALUE(oE->x),NVALUE(oE->y),NVALUE(hit|0x80000));
          if(v.t) Throw("Type mismatch in HIT/HITBY");
          hit=v.u&(classes[o->class]->cflags&CF_COMPATIBLE?0xFC098F7F:-1);
          if(hit&8) goto fail;
          if(!(hit&0x11)) {
            v=send_message(obj,objE,MSG_HITBY,NVALUE(o->x),NVALUE(o->y),NVALUE(hit|0x80000));
            if(v.t) Throw("Type mismatch in HIT/HITBY");
            hit=v.u&(classes[oE->class]->cflags&CF_COMPATIBLE?0xFC098F7F:-1);
            if(hit&8) goto fail;
          }
        }
        objE=obj_below(objE);
      }
      if(!(hit&0x402008)) {
        if(hF<=o->climb || (hit&0x200000)) {
          if(hit&0x20000) goto success;
          if(!oF) goto fail;
          if(move_to(from,obj,oF->x,oF->y)) goto success; else goto fail;
        }
      }
    } else {
      // Volume is too much; hit the objects it won't go between
      if(o->oflags&(OF_DESTROYED|OF_VISUALONLY)) goto fail;
      objE=objLF;
      while(objE!=VOIDLINK) {
        oE=objects[objE];







|











>

|


>











>
|

|


|

|





|
<
|
|
|
<







732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782

783
784
785

786
787
788
789
790
791
792
static int move_dir(Uint32 from,Uint32 obj,Uint32 dir) {
  // This function is complicated, and there may be mistakes.
  Object*o;
  Object*oE;
  Object*oF;
  Uint32 objE,objF,objLF,objRF;
  Uint32 hit=0;
  Uint32 vol;
  Value v;
  if(StackProtection()) Throw("Call stack overflow during movement");
  if(obj==VOIDLINK) return 0;
  o=objects[obj];
  o->dir=dir=resolve_dir(obj,dir);
  if(o->weight>o->inertia) goto fail;
  o->inertia-=o->weight;
  restart:
  if(hit&0x100000) dir=o->dir;
  objF=obj_dir(obj,dir);
  if(objF==VOIDLINK) goto fail;
  if(hit) hit=(hit&0x0C000000)|0x800;
  oF=objects[objF];
  if(height_at(oF->x,oF->y)<=o->climb) hit|=0x200000;
  if(dir&1) {
    // Diagonal movement
    hit|=0x80000;
    objLF=obj_dir(obj,(dir+1)&7);
    objRF=obj_dir(obj,(dir-1)&7);
    vol=o->volume;
    if(objLF!=VOIDLINK) vol+=volume_at(objects[objLF]->x,objects[objLF]->y);
    if(objRF!=VOIDLINK) vol+=volume_at(objects[objRF]->x,objects[objRF]->y);
    if(vol<=max_volume) {
      objE=objF;
      while(objE!=VOIDLINK) {
        if(o->oflags&(OF_DESTROYED|OF_VISUALONLY)) break;
        oE=objects[objE];
        if(oE->height>0) {
          hit&=0xFC287000;
          v=send_message(objE,obj,MSG_HIT,NVALUE(oE->x),NVALUE(oE->y),NVALUE(hit));
          if(v.t) Throw("Type mismatch in HIT/HITBY");
          hit|=v.u&(classes[o->class]->cflags&CF_COMPATIBLE?0xFC098F7F:-1);
          if(hit&8) goto fail;
          if(!(hit&0x11)) {
            v=send_message(obj,objE,MSG_HITBY,NVALUE(o->x),NVALUE(o->y),NVALUE(hit));
            if(v.t) Throw("Type mismatch in HIT/HITBY");
            hit|=v.u&(classes[oE->class]->cflags&CF_COMPATIBLE?0xFC098F7F:-1);
            if(hit&8) goto fail;
          }
        }
        objE=obj_below(objE);
      }
      if((hit&0x200000) && !(hit&0x402008)) {

        if(hit&0x20000) goto success;
        if(!oF) goto fail;
        if(move_to(from,obj,oF->x,oF->y)) goto success; else goto fail;

      }
    } else {
      // Volume is too much; hit the objects it won't go between
      if(o->oflags&(OF_DESTROYED|OF_VISUALONLY)) goto fail;
      objE=objLF;
      while(objE!=VOIDLINK) {
        oE=objects[objE];
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
          if(!(v.u&1)) v=send_message(obj,objE,MSG_HITBY,NVALUE(o->x),NVALUE(o->y),NVALUE(v.u|0x80008));
        }
        objE=obj_below(objE);
      }
    }
  } else {
    // Orthogonal movement
    if(hit) hit=(hit&0x0C000000)|0x800;
    if(!oF) goto fail;
    objE=objF;
    while(objE!=VOIDLINK) {
      if(o->oflags&(OF_DESTROYED|OF_VISUALONLY)) break;
      oE=objects[objE];
      if(oE->height>0) {
        hit&=~7;







<







807
808
809
810
811
812
813

814
815
816
817
818
819
820
          if(!(v.u&1)) v=send_message(obj,objE,MSG_HITBY,NVALUE(o->x),NVALUE(o->y),NVALUE(v.u|0x80008));
        }
        objE=obj_below(objE);
      }
    }
  } else {
    // Orthogonal movement

    if(!oF) goto fail;
    objE=objF;
    while(objE!=VOIDLINK) {
      if(o->oflags&(OF_DESTROYED|OF_VISUALONLY)) break;
      oE=objects[objE];
      if(oE->height>0) {
        hit&=~7;
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
        }
      }
      if(hit&0x400) goto fail;
      objE=obj_below(objE);
    }
    if(hit&0x2008) goto fail;
    if((hit&0x48000)==0x8000) goto restart;
    if(!(hit&0x400000)) {
      if(hF<=o->climb || (hit&0x200000)) {
        if(hit&0x20000) goto success;
        if(move_to(from,obj,oF->x,oF->y)) goto success; else goto fail;
      }
    }
    // Sliding
    if(hit&0x80) goto fail;
    hit|=0x10000;
    
  }
  fail: if(hit&0x1000) goto success; o->inertia=0; return 0;







|
<
|
|
<







845
846
847
848
849
850
851
852

853
854

855
856
857
858
859
860
861
        }
      }
      if(hit&0x400) goto fail;
      objE=obj_below(objE);
    }
    if(hit&0x2008) goto fail;
    if((hit&0x48000)==0x8000) goto restart;
    if((hit&0x200000) && !(hit&0x400000)) {

      if(hit&0x20000) goto success;
      if(move_to(from,obj,oF->x,oF->y)) goto success; else goto fail;

    }
    // Sliding
    if(hit&0x80) goto fail;
    hit|=0x10000;
    
  }
  fail: if(hit&0x1000) goto success; o->inertia=0; return 0;