From 066b436fd97f8aa91799f1087e4f15e7a13f5e7f Mon Sep 17 00:00:00 2001 From: Edu Garcia <28616+Arcnor@users.noreply.github.com> Date: Fri, 19 Apr 2024 13:57:55 +0100 Subject: [PATCH] Revert "Cfile module update" --- 2dlib/font.cpp | 2 +- CMakeLists.txt | 2 +- Descent3/BriefingParse.cpp | 4 +- Descent3/ConfigItem.cpp | 2 +- Descent3/DllWrappers.cpp | 2 +- Descent3/DllWrappers.h | 2 +- Descent3/Inventory.h | 2 +- Descent3/LoadLevel.cpp | 2 +- Descent3/LoadLevel.h | 2 +- Descent3/Mission.cpp | 2 +- Descent3/OsirisLoadandBind.cpp | 6 +- Descent3/PilotPicsAPI.cpp | 2 +- Descent3/TelCom.cpp | 2 +- Descent3/TelComAutoMap.cpp | 2 +- Descent3/TelComCargo.cpp | 2 +- Descent3/TelComGoals.cpp | 2 +- Descent3/aiambient.cpp | 2 +- Descent3/aiambient.h | 2 +- Descent3/ambient.cpp | 1 + Descent3/audiotaunts.cpp | 2 +- Descent3/bsp.h | 2 +- Descent3/buddymenu.cpp | 2 +- Descent3/config.cpp | 2 +- Descent3/d3serial.cpp | 2 +- Descent3/dedicated_server.cpp | 4 +- Descent3/demofile.cpp | 2 +- Descent3/descent.cpp | 2 +- Descent3/game.cpp | 2 +- Descent3/gamesave.cpp | 2 +- Descent3/gamesave.h | 2 +- Descent3/help.cpp | 2 +- Descent3/hotspotmap.cpp | 2 +- Descent3/levelgoal.h | 2 +- Descent3/lnxmain.cpp | 5 +- Descent3/loadstate.cpp | 2 +- Descent3/localization.cpp | 2 +- Descent3/matcen.h | 2 +- Descent3/multi.cpp | 2 +- Descent3/multi_external.h | 2 +- Descent3/multi_save_setting.cpp | 2 +- Descent3/newui_filedlg.cpp | 2 +- Descent3/osiris_dll.h | 2 +- Descent3/osiris_predefs.h | 2 +- Descent3/pilot.cpp | 16 +-- Descent3/pilot_class.h | 2 +- Descent3/vclip.cpp | 2 +- Descent3/weapon.cpp | 2 +- bitmap/bitmain.cpp | 2 +- bitmap/iff.cpp | 2 +- bitmap/iff.h | 2 +- bitmap/tga.cpp | 2 +- cfile/{cfile.cpp => CFILE.cpp} | 186 +++++++++++------------------ cfile/CMakeLists.txt | 11 +- cfile/{inffile.cpp => InfFile.cpp} | 10 +- cfile/{hogfile.cpp => hog.cpp} | 164 +++++++++++++++++++++---- dd_lnxsound/lnxsound.cpp | 2 +- dd_lnxsound/sdlsound.cpp | 2 +- dd_sndlib/Ds3dlib.cpp | 2 +- dd_sndlib/aureal3d.cpp | 2 +- dd_sndlib/ddsoundload.cpp | 2 +- ddio_mac/macfile.cpp | 2 +- grtext/grfont.cpp | 2 +- cfile/cfile.h => lib/CFILE.H | 58 ++++----- cfile/inffile.h => lib/InfFile.h | 20 ++-- lib/bitmap.h | 2 +- {cfile => lib}/hogfile.h | 35 +++--- lib/manage.h | 2 +- lnxcontroller/lnxcontroller.cpp | 2 +- mac/MACDATA.CPP | 2 +- mac/MACGAMESPY.CPP | 2 +- mac/MACSOUND.CPP | 2 +- mac/MACSTREAMAUDIO.CPP | 2 +- manage/doorpage.cpp | 2 +- manage/doorpage.h | 2 +- manage/gamefilepage.cpp | 2 +- manage/gamefilepage.h | 2 +- manage/generic.cpp | 2 +- manage/genericpage.h | 2 +- manage/manage.cpp | 2 +- manage/megapage.cpp | 2 +- manage/megapage.h | 2 +- manage/pagelock.cpp | 2 +- manage/powerpage.h | 2 +- manage/robotpage.h | 2 +- manage/shippage.cpp | 2 +- manage/shippage.h | 2 +- manage/soundpage.cpp | 2 +- manage/soundpage.h | 2 +- manage/texpage.cpp | 2 +- manage/texpage.h | 2 +- manage/weaponpage.cpp | 2 +- manage/weaponpage.h | 2 +- music/omflex.cpp | 2 +- music/sequencer.cpp | 2 +- rtperformance/rtperformance.cpp | 2 +- sndlib/soundload.cpp | 2 +- stream_audio/osfarchive.cpp | 2 +- stream_audio/streamaudio.cpp | 2 +- win32/WinController.cpp | 2 +- 99 files changed, 378 insertions(+), 314 deletions(-) rename cfile/{cfile.cpp => CFILE.cpp} (92%) rename cfile/{inffile.cpp => InfFile.cpp} (96%) rename cfile/{hogfile.cpp => hog.cpp} (65%) rename cfile/cfile.h => lib/CFILE.H (91%) rename cfile/inffile.h => lib/InfFile.h (80%) rename {cfile => lib}/hogfile.h (62%) diff --git a/2dlib/font.cpp b/2dlib/font.cpp index 6ad0a172..e20bad27 100644 --- a/2dlib/font.cpp +++ b/2dlib/font.cpp @@ -102,7 +102,7 @@ #include "renderer.h" #include "gr.h" #include "mono.h" -#include "cfile/cfile.h" +#include "CFILE.H" #include "bitmap.h" #include "mem.h" diff --git a/CMakeLists.txt b/CMakeLists.txt index 6531c004..d18de3d3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -69,7 +69,7 @@ ENDIF () MESSAGE("Install will copy files to ${D3_GAMEDIR}") -include_directories("${CMAKE_SOURCE_DIR}" "lib" "Descent3" ${PLATFORM_INCLUDES}) +include_directories("lib" "Descent3" ${PLATFORM_INCLUDES}) # file(GLOB_RECURSE INCS "*.h") diff --git a/Descent3/BriefingParse.cpp b/Descent3/BriefingParse.cpp index 5f2ee2d4..77e7244d 100644 --- a/Descent3/BriefingParse.cpp +++ b/Descent3/BriefingParse.cpp @@ -47,7 +47,7 @@ #include #include #include -#include "cfile/cfile.h" +#include "CFILE.H" #include "pserror.h" #include "game.h" #include "mem.h" @@ -224,7 +224,7 @@ int ReadFullLine(char **data, CFILE *ifile) { // read in a byte c = cfgetc(ifile); - if ((c == EOF) || (!(ifile->flags & CFF_TEXT) && (c == 0)) || ((ifile->flags & CFF_TEXT) && (c == '\n'))) { + if ((c == EOF) || (!(ifile->flags & CF_TEXT) && (c == 0)) || ((ifile->flags & CF_TEXT) && (c == '\n'))) { // we've hit the end of the line done = true; } else { diff --git a/Descent3/ConfigItem.cpp b/Descent3/ConfigItem.cpp index 9e9c8215..59b1b185 100644 --- a/Descent3/ConfigItem.cpp +++ b/Descent3/ConfigItem.cpp @@ -77,7 +77,7 @@ #include "ddio.h" #include "gamefont.h" #include "multi_ui.h" -#include "cfile/cfile.h" +#include "CFILE.H" #include "mem.h" #include "game.h" #include "stringtable.h" diff --git a/Descent3/DllWrappers.cpp b/Descent3/DllWrappers.cpp index 13071abd..6f3df2c5 100644 --- a/Descent3/DllWrappers.cpp +++ b/Descent3/DllWrappers.cpp @@ -1,7 +1,7 @@ #include "DllWrappers.h" #include "pserror.h" #include "pstring.h" -#include "cfile/cfile.h" +#include "CFILE.H" #include "gamefont.h" #include "grdefs.h" #include "descent.h" diff --git a/Descent3/DllWrappers.h b/Descent3/DllWrappers.h index d5065d85..fb01c10c 100644 --- a/Descent3/DllWrappers.h +++ b/Descent3/DllWrappers.h @@ -2,7 +2,7 @@ #define DLLWRAPPERS_H_ #include "pserror.h" -#include "cfile/cfile.h" +#include "CFILE.H" #include "gamefont.h" #include "grdefs.h" #include "descent.h" diff --git a/Descent3/Inventory.h b/Descent3/Inventory.h index ba5f2aec..67dcabd3 100644 --- a/Descent3/Inventory.h +++ b/Descent3/Inventory.h @@ -164,7 +164,7 @@ #define __INVENTORY_H__ #include "pstypes.h" -#include "cfile/cfile.h" +#include "CFILE.H" struct object; diff --git a/Descent3/LoadLevel.cpp b/Descent3/LoadLevel.cpp index 905578aa..9ea7bbd0 100644 --- a/Descent3/LoadLevel.cpp +++ b/Descent3/LoadLevel.cpp @@ -1230,7 +1230,7 @@ #include "LoadLevel.h" -#include "cfile/cfile.h" +#include "CFILE.H" #include "descent.h" #include "object.h" diff --git a/Descent3/LoadLevel.h b/Descent3/LoadLevel.h index a681e277..deffe696 100644 --- a/Descent3/LoadLevel.h +++ b/Descent3/LoadLevel.h @@ -425,7 +425,7 @@ * $NoKeywords: $ */ -#include "cfile/cfile.h" +#include "CFILE.H" #include "room.h" // Chunk types diff --git a/Descent3/Mission.cpp b/Descent3/Mission.cpp index 49cd2daf..16228d12 100644 --- a/Descent3/Mission.cpp +++ b/Descent3/Mission.cpp @@ -622,7 +622,7 @@ #include "3d.h" #include "LoadLevel.h" #include "pserror.h" -#include "cfile/cfile.h" +#include "CFILE.H" #include "gamefont.h" #include "grdefs.h" #include "descent.h" diff --git a/Descent3/OsirisLoadandBind.cpp b/Descent3/OsirisLoadandBind.cpp index 245e16d1..8bd71e4c 100644 --- a/Descent3/OsirisLoadandBind.cpp +++ b/Descent3/OsirisLoadandBind.cpp @@ -384,7 +384,7 @@ #include "osiris_dll.h" #include "pserror.h" #include "mono.h" -#include "cfile/cfile.h" +#include "CFILE.H" #include "ddio.h" #include "manage.h" #include @@ -898,11 +898,11 @@ int _get_full_path_to_module(char *module_name, char *fullpath, char *basename) int exist = cfexist(modfilename); switch (exist) { - case CFES_ON_DISK: + case CF_ON_DISK: ddio_MakePath(fullpath, LocalScriptDir, modfilename, NULL); return -1; break; - case CFES_IN_LIBRARY: { + case CF_IN_LIBRARY: { ASSERT(OSIRIS_Extracted_script_dir); if (!OSIRIS_Extracted_script_dir) return -2; diff --git a/Descent3/PilotPicsAPI.cpp b/Descent3/PilotPicsAPI.cpp index 999449d2..bab2179e 100644 --- a/Descent3/PilotPicsAPI.cpp +++ b/Descent3/PilotPicsAPI.cpp @@ -45,7 +45,7 @@ #include "bitmap.h" #include "player.h" #include "pilot.h" -#include "cfile/cfile.h" +#include "CFILE.H" #include "mono.h" #include "ddio.h" #include "manage.h" diff --git a/Descent3/TelCom.cpp b/Descent3/TelCom.cpp index 71304acf..eee3098f 100644 --- a/Descent3/TelCom.cpp +++ b/Descent3/TelCom.cpp @@ -483,7 +483,7 @@ #include "ddio.h" #include "descent.h" #include "game.h" -#include "cfile/cfile.h" +#include "CFILE.H" #include "application.h" #include "TelCom.h" #include "TelComEffects.h" diff --git a/Descent3/TelComAutoMap.cpp b/Descent3/TelComAutoMap.cpp index 86440080..1ee12f9a 100644 --- a/Descent3/TelComAutoMap.cpp +++ b/Descent3/TelComAutoMap.cpp @@ -133,7 +133,7 @@ #include #include -#include "cfile/cfile.h" +#include "CFILE.H" #include "pserror.h" #include "ddio.h" #include "bitmap.h" diff --git a/Descent3/TelComCargo.cpp b/Descent3/TelComCargo.cpp index a4a771d6..47084571 100644 --- a/Descent3/TelComCargo.cpp +++ b/Descent3/TelComCargo.cpp @@ -64,7 +64,7 @@ #include #include -#include "cfile/cfile.h" +#include "CFILE.H" #include "pserror.h" #include "ddio.h" #include "bitmap.h" diff --git a/Descent3/TelComGoals.cpp b/Descent3/TelComGoals.cpp index 976f2502..ccbca61e 100644 --- a/Descent3/TelComGoals.cpp +++ b/Descent3/TelComGoals.cpp @@ -67,7 +67,7 @@ #include #include -#include "cfile/cfile.h" +#include "CFILE.H" #include "pserror.h" #include "ddio.h" #include "bitmap.h" diff --git a/Descent3/aiambient.cpp b/Descent3/aiambient.cpp index 5b9a3594..226d730f 100644 --- a/Descent3/aiambient.cpp +++ b/Descent3/aiambient.cpp @@ -1,7 +1,7 @@ -#include #include "aiambient.h" #include "string.h" #include "objinfo.h" +#include #include "game.h" #include "psrand.h" diff --git a/Descent3/aiambient.h b/Descent3/aiambient.h index 9c8b7506..a5b89fb9 100644 --- a/Descent3/aiambient.h +++ b/Descent3/aiambient.h @@ -1,7 +1,7 @@ #ifndef _AIAMBIENT_H_ #define _AIAMBIENT_H_ -#include "cfile/cfile.h" +#include "CFILE.H" #define MAX_AL_TYPES 6 #define MAX_ALS_PER_TYPE 130 diff --git a/Descent3/ambient.cpp b/Descent3/ambient.cpp index 4052a636..50e8199c 100644 --- a/Descent3/ambient.cpp +++ b/Descent3/ambient.cpp @@ -138,6 +138,7 @@ void InitAmbientSounds() { } #include "ddio.h" +#include "CFILE.H" #include "soundload.h" #include "descent.h" #include "mem.h" diff --git a/Descent3/audiotaunts.cpp b/Descent3/audiotaunts.cpp index e0e0f447..bebd8f03 100644 --- a/Descent3/audiotaunts.cpp +++ b/Descent3/audiotaunts.cpp @@ -6,7 +6,7 @@ #include "pserror.h" #include "pstypes.h" #include "audiotaunts.h" -#include "cfile/cfile.h" +#include "CFILE.H" #include "audio_encode.h" #include "byteswap.h" #include "mem.h" diff --git a/Descent3/bsp.h b/Descent3/bsp.h index c16c109e..563ba217 100644 --- a/Descent3/bsp.h +++ b/Descent3/bsp.h @@ -25,7 +25,7 @@ #include "list.h" #include "vecmat.h" -#include "cfile/cfile.h" +#include "CFILE.H" #define BSP_IN_FRONT 1 #define BSP_BEHIND 2 diff --git a/Descent3/buddymenu.cpp b/Descent3/buddymenu.cpp index 7f9f415b..c13ec500 100644 --- a/Descent3/buddymenu.cpp +++ b/Descent3/buddymenu.cpp @@ -41,7 +41,7 @@ #include "ddio.h" #include "descent.h" #include "game.h" -#include "cfile/cfile.h" +#include "CFILE.H" #include "application.h" #include #include diff --git a/Descent3/config.cpp b/Descent3/config.cpp index 2d4cf412..96357e80 100644 --- a/Descent3/config.cpp +++ b/Descent3/config.cpp @@ -278,7 +278,7 @@ #include "cinematics.h" #include "hlsoundlib.h" #include "terrain.h" -#include "cfile/cfile.h" +#include "CFILE.H" #include "mem.h" #include "lighting.h" #include "PHYSICS.H" diff --git a/Descent3/d3serial.cpp b/Descent3/d3serial.cpp index 9bbfe035..c6b63b87 100644 --- a/Descent3/d3serial.cpp +++ b/Descent3/d3serial.cpp @@ -65,7 +65,7 @@ #include "descent.h" #include #include "mono.h" -#include "cfile/cfile.h" +#include "CFILE.H" #include "program.h" #include diff --git a/Descent3/dedicated_server.cpp b/Descent3/dedicated_server.cpp index f29ea1ea..30751332 100644 --- a/Descent3/dedicated_server.cpp +++ b/Descent3/dedicated_server.cpp @@ -94,8 +94,8 @@ typedef int socklen_t; #include "pstypes.h" #include "pserror.h" #include "pstring.h" -#include "cfile/cfile.h" -#include "cfile/inffile.h" +#include "CFILE.H" +#include "InfFile.h" #include "dedicated_server.h" #include "multi.h" #include "args.h" diff --git a/Descent3/demofile.cpp b/Descent3/demofile.cpp index e4f684a2..1cb2e2b7 100644 --- a/Descent3/demofile.cpp +++ b/Descent3/demofile.cpp @@ -248,7 +248,7 @@ */ #include -#include "cfile/cfile.h" +#include "CFILE.H" #include "objinfo.h" #include "ship.h" #include "ui.h" diff --git a/Descent3/descent.cpp b/Descent3/descent.cpp index 9df7d611..67d1bc77 100644 --- a/Descent3/descent.cpp +++ b/Descent3/descent.cpp @@ -367,7 +367,7 @@ #include "pserror.h" #include "grdefs.h" #include "mono.h" -#include "cfile/cfile.h" +#include "CFILE.H" #include "init.h" #include "game.h" diff --git a/Descent3/game.cpp b/Descent3/game.cpp index 946b5835..1950829e 100644 --- a/Descent3/game.cpp +++ b/Descent3/game.cpp @@ -658,7 +658,7 @@ #include "cinematics.h" #include "SmallViews.h" #include "Mission.h" -#include "cfile/cfile.h" +#include "CFILE.H" #include "gameloop.h" #include "cockpit.h" #include "game2dll.h" diff --git a/Descent3/gamesave.cpp b/Descent3/gamesave.cpp index 1e5a2e38..b7d0f4b5 100644 --- a/Descent3/gamesave.cpp +++ b/Descent3/gamesave.cpp @@ -248,7 +248,7 @@ #include "gamesave.h" #include "descent.h" #include "newui.h" -#include "cfile/cfile.h" +#include "CFILE.H" #include "Mission.h" #include "gamesequence.h" #include "gameevent.h" diff --git a/Descent3/gamesave.h b/Descent3/gamesave.h index a1f90d5a..f9d695ae 100644 --- a/Descent3/gamesave.h +++ b/Descent3/gamesave.h @@ -67,7 +67,7 @@ #define GAMESAVE_H #include "pstypes.h" -#include "cfile/cfile.h" +#include "CFILE.H" #include "object.h" #include "objinfo.h" diff --git a/Descent3/help.cpp b/Descent3/help.cpp index 59c02a0e..b57285ba 100644 --- a/Descent3/help.cpp +++ b/Descent3/help.cpp @@ -114,7 +114,7 @@ #include "ddio.h" #include "descent.h" #include "game.h" -#include "cfile/cfile.h" +#include "CFILE.H" #include "application.h" #include #include diff --git a/Descent3/hotspotmap.cpp b/Descent3/hotspotmap.cpp index 44575516..8f146b73 100644 --- a/Descent3/hotspotmap.cpp +++ b/Descent3/hotspotmap.cpp @@ -87,7 +87,7 @@ #include "ddio.h" #include "descent.h" #include "game.h" -#include "cfile/cfile.h" +#include "CFILE.H" #include "application.h" #include #include diff --git a/Descent3/levelgoal.h b/Descent3/levelgoal.h index 47593941..9c3c591b 100644 --- a/Descent3/levelgoal.h +++ b/Descent3/levelgoal.h @@ -2,7 +2,7 @@ #define _LEVELGOAL_H_ #include "object.h" -#include "cfile/cfile.h" +#include "CFILE.H" #if defined(MACOSX) #include #else diff --git a/Descent3/lnxmain.cpp b/Descent3/lnxmain.cpp index 4eb8a83d..b9ef85a2 100644 --- a/Descent3/lnxmain.cpp +++ b/Descent3/lnxmain.cpp @@ -17,7 +17,6 @@ #include #define _GNU_SOURCE #include -#include "cfile/hogfile.h" #endif #include "SDL.h" @@ -313,6 +312,8 @@ void StartDedicatedServer(); static void hogfileRefresh(const char *x) { printf(" - %s\n", x); } // hogfileRefresh +int CreateNewHogFile(const char *hogname, int nfiles, const char **filenames, void (*UpdateFunction)(char *)); + // hack of the century. static void buildNewHogFromFileList(char *fileName) { setbuf(stdout, NULL); @@ -403,7 +404,7 @@ static void buildNewHogFromFileList(char *fileName) { } // for } while (swapped); - NewHogFile("new.hog", i, (const char **)files, (void (*)(char *))hogfileRefresh); + CreateNewHogFile("new.hog", i, (const char **)files, (void (*)(char *))hogfileRefresh); } // buildNewHogFileFromList #endif diff --git a/Descent3/loadstate.cpp b/Descent3/loadstate.cpp index a73f639a..71e15e49 100644 --- a/Descent3/loadstate.cpp +++ b/Descent3/loadstate.cpp @@ -163,7 +163,7 @@ #include "gamesave.h" #include "descent.h" -#include "cfile/cfile.h" +#include "CFILE.H" #include "Mission.h" #include "gamesequence.h" #include "gameevent.h" diff --git a/Descent3/localization.cpp b/Descent3/localization.cpp index ab21dfc1..7c42b8fd 100644 --- a/Descent3/localization.cpp +++ b/Descent3/localization.cpp @@ -73,7 +73,7 @@ #include "game.h" #include "descent.h" #include "mono.h" -#include "cfile/cfile.h" +#include "CFILE.H" #include "localization.h" #include "mem.h" #include "ddio.h" diff --git a/Descent3/matcen.h b/Descent3/matcen.h index 38ff872a..40a93cf2 100644 --- a/Descent3/matcen.h +++ b/Descent3/matcen.h @@ -1,7 +1,7 @@ #ifndef _MATCEN_H_ #define _MATCEN_H_ -#include "cfile/cfile.h" +#include "CFILE.H" #include "vecmat.h" #include "matcen_external.h" diff --git a/Descent3/multi.cpp b/Descent3/multi.cpp index 3b09279a..32b93216 100644 --- a/Descent3/multi.cpp +++ b/Descent3/multi.cpp @@ -7613,7 +7613,7 @@ void MultiAskForFile(ushort file_id, ushort file_who, ushort who) { // Check to see if this file exists already char *p = GetFileNameFromPlayerAndID(file_who, file_id); if (*p) { - if (CFES_ON_DISK == cfexist(p)) { + if (CF_ON_DISK == cfexist(p)) { char szcrc[_MAX_PATH]; char path[_MAX_PATH]; char ext[_MAX_PATH]; diff --git a/Descent3/multi_external.h b/Descent3/multi_external.h index a3f40560..aab4dd6e 100644 --- a/Descent3/multi_external.h +++ b/Descent3/multi_external.h @@ -95,7 +95,7 @@ #include "pstypes.h" #include "manage_external.h" -#include "cfile/cfile.h" +#include "CFILE.H" #include "networking.h" #include "descent.h" //for MSN_NAMELEN #include "byteswap.h" diff --git a/Descent3/multi_save_setting.cpp b/Descent3/multi_save_setting.cpp index ef75bfb3..bb4e9ab1 100644 --- a/Descent3/multi_save_setting.cpp +++ b/Descent3/multi_save_setting.cpp @@ -50,7 +50,7 @@ */ #include -#include "cfile/cfile.h" +#include "CFILE.H" #include "multi.h" #include "objinfo.h" #include "ship.h" diff --git a/Descent3/newui_filedlg.cpp b/Descent3/newui_filedlg.cpp index 733e34a3..0585385c 100644 --- a/Descent3/newui_filedlg.cpp +++ b/Descent3/newui_filedlg.cpp @@ -88,7 +88,7 @@ #include "ddio.h" #include "descent.h" #include "game.h" -#include "cfile/cfile.h" +#include "CFILE.H" #include "application.h" #include #include diff --git a/Descent3/osiris_dll.h b/Descent3/osiris_dll.h index a83a47e9..f3ef58f2 100644 --- a/Descent3/osiris_dll.h +++ b/Descent3/osiris_dll.h @@ -98,7 +98,7 @@ #include "object_external_struct.h" #include "osiris_share.h" #include "module.h" -#include "cfile/cfile.h" +#include "CFILE.H" extern uint Osiris_game_checksum; diff --git a/Descent3/osiris_predefs.h b/Descent3/osiris_predefs.h index 4f125910..e34147b2 100644 --- a/Descent3/osiris_predefs.h +++ b/Descent3/osiris_predefs.h @@ -156,7 +156,7 @@ #define __OSIRIS_PREDEF_H_ #include "osiris_dll.h" -#include "cfile/cfile.h" +#include "CFILE.H" // osipf_CallObjectEvent // Sends an event to an object. Returns true if the default action should diff --git a/Descent3/pilot.cpp b/Descent3/pilot.cpp index 80bd0a84..566586c1 100644 --- a/Descent3/pilot.cpp +++ b/Descent3/pilot.cpp @@ -563,7 +563,7 @@ #include "ddio.h" #include "descent.h" #include "game.h" -#include "cfile/cfile.h" +#include "CFILE.H" #include "application.h" #include "manage.h" #include "newui.h" @@ -933,7 +933,7 @@ void PilotSelect(void) { int res = -1; bool done = false; - if (cfexist(Default_pilot) != CFES_NOT_FOUND) { + if (cfexist(Default_pilot) != CF_NOT_FOUND) { // ok so the default pilot file is around, mark this as the current pilot Current_pilot.set_filename(Default_pilot); PltReadFile(&Current_pilot); @@ -984,7 +984,7 @@ void PilotSelect(void) { // use this in case they cancel out Current_pilot.get_filename(pfilename); - if (cfexist(pfilename) != CFES_NOT_FOUND) { + if (cfexist(pfilename) != CF_NOT_FOUND) { strcpy(old_file, pfilename); } else { old_file[0] = '\0'; @@ -1040,7 +1040,7 @@ void PilotSelect(void) { case UID_CANCEL: { // Cancel out - bool found_old = (cfexist(old_file) != CFES_NOT_FOUND); + bool found_old = (cfexist(old_file) != CF_NOT_FOUND); bool display_error; if (filecount && found_old) @@ -1494,7 +1494,7 @@ void NewPltUpdate(newuiListBox *list, char **flist, int filecount, int selected, list->SetCurrentIndex(selected); - if (filename && (cfexist(filename) != CFES_NOT_FOUND)) { + if (filename && (cfexist(filename) != CF_NOT_FOUND)) { // get the selected pilot from the filename mprintf((0, "Looking for Pilot: %s\n", filename)); for (int d = 0; d < filecount; d++) { @@ -2212,7 +2212,7 @@ bool CreateCRCFileName(const char *src, char *dest) { ASSERT(src); ASSERT(dest); - if (cfexist(src) != CFES_ON_DISK) + if (cfexist(src) != CF_ON_DISK) return false; unsigned int crc_value = cf_GetfileCRC((char *)src); @@ -2243,7 +2243,7 @@ bool CreateCRCFileName(const char *src, char *base, char *newfilename) { ASSERT(base); ASSERT(newfilename); - if (cfexist(src) != CFES_ON_DISK) + if (cfexist(src) != CF_ON_DISK) return false; unsigned int crc_value = cf_GetfileCRC((char *)src); @@ -2345,7 +2345,7 @@ float getdist(angle ang, float height) { // newfile = on return true is the filename of the new bitmap bool ImportGraphic(char *pathname, char *newfile) { ASSERT(pathname); - if (cfexist(pathname) != CFES_ON_DISK) { + if (cfexist(pathname) != CF_ON_DISK) { mprintf((0, "'%s' not found\n", pathname)); return false; } diff --git a/Descent3/pilot_class.h b/Descent3/pilot_class.h index e4f4559e..631cac83 100644 --- a/Descent3/pilot_class.h +++ b/Descent3/pilot_class.h @@ -72,7 +72,7 @@ #include "pstypes.h" #include "controls.h" #include "Controller.h" -#include "cfile/cfile.h" +#include "CFILE.H" #include "weapon.h" #include "config.h" diff --git a/Descent3/vclip.cpp b/Descent3/vclip.cpp index e44d6179..468905cf 100644 --- a/Descent3/vclip.cpp +++ b/Descent3/vclip.cpp @@ -142,7 +142,7 @@ #include "pserror.h" #include "bitmap.h" #include "vclip.h" -#include "cfile/cfile.h" +#include "CFILE.H" #include "mono.h" #include "ddio.h" #include "gametexture.h" diff --git a/Descent3/weapon.cpp b/Descent3/weapon.cpp index 21b986a9..78ba0db3 100644 --- a/Descent3/weapon.cpp +++ b/Descent3/weapon.cpp @@ -338,7 +338,7 @@ #include "sounds.h" #include "stringtable.h" #include "Macros.h" -#include "cfile/cfile.h" +#include "CFILE.H" #include "AIMain.h" #include diff --git a/bitmap/bitmain.cpp b/bitmap/bitmain.cpp index e5d9d7e6..db83c4bf 100644 --- a/bitmap/bitmain.cpp +++ b/bitmap/bitmain.cpp @@ -282,7 +282,7 @@ #include #include #include -#include "cfile/cfile.h" +#include "CFILE.H" #include "texture.h" #include "bitmap.h" #include "pstypes.h" diff --git a/bitmap/iff.cpp b/bitmap/iff.cpp index 098a242d..bec41c8e 100644 --- a/bitmap/iff.cpp +++ b/bitmap/iff.cpp @@ -56,7 +56,7 @@ #include "mem.h" #include "iff.h" #include "byteswap.h" -#include "cfile/cfile.h" +#include "CFILE.H" #include "pserror.h" #include "pstypes.h" #include "bitmap.h" diff --git a/bitmap/iff.h b/bitmap/iff.h index 31760267..e4d5405f 100644 --- a/bitmap/iff.h +++ b/bitmap/iff.h @@ -1,7 +1,7 @@ #ifndef _IFF_H #define _IFF_H -#include "cfile/cfile.h" +#include "CFILE.H" // Error codes for read & write routines diff --git a/bitmap/tga.cpp b/bitmap/tga.cpp index 4a92aae0..6c369bcf 100644 --- a/bitmap/tga.cpp +++ b/bitmap/tga.cpp @@ -114,7 +114,7 @@ * $NoKeywords: $ */ -#include "cfile/cfile.h" +#include "CFILE.H" #include "pserror.h" #include "pstypes.h" #include "bitmap.h" diff --git a/cfile/cfile.cpp b/cfile/CFILE.cpp similarity index 92% rename from cfile/cfile.cpp rename to cfile/CFILE.cpp index 4df2ef76..7932b49e 100644 --- a/cfile/cfile.cpp +++ b/cfile/CFILE.cpp @@ -15,15 +15,13 @@ // Linux Build Includes #include "linux/linux_fix.h" #endif - #include "byteswap.h" #include "pserror.h" #include "ddio.h" #include "psglob.h" -#include "cfile/cfile.h" -#include "cfile/hogfile.h" //info about library file +#include "CFILE.H" +#include "hogfile.h" //info about library file #include "mem.h" - // Library structures typedef struct { char name[PSFILENAME_LEN + 1]; // just the filename part @@ -32,30 +30,25 @@ typedef struct { ulong timestamp; // time and date of file int flags; // misc flags } library_entry; - typedef struct library { char name[_MAX_PATH]; // includes path + filename int nfiles; library_entry *entries; struct library *next; - int handle; // identifier for this lib + int handle; // indentifier for this lib FILE *file; // pointer to file for this lib, if no one using it } library; - // entry in extension->path table typedef struct { char ext[_MAX_EXT]; ubyte pathnum; } ext_entry; - // entry in list of paths typedef struct { char path[_MAX_PATH]; ubyte specific; // if non-zero, only for specific extensions } path_entry; - #define MAX_PATHS 100 - path_entry paths[MAX_PATHS]; int N_paths = 0; #define MAX_EXTENSIONS 100 @@ -63,12 +56,11 @@ ext_entry extensions[MAX_EXTENSIONS]; int N_extensions; library *Libraries = NULL; int lib_handle = 0; - +void cf_Close(); // Structure thrown on disk error cfile_error cfe; // The message for unexpected end of file char *eof_error = "Unexpected end of file"; - // Generates a cfile error void ThrowCFileError(int type, CFILE *file, char *msg) { cfe.read_write = type; @@ -76,9 +68,6 @@ void ThrowCFileError(int type, CFILE *file, char *msg) { cfe.file = file; throw &cfe; } - -void cf_Close(); - // Opens a HOG file. Future calls to cfopen(), etc. will look in this HOG. // Parameters: libname - the path & filename of the HOG file // NOTE: libname must be valid for the entire execution of the program. Therefore, it should either @@ -94,7 +83,7 @@ int cf_OpenLibrary(const char *libname) { tHogFileEntry entry; fp = fopen(libname, "rb"); - if (fp == nullptr) + if (fp == NULL) return 0; // CF_NO_FILE; fread(id, strlen(HOG_TAG_STR), 1, fp); if (strncmp(id, HOG_TAG_STR, strlen(HOG_TAG_STR))) { @@ -159,13 +148,10 @@ int cf_OpenLibrary(const char *libname) { // Sucess. Return the handle return lib->handle; } - -/** - * Closes a library file. - * @param handle the handle returned by cf_OpenLibrary() - */ +// Closes a library file. +// Parameters: handle: the handle returned by cf_OpenLibrary() void cf_CloseLibrary(int handle) { - library *lib, *prev = nullptr; + library *lib, *prev = NULL; for (lib = Libraries; lib; prev = lib, lib = lib->next) { if (lib->handle == handle) { if (prev) @@ -176,11 +162,10 @@ void cf_CloseLibrary(int handle) { fclose(lib->file); mem_free(lib->entries); mem_free(lib); - return; // successful close + return; // sucessful close } } } - // Closes down the CFILE system, freeing up all data, etc. void cf_Close() { library *next; @@ -229,23 +214,16 @@ int cf_SetSearchPath(const char *path, ...) { return 1; } -/** - * Removes all search paths that have been added by cf_SetSearchPath - */ -void cf_ClearAllSearchPaths() { +// Removes all search paths that have been added by cf_SetSearchPath +void cf_ClearAllSearchPaths(void) { N_paths = 0; N_extensions = 0; } -/** - * Opens a file for reading in a library, given the library id - * @param filename - * @param libhandle - * @return - */ +// Opens a file for reading in a library, given the library id CFILE *cf_OpenFileInLibrary(const char *filename, int libhandle) { if (libhandle <= 0) - return nullptr; + return NULL; library *lib; CFILE *cfile; @@ -258,9 +236,9 @@ CFILE *cf_OpenFileInLibrary(const char *filename, int libhandle) { lib = lib->next; } - if (nullptr == lib) { + if (NULL == lib) { // couldn't find the library handle - return nullptr; + return NULL; } // now do a binary search for the file entry @@ -280,10 +258,10 @@ CFILE *cf_OpenFileInLibrary(const char *filename, int libhandle) { first = i + 1; else // search key before check key last = i - 1; - } while (true); + } while (1); if (!found) - return nullptr; // file not in library + return NULL; // file not in library // open the file for reading FILE *fp; @@ -291,13 +269,13 @@ CFILE *cf_OpenFileInLibrary(const char *filename, int libhandle) { // See if there's an available FILE if (lib->file) { fp = lib->file; - lib->file = nullptr; + lib->file = NULL; } else { fp = fopen(lib->name, "rb"); if (!fp) { mprintf((1, "Error opening library <%s> when opening file <%s>; errno=%d.", lib->name, filename, errno)); Int3(); - return nullptr; + return NULL; } } cfile = (CFILE *)mem_malloc(sizeof(*cfile)); @@ -337,20 +315,20 @@ CFILE *open_file_in_lib(const char *filename) { first = i + 1; else // search key before check key last = i - 1; - } while (true); + } while (1); if (found) { FILE *fp; int r; // See if there's an available FILE if (lib->file) { fp = lib->file; - lib->file = nullptr; + lib->file = NULL; } else { fp = fopen(lib->name, "rb"); if (!fp) { mprintf((1, "Error opening library <%s> when opening file <%s>; errno=%d.", lib->name, filename, errno)); Int3(); - return nullptr; + return NULL; } } cfile = (CFILE *)mem_malloc(sizeof(*cfile)); @@ -369,7 +347,7 @@ CFILE *open_file_in_lib(const char *filename) { } lib = lib->next; } - return nullptr; + return NULL; } #ifdef __LINUX__ @@ -386,7 +364,7 @@ public: bool Start(const char *wildcard, char *namebuf); bool Next(char *namebuf); - void Close(); + void Close(void); private: int globindex; @@ -415,7 +393,7 @@ bool CFindFiles::Start(const char *wildcard, char *namebuf) { globindex = 0; char ext[256]; - ddio_SplitPath(ffres.gl_pathv[0], nullptr, namebuf, ext); + ddio_SplitPath(ffres.gl_pathv[0], NULL, namebuf, ext); strcat(namebuf, ext); return true; } @@ -429,12 +407,12 @@ bool CFindFiles::Next(char *namebuf) { return false; char ext[256]; - ddio_SplitPath(ffres.gl_pathv[globindex], nullptr, namebuf, ext); + ddio_SplitPath(ffres.gl_pathv[globindex], NULL, namebuf, ext); strcat(namebuf, ext); return true; } -void CFindFiles::Close() { +void CFindFiles::Close(void) { if (globindex == -1) return; globindex = -1; @@ -471,7 +449,7 @@ bool cf_FindRealFileNameCaseInsenstive(const char *directory, const char *fname, mprintf((1, "CFILE: Found directory \"%s\" in filename, new filename is \"%s\"\n", real_dir, real_file)); } else { use_dir = false; - real_dir = nullptr; + real_dir = NULL; real_file = (char *)fname; } } @@ -578,7 +556,7 @@ FILE *open_file_in_directory_case_sensitive(const char *directory, const char *f if (cf_FindRealFileNameCaseInsenstive(directory, filename, new_filename)) { // we have a file, open it open and use it char full_path[_MAX_PATH * 2]; - if (directory != nullptr) { + if (directory != NULL) { ddio_MakePath(full_path, directory, new_filename, NULL); } else { strcpy(full_path, new_filename); @@ -587,7 +565,7 @@ FILE *open_file_in_directory_case_sensitive(const char *directory, const char *f return fopen(full_path, mode); } - return nullptr; + return NULL; } #endif @@ -597,7 +575,7 @@ CFILE *open_file_in_directory(const char *filename, const char *mode, const char CFILE *cfile; char path[_MAX_PATH * 2]; char tmode[3] = "rb"; - if (directory != nullptr) { + if (directory != NULL) { // Make a full path ddio_MakePath(path, directory, filename, NULL); } else // no directory specified, so just use filename passed @@ -638,7 +616,7 @@ CFILE *open_file_in_directory(const char *filename, const char *mode, const char fp = open_file_in_directory_case_sensitive(directory, filename, tmode, using_filename); if (!fp) { // no dice - return nullptr; + return NULL; } else { // found a version of the file! mprintf((0, "CFILE: Unable to find %s, but using %s instead\n", filename, using_filename)); @@ -696,9 +674,9 @@ CFILE *cfopen(const char *filename, const char *mode) { ddio_SplitPath(filename, path, fname, ext); // if there is a path specified, use it instead of the libraries, search dirs, etc. // if the file is writable, just open it, instead of looking in libs, etc. - if (strlen(path) || (mode[0] == 'w')) { // found a path - cfile = open_file_in_directory(filename, mode, nullptr); // use path specified with file - goto got_file; // don't look in libs, etc. + if (strlen(path) || (mode[0] == 'w')) { // found a path + cfile = open_file_in_directory(filename, mode, NULL); // use path specified with file + goto got_file; // don't look in libs, etc. } //@@ Don't look in current dir. mt, 3-12-97 //@@ //first look in current directory @@ -726,17 +704,15 @@ CFILE *cfopen(const char *filename, const char *mode) { got_file:; if (cfile) { if (mode[0] == 'w') - cfile->flags |= CFF_WRITING; + cfile->flags |= CF_WRITING; if (mode[1] == 't') - cfile->flags |= CFF_TEXT; + cfile->flags |= CF_TEXT; } return cfile; } - // Returns the length of the specified file // Parameters: cfp - the file pointer returned by cfopen() int cfilelength(CFILE *cfp) { return cfp->size; } - // Closes an open CFILE. // Parameters: cfile - the file pointer returned by cfopen() void cfclose(CFILE *cfp) { @@ -746,9 +722,9 @@ void cfclose(CFILE *cfp) { for (lib = Libraries; lib; lib = lib->next) { if (lib->handle == cfp->lib_handle) { // found the library // if library doesn't already have a file, give it this one - if (lib->file == nullptr) { + if (lib->file == NULL) { lib->file = cfp->file; - cfp->file = nullptr; + cfp->file = NULL; } break; } @@ -763,7 +739,6 @@ void cfclose(CFILE *cfp) { // free the cfile struct mem_free(cfp); } - // Just like stdio fgetc(), except works on a CFILE // Returns a char or EOF int cfgetc(CFILE *cfp) { @@ -782,7 +757,7 @@ int cfgetc(CFILE *cfp) { // do special newline handling for text files: // if CR or LF by itself, return as newline // if CR/LF pair, return as newline - if (cfp->flags & CFF_TEXT) { + if (cfp->flags & CF_TEXT) { if (c == 10) // return LF as newline c = '\n'; else if (c == 13) { // check for CR/LF pair @@ -823,13 +798,10 @@ int cfseek(CFILE *cfp, long int offset, int where) { cfp->position = ftell(cfp->file) - cfp->lib_offset; return c; } - // Just like stdio ftell(), except works on a CFILE int cftell(CFILE *cfp) { return cfp->position; } - // Returns true if at EOF int cfeof(CFILE *cfp) { return (cfp->position >= cfp->size); } - // Tells if the file exists // Returns non-zero if file exists. Also tells if the file is on disk // or in a hog - See return values in cfile.h @@ -840,12 +812,12 @@ int cfexist(const char *filename) { cfp = cfopen(filename, "rb"); if (!cfp) { // Didn't get file. Why? if (errno == EACCES) // File exists, but couldn't open it - return CFES_ON_DISK; // so say it exists on the disk + return CF_ON_DISK; //..so say it exists on the disk // DAJ if (errno != ENOENT) //Check if error is "file not found" // DAJ Int3(); //..warn if not - return CFES_NOT_FOUND; // Say we didn't find the file + return CF_NOT_FOUND; // Say we didn't find the file } - ret = cfp->lib_offset ? CFES_IN_LIBRARY : CFES_ON_DISK; + ret = cfp->lib_offset ? CF_IN_LIBRARY : CF_ON_DISK; cfclose(cfp); return ret; } @@ -857,7 +829,7 @@ int cfexist(const char *filename) { int cf_ReadBytes(ubyte *buf, int count, CFILE *cfp) { int i; char *error_msg = eof_error; // default error - ASSERT(!(cfp->flags & CFF_TEXT)); + ASSERT(!(cfp->flags & CF_TEXT)); if (cfp->position + count <= cfp->size) { i = fread(buf, 1, count, cfp->file); if (i == count) { @@ -881,22 +853,22 @@ int cf_ReadBytes(ubyte *buf, int count, CFILE *cfp) { // to be present. // Read and return an integer (32 bits) // Throws an exception of type (cfile_error *) if the OS returns an error on read -int32_t cf_ReadInt(CFILE *cfp) { - int32_t i; +int cf_ReadInt(CFILE *cfp) { + int i; cf_ReadBytes((ubyte *)&i, sizeof(i), cfp); return INTEL_INT(i); } // Read and return a short (16 bits) // Throws an exception of type (cfile_error *) if the OS returns an error on read -int16_t cf_ReadShort(CFILE *cfp) { - int16_t i; +short cf_ReadShort(CFILE *cfp) { + short i; cf_ReadBytes((ubyte *)&i, sizeof(i), cfp); return INTEL_SHORT(i); } // Read and return a byte (8 bits) // Throws an exception of type (cfile_error *) if the OS returns an error on read -int8_t cf_ReadByte(CFILE *cfp) { - int8_t i; +sbyte cf_ReadByte(CFILE *cfp) { + int i; i = cfgetc(cfp); if (i == EOF) ThrowCFileError(CFE_READING, cfp, cfeof(cfp) ? eof_error : strerror(errno)); @@ -904,8 +876,8 @@ int8_t cf_ReadByte(CFILE *cfp) { } // Read and return a float (32 bits) // Throws an exception of type (cfile_error *) if the OS returns an error on read -float_t cf_ReadFloat(CFILE *cfp) { - float_t f; +float cf_ReadFloat(CFILE *cfp) { + float f; cf_ReadBytes((ubyte *)&f, sizeof(f), cfp); #ifdef MACINTOSH float e = INTEL_FLOAT(f); // DAJ bash to zero if reads a NaN @@ -918,8 +890,8 @@ float_t cf_ReadFloat(CFILE *cfp) { } // Read and return a double (64 bits) // Throws an exception of type (cfile_error *) if the OS returns an error on read -double_t cf_ReadDouble(CFILE *cfp) { - double_t f; +double cf_ReadDouble(CFILE *cfp) { + double f; cf_ReadBytes((ubyte *)&f, sizeof(f), cfp); #ifdef BIG_ENDIAN { @@ -957,7 +929,7 @@ int cf_ReadString(char *buf, size_t n, CFILE *cfp) { break; } - if ((!(cfp->flags & CFF_TEXT) && (c == 0)) || ((cfp->flags & CFF_TEXT) && (c == '\n'))) + if ((!(cfp->flags & CF_TEXT) && (c == 0)) || ((cfp->flags & CF_TEXT) && (c == '\n'))) break; // end-of-string if (count < n - 1) // store char if room in buffer *bp++ = c; @@ -972,7 +944,7 @@ int cf_ReadString(char *buf, size_t n, CFILE *cfp) { // Throws an exception of type (cfile_error *) if the OS returns an error on write int cf_WriteBytes(const ubyte *buf, int count, CFILE *cfp) { int i; - if (!(cfp->flags & CFF_WRITING)) + if (!(cfp->flags & CF_WRITING)) return 0; ASSERT(count > 0); i = fwrite(buf, 1, count, cfp->file); @@ -994,10 +966,9 @@ int cf_WriteString(CFILE *cfp, const char *buf) { if (len != 0) // write string cf_WriteBytes((ubyte *)buf, len, cfp); // Terminate with newline (text file) or NULL (binary file) - cf_WriteByte(cfp, (cfp->flags & CFF_TEXT) ? '\n' : 0); + cf_WriteByte(cfp, (cfp->flags & CF_TEXT) ? '\n' : 0); return len + 1; } - // Just like stdio fprintf(), except works on a CFILE int cfprintf(CFILE *cfp, const char *format, ...) { #ifndef MACINTOSH @@ -1010,45 +981,40 @@ int cfprintf(CFILE *cfp, const char *format, ...) { return count; #endif } - // The following functions write numeric vales to a CFILE. All values are // stored to the file in Intel (little-endian) format. // All these throw an exception if there's an error on write. // Write an integer (32 bits) // Throws an exception of type (cfile_error *) if the OS returns an error on write -void cf_WriteInt(CFILE *cfp, int32_t i) { +void cf_WriteInt(CFILE *cfp, int i) { int t = INTEL_INT(i); cf_WriteBytes((ubyte *)&t, sizeof(t), cfp); } - // Write a short (16 bits) // Throws an exception of type (cfile_error *) if the OS returns an error on write -void cf_WriteShort(CFILE *cfp, int16_t s) { +void cf_WriteShort(CFILE *cfp, short s) { short t = INTEL_SHORT(s); cf_WriteBytes((ubyte *)&t, sizeof(t), cfp); } - // Write a byte (8 bits). // Throws an exception of type (cfile_error *) if the OS returns an error on write -void cf_WriteByte(CFILE *cfp, int8_t b) { +void cf_WriteByte(CFILE *cfp, sbyte b) { if (fputc(b, cfp->file) == EOF) ThrowCFileError(CFE_WRITING, cfp, strerror(errno)); cfp->position++; // If text file & writing newline, increment again for LF - if ((cfp->flags & CFF_TEXT) && (b == '\n')) // check for text mode newline + if ((cfp->flags & CF_TEXT) && (b == '\n')) // check for text mode newline cfp->position++; } - // Write a float (32 bits) // Throws an exception of type (cfile_error *) if the OS returns an error on write -void cf_WriteFloat(CFILE *cfp, float_t f) { +void cf_WriteFloat(CFILE *cfp, float f) { float t = INTEL_FLOAT(f); cf_WriteBytes((ubyte *)&t, sizeof(t), cfp); } - // Write a double (64 bits) // Throws an exception of type (cfile_error *) if the OS returns an error on write -void cf_WriteDouble(CFILE *cfp, double_t d) { +void cf_WriteDouble(CFILE *cfp, double d) { #ifdef BIG_ENDIAN { double t; @@ -1061,20 +1027,19 @@ void cf_WriteDouble(CFILE *cfp, double_t d) { #endif cf_WriteBytes((ubyte *)&d, sizeof(d), cfp); } - // Copies a file. Returns TRUE if copied ok. Returns FALSE if error opening either file. // Throws an exception of type (cfile_error *) if the OS returns an error on read or write bool cf_CopyFile(char *dest, const char *src, int copytime) { CFILE *infile, *outfile; if (!stricmp(dest, src)) - return true; // don't copy files if they are the same + return 1; // don't copy files if they are the same infile = (CFILE *)cfopen(src, "rb"); if (!infile) - return false; + return 0; outfile = (CFILE *)cfopen(dest, "wb"); if (!outfile) { cfclose(infile); - return false; + return 0; } int progress = 0; int readcount = 0; @@ -1100,16 +1065,13 @@ bool cf_CopyFile(char *dest, const char *src, int copytime) { if (!infile_lib_offset && copytime) { cf_CopyFileTime(dest, src); } - return true; + return 1; } - // Checks to see if two files are different. // Returns TRUE if the files are different, or FALSE if they are the same. bool cf_Diff(const char *a, const char *b) { return (ddio_FileDiff(a, b)); } - // Copies the file time from one file to another void cf_CopyFileTime(char *dest, const char *src) { ddio_CopyFileTime(dest, src); } - // Changes a files attributes (ie read/write only) void cf_ChangeFileAttributes(const char *name, int attr) { #ifdef MACINTOSH @@ -1119,7 +1081,6 @@ void cf_ChangeFileAttributes(const char *name, int attr) { Int3(); // Get Jason or Matt, file not found! #endif } - // rewinds cfile position void cf_Rewind(CFILE *fp) { if (fp->lib_offset) { @@ -1130,8 +1091,7 @@ void cf_Rewind(CFILE *fp) { } fp->position = 0; } - -// Calculates a 32-bit CRC for the specified file. a return code of -1 means file note found +// Calculates a 32 bit CRC for the specified file. a return code of -1 means file note found #define CRC32_POLYNOMIAL 0xEDB88320L #define CRC_BUFFER_SIZE 5000 @@ -1196,7 +1156,7 @@ unsigned int cf_GetfileCRC(char *src) { } char cfile_search_wildcard[256]; -library *cfile_search_library = nullptr; +library *cfile_search_library = NULL; int cfile_search_curr_index = 0; bool cfile_search_ispattern = false; // the following cf_LibraryFind function are similar to the ddio_Find functions as they look @@ -1242,7 +1202,6 @@ bool cf_LibraryFindFirst(int handle, const char *wildcard, char *buffer) { // we didn't find a match return false; } - bool cf_LibraryFindNext(char *buffer) { while (cfile_search_curr_index < cfile_search_library->nfiles) { if (cfile_search_ispattern) { @@ -1263,9 +1222,8 @@ bool cf_LibraryFindNext(char *buffer) { } return false; } - -void cf_LibraryFindClose() { - cfile_search_library = nullptr; +void cf_LibraryFindClose(void) { + cfile_search_library = NULL; cfile_search_curr_index = 0; cfile_search_ispattern = false; } @@ -1301,7 +1259,7 @@ bool cf_ReadHogFileEntry(int libr, const char *filename, tHogFileEntry *entry, i else // search key before check key last = i - 1; - } while (true); + } while (1); if (found) { strcpy(entry->name, lib->entries[i].name); diff --git a/cfile/CMakeLists.txt b/cfile/CMakeLists.txt index 3f8f63b4..ae569425 100644 --- a/cfile/CMakeLists.txt +++ b/cfile/CMakeLists.txt @@ -1,6 +1,7 @@ -set(CPPS - cfile.cpp - hogfile.cpp - inffile.cpp) +SET (HEADERS ) +SET (CPPS + CFILE.cpp + hog.cpp + InfFile.cpp) -add_library(cfile STATIC ${CPPS}) +ADD_LIBRARY(cfile STATIC ${HEADERS} ${CPPS}) \ No newline at end of file diff --git a/cfile/inffile.cpp b/cfile/InfFile.cpp similarity index 96% rename from cfile/inffile.cpp rename to cfile/InfFile.cpp index 0911f235..e6875d39 100644 --- a/cfile/inffile.cpp +++ b/cfile/InfFile.cpp @@ -2,21 +2,21 @@ // ////////////////////////////////////////////////////////////////////// -#include "cfile/inffile.h" +#include "InfFile.h" -#include "cfile/cfile.h" +#include "CFILE.H" #include "pstring.h" #include "pserror.h" #include -#define INFFILE_NULL (-1024) +#define INFFILE_NULL -1024 ////////////////////////////////////////////////////////////////////// // Construction/Destruction ////////////////////////////////////////////////////////////////////// -InfFile::InfFile() { m_fp = nullptr; } +InfFile::InfFile() { m_fp = NULL; } InfFile::~InfFile() { // close file and free symbol lists @@ -56,7 +56,7 @@ const char *InfFile::GetSymbolText(const char *name) { return (const char *)sym->t.text; } - return nullptr; + return NULL; } // opens an inf file, pass in a lexical analyzer that will return a command index. diff --git a/cfile/hogfile.cpp b/cfile/hog.cpp similarity index 65% rename from cfile/hogfile.cpp rename to cfile/hog.cpp index 4b0382d2..15ded7b5 100644 --- a/cfile/hogfile.cpp +++ b/cfile/hog.cpp @@ -84,7 +84,7 @@ #include "linux/linux_fix.h" #endif #include "byteswap.h" -#include "cfile/hogfile.h" +#include "hogfile.h" #include "pstypes.h" #include "Macros.h" #include "mem.h" @@ -134,7 +134,7 @@ bool FileCopy(FILE *ofp, FILE *ifp, int length) { return true; } bool ReadHogHeader(FILE *fp, tHogHeader *header) { - int res; + int res = 0; res = fread(&header->nfiles, sizeof(header->nfiles), 1, fp); header->nfiles = INTEL_INT(header->nfiles); res = fread(&header->file_data_offset, sizeof(header->file_data_offset), 1, fp); @@ -146,7 +146,7 @@ bool ReadHogHeader(FILE *fp, tHogHeader *header) { return false; } bool ReadHogEntry(FILE *fp, tHogFileEntry *entry) { - int res; + int res = 0; res = fread(entry->name, sizeof(char), HOG_FILENAME_LEN, fp); res = fread(&entry->flags, sizeof(entry->flags), 1, fp); entry->flags = INTEL_INT(entry->flags); @@ -161,8 +161,8 @@ bool ReadHogEntry(FILE *fp, tHogFileEntry *entry) { return false; } -bool WriteHogEntry(FILE *fp, tHogFileEntry *entry) { - int res; +bool WRITE_FILE_ENTRY(FILE *fp, tHogFileEntry *entry) { + int res = 0; res = fwrite(entry->name, sizeof(char), HOG_FILENAME_LEN, fp); res = fwrite(&entry->flags, sizeof(entry->flags), 1, fp); res = fwrite(&entry->len, sizeof(entry->len), 1, fp); @@ -173,11 +173,9 @@ bool WriteHogEntry(FILE *fp, tHogFileEntry *entry) { else return false; } - -// A modified version of NewHogFile() -// This one also takes a pointer to a function that will perform -// progress updates (for the user) -int NewHogFile(const char *hogname, int nfiles, const char **filenames, void (*UpdateFunction)(char *)) { +//////////////////////////////////////////////////////////////////////// +// create new hog file +int NewHogFile(const char *hogname, int nfiles, const char **filenames) { unsigned i; int table_pos; FILE *hog_fp; @@ -185,7 +183,7 @@ int NewHogFile(const char *hogname, int nfiles, const char **filenames, void (*U tHogFileEntry *table; char ext[_MAX_EXT]; hogerr_filename[0] = '\0'; - // allocate file table + // allocate file table if (nfiles <= 0) return HOGMAKER_ERROR; table = new tHogFileEntry[nfiles]; @@ -233,7 +231,125 @@ int NewHogFile(const char *hogname, int nfiles, const char **filenames, void (*U table_pos = strlen(HOG_TAG_STR) + HOG_HDR_SIZE; memset(&table[0], 0, sizeof(table[0])); for (i = 0; i < header.nfiles; i++) { - if (!WriteHogEntry(hog_fp, &table[0])) { + if (!WRITE_FILE_ENTRY(hog_fp, &table[0])) { + delete[] table; + fclose(hog_fp); + strcpy(hogerr_filename, hogname); + return HOGMAKER_OUTFILE; + } + } + // write files (& build index) + for (i = 0; i < header.nfiles; i++) { + FILE *ifp; +#if defined(__LINUX__) || defined(MACINTOSH) + struct stat mystat; +#else + struct _stat32 mystat; +#endif + + ifp = fopen(filenames[i], "rb"); + if (ifp == NULL) { + delete[] table; + fclose(hog_fp); + strcpy(hogerr_filename, filenames[i]); + return HOGMAKER_INFILE; + } + // JEFF: make call to ddio lib, linux doesn't have _splitpath + //_splitpath(filenames[i],NULL,NULL,table[i].name,ext); + ddio_SplitPath(filenames[i], NULL, table[i].name, ext); + _fstat32(fileno(ifp), &mystat); + + strcat(table[i].name, ext); + table[i].flags = 0; +#ifdef MACINTOSH + table[i].len = mystat.st_size; +#else + table[i].len = _filelength(fileno(ifp)); +#endif + table[i].timestamp = mystat.st_mtime; + if (!FileCopy(hog_fp, ifp, table[i].len)) { + delete[] table; + fclose(hog_fp); + strcpy(hogerr_filename, filenames[i]); + return HOGMAKER_COPY; + } + fclose(ifp); + } + // now write the real index + fseek(hog_fp, table_pos, SEEK_SET); + for (i = 0; i < header.nfiles; i++) { + if (!WRITE_FILE_ENTRY(hog_fp, &table[i])) { + delete[] table; + fclose(hog_fp); + strcpy(hogerr_filename, hogname); + return HOGMAKER_OUTFILE; + } + } + // cleanup + fclose(hog_fp); + delete[] table; + return HOGMAKER_OK; +} +// A modifed version of NewHogFile() +// This one also takes a pointer to a function that will perform +// progress updates (for the user) +int CreateNewHogFile(const char *hogname, int nfiles, const char **filenames, void (*UpdateFunction)(char *)) { + unsigned i; + int table_pos; + FILE *hog_fp; + tHogHeader header; + tHogFileEntry *table; + char ext[_MAX_EXT]; + hogerr_filename[0] = '\0'; + // allocate file table + if (nfiles <= 0) + return HOGMAKER_ERROR; + table = new tHogFileEntry[nfiles]; + if (!table) + return HOGMAKER_MEMORY; + // create new file + hog_fp = fopen(hogname, "wb"); + if (hog_fp == NULL) { + delete[] table; + strcpy(hogerr_filename, hogname); + return HOGMAKER_OPENOUTFILE; + } + // write the tag + if (!fwrite(HOG_TAG_STR, strlen(HOG_TAG_STR), 1, hog_fp)) { + delete[] table; + fclose(hog_fp); + strcpy(hogerr_filename, hogname); + return HOGMAKER_OUTFILE; + } + // write number of files + ubyte filler = 0xff; + header.nfiles = (unsigned)nfiles; + header.file_data_offset = strlen(HOG_TAG_STR) + HOG_HDR_SIZE + (sizeof(tHogFileEntry) * header.nfiles); + if (!fwrite(&header.nfiles, sizeof(header.nfiles), 1, hog_fp)) { + delete[] table; + fclose(hog_fp); + strcpy(hogerr_filename, hogname); + return HOGMAKER_OUTFILE; + } + if (!fwrite(&header.file_data_offset, sizeof(header.file_data_offset), 1, hog_fp)) { + delete[] table; + fclose(hog_fp); + strcpy(hogerr_filename, hogname); + return HOGMAKER_OUTFILE; + } + // write out filler + for (i = 0; i < HOG_HDR_SIZE - sizeof(tHogHeader); i++) + if (!fwrite(&filler, sizeof(ubyte), 1, hog_fp)) { + delete[] table; + fclose(hog_fp); + strcpy(hogerr_filename, hogname); + return HOGMAKER_OUTFILE; + } + // save file position of index table and write out dummy table + table_pos = strlen(HOG_TAG_STR) + HOG_HDR_SIZE; + memset(&table[0], 0, sizeof(table[0])); + for (i = 0; i < header.nfiles; i++) { + if (!WRITE_FILE_ENTRY(hog_fp, &table[0])) { delete[] table; fclose(hog_fp); strcpy(hogerr_filename, hogname); @@ -274,32 +390,30 @@ int NewHogFile(const char *hogname, int nfiles, const char **filenames, void (*U return HOGMAKER_COPY; } fclose(ifp); - if (UpdateFunction != nullptr) { - // Setup the update message and send it - char msg[256]; - int ipct = int(100.0 * (double(i) / double(header.nfiles))); - sprintf(msg, "Creating Hog File... (%d%% done)", ipct); + // Setup the update message and send it + char msg[256]; + int ipct = int(100.0 * (double(i) / double(header.nfiles))); + sprintf(msg, "Creating Hog File... (%d%% done)", ipct); + if (UpdateFunction != NULL) UpdateFunction(msg); - } } // now write the real index fseek(hog_fp, table_pos, SEEK_SET); for (i = 0; i < header.nfiles; i++) { - if (!WriteHogEntry(hog_fp, &table[i])) { + if (!WRITE_FILE_ENTRY(hog_fp, &table[i])) { delete[] table; fclose(hog_fp); strcpy(hogerr_filename, hogname); return HOGMAKER_OUTFILE; } } - // cleanup + // cleanup fclose(hog_fp); delete[] table; - if (UpdateFunction != nullptr) { - // Setup the update message and send it - char msg[256]; - sprintf(msg, "Done Creating Hog File."); + // Setup the update message and send it + char msg[256]; + sprintf(msg, "Done Creating Hog File."); + if (UpdateFunction != NULL) UpdateFunction(msg); - } return HOGMAKER_OK; } diff --git a/dd_lnxsound/lnxsound.cpp b/dd_lnxsound/lnxsound.cpp index 28923574..26971e91 100644 --- a/dd_lnxsound/lnxsound.cpp +++ b/dd_lnxsound/lnxsound.cpp @@ -90,7 +90,7 @@ #include #include #include -#include "cfile/cfile.h" +#include "CFILE.H" #include "pserror.h" #include "mono.h" #include "soundload.h" diff --git a/dd_lnxsound/sdlsound.cpp b/dd_lnxsound/sdlsound.cpp index 75270a76..3ae51cb6 100644 --- a/dd_lnxsound/sdlsound.cpp +++ b/dd_lnxsound/sdlsound.cpp @@ -12,7 +12,7 @@ #include #include #include -#include "cfile/cfile.h" +#include "CFILE.H" #include "pserror.h" #include "mono.h" #include "soundload.h" diff --git a/dd_sndlib/Ds3dlib.cpp b/dd_sndlib/Ds3dlib.cpp index 96b94cf5..44761d99 100644 --- a/dd_sndlib/Ds3dlib.cpp +++ b/dd_sndlib/Ds3dlib.cpp @@ -193,7 +193,7 @@ #include #include #include -#include "cfile/cfile.h" +#include "cfile.h" #include "pserror.h" #include "mono.h" #include "soundload.h" diff --git a/dd_sndlib/aureal3d.cpp b/dd_sndlib/aureal3d.cpp index 7f7cc3d3..2a7be19d 100644 --- a/dd_sndlib/aureal3d.cpp +++ b/dd_sndlib/aureal3d.cpp @@ -80,7 +80,7 @@ #include "pserror.h" #include "logfile.h" #include "Macros.h" -#include "cfile/inffile.h" +#include "inffile.h" typedef struct tA3D { diff --git a/dd_sndlib/ddsoundload.cpp b/dd_sndlib/ddsoundload.cpp index 19eec205..0f9e36fc 100644 --- a/dd_sndlib/ddsoundload.cpp +++ b/dd_sndlib/ddsoundload.cpp @@ -83,7 +83,7 @@ #else #include #endif -#include "cfile/cfile.h" +#include "CFILE.H" #include "mem.h" #include "pserror.h" #include diff --git a/ddio_mac/macfile.cpp b/ddio_mac/macfile.cpp index 9c4817f7..f5aadda7 100644 --- a/ddio_mac/macfile.cpp +++ b/ddio_mac/macfile.cpp @@ -64,7 +64,7 @@ #include "ddio_mac.h" #include "psglob.h" #include "mem.h" -#include "cfile/cfile.h" +#include "cfile.h" // --------------------------------------------------------------------------- // File Level Globals // --------------------------------------------------------------------------- diff --git a/grtext/grfont.cpp b/grtext/grfont.cpp index 4118c050..93d70048 100644 --- a/grtext/grfont.cpp +++ b/grtext/grfont.cpp @@ -90,7 +90,7 @@ */ #include "grtextlib.h" -#include "cfile/cfile.h" +#include "CFILE.H" #include "bitmap.h" #include "pserror.h" #include "renderer.h" diff --git a/cfile/cfile.h b/lib/CFILE.H similarity index 91% rename from cfile/cfile.h rename to lib/CFILE.H index 3f4c577b..6dd11765 100644 --- a/cfile/cfile.h +++ b/lib/CFILE.H @@ -76,9 +76,7 @@ #ifndef CFILE_H #define CFILE_H -#include -#include -#include +#include #include "pstypes.h" @@ -96,10 +94,8 @@ typedef struct CFILE { } CFILE; // Defines for cfile_error -enum CFileError { - CFE_READING = 1, - CFE_WRITING, -}; +#define CFE_READING 1 +#define CFE_WRITING 2 // The structure thrown by a cfile error typedef struct { @@ -109,17 +105,8 @@ typedef struct { } cfile_error; // Flags for CFILE struct -enum CFileFlags { - CFF_TEXT = 1, // if this bit set, file is text - CFF_WRITING, // if bit set, file opened for writing -}; - -// return values for cfexist() -enum CFileExitStatus { - CFES_NOT_FOUND = 0, - CFES_ON_DISK, - CFES_IN_LIBRARY, -}; +#define CF_TEXT 1 // if this bit set, file is text +#define CF_WRITING 2 // if bit set, file opened for writing // See if a file is in a hog bool cf_IsFileInHog(char *filename, char *hogname); @@ -143,7 +130,7 @@ void cf_CloseLibrary(int handle); int cf_SetSearchPath(const char *path, ...); // Removes all search paths that have been added by cf_SetSearchPath -void cf_ClearAllSearchPaths(); +void cf_ClearAllSearchPaths(void); // Opens a file for reading or writing // If a path is specified, will try to open the file only in that path. @@ -180,6 +167,11 @@ int cftell(CFILE *cfp); // Returns true if at EOF int cfeof(CFILE *cfp); +// return values for cfexist() +#define CF_NOT_FOUND 0 +#define CF_ON_DISK 1 +#define CF_IN_LIBRARY 2 + // Tells if the file exists // Returns non-zero if file exists. Also tells if the file is on disk // or in a hog - See return values in cfile.h @@ -200,23 +192,23 @@ int cf_ReadBytes(ubyte *buf, int count, CFILE *cfp); // Read and return an integer (32 bits) // Throws an exception of type (cfile_error *) if the OS returns an error on read -int32_t cf_ReadInt(CFILE *cfp); +int cf_ReadInt(CFILE *cfp); // Read and return a short (16 bits) // Throws an exception of type (cfile_error *) if the OS returns an error on read -int16_t cf_ReadShort(CFILE *cfp); +short cf_ReadShort(CFILE *cfp); // Read and return a byte (8 bits) // Throws an exception of type (cfile_error *) if the OS returns an error on read -int8_t cf_ReadByte(CFILE *cfp); +sbyte cf_ReadByte(CFILE *cfp); // Read and return a float (32 bits) // Throws an exception of type (cfile_error *) if the OS returns an error on read -float_t cf_ReadFloat(CFILE *cfp); +float cf_ReadFloat(CFILE *cfp); // Read and return a double (64 bits) // Throws an exception of type (cfile_error *) if the OS returns an error on read -double_t cf_ReadDouble(CFILE *cfp); +double cf_ReadDouble(CFILE *cfp); // Reads a string from a CFILE. If the file is type binary, this // function reads until a NULL or EOF is found. If the file is text, @@ -254,23 +246,23 @@ int cfprintf(CFILE *cfp, const char *format, ...); // Write an integer (32 bits) // Throws an exception of type (cfile_error *) if the OS returns an error on write -void cf_WriteInt(CFILE *cfp, int32_t i); +void cf_WriteInt(CFILE *cfp, int i); // Write a short (16 bits) // Throws an exception of type (cfile_error *) if the OS returns an error on write -void cf_WriteShort(CFILE *cfp, int16_t s); +void cf_WriteShort(CFILE *cfp, short s); // Write a byte (8 bits). If the byte is a newline & the file is a text file, writes a CR/LF pair. // Throws an exception of type (cfile_error *) if the OS returns an error on write -void cf_WriteByte(CFILE *cfp, int8_t b); +void cf_WriteByte(CFILE *cfp, sbyte b); // Write a float (32 bits) // Throws an exception of type (cfile_error *) if the OS returns an error on write -void cf_WriteFloat(CFILE *cfp, float_t f); +void cf_WriteFloat(CFILE *cfp, float f); // Write a double (64 bits) // Throws an exception of type (cfile_error *) if the OS returns an error on write -void cf_WriteDouble(CFILE *cfp, double_t d); +void cf_WriteDouble(CFILE *cfp, double d); // Copies a file. Returns TRUE if copied ok. Returns FALSE if error opening either file. // Throws an exception of type (cfile_error *) if the OS returns an error on read or write @@ -287,17 +279,17 @@ void cf_CopyFileTime(char *dest, const char *src); // Changes a files attributes (ie read/write only) void cf_ChangeFileAttributes(const char *name, int attr); -// rewinds cfile position +// rewinds cfile position void cf_Rewind(CFILE *fp); // Calculates a 32 bit CRC unsigned int cf_GetfileCRC(char *src); unsigned int cf_CalculateFileCRC(CFILE *fp); // same as cf_GetfileCRC, except works with CFILE pointers -// the following cf_LibraryFind function are similar to the ddio_Find functions as they look -// for files that match the wildcard passed in, however, this is to be used for hog files. +// the following cf_LibraryFind function are similar to the ddio_Find functions as they look +// for files that match the wildcard passed in, however, this is to be used for hog files. bool cf_LibraryFindFirst(int handle, const char *wildcard, char *buffer); bool cf_LibraryFindNext(char *buffer); -void cf_LibraryFindClose(); +void cf_LibraryFindClose(void); #endif diff --git a/cfile/inffile.h b/lib/InfFile.h similarity index 80% rename from cfile/inffile.h rename to lib/InfFile.h index 0db55e6f..08caec7c 100644 --- a/cfile/inffile.h +++ b/lib/InfFile.h @@ -2,8 +2,8 @@ // ////////////////////////////////////////////////////////////////////// -#ifndef INFFILE_H -#define INFFILE_H +#if !defined(AFX_INFFILE_H__D8F94664_216E_11D2_AF2D_0060089A8025__INCLUDED_) +#define AFX_INFFILE_H__D8F94664_216E_11D2_AF2D_0060089A8025__INCLUDED_ #if _MSC_VER >= 1000 #pragma once @@ -14,14 +14,12 @@ struct CFILE; -enum InfFileError { - INFFILE_LINELEN = 256, - INFFILE_CUSTOM = -128, - INFFILE_ERROR = -1, - INFFILE_COMMENT = -2, - INFFILE_EOL = -3, - INFFILE_SYMBOL = 1024, -}; +#define INFFILE_LINELEN 256 +#define INFFILE_CUSTOM -128 +#define INFFILE_ERROR -1 +#define INFFILE_COMMENT -2 +#define INFFILE_EOL -3 +#define INFFILE_SYMBOL 1024 class InfFile { public: @@ -70,4 +68,4 @@ public: int line() const { return m_line; }; }; -#endif +#endif // !defined(AFX_INFFILE_H__D8F94664_216E_11D2_AF2D_0060089A8025__INCLUDED_) diff --git a/lib/bitmap.h b/lib/bitmap.h index 69bdd91c..7f667fe9 100644 --- a/lib/bitmap.h +++ b/lib/bitmap.h @@ -1,7 +1,7 @@ #ifndef PSBITMAP_H #define PSBITMAP_H #include "pstypes.h" -#include "cfile/cfile.h" +#include "CFILE.H" #ifdef __LINUX__ #include "linux/linux_fix.h" //needed for stricmp's throughout bitmap lib #endif diff --git a/cfile/hogfile.h b/lib/hogfile.h similarity index 62% rename from cfile/hogfile.h rename to lib/hogfile.h index 8324b65c..1ee9e818 100644 --- a/cfile/hogfile.h +++ b/lib/hogfile.h @@ -42,7 +42,6 @@ #ifndef HOGFILE_H #define HOGFILE_H -#include #include "pstypes.h" #define HOG_HDR_SIZE (64) @@ -50,37 +49,37 @@ #define HOG_FILENAME_LEN (36) typedef struct tHogHeader { - uint32_t nfiles; // number of files in header - uint32_t file_data_offset; // offset in file to filedata. + unsigned nfiles; // number of files in header + unsigned file_data_offset; // offset in file to filedata. } tHogHeader; typedef struct tHogFileEntry { char name[HOG_FILENAME_LEN]; // file name - uint32_t flags; // extra info - uint32_t len; // length of file - uint32_t timestamp; // time of file. + unsigned flags; // extra info + unsigned len; // length of file + unsigned timestamp; // time of file. } tHogFileEntry; -enum HogErrors { - HOGMAKER_ERROR = 0, // Incorrect number of files passed in - HOGMAKER_OK, // Hog file was created successfully - HOGMAKER_MEMORY, // Could not allocate hog entry table - HOGMAKER_OUTFILE, // Error occurred writing to output hog file - HOGMAKER_INFILE, // An input file could not be found (filename is stored in hogerr_filename) - HOGMAKER_COPY, // An error occurred copying an input file into the hog file - HOGMAKER_OPENOUTFILE, // The specified hog file could not be opened for output -}; +#define HOGMAKER_ERROR 0 // Incorrect number of files passed in +#define HOGMAKER_OK 1 // Hog file was created successfully +#define HOGMAKER_MEMORY 2 // Could not allocated hog entry table +#define HOGMAKER_OUTFILE 3 // Error occurred writing to output hog file +#define HOGMAKER_INFILE 4 // An input file could not be found (filename is stored in hogerr_filename) +#define HOGMAKER_COPY 5 // An error occurred copying an input file into the hog file +#define HOGMAKER_OPENOUTFILE 6 // The specified hog file could not be opened for output // Used to return filenames involved in a NewHogFile() error extern char hogerr_filename[PSPATHNAME_LEN]; -int NewHogFile(const char *hogname, int nfiles, const char **filenames, void (*UpdateFunction)(char *) = nullptr); +int NewHogFile(const char *hogname, int nfiles, const char **filenames); bool ReadHogHeader(FILE *fp, tHogHeader *header); bool ReadHogEntry(FILE *fp, tHogFileEntry *entry); -bool WriteHogEntry(FILE *fp, tHogFileEntry *entry); +bool WRITE_FILE_ENTRY(FILE *fp, tHogFileEntry *entry); bool FileCopy(FILE *ofp, FILE *ifp, int length); +int CreateNewHogFile(const char *hogname, int nfiles, const char **filenames, void (*UpdateFunction)(char *)); + // returns hog cfile info, using a library handle opened via cf_OpenLibrary. bool cf_ReadHogFileEntry(int library, const char *filename, tHogFileEntry *entry, int *fileoffset); -#endif +#endif \ No newline at end of file diff --git a/lib/manage.h b/lib/manage.h index c68ea888..1296039f 100644 --- a/lib/manage.h +++ b/lib/manage.h @@ -3,7 +3,7 @@ #define MANAGE_H #include -#include "cfile/cfile.h" +#include "CFILE.H" #include "bitmap.h" #include "manage_external.h" diff --git a/lnxcontroller/lnxcontroller.cpp b/lnxcontroller/lnxcontroller.cpp index d9afdb48..a023c34f 100644 --- a/lnxcontroller/lnxcontroller.cpp +++ b/lnxcontroller/lnxcontroller.cpp @@ -29,7 +29,7 @@ #include "ddio.h" #include "pserror.h" #include "joystick.h" -#include "cfile/inffile.h" +#include "InfFile.h" // Sorry! This is needed for the semi-hacky mouselook support #include "descent.h" diff --git a/mac/MACDATA.CPP b/mac/MACDATA.CPP index 1026b6fb..d5602b0c 100644 --- a/mac/MACDATA.CPP +++ b/mac/MACDATA.CPP @@ -8,7 +8,7 @@ #include "appdatabase.h" #include #include "mem.h" -#include "cfile/cfile.h" +#include "cfile.h" #include "ddio.h" #include "ddio_mac.h" #include "descent.h" diff --git a/mac/MACGAMESPY.CPP b/mac/MACGAMESPY.CPP index afa4c960..ccab9dfd 100644 --- a/mac/MACGAMESPY.CPP +++ b/mac/MACGAMESPY.CPP @@ -32,7 +32,7 @@ #include "descent.h" #include "ddio.h" #include "args.h" -#include "cfile/cfile.h" +#include "CFILE.H" #include "program.h" #include #include diff --git a/mac/MACSOUND.CPP b/mac/MACSOUND.CPP index 148cfd2d..57de93c8 100644 --- a/mac/MACSOUND.CPP +++ b/mac/MACSOUND.CPP @@ -25,7 +25,7 @@ #include #include // #include -#include "cfile/cfile.h" +#include "CFILE.H" #include "pserror.h" #include "mono.h" #include "soundload.h" diff --git a/mac/MACSTREAMAUDIO.CPP b/mac/MACSTREAMAUDIO.CPP index 025b0a66..b4759c17 100644 --- a/mac/MACSTREAMAUDIO.CPP +++ b/mac/MACSTREAMAUDIO.CPP @@ -149,7 +149,7 @@ #include #include "streamaudio.h" #include "pserror.h" -#include "cfile/cfile.h" +#include "CFILE.H" #include "mem.h" #include "Macros.h" #include "ddio.h" diff --git a/manage/doorpage.cpp b/manage/doorpage.cpp index f80f4087..b195ec37 100644 --- a/manage/doorpage.cpp +++ b/manage/doorpage.cpp @@ -129,7 +129,7 @@ #include #endif -#include "cfile/cfile.h" +#include "CFILE.H" #include "manage.h" #include "door.h" #include "doorpage.h" diff --git a/manage/doorpage.h b/manage/doorpage.h index 3dff8c68..182e8b97 100644 --- a/manage/doorpage.h +++ b/manage/doorpage.h @@ -3,7 +3,7 @@ #include "manage.h" #include "door.h" -#include "cfile/cfile.h" +#include "CFILE.H" #include "pstypes.h" typedef struct { diff --git a/manage/gamefilepage.cpp b/manage/gamefilepage.cpp index 72951202..2672bb71 100644 --- a/manage/gamefilepage.cpp +++ b/manage/gamefilepage.cpp @@ -2,7 +2,7 @@ #include #endif -#include "cfile/cfile.h" +#include "CFILE.H" #include "manage.h" #include "mono.h" #include "pserror.h" diff --git a/manage/gamefilepage.h b/manage/gamefilepage.h index 43cfe029..659c4b7e 100644 --- a/manage/gamefilepage.h +++ b/manage/gamefilepage.h @@ -2,7 +2,7 @@ #define GAMEFILEPAGE_H #include "manage.h" -#include "cfile/cfile.h" +#include "CFILE.H" #include "pstypes.h" #include "gamefile.h" diff --git a/manage/generic.cpp b/manage/generic.cpp index 8f19c511..6d391ce0 100644 --- a/manage/generic.cpp +++ b/manage/generic.cpp @@ -337,7 +337,7 @@ #include #endif -#include "cfile/cfile.h" +#include "CFILE.H" #include "manage.h" #include "genericpage.h" #include "soundpage.h" diff --git a/manage/genericpage.h b/manage/genericpage.h index a3bad7c0..d3863b69 100644 --- a/manage/genericpage.h +++ b/manage/genericpage.h @@ -2,7 +2,7 @@ #define GENERICPAGE_H #include "manage.h" -#include "cfile/cfile.h" +#include "CFILE.H" #include "pstypes.h" #include "objinfo.h" #include "robotfirestruct.h" diff --git a/manage/manage.cpp b/manage/manage.cpp index 3d60e645..d0460717 100644 --- a/manage/manage.cpp +++ b/manage/manage.cpp @@ -438,7 +438,7 @@ #include "mono.h" #include "object.h" #include "ddio.h" -#include "cfile/cfile.h" +#include "CFILE.H" #include "appdatabase.h" #include "genericpage.h" #include "mem.h" diff --git a/manage/megapage.cpp b/manage/megapage.cpp index 4be68bf4..7e3c2be0 100644 --- a/manage/megapage.cpp +++ b/manage/megapage.cpp @@ -46,7 +46,7 @@ #if defined(WIN32) #include #endif -#include "cfile/cfile.h" +#include "CFILE.H" #include "manage.h" #include "megacell.h" #include "megapage.h" diff --git a/manage/megapage.h b/manage/megapage.h index efa389b1..2c347557 100644 --- a/manage/megapage.h +++ b/manage/megapage.h @@ -3,7 +3,7 @@ #include "manage.h" #include "megacell.h" -#include "cfile/cfile.h" +#include "CFILE.H" #include "pstypes.h" typedef struct { diff --git a/manage/pagelock.cpp b/manage/pagelock.cpp index 9c8c6645..e8167da4 100644 --- a/manage/pagelock.cpp +++ b/manage/pagelock.cpp @@ -160,7 +160,7 @@ #include #include #include -#include "cfile/cfile.h" +#include "CFILE.H" #include "manage.h" #include "pstypes.h" #include "pserror.h" diff --git a/manage/powerpage.h b/manage/powerpage.h index 6e6d931b..8c5a2fc5 100644 --- a/manage/powerpage.h +++ b/manage/powerpage.h @@ -2,7 +2,7 @@ #define POWERPAGE_H #include "manage.h" -#include "cfile/cfile.h" +#include "cfile.h" #include "pstypes.h" #include "powerup.h" diff --git a/manage/robotpage.h b/manage/robotpage.h index c2dfd44c..671ba50a 100644 --- a/manage/robotpage.h +++ b/manage/robotpage.h @@ -3,7 +3,7 @@ #include "manage.h" #include "robot.h" -#include "cfile/cfile.h" +#include "cfile.h" #include "pstypes.h" #include "objinfo.h" diff --git a/manage/shippage.cpp b/manage/shippage.cpp index dabc3270..fab0c84e 100644 --- a/manage/shippage.cpp +++ b/manage/shippage.cpp @@ -183,7 +183,7 @@ #include #endif -#include "cfile/cfile.h" +#include "CFILE.H" #include "manage.h" #include "ship.h" #include "shippage.h" diff --git a/manage/shippage.h b/manage/shippage.h index 66d86032..a52ec73f 100644 --- a/manage/shippage.h +++ b/manage/shippage.h @@ -3,7 +3,7 @@ #include "manage.h" #include "ship.h" -#include "cfile/cfile.h" +#include "CFILE.H" #include "pstypes.h" typedef struct { diff --git a/manage/soundpage.cpp b/manage/soundpage.cpp index 11e3b27b..f375fdd8 100644 --- a/manage/soundpage.cpp +++ b/manage/soundpage.cpp @@ -102,7 +102,7 @@ #if defined(WIN32) #include #endif -#include "cfile/cfile.h" +#include "CFILE.H" #include "manage.h" #include "soundpage.h" #include "mono.h" diff --git a/manage/soundpage.h b/manage/soundpage.h index 05740925..3e3c4bee 100644 --- a/manage/soundpage.h +++ b/manage/soundpage.h @@ -3,7 +3,7 @@ #include "manage.h" #include "soundload.h" -#include "cfile/cfile.h" +#include "CFILE.H" #include "pstypes.h" typedef struct { diff --git a/manage/texpage.cpp b/manage/texpage.cpp index 6428af08..4075acbc 100644 --- a/manage/texpage.cpp +++ b/manage/texpage.cpp @@ -243,7 +243,7 @@ #include #endif -#include "cfile/cfile.h" +#include "CFILE.H" #include "manage.h" #include "gametexture.h" #include "bitmap.h" diff --git a/manage/texpage.h b/manage/texpage.h index 18971db6..314d5d13 100644 --- a/manage/texpage.h +++ b/manage/texpage.h @@ -2,7 +2,7 @@ #define TEXPAGE_H #include "manage.h" -#include "cfile/cfile.h" +#include "CFILE.H" #include "pstypes.h" #include "procedurals.h" diff --git a/manage/weaponpage.cpp b/manage/weaponpage.cpp index d9c8fcc7..bb9fb254 100644 --- a/manage/weaponpage.cpp +++ b/manage/weaponpage.cpp @@ -272,7 +272,7 @@ #include #endif -#include "cfile/cfile.h" +#include "CFILE.H" #include "manage.h" #include "weapon.h" #include "weaponpage.h" diff --git a/manage/weaponpage.h b/manage/weaponpage.h index 635d116b..bc0da664 100644 --- a/manage/weaponpage.h +++ b/manage/weaponpage.h @@ -4,7 +4,7 @@ #include "manage.h" #include "weapon.h" -#include "cfile/cfile.h" +#include "CFILE.H" #include "pstypes.h" typedef struct { diff --git a/music/omflex.cpp b/music/omflex.cpp index d2368d84..50a64ed9 100644 --- a/music/omflex.cpp +++ b/music/omflex.cpp @@ -55,7 +55,7 @@ #include "music.h" #include "musiclib.h" -#include "cfile/inffile.h" +#include "InfFile.h" #include "mem.h" #include diff --git a/music/sequencer.cpp b/music/sequencer.cpp index b5149de5..50734fcc 100644 --- a/music/sequencer.cpp +++ b/music/sequencer.cpp @@ -132,7 +132,7 @@ #include "pserror.h" #include "ddio.h" #include "Macros.h" -#include "cfile/inffile.h" +#include "InfFile.h" #include "streamaudio.h" #include "mem.h" #include diff --git a/rtperformance/rtperformance.cpp b/rtperformance/rtperformance.cpp index 2b5a4dd5..19486004 100644 --- a/rtperformance/rtperformance.cpp +++ b/rtperformance/rtperformance.cpp @@ -46,7 +46,7 @@ #include "descent.h" #include "manage.h" #include "ddio.h" -#include "cfile/cfile.h" +#include "CFILE.H" #include #include diff --git a/sndlib/soundload.cpp b/sndlib/soundload.cpp index 08becc4d..4c48dc82 100644 --- a/sndlib/soundload.cpp +++ b/sndlib/soundload.cpp @@ -216,7 +216,7 @@ #include #include "ssl_lib.h" #include "object.h" -#include "cfile/cfile.h" +#include "CFILE.H" #include "ddio.h" #include "soundload.h" #include "weapon.h" diff --git a/stream_audio/osfarchive.cpp b/stream_audio/osfarchive.cpp index b3ea9665..0539a252 100644 --- a/stream_audio/osfarchive.cpp +++ b/stream_audio/osfarchive.cpp @@ -33,7 +33,7 @@ */ #include "streamaudio.h" -#include "cfile/cfile.h" +#include "CFILE.H" #include "pserror.h" #include diff --git a/stream_audio/streamaudio.cpp b/stream_audio/streamaudio.cpp index b4812a65..ac975995 100644 --- a/stream_audio/streamaudio.cpp +++ b/stream_audio/streamaudio.cpp @@ -148,7 +148,7 @@ */ #include "streamaudio.h" #include "pserror.h" -#include "cfile/cfile.h" +#include "CFILE.H" #include "mem.h" #include "Macros.h" #include "ddio.h" diff --git a/win32/WinController.cpp b/win32/WinController.cpp index e6a581e7..3b4f1315 100644 --- a/win32/WinController.cpp +++ b/win32/WinController.cpp @@ -302,7 +302,7 @@ #include "ddio.h" #include "joystick.h" #include "Macros.h" -#include "cfile/inffile.h" +#include "inffile.h" // Sorry! This is needed for the semi-hacky mouselook support #include "descent.h"