I'm trying to compile and run the open source code for Alien vs Predator (2000). See https://app.assembla.com/spaces/avp_mod/git/source. The level map data is stored in .RIF files, which are compressed. The first thing on each level load is to read in the data from the file before de-compressing it. In VS 2017, reading the file truncates after a certain number of character reads because it starts pulling in negative character codes (-44, for example). This is using
std::ifstream infile;
inFile.open(file_name, std::ios::in | std::ios::binary | std::ios::ate);
Not certain it matters, but the last character it successfully pulls in is a null (\0). After that, all values are negative. Any idea how to read this file correctly? I can provide more information if needed.
I've also tried reading each character in one at a time, which is how I determined that the negatives were being pulled in.
Update: original code referenced in my comment below. On last line, "buffer" is filled with characters up to the point where the negative values begin to come in. This code, I assume, worked correctly as written in the original compiler (VS2010, I believe).
unsigned long bytes_read;
char * buffer;
char * buffer_ptr;
char id_buffer[9];
HANDLE rif_file = CreateFileA(file_name, GENERIC_READ, 0, 0, OPEN_EXISTING, FILE_FLAG_RANDOM_ACCESS, 0);
DWORD file_size = GetFileSize (rif_file, NULL);
if (!ReadFile(rif_file, id_buffer, 8, &bytes_read, 0)) {
CloseHandle(rif_file);
return 0;
}
buffer = new char[file_size];
if (!ReadFile(rif_file, buffer + 8, (file_size - 8), &bytes_read, 0))
Update 2: Link to one of the rif files: https://drive.google.com/open?id=18BJR_6CkeHPU25u1DY6RGQQVWmR-kGdP
Update 3: my test code
const char * file_name = "E3demoSP.RIF";
std::ifstream inFile;
size_t size = 0;
inFile.open(file_name, std::ios::in | std::ios::binary);
char* oData = 0;
char ch;
inFile.seekg(0, std::ios::end);
size = inFile.tellg();
std::cout << "Size of file: " << size;
inFile.seekg(0, std::ios::beg);
oData = new char[size + 1];
int counter = 0;
while (inFile >> std::noskipws >> ch) {
oData[counter] = ch;
counter++;
}
return 0;