From 7a3249ce14ac528a5cdf9ca2d0a62535cf2bb1cd Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Mon, 3 May 2010 18:23:15 +0000 Subject: Fix compiler warnings. Subversion-branch: /branches/raven-branch Subversion-revision: 1934 --- src/hexen/mn_menu.c | 47 ++++++++++++++++++++++++++++------------------- 1 file changed, 28 insertions(+), 19 deletions(-) (limited to 'src/hexen/mn_menu.c') diff --git a/src/hexen/mn_menu.c b/src/hexen/mn_menu.c index 09a8f1ea..9f37df66 100644 --- a/src/hexen/mn_menu.c +++ b/src/hexen/mn_menu.c @@ -679,6 +679,32 @@ static void DrawSaveMenu(void) DrawFileSlots(&SaveMenu); } +static boolean ReadDescriptionForSlot(int slot, char *description) +{ + FILE *fp; + boolean found; + char name[100]; + char versionText[HXS_VERSION_TEXT_LENGTH]; + + sprintf(name, "%shex%d.hxs", SavePath, slot); + + fp = fopen(name, "rb"); + + if (fp == NULL) + { + return false; + } + + found = fread(description, HXS_DESCRIPTION_LENGTH, 1, fp) == 1 + && fread(versionText, HXS_VERSION_TEXT_LENGTH, 1, fp) == 1; + + found = found && strcmp(versionText, HXS_VERSION_TEXT) == 0; + + fclose(fp); + + return found; +} + //=========================================================================== // // MN_LoadSlotText @@ -689,29 +715,12 @@ static void DrawSaveMenu(void) void MN_LoadSlotText(void) { - int slot; - FILE *fp; - char name[100]; - char versionText[HXS_VERSION_TEXT_LENGTH]; char description[HXS_DESCRIPTION_LENGTH]; - boolean found; + int slot; for (slot = 0; slot < 6; slot++) { - found = false; - sprintf(name, "%shex%d.hxs", SavePath, slot); - fp = fopen(name, "rb"); - if (fp) - { - fread(description, HXS_DESCRIPTION_LENGTH, 1, fp); - fread(versionText, HXS_VERSION_TEXT_LENGTH, 1, fp); - fclose(fp); - if (!strcmp(versionText, HXS_VERSION_TEXT)) - { - found = true; - } - } - if (found) + if (ReadDescriptionForSlot(slot, description)) { memcpy(SlotText[slot], description, SLOTTEXTLEN); SlotStatus[slot] = 1; -- cgit v1.2.3