tImpose minimum and maximum limits on all relevant configuration file variables, and enforce this in the GUI client Options dialog. - vaccinewars - be a doctor and try to vaccinate the world
 (HTM) git clone git://src.adamsgaard.dk/vaccinewars
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit c298f118abbdadcdef3682ec893d7879d1127a82
 (DIR) parent 001aedbb201916005753e3ffde2355546018f4de
 (HTM) Author: Ben Webb <ben@salilab.org>
       Date:   Mon, 23 Jun 2003 11:35:28 +0000
       
       Impose minimum and maximum limits on all relevant configuration file
       variables, and enforce this in the GUI client Options dialog.
       
       
       Diffstat:
         M ChangeLog                           |       2 ++
         M TODO                                |       2 --
         M src/gui_client/optdialog.c          |      32 +++++++++++++++++++++++++++----
       
       3 files changed, 30 insertions(+), 6 deletions(-)
       ---
 (DIR) diff --git a/ChangeLog b/ChangeLog
       t@@ -3,6 +3,8 @@ cvs
              by the cops
            - Some problems with the curses client missing screen resize events fixed
            - Logging to a file should now work properly again
       +    - Minimum and maximum limits on all relevant integer configuration
       +      file variables are now imposed for sanity
        
        1.5.9   07-06-2003
            - The messages window in the curses client can now be scrolled with the
 (DIR) diff --git a/TODO b/TODO
       t@@ -14,8 +14,6 @@
        - Track down server memory corruption bug!
        - Implement server option to buy more than one bitch at a time in the Pub.
        - Allow customisation of GtkTextView tag colours
       -- Impose sensible limits on numbers in Options dialog (e.g. percentages)
       -  (should also enforce this for config file / server admin)
        - Admin of running NT Service servers
        - GSS_API SOCKS support?
        - Fix problem with dialogs popping up while menus are open
 (DIR) diff --git a/src/gui_client/optdialog.c b/src/gui_client/optdialog.c
       t@@ -107,6 +107,12 @@ static void SaveConfigWidget(struct GLOBALS *gvar, struct ConfigWidget *cwid,
        
              intpt = GetGlobalInt(cwid->globind, structind);
              newset = atoi(text);
       +      if (newset < gvar->MinVal) {
       +        newset = gvar->MinVal;
       +      }
       +      if (gvar->MaxVal > gvar->MinVal && newset > gvar->MaxVal) {
       +        newset = gvar->MaxVal;
       +      }
              changed = (*intpt != newset);
              *intpt = newset;
            } else if (gvar->PriceVal) {
       t@@ -243,9 +249,20 @@ static GtkWidget *NewConfigEntry(gchar *name)
          if (gvar->StringVal) {
            gtk_entry_set_text(GTK_ENTRY(entry), *gvar->StringVal);
          } else if (gvar->IntVal) {
       -    tmpstr = g_strdup_printf("%d", *gvar->IntVal);
       -    gtk_entry_set_text(GTK_ENTRY(entry), tmpstr);
       -    g_free(tmpstr);
       +    if (gvar->MaxVal > gvar->MinVal) {
       +      GtkAdjustment *spin_adj;
       +
       +      gtk_widget_destroy(entry);
       +      spin_adj = (GtkAdjustment *)gtk_adjustment_new(*gvar->IntVal,
       +                                                     gvar->MinVal,
       +                                                     gvar->MaxVal,
       +                                                     1.0, 10.0, 10.0);
       +      entry = gtk_spin_button_new(spin_adj, 1.0, 0);
       +    } else {
       +      tmpstr = g_strdup_printf("%d", *gvar->IntVal);
       +      gtk_entry_set_text(GTK_ENTRY(entry), tmpstr);
       +      g_free(tmpstr);
       +    }
          } else if (gvar->PriceVal) {
            tmpstr = pricetostr(*gvar->PriceVal);
            gtk_entry_set_text(GTK_ENTRY(entry), tmpstr);
       t@@ -279,7 +296,14 @@ static void AddStructConfig(GtkWidget *table, int row, gchar *structname,
            label = gtk_label_new(_(member->label));
            gtk_table_attach(GTK_TABLE(table), label, 0, 1, row, row + 1,
                             GTK_SHRINK, GTK_SHRINK, 0, 0);
       -    entry = gtk_entry_new();
       +    if (gvar->IntVal && gvar->MaxVal > gvar->MinVal) {
       +      GtkAdjustment *spin_adj = (GtkAdjustment *)
       +          gtk_adjustment_new(gvar->MinVal, gvar->MinVal, gvar->MaxVal,
       +                             1.0, 10.0, 10.0);
       +      entry = gtk_spin_button_new(spin_adj, 1.0, 0);
       +    } else {
       +      entry = gtk_entry_new();
       +    }
            gtk_table_attach_defaults(GTK_TABLE(table), entry, 1, 2, row, row + 1);
            AddConfigWidget(entry, ind);
          }