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

OpenTTD Source 15.0-RC2

newgrf_bytereader.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 "../string_func.h"
12#include "newgrf_bytereader.h"
13
14#include "../safeguards.h"
15
20uint32_t ByteReader::ReadVarSize(uint8_t size)
21{
22 switch (size) {
23 case 1: return this->ReadByte();
24 case 2: return this->ReadWord();
25 case 4: return this->ReadDWord();
26 default:
27 NOT_REACHED();
28 return 0;
29 }
30}
ByteReader::ReadDWord
uint32_t ReadDWord()
Read a single DWord (32 bits).
Definition newgrf_bytereader.h:66
ByteReader::ReadWord
uint16_t ReadWord()
Read a single Word (16 bits).
Definition newgrf_bytereader.h:45
ByteReader::ReadVarSize
uint32_t ReadVarSize(uint8_t size)
Read a value of the given number of bytes.
Definition newgrf_bytereader.cpp:20
ByteReader::ReadByte
uint8_t ReadByte()
Read a single byte (8 bits).
Definition newgrf_bytereader.h:34
newgrf_bytereader.h
NewGRF buffer reader definition.