mirror of
https://github.com/sockspls/badfish
synced 2025-07-13 04:29:15 +00:00
Fix an issue when adding a book during the game
Currently when we fail to open a book file, for instance if it doesn't exsist, we leave Book::open() with ifstream failbit set. If then the book file is added, we correctly open it at next attempt, but failbit is still set so that after opening we exit because ifstream::good() returns false. The fix is to reset failbit upon exiting. No functional change. Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
parent
6828325881
commit
0412f4a1ee
1 changed files with 3 additions and 0 deletions
|
@ -378,7 +378,10 @@ bool Book::open(const char* fName) {
|
||||||
ifstream::open(fName, ifstream::in | ifstream::binary | ios::ate);
|
ifstream::open(fName, ifstream::in | ifstream::binary | ios::ate);
|
||||||
|
|
||||||
if (!is_open())
|
if (!is_open())
|
||||||
|
{
|
||||||
|
clear();
|
||||||
return false; // Silently fail if the file is not found
|
return false; // Silently fail if the file is not found
|
||||||
|
}
|
||||||
|
|
||||||
// Get the book size in number of entries, we are already at the end of file
|
// Get the book size in number of entries, we are already at the end of file
|
||||||
size = (size_t)tellg() / sizeof(BookEntry);
|
size = (size_t)tellg() / sizeof(BookEntry);
|
||||||
|
|
Loading…
Add table
Reference in a new issue