Free Hero Mesh

Check-in [846874b02f]
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 version_change logic in edit.c to work with the new user state format. (It no longer works with the old format, although it will automatically be upgraded in game.c anyways, so it is unlikely to need to work with the old format.)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 846874b02fd33cff2fb89f771e2c9ffcce21f11a
User & Date: user on 2022-07-28 03:23:00
Other Links: manifest | tags
Context
2022-07-29
00:09
Add a few functions into picture.c for dealing with multibyte encodings and font sizes other than 8x8; however, this feature is not implemented yet, and only one of these functions is implemented so far. check-in: 07386d0511 user: user tags: trunk
2022-07-28
03:23
Fix the version_change logic in edit.c to work with the new user state format. (It no longer works with the old format, although it will automatically be upgraded in game.c anyways, so it is unlikely to need to work with the old format.) check-in: 846874b02f user: user tags: trunk
2022-07-21
23:39
Finish the implementation of multidependent pictures. check-in: 59c1955556 user: user tags: trunk
Changes

Modified edit.c from [6dfe3afa21] to [3f10c9de85].

101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122






123
124
125
126
127
128
129
  if(!size || !data) fatal("Error in string builder\n");
  write_lump(FIL_LEVEL,LUMP_CLASS_DEF,size,data);
  sqlite3_free(data);
}

static inline void version_change(void) {
  long sz=0;
  int n;
  unsigned char*buf=read_lump(FIL_SOLUTION,level_id,&sz);
  if(!buf) goto us;
  if(sz>2 && (buf[0]|(buf[1]<<8))==level_version) ++level_version;
  free(buf);
  us:
  // Set user state to unsolved, if applicable
  buf=read_userstate(FIL_LEVEL,level_id,&sz);
  if(!buf) return;
  if(sz>2) {
    n=(buf[sz-2]<<8)|buf[sz-1];
    if(sz-n>=6 && (buf[n+2]<<8)+buf[n+3]==level_version) {
      buf[n+2]=(level_version-1)>>8;
      buf[n+3]=level_version-1;
      write_userstate(FIL_LEVEL,level_id,sz,buf);






    }
  }
  free(buf);
}

static void save_obj(sqlite3_str*s,const Object*o,const Object**m,Uint8 x,Uint8 y) {
  static Uint8 r=0;







|








|
|
<
|
|
|
>
>
>
>
>
>







101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118

119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
  if(!size || !data) fatal("Error in string builder\n");
  write_lump(FIL_LEVEL,LUMP_CLASS_DEF,size,data);
  sqlite3_free(data);
}

static inline void version_change(void) {
  long sz=0;
  long n;
  unsigned char*buf=read_lump(FIL_SOLUTION,level_id,&sz);
  if(!buf) goto us;
  if(sz>2 && (buf[0]|(buf[1]<<8))==level_version) ++level_version;
  free(buf);
  us:
  // Set user state to unsolved, if applicable
  buf=read_userstate(FIL_LEVEL,level_id,&sz);
  if(!buf) return;
  if(sz>2 && !*buf) {
    for(n=1;n<sz-2;) {

      if(buf[n]==0x41) {
        memmove(buf+n,buf+n+3,sz-n-3);
        write_userstate(FIL_LEVEL,level_id,sz-3,buf);
        break;
      } else if(buf[n]<0x40) {
        n+=strnlen(buf+n,sz-n)+1;
      } else {
        n+=(buf[n]<0x80?3:buf[n]<0xC0?5:9);
      }
    }
  }
  free(buf);
}

static void save_obj(sqlite3_str*s,const Object*o,const Object**m,Uint8 x,Uint8 y) {
  static Uint8 r=0;