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

OpenTTD Source 15.3

newgrf_actc.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 "../string_func.h"
13#include "newgrf_bytereader.h"
14#include "newgrf_internal.h"
15
16#include "../safeguards.h"
17
18/* Action 0x0C */
19static void GRFComment(ByteReader &buf)
20{
21 /* <0C> [<ignored...>]
22 *
23 * V ignored Anything following the 0C is ignored */
24
25 if (!buf.HasData()) return;
26
27 std::string_view text = buf.ReadString();
28 GrfMsg(2, "GRFComment: {}", StrMakeValid(text));
29}
30
31template <> void GrfActionHandler<0x0C>::FileScan(ByteReader &) { }
32template <> void GrfActionHandler<0x0C>::SafetyScan(ByteReader &) { }
33template <> void GrfActionHandler<0x0C>::LabelScan(ByteReader &) { }
34template <> void GrfActionHandler<0x0C>::Init(ByteReader &buf) { GRFComment(buf); }
35template <> void GrfActionHandler<0x0C>::Reserve(ByteReader &) { }
36template <> void GrfActionHandler<0x0C>::Activation(ByteReader &buf) { GRFComment(buf); }
ByteReader
Class to read from a NewGRF file.
Definition newgrf_bytereader.h:18
ByteReader::ReadString
std::string_view ReadString()
Read a NUL-terminated string.
Definition newgrf_bytereader.h:91
newgrf_bytereader.h
NewGRF buffer reader definition.
newgrf_internal.h
NewGRF internal processing state.
StrMakeValid
static void StrMakeValid(Builder &builder, StringConsumer &consumer, StringValidationSettings settings)
Copies the valid (UTF-8) characters from consumer to the builder.
Definition string.cpp:119
GrfActionHandler
GRF action handler.
Definition newgrf_internal.h:37