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 ...@@ -77,3 +77,33 @@ at a time
possible to calculate the sound lengths in terms of 70Hz (adlib sound len / 2, possible to calculate the sound lengths in terms of 70Hz (adlib sound len / 2,
pcm sound len / 100). 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 @@ ...@@ -7,9 +7,9 @@
#define MaxHighName 57 #define MaxHighName 57
#define MaxScores 7 #define MaxScores 7
typedef struct { typedef struct {
char name[MaxHighName + 1]; char name[MaxHighName + 1];
long score; int score;
word completed,episode; int completed, episode;
} HighScore; } HighScore;
#define MaxString 128 // Maximum input string size #define MaxString 128 // Maximum input string size
......
...@@ -226,11 +226,18 @@ int OpenWrite(char *fn) ...@@ -226,11 +226,18 @@ int OpenWrite(char *fn)
{ {
int fp; 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); 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; 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) void CloseWrite(int fp)
{ {
close(fp); close(fp);
...@@ -241,6 +248,11 @@ int WriteSeek(int fp, int offset, int whence) ...@@ -241,6 +248,11 @@ int WriteSeek(int fp, int offset, int whence)
return lseek(fp, offset, whence); return lseek(fp, offset, whence);
} }
int WritePos(int fp)
{
return lseek(fp, 0, SEEK_CUR);
}
int WriteInt8(int fp, int8_t d) int WriteInt8(int fp, int8_t d)
{ {
return write(fp, &d, 1); return write(fp, &d, 1);
......
...@@ -25,9 +25,11 @@ char *ultoa(unsigned long value, char *string, int radix); ...@@ -25,9 +25,11 @@ char *ultoa(unsigned long value, char *string, int radix);
#endif /* DOSISM */ #endif /* DOSISM */
extern int OpenWrite(char *fn); extern int OpenWrite(char *fn);
extern int OpenWriteAppend(char *fn);
extern void CloseWrite(int fp); extern void CloseWrite(int fp);
extern int WriteSeek(int fp, int offset, int whence); extern int WriteSeek(int fp, int offset, int whence);
extern int WritePos(int fp);
extern int WriteInt8(int fp, int8_t d); extern int WriteInt8(int fp, int8_t d);
extern int WriteInt16(int fp, int16_t d); extern int WriteInt16(int fp, int16_t d);
......
...@@ -689,21 +689,22 @@ extern int shootdelta; ...@@ -689,21 +689,22 @@ extern int shootdelta;
extern boolean startgame,loadedgame; extern boolean startgame,loadedgame;
extern int mouseadjustment; extern int mouseadjustment;
// /* math tables */
// math tables
//
extern int pixelangle[MAXVIEWWIDTH]; extern int pixelangle[MAXVIEWWIDTH];
extern long finetangent[FINEANGLES/4]; extern long finetangent[FINEANGLES/4];
extern fixed sintable[], *costable; 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(); void ShutdownId();
int WriteConfig(); int WriteConfig();
......
...@@ -1058,7 +1058,7 @@ restartgame: ...@@ -1058,7 +1058,7 @@ restartgame:
SetupGameLevel(); SetupGameLevel();
#ifdef SPEAR #ifdef SPEAR
if (gamestate.mapon == 20) // give them the key allways if (gamestate.mapon == 20) /* give them the key always */
{ {
gamestate.keys |= 1; gamestate.keys |= 1;
DrawKeys(); DrawKeys();
......
This diff is collapsed.
...@@ -1164,11 +1164,10 @@ void DrawLSAction(int which) ...@@ -1164,11 +1164,10 @@ void DrawLSAction(int which)
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
int CP_LoadGame(int quick) int CP_LoadGame(int quick)
{ {
int handle,which,exit=0; int which, exit=0;
char name[13]; char name[13];
strcpy(name, SaveName);
strcpy(name,SaveName);
// //
// QUICKLOAD? // QUICKLOAD?
...@@ -1180,12 +1179,9 @@ int CP_LoadGame(int quick) ...@@ -1180,12 +1179,9 @@ int CP_LoadGame(int quick)
if (SaveGamesAvail[which]) if (SaveGamesAvail[which])
{ {
name[7]=which+'0'; name[7]=which+'0';
handle=open(name,O_BINARY);
lseek(handle,32,SEEK_SET);
loadedgame=true; loadedgame=true;
LoadTheGame(handle,0,0); LoadTheGame(name, 0, 0);
loadedgame=false; loadedgame=false;
close(handle);
DrawStatusBar(); DrawStatusBar();
...@@ -1209,14 +1205,10 @@ int CP_LoadGame(int quick) ...@@ -1209,14 +1205,10 @@ int CP_LoadGame(int quick)
ShootSnd(); ShootSnd();
name[7]=which+'0'; name[7]=which+'0';
handle=open(name,O_BINARY);
lseek(handle,32,SEEK_SET);
DrawLSAction(0); DrawLSAction(0);
loadedgame=true; loadedgame=true;
LoadTheGame(handle,LSA_X+8,LSA_Y+5); LoadTheGame(name, LSA_X+8, LSA_Y+5);
close(handle);
StartGame=1; StartGame=1;
ShootSnd(); ShootSnd();
...@@ -1321,10 +1313,8 @@ void PrintLSEntry(int w,int color) ...@@ -1321,10 +1313,8 @@ void PrintLSEntry(int w,int color)
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
int CP_SaveGame(int quick) int CP_SaveGame(int quick)
{ {
int handle,which,exit=0; int which, exit=0;
unsigned nwritten; char name[13], input[32];
char name[13],input[32];
strcpy(name,SaveName); strcpy(name,SaveName);
...@@ -1337,16 +1327,9 @@ int CP_SaveGame(int quick) ...@@ -1337,16 +1327,9 @@ int CP_SaveGame(int quick)
if (SaveGamesAvail[which]) if (SaveGamesAvail[which])
{ {
name[7]=which+'0'; name[7] = which+'0';
handle=creat(name,S_IREAD|S_IWRITE); SaveTheGame(name, &SaveGameNames[which][0], 0, 0);
strcpy(input,&SaveGameNames[which][0]);
nwritten = write(handle,(void *)input,32);
lseek(handle,32,SEEK_SET);
SaveTheGame(handle,0,0);
close(handle);
return 1; return 1;
} }
} }
...@@ -1393,17 +1376,9 @@ int CP_SaveGame(int quick) ...@@ -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)) 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; 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); DrawLSAction(1);
SaveTheGame(handle, LSA_X+8, LSA_Y+5); strcpy(&SaveGameNames[which][0],input);
SaveTheGame(name, input, LSA_X+8, LSA_Y+5);
close(handle);
ShootSnd(); ShootSnd();
exit=1; exit=1;
} }
...@@ -2622,14 +2597,12 @@ void SetupControlPanel() ...@@ -2622,14 +2597,12 @@ void SetupControlPanel()
which=f.ff_name[7]-'0'; which=f.ff_name[7]-'0';
if (which<10) if (which<10)
{ {
int handle;
char temp[32]; char temp[32];
SaveGamesAvail[which]=1; if (ReadSaveTag(f.ff_name, temp) != -1) {
handle=open(f.ff_name,O_BINARY); SaveGamesAvail[which]=1;
read(handle,temp,32); strcpy(&SaveGameNames[which][0],temp);
close(handle); }
strcpy(&SaveGameNames[which][0],temp);
} }
} while(!findnext(&f)); } while(!findnext(&f));
#else #else
...@@ -2666,14 +2639,12 @@ void SetupControlPanel() ...@@ -2666,14 +2639,12 @@ void SetupControlPanel()
which=f.name[7]-'0'; which=f.name[7]-'0';
if (which<10) if (which<10)
{ {
int handle;
char temp[32]; char temp[32];
SaveGamesAvail[which]=1; if (ReadSaveTag(f.name, temp) != -1) {
handle=open(f.name,O_BINARY); SaveGamesAvail[which]=1;
read(handle,temp,32); strcpy(&SaveGameNames[which][0],temp);
close(handle); }
strcpy(&SaveGameNames[which][0],temp);
} }
} while(_findnext(hand, &f) != -1); } while(_findnext(hand, &f) != -1);
#endif #endif
...@@ -2705,14 +2676,12 @@ void SetupControlPanel() ...@@ -2705,14 +2676,12 @@ void SetupControlPanel()
for (x = 0; x < globbuf.gl_pathc; x++) { for (x = 0; x < globbuf.gl_pathc; x++) {
which = globbuf.gl_pathv[x][7] - '0'; which = globbuf.gl_pathv[x][7] - '0';
if (which < 10) { if (which < 10) {
int handle;
char temp[32]; char temp[32];
SaveGamesAvail[which] = 1; if (ReadSaveTag(globbuf.gl_pathv[x], temp) != -1) {
handle = open(globbuf.gl_pathv[x], O_RDONLY); SaveGamesAvail[which]=1;
read(handle, temp, 32); strcpy(&SaveGameNames[which][0],temp);
close(handle); }
strcpy(SaveGameNames[which], temp);
} }
} }
globfree(&globbuf); globfree(&globbuf);
......
...@@ -50,15 +50,7 @@ memptr demobuffer; ...@@ -50,15 +50,7 @@ memptr demobuffer;
int controlx,controly; // range from -100 to 100 per tic int controlx,controly; // range from -100 to 100 per tic
boolean buttonstate[NUMBUTTONS]; boolean buttonstate[NUMBUTTONS];
//===========================================================================
static void RemoveObj(objtype *gone); static void RemoveObj(objtype *gone);
void StopMusic();
void StartMusic();
void PlayLoop();
/* /*
============================================================================= =============================================================================
...@@ -770,9 +762,6 @@ void InitActorList() ...@@ -770,9 +762,6 @@ void InitActorList()
= Sets the global variable new to point to a free spot in objlist. = 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 = 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() ...@@ -805,7 +794,7 @@ void GetNewActor()
= =
= RemoveObj = 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 = 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