OpenTTD Source 20250331-master-g3c15e0c889
newgrf_act0_canals.cpp
Go to the documentation of this file.
1/*
2 * This file is part of OpenTTD.
3 * 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.
4 * 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.
5 * 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/>.
6 */
7
10#include "../stdafx.h"
11#include "../debug.h"
12#include "newgrf_bytereader.h"
13#include "newgrf_internal.h"
14
15#include "../safeguards.h"
16
25static ChangeInfoResult CanalChangeInfo(uint first, uint last, int prop, ByteReader &buf)
26{
28
29 if (last > CF_END) {
30 GrfMsg(1, "CanalChangeInfo: Canal feature 0x{:02X} is invalid, max {}, ignoring", last, CF_END);
31 return CIR_INVALID_ID;
32 }
33
34 for (uint id = first; id < last; ++id) {
36
37 switch (prop) {
38 case 0x08:
39 cp->callback_mask = static_cast<CanalCallbackMasks>(buf.ReadByte());
40 break;
41
42 case 0x09:
43 cp->flags = buf.ReadByte();
44 break;
45
46 default:
47 ret = CIR_UNKNOWN;
48 break;
49 }
50 }
51
52 return ret;
53}
54
56template <> ChangeInfoResult GrfChangeInfoHandler<GSF_CANALS>::Activation(uint first, uint last, int prop, ByteReader &buf) { return CanalChangeInfo(first, last, prop, buf); }
Class to read from a NewGRF file.
uint8_t ReadByte()
Read a single byte (8 bits).
static ChangeInfoResult CanalChangeInfo(uint first, uint last, int prop, ByteReader &buf)
Define properties for water features.
NewGRF buffer reader definition.
NewGRF internal processing state.
ChangeInfoResult
Possible return values for the GrfChangeInfoHandler functions.
@ CIR_INVALID_ID
Attempt to modify an invalid ID.
@ CIR_UNKNOWN
Variable is unknown.
@ CIR_UNHANDLED
Variable was parsed but unread.
@ CIR_SUCCESS
Variable was parsed and read.
Canal properties local to the NewGRF.
Definition newgrf.h:41
CanalCallbackMasks callback_mask
Bitmask of canal callbacks that have to be called.
Definition newgrf.h:42
uint8_t flags
Flags controlling display.
Definition newgrf.h:43
std::array< CanalProperties, CF_END > canal_local_properties
Canal properties as set by this NewGRF.
Definition newgrf.h:149
GRF feature handler.
GRFFile * grffile
Currently processed GRF file.