mirror of
https://github.com/kevinbentley/Descent3.git
synced 2025-01-23 12:08:56 +00:00
Merge pull request #333 from Jayman2000/minor-hog-id-detection-improvements
Minor improvements to `cf_OpenLibrary()`’s HOG2 id detection code
This commit is contained in:
commit
71244290e0
@ -104,7 +104,7 @@ static CFILE *open_file_in_lib(const char *filename);
|
|||||||
// Returns: 0 if error, else library handle that can be used to close the library
|
// Returns: 0 if error, else library handle that can be used to close the library
|
||||||
int cf_OpenLibrary(const char *libname) {
|
int cf_OpenLibrary(const char *libname) {
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
char id[4];
|
char id[HOG_TAG_LEN];
|
||||||
int i, offset;
|
int i, offset;
|
||||||
library *lib;
|
library *lib;
|
||||||
static int first_time = 1;
|
static int first_time = 1;
|
||||||
@ -147,8 +147,7 @@ int cf_OpenLibrary(const char *libname) {
|
|||||||
mem_free(lib);
|
mem_free(lib);
|
||||||
return 0; // CF_NO_FILE;
|
return 0; // CF_NO_FILE;
|
||||||
}
|
}
|
||||||
fread(id, strlen(HOG_TAG_STR), 1, fp);
|
if (!fread(id, HOG_TAG_LEN, 1, fp) || strncmp(id, HOG_TAG_STR, HOG_TAG_LEN)) {
|
||||||
if (strncmp(id, HOG_TAG_STR, strlen(HOG_TAG_STR))) {
|
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
mem_free(lib);
|
mem_free(lib);
|
||||||
return 0; // CF_BAD_FILE;
|
return 0; // CF_BAD_FILE;
|
||||||
@ -179,7 +178,7 @@ int cf_OpenLibrary(const char *libname) {
|
|||||||
// DAJ offset = INTEL_INT(header.file_data_offset);
|
// DAJ offset = INTEL_INT(header.file_data_offset);
|
||||||
offset = header.file_data_offset;
|
offset = header.file_data_offset;
|
||||||
// Go to index start
|
// Go to index start
|
||||||
fseek(fp, strlen(HOG_TAG_STR) + HOG_HDR_SIZE, SEEK_SET);
|
fseek(fp, HOG_TAG_LEN + HOG_HDR_SIZE, SEEK_SET);
|
||||||
|
|
||||||
// read in index table
|
// read in index table
|
||||||
for (i = 0; i < lib->nfiles; i++) {
|
for (i = 0; i < lib->nfiles; i++) {
|
||||||
|
@ -65,6 +65,7 @@
|
|||||||
|
|
||||||
#define HOG_HDR_SIZE (64)
|
#define HOG_HDR_SIZE (64)
|
||||||
#define HOG_TAG_STR "HOG2"
|
#define HOG_TAG_STR "HOG2"
|
||||||
|
#define HOG_TAG_LEN (4)
|
||||||
#define HOG_FILENAME_LEN (36)
|
#define HOG_FILENAME_LEN (36)
|
||||||
|
|
||||||
typedef struct tHogHeader {
|
typedef struct tHogHeader {
|
||||||
|
Loading…
Reference in New Issue
Block a user