OpenTTD Source 20251213-master-g1091fa6071
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}
uint32_t ReadDWord()
Read a single DWord (32 bits).
uint16_t ReadWord()
Read a single Word (16 bits).
uint32_t ReadVarSize(uint8_t size)
Read a value of the given number of bytes.
uint8_t ReadByte()
Read a single byte (8 bits).
NewGRF buffer reader definition.