OpenTTD Source: src/newgrf/newgrf_act10.cpp Source File

OpenTTD Source 15.3

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 <https://www.gnu.org/licenses/old-licenses/gpl-2.0>.
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
18 static 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_gps.grffile->labels.emplace_back(nfo_label, _cur_gps.nfo_line, _cur_gps.file->GetPos());
28
29 GrfMsg(2, "DefineGotoLabel: GOTO target with label 0x{:02X}", nfo_label);
30}
31
32template <> void GrfActionHandler<0x10>::FileScan(ByteReader &) { }
33template <> void GrfActionHandler<0x10>::SafetyScan(ByteReader &) { }
34template <> void GrfActionHandler<0x10>::LabelScan(ByteReader &buf) { DefineGotoLabel(buf); }
35template <> void GrfActionHandler<0x10>::Init(ByteReader &) { }
36template <> void GrfActionHandler<0x10>::Reserve(ByteReader &) { }
37template <> void GrfActionHandler<0x10>::Activation(ByteReader &) { }
ByteReader
Class to read from a NewGRF file.
Definition newgrf_bytereader.h:18
ByteReader::ReadByte
uint8_t ReadByte()
Read a single byte (8 bits).
Definition newgrf_bytereader.h:34
RandomAccessFile::GetPos
size_t GetPos() const
Get position in the file.
Definition random_access_file.cpp:71
DefineGotoLabel
static void DefineGotoLabel(ByteReader &buf)
Action 0x10 - Define goto label.
Definition newgrf_act10.cpp:18
newgrf_bytereader.h
NewGRF buffer reader definition.
newgrf_internal.h
NewGRF internal processing state.
GRFFile::labels
std::vector< GRFLabel > labels
List of labels.
Definition newgrf.h:133
GrfActionHandler
GRF action handler.
Definition newgrf_internal.h:37
GrfProcessingState::file
SpriteFile * file
File of currently processed GRF file.
Definition newgrf_internal.h:66
GrfProcessingState::grffile
GRFFile * grffile
Currently processed GRF file.
Definition newgrf_internal.h:67
GrfProcessingState::nfo_line
uint32_t nfo_line
Currently processed pseudo sprite number in the GRF.
Definition newgrf_internal.h:69