# HG changeset patch # User KUDr # Date 1163760140 0 # Node ID 5626f4b8b46e12910933990e0c313541d6e83b50 # Parent 9bb62a7fc166ed21f41a91467feadcfae68aa906 (svn r7190) -Fix: If the non-player-based _patches setting was changed on the server during MP game, the callback function was: 1. Called only on the server but not on its clients. 2. Was called before the setting change occurred (usually with no effect) 3. Received old 'p1' argument value intead of new one It could cause some MP desyncs in the future. diff -r 9bb62a7fc166 -r 5626f4b8b46e settings.c --- a/settings.c Fri Nov 17 10:06:11 2006 +0000 +++ b/settings.c Fri Nov 17 10:42:20 2006 +0000 @@ -1582,6 +1582,7 @@ Patches *patches_ptr = (_game_mode == GM_MENU) ? &_patches_newgame : &_patches; void *var = ini_get_variable(&sd->save, patches_ptr); Write_ValidateSetting(var, sd, (int32)p2); + if (sd->desc.proc != NULL) sd->desc.proc((int32)ReadValue(var, sd->save.conv)); InvalidateWindow(WC_GAME_OPTIONS, 0); } @@ -1611,6 +1612,7 @@ void *var2 = ini_get_variable(&sd->save, &_patches_newgame); Write_ValidateSetting(var2, sd, value); } + if (sd->desc.proc != NULL) sd->desc.proc((int32)ReadValue(var, sd->save.conv)); InvalidateWindow(WC_GAME_OPTIONS, 0); return true; } @@ -1653,7 +1655,6 @@ ptr = ini_get_variable(&sd->save, patches_ptr); success = SetPatchValue(index, patches_ptr, value); - if (success && sd->desc.proc != NULL) sd->desc.proc(value); return success; } diff -r 9bb62a7fc166 -r 5626f4b8b46e settings_gui.c --- a/settings_gui.c Fri Nov 17 10:06:11 2006 +0000 +++ b/settings_gui.c Fri Nov 17 10:42:20 2006 +0000 @@ -833,7 +833,6 @@ if (value != oldvalue) { SetPatchValue(page->entries[btn].index, patches_ptr, value); SetWindowDirty(w); - if (sdb->proc != NULL) sdb->proc((int32)ReadValue(var, sd->save.conv)); } } else { /* only open editbox for types that its sensible for */ @@ -868,7 +867,6 @@ if (e->we.edittext.str != NULL) { const PatchEntry *pe = &_patches_page[WP(w,def_d).data_1].entries[WP(w,def_d).data_3]; const SettingDesc *sd = pe->setting; - void *var = ini_get_variable(&sd->save, patches_ptr); int32 value = atoi(e->we.edittext.str); /* Save the correct currency-translated value */ @@ -876,8 +874,6 @@ SetPatchValue(pe->index, patches_ptr, value); SetWindowDirty(w); - - if (sd->desc.proc != NULL) sd->desc.proc((int32)ReadValue(var, sd->save.conv)); } break; }