Descent3/manage/gamefilepage.h

56 lines
2.2 KiB
C
Raw Normal View History

2024-04-16 03:43:29 +00:00
#ifndef GAMEFILEPAGE_H
#define GAMEFILEPAGE_H
#include "manage.h"
#include "cfile/cfile.h"
2024-04-16 03:43:29 +00:00
#include "pstypes.h"
#include "gamefile.h"
2024-04-16 18:56:40 +00:00
typedef struct {
gamefile gamefile_struct;
2024-04-16 03:43:29 +00:00
} mngs_gamefile_page;
// Gamefile page functions
//---------------------------------------------------------------
// Given an open file pointer and a gamefile_page struct, writes that gamefile page out
2024-04-16 18:56:40 +00:00
void mng_WriteGamefilePage(CFILE *outfile, mngs_gamefile_page *gamefilepage);
2024-04-16 03:43:29 +00:00
2024-04-16 18:56:40 +00:00
// Reads a gamefile page from an open file. Returns 0 on error.
int mng_ReadGamefilePage(CFILE *infile, mngs_gamefile_page *gamefilepage);
2024-04-16 03:43:29 +00:00
// Given an open file pointer and a gamefile_page struct, writes that gamefile page out
2024-04-16 18:56:40 +00:00
void mng_WriteNewGamefilePage(CFILE *outfile, mngs_gamefile_page *gamefilepage);
2024-04-16 03:43:29 +00:00
2024-04-16 18:56:40 +00:00
// Reads a gamefile page from an open file. Returns 0 on error.
int mng_ReadNewGamefilePage(CFILE *infile, mngs_gamefile_page *gamefilepage);
2024-04-16 03:43:29 +00:00
// Reads in the gamefilepage named "name" into gamefilepage struct
// Returns 0 on error or couldn't find, else 1 if all is good
2024-04-16 18:56:40 +00:00
int mng_FindSpecificGamefilePage(char *name, mngs_gamefile_page *gamefilepage, int offset = 0);
2024-04-16 03:43:29 +00:00
2024-04-16 18:56:40 +00:00
// Given a gamefile page, allocs a gamefile and calls AssignGamefilePageToGamefile to actually
2024-04-16 03:43:29 +00:00
// load bitmaps and values. Rturns gamefile handle on success, -1 if fail
2024-04-16 18:56:40 +00:00
int mng_SetAndLoadGamefile(mngs_gamefile_page *gamefilepage);
2024-04-16 03:43:29 +00:00
2024-04-16 18:56:40 +00:00
// Given a gamefilepage and a gamefile handle, attempts to make gamefile n correspond to
// to the gamefilepage.
2024-04-16 03:43:29 +00:00
// Returns 1 on success, 0 otherwise
2024-04-16 18:56:40 +00:00
int mng_AssignGamefilePageToGamefile(mngs_gamefile_page *gamefilepage, int n);
2024-04-16 03:43:29 +00:00
// Copies values from a gamefile into a gamefile_page
2024-04-16 18:56:40 +00:00
void mng_AssignGamefileToGamefilePage(int n, mngs_gamefile_page *gamefilepage);
2024-04-16 03:43:29 +00:00
2024-04-16 18:56:40 +00:00
// Reads in a gamefile page from the local table file, superseding any gamefile
2024-04-16 03:43:29 +00:00
// already in RAM with that same name
void mng_LoadLocalGamefilePage(CFILE *);
// Reads in a page off the net
2024-04-16 18:56:40 +00:00
void mng_LoadNetGamefilePage(CFILE *, bool overlay = false);
2024-04-16 03:43:29 +00:00
// First searches through the gamefile index to see if the gamefile is already
2024-04-16 18:56:40 +00:00
// loaded. If not, searches in the table file and loads it.
2024-04-16 03:43:29 +00:00
// Returns index of gamefile if found, -1 if not
2024-04-16 18:56:40 +00:00
int mng_GetGuaranteedGamefilePage(char *name, CFILE *infile = NULL);
2024-04-16 03:43:29 +00:00
#endif