Closed Ithamar closed 3 years ago
The only other instance of f.is_open()
is later on in the function at line 116, on line 115 we are re-using the ifstream instance f
to open another file:
115 f.open(ss.str()); 116 a.m_Valid = f.is_open();
The f.close() is meant to ensure that the instance is no longer associated with a file on the filesystem.
you are absolutely right, I should not try to do 2 things at the same time 😢 I just noticed I was testing with the HUNTDAT folder from the C2 demo, which indeed has no AREA1.MAP but has AREA2.MAP as demo. It was rightly marking AREA1 as invalid, but the code is not expecting an invalid item before a valid one 😛
Closing this merge request, I'll consider looking into a fix for the real issue here once the SDL port is done 👍
It's alright, it's just nice to see another enthusiast contributing. In regards to the demo, a special case may need to be made for it.
This function uses
f.is_open()
at the end to check if it was able to read the area description, although it just closed the file directly after successfully reading the file.Just removing the "early" close fixes the error, and makes the menu work again with retail C2 _RES.TXT files.