diff -Nur -Xfreeciv/diff_ignore rawciv/client/civclient.c wlciv/client/civclient.c --- rawciv/client/civclient.c Tue Feb 20 06:35:27 2001 +++ wlciv/client/civclient.c Tue Mar 13 13:09:12 2001 @@ -486,6 +486,8 @@ update_research(game.player_ptr); role_unit_precalcs(); boot_help_texts(); /* reboot */ + load_options(); + send_saved_worklists(); update_unit_focus(); } else if(client_state==CLIENT_PRE_GAME_STATE) { diff -Nur -Xfreeciv/diff_ignore rawciv/client/options.c wlciv/client/options.c --- rawciv/client/options.c Wed Feb 7 06:31:11 2001 +++ wlciv/client/options.c Tue Mar 13 16:04:17 2001 @@ -19,19 +19,26 @@ #include #include +#include "city.h" #include "events.h" #include "fcintl.h" +#include "game.h" #include "log.h" #include "registry.h" +#include "packets.h" #include "shared.h" #include "support.h" #include "version.h" +#include "worklist.h" #include "chatline_g.h" #include "cityrepdata.h" #include "options.h" +extern struct connection aconnection; +static struct worklist opt_worklists[MAX_NUM_WORKLISTS]; + /** Local Options: **/ int solid_color_behind_units=0; @@ -198,10 +205,68 @@ qsort(sorted_events, E_LAST, sizeof(int), compar_message_texts); } +/**************************************************************** +... +*****************************************************************/ +static void worklist_load(struct section_file *file, + char *path, int wlinx, struct worklist *pwl) +{ + char efpath[64]; + char idpath[64]; + int i, end = 0; + + sz_strlcpy(efpath, path); + sz_strlcat(efpath, ".wlef%d"); + sz_strlcpy(idpath, path); + sz_strlcat(idpath, ".wlid%d"); + + for (i = 0; i < MAX_LEN_WORKLIST; i++) { + if (end) { + pwl->wlefs[i] = WEF_END; + pwl->wlids[i] = 0; + section_file_lookup(file, efpath, wlinx, i); + section_file_lookup(file, idpath, wlinx, i); + } else { + pwl->wlefs[i] = + secfile_lookup_int_default(file, WEF_END, efpath, wlinx, i); + pwl->wlids[i] = + secfile_lookup_int_default(file, 0, idpath,wlinx, i); + + if ((pwl->wlefs[i] <= WEF_END) || (pwl->wlefs[i] >= WEF_LAST) || + ((pwl->wlefs[i] == WEF_UNIT) && !unit_type_exists(pwl->wlids[i])) || + ((pwl->wlefs[i] == WEF_IMPR) && !improvement_exists(pwl->wlids[i]))) { + pwl->wlefs[i] = WEF_END; + pwl->wlids[i] = 0; + end = 1; + } + } + } +} + +/**************************************************************** +... +*****************************************************************/ +static void worklist_save(struct section_file *file, + char *path, int wlinx, struct worklist *pwl) +{ + char efpath[64]; + char idpath[64]; + int i; + + sz_strlcpy(efpath, path); + sz_strlcat(efpath, ".wlef%d"); + sz_strlcpy(idpath, path); + sz_strlcat(idpath, ".wlid%d"); + + for (i = 0; i < MAX_LEN_WORKLIST; i++) { + secfile_insert_int(file, pwl->wlefs[i], efpath, wlinx, i); + secfile_insert_int(file, pwl->wlids[i], idpath, wlinx, i); + } +} /**************************************************************** The "options" file handles actual "options", and also view options, - message options, and city report settings + message options, city report settings, and saved global worklists *****************************************************************/ /**************************************************************** @@ -235,35 +300,6 @@ freelog(LOG_VERBOSE, "settings file is %s", name_buffer); return name_buffer; } - -/**************************************************************** -... -*****************************************************************/ -static FILE *open_option_file(char *mode) -{ - char *name; - FILE *f; - - name = option_file_name(); - if (name==NULL) { - return NULL; - } - f = fopen(name, mode); - - if(mode[0]=='w') { - char output_buffer[256]; - if (f) { - my_snprintf(output_buffer, sizeof(output_buffer), - _("Settings file is %s"), name); - } else { - my_snprintf(output_buffer, sizeof(output_buffer), - _("Cannot write to file %s"), name); - } - append_output_window(output_buffer); - } - - return f; -} /**************************************************************** ... @@ -303,6 +339,17 @@ *ip = secfile_lookup_int_default(&sf, *ip, "%s.city_report_%s", prefix, city_report_spec_tagname(i)); } + + for (i = 0; i < MAX_NUM_WORKLISTS; i++) { + opt_worklists[i].is_valid = + secfile_lookup_int_default(&sf, 0, + "worklists.worklist%d.is_valid", i); + strcpy(opt_worklists[i].name, + secfile_lookup_str_default(&sf, "", + "worklists.worklist%d.name", i)); + worklist_load(&sf, "worklists.worklist%d", i, &opt_worklists[i]); + } + /* avoid warning for unused: */ section_file_lookup(&sf, "client.flags_are_transparent"); @@ -315,38 +362,62 @@ *****************************************************************/ void save_options(void) { - FILE *option_file; + struct section_file sf; client_option *o; + char *name; + char output_buffer[256]; view_option *v; int i; - option_file = open_option_file("w"); - if (option_file==NULL) { - append_output_window(_("Cannot save settings.")); - return; - } + name = option_file_name(); + if (name==NULL) return; - fprintf(option_file, "# settings file for freeciv client version %s\n#\n", - VERSION_STRING); - - fprintf(option_file, "[client]\n"); + section_file_init(&sf); - for (o=options; o->name; o++) { - fprintf(option_file, "%s = %d\n", o->name, *(o->p_value)); - } - for (v=view_options; v->name; v++) { - fprintf(option_file, "%s = %d\n", v->name, *(v->p_value)); + for(o=options; o->name; o++) + secfile_insert_int(&sf, *(o->p_value), "client.%s", o->name); + + for(v=view_options; v->name; v++) + secfile_insert_int(&sf, *(v->p_value), "client.%s", v->name); + + for(i=0; i < E_LAST; i++) + secfile_insert_int(&sf, messages_where[i],"client.message_where_%02d",i); + + for(i=1; i < num_city_report_spec(); i++){ + secfile_insert_int(&sf, city_report_spec_show_ptr(i), + "client.city_report_%s", city_report_spec_tagname(i)); } - for (i=0; iworklists[i].is_valid, + "worklists.worklist%d.is_valid", i); + secfile_insert_str(&sf, game.player_ptr->worklists[i].name, + "worklists.worklist%d.name", i); + worklist_save(&sf, "worklists.worklist%d", i, &(game.player_ptr->worklists[i])); } - for (i=1; i