From d2177bb6187f741f27a44a0c3667f7ac674b6049 Mon Sep 17 00:00:00 2001 From: Yamagi Burmeister Date: Sun, 3 Jun 2012 21:53:51 +0200 Subject: [PATCH] Open binary files in mode "rb" instead of "r" This subtile bug didn't show on unixoid platforms, but led to problems on Windows. --- TODO | 2 ++ src/common/filesystem.c | 8 ++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/TODO b/TODO index 00a3f252..aaaec002 100644 --- a/TODO +++ b/TODO @@ -22,6 +22,8 @@ Windows Port TODO - Replace rand() with randk() in Windows code. - Implement Sys_AppActivate() as soon as cl_hwnd is ported to Yamagi Quake II. +- Check of "rb" is the correct mode to open files in + filesystem.c The big plan: 1. Get the dedicated server builded (03/06/12) diff --git a/src/common/filesystem.c b/src/common/filesystem.c index 1a982dc2..32970a28 100644 --- a/src/common/filesystem.c +++ b/src/common/filesystem.c @@ -421,7 +421,7 @@ FS_FOpenFileRead(fsHandle_t * handle) { /* PAK */ file_from_pak = 1; - handle->file = fopen(pack->name, "r"); + handle->file = fopen(pack->name, "rb"); if (handle->file) { @@ -461,12 +461,12 @@ FS_FOpenFileRead(fsHandle_t * handle) /* Search in a directory tree. */ Com_sprintf(path, sizeof(path), "%s/%s", search->path, handle->name); - handle->file = fopen(path, "r"); + handle->file = fopen(path, "rb"); if (!handle->file) { strlwr(path); - handle->file = fopen(path, "r"); + handle->file = fopen(path, "rb"); } if (!handle->file) @@ -1030,7 +1030,7 @@ FS_LoadPAK(const char *packPath) dpackheader_t header; /* PAK file header. */ dpackfile_t info[MAX_FILES_IN_PACK]; /* PAK info. */ - handle = fopen(packPath, "r"); + handle = fopen(packPath, "rb"); if (handle == NULL) return (NULL);