|
@@ -4,38 +4,42 @@
|
|
|
* This file is part of OpenTTD.
|
|
|
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
|
|
|
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
|
|
|
*/
|
|
|
|
|
|
/**
|
|
|
* @file newgrf_commons.cpp Implementation of the class OverrideManagerBase
|
|
|
* and its descendance, present and futur
|
|
|
*/
|
|
|
|
|
|
#include "stdafx.h"
|
|
|
#include "debug.h"
|
|
|
#include "landscape.h"
|
|
|
#include "house.h"
|
|
|
#include "industrytype.h"
|
|
|
#include "newgrf.h"
|
|
|
#include "newgrf_config.h"
|
|
|
#include "clear_map.h"
|
|
|
#include "station_map.h"
|
|
|
#include "tree_map.h"
|
|
|
#include "tunnelbridge_map.h"
|
|
|
#include "newgrf_object.h"
|
|
|
#include "genworld.h"
|
|
|
#include "newgrf_spritegroup.h"
|
|
|
#include "newgrf_text.h"
|
|
|
#include "livery.h"
|
|
|
#include "company_base.h"
|
|
|
#include "gui.h"
|
|
|
#include "strings_func.h"
|
|
|
|
|
|
#include "table/strings.h"
|
|
|
|
|
|
/**
|
|
|
* Constructor of generic class
|
|
|
* @param offset end of original data for this entity. i.e: houses = 110
|
|
|
* @param maximum of entities this manager can deal with. i.e: houses = 512
|
|
|
* @param invalid is the ID used to identify an invalid entity id
|
|
|
*/
|
|
|
OverrideManagerBase::OverrideManagerBase(uint16 offset, uint16 maximum, uint16 invalid)
|
|
|
{
|
|
|
max_offset = offset;
|
|
@@ -486,24 +490,56 @@ CommandCost GetErrorMessageFromLocationC
|
|
|
case 0x406: res = CommandCost(STR_ERROR_CAN_T_BUILD_ON_SEA); break;
|
|
|
case 0x407: res = CommandCost(STR_ERROR_CAN_T_BUILD_ON_CANAL); break;
|
|
|
case 0x408: res = CommandCost(STR_ERROR_CAN_T_BUILD_ON_RIVER); break;
|
|
|
default: res = CommandCost(GetGRFStringID(grfid, 0xD000 + cb_res)); break;
|
|
|
}
|
|
|
|
|
|
/* Copy some parameters from the registers to the error message text ref. stack */
|
|
|
res.UseTextRefStack(4);
|
|
|
|
|
|
return res;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Record that a NewGRF returned an unknown/invalid callback result.
|
|
|
* Also show an error to the user.
|
|
|
* @param grfid ID of the NewGRF causing the problem.
|
|
|
* @param cbid Callback causing the problem.
|
|
|
* @param cb_res Invalid result returned by the callback.
|
|
|
*/
|
|
|
void ErrorUnknownCallbackResult(uint32 grfid, uint16 cbid, uint16 cb_res)
|
|
|
{
|
|
|
GRFConfig *grfconfig = GetGRFConfig(grfid);
|
|
|
|
|
|
if (!HasBit(grfconfig->grf_bugs, GBUG_UNKNOWN_CB_RESULT)) {
|
|
|
SetBit(grfconfig->grf_bugs, GBUG_UNKNOWN_CB_RESULT);
|
|
|
SetDParamStr(0, grfconfig->GetName());
|
|
|
SetDParam(1, cbid);
|
|
|
SetDParam(2, cb_res);
|
|
|
ShowErrorMessage(STR_NEWGRF_BUGGY, STR_NEWGRF_BUGGY_UNKNOWN_CALLBACK_RESULT, WL_CRITICAL);
|
|
|
}
|
|
|
|
|
|
/* debug output */
|
|
|
char buffer[512];
|
|
|
|
|
|
SetDParamStr(0, grfconfig->GetName());
|
|
|
GetString(buffer, STR_NEWGRF_BUGGY, lastof(buffer));
|
|
|
DEBUG(grf, 0, "%s", buffer + 3);
|
|
|
|
|
|
SetDParam(1, cbid);
|
|
|
SetDParam(2, cb_res);
|
|
|
GetString(buffer, STR_NEWGRF_BUGGY_UNKNOWN_CALLBACK_RESULT, lastof(buffer));
|
|
|
DEBUG(grf, 0, "%s", buffer + 3);
|
|
|
}
|
|
|
|
|
|
/* static */ SmallVector<DrawTileSeqStruct, 8> NewGRFSpriteLayout::result_seq;
|
|
|
|
|
|
/**
|
|
|
* Clone the building sprites of a spritelayout.
|
|
|
* @param source The building sprites to copy.
|
|
|
*/
|
|
|
void NewGRFSpriteLayout::Clone(const DrawTileSeqStruct *source)
|
|
|
{
|
|
|
assert(this->seq == NULL);
|
|
|
assert(source != NULL);
|
|
|
|
|
|
size_t count = 1; // 1 for the terminator
|