[SCM] SDL-Port of Wolfenstein 3-D and Spear of Destiny branch, master, updated. debian/1.6-0fab3-9-g663c1bd
Jon Dowland
jmtd at debian.org
Thu Mar 24 11:49:09 UTC 2011
The following commit has been merged in the master branch:
commit 663c1bd544789b4d5af58ba51f08fc45158c50ce
Author: Jon Dowland <jmtd at debian.org>
Date: Wed Mar 23 23:44:49 2011 +0000
line-wrap changelog
diff --git a/Makefile b/Makefile
index 75ba7a1..a2cbe1b 100644
--- a/Makefile
+++ b/Makefile
@@ -54,6 +54,7 @@ SRCS += wl_agent.cpp
SRCS += wl_atmos.cpp
SRCS += wl_cloudsky.cpp
SRCS += wl_debug.cpp
+SRCS += wl_shade.cpp
SRCS += wl_draw.cpp
SRCS += wl_floorceiling.cpp
SRCS += wl_game.cpp
diff --git a/debian/changelog b/debian/changelog
index 5fbdc72..a90caab 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -8,7 +8,8 @@ wolf4sdl (1.6-1) experimental; urgency=low
* Add Vcs-* fields.
* Play safe and run "make clean" between the builds.
* Fix debian/watch file.
- * Document the missing game data files in both debian/control and README.Debian.
+ * Document the missing game data files in both debian/control and
+ README.Debian.
-- Fabian Greffrath <fabian+debian at greffrath.com> Mon, 28 Feb 2011 13:06:25 +0100
diff --git a/fmopl.cpp b/fmopl.cpp
index 77ce741..ae10f37 100644
--- a/fmopl.cpp
+++ b/fmopl.cpp
@@ -1955,19 +1955,21 @@ static void OPLSetUpdateHandler(FM_OPL *OPL,OPL_UPDATEHANDLER UpdateHandler,int
OPL->UpdateParam = param;
}
+/*
static int OPLWrite(FM_OPL *OPL,int a,int v)
{
if( !(a&1) )
- { /* address port */
+ { // address port
OPL->address = v & 0xff;
}
else
- { /* data port */
+ { // data port
if(OPL->UpdateHandler) OPL->UpdateHandler(OPL->UpdateParam,0);
OPLWriteReg(OPL,OPL->address,v);
}
return OPL->status>>7;
}
+*/
static unsigned char OPLRead(FM_OPL *OPL,int a)
{
diff --git a/id_ca.cpp b/id_ca.cpp
index f2f2b63..a66c362 100644
--- a/id_ca.cpp
+++ b/id_ca.cpp
@@ -23,7 +23,6 @@ loaded into the data segment
#endif
#include "wl_def.h"
-#pragma hdrstop
#define THREEBYTEGRSTARTS
@@ -81,13 +80,13 @@ int numEpisodesMissing = 0;
char extension[5]; // Need a string, not constant to change cache files
char graphext[5];
char audioext[5];
-static const char gheadname[] = "vgahead.";
-static const char gfilename[] = "vgagraph.";
-static const char gdictname[] = "vgadict.";
-static const char mheadname[] = "maphead.";
-static const char mfilename[] = "maptemp.";
-static const char aheadname[] = "audiohed.";
-static const char afilename[] = "audiot.";
+static const char gheadname[] = DATADIR "vgahead.";
+static const char gfilename[] = DATADIR "vgagraph.";
+static const char gdictname[] = DATADIR "vgadict.";
+static const char mheadname[] = DATADIR "maphead.";
+static const char mfilename[] = DATADIR "maptemp.";
+static const char aheadname[] = DATADIR "audiohed.";
+static const char afilename[] = DATADIR "audiot.";
void CA_CannotOpen(const char *string);
@@ -154,7 +153,7 @@ void CAL_GetGrChunkLength (int chunk)
boolean CA_WriteFile (const char *filename, void *ptr, int32_t length)
{
- const int handle = open(filename, O_CREAT | O_WRONLY | O_BINARY);
+ const int handle = open(filename, O_CREAT | O_WRONLY | O_BINARY, 0644);
if (handle == -1)
return false;
@@ -443,7 +442,7 @@ void CA_RLEWexpand (word *source, word *dest, int32_t length, word rlewtag)
void CAL_SetupGrFile (void)
{
- char fname[13];
+ char fname[13 + sizeof(DATADIR)];
int handle;
byte *compseg;
@@ -539,7 +538,7 @@ void CAL_SetupMapFile (void)
int i;
int handle;
int32_t length,pos;
- char fname[13];
+ char fname[13 + sizeof(DATADIR)];
//
// load maphead.ext (offsets and tileinfo for map file)
@@ -563,7 +562,7 @@ void CAL_SetupMapFile (void)
// open the data file
//
#ifdef CARMACIZED
- strcpy(fname, "gamemaps.");
+ strcpy(fname, DATADIR "gamemaps.");
strcat(fname, extension);
maphandle = open(fname, O_RDONLY | O_BINARY);
@@ -619,7 +618,7 @@ void CAL_SetupMapFile (void)
void CAL_SetupAudioFile (void)
{
- char fname[13];
+ char fname[13 + sizeof(DATADIR)];
//
// load audiohed.ext (offsets for audio file)
@@ -685,7 +684,7 @@ void CA_Startup (void)
void CA_Shutdown (void)
{
- int i,start;
+ int i,start = STARTADLIBSOUNDS;
if(maphandle != -1)
close(maphandle);
@@ -795,7 +794,7 @@ void CA_CacheAdlibSoundChunk (int chunk)
void CA_LoadAllSounds (void)
{
- unsigned start,i;
+ unsigned start = STARTADLIBSOUNDS,i;
switch (oldsoundmode)
{
@@ -1031,7 +1030,7 @@ void CA_CacheMap (int mapnum)
int32_t pos,compressed;
int plane;
word *dest;
- memptr bigbufferseg;
+ memptr bigbufferseg = 0;
unsigned size;
word *source;
#ifdef CARMACIZED
diff --git a/id_pm.cpp b/id_pm.cpp
index b238edf..d24219c 100644
--- a/id_pm.cpp
+++ b/id_pm.cpp
@@ -16,7 +16,7 @@ uint8_t **PMPages;
void PM_Startup()
{
- char fname[13] = "vswap.";
+ char fname[13 + sizeof(DATADIR)] = DATADIR "vswap.";
strcat(fname,extension);
FILE *file = fopen(fname,"rb");
@@ -82,7 +82,7 @@ void PM_Startup()
uint8_t *ptr = (uint8_t *) PMPageData;
for(i = 0; i < ChunksInFile; i++)
{
- if(i >= PMSpriteStart && i < PMSoundStart || i == ChunksInFile - 1)
+ if((i >= PMSpriteStart && i < PMSoundStart) || i == ChunksInFile - 1)
{
size_t offs = ptr - (uint8_t *) PMPageData;
diff --git a/id_sd.cpp b/id_sd.cpp
index 165fc67..92cb865 100644
--- a/id_sd.cpp
+++ b/id_sd.cpp
@@ -31,7 +31,6 @@
#include <SDL_mixer.h>
#include "fmopl.h"
-#pragma hdrstop
#define ORIGSAMPLERATE 7042
@@ -95,7 +94,6 @@ static boolean DigiPlaying;
// PC Sound variables
static volatile byte pcLastSample;
static byte * volatile pcSound;
-static longword pcLengthLeft;
// AdLib variables
static byte * volatile alSound;
@@ -780,6 +778,7 @@ SDL_ShutAL(void)
// SDL_CleanAL() - Totally shuts down the AdLib card
//
///////////////////////////////////////////////////////////////////////////
+/*
static void
SDL_CleanAL(void)
{
@@ -789,6 +788,7 @@ SDL_CleanAL(void)
for (i = 1; i < 0xf5; i++)
alOut(i, 0);
}
+*/
///////////////////////////////////////////////////////////////////////////
//
@@ -808,6 +808,7 @@ SDL_StartAL(void)
// emulating an AdLib) present
//
///////////////////////////////////////////////////////////////////////////
+/*
static boolean
SDL_DetectAdLib(void)
{
@@ -819,6 +820,7 @@ SDL_DetectAdLib(void)
return true;
}
+*/
////////////////////////////////////////////////////////////////////////////
//
@@ -845,12 +847,14 @@ SDL_ShutDevice(void)
// SDL_CleanDevice() - totally shuts down all sound devices
//
///////////////////////////////////////////////////////////////////////////
+/*
static void
SDL_CleanDevice(void)
{
if ((SoundMode == sdm_AdLib) || (MusicMode == smm_AdLib))
SDL_CleanAL();
}
+*/
///////////////////////////////////////////////////////////////////////////
//
diff --git a/id_us_1.cpp b/id_us_1.cpp
index db8e30e..aeac073 100644
--- a/id_us_1.cpp
+++ b/id_us_1.cpp
@@ -22,7 +22,6 @@
#include "wl_def.h"
-#pragma hdrstop
#if _MSC_VER == 1200 // Visual C++ 6
#define vsnprintf _vsnprintf
@@ -177,7 +176,7 @@ void
US_PrintUnsigned(longword n)
{
char buffer[32];
- sprintf(buffer, "%lu", n);
+ sprintf(buffer, "%lu", (long unsigned int) n);
US_Print(buffer);
}
@@ -488,11 +487,11 @@ US_LineInput(int x,int y,char *buf,const char *def,boolean escok,
{
boolean redraw,
cursorvis,cursormoved,
- done,result, checkkey;
+ done,result = false, checkkey;
ScanCode sc;
char c;
char s[MaxString],olds[MaxString];
- int cursor,len;
+ int cursor,len = 0;
word i,
w,h,
temp;
@@ -530,7 +529,7 @@ US_LineInput(int x,int y,char *buf,const char *def,boolean escok,
curtime = GetTimeCount();
// After each direction change accept the next change after 250 ms and then everz 125 ms
- if(ci.dir != lastdir || curtime - lastdirtime > TickBase / 4 && curtime - lastdirmovetime > TickBase / 8)
+ if(ci.dir != lastdir || (curtime - lastdirtime > TickBase / 4 && curtime - lastdirmovetime > TickBase / 8))
{
if(ci.dir != lastdir)
{
@@ -558,7 +557,7 @@ US_LineInput(int x,int y,char *buf,const char *def,boolean escok,
if(!s[cursor])
{
USL_MeasureString(s,&w,&h);
- if(len >= maxchars || maxwidth && w >= maxwidth) break;
+ if(len >= maxchars || (maxwidth && w >= maxwidth)) break;
s[cursor] = ' ';
s[cursor + 1] = 0;
@@ -572,7 +571,7 @@ US_LineInput(int x,int y,char *buf,const char *def,boolean escok,
if(!s[cursor])
{
USL_MeasureString(s,&w,&h);
- if(len >= maxchars || maxwidth && w >= maxwidth) break;
+ if(len >= maxchars || (maxwidth && w >= maxwidth)) break;
s[cursor + 1] = 0;
}
s[cursor] = USL_RotateChar(s[cursor], 1);
@@ -584,7 +583,7 @@ US_LineInput(int x,int y,char *buf,const char *def,boolean escok,
if(!s[cursor])
{
USL_MeasureString(s,&w,&h);
- if(len >= maxchars || maxwidth && w >= maxwidth) break;
+ if(len >= maxchars || (maxwidth && w >= maxwidth)) break;
s[cursor + 1] = 0;
}
s[cursor] = USL_RotateChar(s[cursor], -1);
diff --git a/id_vl.cpp b/id_vl.cpp
index 57886c0..82f6e22 100644
--- a/id_vl.cpp
+++ b/id_vl.cpp
@@ -2,7 +2,6 @@
#include <string.h>
#include "wl_def.h"
-#pragma hdrstop
// Uncomment the following line, if you get destination out of bounds
// assertion errors and want to ignore them during debugging
diff --git a/version.h b/version.h
index 5ddcf12..dd4d453 100644
--- a/version.h
+++ b/version.h
@@ -3,12 +3,16 @@
#ifndef VERSIONALREADYCHOSEN // used for batch compiling
+#ifndef DATADIR
+#define DATADIR ""
+#endif
+
/* Defines used for different versions */
-//#define SPEAR
-//#define SPEARDEMO
+#define SPEAR
+#define SPEARDEMO
//#define UPLOAD
-#define GOODTIMES
+//#define GOODTIMES
#define CARMACIZED
//#define APOGEE_1_0
//#define APOGEE_1_1
@@ -30,7 +34,7 @@
#endif
//#define USE_FEATUREFLAGS // Enables the level feature flags (see bottom of wl_def.h)
-//#define USE_SHADING // Enables shading support (see wl_shade.cpp)
+#define USE_SHADING // Enables shading support (see wl_shade.cpp)
//#define USE_DIR3DSPR // Enables directional 3d sprites (see wl_dir3dspr.cpp)
//#define USE_FLOORCEILINGTEX // Enables floor and ceiling textures stored in the third mapplane (see wl_floorceiling.cpp)
//#define USE_HIRES // Enables high resolution textures/sprites (128x128)
diff --git a/wl_act1.cpp b/wl_act1.cpp
index 40dc82d..69fc738 100644
--- a/wl_act1.cpp
+++ b/wl_act1.cpp
@@ -1,7 +1,6 @@
// WL_ACT1.C
#include "wl_def.h"
-#pragma hdrstop
/*
=============================================================================
@@ -17,6 +16,7 @@ statobj_t *laststatobj;
struct
+statinfo_t
{
short picnum;
wl_stat_t type;
@@ -844,7 +844,7 @@ void MovePWalls (void)
pwally += dy;
if (actorat[pwallx+dx][pwally+dy]
- || xl<=pwallx+dx && pwallx+dx<=xh && yl<=pwally+dy && pwally+dy<=yh)
+ || (xl<=pwallx+dx && pwallx+dx<=xh && yl<=pwally+dy && pwally+dy<=yh))
{
pwallstate = 0;
tilemap[pwallx][pwally] = oldtile;
diff --git a/wl_act2.cpp b/wl_act2.cpp
index cacdd98..287f5d8 100644
--- a/wl_act2.cpp
+++ b/wl_act2.cpp
@@ -3,7 +3,6 @@
#include <stdio.h>
#include <math.h>
#include "wl_def.h"
-#pragma hdrstop
/*
=============================================================================
@@ -307,7 +306,7 @@ boolean ProjectileTryMove (objtype *ob)
void T_Projectile (objtype *ob)
{
int32_t deltax,deltay;
- int damage;
+ int damage = 0;
int32_t speed;
speed = (int32_t)ob->speed*tics;
diff --git a/wl_agent.cpp b/wl_agent.cpp
index cc49087..23234eb 100644
--- a/wl_agent.cpp
+++ b/wl_agent.cpp
@@ -1,7 +1,6 @@
// WL_AGENT.C
#include "wl_def.h"
-#pragma hdrstop
/*
=============================================================================
diff --git a/wl_debug.cpp b/wl_debug.cpp
index deaa0b8..2d5e6fc 100644
--- a/wl_debug.cpp
+++ b/wl_debug.cpp
@@ -7,7 +7,6 @@
#endif
#include "wl_def.h"
-#pragma hdrstop
#ifdef USE_CLOUDSKY
#include "wl_cloudsky.h"
@@ -52,7 +51,7 @@ void SimpleScaleShape (int xcenter, int shapenum, unsigned height);
int maporgx;
int maporgy;
-enum {mapview,tilemapview,actoratview,visview} viewtype;
+enum viewtype_t {mapview,tilemapview,actoratview,visview} viewtype;
void ViewMap (void);
@@ -181,7 +180,7 @@ void BasicOverhead (void)
// left side (filtered)
uintptr_t tile;
- int color;
+ int color = 0;
offx -= 128;
for(x=0;x<MAPSIZE;x++)
diff --git a/wl_def.h b/wl_def.h
index 48007f5..95e30c8 100644
--- a/wl_def.h
+++ b/wl_def.h
@@ -915,7 +915,7 @@ extern unsigned screenofs;
extern boolean startgame;
extern char str[80];
-extern char configname[13];
+extern char configname[256];
//
// Command line parameter variables
diff --git a/wl_draw.cpp b/wl_draw.cpp
index 3eb9e6a..65909ad 100644
--- a/wl_draw.cpp
+++ b/wl_draw.cpp
@@ -1,7 +1,6 @@
// WL_DRAW.C
#include "wl_def.h"
-#pragma hdrstop
#include "wl_cloudsky.h"
#include "wl_atmos.h"
@@ -484,7 +483,7 @@ void HitHorizWall (void)
void HitHorizDoor (void)
{
- int doorpage;
+ int doorpage = DOORWALL;
int doornum;
int texture;
@@ -549,7 +548,7 @@ void HitHorizDoor (void)
void HitVertDoor (void)
{
- int doorpage;
+ int doorpage = DOORWALL+1;
int doornum;
int texture;
@@ -1208,8 +1207,8 @@ void CalcTics (void)
void AsmRefresh()
{
- int32_t xstep,ystep;
- longword xpartial,ypartial;
+ int32_t xstep = 0,ystep = 0;
+ longword xpartial = 0,ypartial = 0;
boolean playerInPushwallBackTile = tilemap[focaltx][focalty] == 64;
for(pixx=0;pixx<viewwidth;pixx++)
@@ -1264,8 +1263,8 @@ void AsmRefresh()
// Special treatment when player is in back tile of pushwall
if(playerInPushwallBackTile)
{
- if( pwalldir == di_east && xtilestep == 1
- || pwalldir == di_west && xtilestep == -1)
+ if( (pwalldir == di_east && xtilestep == 1)
+ || (pwalldir == di_west && xtilestep == -1))
{
int32_t yintbuf = yintercept - ((ystep * (64 - pwallpos)) >> 6);
if((yintbuf >> 16) == focalty) // ray hits pushwall back?
@@ -1280,8 +1279,8 @@ void AsmRefresh()
continue;
}
}
- else if(pwalldir == di_south && ytilestep == 1
- || pwalldir == di_north && ytilestep == -1)
+ else if((pwalldir == di_south && ytilestep == 1)
+ || (pwalldir == di_north && ytilestep == -1))
{
int32_t xintbuf = xintercept - ((xstep * (64 - pwallpos)) >> 6);
if((xintbuf >> 16) == focaltx) // ray hits pushwall back?
@@ -1348,8 +1347,8 @@ vertentry:
pwallposnorm = pwallpos;
pwallposinv = 64-pwallpos;
}
- if(pwalldir == di_east && xtile==pwallx && ((uint32_t)yintercept>>16)==pwally
- || pwalldir == di_west && !(xtile==pwallx && ((uint32_t)yintercept>>16)==pwally))
+ if((pwalldir == di_east && xtile==pwallx && ((uint32_t)yintercept>>16)==pwally)
+ || (pwalldir == di_west && !(xtile==pwallx && ((uint32_t)yintercept>>16)==pwally)))
{
yintbuf=yintercept+((ystep*pwallposnorm)>>6);
if((yintbuf>>16)!=(yintercept>>16))
@@ -1376,13 +1375,13 @@ vertentry:
{
int pwallposi = pwallpos;
if(pwalldir==di_north) pwallposi = 64-pwallpos;
- if(pwalldir==di_south && (word)yintercept<(pwallposi<<10)
- || pwalldir==di_north && (word)yintercept>(pwallposi<<10))
+ if((pwalldir==di_south && (word)yintercept<(pwallposi<<10))
+ || (pwalldir==di_north && (word)yintercept>(pwallposi<<10)))
{
if(((uint32_t)yintercept>>16)==pwally && xtile==pwallx)
{
- if(pwalldir==di_south && (int32_t)((word)yintercept)+ystep<(pwallposi<<10)
- || pwalldir==di_north && (int32_t)((word)yintercept)+ystep>(pwallposi<<10))
+ if((pwalldir==di_south && (int32_t)((word)yintercept)+ystep<(pwallposi<<10))
+ || (pwalldir==di_north && (int32_t)((word)yintercept)+ystep>(pwallposi<<10)))
goto passvert;
if(pwalldir==di_south)
@@ -1412,8 +1411,8 @@ vertentry:
}
else
{
- if(pwalldir==di_south && (int32_t)((word)yintercept)+ystep>(pwallposi<<10)
- || pwalldir==di_north && (int32_t)((word)yintercept)+ystep<(pwallposi<<10))
+ if((pwalldir==di_south && (int32_t)((word)yintercept)+ystep>(pwallposi<<10))
+ || (pwalldir==di_north && (int32_t)((word)yintercept)+ystep<(pwallposi<<10)))
goto passvert;
if(pwalldir==di_south)
@@ -1494,8 +1493,8 @@ horizentry:
pwallposnorm = pwallpos;
pwallposinv = 64-pwallpos;
}
- if(pwalldir == di_south && ytile==pwally && ((uint32_t)xintercept>>16)==pwallx
- || pwalldir == di_north && !(ytile==pwally && ((uint32_t)xintercept>>16)==pwallx))
+ if((pwalldir == di_south && ytile==pwally && ((uint32_t)xintercept>>16)==pwallx)
+ || (pwalldir == di_north && !(ytile==pwally && ((uint32_t)xintercept>>16)==pwallx)))
{
xintbuf=xintercept+((xstep*pwallposnorm)>>6);
if((xintbuf>>16)!=(xintercept>>16))
@@ -1522,13 +1521,13 @@ horizentry:
{
int pwallposi = pwallpos;
if(pwalldir==di_west) pwallposi = 64-pwallpos;
- if(pwalldir==di_east && (word)xintercept<(pwallposi<<10)
- || pwalldir==di_west && (word)xintercept>(pwallposi<<10))
+ if((pwalldir==di_east && (word)xintercept<(pwallposi<<10))
+ || (pwalldir==di_west && (word)xintercept>(pwallposi<<10)))
{
if(((uint32_t)xintercept>>16)==pwallx && ytile==pwally)
{
- if(pwalldir==di_east && (int32_t)((word)xintercept)+xstep<(pwallposi<<10)
- || pwalldir==di_west && (int32_t)((word)xintercept)+xstep>(pwallposi<<10))
+ if((pwalldir==di_east && (int32_t)((word)xintercept)+xstep<(pwallposi<<10))
+ || (pwalldir==di_west && (int32_t)((word)xintercept)+xstep>(pwallposi<<10)))
goto passhoriz;
if(pwalldir==di_east)
@@ -1558,8 +1557,8 @@ horizentry:
}
else
{
- if(pwalldir==di_east && (int32_t)((word)xintercept)+xstep>(pwallposi<<10)
- || pwalldir==di_west && (int32_t)((word)xintercept)+xstep<(pwallposi<<10))
+ if((pwalldir==di_east && (int32_t)((word)xintercept)+xstep>(pwallposi<<10))
+ || (pwalldir==di_west && (int32_t)((word)xintercept)+xstep<(pwallposi<<10)))
goto passhoriz;
if(pwalldir==di_east)
diff --git a/wl_game.cpp b/wl_game.cpp
index bee0073..fcbad42 100644
--- a/wl_game.cpp
+++ b/wl_game.cpp
@@ -3,7 +3,6 @@
#include <math.h>
#include "wl_def.h"
#include <SDL_mixer.h>
-#pragma hdrstop
#ifdef MYPROFILE
#include <TIME.H>
@@ -1177,7 +1176,8 @@ void PlayDemo (int demonumber)
NewGame (1,0);
gamestate.mapon = *demoptr++;
gamestate.difficulty = gd_hard;
- length = READWORD(*(uint8_t **)&demoptr);
+ length = demoptr[0] | demoptr[1] << 8;
+ demoptr+=2;
// TODO: Seems like the original demo format supports 16 MB demos
// But T_DEM00 and T_DEM01 of Wolf have a 0xd8 as third length size...
demoptr++;
diff --git a/wl_inter.cpp b/wl_inter.cpp
index c045de8..d60f07e 100644
--- a/wl_inter.cpp
+++ b/wl_inter.cpp
@@ -1,7 +1,6 @@
// WL_INTER.C
#include "wl_def.h"
-#pragma hdrstop
LRstruct LevelRatios[LRpack];
int32_t lastBreathTime = 0;
@@ -386,7 +385,7 @@ Write (int x, int y, const char *string)
break;
default:
- VWB_DrawPic (nx, ny, alpha[ch]);
+ VWB_DrawPic (nx, ny, alpha[(int)ch]);
}
nx += 16;
}
diff --git a/wl_main.cpp b/wl_main.cpp
index dca0e89..b9313f7 100644
--- a/wl_main.cpp
+++ b/wl_main.cpp
@@ -4,12 +4,14 @@
#include <io.h>
#else
#include <unistd.h>
+ #include <sys/stat.h>
+ #include <sys/types.h>
#endif
#include "wl_def.h"
-#pragma hdrstop
#include "wl_atmos.h"
#include <SDL_syswm.h>
+#include <errno.h>
/*
@@ -73,7 +75,8 @@ boolean startgame;
boolean loadedgame;
int mouseadjustment;
-char configname[13]="config.";
+char configdir[256];
+char configname[256];
//
// Command line parameter variables
@@ -1418,7 +1421,7 @@ void Quit (const char *errorStr, ...)
if (!pictable) // don't try to display the red box before it's loaded
{
ShutdownId();
- if (error && *error)
+ if (*error)
{
#ifdef NOTYET
SetTextCursor(0,0);
@@ -1432,7 +1435,7 @@ void Quit (const char *errorStr, ...)
exit(1);
}
- if (!error || !*error)
+ if (!*error)
{
#ifdef NOTYET
#ifndef JAPAN
@@ -1452,7 +1455,7 @@ void Quit (const char *errorStr, ...)
ShutdownId ();
- if (error && *error)
+ if (*error)
{
#ifdef NOTYET
memcpy((byte *)0xb8000,screen+7,7*160);
@@ -1466,7 +1469,7 @@ void Quit (const char *errorStr, ...)
exit(1);
}
else
- if (!error || !(*error))
+ if (!*error)
{
#ifdef NOTYET
#ifndef JAPAN
@@ -1698,7 +1701,7 @@ void CheckParameters(int argc, char *argv[])
screenWidth = atoi(argv[++i]);
screenHeight = atoi(argv[++i]);
unsigned factor = screenWidth / 320;
- if(screenWidth % 320 || screenHeight != 200 * factor && screenHeight != 240 * factor)
+ if(screenWidth % 320 || (screenHeight != 200 * factor && screenHeight != 240 * factor))
printf("Screen size must be a multiple of 320x200 or 320x240!\n"), hasError = true;
}
}
@@ -1871,6 +1874,19 @@ int main (int argc, char *argv[])
CheckParameters(argc, argv);
#endif
+#if defined (__unix__) && !defined(__MINGW32__)
+ /* Set up home directory */
+ if (getenv ("HOME") == NULL)
+ Quit ("Could not get \"HOME\" environment variable.");
+ int err;
+ snprintf(configdir, sizeof(configdir) - 1, "%s/.wolf4sdl/", getenv ("HOME"));
+ err = mkdir(configdir, S_IRWXU);
+ if (err == -1 && errno != EEXIST)
+ Quit ("Could not create directory \"%s\": %s\n", configdir, strerror (errno));
+#else
+ strcpy(configdir, "");
+#endif
+
CheckForEpisodes();
InitGame();
diff --git a/wl_menu.cpp b/wl_menu.cpp
index 5591803..297f16a 100644
--- a/wl_menu.cpp
+++ b/wl_menu.cpp
@@ -14,10 +14,10 @@
#endif
#include "wl_def.h"
-#pragma hdrstop
extern int lastgamemusicoffset;
extern int numEpisodesMissing;
+extern char configdir[256];
//
// PRIVATE PROTOTYPES
@@ -277,8 +277,8 @@ static int SaveGamesAvail[10];
static int StartGame;
static int SoundStatus = 1;
static int pickquick;
-static char SaveGameNames[10][32];
-static char SaveName[13] = "savegam?.";
+static char SaveGameNames[10][256];
+static char SaveName[256] = "savegam?.";
////////////////////////////////////////////////////////////////////
@@ -920,7 +920,7 @@ CP_CheckQuick (ScanCode scancode)
#ifdef SPANISH
if (Confirm (ENDGAMESTR))
#else
- if (Confirm (endStrings[US_RndT () & 0x7 + (US_RndT () & 1)]))
+ if (Confirm (endStrings[US_RndT () & (0x7 + (US_RndT () & 1))]))
#endif
#endif
{
@@ -1497,10 +1497,10 @@ CP_LoadGame (int quick)
{
FILE *file;
int which, exit = 0;
- char name[13];
+ char name[256];
- strcpy (name, SaveName);
+ snprintf (name, sizeof(name) - 1, "%s%s", configdir, SaveName);
//
// QUICKLOAD?
@@ -1511,7 +1511,7 @@ CP_LoadGame (int quick)
if (SaveGamesAvail[which])
{
- name[7] = which + '0';
+ name[strlen(configdir) + 7] = which + '0';
#ifdef _arch_dreamcast
DC_LoadFromVMU(name);
#endif
@@ -1549,7 +1549,7 @@ CP_LoadGame (int quick)
if (which >= 0 && SaveGamesAvail[which])
{
ShootSnd ();
- name[7] = which + '0';
+ name[strlen(configdir) + 7] = which + '0';
#ifdef _arch_dreamcast
DC_LoadFromVMU(name);
@@ -1676,11 +1676,11 @@ CP_SaveGame (int quick)
{
int which, exit = 0;
FILE *file;
- char name[13];
- char input[32];
+ char name[256];
+ char input[256];
- strcpy (name, SaveName);
+ snprintf (name, sizeof(name) - 1, "%s%s", configdir, SaveName);
//
// QUICKSAVE?
@@ -1691,7 +1691,7 @@ CP_SaveGame (int quick)
if (SaveGamesAvail[which])
{
- name[7] = which + '0';
+ name[strlen(configdir) + 7] = which + '0';
unlink (name);
file = fopen (name, "wb");
@@ -1728,6 +1728,7 @@ CP_SaveGame (int quick)
// OVERWRITE EXISTING SAVEGAME?
//
if (SaveGamesAvail[which])
+ {
#ifdef JAPAN
if (!GetYorN (7, 8, C_JAPSAVEOVERPIC))
#else
@@ -1743,11 +1744,12 @@ CP_SaveGame (int quick)
PrintLSEntry (which, HIGHLIGHT);
VW_UpdateScreen ();
}
+ }
ShootSnd ();
strcpy (input, &SaveGameNames[which][0]);
- name[7] = which + '0';
+ name[strlen(configdir) + 7] = which + '0';
fontnumber = 0;
if (!SaveGamesAvail[which])
@@ -2113,7 +2115,7 @@ CustomControls (int)
void
DefineMouseBtns (void)
{
- CustomCtrls mouseallowed = { 0, 1, 1, 1 };
+ CustomCtrls mouseallowed = {{ 0, 1, 1, 1 }};
EnterCtrlData (2, &mouseallowed, DrawCustMouse, PrintCustMouse, MOUSE);
}
@@ -2125,7 +2127,7 @@ DefineMouseBtns (void)
void
DefineJoyBtns (void)
{
- CustomCtrls joyallowed = { 1, 1, 1, 1 };
+ CustomCtrls joyallowed = {{ 1, 1, 1, 1 }};
EnterCtrlData (5, &joyallowed, DrawCustJoy, PrintCustJoy, JOYSTICK);
}
@@ -2137,7 +2139,7 @@ DefineJoyBtns (void)
void
DefineKeyBtns (void)
{
- CustomCtrls keyallowed = { 1, 1, 1, 1 };
+ CustomCtrls keyallowed = {{ 1, 1, 1, 1 }};
EnterCtrlData (8, &keyallowed, DrawCustKeybd, PrintCustKeybd, KEYBOARDBTNS);
}
@@ -2149,7 +2151,7 @@ DefineKeyBtns (void)
void
DefineKeyMove (void)
{
- CustomCtrls keyallowed = { 1, 1, 1, 1 };
+ CustomCtrls keyallowed = {{ 1, 1, 1, 1 }};
EnterCtrlData (10, &keyallowed, DrawCustKeys, PrintCustKeys, KEYBOARDMOVE);
}
@@ -2166,7 +2168,7 @@ void
EnterCtrlData (int index, CustomCtrls * cust, void (*DrawRtn) (int), void (*PrintRtn) (int),
int type)
{
- int j, exit, tick, redraw, which, x, picked, lastFlashTime;
+ int j, exit, tick, redraw, which = 0, x = 0, picked, lastFlashTime;
ControlInfo ci;
@@ -2217,7 +2219,7 @@ EnterCtrlData (int index, CustomCtrls * cust, void (*DrawRtn) (int), void (*Prin
//
// CHANGE BUTTON VALUE?
//
- if ((type != KEYBOARDBTNS && type != KEYBOARDMOVE) && (ci.button0 | ci.button1 | ci.button2 | ci.button3) ||
+ if (((type != KEYBOARDBTNS && type != KEYBOARDMOVE) && (ci.button0 | ci.button1 | ci.button2 | ci.button3)) ||
((type == KEYBOARDBTNS || type == KEYBOARDMOVE) && LastScan == sc_Enter))
{
lastFlashTime = GetTimeCount();
@@ -2338,7 +2340,7 @@ EnterCtrlData (int index, CustomCtrls * cust, void (*DrawRtn) (int), void (*Prin
//
// EXIT INPUT?
//
- if (IN_KeyDown (sc_Escape) || type != JOYSTICK && ci.button1)
+ if (IN_KeyDown (sc_Escape) || (type != JOYSTICK && ci.button1))
{
picked = 1;
SD_PlaySound (ESCPRESSEDSND);
@@ -2918,7 +2920,7 @@ CP_Quit (int)
#ifdef SPANISH
if (Confirm (ENDGAMESTR))
#else
- if (Confirm (endStrings[US_RndT () & 0x7 + (US_RndT () & 1)]))
+ if (Confirm (endStrings[US_RndT () & (0x7 + (US_RndT () & 1))]))
#endif
#endif
@@ -3142,7 +3144,7 @@ SetupControlPanel (void)
////////////////////////////////////////////////////////////////////
void SetupSaveGames()
{
- char name[13];
+ char name[256];
#ifdef _arch_dreamcast
file_t dir;
@@ -3152,12 +3154,12 @@ void SetupSaveGames()
dir = fs_open("/vmu/a1", O_RDONLY | O_DIR);
x = 0;
- strcpy(name, SaveName);
+ snprintf(name, sizeof(name) - 1, "%s%s", configdir, SaveName);
while((dirent = fs_readdir(dir)) && x < 10)
{
for(int i=0; i<10; i++)
{
- name[7] = '0' + i;
+ name[strlen(configdir) + 7] = '0' + i;
if(!strcmp(name, dirent->name))
{
if(DC_LoadFromVMU(name) != -1)
@@ -3181,10 +3183,10 @@ void SetupSaveGames()
fs_close(dir);
#else
- strcpy(name, SaveName);
+ snprintf(name, sizeof(name) - 1, "%s%s", configdir, SaveName);
for(int i=0; i<10; i++)
{
- name[7] = '0' + i;
+ name[strlen(configdir) + 7] = '0' + i;
const int handle = open(name, O_RDONLY | O_BINARY);
if (handle >= 0)
{
@@ -3404,7 +3406,7 @@ HandleMenu (CP_iteminfo * item_i, CP_itemtype * items, void (*routine) (int w))
if (ci.button0 || Keyboard[sc_Space] || Keyboard[sc_Enter])
exit = 1;
- if (ci.button1 && !Keyboard[sc_Alt] || Keyboard[sc_Escape])
+ if ((ci.button1 && !Keyboard[sc_Alt]) || Keyboard[sc_Escape])
exit = 2;
}
@@ -3851,7 +3853,7 @@ Message (const char *string)
h += font->height;
}
else
- w += font->width[string[i]];
+ w += font->width[(int8_t)string[i]];
}
if (w + 10 > mw)
@@ -3998,16 +4000,16 @@ CheckForEpisodes (void)
//
#ifdef JAPAN
#ifdef JAPDEMO
- if(!stat("vswap.wj1", &statbuf))
+ if(!stat(DATADIR "vswap.wj1", &statbuf))
{
strcpy (extension, "wj1");
numEpisodesMissing = 5;
#else
- if(!stat("vswap.wj6", &statbuf))
+ if(!stat(DATADIR "vswap.wj6", &statbuf))
{
strcpy (extension, "wj6");
#endif
- strcat (configname, extension);
+ snprintf(configname, sizeof(configname) - 1, "%sconfig.%s", configdir, extension);
strcat (SaveName, extension);
strcat (demoname, extension);
EpisodeSelect[1] =
@@ -4021,7 +4023,7 @@ CheckForEpisodes (void)
// ENGLISH
//
#ifdef UPLOAD
- if(!stat("vswap.wl1", &statbuf))
+ if(!stat(DATADIR "vswap.wl1", &statbuf))
{
strcpy (extension, "wl1");
numEpisodesMissing = 5;
@@ -4030,7 +4032,7 @@ CheckForEpisodes (void)
Quit ("NO WOLFENSTEIN 3-D DATA FILES to be found!");
#else
#ifndef SPEAR
- if(!stat("vswap.wl6", &statbuf))
+ if(!stat(DATADIR "vswap.wl6", &statbuf))
{
strcpy (extension, "wl6");
NewEmenu[2].active =
@@ -4043,7 +4045,7 @@ CheckForEpisodes (void)
}
else
{
- if(!stat("vswap.wl3", &statbuf))
+ if(!stat(DATADIR "vswap.wl3", &statbuf))
{
strcpy (extension, "wl3");
numEpisodesMissing = 3;
@@ -4051,7 +4053,7 @@ CheckForEpisodes (void)
}
else
{
- if(!stat("vswap.wl1", &statbuf))
+ if(!stat(DATADIR "vswap.wl1", &statbuf))
{
strcpy (extension, "wl1");
numEpisodesMissing = 5;
@@ -4068,21 +4070,21 @@ CheckForEpisodes (void)
#ifndef SPEARDEMO
if(param_mission == 1)
{
- if(!stat("vswap.sod", &statbuf))
+ if(!stat(DATADIR "vswap.sod", &statbuf))
strcpy (extension, "sod");
else
Quit ("NO SPEAR OF DESTINY DATA FILES TO BE FOUND!");
}
else if(param_mission == 2)
{
- if(!stat("vswap.sd2", &statbuf))
+ if(!stat(DATADIR "vswap.sd2", &statbuf))
strcpy (extension, "sd2");
else
Quit ("NO SPEAR OF DESTINY DATA FILES TO BE FOUND!");
}
else if(param_mission == 3)
{
- if(!stat("vswap.sd3", &statbuf))
+ if(!stat(DATADIR "vswap.sd3", &statbuf))
strcpy (extension, "sd3");
else
Quit ("NO SPEAR OF DESTINY DATA FILES TO BE FOUND!");
@@ -4092,7 +4094,7 @@ CheckForEpisodes (void)
strcpy (graphext, "sod");
strcpy (audioext, "sod");
#else
- if(!stat("vswap.sdm", &statbuf))
+ if(!stat(DATADIR "vswap.sdm", &statbuf))
{
strcpy (extension, "sdm");
}
@@ -4106,7 +4108,7 @@ CheckForEpisodes (void)
strcpy (audioext, extension);
#endif
- strcat (configname, extension);
+ snprintf (configname, sizeof(configname) - 1, "%sconfig.%s", configdir, extension);
strcat (SaveName, extension);
strcat (demoname, extension);
diff --git a/wl_play.cpp b/wl_play.cpp
index e74d849..7f56b04 100644
--- a/wl_play.cpp
+++ b/wl_play.cpp
@@ -1,7 +1,6 @@
// WL_PLAY.C
#include "wl_def.h"
-#pragma hdrstop
#include "wl_cloudsky.h"
#include "wl_shade.h"
@@ -688,8 +687,6 @@ void CheckKeys (void)
#endif
scan == sc_F9 || scan == sc_F7 || scan == sc_F8) // pop up quit dialog
{
- short oldmapon = gamestate.mapon;
- short oldepisode = gamestate.episode;
ClearMemory ();
ClearSplitVWB ();
US_ControlPanel (scan);
diff --git a/wl_state.cpp b/wl_state.cpp
index 1f46a4a..68610c3 100644
--- a/wl_state.cpp
+++ b/wl_state.cpp
@@ -1,7 +1,6 @@
// WL_STATE.C
#include "wl_def.h"
-#pragma hdrstop
/*
=============================================================================
diff --git a/wl_text.cpp b/wl_text.cpp
index a3e2583..fcd36d7 100644
--- a/wl_text.cpp
+++ b/wl_text.cpp
@@ -1,7 +1,6 @@
// WL_TEXT.C
#include "wl_def.h"
-#pragma hdrstop
/*
=============================================================================
--
SDL-Port of Wolfenstein 3-D and Spear of Destiny
More information about the Pkg-games-commits
mailing list