Commit 06fba6a9 authored by Steven Fuller's avatar Steven Fuller

Finished rewriting config files and save games. Hoping that everything still

works...
parent 3d610c50
......@@ -77,3 +77,33 @@ at a time
possible to calculate the sound lengths in terms of 70Hz (adlib sound len / 2,
pcm sound len / 100).
------------------------------------------------------------------------------
Save game header:
8 bytes: WOLF3D, 0, 0
4 bytes: SAV, 0
4 bytes: version (integer)
4 bytes: game type (WL1, WL6, SDM, SOD)
4 bytes: seconds past 1970 (time(NULL))
4 bytes: padding
4 bytes: checksum for the data (after text string)
32 bytes: text string
< data follows >
---
Config header:
8 bytes: WOLF3D, 0, 0
4 bytes: CFG, 0
4 bytes: version (integer)
4 bytes: game type (WL1, WL6, SDM, SOD)
4 bytes: seconds past 1970 (time(NULL))
4 bytes: padding
4 bytes: checksum for the data
Version 0xFFFFFFFF Data: (Unofficial Config data)
<see wl_main.c>
Version 0x00000000 Data: (Official)
<undetermined>
------------------------------------------------------------------------------
......@@ -7,9 +7,9 @@
#define MaxHighName 57
#define MaxScores 7
typedef struct {
char name[MaxHighName + 1];
long score;
word completed,episode;
char name[MaxHighName + 1];
int score;
int completed, episode;
} HighScore;
#define MaxString 128 // Maximum input string size
......
......@@ -226,11 +226,18 @@ int OpenWrite(char *fn)
{
int fp;
/* fp = creat(fn, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH); */
fp = open(fn, O_CREAT|O_WRONLY|O_TRUNC|O_BINARY, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH);
return fp;
}
int OpenWriteAppend(char *fn)
{
int fp;
fp = open(fn, O_CREAT|O_WRONLY|O_BINARY, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH);
return fp;
}
void CloseWrite(int fp)
{
close(fp);
......@@ -241,6 +248,11 @@ int WriteSeek(int fp, int offset, int whence)
return lseek(fp, offset, whence);
}
int WritePos(int fp)
{
return lseek(fp, 0, SEEK_CUR);
}
int WriteInt8(int fp, int8_t d)
{
return write(fp, &d, 1);
......
......@@ -25,9 +25,11 @@ char *ultoa(unsigned long value, char *string, int radix);
#endif /* DOSISM */
extern int OpenWrite(char *fn);
extern int OpenWriteAppend(char *fn);
extern void CloseWrite(int fp);
extern int WriteSeek(int fp, int offset, int whence);
extern int WritePos(int fp);
extern int WriteInt8(int fp, int8_t d);
extern int WriteInt16(int fp, int16_t d);
......
......@@ -689,21 +689,22 @@ extern int shootdelta;
extern boolean startgame,loadedgame;
extern int mouseadjustment;
//
// math tables
//
/* math tables */
extern int pixelangle[MAXVIEWWIDTH];
extern long finetangent[FINEANGLES/4];
extern fixed sintable[], *costable;
extern char configname[13];
extern char configname[13];
void CalcProjection(long focal);
void NewGame(int difficulty,int episode);
void NewViewSize(int width);
void ShowViewSize(int width);
int LoadTheGame(char *fn, int x, int y);
int SaveTheGame(char *fn, char *tag, int x, int y);
int ReadSaveTag(char *fn, char *tag);
void CalcProjection (long focal);
void NewGame (int difficulty,int episode);
void NewViewSize (int width);
boolean LoadTheGame(int file,int x,int y);
boolean SaveTheGame(int file,int x,int y);
void ShowViewSize (int width);
void ShutdownId();
int WriteConfig();
......
......@@ -1058,7 +1058,7 @@ restartgame:
SetupGameLevel();
#ifdef SPEAR
if (gamestate.mapon == 20) // give them the key allways
if (gamestate.mapon == 20) /* give them the key always */
{
gamestate.keys |= 1;
DrawKeys();
......
This diff is collapsed.
......@@ -1164,11 +1164,10 @@ void DrawLSAction(int which)
////////////////////////////////////////////////////////////////////
int CP_LoadGame(int quick)
{
int handle,which,exit=0;
int which, exit=0;
char name[13];
strcpy(name,SaveName);
strcpy(name, SaveName);
//
// QUICKLOAD?
......@@ -1180,12 +1179,9 @@ int CP_LoadGame(int quick)
if (SaveGamesAvail[which])
{
name[7]=which+'0';
handle=open(name,O_BINARY);
lseek(handle,32,SEEK_SET);
loadedgame=true;
LoadTheGame(handle,0,0);
LoadTheGame(name, 0, 0);
loadedgame=false;
close(handle);
DrawStatusBar();
......@@ -1209,14 +1205,10 @@ int CP_LoadGame(int quick)
ShootSnd();
name[7]=which+'0';
handle=open(name,O_BINARY);
lseek(handle,32,SEEK_SET);
DrawLSAction(0);
loadedgame=true;
LoadTheGame(handle,LSA_X+8,LSA_Y+5);
close(handle);
LoadTheGame(name, LSA_X+8, LSA_Y+5);
StartGame=1;
ShootSnd();
......@@ -1321,10 +1313,8 @@ void PrintLSEntry(int w,int color)
////////////////////////////////////////////////////////////////////
int CP_SaveGame(int quick)
{
int handle,which,exit=0;
unsigned nwritten;
char name[13],input[32];
int which, exit=0;
char name[13], input[32];
strcpy(name,SaveName);
......@@ -1337,16 +1327,9 @@ int CP_SaveGame(int quick)
if (SaveGamesAvail[which])
{
name[7]=which+'0';
handle=creat(name,S_IREAD|S_IWRITE);
strcpy(input,&SaveGameNames[which][0]);
nwritten = write(handle,(void *)input,32);
lseek(handle,32,SEEK_SET);
SaveTheGame(handle,0,0);
close(handle);
name[7] = which+'0';
SaveTheGame(name, &SaveGameNames[which][0], 0, 0);
return 1;
}
}
......@@ -1393,17 +1376,9 @@ int CP_SaveGame(int quick)
if (US_LineInput(LSM_X+LSItems.indent+2,LSM_Y+which*13+1,input,input,true,31,LSM_W-LSItems.indent-30))
{
SaveGamesAvail[which] = 1;
strcpy(&SaveGameNames[which][0],input);
handle = creat(name, S_IREAD|S_IWRITE);
nwritten = write(handle, (void *)input, 32);
lseek(handle, 32, SEEK_SET);
DrawLSAction(1);
SaveTheGame(handle, LSA_X+8, LSA_Y+5);
close(handle);
strcpy(&SaveGameNames[which][0],input);
SaveTheGame(name, input, LSA_X+8, LSA_Y+5);
ShootSnd();
exit=1;
}
......@@ -2622,14 +2597,12 @@ void SetupControlPanel()
which=f.ff_name[7]-'0';
if (which<10)
{
int handle;
char temp[32];
SaveGamesAvail[which]=1;
handle=open(f.ff_name,O_BINARY);
read(handle,temp,32);
close(handle);
strcpy(&SaveGameNames[which][0],temp);
if (ReadSaveTag(f.ff_name, temp) != -1) {
SaveGamesAvail[which]=1;
strcpy(&SaveGameNames[which][0],temp);
}
}
} while(!findnext(&f));
#else
......@@ -2666,14 +2639,12 @@ void SetupControlPanel()
which=f.name[7]-'0';
if (which<10)
{
int handle;
char temp[32];
SaveGamesAvail[which]=1;
handle=open(f.name,O_BINARY);
read(handle,temp,32);
close(handle);
strcpy(&SaveGameNames[which][0],temp);
if (ReadSaveTag(f.name, temp) != -1) {
SaveGamesAvail[which]=1;
strcpy(&SaveGameNames[which][0],temp);
}
}
} while(_findnext(hand, &f) != -1);
#endif
......@@ -2705,14 +2676,12 @@ void SetupControlPanel()
for (x = 0; x < globbuf.gl_pathc; x++) {
which = globbuf.gl_pathv[x][7] - '0';
if (which < 10) {
int handle;
char temp[32];
SaveGamesAvail[which] = 1;
handle = open(globbuf.gl_pathv[x], O_RDONLY);
read(handle, temp, 32);
close(handle);
strcpy(SaveGameNames[which], temp);
if (ReadSaveTag(globbuf.gl_pathv[x], temp) != -1) {
SaveGamesAvail[which]=1;
strcpy(&SaveGameNames[which][0],temp);
}
}
}
globfree(&globbuf);
......
......@@ -50,15 +50,7 @@ memptr demobuffer;
int controlx,controly; // range from -100 to 100 per tic
boolean buttonstate[NUMBUTTONS];
//===========================================================================
static void RemoveObj(objtype *gone);
void StopMusic();
void StartMusic();
void PlayLoop();
/*
=============================================================================
......@@ -770,9 +762,6 @@ void InitActorList()
= Sets the global variable new to point to a free spot in objlist.
= The free spot is inserted at the end of the liked list
=
= When the object list is full, the caller can either have it bomb out ot
= return a dummy object pointer that will never get used
=
=========================
*/
......@@ -805,7 +794,7 @@ void GetNewActor()
=
= RemoveObj
=
= Add the given object back into the free list, and unlink it from it's
= Add the given object back into the free list, and unlink it from its
= neighbors
=
=========================
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment