mirror of
https://github.com/JGRennison/OpenTTD-patches.git
synced 2024-11-02 09:40:35 +00:00
(svn r14233) -Feature/Fix [FS#2172]: save the palette of the loaded NewGRFs in the savegame, so joining with a server using Windows palette will make a client with the DOS palette do palette conversion and (thus) not cause a desync due to the different palettes disabling different NewGRFs.
This commit is contained in:
parent
c620d5e5f0
commit
a4cd12274c
@ -299,11 +299,11 @@ static void LoadSpriteTables()
|
||||
GRFConfig *master = CallocT<GRFConfig>(1);
|
||||
master->filename = strdup(_used_graphics_set->files[GFT_EXTRA].filename);
|
||||
FillGRFDetails(master, false);
|
||||
master->windows_paletted = (_used_graphics_set->palette == PAL_WINDOWS);
|
||||
ClrBit(master->flags, GCF_INIT_ONLY);
|
||||
master->next = top;
|
||||
_grfconfig = master;
|
||||
|
||||
_palette_remap_grf[i] = (_use_palette != _used_graphics_set->palette);
|
||||
LoadNewGRF(SPR_NEWGRFS_BASE, i);
|
||||
|
||||
/* Free and remove the top element. */
|
||||
|
@ -3194,10 +3194,13 @@ STR_PERFORMANCE_DETAIL_TOTAL_TIP :{BLACK}Total po
|
||||
STR_NEWGRF_SETTINGS_BUTTON :{BLACK}NewGRF Settings
|
||||
STR_NEWGRF_SETTINGS_CAPTION :{WHITE}NewGRF settings
|
||||
STR_NEWGRF_APPLY_CHANGES :{BLACK}Apply changes
|
||||
STR_NEWGRF_TOGGLE_PALETTE :{BLACK}Toggle palette
|
||||
STR_NEWGRF_TOGGLE_PALETTE_TIP :{BLACK}Toggle the palette of the selected NewGRF.{}Do this when the graphics from this NewGRF look pink in-game
|
||||
STR_NEWGRF_SET_PARAMETERS :{BLACK}Set parameters
|
||||
STR_NEWGRF_TIP :{BLACK}A list of all the Newgrf sets that you have installed. Click a set to change the settings
|
||||
STR_NEWGRF_NO_FILES_INSTALLED :{BLACK}There are currently no newgrf files installed! Please refer to the manual for instructions on installing new graphics
|
||||
STR_NEWGRF_FILENAME :{BLACK}Filename: {SILVER}{RAW_STRING}
|
||||
STR_NEWGRF_PALETTE :{BLACK}Palette: {SILVER}{RAW_STRING}
|
||||
STR_NEWGRF_GRF_ID :{BLACK}GRF ID: {SILVER}{RAW_STRING}
|
||||
STR_NEWGRF_MD5SUM :{BLACK}MD5sum: {SILVER}{RAW_STRING}
|
||||
STR_NEWGRF_CONFIRMATION_TEXT :{YELLOW}You are about to make changes to a running game; this can crash OpenTTD.{}Are you absolutely sure about this?
|
||||
|
@ -3644,11 +3644,7 @@ bool GetGlobalVariable(byte param, uint32 *value)
|
||||
}
|
||||
|
||||
case 0x0D: // TTD Version, 00=DOS, 01=Windows
|
||||
if (_palette_remap_grf[_file_index]) {
|
||||
*value = !_use_palette;
|
||||
} else {
|
||||
*value = _use_palette;
|
||||
}
|
||||
*value = _cur_grfconfig->windows_paletted;
|
||||
return true;
|
||||
|
||||
case 0x0E: // Y-offset for train sprites
|
||||
@ -4100,7 +4096,7 @@ static void GRFInfo(byte *buf, size_t len)
|
||||
_cur_grfconfig->status = _cur_stage < GLS_RESERVE ? GCS_INITIALISED : GCS_ACTIVATED;
|
||||
|
||||
/* Do swap the GRFID for displaying purposes since people expect that */
|
||||
DEBUG(grf, 1, "GRFInfo: Loaded GRFv%d set %08lX - %s", version, BSWAP32(grfid), name);
|
||||
DEBUG(grf, 1, "GRFInfo: Loaded GRFv%d set %08lX - %s (palette: %s)", version, BSWAP32(grfid), name, _cur_grfconfig->windows_paletted ? "Windows" : "DOS");
|
||||
}
|
||||
|
||||
/* Action 0x0A */
|
||||
@ -5894,6 +5890,7 @@ void LoadNewGRFFile(GRFConfig *config, uint file_index, GrfLoadingStage stage)
|
||||
|
||||
FioOpenFile(file_index, filename);
|
||||
_file_index = file_index; // XXX
|
||||
_palette_remap_grf[_file_index] = (config->windows_paletted != (_use_palette == PAL_WINDOWS));
|
||||
|
||||
_cur_grfconfig = config;
|
||||
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include "string_func.h"
|
||||
#include "gamelog.h"
|
||||
#include "network/network_type.h"
|
||||
#include "gfx_func.h"
|
||||
|
||||
#include "fileio_func.h"
|
||||
#include "fios.h"
|
||||
@ -72,6 +73,8 @@ bool FillGRFDetails(GRFConfig *config, bool is_static)
|
||||
if (HasBit(config->flags, GCF_UNSAFE)) return false;
|
||||
}
|
||||
|
||||
config->windows_paletted = (_use_palette == PAL_WINDOWS);
|
||||
|
||||
return CalcGRFMD5Sum(config);
|
||||
}
|
||||
|
||||
@ -481,11 +484,12 @@ bool GRFConfig::IsOpenTTDBaseGRF() const
|
||||
|
||||
|
||||
static const SaveLoad _grfconfig_desc[] = {
|
||||
SLE_STR(GRFConfig, filename, SLE_STR, 0x40),
|
||||
SLE_VAR(GRFConfig, grfid, SLE_UINT32),
|
||||
SLE_ARR(GRFConfig, md5sum, SLE_UINT8, 16),
|
||||
SLE_ARR(GRFConfig, param, SLE_UINT32, 0x80),
|
||||
SLE_VAR(GRFConfig, num_params, SLE_UINT8),
|
||||
SLE_STR(GRFConfig, filename, SLE_STR, 0x40),
|
||||
SLE_VAR(GRFConfig, grfid, SLE_UINT32),
|
||||
SLE_ARR(GRFConfig, md5sum, SLE_UINT8, 16),
|
||||
SLE_ARR(GRFConfig, param, SLE_UINT32, 0x80),
|
||||
SLE_VAR(GRFConfig, num_params, SLE_UINT8),
|
||||
SLE_CONDVAR(GRFConfig, windows_paletted, SLE_BOOL, 101, SL_MAX_VERSION),
|
||||
SLE_END()
|
||||
};
|
||||
|
||||
@ -508,6 +512,7 @@ static void Load_NGRF()
|
||||
while (SlIterateArray() != -1) {
|
||||
GRFConfig *c = CallocT<GRFConfig>(1);
|
||||
SlObject(c, _grfconfig_desc);
|
||||
if (CheckSavegameVersion(101)) c->windows_paletted = (_use_palette == PAL_WINDOWS);
|
||||
AppendToGRFConfigList(&_grfconfig, c);
|
||||
}
|
||||
|
||||
|
@ -68,6 +68,7 @@ struct GRFConfig : public GRFIdentifier {
|
||||
uint32 grf_bugs; ///< NOSAVE: bugs in this GRF in this run, @see enum GRFBugs
|
||||
uint32 param[0x80]; ///< GRF parameters
|
||||
uint8 num_params; ///< Number of used parameters
|
||||
bool windows_paletted; ///< Whether the NewGRF is Windows paletted or not
|
||||
|
||||
struct GRFConfig *next; ///< NOSAVE: Next item in the linked list
|
||||
|
||||
|
@ -100,6 +100,10 @@ static void ShowNewGRFInfo(const GRFConfig *c, uint x, uint y, uint w, uint bott
|
||||
y += DrawStringMultiLine(x, y, STR_NEWGRF_PARAMETER, w, bottom - y);
|
||||
}
|
||||
|
||||
/* Draw the palette of the NewGRF */
|
||||
SetDParamStr(0, c->windows_paletted ? "Windows" : "DOS");
|
||||
y += DrawStringMultiLine(x, y, STR_NEWGRF_PALETTE, w, bottom - y);
|
||||
|
||||
/* Show flags */
|
||||
if (c->status == GCS_NOT_FOUND) y += DrawStringMultiLine(x, y, STR_NEWGRF_NOT_FOUND, w, bottom - y);
|
||||
if (c->status == GCS_DISABLED) y += DrawStringMultiLine(x, y, STR_NEWGRF_DISABLED, w, bottom - y);
|
||||
@ -301,6 +305,7 @@ struct NewGRFWindow : public Window {
|
||||
SNGRFS_SCROLLBAR,
|
||||
SNGRFS_NEWGRF_INFO,
|
||||
SNGRFS_SET_PARAMETERS,
|
||||
SNGRFS_TOGGLE_PALETTE,
|
||||
SNGRFS_APPLY_CHANGES,
|
||||
SNGRFS_RESIZE,
|
||||
};
|
||||
@ -359,6 +364,7 @@ struct NewGRFWindow : public Window {
|
||||
SNGRFS_PRESET_LIST,
|
||||
SNGRFS_ADD,
|
||||
SNGRFS_APPLY_CHANGES,
|
||||
SNGRFS_TOGGLE_PALETTE,
|
||||
WIDGET_LIST_END
|
||||
);
|
||||
}
|
||||
@ -571,6 +577,14 @@ struct NewGRFWindow : public Window {
|
||||
ShowQueryString(STR_JUST_RAW_STRING, STR_NEWGRF_PARAMETER_QUERY, 63, 250, this, CS_ALPHANUMERAL);
|
||||
break;
|
||||
}
|
||||
|
||||
case SNGRFS_TOGGLE_PALETTE: {
|
||||
if (this->sel != NULL) {
|
||||
this->sel->windows_paletted ^= true;
|
||||
this->SetDirty();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -665,16 +679,17 @@ static const Widget _newgrf_widgets[] = {
|
||||
{ WWT_PUSHTXTBTN, RESIZE_RIGHT, COLOUR_YELLOW, 220, 289, 32, 43, STR_NEWGRF_MOVEDOWN, STR_NEWGRF_MOVEDOWN_TIP }, // SNGRFS_MOVE_DOWN
|
||||
{ WWT_MATRIX, RESIZE_RB, COLOUR_MAUVE, 0, 287, 46, 115, 0x501, STR_NEWGRF_FILE_TIP }, // SNGRFS_FILE_LIST
|
||||
{ WWT_SCROLLBAR, RESIZE_LRB, COLOUR_MAUVE, 288, 299, 46, 115, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST }, // SNGRFS_SCROLLBAR
|
||||
{ WWT_PANEL, RESIZE_RTB, COLOUR_MAUVE, 0, 299, 116, 228, STR_NULL, STR_NULL }, // SNGRFS_NEWGRF_INFO
|
||||
{ WWT_PUSHTXTBTN, RESIZE_TB, COLOUR_MAUVE, 0, 143, 229, 240, STR_NEWGRF_SET_PARAMETERS, STR_NULL }, // SNGRFS_SET_PARAMETERS
|
||||
{ WWT_PUSHTXTBTN, RESIZE_RTB, COLOUR_MAUVE, 144, 287, 229, 240, STR_NEWGRF_APPLY_CHANGES, STR_NULL }, // SNGRFS_APPLY_CHANGES
|
||||
{ WWT_RESIZEBOX, RESIZE_LRTB, COLOUR_MAUVE, 288, 299, 229, 240, 0x0, STR_RESIZE_BUTTON }, // SNGRFS_RESIZE
|
||||
{ WWT_PANEL, RESIZE_RTB, COLOUR_MAUVE, 0, 299, 116, 238, STR_NULL, STR_NULL }, // SNGRFS_NEWGRF_INFO
|
||||
{ WWT_PUSHTXTBTN, RESIZE_TB, COLOUR_MAUVE, 0, 95, 239, 250, STR_NEWGRF_SET_PARAMETERS, STR_NULL }, // SNGRFS_SET_PARAMETERS
|
||||
{ WWT_PUSHTXTBTN, RESIZE_RTB, COLOUR_MAUVE, 96, 191, 239, 250, STR_NEWGRF_TOGGLE_PALETTE, STR_NEWGRF_TOGGLE_PALETTE_TIP }, // SNGRFS_TOGGLE_PALETTE
|
||||
{ WWT_PUSHTXTBTN, RESIZE_RTB, COLOUR_MAUVE, 192, 287, 239, 250, STR_NEWGRF_APPLY_CHANGES, STR_NULL }, // SNGRFS_APPLY_CHANGES
|
||||
{ WWT_RESIZEBOX, RESIZE_LRTB, COLOUR_MAUVE, 288, 299, 239, 250, 0x0, STR_RESIZE_BUTTON }, // SNGRFS_RESIZE
|
||||
{ WIDGETS_END },
|
||||
};
|
||||
|
||||
/* Window definition of the manage newgrfs window */
|
||||
static const WindowDesc _newgrf_desc = {
|
||||
WDP_CENTER, WDP_CENTER, 300, 241, 300, 241,
|
||||
WDP_CENTER, WDP_CENTER, 300, 251, 300, 251,
|
||||
WC_GAME_OPTIONS, WC_NONE,
|
||||
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_RESIZABLE,
|
||||
_newgrf_widgets,
|
||||
|
@ -37,7 +37,7 @@
|
||||
|
||||
#include "table/strings.h"
|
||||
|
||||
extern const uint16 SAVEGAME_VERSION = 100;
|
||||
extern const uint16 SAVEGAME_VERSION = 101;
|
||||
|
||||
SavegameType _savegame_type; ///< type of savegame we are loading
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user