int ini_display(t_display *d) { if (ini_map(d) == -1 || ini_ray(d) == -1 || ini_key(d) == -1 || ini_player(d) == -1 || ini_xpm(d) == -1) return (-1); return (0); }
ini_key ini_section::operator[]( const tdk::tstring& key ) { return ini_key( *this , key ); }
static void merc_ini_load(void) { char *value; int i; ini_t *ini = ini_load(INI_NAME); if (!ini) { LOG("No "INI_NAME" found."); return; } while (ini_seek_section(ini, NULL)) { int i; char *end; char *section = ini_section(ini); if (strncasecmp(section, "merc", 4) != 0) continue; i = strtoul(§ion[4], &end, 10) - 1; if (!section[4] || *end) continue; if (i < 0 || i >= MERCOPT_MAX) continue; while (ini_seek_setting(ini, NULL)) { char *key = ini_key(ini); char *value = ini_value(ini); if (strcasecmp(key, "class") == 0) { mercopt[i].merc_class = strtoul(value, NULL, 0); } else if (strcasecmp(key, "allow_class") == 0) { int j; int klass[7]; int klasses = merc_parse_array(value, klass, 7); mercopt[i].allow_class = 0; for (j = 0; j < klasses; ++j) mercopt[i].allow_class |= 1 << klass[j]; } else if (strcasecmp(key, "allow_2h") == 0) { mercopt[i].allow_2h = !!strtoul(value, NULL, 0); } else if (strcasecmp(key, "dual") == 0) { mercopt[i].dual_types = merc_parse_array(value, mercopt[i].dual_type, MERCOPT_TYPE_MAX); } else if (strcasecmp(key, "except") == 0) { mercopt[i].except_types = merc_parse_array(value, mercopt[i].except_type, MERCOPT_TYPE_MAX); } else if (strcasecmp(key, "allow") == 0) { mercopt[i].allow_types = merc_parse_array(value, mercopt[i].allow_type, MERCOPT_TYPE_MAX); } else if (strcasecmp(key, "deny") == 0) { mercopt[i].deny_types = merc_parse_array(value, mercopt[i].deny_type, MERCOPT_TYPE_MAX); } /* else, ignore ( option for new version? :-D ) */ } } value = ini_get_setting(ini, "mercmod", "loadmpq"); if (value) { merc_load_image_mpq = !!strtoul(value, NULL, 0); } for (i = 0; i < INVREC_MAX; ++i) { char setting[32]; snprintf(setting, sizeof(setting), "inv%d", i + 1); value = ini_get_setting(ini, "mercmod", setting); if (value) { int j, r; int arr[1 + 6*INVENTORY_REC_ITEM_MAX]; int count = merc_parse_array(value, arr, 1 + 6*INVENTORY_REC_ITEM_MAX); if (count <= 0) continue; invrec_idx[i] = arr[0]; for (j = 1, r = 0; j <= (count-6); j += 6) { invrec[i][r].left = arr[j]; invrec[i][r].right = arr[j+1]; invrec[i][r].top = arr[j+2]; invrec[i][r].bottom = arr[j+3]; invrec[i][r].w = arr[j+4]; invrec[i][r].h = arr[j+5]; } } } ini_free(ini); }