| 1 |
|
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
#include "angband.h" |
|---|
| 19 |
#include "tvalsval.h" |
|---|
| 20 |
#include "ui-menu.h" |
|---|
| 21 |
#include "cmds.h" |
|---|
| 22 |
#include "option.h" |
|---|
| 23 |
|
|---|
| 24 |
#define MAX_PANEL 12 |
|---|
| 25 |
|
|---|
| 26 |
|
|---|
| 27 |
#if 0 |
|---|
| 28 |
|
|---|
| 29 |
|
|---|
| 30 |
|
|---|
| 31 |
|
|---|
| 32 |
|
|---|
| 33 |
|
|---|
| 34 |
|
|---|
| 35 |
|
|---|
| 36 |
|
|---|
| 37 |
|
|---|
| 38 |
|
|---|
| 39 |
|
|---|
| 40 |
|
|---|
| 41 |
|
|---|
| 42 |
|
|---|
| 43 |
|
|---|
| 44 |
static s16b tokenize_whitespace(char *buf, s16b num, char **tokens) |
|---|
| 45 |
{ |
|---|
| 46 |
int k = 0; |
|---|
| 47 |
|
|---|
| 48 |
char *s = buf; |
|---|
| 49 |
|
|---|
| 50 |
|
|---|
| 51 |
|
|---|
| 52 |
while (k < num) |
|---|
| 53 |
{ |
|---|
| 54 |
char *t; |
|---|
| 55 |
|
|---|
| 56 |
|
|---|
| 57 |
for ( ; *s && isspace((unsigned char)*s); ++s) ; |
|---|
| 58 |
|
|---|
| 59 |
|
|---|
| 60 |
if (!*s) break; |
|---|
| 61 |
|
|---|
| 62 |
|
|---|
| 63 |
for (t = s; *t && !isspace((unsigned char)*t); ++t) ; |
|---|
| 64 |
|
|---|
| 65 |
|
|---|
| 66 |
if (*t) *t++ = '\0'; |
|---|
| 67 |
|
|---|
| 68 |
|
|---|
| 69 |
tokens[k++] = s; |
|---|
| 70 |
|
|---|
| 71 |
|
|---|
| 72 |
s = t; |
|---|
| 73 |
} |
|---|
| 74 |
|
|---|
| 75 |
|
|---|
| 76 |
return (k); |
|---|
| 77 |
} |
|---|
| 78 |
|
|---|
| 79 |
#endif |
|---|
| 80 |
|
|---|
| 81 |
|
|---|
| 82 |
|
|---|
| 83 |
|
|---|
| 84 |
|
|---|
| 85 |
|
|---|
| 86 |
|
|---|
| 87 |
|
|---|
| 88 |
|
|---|
| 89 |
|
|---|
| 90 |
|
|---|
| 91 |
|
|---|
| 92 |
|
|---|
| 93 |
|
|---|
| 94 |
|
|---|
| 95 |
|
|---|
| 96 |
|
|---|
| 97 |
|
|---|
| 98 |
s16b tokenize(char *buf, s16b num, char **tokens) |
|---|
| 99 |
{ |
|---|
| 100 |
int i = 0; |
|---|
| 101 |
|
|---|
| 102 |
char *s = buf; |
|---|
| 103 |
|
|---|
| 104 |
|
|---|
| 105 |
|
|---|
| 106 |
while (i < num - 1) |
|---|
| 107 |
{ |
|---|
| 108 |
char *t; |
|---|
| 109 |
|
|---|
| 110 |
|
|---|
| 111 |
for (t = s; *t; t++) |
|---|
| 112 |
{ |
|---|
| 113 |
|
|---|
| 114 |
if (*t == '\\') t++; |
|---|
| 115 |
|
|---|
| 116 |
|
|---|
| 117 |
else if (*t == ':') break; |
|---|
| 118 |
} |
|---|
| 119 |
|
|---|
| 120 |
|
|---|
| 121 |
if (!*t) break; |
|---|
| 122 |
|
|---|
| 123 |
|
|---|
| 124 |
*t++ = '\0'; |
|---|
| 125 |
|
|---|
| 126 |
|
|---|
| 127 |
tokens[i++] = s; |
|---|
| 128 |
|
|---|
| 129 |
|
|---|
| 130 |
s = t; |
|---|
| 131 |
} |
|---|
| 132 |
|
|---|
| 133 |
|
|---|
| 134 |
tokens[i++] = s; |
|---|
| 135 |
|
|---|
| 136 |
|
|---|
| 137 |
return (i); |
|---|
| 138 |
} |
|---|
| 139 |
|
|---|
| 140 |
|
|---|
| 141 |
|
|---|
| 142 |
|
|---|
| 143 |
|
|---|
| 144 |
|
|---|
| 145 |
|
|---|
| 146 |
|
|---|
| 147 |
|
|---|
| 148 |
|
|---|
| 149 |
|
|---|
| 150 |
|
|---|
| 151 |
|
|---|
| 152 |
|
|---|
| 153 |
|
|---|
| 154 |
|
|---|
| 155 |
|
|---|
| 156 |
|
|---|
| 157 |
|
|---|
| 158 |
|
|---|
| 159 |
|
|---|
| 160 |
|
|---|
| 161 |
|
|---|
| 162 |
|
|---|
| 163 |
|
|---|
| 164 |
|
|---|
| 165 |
|
|---|
| 166 |
|
|---|
| 167 |
|
|---|
| 168 |
|
|---|
| 169 |
|
|---|
| 170 |
|
|---|
| 171 |
|
|---|
| 172 |
|
|---|
| 173 |
|
|---|
| 174 |
|
|---|
| 175 |
|
|---|
| 176 |
|
|---|
| 177 |
|
|---|
| 178 |
|
|---|
| 179 |
|
|---|
| 180 |
|
|---|
| 181 |
|
|---|
| 182 |
|
|---|
| 183 |
|
|---|
| 184 |
|
|---|
| 185 |
|
|---|
| 186 |
|
|---|
| 187 |
|
|---|
| 188 |
|
|---|
| 189 |
|
|---|
| 190 |
|
|---|
| 191 |
|
|---|
| 192 |
|
|---|
| 193 |
|
|---|
| 194 |
|
|---|
| 195 |
|
|---|
| 196 |
|
|---|
| 197 |
|
|---|
| 198 |
|
|---|
| 199 |
|
|---|
| 200 |
|
|---|
| 201 |
|
|---|
| 202 |
|
|---|
| 203 |
|
|---|
| 204 |
|
|---|
| 205 |
errr process_pref_file_command(char *buf) |
|---|
| 206 |
{ |
|---|
| 207 |
long i, n1, n2, sq; |
|---|
| 208 |
|
|---|
| 209 |
char *zz[16]; |
|---|
| 210 |
|
|---|
| 211 |
|
|---|
| 212 |
|
|---|
| 213 |
if (!buf[0]) return (0); |
|---|
| 214 |
|
|---|
| 215 |
|
|---|
| 216 |
if (isspace((unsigned char)buf[0])) return (0); |
|---|
| 217 |
|
|---|
| 218 |
|
|---|
| 219 |
if (buf[0] == '#') return (0); |
|---|
| 220 |
|
|---|
| 221 |
|
|---|
| 222 |
|
|---|
| 223 |
|
|---|
| 224 |
|
|---|
| 225 |
|
|---|
| 226 |
|
|---|
| 227 |
if (buf[1] != ':') return (1); |
|---|
| 228 |
|
|---|
| 229 |
|
|---|
| 230 |
|
|---|
| 231 |
if (buf[0] == 'R') |
|---|
| 232 |
{ |
|---|
| 233 |
if (tokenize(buf+2, 3, zz) == 3) |
|---|
| 234 |
{ |
|---|
| 235 |
monster_race *r_ptr; |
|---|
| 236 |
i = strtol(zz[0], NULL, 0); |
|---|
| 237 |
n1 = strtol(zz[1], NULL, 0); |
|---|
| 238 |
n2 = strtol(zz[2], NULL, 0); |
|---|
| 239 |
if ((i < 0) || (i >= (long)z_info->r_max)) return (1); |
|---|
| 240 |
r_ptr = &r_info[i]; |
|---|
| 241 |
if (n1) r_ptr->x_attr = (byte)n1; |
|---|
| 242 |
if (n2) r_ptr->x_char = (char)n2; |
|---|
| 243 |
return (0); |
|---|
| 244 |
} |
|---|
| 245 |
} |
|---|
| 246 |
|
|---|
| 247 |
|
|---|
| 248 |
else if (buf[0] == 'B') |
|---|
| 249 |
{ |
|---|
| 250 |
if (2 == tokenize(buf + 2, 2, zz)) |
|---|
| 251 |
{ |
|---|
| 252 |
add_autoinscription(strtol(zz[0], NULL, 0), zz[1]); |
|---|
| 253 |
return (0); |
|---|
| 254 |
} |
|---|
| 255 |
} |
|---|
| 256 |
|
|---|
| 257 |
|
|---|
| 258 |
|
|---|
| 259 |
|
|---|
| 260 |
else if (buf[0] == 'Q') |
|---|
| 261 |
{ |
|---|
| 262 |
i = tokenize(buf+2, 4, zz); |
|---|
| 263 |
if (i == 2) |
|---|
| 264 |
{ |
|---|
| 265 |
n1 = strtol(zz[0], NULL, 0); |
|---|
| 266 |
n2 = strtol(zz[1], NULL, 0); |
|---|
| 267 |
squelch_level[n1] = n2; |
|---|
| 268 |
return(0); |
|---|
| 269 |
} |
|---|
| 270 |
else if (i == 4) |
|---|
| 271 |
{ |
|---|
| 272 |
i = strtol(zz[0], NULL, 0); |
|---|
| 273 |
n1 = strtol(zz[1], NULL, 0); |
|---|
| 274 |
n2 = strtol(zz[2], NULL, 0); |
|---|
| 275 |
sq = strtol(zz[3], NULL, 0); |
|---|
| 276 |
if ((k_info[i].tval == n1) && (k_info[i].sval == n2)) |
|---|
| 277 |
{ |
|---|
| 278 |
k_info[i].squelch = sq; |
|---|
| 279 |
return(0); |
|---|
| 280 |
} |
|---|
| 281 |
else |
|---|
| 282 |
{ |
|---|
| 283 |
for (i = 1; i < z_info->k_max; i++) |
|---|
| 284 |
{ |
|---|
| 285 |
if ((k_info[i].tval == n1) && (k_info[i].sval == n2)) |
|---|
| 286 |
{ |
|---|
| 287 |
k_info[i].squelch = sq; |
|---|
| 288 |
return(0); |
|---|
| 289 |
} |
|---|
| 290 |
} |
|---|
| 291 |
} |
|---|
| 292 |
} |
|---|
| 293 |
} |
|---|
| 294 |
|
|---|
| 295 |
|
|---|
| 296 |
else if (buf[0] == 'K') |
|---|
| 297 |
{ |
|---|
| 298 |
if (tokenize(buf+2, 4, zz) == 4) |
|---|
| 299 |
{ |
|---|
| 300 |
object_kind *k_ptr; |
|---|
| 301 |
|
|---|
| 302 |
int tval, sval; |
|---|
| 303 |
const char *tval_s = zz[0]; |
|---|
| 304 |
const char *sval_s = zz[1]; |
|---|
| 305 |
|
|---|
| 306 |
n1 = strtol(zz[2], NULL, 0); |
|---|
| 307 |
n2 = strtol(zz[3], NULL, 0); |
|---|
| 308 |
|
|---|
| 309 |
|
|---|
| 310 |
if (1 != sscanf(tval_s, "%d", &tval)) |
|---|
| 311 |
{ |
|---|
| 312 |
tval = tval_find_idx(tval_s); |
|---|
| 313 |
if (tval == -1) return 1; |
|---|
| 314 |
} |
|---|
| 315 |
|
|---|
| 316 |
|
|---|
| 317 |
if (1 != sscanf(sval_s, "%d", &sval)) |
|---|
| 318 |
{ |
|---|
| 319 |
sval = lookup_sval(tval, sval_s); |
|---|
| 320 |
if (sval == -1) return 1; |
|---|
| 321 |
} |
|---|
| 322 |
|
|---|
| 323 |
i = lookup_kind(tval, sval); |
|---|
| 324 |
|
|---|
| 325 |
if ((i < 0) || (i >= (long)z_info->k_max)) return (1); |
|---|
| 326 |
|
|---|
| 327 |
k_ptr = &k_info[i]; |
|---|
| 328 |
|
|---|
| 329 |
if (n1) k_ptr->x_attr = (byte)n1; |
|---|
| 330 |
if (n2) k_ptr->x_char = (char)n2; |
|---|
| 331 |
|
|---|
| 332 |
return (0); |
|---|
| 333 |
} |
|---|
| 334 |
} |
|---|
| 335 |
|
|---|
| 336 |
|
|---|
| 337 |
|
|---|
| 338 |
else if (buf[0] == 'F') |
|---|
| 339 |
{ |
|---|
| 340 |
if (tokenize(buf+2, 3, zz) == 3) |
|---|
| 341 |
{ |
|---|
| 342 |
feature_type *f_ptr; |
|---|
| 343 |
i = strtol(zz[0], NULL, 0); |
|---|
| 344 |
n1 = strtol(zz[1], NULL, 0); |
|---|
| 345 |
n2 = strtol(zz[2], NULL, 0); |
|---|
| 346 |
if ((i < 0) || (i >= (long)z_info->f_max)) return (1); |
|---|
| 347 |
f_ptr = &f_info[i]; |
|---|
| 348 |
if (n1) f_ptr->x_attr = (byte)n1; |
|---|
| 349 |
if (n2) f_ptr->x_char = (char)n2; |
|---|
| 350 |
return (0); |
|---|
| 351 |
} |
|---|
| 352 |
} |
|---|
| 353 |
|
|---|
| 354 |
|
|---|
| 355 |
|
|---|
| 356 |
else if (buf[0] == 'L') |
|---|
| 357 |
{ |
|---|
| 358 |
if (tokenize(buf+2, 3, zz) == 3) |
|---|
| 359 |
{ |
|---|
| 360 |
flavor_type *flavor_ptr; |
|---|
| 361 |
i = strtol(zz[0], NULL, 0); |
|---|
| 362 |
n1 = strtol(zz[1], NULL, 0); |
|---|
| 363 |
n2 = strtol(zz[2], NULL, 0); |
|---|
| 364 |
if ((i < 0) || (i >= (long)z_info->flavor_max)) return (1); |
|---|
| 365 |
flavor_ptr = &flavor_info[i]; |
|---|
| 366 |
if (n1) flavor_ptr->x_attr = (byte)n1; |
|---|
| 367 |
if (n2) flavor_ptr->x_char = (char)n2; |
|---|
| 368 |
return (0); |
|---|
| 369 |
} |
|---|
| 370 |
} |
|---|
| 371 |
|
|---|
| 372 |
|
|---|
| 373 |
|
|---|
| 374 |
else if (buf[0] == 'S') |
|---|
| 375 |
{ |
|---|
| 376 |
if (tokenize(buf+2, 3, zz) == 3) |
|---|
| 377 |
{ |
|---|
| 378 |
i = strtol(zz[0], NULL, 0); |
|---|
| 379 |
n1 = strtol(zz[1], NULL, 0); |
|---|
| 380 |
n2 = strtol(zz[2], NULL, 0); |
|---|
| 381 |
if ((i < 0) || (i >= (long)N_ELEMENTS(misc_to_attr))) return (1); |
|---|
| 382 |
misc_to_attr[i] = (byte)n1; |
|---|
| 383 |
misc_to_char[i] = (char)n2; |
|---|
| 384 |
return (0); |
|---|
| 385 |
} |
|---|
| 386 |
} |
|---|
| 387 |
|
|---|
| 388 |
|
|---|
| 389 |
|
|---|
| 390 |
else if (buf[0] == 'E') |
|---|
| 391 |
{ |
|---|
| 392 |
if (tokenize(buf+2, 2, zz) == 2) |
|---|
| 393 |
{ |
|---|
| 394 |
i = strtol(zz[0], NULL, 0) % 128; |
|---|
| 395 |
n1 = strtol(zz[1], NULL, 0); |
|---|
| 396 |
if ((i < 0) || (i >= (long)N_ELEMENTS(tval_to_attr))) return (1); |
|---|
| 397 |
if (n1) tval_to_attr[i] = (byte)n1; |
|---|
| 398 |
return (0); |
|---|
| 399 |
} |
|---|
| 400 |
} |
|---|
| 401 |
|
|---|
| 402 |
|
|---|
| 403 |
|
|---|
| 404 |
else if (buf[0] == 'A') |
|---|
| 405 |
{ |
|---|
| 406 |
text_to_ascii(macro_buffer, sizeof(macro_buffer), buf+2); |
|---|
| 407 |
return (0); |
|---|
| 408 |
} |
|---|
| 409 |
|
|---|
| 410 |
|
|---|
| 411 |
else if (buf[0] == 'P') |
|---|
| 412 |
{ |
|---|
| 413 |
char tmp[1024]; |
|---|
| 414 |
text_to_ascii(tmp, sizeof(tmp), buf+2); |
|---|
| 415 |
macro_add(tmp, macro_buffer); |
|---|
| 416 |
return (0); |
|---|
| 417 |
} |
|---|
| 418 |
|
|---|
| 419 |
|
|---|
| 420 |
else if (buf[0] == 'C') |
|---|
| 421 |
{ |
|---|
| 422 |
long mode; |
|---|
| 423 |
|
|---|
| 424 |
char tmp[1024]; |
|---|
| 425 |
|
|---|
| 426 |
if (tokenize(buf+2, 2, zz) != 2) return (1); |
|---|
| 427 |
|
|---|
| 428 |
mode = strtol(zz[0], NULL, 0); |
|---|
| 429 |
if ((mode < 0) || (mode >= KEYMAP_MODES)) return (1); |
|---|
| 430 |
|
|---|
| 431 |
text_to_ascii(tmp, sizeof(tmp), zz[1]); |
|---|
| 432 |
if (!tmp[0] || tmp[1]) return (1); |
|---|
| 433 |
i = (long)tmp[0]; |
|---|
| 434 |
|
|---|
| 435 |
string_free(keymap_act[mode][i]); |
|---|
| 436 |
|
|---|
| 437 |
keymap_act[mode][i] = string_make(macro_buffer); |
|---|
| 438 |
|
|---|
| 439 |
return (0); |
|---|
| 440 |
} |
|---|
| 441 |
|
|---|
| 442 |
|
|---|
| 443 |
|
|---|
| 444 |
else if (buf[0] == 'V') |
|---|
| 445 |
{ |
|---|
| 446 |
if (tokenize(buf+2, 5, zz) == 5) |
|---|
| 447 |
{ |
|---|
| 448 |
i = strtol(zz[0], NULL, 0); |
|---|
| 449 |
if ((i < 0) || (i >= MAX_COLORS)) return (1); |
|---|
| 450 |
angband_color_table[i][0] = (byte)strtol(zz[1], NULL, 0); |
|---|
| 451 |
angband_color_table[i][1] = (byte)strtol(zz[2], NULL, 0); |
|---|
| 452 |
angband_color_table[i][2] = (byte)strtol(zz[3], NULL, 0); |
|---|
| 453 |
angband_color_table[i][3] = (byte)strtol(zz[4], NULL, 0); |
|---|
| 454 |
return (0); |
|---|
| 455 |
} |
|---|
| 456 |
} |
|---|
| 457 |
|
|---|
| 458 |
|
|---|
| 459 |
|
|---|
| 460 |
|
|---|
| 461 |
else if (buf[0] == 'T') |
|---|
| 462 |
{ |
|---|
| 463 |
int tok; |
|---|
| 464 |
|
|---|
| 465 |
tok = tokenize(buf + 2, MAX_MACRO_MOD + 2, zz); |
|---|
| 466 |
|
|---|
| 467 |
|
|---|
| 468 |
if (tok >= 4) |
|---|
| 469 |
{ |
|---|
| 470 |
int i; |
|---|
| 471 |
int num; |
|---|
| 472 |
|
|---|
| 473 |
|
|---|
| 474 |
macro_trigger_free(); |
|---|
| 475 |
|
|---|
| 476 |
|
|---|
| 477 |
if (*zz[0] == '\0') return 0; |
|---|
| 478 |
|
|---|
| 479 |
|
|---|
| 480 |
num = strlen(zz[1]); |
|---|
| 481 |
|
|---|
| 482 |
|
|---|
| 483 |
if (num + 2 != tok) return 1; |
|---|
| 484 |
|
|---|
| 485 |
|
|---|
| 486 |
macro_template = string_make(zz[0]); |
|---|
| 487 |
|
|---|
| 488 |
|
|---|
| 489 |
macro_modifier_chr = string_make(zz[1]); |
|---|
| 490 |
|
|---|
| 491 |
|
|---|
| 492 |
for (i = 0; i < num; i++) |
|---|
| 493 |
{ |
|---|
| 494 |
macro_modifier_name[i] = string_make(zz[2+i]); |
|---|
| 495 |
} |
|---|
| 496 |
} |
|---|
| 497 |
|
|---|
| 498 |
|
|---|
| 499 |
else if (tok >= 2) |
|---|
| 500 |
{ |
|---|
| 501 |
char *buf; |
|---|
| 502 |
cptr s; |
|---|
| 503 |
char *t; |
|---|
| 504 |
|
|---|
| 505 |
if (max_macrotrigger >= MAX_MACRO_TRIGGER) |
|---|
| 506 |
{ |
|---|
| 507 |
msg_print("Too many macro triggers!"); |
|---|
| 508 |
return 1; |
|---|
| 509 |
} |
|---|
| 510 |
|
|---|
| 511 |
|
|---|
| 512 |
buf = C_ZNEW(strlen(zz[0]) + 1, char); |
|---|
| 513 |
|
|---|
| 514 |
|
|---|
| 515 |
s = zz[0]; |
|---|
| 516 |
t = buf; |
|---|
| 517 |
|
|---|
| 518 |
while (*s) |
|---|
| 519 |
{ |
|---|
| 520 |
if ('\\' == *s) s++; |
|---|
| 521 |
*t++ = *s++; |
|---|
| 522 |
} |
|---|
| 523 |
|
|---|
| 524 |
|
|---|
| 525 |
*t = '\0'; |
|---|
| 526 |
|
|---|
| 527 |
|
|---|
| 528 |
macro_trigger_name[max_macrotrigger] = string_make(buf); |
|---|
| 529 |
|
|---|
| 530 |
|
|---|
| 531 |
FREE(buf); |
|---|
| 532 |
|
|---|
| 533 |
|
|---|
| 534 |
macro_trigger_keycode[0][max_macrotrigger] = string_make(zz[1]); |
|---|
| 535 |
|
|---|
| 536 |
|
|---|
| 537 |
if (tok == 3) |
|---|
| 538 |
{ |
|---|
| 539 |
macro_trigger_keycode[1][max_macrotrigger] = string_make(zz[2]); |
|---|
| 540 |
} |
|---|
| 541 |
|
|---|
| 542 |
else |
|---|
| 543 |
{ |
|---|
| 544 |
macro_trigger_keycode[1][max_macrotrigger] = string_make(zz[1]); |
|---|
| 545 |
} |
|---|
| 546 |
|
|---|
| 547 |
|
|---|
| 548 |
max_macrotrigger++; |
|---|
| 549 |
} |
|---|
| 550 |
|
|---|
| 551 |
return 0; |
|---|
| 552 |
} |
|---|
| 553 |
|
|---|
| 554 |
|
|---|
| 555 |
else if (buf[0] == 'X') |
|---|
| 556 |
{ |
|---|
| 557 |
|
|---|
| 558 |
for (i = 0; i < OPT_ADULT; i++) |
|---|
| 559 |
{ |
|---|
| 560 |
if (option_name(i) && streq(option_name(i), buf + 2)) |
|---|
| 561 |
{ |
|---|
| 562 |
option_set(i, FALSE); |
|---|
| 563 |
return (0); |
|---|
| 564 |
} |
|---|
| 565 |
} |
|---|
| 566 |
|
|---|
| 567 |
|
|---|
| 568 |
return (0); |
|---|
| 569 |
} |
|---|
| 570 |
|
|---|
| 571 |
|
|---|
| 572 |
else if (buf[0] == 'Y') |
|---|
| 573 |
{ |
|---|
| 574 |
|
|---|
| 575 |
for (i = 0; i < OPT_ADULT; i++) |
|---|
| 576 |
{ |
|---|
| 577 |
if (option_name(i) && streq(option_name(i), buf + 2)) |
|---|
| 578 |
{ |
|---|
| 579 |
option_set(i, TRUE); |
|---|
| 580 |
return (0); |
|---|
| 581 |
} |
|---|
| 582 |
} |
|---|
| 583 |
|
|---|
| 584 |
|
|---|
| 585 |
return (0); |
|---|
| 586 |
} |
|---|
| 587 |
|
|---|
| 588 |
|
|---|
| 589 |
|
|---|
| 590 |
else if (buf[0] == 'W') |
|---|
| 591 |
{ |
|---|
| 592 |
long win, flag, value; |
|---|
| 593 |
|
|---|
| 594 |
if (tokenize(buf + 2, 3, zz) == 3) |
|---|
| 595 |
{ |
|---|
| 596 |
win = strtol(zz[0], NULL, 0); |
|---|
| 597 |
flag = strtol(zz[1], NULL, 0); |
|---|
| 598 |
value = strtol(zz[2], NULL, 0); |
|---|
| 599 |
|
|---|
| 600 |
|
|---|
| 601 |
|
|---|
| 602 |
if ((win <= 0) || (win >= ANGBAND_TERM_MAX)) return (1); |
|---|
| 603 |
|
|---|
| 604 |
|
|---|
| 605 |
if ((flag < 0) || (flag >= (int)N_ELEMENTS(window_flag_desc))) return (1); |
|---|
| 606 |
|
|---|
| 607 |
|
|---|
| 608 |
if (window_flag_desc[flag]) |
|---|
| 609 |
{ |
|---|
| 610 |
if (value) |
|---|
| 611 |
{ |
|---|
| 612 |
|
|---|
| 613 |
op_ptr->window_flag[win] |= (1L << flag); |
|---|
| 614 |
} |
|---|
| 615 |
else |
|---|
| 616 |
{ |
|---|
| 617 |
|
|---|
| 618 |
op_ptr->window_flag[win] &= ~(1L << flag); |
|---|
| 619 |
} |
|---|
| 620 |
} |
|---|
| 621 |
|
|---|
| 622 |
|
|---|
| 623 |
return (0); |
|---|
| 624 |
} |
|---|
| 625 |
} |
|---|
| 626 |
|
|---|
| 627 |
|
|---|
| 628 |
|
|---|
| 629 |
else if (buf[0] == 'M') |
|---|
| 630 |
{ |
|---|
| 631 |
if (tokenize(buf+2, 2, zz) == 2) |
|---|
| 632 |
{ |
|---|
| 633 |
long type = strtol(zz[0], NULL, 0); |
|---|
| 634 |
int color = color_char_to_attr(zz[1][0]); |
|---|
| 635 |
|
|---|
| 636 |
|
|---|
| 637 |
if (color < 0) return (1); |
|---|
| 638 |
|
|---|
| 639 |
|
|---|
| 640 |
return (message_color_define((u16b)type, (byte)color)); |
|---|
| 641 |
} |
|---|
| 642 |
} |
|---|
| 643 |
|
|---|
| 644 |
|
|---|
| 645 |
|
|---|
| 646 |
return (1); |
|---|
| 647 |
} |
|---|
| 648 |
|
|---|
| 649 |
|
|---|
| 650 |
|
|---|
| 651 |
|
|---|
| 652 |
|
|---|
| 653 |
|
|---|
| 654 |
|
|---|
| 655 |
|
|---|
| 656 |
|
|---|
| 657 |
|
|---|
| 658 |
|
|---|
| 659 |
|
|---|
| 660 |
static cptr process_pref_file_expr(char **sp, char *fp) |
|---|
| 661 |
{ |
|---|
| 662 |
cptr v; |
|---|
| 663 |
|
|---|
| 664 |
char *b; |
|---|
| 665 |
char *s; |
|---|
| 666 |
|
|---|
| 667 |
char b1 = '['; |
|---|
| 668 |
char b2 = ']'; |
|---|
| 669 |
|
|---|
| 670 |
char f = ' '; |
|---|
| 671 |
|
|---|
| 672 |
|
|---|
| 673 |
s = (*sp); |
|---|
| 674 |
|
|---|
| 675 |
|
|---|
| 676 |
while (isspace((unsigned char)*s)) s++; |
|---|
| 677 |
|
|---|
| 678 |
|
|---|
| 679 |
b = s; |
|---|
| 680 |
|
|---|
| 681 |
|
|---|
| 682 |
v = "?o?o?"; |
|---|
| 683 |
|
|---|
| 684 |
|
|---|
| 685 |
if (*s == b1) |
|---|
| 686 |
{ |
|---|
| 687 |
const char *p; |
|---|
| 688 |
const char *t; |
|---|
| 689 |
|
|---|
| 690 |
|
|---|
| 691 |
s++; |
|---|
| 692 |
|
|---|
| 693 |
|
|---|
| 694 |
t = process_pref_file_expr(&s, &f); |
|---|
| 695 |
|
|---|
| 696 |
|
|---|
| 697 |
if (!*t) |
|---|
| 698 |
{ |
|---|
| 699 |
|
|---|
| 700 |
} |
|---|
| 701 |
|
|---|
| 702 |
|
|---|
| 703 |
else if (streq(t, "IOR")) |
|---|
| 704 |
{ |
|---|
| 705 |
v = "0"; |
|---|
| 706 |
while (*s && (f != b2)) |
|---|
| 707 |
{ |
|---|
| 708 |
t = process_pref_file_expr(&s, &f); |
|---|
| 709 |
if (*t && !streq(t, "0")) v = "1"; |
|---|
| 710 |
} |
|---|
| 711 |
} |
|---|
| 712 |
|
|---|
| 713 |
|
|---|
| 714 |
else if (streq(t, "AND")) |
|---|
| 715 |
{ |
|---|
| 716 |
v = "1"; |
|---|
| 717 |
while (*s && (f != b2)) |
|---|
| 718 |
{ |
|---|
| 719 |
t = process_pref_file_expr(&s, &f); |
|---|
| 720 |
if (*t && streq(t, "0")) v = "0"; |
|---|
| 721 |
} |
|---|
| 722 |
} |
|---|
| 723 |
|
|---|
| 724 |
|
|---|
| 725 |
else if (streq(t, "NOT")) |
|---|
| 726 |
{ |
|---|
| 727 |
v = "1"; |
|---|
| 728 |
while (*s && (f != b2)) |
|---|
| 729 |
{ |
|---|
| 730 |
t = process_pref_file_expr(&s, &f); |
|---|
| 731 |
if (*t && !streq(t, "0")) v = "0"; |
|---|
| 732 |
} |
|---|
| 733 |
} |
|---|
| 734 |
|
|---|
| 735 |
|
|---|
| 736 |
else if (streq(t, "EQU")) |
|---|
| 737 |
{ |
|---|
| 738 |
v = "1"; |
|---|
| 739 |
if (*s && (f != b2)) |
|---|
| 740 |
{ |
|---|
| 741 |
t = process_pref_file_expr(&s, &f); |
|---|
| 742 |
} |
|---|
| 743 |
while (*s && (f != b2)) |
|---|
| 744 |
{ |
|---|
| 745 |
p = t; |
|---|
| 746 |
t = process_pref_file_expr(&s, &f); |
|---|
| 747 |
if (*t && !streq(p, t)) v = "0"; |
|---|
| 748 |
} |
|---|
| 749 |
} |
|---|
| 750 |
|
|---|
| 751 |
|
|---|
| 752 |
else if (streq(t, "LEQ")) |
|---|
| 753 |
{ |
|---|
| 754 |
v = "1"; |
|---|
| 755 |
if (*s && (f != b2)) |
|---|
| 756 |
{ |
|---|
| 757 |
t = process_pref_file_expr(&s, &f); |
|---|
| 758 |
} |
|---|
| 759 |
while (*s && (f != b2)) |
|---|
| 760 |
{ |
|---|
| 761 |
p = t; |
|---|
| 762 |
t = process_pref_file_expr(&s, &f); |
|---|
| 763 |
if (*t && (strcmp(p, t) >= 0)) v = "0"; |
|---|
| 764 |
} |
|---|
| 765 |
} |
|---|
| 766 |
|
|---|
| 767 |
|
|---|
| 768 |
else if (streq(t, "GEQ")) |
|---|
| 769 |
{ |
|---|
| 770 |
v = "1"; |
|---|
| 771 |
if (*s && (f != b2)) |
|---|
| 772 |
{ |
|---|
| 773 |
t = process_pref_file_expr(&s, &f); |
|---|
| 774 |
} |
|---|
| 775 |
while (*s && (f != b2)) |
|---|
| 776 |
{ |
|---|
| 777 |
p = t; |
|---|
| 778 |
t = process_pref_file_expr(&s, &f); |
|---|
| 779 |
if (*t && (strcmp(p, t) <= 0)) v = "0"; |
|---|
| 780 |
} |
|---|
| 781 |
} |
|---|
| 782 |
|
|---|
| 783 |
|
|---|
| 784 |
else |
|---|
| 785 |
{ |
|---|
| 786 |
while (*s && (f != b2)) |
|---|
| 787 |
{ |
|---|
| 788 |
t = process_pref_file_expr(&s, &f); |
|---|
| 789 |
} |
|---|
| 790 |
} |
|---|
| 791 |
|
|---|
| 792 |
|
|---|
| 793 |
if (f != b2) v = "?x?x?"; |
|---|
| 794 |
|
|---|
| 795 |
|
|---|
| 796 |
if ((f = *s) != '\0') *s++ = '\0'; |
|---|
| 797 |
} |
|---|
| 798 |
|
|---|
| 799 |
|
|---|
| 800 |
else |
|---|
| 801 |
{ |
|---|
| 802 |
|
|---|
| 803 |
while (isprint((unsigned char)*s) && !strchr(" []", *s)) ++s; |
|---|
| 804 |
|
|---|
| 805 |
|
|---|
| 806 |
if ((f = *s) != '\0') *s++ = '\0'; |
|---|
| 807 |
|
|---|
| 808 |
|
|---|
| 809 |
if (*b == '$') |
|---|
| 810 |
{ |
|---|
| 811 |
|
|---|
| 812 |
if (streq(b+1, "SYS")) |
|---|
| 813 |
{ |
|---|
| 814 |
v = ANGBAND_SYS; |
|---|
| 815 |
} |
|---|
| 816 |
|
|---|
| 817 |
|
|---|
| 818 |
else if (streq(b+1, "GRAF")) |
|---|
| 819 |
{ |
|---|
| 820 |
|
|---|