25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
Value misc1,misc2,misc3;
} MRU;
#define MRUCOUNT 32
static MRU mru[MRUCOUNT];
static int curmru;
static char*solution_data;
static int solution_length;
static inline void discard_solution(void) {
if(solution_data) {
sqlite3_free(solution_data);
solution_data=0;
solution_length=0;
}
}
static void rewrite_class_def(void) {
Uint32 i,n;
|
|
|
|
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
Value misc1,misc2,misc3;
} MRU;
#define MRUCOUNT 32
static MRU mru[MRUCOUNT];
static int curmru;
static char*solution_data;
static size_t solution_length;
static inline void discard_solution(void) {
if(solution_data) {
free(solution_data);
solution_data=0;
solution_length=0;
}
}
static void rewrite_class_def(void) {
Uint32 i,n;
|
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
|
char d=0;
int x,y;
Object*o;
FILE*fp;
size_t size=0;
char*buf=0;
char*p;
sqlite3_str*sol=0;
Value v;
if(!cmd || !*cmd) return;
fp=main_options['i']?stdin:popen(cmd,"r");
if(!fp) {
screen_message("Cannot open pipe");
return;
}
|
|
|
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
|
char d=0;
int x,y;
Object*o;
FILE*fp;
size_t size=0;
char*buf=0;
char*p;
FILE*sol=0;
Value v;
if(!cmd || !*cmd) return;
fp=main_options['i']?stdin:popen(cmd,"r");
if(!fp) {
screen_message("Cannot open pipe");
return;
}
|
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
|
levelstrings=realloc(levelstrings,(nlevelstrings+1)*sizeof(unsigned char*));
if(!levelstrings) fatal("Allocation failed\n");
levelstrings[nlevelstrings++]=import_string(p+1);
}
break;
case '\'':
if(!sol) {
sol=sqlite3_str_new(userdb);
sqlite3_str_appendchar(sol,3,0); // append level version (will be overwritten later) and flags
}
p=strchr(buf,' ');
if(p) {
*p=0;
p=import_numbers(p+1,&y,0);
if(!p || *p) goto bad;
} else {
y=1;
}
for(x=8;x<256;x++) {
if(heromesh_key_names[x] && !strcmp(buf+1,heromesh_key_names[x])) {
sqlite3_str_appendchar(sol,y,x);
break;
}
}
if(x==256) goto bad;
break;
case '=':
if(main_options['i']) goto done;
|
|
>
|
|
|
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
|
levelstrings=realloc(levelstrings,(nlevelstrings+1)*sizeof(unsigned char*));
if(!levelstrings) fatal("Allocation failed\n");
levelstrings[nlevelstrings++]=import_string(p+1);
}
break;
case '\'':
if(!sol) {
sol=open_memstream(&solution_data,&solution_length);
if(!sol) fatal("Allocation failed\n");
fwrite("\0\0",1,3,sol); // append level version (will be overwritten later) and flags
}
p=strchr(buf,' ');
if(p) {
*p=0;
p=import_numbers(p+1,&y,0);
if(!p || *p) goto bad;
} else {
y=1;
}
for(x=8;x<256;x++) {
if(heromesh_key_names[x] && !strcmp(buf+1,heromesh_key_names[x])) {
while(y-->0) encode_move(sol,x);
break;
}
}
if(x==256) goto bad;
break;
case '=':
if(main_options['i']) goto done;
|
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
|
}
}
done:
free(buf);
if(!main_options['i']) pclose(fp);
generation_number_inc=0;
if(sol) {
solution_length=sqlite3_str_length(sol);
solution_data=sqlite3_str_finish(sol);
if(!solution_data) fatal("Allocation failed");
}
}
static void new_level(void) {
sqlite3_stmt*st;
int i;
|
<
|
|
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
|
}
}
done:
free(buf);
if(!main_options['i']) pclose(fp);
generation_number_inc=0;
if(sol) {
fclose(sol);
if(!solution_data) fatal("Allocation failed");
}
}
static void new_level(void) {
sqlite3_stmt*st;
int i;
|