Free Hero Mesh

Check-in [d033ec4bd1]
Login
This is a mirror of the main repository for Free Hero Mesh. New tickets and changes will not be accepted at this mirror.
Overview
Comment:Make some corrections to the implementation of dead animations
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: d033ec4bd196c46ca9dd5ca4052400eeeba17a67
User & Date: user on 2021-03-20 04:36:55
Other Links: manifest | tags
Context
2021-03-21
03:51
Implement the .autoSave resource. check-in: 694a67346e user: user tags: trunk
2021-03-20
04:36
Make some corrections to the implementation of dead animations check-in: d033ec4bd1 user: user tags: trunk
02:26
Implement death animations check-in: 152aca780c user: user tags: trunk
Changes

Modified exec.c from [08725a980a] to [3e66eb8ad9].

35
36
37
38
39
40
41

42
43
44
45
46
47
48
Inventory*inventory;
Uint32 ninventory;
char**levelstrings;
Uint16 nlevelstrings;
Value*array_data;
Uint16 ndeadanim;
DeadAnimation*deadanim;


typedef struct {
  Uint16 msg;
  Uint32 from;
  Value arg1,arg2,arg3;
} MessageVars;








>







35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
Inventory*inventory;
Uint32 ninventory;
char**levelstrings;
Uint16 nlevelstrings;
Value*array_data;
Uint16 ndeadanim;
DeadAnimation*deadanim;
Uint8 no_dead_anim;

typedef struct {
  Uint16 msg;
  Uint32 from;
  Value arg1,arg2,arg3;
} MessageVars;

161
162
163
164
165
166
167

168
169
170
171
172
173
174
  return VOIDLINK;
}

#define animfree free

static void set_dead_animation(const Object*o) {
  DeadAnimation*d;

  deadanim=realloc(deadanim,(ndeadanim+1)*sizeof(DeadAnimation));
  if(!deadanim) fatal("Allocation failed\n");
  d=deadanim+ndeadanim++;
  d->class=o->class;
  d->x=o->x;
  d->y=o->y;
  d->s=o->anim->step[o->anim->vstep];







>







162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
  return VOIDLINK;
}

#define animfree free

static void set_dead_animation(const Object*o) {
  DeadAnimation*d;
  if(no_dead_anim) return;
  deadanim=realloc(deadanim,(ndeadanim+1)*sizeof(DeadAnimation));
  if(!deadanim) fatal("Allocation failed\n");
  d=deadanim+ndeadanim++;
  d->class=o->class;
  d->x=o->x;
  d->y=o->y;
  d->s=o->anim->step[o->anim->vstep];

Modified game.c from [6482a4e0d5] to [9b17d3be8b].

181
182
183
184
185
186
187

188
189
190
191
192
193
194
      draw_cell(d->x,d->y);
      if(!d->s.flag) continue;
      if(d->vimage<classes[d->class]->nimages)
       draw_picture((d->x-1)*picture_size+left_margin,(d->y-1)*picture_size,classes[d->class]->images[d->vimage]&0x7FFF);
      if(++d->vtime>=d->s.speed) {
        if(d->vimage==d->s.end) d->s.flag=0;
        if(d->s.end>=d->s.start) ++d->vimage; else --d->vimage;

      }
    }
    for(i=0;i<ndeadanim;i++) while(i<ndeadanim && !deadanim[i].s.flag) {
      draw_cell(deadanim[i].x,deadanim[i].y);
      if(i<ndeadanim-1) deadanim[i]=deadanim[ndeadanim-1];
      --ndeadanim;
    }







>







181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
      draw_cell(d->x,d->y);
      if(!d->s.flag) continue;
      if(d->vimage<classes[d->class]->nimages)
       draw_picture((d->x-1)*picture_size+left_margin,(d->y-1)*picture_size,classes[d->class]->images[d->vimage]&0x7FFF);
      if(++d->vtime>=d->s.speed) {
        if(d->vimage==d->s.end) d->s.flag=0;
        if(d->s.end>=d->s.start) ++d->vimage; else --d->vimage;
        d->vtime=0;
      }
    }
    for(i=0;i<ndeadanim;i++) while(i<ndeadanim && !deadanim[i].s.flag) {
      draw_cell(deadanim[i].x,deadanim[i].y);
      if(i<ndeadanim-1) deadanim[i]=deadanim[ndeadanim-1];
      --ndeadanim;
    }
679
680
681
682
683
684
685

686
687
688
689
690
691
692
      if(!number) return 1;
      if(number>replay_count) number=replay_count;
      if(number>=inputs_size) {
        inputs=realloc(inputs,inputs_size=number+1);
        if(!inputs) fatal("Allocation failed\n");
      }
      memcpy(inputs,replay_list,inputs_count=number);

      return 1;
    case '^<': // Rewind to mark
      number=replay_mark;
      goto restart;
    case '^>': // Replay to mark
      inputs_count=0;
      number=replay_mark-replay_pos;







