carnivores-cpe / Carn2-Menu

Carnivores 2/IA Menu implementation using left over code from Interface.cpp and referencing the Carnivores 1 menu code.
Creative Commons Zero v1.0 Universal
4 stars 3 forks source link

Fix MakeOldAreaInfo so retail C2 _RES.TXT files work again #19

Closed Ithamar closed 3 years ago

Ithamar commented 3 years ago

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.

Rexhunter99 commented 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.

Ithamar commented 3 years ago

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 👍

Rexhunter99 commented 3 years ago

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.