Free Hero Mesh

Check-in [1939e893b0]
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:Fix the level conversion/loading by changing the MRU logic slightly.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 1939e893b0522cc4c8bbf61049ddcf4cc8ec27fd
User & Date: user on 2020-11-22 02:05:24
Other Links: manifest | tags
Context
2020-11-22
04:29
Implement level selection in game play mode (not yet complete; needs to initialize the level too), and add some more keyboard commands to the class selection menu in the editor. check-in: c1e8833d15 user: user tags: trunk
02:05
Fix the level conversion/loading by changing the MRU logic slightly. check-in: 1939e893b0 user: user tags: trunk
2020-11-19
00:00
Correct a mistake in the level conversion check-in: 086b55093c user: user tags: trunk
Changes

Modified main.c from [eeee5538b3] to [fec4beb6eb].

248
249
250
251
252
253
254

255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
      if(p>=end) goto bad1;
      z=*p++;
      if(z==0xFF) break;
      if(z&0x20) x=*p++;
      if(z&0x10) y=*p++;
      if(z&0x40) x++;
      if(!x || !y || x>pfwidth || y>pfheight) goto bad2;

      if(z&0x80) {
        // MRU
        n=playfield[x+y*64-65]==VOIDLINK?0:1;
        if(mru[n]==VOIDLINK) goto bad1;
        o=objalloc(objects[mru[n]]->class);
        if(o==VOIDLINK) goto bad3;
        objects[o]->image=objects[mru[n]]->image;
        objects[o]->misc1=objects[mru[n]]->misc1;
        objects[o]->misc2=objects[mru[n]]->misc2;
        objects[o]->misc3=objects[mru[n]]->misc3;
        objects[o]->dir=objects[mru[n]]->dir;
        objects[o]->x=x;
        objects[o]->y=y;
        pflink(o);
        n=z&15;
      } else {
        // Not MRU
        n=playfield[x+y*64-65];
        n=n==VOIDLINK?0:objects[n]->down==VOIDLINK?1:2;
        i=*p++;
        i|=*p++<<8;
        o=objalloc(i&0x3FFF);
        if(o==VOIDLINK) goto bad3;
        if(n!=2) mru[n]=o;
        if(i&0x8000) {
          n=objects[o]->class;







>


<














<
<







248
249
250
251
252
253
254
255
256
257

258
259
260
261
262
263
264
265
266
267
268
269
270
271


272
273
274
275
276
277
278
      if(p>=end) goto bad1;
      z=*p++;
      if(z==0xFF) break;
      if(z&0x20) x=*p++;
      if(z&0x10) y=*p++;
      if(z&0x40) x++;
      if(!x || !y || x>pfwidth || y>pfheight) goto bad2;
      n=z&0x70?0:1;
      if(z&0x80) {
        // MRU

        if(mru[n]==VOIDLINK) goto bad1;
        o=objalloc(objects[mru[n]]->class);
        if(o==VOIDLINK) goto bad3;
        objects[o]->image=objects[mru[n]]->image;
        objects[o]->misc1=objects[mru[n]]->misc1;
        objects[o]->misc2=objects[mru[n]]->misc2;
        objects[o]->misc3=objects[mru[n]]->misc3;
        objects[o]->dir=objects[mru[n]]->dir;
        objects[o]->x=x;
        objects[o]->y=y;
        pflink(o);
        n=z&15;
      } else {
        // Not MRU


        i=*p++;
        i|=*p++<<8;
        o=objalloc(i&0x3FFF);
        if(o==VOIDLINK) goto bad3;
        if(n!=2) mru[n]=o;
        if(i&0x8000) {
          n=objects[o]->class;

Modified mbtofhm.c from [75af1cacc3] to [ea176bca7b].

942
943
944
945
946
947
948








949
950
951
952
953
954
955
  fread(mru,1,32,stdin); // Skip border colours
  fread(buf,1,2,stdin); // Skip border colours
  mru[0x04]=mru[0x14]=255;
  n=fgetc(stdin);
  n|=fgetc(stdin)<<8;
  x=q=r=0;
  y=1;








  // Free Hero Mesh level format for objects:
  //   * bit flags (or 0xFF for end):
  //     bit7 = MRU (omit everything but position)
  //     bit6 = Next position
  //     bit5 = New X position
  //     bit4 = New Y position
  //     bit3 = Has MiscVars (RLE in case of MRU)







>
>
>
>
>
>
>
>







942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
  fread(mru,1,32,stdin); // Skip border colours
  fread(buf,1,2,stdin); // Skip border colours
  mru[0x04]=mru[0x14]=255;
  n=fgetc(stdin);
  n|=fgetc(stdin)<<8;
  x=q=r=0;
  y=1;
  // Hero Mesh level format for objects:
  //   0-1    Class
  //   2-3    CurImage
  //   4      LastDir
  //   5      Misc Types
  //   6-7    X
  //   8-9    Y
  //   10-15  Misc1,Misc2,Misc3
  // Free Hero Mesh level format for objects:
  //   * bit flags (or 0xFF for end):
  //     bit7 = MRU (omit everything but position)
  //     bit6 = Next position
  //     bit5 = New X position
  //     bit4 = New Y position
  //     bit3 = Has MiscVars (RLE in case of MRU)
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
    ++*buf;
    if(!*buf) ++buf[1];
    mru[0x06]=mru[0x16]=buf[6];
    mru[0x08]=mru[0x18]=buf[8];
    i=0;
    if(buf[6]==x+1) i|=0x40; else if(buf[6]!=x) i|=0x20;
    if(buf[8]!=y) i|=0x10;
    if(x==buf[6] && y==buf[8]) q+=16; else q=0;
    if(q<32 && !memcmp(mru+q,buf,16)) {
      i|=0x80;
    } else {
      i|=buf[4]&7;
      if(buf[5] || memcmp(buf+10,"\0\0\0\0\0\0",6)) i|=0x08;
      if(q<32) memcpy(mru+q,buf,16);
    }







|







977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
    ++*buf;
    if(!*buf) ++buf[1];
    mru[0x06]=mru[0x16]=buf[6];
    mru[0x08]=mru[0x18]=buf[8];
    i=0;
    if(buf[6]==x+1) i|=0x40; else if(buf[6]!=x) i|=0x20;
    if(buf[8]!=y) i|=0x10;
    q=i&0x70?0:16;
    if(q<32 && !memcmp(mru+q,buf,16)) {
      i|=0x80;
    } else {
      i|=buf[4]&7;
      if(buf[5] || memcmp(buf+10,"\0\0\0\0\0\0",6)) i|=0x08;
      if(q<32) memcpy(mru+q,buf,16);
    }