OpenTTD Source 20250331-master-g3c15e0c889
newgrf_act10.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
18static void DefineGotoLabel(ByteReader &buf)
19{
20 /* <10> <label> [<comment>]
21 *
22 * B label The label to define
23 * V comment Optional comment - ignored */
24
25 uint8_t nfo_label = buf.ReadByte();
26
27 _cur.grffile->labels.emplace_back(nfo_label, _cur.nfo_line, _cur.file->GetPos());
28
29 GrfMsg(2, "DefineGotoLabel: GOTO target with label 0x{:02X}", nfo_label);
30}
31
32template <> void GrfActionHandler<0x10>::FileScan(ByteReader &) { }
35template <> void GrfActionHandler<0x10>::Init(ByteReader &) { }
36template <> void GrfActionHandler<0x10>::Reserve(ByteReader &) { }
Class to read from a NewGRF file.
uint8_t ReadByte()
Read a single byte (8 bits).
size_t GetPos() const
Get position in the file.
static void DefineGotoLabel(ByteReader &buf)
Action 0x10 - Define goto label.
NewGRF buffer reader definition.
NewGRF internal processing state.
std::vector< GRFLabel > labels
List of labels.
Definition newgrf.h:132
GRF action handler.
SpriteFile * file
File of currently processed GRF file.
GRFFile * grffile
Currently processed GRF file.
uint32_t nfo_line
Currently processed pseudo sprite number in the GRF.