mirror of https://github.com/OpenTTD/OpenTTD
(svn r12963) -Fix (r12960): loading some NewGRFs could cause an infinite loop.
parent
71800aa7c6
commit
50516f2372
|
@ -45,7 +45,7 @@ static Fio _fio;
|
||||||
/* Get current position in file */
|
/* Get current position in file */
|
||||||
uint32 FioGetPos()
|
uint32 FioGetPos()
|
||||||
{
|
{
|
||||||
return _fio.pos + (_fio.buffer - _fio.buffer_start) - FIO_BUFFER_SIZE;
|
return _fio.pos + (_fio.buffer - _fio.buffer_end);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *FioGetFilename(uint8 slot)
|
const char *FioGetFilename(uint8 slot)
|
||||||
|
@ -92,7 +92,11 @@ byte FioReadByte()
|
||||||
{
|
{
|
||||||
if (_fio.buffer == _fio.buffer_end) {
|
if (_fio.buffer == _fio.buffer_end) {
|
||||||
_fio.buffer = _fio.buffer_start;
|
_fio.buffer = _fio.buffer_start;
|
||||||
_fio.pos += fread(_fio.buffer, 1, FIO_BUFFER_SIZE, _fio.cur_fh);
|
size_t size = fread(_fio.buffer, 1, FIO_BUFFER_SIZE, _fio.cur_fh);
|
||||||
|
_fio.pos += size;
|
||||||
|
_fio.buffer_end = _fio.buffer_start + size;
|
||||||
|
|
||||||
|
if (size == 0) return 0;
|
||||||
}
|
}
|
||||||
return *_fio.buffer++;
|
return *_fio.buffer++;
|
||||||
}
|
}
|
||||||
|
|
|
@ -595,7 +595,7 @@ DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_MAP)
|
||||||
|
|
||||||
if (maptype == MAP_PACKET_NORMAL) {
|
if (maptype == MAP_PACKET_NORMAL) {
|
||||||
// We are still receiving data, put it to the file
|
// We are still receiving data, put it to the file
|
||||||
if (fwrite(p->buffer + p->pos, 1, p->size - p->pos, file_pointer) != p->size - p->pos) {
|
if (fwrite(p->buffer + p->pos, 1, p->size - p->pos, file_pointer) != (size_t)(p->size - p->pos)) {
|
||||||
_switch_mode_errorstr = STR_NETWORK_ERR_SAVEGAMEERROR;
|
_switch_mode_errorstr = STR_NETWORK_ERR_SAVEGAMEERROR;
|
||||||
return NETWORK_RECV_STATUS_SAVEGAME;
|
return NETWORK_RECV_STATUS_SAVEGAME;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue