--- a/settings.c Tue Apr 10 09:49:41 2007 +0000
+++ b/settings.c Tue Apr 10 09:57:35 2007 +0000
@@ -260,7 +260,13 @@
}
} else if (group) {
// find end of keyname
- for (t = s; *t != '\0' && *t != '=' && *t != '\t' && *t != ' '; t++);
+ if (*s == '\"') {
+ s++;
+ for (t = s; *t != '\0' && *t != '\"'; t++);
+ if (*t == '\"') *t = ' ';
+ } else {
+ for (t = s; *t != '\0' && *t != '=' && *t != '\t' && *t != ' '; t++);
+ }
// it's an item in an existing group
item = ini_item_alloc(group, s, t-s);
@@ -348,11 +354,18 @@
assert(item->value != NULL);
if (item->comment != NULL) fputs(item->comment, f);
+ /* protect item->name with quotes if needed */
+ if (strchr(item->name, ' ') != NULL) {
+ fprintf(f, "\"%s\"", item->name);
+ } else {
+ fprintf(f, "%s", item->name);
+ }
+
/* Don't give an equal sign to list items that don't have a parameter */
if (group->type == IGT_LIST && *item->value == '\0') {
- fprintf(f, "%s\n", item->name);
+ fprintf(f, "\n");
} else {
- fprintf(f, "%s = %s\n", item->name, item->value);
+ fprintf(f, " = %s\n", item->value);
}
}
}
@@ -1800,6 +1813,26 @@
name, value, (sd->desc.flags & SGF_0ISDISABLED) ? "(0) " : "", sd->desc.min, sd->desc.max);
}
+void IConsoleListPatches(void)
+{
+ const SettingDesc *sd;
+ IConsolePrintF(_icolour_warn, "All patches with their current value:");
+
+ for (sd = _patch_settings; sd->save.cmd != SL_END; sd++) {
+ char value[80];
+ const void *ptr = GetVariableAddress((_game_mode == GM_MENU) ? &_patches_newgame : &_patches, &sd->save);
+
+ if (sd->desc.cmd == SDT_BOOLX) {
+ snprintf(value, lengthof(value), (*(bool*)ptr == 1) ? "on" : "off");
+ } else {
+ snprintf(value, lengthof(value), "%d", (uint32)ReadValue(ptr, sd->save.conv));
+ }
+ IConsolePrintF(_icolour_def, "%s = %s", sd->desc.name, value);
+ }
+
+ IConsolePrintF(_icolour_warn, "Use 'patch' command to change a value");
+}
+
/** Save and load handler for patches/settings
* @param osd SettingDesc struct containing all information
* @param object can be either NULL in which case we load global variables or