openttd updated to 1.5.0-beta2
--HG-- branch : openttd
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
/* $Id: newgrf.cpp 26245 2014-01-12 18:01:50Z frosch $ */
|
||||
/* $Id: newgrf.cpp 27138 2015-02-06 21:56:50Z frosch $ */
|
||||
|
||||
/*
|
||||
* This file is part of OpenTTD.
|
||||
@@ -52,6 +52,8 @@
|
||||
#include "table/strings.h"
|
||||
#include "table/build_industry.h"
|
||||
|
||||
#include "safeguards.h"
|
||||
|
||||
/* TTDPatch extended GRF format codec
|
||||
* (c) Petr Baudis 2004 (GPL'd)
|
||||
* Changes by Florian octo Forster are (c) by the OpenTTD development team.
|
||||
@@ -375,7 +377,7 @@ void CDECL grfmsg(int severity, const char *str, ...)
|
||||
va_list va;
|
||||
|
||||
va_start(va, str);
|
||||
vsnprintf(buf, sizeof(buf), str, va);
|
||||
vseprintf(buf, lastof(buf), str, va);
|
||||
va_end(va);
|
||||
|
||||
DEBUG(grf, severity, "[%s:%d] %s", _cur.grfconfig->filename, _cur.nfo_line, buf);
|
||||
@@ -2694,13 +2696,13 @@ static ChangeInfoResult GlobalVarChangeInfo(uint gvid, int numinfo, int prop, By
|
||||
for (uint j = 0; j < SNOW_LINE_DAYS; j++) {
|
||||
table[i][j] = buf->ReadByte();
|
||||
if (_cur.grffile->grf_version >= 8) {
|
||||
if (table[i][j] != 0xFF) table[i][j] = table[i][j] * (1 + MAX_TILE_HEIGHT) / 256;
|
||||
if (table[i][j] != 0xFF) table[i][j] = table[i][j] * (1 + _settings_game.construction.max_heightlevel) / 256;
|
||||
} else {
|
||||
if (table[i][j] >= 128) {
|
||||
/* no snow */
|
||||
table[i][j] = 0xFF;
|
||||
} else {
|
||||
table[i][j] = table[i][j] * (1 + MAX_TILE_HEIGHT) / 128;
|
||||
table[i][j] = table[i][j] * (1 + _settings_game.construction.max_heightlevel) / 128;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3469,6 +3471,15 @@ static ChangeInfoResult IndustriesChangeInfo(uint indid, int numinfo, int prop,
|
||||
} else if (itt[k].gfx == 0xFF) {
|
||||
itt[k].ti.x = (int8)GB(itt[k].ti.x, 0, 8);
|
||||
itt[k].ti.y = (int8)GB(itt[k].ti.y, 0, 8);
|
||||
|
||||
/* When there were only 256x256 maps, TileIndex was a uint16 and
|
||||
* itt[k].ti was just a TileIndexDiff that was added to it.
|
||||
* As such negative "x" values were shifted into the "y" position.
|
||||
* x = -1, y = 1 -> x = 255, y = 0
|
||||
* Since GRF version 8 the position is interpreted as pair of independent int8.
|
||||
* For GRF version < 8 we need to emulate the old shifting behaviour.
|
||||
*/
|
||||
if (_cur.grffile->grf_version < 8 && itt[k].ti.x < 0) itt[k].ti.y += 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5592,6 +5603,7 @@ static const Action5Type _action5_types[] = {
|
||||
/* 0x15 */ { A5BLOCK_ALLOW_OFFSET, SPR_OPENTTD_BASE, 1, OPENTTD_SPRITE_COUNT, "OpenTTD GUI graphics" },
|
||||
/* 0x16 */ { A5BLOCK_ALLOW_OFFSET, SPR_AIRPORT_PREVIEW_BASE, 1, SPR_AIRPORT_PREVIEW_COUNT, "Airport preview graphics" },
|
||||
/* 0x17 */ { A5BLOCK_ALLOW_OFFSET, SPR_RAILTYPE_TUNNEL_BASE, 1, RAILTYPE_TUNNEL_BASE_COUNT, "Railtype tunnel base" },
|
||||
/* 0x18 */ { A5BLOCK_ALLOW_OFFSET, SPR_PALETTE_BASE, 1, PALETTE_SPRITE_COUNT, "Palette" },
|
||||
};
|
||||
|
||||
/* Action 0x05 */
|
||||
@@ -5824,7 +5836,7 @@ bool GetGlobalVariable(byte param, uint32 *value, const GRFFile *grffile)
|
||||
|
||||
case 0x20: { // snow line height
|
||||
byte snowline = GetSnowLine();
|
||||
if (_settings_game.game_creation.landscape == LT_ARCTIC && snowline <= MAX_TILE_HEIGHT) {
|
||||
if (_settings_game.game_creation.landscape == LT_ARCTIC && snowline <= _settings_game.construction.max_heightlevel) {
|
||||
*value = Clamp(snowline * (grffile->grf_version >= 8 ? 1 : TILE_HEIGHT), 0, 0xFE);
|
||||
} else {
|
||||
/* No snow */
|
||||
@@ -6004,7 +6016,7 @@ static void CfgApply(ByteReader *buf)
|
||||
static void DisableStaticNewGRFInfluencingNonStaticNewGRFs(GRFConfig *c)
|
||||
{
|
||||
GRFError *error = DisableGrf(STR_NEWGRF_ERROR_STATIC_GRF_CAUSES_DESYNC, c);
|
||||
error->data = strdup(_cur.grfconfig->GetName());
|
||||
error->data = stredup(_cur.grfconfig->GetName());
|
||||
}
|
||||
|
||||
/* Action 0x07
|
||||
@@ -6092,7 +6104,7 @@ static void SkipIf(ByteReader *buf)
|
||||
|
||||
case 0x0A: // GRFID is not nor will be active
|
||||
/* This is the only condtype that doesn't get ignored if the GRFID is not found */
|
||||
result = c == NULL || c->flags == GCS_DISABLED || c->status == GCS_NOT_FOUND;
|
||||
result = c == NULL || c->status == GCS_DISABLED || c->status == GCS_NOT_FOUND;
|
||||
break;
|
||||
|
||||
default: grfmsg(1, "SkipIf: Unsupported GRF condition type %02X. Ignoring", condtype); return;
|
||||
@@ -6367,7 +6379,7 @@ static void GRFLoadError(ByteReader *buf)
|
||||
error->custom_message = TranslateTTDPatchCodes(_cur.grffile->grfid, lang, true, message, NULL, SCC_RAW_STRING_POINTER);
|
||||
} else {
|
||||
grfmsg(7, "GRFLoadError: No custom message supplied.");
|
||||
error->custom_message = strdup("");
|
||||
error->custom_message = stredup("");
|
||||
}
|
||||
} else {
|
||||
error->message = msgstr[message_id];
|
||||
@@ -6379,7 +6391,7 @@ static void GRFLoadError(ByteReader *buf)
|
||||
error->data = TranslateTTDPatchCodes(_cur.grffile->grfid, lang, true, data);
|
||||
} else {
|
||||
grfmsg(7, "GRFLoadError: No message data supplied.");
|
||||
error->data = strdup("");
|
||||
error->data = stredup("");
|
||||
}
|
||||
|
||||
/* Only two parameter numbers can be used in the string. */
|
||||
@@ -6481,7 +6493,7 @@ static uint32 GetPatchVariable(uint8 param)
|
||||
|
||||
/* The maximum height of the map. */
|
||||
case 0x14:
|
||||
return MAX_TILE_HEIGHT;
|
||||
return _settings_game.construction.max_heightlevel;
|
||||
|
||||
/* Extra foundations base sprite */
|
||||
case 0x15:
|
||||
@@ -6736,7 +6748,7 @@ static void ParamSet(ByteReader *buf)
|
||||
if ((int32)src2 < 0) {
|
||||
res = src1 >> -(int32)src2;
|
||||
} else {
|
||||
res = src1 << src2;
|
||||
res = src1 << (src2 & 0x1F); // Same behaviour as in EvalAdjustT, mask 'value' to 5 bits, which should behave the same on all architectures.
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -6744,7 +6756,7 @@ static void ParamSet(ByteReader *buf)
|
||||
if ((int32)src2 < 0) {
|
||||
res = (int32)src1 >> -(int32)src2;
|
||||
} else {
|
||||
res = (int32)src1 << src2;
|
||||
res = (int32)src1 << (src2 & 0x1F); // Same behaviour as in EvalAdjustT, mask 'value' to 5 bits, which should behave the same on all architectures.
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -6888,7 +6900,7 @@ static void GRFInhibit(ByteReader *buf)
|
||||
if (file != NULL && file != _cur.grfconfig) {
|
||||
grfmsg(2, "GRFInhibit: Deactivating file '%s'", file->filename);
|
||||
GRFError *error = DisableGrf(STR_NEWGRF_ERROR_FORCEFULLY_DISABLED, file);
|
||||
error->data = strdup(_cur.grfconfig->GetName());
|
||||
error->data = stredup(_cur.grfconfig->GetName());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7239,7 +7251,7 @@ static void TranslateGRFStrings(ByteReader *buf)
|
||||
|
||||
char tmp[256];
|
||||
GetString(tmp, STR_NEWGRF_ERROR_AFTER_TRANSLATED_FILE, lastof(tmp));
|
||||
error->data = strdup(tmp);
|
||||
error->data = stredup(tmp);
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -7659,7 +7671,7 @@ AllowedSubtags _tags_root[] = {
|
||||
* Try to skip the current node and all subnodes (if it's a branch node).
|
||||
* @param buf Buffer.
|
||||
* @param type The node type to skip.
|
||||
* @return True if we could skip the node, false if an error occured.
|
||||
* @return True if we could skip the node, false if an error occurred.
|
||||
*/
|
||||
static bool SkipUnknownInfo(ByteReader *buf, byte type)
|
||||
{
|
||||
@@ -8180,7 +8192,7 @@ static void InitNewGRFFile(const GRFConfig *config)
|
||||
*/
|
||||
GRFFile::GRFFile(const GRFConfig *config)
|
||||
{
|
||||
this->filename = strdup(config->filename);
|
||||
this->filename = stredup(config->filename);
|
||||
this->grfid = config->ident.grfid;
|
||||
|
||||
/* Initialise local settings to defaults */
|
||||
@@ -9089,8 +9101,6 @@ static void FinalisePriceBaseMultipliers()
|
||||
}
|
||||
}
|
||||
|
||||
void InitDepotWindowBlockSizes();
|
||||
|
||||
extern void InitGRFTownGeneratorNames();
|
||||
|
||||
/** Finish loading NewGRFs and execute needed post-processing */
|
||||
@@ -9119,9 +9129,6 @@ static void AfterLoadGRFs()
|
||||
/* Set the actually used Canal properties */
|
||||
FinaliseCanals();
|
||||
|
||||
/* Set the block size in the depot windows based on vehicle sprite sizes */
|
||||
InitDepotWindowBlockSizes();
|
||||
|
||||
/* Add all new houses to the house array. */
|
||||
FinaliseHouseArray();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user