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;
|