>







680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
      if(!number) return 1;
      if(number>replay_count) number=replay_count;
      if(number>=inputs_size) {
        inputs=realloc(inputs,inputs_size=number+1);
        if(!inputs) fatal("Allocation failed\n");
      }
      memcpy(inputs,replay_list,inputs_count=number);
      no_dead_anim=1;
      return 1;
    case '^<': // Rewind to mark
      number=replay_mark;
      goto restart;
    case '^>': // Replay to mark
      inputs_count=0;
      number=replay_mark-replay_pos;
836
837
838
839
840
841
842
843
844
845

846
847
848
849
850
851
852
853
854
855
856
857
858
859
860

861
862
863
864
865
866
867
        if(i==-2) {
          main_options['e']=1;
          SDL_SetTimer(0,0);
          return;
        }
      replay:
        if(inputs_count) {
          //TODO: Check for solution replay
          for(i=0;i<inputs_count && !gameover;i++) if(inputs[i]) input_move(inputs[i]);
          inputs_count=0;

        }
        redraw_game();
        timerflag=0; // ensure we have not missed a timer event
        break;
    }
  }
  quit:
  save_replay();
  exit(0);
}

void run_auto_test(void) {
  Uint8 rc=0;
  int lvl,pro,i,n;
  const char*t;

  setbuf(stdout,0);
  solution_replay=1;
  optionquery[1]=Q_progress;
  t=xrm_get_resource(resourcedb,optionquery,optionquery,2);
  pro=t?strtol(t,0,10):0;
  if(main_options['t']) pro=0;
  optionquery[1]=Q_level;







<


>















>







838
839
840
841
842
843
844

845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
        if(i==-2) {
          main_options['e']=1;
          SDL_SetTimer(0,0);
          return;
        }
      replay:
        if(inputs_count) {

          for(i=0;i<inputs_count && !gameover;i++) if(inputs[i]) input_move(inputs[i]);
          inputs_count=0;
          no_dead_anim=0;
        }
        redraw_game();
        timerflag=0; // ensure we have not missed a timer event
        break;
    }
  }
  quit:
  save_replay();
  exit(0);
}

void run_auto_test(void) {
  Uint8 rc=0;
  int lvl,pro,i,n;
  const char*t;
  no_dead_anim=1;
  setbuf(stdout,0);
  solution_replay=1;
  optionquery[1]=Q_progress;
  t=xrm_get_resource(resourcedb,optionquery,optionquery,2);
  pro=t?strtol(t,0,10):0;
  if(main_options['t']) pro=0;
  optionquery[1]=Q_level;

Modified heromesh.h from [97efdb5c5e] to [75d4788d3e].

258
259
260
261
262
263
264

265
266
267
268
269
270
271
extern Inventory*inventory;
extern Uint32 ninventory;
extern char**levelstrings;
extern Uint16 nlevelstrings;
extern Value*array_data;
extern Uint16 ndeadanim;
extern DeadAnimation*deadanim;


const char*value_string_ptr(Value v);
void pfunlink(Uint32 n);
void pflink(Uint32 n);
Uint32 objalloc(Uint16 c);
void objtrash(Uint32 n);
void annihilate(void);







>







258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
extern Inventory*inventory;
extern Uint32 ninventory;
extern char**levelstrings;
extern Uint16 nlevelstrings;
extern Value*array_data;
extern Uint16 ndeadanim;
extern DeadAnimation*deadanim;
extern Uint8 no_dead_anim;

const char*value_string_ptr(Value v);
void pfunlink(Uint32 n);
void pflink(Uint32 n);
Uint32 objalloc(Uint16 c);
void objtrash(Uint32 n);
void annihilate(void);

Modified main.c from [23edf40a2c] to [45d9e047ec].

907
908
909
910
911
912
913

914
915
916
917
918
  set_tracing();
  annihilate();
  optionquery[1]=Q_level;
  if(level_ord=strtol(xrm_get_resource(resourcedb,optionquery,optionquery,2)?:"",0,10)) log_if_error(load_level(-level_ord));
  if(main_options['a']) run_auto_test();
  if(main_options['x']) {
    fprintf(stderr,"Ready for executing SQL statements.\n");

    do_sql_mode();
    return 0;
  }
  for(;;) { if(main_options['e']) run_editor(); else run_game(); }
}







>





907
908
909
910
911
912
913
914
915
916
917
918
919
  set_tracing();
  annihilate();
  optionquery[1]=Q_level;
  if(level_ord=strtol(xrm_get_resource(resourcedb,optionquery,optionquery,2)?:"",0,10)) log_if_error(load_level(-level_ord));
  if(main_options['a']) run_auto_test();
  if(main_options['x']) {
    fprintf(stderr,"Ready for executing SQL statements.\n");
    no_dead_anim=1;
    do_sql_mode();
    return 0;
  }
  for(;;) { if(main_options['e']) run_editor(); else run_game(); }
}