mirror of
https://github.com/kevinbentley/Descent3.git
synced 2025-01-22 11:28:56 +00:00
parent
9ff3bd2e53
commit
c275d359c7
@ -120,7 +120,7 @@
|
||||
#include "renderer.h"
|
||||
#include "gr.h"
|
||||
#include "mono.h"
|
||||
#include "CFILE.H"
|
||||
#include "cfile/cfile.h"
|
||||
#include "bitmap.h"
|
||||
#include "mem.h"
|
||||
|
||||
|
@ -104,7 +104,7 @@ if(LOGGER)
|
||||
add_definitions(-DLOGGER)
|
||||
endif()
|
||||
|
||||
include_directories("lib" "Descent3" ${PLATFORM_INCLUDES})
|
||||
include_directories("${CMAKE_SOURCE_DIR}" "lib" "Descent3" ${PLATFORM_INCLUDES})
|
||||
|
||||
# file(GLOB_RECURSE INCS "*.h")
|
||||
|
||||
|
@ -65,7 +65,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include "CFILE.H"
|
||||
#include "cfile/cfile.h"
|
||||
#include "pserror.h"
|
||||
#include "game.h"
|
||||
#include "mem.h"
|
||||
@ -242,7 +242,7 @@ int ReadFullLine(char **data, CFILE *ifile) {
|
||||
// read in a byte
|
||||
c = cfgetc(ifile);
|
||||
|
||||
if ((c == EOF) || (!(ifile->flags & CF_TEXT) && (c == 0)) || ((ifile->flags & CF_TEXT) && (c == '\n'))) {
|
||||
if ((c == EOF) || (!(ifile->flags & CFF_TEXT) && (c == 0)) || ((ifile->flags & CFF_TEXT) && (c == '\n'))) {
|
||||
// we've hit the end of the line
|
||||
done = true;
|
||||
} else {
|
||||
|
@ -95,7 +95,7 @@
|
||||
#include "ddio.h"
|
||||
#include "gamefont.h"
|
||||
#include "multi_ui.h"
|
||||
#include "CFILE.H"
|
||||
#include "cfile/cfile.h"
|
||||
#include "mem.h"
|
||||
#include "game.h"
|
||||
#include "stringtable.h"
|
||||
|
@ -19,7 +19,7 @@
|
||||
#include "DllWrappers.h"
|
||||
#include "pserror.h"
|
||||
#include "pstring.h"
|
||||
#include "CFILE.H"
|
||||
#include "cfile/cfile.h"
|
||||
#include "gamefont.h"
|
||||
#include "grdefs.h"
|
||||
#include "descent.h"
|
||||
|
@ -20,7 +20,7 @@
|
||||
#define DLLWRAPPERS_H_
|
||||
|
||||
#include "pserror.h"
|
||||
#include "CFILE.H"
|
||||
#include "cfile/cfile.h"
|
||||
#include "gamefont.h"
|
||||
#include "grdefs.h"
|
||||
#include "descent.h"
|
||||
|
@ -182,7 +182,7 @@
|
||||
#define __INVENTORY_H__
|
||||
|
||||
#include "pstypes.h"
|
||||
#include "CFILE.H"
|
||||
#include "cfile/cfile.h"
|
||||
|
||||
struct object;
|
||||
|
||||
|
@ -1248,7 +1248,7 @@
|
||||
|
||||
#include "LoadLevel.h"
|
||||
|
||||
#include "CFILE.H"
|
||||
#include "cfile/cfile.h"
|
||||
|
||||
#include "descent.h"
|
||||
#include "object.h"
|
||||
|
@ -443,7 +443,7 @@
|
||||
* $NoKeywords: $
|
||||
*/
|
||||
|
||||
#include "CFILE.H"
|
||||
#include "cfile/cfile.h"
|
||||
#include "room.h"
|
||||
|
||||
// Chunk types
|
||||
|
@ -640,7 +640,7 @@
|
||||
#include "3d.h"
|
||||
#include "LoadLevel.h"
|
||||
#include "pserror.h"
|
||||
#include "CFILE.H"
|
||||
#include "cfile/cfile.h"
|
||||
#include "gamefont.h"
|
||||
#include "grdefs.h"
|
||||
#include "descent.h"
|
||||
|
@ -402,7 +402,7 @@
|
||||
#include "osiris_dll.h"
|
||||
#include "pserror.h"
|
||||
#include "mono.h"
|
||||
#include "CFILE.H"
|
||||
#include "cfile/cfile.h"
|
||||
#include "ddio.h"
|
||||
#include "manage.h"
|
||||
#include <stdlib.h>
|
||||
@ -917,11 +917,11 @@ int _get_full_path_to_module(char *module_name, char *fullpath, char *basename)
|
||||
|
||||
int exist = cfexist(modfilename);
|
||||
switch (exist) {
|
||||
case CF_ON_DISK:
|
||||
case CFES_ON_DISK:
|
||||
ddio_MakePath(fullpath, LocalScriptDir, modfilename, NULL);
|
||||
return -1;
|
||||
break;
|
||||
case CF_IN_LIBRARY: {
|
||||
case CFES_IN_LIBRARY: {
|
||||
ASSERT(OSIRIS_Extracted_script_dir);
|
||||
if (!OSIRIS_Extracted_script_dir)
|
||||
return -2;
|
||||
|
@ -63,7 +63,7 @@
|
||||
#include "bitmap.h"
|
||||
#include "player.h"
|
||||
#include "pilot.h"
|
||||
#include "CFILE.H"
|
||||
#include "cfile/cfile.h"
|
||||
#include "mono.h"
|
||||
#include "ddio.h"
|
||||
#include "manage.h"
|
||||
|
@ -501,7 +501,7 @@
|
||||
#include "ddio.h"
|
||||
#include "descent.h"
|
||||
#include "game.h"
|
||||
#include "CFILE.H"
|
||||
#include "cfile/cfile.h"
|
||||
#include "application.h"
|
||||
#include "TelCom.h"
|
||||
#include "TelComEffects.h"
|
||||
|
@ -151,7 +151,7 @@
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include "CFILE.H"
|
||||
#include "cfile/cfile.h"
|
||||
#include "pserror.h"
|
||||
#include "ddio.h"
|
||||
#include "bitmap.h"
|
||||
|
@ -82,7 +82,7 @@
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include "CFILE.H"
|
||||
#include "cfile/cfile.h"
|
||||
#include "pserror.h"
|
||||
#include "ddio.h"
|
||||
#include "bitmap.h"
|
||||
|
@ -85,7 +85,7 @@
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include "CFILE.H"
|
||||
#include "cfile/cfile.h"
|
||||
#include "pserror.h"
|
||||
#include "ddio.h"
|
||||
#include "bitmap.h"
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Descent 3
|
||||
* Descent 3
|
||||
* Copyright (C) 2024 Parallax Software
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
@ -16,10 +16,10 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "aiambient.h"
|
||||
#include "string.h"
|
||||
#include "objinfo.h"
|
||||
#include <stdlib.h>
|
||||
#include "game.h"
|
||||
#include "psrand.h"
|
||||
|
||||
|
@ -19,7 +19,7 @@
|
||||
#ifndef _AIAMBIENT_H_
|
||||
#define _AIAMBIENT_H_
|
||||
|
||||
#include "CFILE.H"
|
||||
#include "cfile/cfile.h"
|
||||
|
||||
#define MAX_AL_TYPES 6
|
||||
#define MAX_ALS_PER_TYPE 130
|
||||
|
@ -156,7 +156,6 @@ void InitAmbientSounds() {
|
||||
}
|
||||
|
||||
#include "ddio.h"
|
||||
#include "CFILE.H"
|
||||
#include "soundload.h"
|
||||
#include "descent.h"
|
||||
#include "mem.h"
|
||||
|
@ -24,7 +24,7 @@
|
||||
#include "pserror.h"
|
||||
#include "pstypes.h"
|
||||
#include "audiotaunts.h"
|
||||
#include "CFILE.H"
|
||||
#include "cfile/cfile.h"
|
||||
#include "audio_encode.h"
|
||||
#include "byteswap.h"
|
||||
#include "mem.h"
|
||||
|
@ -43,7 +43,7 @@
|
||||
|
||||
#include "list.h"
|
||||
#include "vecmat.h"
|
||||
#include "CFILE.H"
|
||||
#include "cfile/cfile.h"
|
||||
|
||||
#define BSP_IN_FRONT 1
|
||||
#define BSP_BEHIND 2
|
||||
|
@ -59,7 +59,7 @@
|
||||
#include "ddio.h"
|
||||
#include "descent.h"
|
||||
#include "game.h"
|
||||
#include "CFILE.H"
|
||||
#include "cfile/cfile.h"
|
||||
#include "application.h"
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
@ -296,7 +296,7 @@
|
||||
#include "cinematics.h"
|
||||
#include "hlsoundlib.h"
|
||||
#include "terrain.h"
|
||||
#include "CFILE.H"
|
||||
#include "cfile/cfile.h"
|
||||
#include "mem.h"
|
||||
#include "lighting.h"
|
||||
#include "PHYSICS.H"
|
||||
|
@ -83,7 +83,7 @@
|
||||
#include "descent.h"
|
||||
#include <time.h>
|
||||
#include "mono.h"
|
||||
#include "CFILE.H"
|
||||
#include "cfile/cfile.h"
|
||||
#include "program.h"
|
||||
|
||||
#include <fcntl.h>
|
||||
|
@ -112,8 +112,8 @@ typedef int socklen_t;
|
||||
#include "pstypes.h"
|
||||
#include "pserror.h"
|
||||
#include "pstring.h"
|
||||
#include "CFILE.H"
|
||||
#include "InfFile.h"
|
||||
#include "cfile/cfile.h"
|
||||
#include "cfile/inffile.h"
|
||||
#include "dedicated_server.h"
|
||||
#include "multi.h"
|
||||
#include "args.h"
|
||||
|
@ -266,7 +266,7 @@
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "CFILE.H"
|
||||
#include "cfile/cfile.h"
|
||||
#include "objinfo.h"
|
||||
#include "ship.h"
|
||||
#include "ui.h"
|
||||
|
@ -385,7 +385,7 @@
|
||||
#include "pserror.h"
|
||||
#include "grdefs.h"
|
||||
#include "mono.h"
|
||||
#include "CFILE.H"
|
||||
#include "cfile/cfile.h"
|
||||
|
||||
#include "init.h"
|
||||
#include "game.h"
|
||||
|
@ -676,7 +676,7 @@
|
||||
#include "cinematics.h"
|
||||
#include "SmallViews.h"
|
||||
#include "Mission.h"
|
||||
#include "CFILE.H"
|
||||
#include "cfile/cfile.h"
|
||||
#include "gameloop.h"
|
||||
#include "cockpit.h"
|
||||
#include "game2dll.h"
|
||||
|
@ -266,7 +266,7 @@
|
||||
#include "gamesave.h"
|
||||
#include "descent.h"
|
||||
#include "newui.h"
|
||||
#include "CFILE.H"
|
||||
#include "cfile/cfile.h"
|
||||
#include "Mission.h"
|
||||
#include "gamesequence.h"
|
||||
#include "gameevent.h"
|
||||
|
@ -85,7 +85,7 @@
|
||||
#define GAMESAVE_H
|
||||
|
||||
#include "pstypes.h"
|
||||
#include "CFILE.H"
|
||||
#include "cfile/cfile.h"
|
||||
#include "object.h"
|
||||
#include "objinfo.h"
|
||||
|
||||
|
@ -132,7 +132,7 @@
|
||||
#include "ddio.h"
|
||||
#include "descent.h"
|
||||
#include "game.h"
|
||||
#include "CFILE.H"
|
||||
#include "cfile/cfile.h"
|
||||
#include "application.h"
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
@ -105,7 +105,7 @@
|
||||
#include "ddio.h"
|
||||
#include "descent.h"
|
||||
#include "game.h"
|
||||
#include "CFILE.H"
|
||||
#include "cfile/cfile.h"
|
||||
#include "application.h"
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
@ -20,7 +20,7 @@
|
||||
#define _LEVELGOAL_H_
|
||||
|
||||
#include "object.h"
|
||||
#include "CFILE.H"
|
||||
#include "cfile/cfile.h"
|
||||
#if defined(MACOSX)
|
||||
#include <malloc/malloc.h>
|
||||
#else
|
||||
|
@ -35,6 +35,7 @@
|
||||
#include <dirent.h>
|
||||
#define _GNU_SOURCE
|
||||
#include <fnmatch.h>
|
||||
#include "cfile/hogfile.h"
|
||||
#endif
|
||||
|
||||
#include "SDL.h"
|
||||
@ -330,8 +331,6 @@ 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);
|
||||
@ -422,7 +421,7 @@ static void buildNewHogFromFileList(char *fileName) {
|
||||
} // for
|
||||
} while (swapped);
|
||||
|
||||
CreateNewHogFile("new.hog", i, (const char **)files, (void (*)(char *))hogfileRefresh);
|
||||
NewHogFile("new.hog", i, (const char **)files, (void (*)(char *))hogfileRefresh);
|
||||
} // buildNewHogFileFromList
|
||||
|
||||
#endif
|
||||
|
@ -181,7 +181,7 @@
|
||||
|
||||
#include "gamesave.h"
|
||||
#include "descent.h"
|
||||
#include "CFILE.H"
|
||||
#include "cfile/cfile.h"
|
||||
#include "Mission.h"
|
||||
#include "gamesequence.h"
|
||||
#include "gameevent.h"
|
||||
|
@ -91,7 +91,7 @@
|
||||
#include "game.h"
|
||||
#include "descent.h"
|
||||
#include "mono.h"
|
||||
#include "CFILE.H"
|
||||
#include "cfile/cfile.h"
|
||||
#include "localization.h"
|
||||
#include "mem.h"
|
||||
#include "ddio.h"
|
||||
|
@ -19,7 +19,7 @@
|
||||
#ifndef _MATCEN_H_
|
||||
#define _MATCEN_H_
|
||||
|
||||
#include "CFILE.H"
|
||||
#include "cfile/cfile.h"
|
||||
#include "vecmat.h"
|
||||
#include "matcen_external.h"
|
||||
|
||||
|
@ -7631,7 +7631,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 (CF_ON_DISK == cfexist(p)) {
|
||||
if (CFES_ON_DISK == cfexist(p)) {
|
||||
char szcrc[_MAX_PATH];
|
||||
char path[_MAX_PATH];
|
||||
char ext[_MAX_PATH];
|
||||
|
@ -113,7 +113,7 @@
|
||||
|
||||
#include "pstypes.h"
|
||||
#include "manage_external.h"
|
||||
#include "CFILE.H"
|
||||
#include "cfile/cfile.h"
|
||||
#include "networking.h"
|
||||
#include "descent.h" //for MSN_NAMELEN
|
||||
#include "byteswap.h"
|
||||
|
@ -68,7 +68,7 @@
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "CFILE.H"
|
||||
#include "cfile/cfile.h"
|
||||
#include "multi.h"
|
||||
#include "objinfo.h"
|
||||
#include "ship.h"
|
||||
|
@ -106,7 +106,7 @@
|
||||
#include "ddio.h"
|
||||
#include "descent.h"
|
||||
#include "game.h"
|
||||
#include "CFILE.H"
|
||||
#include "cfile/cfile.h"
|
||||
#include "application.h"
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
@ -116,7 +116,7 @@
|
||||
#include "object_external_struct.h"
|
||||
#include "osiris_share.h"
|
||||
#include "module.h"
|
||||
#include "CFILE.H"
|
||||
#include "cfile/cfile.h"
|
||||
|
||||
extern uint Osiris_game_checksum;
|
||||
|
||||
|
@ -174,7 +174,7 @@
|
||||
#define __OSIRIS_PREDEF_H_
|
||||
|
||||
#include "osiris_dll.h"
|
||||
#include "CFILE.H"
|
||||
#include "cfile/cfile.h"
|
||||
|
||||
// osipf_CallObjectEvent
|
||||
// Sends an event to an object. Returns true if the default action should
|
||||
|
@ -581,7 +581,7 @@
|
||||
#include "ddio.h"
|
||||
#include "descent.h"
|
||||
#include "game.h"
|
||||
#include "CFILE.H"
|
||||
#include "cfile/cfile.h"
|
||||
#include "application.h"
|
||||
#include "manage.h"
|
||||
#include "newui.h"
|
||||
@ -951,7 +951,7 @@ void PilotSelect(void) {
|
||||
int res = -1;
|
||||
bool done = false;
|
||||
|
||||
if (cfexist(Default_pilot) != CF_NOT_FOUND) {
|
||||
if (cfexist(Default_pilot) != CFES_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);
|
||||
@ -1002,7 +1002,7 @@ void PilotSelect(void) {
|
||||
|
||||
// use this in case they cancel out
|
||||
Current_pilot.get_filename(pfilename);
|
||||
if (cfexist(pfilename) != CF_NOT_FOUND) {
|
||||
if (cfexist(pfilename) != CFES_NOT_FOUND) {
|
||||
strcpy(old_file, pfilename);
|
||||
} else {
|
||||
old_file[0] = '\0';
|
||||
@ -1058,7 +1058,7 @@ void PilotSelect(void) {
|
||||
|
||||
case UID_CANCEL: {
|
||||
// Cancel out
|
||||
bool found_old = (cfexist(old_file) != CF_NOT_FOUND);
|
||||
bool found_old = (cfexist(old_file) != CFES_NOT_FOUND);
|
||||
bool display_error;
|
||||
|
||||
if (filecount && found_old)
|
||||
@ -1512,7 +1512,7 @@ void NewPltUpdate(newuiListBox *list, char **flist, int filecount, int selected,
|
||||
|
||||
list->SetCurrentIndex(selected);
|
||||
|
||||
if (filename && (cfexist(filename) != CF_NOT_FOUND)) {
|
||||
if (filename && (cfexist(filename) != CFES_NOT_FOUND)) {
|
||||
// get the selected pilot from the filename
|
||||
mprintf((0, "Looking for Pilot: %s\n", filename));
|
||||
for (int d = 0; d < filecount; d++) {
|
||||
@ -2230,7 +2230,7 @@ bool CreateCRCFileName(const char *src, char *dest) {
|
||||
ASSERT(src);
|
||||
ASSERT(dest);
|
||||
|
||||
if (cfexist(src) != CF_ON_DISK)
|
||||
if (cfexist(src) != CFES_ON_DISK)
|
||||
return false;
|
||||
|
||||
unsigned int crc_value = cf_GetfileCRC((char *)src);
|
||||
@ -2261,7 +2261,7 @@ bool CreateCRCFileName(const char *src, char *base, char *newfilename) {
|
||||
ASSERT(base);
|
||||
ASSERT(newfilename);
|
||||
|
||||
if (cfexist(src) != CF_ON_DISK)
|
||||
if (cfexist(src) != CFES_ON_DISK)
|
||||
return false;
|
||||
|
||||
unsigned int crc_value = cf_GetfileCRC((char *)src);
|
||||
@ -2363,7 +2363,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) != CF_ON_DISK) {
|
||||
if (cfexist(pathname) != CFES_ON_DISK) {
|
||||
mprintf((0, "'%s' not found\n", pathname));
|
||||
return false;
|
||||
}
|
||||
|
@ -90,7 +90,7 @@
|
||||
#include "pstypes.h"
|
||||
#include "controls.h"
|
||||
#include "Controller.h"
|
||||
#include "CFILE.H"
|
||||
#include "cfile/cfile.h"
|
||||
#include "weapon.h"
|
||||
#include "config.h"
|
||||
|
||||
|
@ -160,7 +160,7 @@
|
||||
#include "pserror.h"
|
||||
#include "bitmap.h"
|
||||
#include "vclip.h"
|
||||
#include "CFILE.H"
|
||||
#include "cfile/cfile.h"
|
||||
#include "mono.h"
|
||||
#include "ddio.h"
|
||||
#include "gametexture.h"
|
||||
|
@ -356,7 +356,7 @@
|
||||
#include "sounds.h"
|
||||
#include "stringtable.h"
|
||||
#include "Macros.h"
|
||||
#include "CFILE.H"
|
||||
#include "cfile/cfile.h"
|
||||
#include "AIMain.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
@ -300,7 +300,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include "CFILE.H"
|
||||
#include "cfile/cfile.h"
|
||||
#include "texture.h"
|
||||
#include "bitmap.h"
|
||||
#include "pstypes.h"
|
||||
|
@ -74,7 +74,7 @@
|
||||
#include "mem.h"
|
||||
#include "iff.h"
|
||||
#include "byteswap.h"
|
||||
#include "CFILE.H"
|
||||
#include "cfile/cfile.h"
|
||||
#include "pserror.h"
|
||||
#include "pstypes.h"
|
||||
#include "bitmap.h"
|
||||
|
@ -19,7 +19,7 @@
|
||||
#ifndef _IFF_H
|
||||
#define _IFF_H
|
||||
|
||||
#include "CFILE.H"
|
||||
#include "cfile/cfile.h"
|
||||
|
||||
// Error codes for read & write routines
|
||||
|
||||
|
@ -132,7 +132,7 @@
|
||||
* $NoKeywords: $
|
||||
*/
|
||||
|
||||
#include "CFILE.H"
|
||||
#include "cfile/cfile.h"
|
||||
#include "pserror.h"
|
||||
#include "pstypes.h"
|
||||
#include "bitmap.h"
|
||||
|
@ -1,7 +1,6 @@
|
||||
set(HEADERS)
|
||||
set(CPPS
|
||||
CFILE.cpp
|
||||
hog.cpp
|
||||
InfFile.cpp)
|
||||
cfile.cpp
|
||||
hogfile.cpp
|
||||
inffile.cpp)
|
||||
|
||||
add_library(cfile STATIC ${HEADERS} ${CPPS})
|
||||
add_library(cfile STATIC ${CPPS})
|
||||
|
@ -33,13 +33,15 @@
|
||||
// Linux Build Includes
|
||||
#include "linux/linux_fix.h"
|
||||
#endif
|
||||
|
||||
#include "byteswap.h"
|
||||
#include "pserror.h"
|
||||
#include "ddio.h"
|
||||
#include "psglob.h"
|
||||
#include "CFILE.H"
|
||||
#include "hogfile.h" //info about library file
|
||||
#include "cfile/cfile.h"
|
||||
#include "cfile/hogfile.h" //info about library file
|
||||
#include "mem.h"
|
||||
|
||||
// Library structures
|
||||
typedef struct {
|
||||
char name[PSFILENAME_LEN + 1]; // just the filename part
|
||||
@ -48,25 +50,30 @@ 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; // indentifier for this lib
|
||||
int handle; // identifier 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
|
||||
@ -74,11 +81,12 @@ 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;
|
||||
@ -86,6 +94,9 @@ 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
|
||||
@ -101,7 +112,7 @@ int cf_OpenLibrary(const char *libname) {
|
||||
tHogFileEntry entry;
|
||||
|
||||
fp = fopen(libname, "rb");
|
||||
if (fp == NULL)
|
||||
if (fp == nullptr)
|
||||
return 0; // CF_NO_FILE;
|
||||
fread(id, strlen(HOG_TAG_STR), 1, fp);
|
||||
if (strncmp(id, HOG_TAG_STR, strlen(HOG_TAG_STR))) {
|
||||
@ -166,10 +177,13 @@ int cf_OpenLibrary(const char *libname) {
|
||||
// Sucess. Return the handle
|
||||
return lib->handle;
|
||||
}
|
||||
// Closes a library file.
|
||||
// Parameters: handle: the handle returned by cf_OpenLibrary()
|
||||
|
||||
/**
|
||||
* Closes a library file.
|
||||
* @param handle the handle returned by cf_OpenLibrary()
|
||||
*/
|
||||
void cf_CloseLibrary(int handle) {
|
||||
library *lib, *prev = NULL;
|
||||
library *lib, *prev = nullptr;
|
||||
for (lib = Libraries; lib; prev = lib, lib = lib->next) {
|
||||
if (lib->handle == handle) {
|
||||
if (prev)
|
||||
@ -180,10 +194,11 @@ void cf_CloseLibrary(int handle) {
|
||||
fclose(lib->file);
|
||||
mem_free(lib->entries);
|
||||
mem_free(lib);
|
||||
return; // sucessful close
|
||||
return; // successful close
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Closes down the CFILE system, freeing up all data, etc.
|
||||
void cf_Close() {
|
||||
library *next;
|
||||
@ -232,16 +247,23 @@ int cf_SetSearchPath(const char *path, ...) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Removes all search paths that have been added by cf_SetSearchPath
|
||||
void cf_ClearAllSearchPaths(void) {
|
||||
/**
|
||||
* Removes all search paths that have been added by cf_SetSearchPath
|
||||
*/
|
||||
void cf_ClearAllSearchPaths() {
|
||||
N_paths = 0;
|
||||
N_extensions = 0;
|
||||
}
|
||||
|
||||
// Opens a file for reading in a library, given the library id
|
||||
/**
|
||||
* Opens a file for reading in a library, given the library id
|
||||
* @param filename
|
||||
* @param libhandle
|
||||
* @return
|
||||
*/
|
||||
CFILE *cf_OpenFileInLibrary(const char *filename, int libhandle) {
|
||||
if (libhandle <= 0)
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
library *lib;
|
||||
CFILE *cfile;
|
||||
@ -254,9 +276,9 @@ CFILE *cf_OpenFileInLibrary(const char *filename, int libhandle) {
|
||||
lib = lib->next;
|
||||
}
|
||||
|
||||
if (NULL == lib) {
|
||||
if (nullptr == lib) {
|
||||
// couldn't find the library handle
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// now do a binary search for the file entry
|
||||
@ -276,10 +298,10 @@ CFILE *cf_OpenFileInLibrary(const char *filename, int libhandle) {
|
||||
first = i + 1;
|
||||
else // search key before check key
|
||||
last = i - 1;
|
||||
} while (1);
|
||||
} while (true);
|
||||
|
||||
if (!found)
|
||||
return NULL; // file not in library
|
||||
return nullptr; // file not in library
|
||||
|
||||
// open the file for reading
|
||||
FILE *fp;
|
||||
@ -287,13 +309,13 @@ CFILE *cf_OpenFileInLibrary(const char *filename, int libhandle) {
|
||||
// See if there's an available FILE
|
||||
if (lib->file) {
|
||||
fp = lib->file;
|
||||
lib->file = NULL;
|
||||
lib->file = nullptr;
|
||||
} 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 NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
cfile = (CFILE *)mem_malloc(sizeof(*cfile));
|
||||
@ -333,20 +355,20 @@ CFILE *open_file_in_lib(const char *filename) {
|
||||
first = i + 1;
|
||||
else // search key before check key
|
||||
last = i - 1;
|
||||
} while (1);
|
||||
} while (true);
|
||||
if (found) {
|
||||
FILE *fp;
|
||||
int r;
|
||||
// See if there's an available FILE
|
||||
if (lib->file) {
|
||||
fp = lib->file;
|
||||
lib->file = NULL;
|
||||
lib->file = nullptr;
|
||||
} 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 NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
cfile = (CFILE *)mem_malloc(sizeof(*cfile));
|
||||
@ -365,7 +387,7 @@ CFILE *open_file_in_lib(const char *filename) {
|
||||
}
|
||||
lib = lib->next;
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
#ifdef __LINUX__
|
||||
@ -382,7 +404,7 @@ public:
|
||||
|
||||
bool Start(const char *wildcard, char *namebuf);
|
||||
bool Next(char *namebuf);
|
||||
void Close(void);
|
||||
void Close();
|
||||
|
||||
private:
|
||||
int globindex;
|
||||
@ -411,7 +433,7 @@ bool CFindFiles::Start(const char *wildcard, char *namebuf) {
|
||||
|
||||
globindex = 0;
|
||||
char ext[256];
|
||||
ddio_SplitPath(ffres.gl_pathv[0], NULL, namebuf, ext);
|
||||
ddio_SplitPath(ffres.gl_pathv[0], nullptr, namebuf, ext);
|
||||
strcat(namebuf, ext);
|
||||
return true;
|
||||
}
|
||||
@ -425,12 +447,12 @@ bool CFindFiles::Next(char *namebuf) {
|
||||
return false;
|
||||
|
||||
char ext[256];
|
||||
ddio_SplitPath(ffres.gl_pathv[globindex], NULL, namebuf, ext);
|
||||
ddio_SplitPath(ffres.gl_pathv[globindex], nullptr, namebuf, ext);
|
||||
strcat(namebuf, ext);
|
||||
return true;
|
||||
}
|
||||
|
||||
void CFindFiles::Close(void) {
|
||||
void CFindFiles::Close() {
|
||||
if (globindex == -1)
|
||||
return;
|
||||
globindex = -1;
|
||||
@ -467,7 +489,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 = NULL;
|
||||
real_dir = nullptr;
|
||||
real_file = (char *)fname;
|
||||
}
|
||||
}
|
||||
@ -574,7 +596,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 != NULL) {
|
||||
if (directory != nullptr) {
|
||||
ddio_MakePath(full_path, directory, new_filename, NULL);
|
||||
} else {
|
||||
strcpy(full_path, new_filename);
|
||||
@ -583,7 +605,7 @@ FILE *open_file_in_directory_case_sensitive(const char *directory, const char *f
|
||||
return fopen(full_path, mode);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -593,7 +615,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 != NULL) {
|
||||
if (directory != nullptr) {
|
||||
// Make a full path
|
||||
ddio_MakePath(path, directory, filename, NULL);
|
||||
} else // no directory specified, so just use filename passed
|
||||
@ -634,7 +656,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 NULL;
|
||||
return nullptr;
|
||||
} else {
|
||||
// found a version of the file!
|
||||
mprintf((0, "CFILE: Unable to find %s, but using %s instead\n", filename, using_filename));
|
||||
@ -692,9 +714,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, NULL); // 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, nullptr); // 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
|
||||
@ -722,15 +744,17 @@ CFILE *cfopen(const char *filename, const char *mode) {
|
||||
got_file:;
|
||||
if (cfile) {
|
||||
if (mode[0] == 'w')
|
||||
cfile->flags |= CF_WRITING;
|
||||
cfile->flags |= CFF_WRITING;
|
||||
if (mode[1] == 't')
|
||||
cfile->flags |= CF_TEXT;
|
||||
cfile->flags |= CFF_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) {
|
||||
@ -740,9 +764,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 == NULL) {
|
||||
if (lib->file == nullptr) {
|
||||
lib->file = cfp->file;
|
||||
cfp->file = NULL;
|
||||
cfp->file = nullptr;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -757,6 +781,7 @@ 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) {
|
||||
@ -775,7 +800,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 & CF_TEXT) {
|
||||
if (cfp->flags & CFF_TEXT) {
|
||||
if (c == 10) // return LF as newline
|
||||
c = '\n';
|
||||
else if (c == 13) { // check for CR/LF pair
|
||||
@ -816,10 +841,13 @@ 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
|
||||
@ -830,12 +858,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 CF_ON_DISK; //..so say it exists on the disk
|
||||
return CFES_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 CF_NOT_FOUND; // Say we didn't find the file
|
||||
return CFES_NOT_FOUND; // Say we didn't find the file
|
||||
}
|
||||
ret = cfp->lib_offset ? CF_IN_LIBRARY : CF_ON_DISK;
|
||||
ret = cfp->lib_offset ? CFES_IN_LIBRARY : CFES_ON_DISK;
|
||||
cfclose(cfp);
|
||||
return ret;
|
||||
}
|
||||
@ -847,7 +875,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 & CF_TEXT));
|
||||
ASSERT(!(cfp->flags & CFF_TEXT));
|
||||
if (cfp->position + count <= cfp->size) {
|
||||
i = fread(buf, 1, count, cfp->file);
|
||||
if (i == count) {
|
||||
@ -871,22 +899,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
|
||||
int cf_ReadInt(CFILE *cfp) {
|
||||
int i;
|
||||
int32_t cf_ReadInt(CFILE *cfp) {
|
||||
int32_t 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
|
||||
short cf_ReadShort(CFILE *cfp) {
|
||||
short i;
|
||||
int16_t cf_ReadShort(CFILE *cfp) {
|
||||
int16_t 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
|
||||
sbyte cf_ReadByte(CFILE *cfp) {
|
||||
int i;
|
||||
int8_t cf_ReadByte(CFILE *cfp) {
|
||||
int8_t i;
|
||||
i = cfgetc(cfp);
|
||||
if (i == EOF)
|
||||
ThrowCFileError(CFE_READING, cfp, cfeof(cfp) ? eof_error : strerror(errno));
|
||||
@ -894,8 +922,8 @@ 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 cf_ReadFloat(CFILE *cfp) {
|
||||
float f;
|
||||
float_t cf_ReadFloat(CFILE *cfp) {
|
||||
float_t f;
|
||||
cf_ReadBytes((ubyte *)&f, sizeof(f), cfp);
|
||||
#ifdef MACINTOSH
|
||||
float e = INTEL_FLOAT(f); // DAJ bash to zero if reads a NaN
|
||||
@ -908,8 +936,8 @@ 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 cf_ReadDouble(CFILE *cfp) {
|
||||
double f;
|
||||
double_t cf_ReadDouble(CFILE *cfp) {
|
||||
double_t f;
|
||||
cf_ReadBytes((ubyte *)&f, sizeof(f), cfp);
|
||||
#ifdef OUTRAGE_BIG_ENDIAN
|
||||
{
|
||||
@ -947,7 +975,7 @@ int cf_ReadString(char *buf, size_t n, CFILE *cfp) {
|
||||
break;
|
||||
}
|
||||
|
||||
if ((!(cfp->flags & CF_TEXT) && (c == 0)) || ((cfp->flags & CF_TEXT) && (c == '\n')))
|
||||
if ((!(cfp->flags & CFF_TEXT) && (c == 0)) || ((cfp->flags & CFF_TEXT) && (c == '\n')))
|
||||
break; // end-of-string
|
||||
if (count < n - 1) // store char if room in buffer
|
||||
*bp++ = c;
|
||||
@ -962,7 +990,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 & CF_WRITING))
|
||||
if (!(cfp->flags & CFF_WRITING))
|
||||
return 0;
|
||||
ASSERT(count > 0);
|
||||
i = fwrite(buf, 1, count, cfp->file);
|
||||
@ -984,9 +1012,10 @@ 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 & CF_TEXT) ? '\n' : 0);
|
||||
cf_WriteByte(cfp, (cfp->flags & CFF_TEXT) ? '\n' : 0);
|
||||
return len + 1;
|
||||
}
|
||||
|
||||
// Just like stdio fprintf(), except works on a CFILE
|
||||
int cfprintf(CFILE *cfp, const char *format, ...) {
|
||||
#ifndef MACINTOSH
|
||||
@ -999,40 +1028,45 @@ 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, int i) {
|
||||
void cf_WriteInt(CFILE *cfp, int32_t 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, short s) {
|
||||
void cf_WriteShort(CFILE *cfp, int16_t 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, sbyte b) {
|
||||
void cf_WriteByte(CFILE *cfp, int8_t 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 & CF_TEXT) && (b == '\n')) // check for text mode newline
|
||||
if ((cfp->flags & CFF_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 f) {
|
||||
void cf_WriteFloat(CFILE *cfp, float_t 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 d) {
|
||||
void cf_WriteDouble(CFILE *cfp, double_t d) {
|
||||
#ifdef OUTRAGE_BIG_ENDIAN
|
||||
{
|
||||
double t;
|
||||
@ -1045,19 +1079,20 @@ void cf_WriteDouble(CFILE *cfp, double 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 1; // don't copy files if they are the same
|
||||
return true; // don't copy files if they are the same
|
||||
infile = (CFILE *)cfopen(src, "rb");
|
||||
if (!infile)
|
||||
return 0;
|
||||
return false;
|
||||
outfile = (CFILE *)cfopen(dest, "wb");
|
||||
if (!outfile) {
|
||||
cfclose(infile);
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
int progress = 0;
|
||||
int readcount = 0;
|
||||
@ -1083,13 +1118,16 @@ bool cf_CopyFile(char *dest, const char *src, int copytime) {
|
||||
if (!infile_lib_offset && copytime) {
|
||||
cf_CopyFileTime(dest, src);
|
||||
}
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
// 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
|
||||
@ -1099,6 +1137,7 @@ 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) {
|
||||
@ -1109,7 +1148,8 @@ 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
|
||||
|
||||
@ -1174,7 +1214,7 @@ unsigned int cf_GetfileCRC(char *src) {
|
||||
}
|
||||
|
||||
char cfile_search_wildcard[256];
|
||||
library *cfile_search_library = NULL;
|
||||
library *cfile_search_library = nullptr;
|
||||
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
|
||||
@ -1220,6 +1260,7 @@ 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) {
|
||||
@ -1240,8 +1281,9 @@ bool cf_LibraryFindNext(char *buffer) {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
void cf_LibraryFindClose(void) {
|
||||
cfile_search_library = NULL;
|
||||
|
||||
void cf_LibraryFindClose() {
|
||||
cfile_search_library = nullptr;
|
||||
cfile_search_curr_index = 0;
|
||||
cfile_search_ispattern = false;
|
||||
}
|
||||
@ -1277,7 +1319,7 @@ bool cf_ReadHogFileEntry(int libr, const char *filename, tHogFileEntry *entry, i
|
||||
else // search key before check key
|
||||
last = i - 1;
|
||||
|
||||
} while (1);
|
||||
} while (true);
|
||||
|
||||
if (found) {
|
||||
strcpy(entry->name, lib->entries[i].name);
|
@ -76,7 +76,9 @@
|
||||
#ifndef CFILE_H
|
||||
#define CFILE_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <cmath>
|
||||
#include <cstdint>
|
||||
#include <cstdio>
|
||||
|
||||
#include "pstypes.h"
|
||||
|
||||
@ -94,8 +96,10 @@ typedef struct CFILE {
|
||||
} CFILE;
|
||||
|
||||
// Defines for cfile_error
|
||||
#define CFE_READING 1
|
||||
#define CFE_WRITING 2
|
||||
enum CFileError {
|
||||
CFE_READING = 1,
|
||||
CFE_WRITING,
|
||||
};
|
||||
|
||||
// The structure thrown by a cfile error
|
||||
typedef struct {
|
||||
@ -105,8 +109,17 @@ typedef struct {
|
||||
} cfile_error;
|
||||
|
||||
// Flags for CFILE struct
|
||||
#define CF_TEXT 1 // if this bit set, file is text
|
||||
#define CF_WRITING 2 // if bit set, file opened for writing
|
||||
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,
|
||||
};
|
||||
|
||||
// See if a file is in a hog
|
||||
bool cf_IsFileInHog(char *filename, char *hogname);
|
||||
@ -130,7 +143,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);
|
||||
void cf_ClearAllSearchPaths();
|
||||
|
||||
// Opens a file for reading or writing
|
||||
// If a path is specified, will try to open the file only in that path.
|
||||
@ -167,11 +180,6 @@ 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
|
||||
@ -192,23 +200,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
|
||||
int cf_ReadInt(CFILE *cfp);
|
||||
int32_t 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
|
||||
short cf_ReadShort(CFILE *cfp);
|
||||
int16_t 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
|
||||
sbyte cf_ReadByte(CFILE *cfp);
|
||||
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 cf_ReadFloat(CFILE *cfp);
|
||||
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 cf_ReadDouble(CFILE *cfp);
|
||||
double_t 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,
|
||||
@ -246,23 +254,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, int i);
|
||||
void cf_WriteInt(CFILE *cfp, int32_t 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, short s);
|
||||
void cf_WriteShort(CFILE *cfp, int16_t 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, sbyte b);
|
||||
void cf_WriteByte(CFILE *cfp, int8_t 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 f);
|
||||
void cf_WriteFloat(CFILE *cfp, float_t 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 d);
|
||||
void cf_WriteDouble(CFILE *cfp, double_t 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
|
||||
@ -279,17 +287,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);
|
||||
void cf_LibraryFindClose();
|
||||
|
||||
#endif
|
@ -102,7 +102,7 @@
|
||||
#include "linux/linux_fix.h"
|
||||
#endif
|
||||
#include "byteswap.h"
|
||||
#include "hogfile.h"
|
||||
#include "cfile/hogfile.h"
|
||||
#include "pstypes.h"
|
||||
#include "Macros.h"
|
||||
#include "mem.h"
|
||||
@ -152,7 +152,7 @@ bool FileCopy(FILE *ofp, FILE *ifp, int length) {
|
||||
return true;
|
||||
}
|
||||
bool ReadHogHeader(FILE *fp, tHogHeader *header) {
|
||||
int res = 0;
|
||||
int res;
|
||||
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);
|
||||
@ -164,7 +164,7 @@ bool ReadHogHeader(FILE *fp, tHogHeader *header) {
|
||||
return false;
|
||||
}
|
||||
bool ReadHogEntry(FILE *fp, tHogFileEntry *entry) {
|
||||
int res = 0;
|
||||
int res;
|
||||
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);
|
||||
@ -179,8 +179,8 @@ bool ReadHogEntry(FILE *fp, tHogFileEntry *entry) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool WRITE_FILE_ENTRY(FILE *fp, tHogFileEntry *entry) {
|
||||
int res = 0;
|
||||
bool WriteHogEntry(FILE *fp, tHogFileEntry *entry) {
|
||||
int res;
|
||||
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);
|
||||
@ -191,127 +191,11 @@ bool WRITE_FILE_ENTRY(FILE *fp, tHogFileEntry *entry) {
|
||||
else
|
||||
return false;
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// create new hog file
|
||||
int NewHogFile(const char *hogname, int nfiles, const char **filenames) {
|
||||
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);
|
||||
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()
|
||||
// A modified 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 *)) {
|
||||
int NewHogFile(const char *hogname, int nfiles, const char **filenames, void (*UpdateFunction)(char *)) {
|
||||
unsigned i;
|
||||
int table_pos;
|
||||
FILE *hog_fp;
|
||||
@ -319,7 +203,7 @@ int CreateNewHogFile(const char *hogname, int nfiles, const char **filenames, vo
|
||||
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];
|
||||
@ -367,7 +251,7 @@ int CreateNewHogFile(const char *hogname, int nfiles, const char **filenames, vo
|
||||
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])) {
|
||||
if (!WriteHogEntry(hog_fp, &table[0])) {
|
||||
delete[] table;
|
||||
fclose(hog_fp);
|
||||
strcpy(hogerr_filename, hogname);
|
||||
@ -408,30 +292,32 @@ int CreateNewHogFile(const char *hogname, int nfiles, const char **filenames, vo
|
||||
return HOGMAKER_COPY;
|
||||
}
|
||||
fclose(ifp);
|
||||
// Setup the update message and send it
|
||||
char msg[256];
|
||||
int ipct = int(100.0 * (double(i) / double(header.nfiles)));
|
||||
snprintf(msg, sizeof(msg), "Creating Hog File... (%d%% done)", ipct);
|
||||
if (UpdateFunction != NULL)
|
||||
if (UpdateFunction != nullptr) {
|
||||
// Setup the update message and send it
|
||||
char msg[256];
|
||||
int ipct = int(100.0 * (double(i) / double(header.nfiles)));
|
||||
snprintf(msg, sizeof(msg), "Creating Hog File... (%d%% done)", ipct);
|
||||
UpdateFunction(msg);
|
||||
}
|
||||
}
|
||||
// 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])) {
|
||||
if (!WriteHogEntry(hog_fp, &table[i])) {
|
||||
delete[] table;
|
||||
fclose(hog_fp);
|
||||
strcpy(hogerr_filename, hogname);
|
||||
return HOGMAKER_OUTFILE;
|
||||
}
|
||||
}
|
||||
// cleanup
|
||||
// cleanup
|
||||
fclose(hog_fp);
|
||||
delete[] table;
|
||||
// Setup the update message and send it
|
||||
char msg[256];
|
||||
snprintf(msg, sizeof(msg), "Done Creating Hog File.");
|
||||
if (UpdateFunction != NULL)
|
||||
if (UpdateFunction != nullptr) {
|
||||
// Setup the update message and send it
|
||||
char msg[256];
|
||||
snprintf(msg, sizeof(msg), "Done Creating Hog File.");
|
||||
UpdateFunction(msg);
|
||||
}
|
||||
return HOGMAKER_OK;
|
||||
}
|
@ -60,6 +60,7 @@
|
||||
#ifndef HOGFILE_H
|
||||
#define HOGFILE_H
|
||||
|
||||
#include <cstdint>
|
||||
#include "pstypes.h"
|
||||
|
||||
#define HOG_HDR_SIZE (64)
|
||||
@ -67,37 +68,37 @@
|
||||
#define HOG_FILENAME_LEN (36)
|
||||
|
||||
typedef struct tHogHeader {
|
||||
unsigned nfiles; // number of files in header
|
||||
unsigned file_data_offset; // offset in file to filedata.
|
||||
uint32_t nfiles; // number of files in header
|
||||
uint32_t file_data_offset; // offset in file to filedata.
|
||||
} tHogHeader;
|
||||
|
||||
typedef struct tHogFileEntry {
|
||||
char name[HOG_FILENAME_LEN]; // file name
|
||||
unsigned flags; // extra info
|
||||
unsigned len; // length of file
|
||||
unsigned timestamp; // time of file.
|
||||
uint32_t flags; // extra info
|
||||
uint32_t len; // length of file
|
||||
uint32_t timestamp; // time of file.
|
||||
} tHogFileEntry;
|
||||
|
||||
#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
|
||||
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
|
||||
};
|
||||
|
||||
// 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);
|
||||
int NewHogFile(const char *hogname, int nfiles, const char **filenames, void (*UpdateFunction)(char *) = nullptr);
|
||||
bool ReadHogHeader(FILE *fp, tHogHeader *header);
|
||||
bool ReadHogEntry(FILE *fp, tHogFileEntry *entry);
|
||||
bool WRITE_FILE_ENTRY(FILE *fp, tHogFileEntry *entry);
|
||||
bool WriteHogEntry(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
|
@ -20,21 +20,21 @@
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "InfFile.h"
|
||||
#include "cfile/inffile.h"
|
||||
|
||||
#include "CFILE.H"
|
||||
#include "cfile/cfile.h"
|
||||
#include "pstring.h"
|
||||
#include "pserror.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#define INFFILE_NULL -1024
|
||||
#define INFFILE_NULL (-1024)
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Construction/Destruction
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
InfFile::InfFile() { m_fp = NULL; }
|
||||
InfFile::InfFile() { m_fp = nullptr; }
|
||||
|
||||
InfFile::~InfFile() {
|
||||
// close file and free symbol lists
|
||||
@ -74,7 +74,7 @@ const char *InfFile::GetSymbolText(const char *name) {
|
||||
return (const char *)sym->t.text;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// opens an inf file, pass in a lexical analyzer that will return a command index.
|
@ -20,8 +20,8 @@
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(AFX_INFFILE_H__D8F94664_216E_11D2_AF2D_0060089A8025__INCLUDED_)
|
||||
#define AFX_INFFILE_H__D8F94664_216E_11D2_AF2D_0060089A8025__INCLUDED_
|
||||
#ifndef INFFILE_H
|
||||
#define INFFILE_H
|
||||
|
||||
#if _MSC_VER >= 1000
|
||||
#pragma once
|
||||
@ -32,12 +32,14 @@
|
||||
|
||||
struct CFILE;
|
||||
|
||||
#define INFFILE_LINELEN 256
|
||||
#define INFFILE_CUSTOM -128
|
||||
#define INFFILE_ERROR -1
|
||||
#define INFFILE_COMMENT -2
|
||||
#define INFFILE_EOL -3
|
||||
#define INFFILE_SYMBOL 1024
|
||||
enum InfFileError {
|
||||
INFFILE_LINELEN = 256,
|
||||
INFFILE_CUSTOM = -128,
|
||||
INFFILE_ERROR = -1,
|
||||
INFFILE_COMMENT = -2,
|
||||
INFFILE_EOL = -3,
|
||||
INFFILE_SYMBOL = 1024,
|
||||
};
|
||||
|
||||
class InfFile {
|
||||
public:
|
||||
@ -86,4 +88,4 @@ public:
|
||||
int line() const { return m_line; };
|
||||
};
|
||||
|
||||
#endif // !defined(AFX_INFFILE_H__D8F94664_216E_11D2_AF2D_0060089A8025__INCLUDED_)
|
||||
#endif
|
@ -108,7 +108,7 @@
|
||||
#include <linux/soundcard.h>
|
||||
#include <stdarg.h>
|
||||
#include <errno.h>
|
||||
#include "CFILE.H"
|
||||
#include "cfile/cfile.h"
|
||||
#include "pserror.h"
|
||||
#include "mono.h"
|
||||
#include "soundload.h"
|
||||
|
@ -30,7 +30,7 @@
|
||||
#include <dlfcn.h>
|
||||
#include <stdarg.h>
|
||||
#include <errno.h>
|
||||
#include "CFILE.H"
|
||||
#include "cfile/cfile.h"
|
||||
#include "pserror.h"
|
||||
#include "mono.h"
|
||||
#include "soundload.h"
|
||||
|
@ -211,7 +211,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <process.h>
|
||||
#include "cfile.h"
|
||||
#include "cfile/cfile.h"
|
||||
#include "pserror.h"
|
||||
#include "mono.h"
|
||||
#include "soundload.h"
|
||||
|
@ -98,7 +98,7 @@
|
||||
#include "pserror.h"
|
||||
#include "logfile.h"
|
||||
#include "Macros.h"
|
||||
#include "inffile.h"
|
||||
#include "cfile/inffile.h"
|
||||
|
||||
typedef struct tA3D
|
||||
{
|
||||
|
@ -101,7 +101,7 @@
|
||||
#else
|
||||
#include <malloc.h>
|
||||
#endif
|
||||
#include "CFILE.H"
|
||||
#include "cfile/cfile.h"
|
||||
#include "mem.h"
|
||||
#include "pserror.h"
|
||||
#include <string.h>
|
||||
|
@ -82,7 +82,7 @@
|
||||
#include "ddio_mac.h"
|
||||
#include "psglob.h"
|
||||
#include "mem.h"
|
||||
#include "cfile.h"
|
||||
#include "cfile/cfile.h"
|
||||
// ---------------------------------------------------------------------------
|
||||
// File Level Globals
|
||||
// ---------------------------------------------------------------------------
|
||||
|
@ -108,7 +108,7 @@
|
||||
*/
|
||||
|
||||
#include "grtextlib.h"
|
||||
#include "CFILE.H"
|
||||
#include "cfile/cfile.h"
|
||||
#include "bitmap.h"
|
||||
#include "pserror.h"
|
||||
#include "renderer.h"
|
||||
|
@ -19,7 +19,7 @@
|
||||
#ifndef PSBITMAP_H
|
||||
#define PSBITMAP_H
|
||||
#include "pstypes.h"
|
||||
#include "CFILE.H"
|
||||
#include "cfile/cfile.h"
|
||||
#ifdef __LINUX__
|
||||
#include "linux/linux_fix.h" //needed for stricmp's throughout bitmap lib
|
||||
#endif
|
||||
|
@ -21,7 +21,7 @@
|
||||
#define MANAGE_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include "CFILE.H"
|
||||
#include "cfile/cfile.h"
|
||||
#include "bitmap.h"
|
||||
#include "manage_external.h"
|
||||
|
||||
|
@ -47,7 +47,7 @@
|
||||
#include "ddio.h"
|
||||
#include "pserror.h"
|
||||
#include "joystick.h"
|
||||
#include "InfFile.h"
|
||||
#include "cfile/inffile.h"
|
||||
|
||||
// Sorry! This is needed for the semi-hacky mouselook support
|
||||
#include "descent.h"
|
||||
|
@ -8,7 +8,7 @@
|
||||
#include "appdatabase.h"
|
||||
#include <string.h>
|
||||
#include "mem.h"
|
||||
#include "cfile.h"
|
||||
#include "cfile/cfile.h"
|
||||
#include "ddio.h"
|
||||
#include "ddio_mac.h"
|
||||
#include "descent.h"
|
||||
|
@ -32,7 +32,7 @@
|
||||
#include "descent.h"
|
||||
#include "ddio.h"
|
||||
#include "args.h"
|
||||
#include "CFILE.H"
|
||||
#include "cfile/cfile.h"
|
||||
#include "program.h"
|
||||
#include <stdlib.h>
|
||||
#include <memory.h>
|
||||
|
@ -25,7 +25,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
// #include <process.h>
|
||||
#include "CFILE.H"
|
||||
#include "cfile/cfile.h"
|
||||
#include "pserror.h"
|
||||
#include "mono.h"
|
||||
#include "soundload.h"
|
||||
|
@ -149,7 +149,7 @@
|
||||
#include <sound.h>
|
||||
#include "streamaudio.h"
|
||||
#include "pserror.h"
|
||||
#include "CFILE.H"
|
||||
#include "cfile/cfile.h"
|
||||
#include "mem.h"
|
||||
#include "Macros.h"
|
||||
#include "ddio.h"
|
||||
|
@ -147,7 +147,7 @@
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#include "CFILE.H"
|
||||
#include "cfile/cfile.h"
|
||||
#include "manage.h"
|
||||
#include "door.h"
|
||||
#include "doorpage.h"
|
||||
|
@ -21,7 +21,7 @@
|
||||
|
||||
#include "manage.h"
|
||||
#include "door.h"
|
||||
#include "CFILE.H"
|
||||
#include "cfile/cfile.h"
|
||||
#include "pstypes.h"
|
||||
|
||||
typedef struct {
|
||||
|
@ -20,7 +20,7 @@
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#include "CFILE.H"
|
||||
#include "cfile/cfile.h"
|
||||
#include "manage.h"
|
||||
#include "mono.h"
|
||||
#include "pserror.h"
|
||||
|
@ -20,7 +20,7 @@
|
||||
#define GAMEFILEPAGE_H
|
||||
|
||||
#include "manage.h"
|
||||
#include "CFILE.H"
|
||||
#include "cfile/cfile.h"
|
||||
#include "pstypes.h"
|
||||
#include "gamefile.h"
|
||||
|
||||
|
@ -355,7 +355,7 @@
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#include "CFILE.H"
|
||||
#include "cfile/cfile.h"
|
||||
#include "manage.h"
|
||||
#include "genericpage.h"
|
||||
#include "soundpage.h"
|
||||
|
@ -20,7 +20,7 @@
|
||||
#define GENERICPAGE_H
|
||||
|
||||
#include "manage.h"
|
||||
#include "CFILE.H"
|
||||
#include "cfile/cfile.h"
|
||||
#include "pstypes.h"
|
||||
#include "objinfo.h"
|
||||
#include "robotfirestruct.h"
|
||||
|
@ -456,7 +456,7 @@
|
||||
#include "mono.h"
|
||||
#include "object.h"
|
||||
#include "ddio.h"
|
||||
#include "CFILE.H"
|
||||
#include "cfile/cfile.h"
|
||||
#include "appdatabase.h"
|
||||
#include "genericpage.h"
|
||||
#include "mem.h"
|
||||
|
@ -64,7 +64,7 @@
|
||||
#if defined(WIN32)
|
||||
#include <windows.h>
|
||||
#endif
|
||||
#include "CFILE.H"
|
||||
#include "cfile/cfile.h"
|
||||
#include "manage.h"
|
||||
#include "megacell.h"
|
||||
#include "megapage.h"
|
||||
|
@ -21,7 +21,7 @@
|
||||
|
||||
#include "manage.h"
|
||||
#include "megacell.h"
|
||||
#include "CFILE.H"
|
||||
#include "cfile/cfile.h"
|
||||
#include "pstypes.h"
|
||||
|
||||
typedef struct {
|
||||
|
@ -178,7 +178,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include "CFILE.H"
|
||||
#include "cfile/cfile.h"
|
||||
#include "manage.h"
|
||||
#include "pstypes.h"
|
||||
#include "pserror.h"
|
||||
|
@ -20,7 +20,7 @@
|
||||
#define POWERPAGE_H
|
||||
|
||||
#include "manage.h"
|
||||
#include "cfile.h"
|
||||
#include "cfile/cfile.h"
|
||||
#include "pstypes.h"
|
||||
#include "powerup.h"
|
||||
|
||||
|
@ -21,7 +21,7 @@
|
||||
|
||||
#include "manage.h"
|
||||
#include "robot.h"
|
||||
#include "cfile.h"
|
||||
#include "cfile/cfile.h"
|
||||
#include "pstypes.h"
|
||||
#include "objinfo.h"
|
||||
|
||||
|
@ -201,7 +201,7 @@
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#include "CFILE.H"
|
||||
#include "cfile/cfile.h"
|
||||
#include "manage.h"
|
||||
#include "ship.h"
|
||||
#include "shippage.h"
|
||||
|
@ -21,7 +21,7 @@
|
||||
|
||||
#include "manage.h"
|
||||
#include "ship.h"
|
||||
#include "CFILE.H"
|
||||
#include "cfile/cfile.h"
|
||||
#include "pstypes.h"
|
||||
|
||||
typedef struct {
|
||||
|
@ -120,7 +120,7 @@
|
||||
#if defined(WIN32)
|
||||
#include <windows.h>
|
||||
#endif
|
||||
#include "CFILE.H"
|
||||
#include "cfile/cfile.h"
|
||||
#include "manage.h"
|
||||
#include "soundpage.h"
|
||||
#include "mono.h"
|
||||
|
@ -21,7 +21,7 @@
|
||||
|
||||
#include "manage.h"
|
||||
#include "soundload.h"
|
||||
#include "CFILE.H"
|
||||
#include "cfile/cfile.h"
|
||||
#include "pstypes.h"
|
||||
|
||||
typedef struct {
|
||||
|
@ -261,7 +261,7 @@
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#include "CFILE.H"
|
||||
#include "cfile/cfile.h"
|
||||
#include "manage.h"
|
||||
#include "gametexture.h"
|
||||
#include "bitmap.h"
|
||||
|
@ -20,7 +20,7 @@
|
||||
#define TEXPAGE_H
|
||||
|
||||
#include "manage.h"
|
||||
#include "CFILE.H"
|
||||
#include "cfile/cfile.h"
|
||||
#include "pstypes.h"
|
||||
#include "procedurals.h"
|
||||
|
||||
|
@ -290,7 +290,7 @@
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#include "CFILE.H"
|
||||
#include "cfile/cfile.h"
|
||||
#include "manage.h"
|
||||
#include "weapon.h"
|
||||
#include "weaponpage.h"
|
||||
|
@ -22,7 +22,7 @@
|
||||
|
||||
#include "manage.h"
|
||||
#include "weapon.h"
|
||||
#include "CFILE.H"
|
||||
#include "cfile/cfile.h"
|
||||
#include "pstypes.h"
|
||||
|
||||
typedef struct {
|
||||
|
@ -73,7 +73,7 @@
|
||||
|
||||
#include "music.h"
|
||||
#include "musiclib.h"
|
||||
#include "InfFile.h"
|
||||
#include "cfile/inffile.h"
|
||||
#include "mem.h"
|
||||
|
||||
#include <string.h>
|
||||
|
@ -150,7 +150,7 @@
|
||||
#include "pserror.h"
|
||||
#include "ddio.h"
|
||||
#include "Macros.h"
|
||||
#include "InfFile.h"
|
||||
#include "cfile/inffile.h"
|
||||
#include "streamaudio.h"
|
||||
#include "mem.h"
|
||||
#include <string.h>
|
||||
|
@ -64,7 +64,7 @@
|
||||
#include "descent.h"
|
||||
#include "manage.h"
|
||||
#include "ddio.h"
|
||||
#include "CFILE.H"
|
||||
#include "cfile/cfile.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
@ -234,7 +234,7 @@
|
||||
#include <string.h>
|
||||
#include "ssl_lib.h"
|
||||
#include "object.h"
|
||||
#include "CFILE.H"
|
||||
#include "cfile/cfile.h"
|
||||
#include "ddio.h"
|
||||
#include "soundload.h"
|
||||
#include "weapon.h"
|
||||
|
@ -51,7 +51,7 @@
|
||||
*/
|
||||
|
||||
#include "streamaudio.h"
|
||||
#include "CFILE.H"
|
||||
#include "cfile/cfile.h"
|
||||
#include "pserror.h"
|
||||
#include <string.h>
|
||||
|
||||
|
@ -166,7 +166,7 @@
|
||||
*/
|
||||
#include "streamaudio.h"
|
||||
#include "pserror.h"
|
||||
#include "CFILE.H"
|
||||
#include "cfile/cfile.h"
|
||||
#include "mem.h"
|
||||
#include "Macros.h"
|
||||
#include "ddio.h"
|
||||
|
@ -320,7 +320,7 @@
|
||||
#include "ddio.h"
|
||||
#include "joystick.h"
|
||||
#include "Macros.h"
|
||||
#include "inffile.h"
|
||||
#include "cfile/inffile.h"
|
||||
|
||||
// Sorry! This is needed for the semi-hacky mouselook support
|
||||
#include "descent.h"
|
||||
|
Loading…
Reference in New Issue
Block a user