OpenTTD Source 20250528-master-g3aca5d62a8
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 <http://www.gnu.org/licenses/>.
6 */
7
10#include "../stdafx.h"
11#include "../core/backup_type.hpp"
12#include "../string_func.h"
13#include "newgrf_bytereader.h"
14
15#include "../safeguards.h"
16
21uint32_t ByteReader::ReadVarSize(uint8_t size)
22{
23 switch (size) {
24 case 1: return this->ReadByte();
25 case 2: return this->ReadWord();
26 case 4: return this->ReadDWord();
27 default:
28 NOT_REACHED();
29 return 0;
30 }
31}
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.