mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-09 23:50:25 +00:00
(svn r20253) -Codechange: change GRFConfig::windows_paletted into a bitmask/bitset
This commit is contained in:
parent
f7794e313f
commit
e469a94a2d
@ -180,7 +180,7 @@ static void LoadSpriteTables()
|
|||||||
GRFConfig *top = _grfconfig;
|
GRFConfig *top = _grfconfig;
|
||||||
GRFConfig *master = new GRFConfig(used_set->files[GFT_EXTRA].filename);
|
GRFConfig *master = new GRFConfig(used_set->files[GFT_EXTRA].filename);
|
||||||
FillGRFDetails(master, false);
|
FillGRFDetails(master, false);
|
||||||
master->windows_paletted = (used_set->palette == PAL_WINDOWS);
|
master->palette = (used_set->palette == PAL_WINDOWS) ? GRFP_USE_WINDOWS : GRFP_USE_DOS;
|
||||||
ClrBit(master->flags, GCF_INIT_ONLY);
|
ClrBit(master->flags, GCF_INIT_ONLY);
|
||||||
master->next = top;
|
master->next = top;
|
||||||
_grfconfig = master;
|
_grfconfig = master;
|
||||||
|
@ -4415,7 +4415,7 @@ bool GetGlobalVariable(byte param, uint32 *value)
|
|||||||
}
|
}
|
||||||
|
|
||||||
case 0x0D: // TTD Version, 00=DOS, 01=Windows
|
case 0x0D: // TTD Version, 00=DOS, 01=Windows
|
||||||
*value = _cur_grfconfig->windows_paletted;
|
*value = _cur_grfconfig->palette & GRFP_USE_MASK;
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case 0x0E: // Y-offset for train sprites
|
case 0x0E: // Y-offset for train sprites
|
||||||
@ -4869,7 +4869,7 @@ static void GRFInfo(ByteReader *buf)
|
|||||||
_cur_grfconfig->status = _cur_stage < GLS_RESERVE ? GCS_INITIALISED : GCS_ACTIVATED;
|
_cur_grfconfig->status = _cur_stage < GLS_RESERVE ? GCS_INITIALISED : GCS_ACTIVATED;
|
||||||
|
|
||||||
/* Do swap the GRFID for displaying purposes since people expect that */
|
/* Do swap the GRFID for displaying purposes since people expect that */
|
||||||
DEBUG(grf, 1, "GRFInfo: Loaded GRFv%d set %08X - %s (palette: %s)", version, BSWAP32(grfid), name, _cur_grfconfig->windows_paletted ? "Windows" : "DOS");
|
DEBUG(grf, 1, "GRFInfo: Loaded GRFv%d set %08X - %s (palette: %s)", version, BSWAP32(grfid), name, (_cur_grfconfig->palette & GRFP_USE_MASK) ? "Windows" : "DOS");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Action 0x0A */
|
/* Action 0x0A */
|
||||||
@ -6974,7 +6974,7 @@ void LoadNewGRFFile(GRFConfig *config, uint file_index, GrfLoadingStage stage)
|
|||||||
|
|
||||||
FioOpenFile(file_index, filename);
|
FioOpenFile(file_index, filename);
|
||||||
_file_index = file_index; // XXX
|
_file_index = file_index; // XXX
|
||||||
_palette_remap_grf[_file_index] = (config->windows_paletted != (_use_palette == PAL_WINDOWS));
|
_palette_remap_grf[_file_index] = ((config->palette & GRFP_USE_MASK) != (_use_palette == PAL_WINDOWS));
|
||||||
|
|
||||||
_cur_grfconfig = config;
|
_cur_grfconfig = config;
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ GRFConfig::GRFConfig(const GRFConfig &config) :
|
|||||||
grf_bugs(config.grf_bugs),
|
grf_bugs(config.grf_bugs),
|
||||||
num_params(config.num_params),
|
num_params(config.num_params),
|
||||||
num_valid_params(config.num_valid_params),
|
num_valid_params(config.num_valid_params),
|
||||||
windows_paletted(config.windows_paletted)
|
palette(config.palette)
|
||||||
{
|
{
|
||||||
MemCpyT<uint8>(this->original_md5sum, config.original_md5sum, lengthof(this->original_md5sum));
|
MemCpyT<uint8>(this->original_md5sum, config.original_md5sum, lengthof(this->original_md5sum));
|
||||||
MemCpyT<uint32>(this->param, config.param, lengthof(this->param));
|
MemCpyT<uint32>(this->param, config.param, lengthof(this->param));
|
||||||
@ -92,7 +92,8 @@ const char *GRFConfig::GetDescription() const
|
|||||||
*/
|
*/
|
||||||
void GRFConfig::SetSuitablePalette()
|
void GRFConfig::SetSuitablePalette()
|
||||||
{
|
{
|
||||||
this->windows_paletted = (_use_palette == PAL_WINDOWS);
|
PaletteType pal = _use_palette;
|
||||||
|
SB(this->palette, GRFP_USE_BIT, 1, pal == PAL_WINDOWS ? GRFP_USE_WINDOWS : GRFP_USE_DOS);
|
||||||
}
|
}
|
||||||
|
|
||||||
GRFConfig *_all_grfs;
|
GRFConfig *_all_grfs;
|
||||||
|
@ -49,6 +49,16 @@ enum GRFListCompatibility {
|
|||||||
GLC_NOT_FOUND ///< At least one GRF couldn't be found (higher priority than GLC_COMPATIBLE)
|
GLC_NOT_FOUND ///< At least one GRF couldn't be found (higher priority than GLC_COMPATIBLE)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/** Information that can/has to be stored about a GRF's palette. */
|
||||||
|
enum GRFPalette {
|
||||||
|
GRFP_USE_BIT = 0, ///< The bit used for storing the palette to use.
|
||||||
|
|
||||||
|
GRFP_USE_DOS = 0x0, ///< The palette state is set to use the DOS palette.
|
||||||
|
GRFP_USE_WINDOWS = 0x1, ///< The palette state is set to use the Windows palette.
|
||||||
|
GRFP_USE_MASK = 0x1, ///< Bitmask to get only the use palette use states.
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/** Basic data to distinguish a GRF. Used in the server list window */
|
/** Basic data to distinguish a GRF. Used in the server list window */
|
||||||
struct GRFIdentifier {
|
struct GRFIdentifier {
|
||||||
uint32 grfid; ///< GRF ID (defined by Action 0x08)
|
uint32 grfid; ///< GRF ID (defined by Action 0x08)
|
||||||
@ -94,15 +104,15 @@ struct GRFConfig : ZeroedMemoryAllocator {
|
|||||||
struct GRFText *info; ///< NOSAVE: GRF info (author, copyright, ...) (Action 0x08)
|
struct GRFText *info; ///< NOSAVE: GRF info (author, copyright, ...) (Action 0x08)
|
||||||
GRFError *error; ///< NOSAVE: Error/Warning during GRF loading (Action 0x0B)
|
GRFError *error; ///< NOSAVE: Error/Warning during GRF loading (Action 0x0B)
|
||||||
|
|
||||||
uint8 flags; ///< NOSAVE: GCF_Flags, bitset
|
uint8 flags; ///< NOSAVE: GCF_Flags, bitset
|
||||||
GRFStatus status; ///< NOSAVE: GRFStatus, enum
|
GRFStatus status; ///< NOSAVE: GRFStatus, enum
|
||||||
uint32 grf_bugs; ///< NOSAVE: bugs in this GRF in this run, @see enum GRFBugs
|
uint32 grf_bugs; ///< NOSAVE: bugs in this GRF in this run, @see enum GRFBugs
|
||||||
uint32 param[0x80]; ///< GRF parameters
|
uint32 param[0x80]; ///< GRF parameters
|
||||||
uint8 num_params; ///< Number of used parameters
|
uint8 num_params; ///< Number of used parameters
|
||||||
uint8 num_valid_params; ///< Number of valid parameters (action 0x14)
|
uint8 num_valid_params; ///< NOSAVE: Number of valid parameters (action 0x14)
|
||||||
bool windows_paletted; ///< Whether the NewGRF is Windows paletted or not
|
uint8 palette; ///< GRFPalette, bitset
|
||||||
|
|
||||||
struct GRFConfig *next; ///< NOSAVE: Next item in the linked list
|
struct GRFConfig *next; ///< NOSAVE: Next item in the linked list
|
||||||
|
|
||||||
bool IsOpenTTDBaseGRF() const;
|
bool IsOpenTTDBaseGRF() const;
|
||||||
|
|
||||||
|
@ -96,7 +96,7 @@ static void ShowNewGRFInfo(const GRFConfig *c, uint x, uint y, uint right, uint
|
|||||||
y = DrawStringMultiLine(x, right, y, bottom, STR_NEWGRF_SETTINGS_PARAMETER);
|
y = DrawStringMultiLine(x, right, y, bottom, STR_NEWGRF_SETTINGS_PARAMETER);
|
||||||
|
|
||||||
/* Draw the palette of the NewGRF */
|
/* Draw the palette of the NewGRF */
|
||||||
SetDParamStr(0, c->windows_paletted ? "Windows" : "DOS");
|
SetDParamStr(0, (c->palette & GRFP_USE_WINDOWS) ? "Windows" : "DOS");
|
||||||
y = DrawStringMultiLine(x, right, y, bottom, STR_NEWGRF_SETTINGS_PALETTE);
|
y = DrawStringMultiLine(x, right, y, bottom, STR_NEWGRF_SETTINGS_PALETTE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -592,7 +592,7 @@ struct NewGRFWindow : public QueryStringBaseWindow {
|
|||||||
|
|
||||||
case SNGRFS_TOGGLE_PALETTE:
|
case SNGRFS_TOGGLE_PALETTE:
|
||||||
if (this->active_sel != NULL || !this->editable) {
|
if (this->active_sel != NULL || !this->editable) {
|
||||||
this->active_sel->windows_paletted ^= true;
|
this->active_sel->palette ^= GRFP_USE_MASK;
|
||||||
this->SetDirty();
|
this->SetDirty();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -24,7 +24,7 @@ static const SaveLoad _grfconfig_desc[] = {
|
|||||||
SLE_ARR(GRFConfig, ident.md5sum, SLE_UINT8, 16),
|
SLE_ARR(GRFConfig, ident.md5sum, SLE_UINT8, 16),
|
||||||
SLE_ARR(GRFConfig, param, SLE_UINT32, 0x80),
|
SLE_ARR(GRFConfig, param, SLE_UINT32, 0x80),
|
||||||
SLE_VAR(GRFConfig, num_params, SLE_UINT8),
|
SLE_VAR(GRFConfig, num_params, SLE_UINT8),
|
||||||
SLE_CONDVAR(GRFConfig, windows_paletted, SLE_BOOL, 101, SL_MAX_VERSION),
|
SLE_CONDVAR(GRFConfig, palette, SLE_UINT8, 101, SL_MAX_VERSION),
|
||||||
SLE_END()
|
SLE_END()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user