summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSteven Fuller <relnev@icculus.org>2001-12-09 20:21:44 +0000
committerPatryk Obara <dreamer.tan@gmail.com>2019-08-20 02:22:37 +0200
commita2d3afb314a3b27a55f68e05f0d2c7d5dff015be (patch)
tree2597aeb6b453a212526326ba2af6dec073371642 /src
parentc69d42233364999afe5257e3ea536d6b3cd035c6 (diff)
Better error checking in winapi.c. (Tim Beckmann)
Keep track of profile timestamps. (Tim Beckmann) Implemented a few other missing bits.
Diffstat (limited to 'src')
-rw-r--r--src/avp/win95/frontend/avp_menus.c105
-rw-r--r--src/avp/win95/frontend/avp_menus.h3
-rw-r--r--src/avp/win95/frontend/avp_userprofile.cpp193
-rw-r--r--src/avp/win95/progress_bar.cpp4
-rw-r--r--src/fixer.h39
-rw-r--r--src/main.c15
-rw-r--r--src/openal.c8
-rw-r--r--src/version.c4
-rw-r--r--src/version.h7
-rw-r--r--src/winapi.c80
10 files changed, 127 insertions, 331 deletions
diff --git a/src/avp/win95/frontend/avp_menus.c b/src/avp/win95/frontend/avp_menus.c
index 047a09c..b7f3087 100644
--- a/src/avp/win95/frontend/avp_menus.c
+++ b/src/avp/win95/frontend/avp_menus.c
@@ -24,12 +24,11 @@
#include "psnd.h"
#include "savegame.h"
-#if 0
-#undef BRIGHTNESS_CHANGE_SPEED
-#define BRIGHTNESS_CHANGE_SPEED (RealFrameTime/4)
-#endif
-
-
+/* used to get file time */
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+
extern void StartMenuBackgroundBink(void);
extern int PlayMenuBackgroundBink(void);
extern void EndMenuBackgroundBink(void);
@@ -346,12 +345,10 @@ extern int AvP_MainMenus(void)
EndMenuBackgroundBink();
TimeStampedMessage("after EndMenuMusic");
- #if 0
#if PREDATOR_DEMO||MARINE_DEMO||ALIEN_DEMO
- if (/*!AvP.LevelCompleted &&*/ (AvPMenus.MenusState != MENUSSTATE_STARTGAME)) ShowSplashScreens();
+ if ((AvPMenus.MenusState != MENUSSTATE_STARTGAME)) ShowSplashScreens();
TimeStampedMessage("after ShowSplashScreens");
#endif
- #endif
ReleaseAllAvPMenuGfx();
TimeStampedMessage("after ReleaseAllAvPMenuGfx");
@@ -665,25 +662,7 @@ extern void AvP_UpdateMenus(void)
profilePtr = GetNextUserProfile();
RenderMenuText(profilePtr->Name,MENU_CENTREX,MENU_CENTREY-100,ONE_FIXED,AVPMENUFORMAT_CENTREJUSTIFIED);
- {
-#warning commented out code
-#if 0
- char buffer[100];
- char buffer2[100];
- int nLen = 80;
-
- time_t time_of_day;
-
- time_of_day = time( NULL );
-
- nLen = GetDateFormat(GetThreadLocale(), DATE_LONGDATE, &profilePtr->TimeLastUpdated,NULL,buffer,nLen);
- nLen = GetTimeFormat(GetThreadLocale(), 0, &profilePtr->TimeLastUpdated,NULL,buffer2,100);
-
- strcat(buffer2," ");
- strcat(buffer2,buffer);
- RenderSmallMenuText(buffer2,MENU_CENTREX,MENU_CENTREY-70,ONE_FIXED,AVPMENUFORMAT_CENTREJUSTIFIED);
-#endif
- }
+ RenderSmallMenuText(ctime(&profilePtr->FileTime),MENU_CENTREX,MENU_CENTREY-70,ONE_FIXED,AVPMENUFORMAT_CENTREJUSTIFIED);
RenderMenu();
RenderHelpString();
@@ -1732,10 +1711,7 @@ static void RenderUserProfileSelectMenu(void)
char *textPtr = GetTextString(AvPMenusData[AvPMenus.CurrentMenu].MenuTitle);
RenderMenuText(textPtr,MENU_CENTREX,70,ONE_FIXED,AVPMENUFORMAT_CENTREJUSTIFIED);
}
-#warning commented out code
-#if 0
- GetLocalTime(&profilePtr->TimeLastUpdated);
-#endif
+
for (i=0; i<=elementPtr->b.MaxSliderValue; i++, profilePtr = GetNextUserProfile())
{
int y;
@@ -1775,37 +1751,8 @@ static void RenderUserProfileSelectMenu(void)
}
b=Brightness[i];
RenderMenuText_Clipped(textPtr,MENU_CENTREX,MENU_CENTREY+y-60,b,AVPMENUFORMAT_CENTREJUSTIFIED,MENU_CENTREY-60-100,MENU_CENTREY-30+150);
- {
-#warning commented out code
-#if 0
- char buffer[100];
- char buffer2[100];
- int nLen = 80;
- /*sprintf(buffer,"%d:%d:%d %d/%d/%d",
- profilePtr->TimeLastUpdated.wHour,
- profilePtr->TimeLastUpdated.wMinute,
- profilePtr->TimeLastUpdated.wSecond,
- profilePtr->TimeLastUpdated.wYear,
- profilePtr->TimeLastUpdated.wMonth,
- profilePtr->TimeLastUpdated.wDay);
- */
- time_t time_of_day;
-
- time_of_day = time( NULL );
-// strftime( buffer, 80, "%c",
-// localtime( &time_of_day ) );
-
- nLen = GetDateFormat(GetThreadLocale(), DATE_LONGDATE, &profilePtr->TimeLastUpdated,
- NULL,buffer,
- nLen);
- nLen = GetTimeFormat(GetThreadLocale(), 0, &profilePtr->TimeLastUpdated,
- NULL,buffer2,
- 100);
- strcat(buffer2," ");
- strcat(buffer2,buffer);
- RenderSmallMenuText(buffer2,MENU_CENTREX,MENU_CENTREY+y-30,b,AVPMENUFORMAT_CENTREJUSTIFIED);
-#endif
- }
+ if (i > 0)
+ RenderSmallMenuText(ctime(&profilePtr->FileTime),MENU_CENTREX,MENU_CENTREY+y-30,b,AVPMENUFORMAT_CENTREJUSTIFIED);
}
}
@@ -1935,22 +1882,7 @@ static void RenderLoadGameMenu(void)
sprintf(buffer, "%s: %d",GetTextString(TEXTSTRING_SAVEGAME_SAVESLEFT),slotPtr->SavesLeft);
RenderText(buffer,MENU_CENTREX,y+HUD_FONT_HEIGHT+1,elementPtr->Brightness,AVPMENUFORMAT_CENTREJUSTIFIED);
- {
-#warning commented out code
-#if 0
- char buffer2[100];
- int nLen = 80;
-
- //GetLocalTime(&slotPtr->TimeStamp);
-
- nLen = GetDateFormat(GetThreadLocale(), DATE_SHORTDATE, &slotPtr->TimeStamp,NULL,buffer,nLen);
- nLen = GetTimeFormat(GetThreadLocale(), 0, &slotPtr->TimeStamp,NULL,buffer2,100);
-
- strcat(buffer2," ");
- strcat(buffer2,buffer);
- RenderText(buffer2,MENU_RIGHTXEDGE-30,y+HUD_FONT_HEIGHT+1,elementPtr->Brightness,AVPMENUFORMAT_RIGHTJUSTIFIED);
-#endif
- }
+ RenderText(ctime(&slotPtr->TimeStamp),MENU_RIGHTXEDGE-30,y+HUD_FONT_HEIGHT+1,elementPtr->Brightness,AVPMENUFORMAT_RIGHTJUSTIFIED);
}
else
{
@@ -5581,7 +5513,6 @@ void LoadLevelHeader(SAVE_BLOCK_HEADER* header)
}
-
static void GetHeaderInfoForSaveSlot(SAVE_SLOT_HEADER* save_slot,const char* filename)
{
LEVEL_SAVE_BLOCK block;
@@ -5610,17 +5541,13 @@ static void GetHeaderInfoForSaveSlot(SAVE_SLOT_HEADER* save_slot,const char* fil
}
-#warning commented out code
-#if 0
- //get the time stamp for the file
- {
- FILETIME time,localTime;
- GetFileTime(file,0,0,&time);
- FileTimeToLocalFileTime(&time,&localTime);
- FileTimeToSystemTime(&localTime,&save_slot->TimeStamp);
+{
+ struct stat buf;
+ if (stat(filename, &buf) != -1) {
+ save_slot->TimeStamp = buf.st_mtime;
}
-#endif
+}
//load the level header
ReadFile(file,&block,sizeof(block),(LPDWORD)&bytes_read,0);
diff --git a/src/avp/win95/frontend/avp_menus.h b/src/avp/win95/frontend/avp_menus.h
index 800747b..41d8966 100644
--- a/src/avp/win95/frontend/avp_menus.h
+++ b/src/avp/win95/frontend/avp_menus.h
@@ -337,8 +337,7 @@ typedef struct
unsigned char ElapsedTime_Seconds;
unsigned char Difficulty;
- SYSTEMTIME TimeStamp;
-
+ FILETIME TimeStamp;
} SAVE_SLOT_HEADER;
#define NUMBER_OF_SAVE_SLOTS 8
diff --git a/src/avp/win95/frontend/avp_userprofile.cpp b/src/avp/win95/frontend/avp_userprofile.cpp
index a40ac85..80434da 100644
--- a/src/avp/win95/frontend/avp_userprofile.cpp
+++ b/src/avp/win95/frontend/avp_userprofile.cpp
@@ -28,7 +28,6 @@ extern "C"
static int LoadUserProfiles(void);
static void EmptyUserProfilesList(void);
-static int MakeNewUserProfile(void);
static void InsertProfileIntoList(AVP_USER_PROFILE *profilePtr);
static int ProfileIsMoreRecent(AVP_USER_PROFILE *profilePtr, AVP_USER_PROFILE *profileToTestAgainstPtr);
static void SetDefaultProfileOptions(AVP_USER_PROFILE *profilePtr);
@@ -53,32 +52,20 @@ extern void ExamineSavedUserProfiles(void)
// delete any existing profiles
EmptyUserProfilesList();
-// UserProfilesList.add_entry(profilePtr);
-// SaveUserProfile(profilePtr);
- if (LoadUserProfiles())
- {
+ // load any available user profiles
+ LoadUserProfiles();
- }
- else /* No user profile found. We'll have to make one */
- {
- // MakeNewUserProfile();
- }
-
+ // make a fake entry to allow creating new user profiles
AVP_USER_PROFILE *profilePtr = new AVP_USER_PROFILE;
*profilePtr = DefaultUserProfile;
- fprintf(stderr, "STUB: ExamineSavedUserProfiles()\n");
-#if 0
- GetLocalTime(&profilePtr->TimeLastUpdated);
- SystemTimeToFileTime(&profilePtr->TimeLastUpdated,&profilePtr->FileTime);
-#endif
+ profilePtr->FileTime = time(NULL);
strncpy(profilePtr->Name,GetTextString(TEXTSTRING_USERPROFILE_NEW),MAX_SIZE_OF_USERS_NAME);
profilePtr->Name[MAX_SIZE_OF_USERS_NAME]=0;
SetDefaultProfileOptions(profilePtr);
InsertProfileIntoList(profilePtr);
-
}
extern int NumberOfUserProfiles(void)
@@ -135,7 +122,6 @@ extern int SaveUserProfile(AVP_USER_PROFILE *profilePtr)
fclose(file);
return 1;
-
}
extern void DeleteUserProfile(int number)
@@ -163,11 +149,8 @@ extern void DeleteUserProfile(int number)
}
delete [] filename;
}
-
}
-
-
static void InsertProfileIntoList(AVP_USER_PROFILE *profilePtr)
{
if (UserProfilesList.size())
@@ -188,18 +171,11 @@ static void InsertProfileIntoList(AVP_USER_PROFILE *profilePtr)
static int ProfileIsMoreRecent(AVP_USER_PROFILE *profilePtr, AVP_USER_PROFILE *profileToTestAgainstPtr)
{
- fprintf(stderr, "STUB: ProfileIsMoreRecent(%p, %p)\n", profilePtr, profileToTestAgainstPtr);
- return 1;
-#if 0
- if (CompareFileTime(&profilePtr->FileTime,&profileToTestAgainstPtr->FileTime)==1)
- {
- return 1;
- }
- else
- {
+ if (difftime(profilePtr->FileTime, profileToTestAgainstPtr->FileTime) > 0.0) {
+ return 1; /* first file newer than file to test */
+ } else {
return 0;
}
-#endif
}
static int LoadUserProfiles(void)
@@ -227,7 +203,7 @@ static int LoadUserProfiles(void)
if (nLen > nPathLen) nPathLen = nLen;
}
- for (int i = 0; i < globbuf.gl_pathc; i++) {
+ for (unsigned int i = 0; i < globbuf.gl_pathc; i++) {
struct stat buf;
if (stat(globbuf.gl_pathv[i], &buf) == -1)
@@ -239,14 +215,11 @@ static int LoadUserProfiles(void)
// strncpy(pszFullPath,load_name,nPathLen);
strcpy(pszFullPath /* +nPathLen */, globbuf.gl_pathv[i]);
-
- //make sure the file is a rif file
HANDLE rif_file;
rif_file = CreateFile (pszFullPath, GENERIC_READ, 0, 0, OPEN_EXISTING,
FILE_FLAG_RANDOM_ACCESS, 0);
if(rif_file==INVALID_HANDLE_VALUE)
{
-// printf("couldn't open %s\n",pszFullPath);
delete[] pszFullPath;
continue;
}
@@ -256,121 +229,25 @@ static int LoadUserProfiles(void)
if (!ReadFile(rif_file, profilePtr, sizeof(AVP_USER_PROFILE), &bytes_read, 0))
{
- CloseHandle (rif_file);
+ CloseHandle (rif_file);
delete[] pszFullPath;
delete profilePtr;
continue;
}
-#if 0
- FILETIME ftLocal;
- FileTimeToLocalFileTime(&wfd.ftLastWriteTime,&ftLocal);
- FileTimeToSystemTime(&ftLocal,&profilePtr->TimeLastUpdated);
- profilePtr->FileTime = ftLocal;
-#endif
- InsertProfileIntoList(profilePtr);
- CloseHandle (rif_file);
- delete[] pszFullPath;
- }
-
- }
-
- globfree(&globbuf);
-
-#if 0
- const char* load_name=USER_PROFILES_WILDCARD_NAME;
- // allow a wildcard search
- WIN32_FIND_DATA wfd;
-
- HANDLE hFindFile = ::FindFirstFile(load_name,&wfd);
-
- if (INVALID_HANDLE_VALUE == hFindFile)
- {
-// printf("File Not Found: <%s>\n",load_name);
- return 0;
- }
-
- // get any path in the load_name
- int nPathLen = 0;
- char * pColon = strrchr(load_name,':');
- if (pColon) nPathLen = pColon - load_name + 1;
- char * pBackSlash = strrchr(load_name,'\\');
- if (pBackSlash)
- {
- int nLen = pBackSlash - load_name + 1;
- if (nLen > nPathLen) nPathLen = nLen;
- }
- char * pSlash = strrchr(load_name,'/');
- if (pSlash)
- {
- int nLen = pSlash - load_name + 1;
- if (nLen > nPathLen) nPathLen = nLen;
- }
-
- do
- {
- if
- (
- !(wfd.dwFileAttributes &
- (FILE_ATTRIBUTE_DIRECTORY
- |FILE_ATTRIBUTE_SYSTEM
- |FILE_ATTRIBUTE_HIDDEN
- |FILE_ATTRIBUTE_READONLY))
- // not a directory, hidden or system file
- )
- {
- char * pszFullPath = new char [nPathLen+strlen(wfd.cFileName)+1];
- strncpy(pszFullPath,load_name,nPathLen);
- strcpy(pszFullPath+nPathLen,wfd.cFileName);
-
-
- //make sure the file is a rif file
- HANDLE rif_file;
- rif_file = CreateFile (pszFullPath, GENERIC_READ, 0, 0, OPEN_EXISTING,
- FILE_FLAG_RANDOM_ACCESS, 0);
- if(rif_file==INVALID_HANDLE_VALUE)
- {
-// printf("couldn't open %s\n",pszFullPath);
- delete[] pszFullPath;
- continue;
- }
-
- AVP_USER_PROFILE *profilePtr = new AVP_USER_PROFILE;
- unsigned long bytes_read;
+ profilePtr->FileTime = buf.st_mtime;
- if (!ReadFile(rif_file, profilePtr, sizeof(AVP_USER_PROFILE), &bytes_read, 0))
- {
- CloseHandle (rif_file);
- delete[] pszFullPath;
- delete profilePtr;
- continue;
- }
- FILETIME ftLocal;
- FileTimeToLocalFileTime(&wfd.ftLastWriteTime,&ftLocal);
- FileTimeToSystemTime(&ftLocal,&profilePtr->TimeLastUpdated);
- profilePtr->FileTime = ftLocal;
InsertProfileIntoList(profilePtr);
CloseHandle (rif_file);
delete[] pszFullPath;
-
}
-
- }
- while (::FindNextFile(hFindFile,&wfd));
-
-
- if (ERROR_NO_MORE_FILES != GetLastError())
- {
- // printf("Error finding next file\n");
}
+
+ globfree(&globbuf);
- ::FindClose(hFindFile);
-#endif
return 1;
}
-
-
static void SetDefaultProfileOptions(AVP_USER_PROFILE *profilePtr)
{
// set Gamma
@@ -393,46 +270,7 @@ static void SetDefaultProfileOptions(AVP_USER_PROFILE *profilePtr)
IntroOutroMoviesAreActive = 1;
AutoWeaponChangeOn = TRUE;
-
- // Edmond to add in network name
- srand(time(NULL));
- switch(rand()%11)
- {
- case 0:
- strcpy(MP_PlayerName, "DogMeat");
- break;
- case 1:
- strcpy(MP_PlayerName, "FreshMeat");
- break;
- case 2:
- strcpy(MP_PlayerName, "RancidMeat");
- break;
- case 3:
- strcpy(MP_PlayerName, "HorseMeat");
- break;
- case 4:
- strcpy(MP_PlayerName, "RawMeat");
- break;
- case 5:
- strcpy(MP_PlayerName, "LiveMeat");
- break;
- case 6:
- strcpy(MP_PlayerName, "M-m-m-meat");
- break;
- case 7:
- strcpy(MP_PlayerName, "LlamaMeat");
- break;
- case 8:
- strcpy(MP_PlayerName, "JustMeat");
- break;
- case 9:
- strcpy(MP_PlayerName, "TastyMeat");
- break;
- case 10:
- strcpy(MP_PlayerName, "MonkeyMeat");
- break;
- }
- strcpy(MP_PlayerName,"DeadMeat");
+ strcpy(MP_PlayerName, "DeadMeat");
SetToDefaultDetailLevels();
@@ -448,10 +286,6 @@ static void SetDefaultProfileOptions(AVP_USER_PROFILE *profilePtr)
SaveSettingsToUserProfile(profilePtr);
}
-
-
-
-
extern void GetSettingsFromUserProfile(void)
{
@@ -477,7 +311,6 @@ extern void GetSettingsFromUserProfile(void)
SetDetailLevelsFromMenu();
}
-
extern void SaveSettingsToUserProfile(AVP_USER_PROFILE *profilePtr)
{
profilePtr->GammaSetting = RequestedGammaSetting;
diff --git a/src/avp/win95/progress_bar.cpp b/src/avp/win95/progress_bar.cpp
index 4396b21..ffa1ddc 100644
--- a/src/avp/win95/progress_bar.cpp
+++ b/src/avp/win95/progress_bar.cpp
@@ -173,9 +173,9 @@ void Start_Progress_Bar()
FlushD3DZBuffer();
ThisFramesRenderingHasBegun();
-#if !ALIEN_DEMO /* TODO: disabled for alien demo */
+
RenderBriefingText(ScreenDescriptorBlock.SDB_Height/2, ONE_FIXED);
-#endif
+
ThisFramesRenderingHasFinished();
/* FlipBuffers(); */
diff --git a/src/fixer.h b/src/fixer.h
index 522caaa..2881e83 100644
--- a/src/fixer.h
+++ b/src/fixer.h
@@ -9,10 +9,13 @@ extern "C" {
#include <stdlib.h>
#include <string.h>
#include <limits.h>
-#include <inttypes.h> // int64_t
+#include <inttypes.h> /* int64_t */
+
+void FixFilename(char *str);
#define PACKED __attribute__((packed))
+/* windows junk */
#ifndef min
#define min(a, b) (((a) < (b)) ? (a) : (b))
#endif
@@ -38,16 +41,12 @@ extern "C" {
#define _tcslen strlen
#define _tcscpy strcpy
-/* #define _mbclen strlen */
size_t _mbclen(const unsigned char *s);
#define RGBA_MAKE(r, g, b, a) ((((a) << 24) | ((r) << 16) | ((g) << 8) | (b)))
#define MAX_PATH PATH_MAX
-void FixFilename(char *str);
-
-/* windows junk */
typedef int GUID;
typedef int DPID;
typedef int HINSTANCE;
@@ -78,17 +77,19 @@ typedef RECT RECT_AVP;
typedef int64_t __int64;
-typedef int FILETIME;
+typedef time_t FILETIME;
-typedef struct SYSTEMTIME
+/* this SYSTEMTIME is incorrect, but it is also currently unused */
+typedef struct SYSTEMTIME
{
-//#warning "TODO: SYSTEMTIME format is not correct"
+ int wYear; /* should be uint16_t, not int32_t */
+ int wMonth;
+ int wDay;
+ /* int wDayOfWeek; */
int wHour;
int wMinute;
int wSecond;
- int wYear;
- int wMonth;
- int wDay;
+ /* int wMilliseconds; */
} SYSTEMTIME;
#define VK_BACK 1
@@ -108,14 +109,14 @@ typedef struct SYSTEMTIME
#define FILE_FLAG_RANDOM_ACCESS 0x0004
#define GENERIC_READ 0x0008
#define OPEN_EXISTING 0x0010
-#define FILE_ATTRIBUTE_READONLY 0x0020
-#define FILE_CURRENT 0x0040
-#define FILE_BEGIN 0x0080
-#define FILE_END 0x0100
-#define FILE_SHARE_READ 0x0200
-#define FILE_ATTRIBUTE_DIRECTORY 0x0400
-#define FILE_SHARE_WRITE 0x0800
-#define OPEN_ALWAYS 0x1000
+#define FILE_CURRENT 0x0020
+#define FILE_BEGIN 0x0040
+#define FILE_END 0x0080
+#define FILE_SHARE_READ 0x0100
+#define FILE_SHARE_WRITE 0x0200
+#define OPEN_ALWAYS 0x0400
+#define FILE_ATTRIBUTE_READONLY 0x0800
+#define FILE_ATTRIBUTE_DIRECTORY 0x1000
#define FILE_ATTRIBUTE_NORMAL 0x2000
diff --git a/src/main.c b/src/main.c
index 4e0572f..f366a2f 100644
--- a/src/main.c
+++ b/src/main.c
@@ -24,6 +24,7 @@
#include "pldnet.h"
#include "cdtrackselection.h"
#include "gammacontrol.h"
+#include "version.h"
char LevelName[] = {"predbit6\0QuiteALongNameActually"}; /* the real way to load levels */
@@ -963,6 +964,9 @@ int ExitWindowsSystem()
int main(int argc, char *argv[])
{
+/*
+ printf("%s", AvPVersionString);
+*/
if (InitSDL() == -1) {
fprintf(stderr, "Could not find a sutable resolution!\n");
fprintf(stderr, "At least 512x384 is needed. Does OpenGL work?\n");
@@ -1048,9 +1052,9 @@ int main(int argc, char *argv[])
#endif
#if !(ALIEN_DEMO|PREDATOR_DEMO|MARINE_DEMO)
-while(AvP_MainMenus())
+while (AvP_MainMenus())
#else
- SetBriefingTextToBlank();
+if (AvP_MainMenus())
#endif
{
int menusActive = 0;
@@ -1209,8 +1213,11 @@ while(AvP_MainMenus())
}
ClearMemoryPool();
-
- SetSoftVideoMode(640, 480, 16);
+
+/* go back to menu mode */
+#if !(ALIEN_DEMO|PREDATOR_DEMO|MARINE_DEMO)
+ SetSoftVideoMode(640, 480, 16);
+#endif
}
SoundSys_StopAll();
diff --git a/src/openal.c b/src/openal.c
index 5dfd931..e39ba66 100644
--- a/src/openal.c
+++ b/src/openal.c
@@ -449,7 +449,7 @@ void PlatStopSound(int activeIndex)
/* printf("PlatStopSound(%d)\n", activeIndex); */
if (!SoundActivated)
- return 0;
+ return;
// if (ActiveSounds[activeIndex].paused)
// alSourcePause (ActiveSounds[activeIndex].ds3DBufferP);
@@ -656,7 +656,7 @@ void PlatUpdatePlayer()
ALfloat vel[3], or[6], pos[3];
if (!SoundActivated)
- return 0;
+ return;
if (Global_VDB_Ptr) {
extern int NormalFrameTime;
@@ -710,7 +710,7 @@ void PlatEndGameSound(SOUNDINDEX index)
int i;
if (!SoundActivated)
- return 0;
+ return;
if((index<0)||(index>=SID_MAXIMUM)) return; /* no such sound */
@@ -780,7 +780,7 @@ void UpdateSoundFrequencies()
/* printf("FREQ UpdateSoundFreqncies()\n"); */
if (!SoundActivated)
- return 0;
+ return;
if (!SoundSwitchedOn) /* TODO: maybe I should have used this var.. */
return;
diff --git a/src/version.c b/src/version.c
index 2d2681b..5aa6924 100644
--- a/src/version.c
+++ b/src/version.c
@@ -2,7 +2,9 @@
extern void NewOnScreenMessage(unsigned char *messagePtr);
+const char *AvPVersionString = "Aliens vs Predator - Linux \n Build 000 \n Based on Rebellion Developments AvP Gold source \n";
+
void GiveVersionDetails(void)
{
- NewOnScreenMessage("Aliens vs Predator - Linux\n Build 000 \n Based on Rebellion Developments AvP Gold source \n");
+ NewOnScreenMessage(AvPVersionString);
}
diff --git a/src/version.h b/src/version.h
index 8e1e1f5..b22b4ef 100644
--- a/src/version.h
+++ b/src/version.h
@@ -1,3 +1,10 @@
+#ifndef __VERSION_H__
+#define __VERSION_H__
+
+extern const char *AvPVersionString;
+
/* KJL 15:56:24 29/03/98 - this function supplies a text
description of the current build, and the build date. */
extern void GiveVersionDetails(void);
+
+#endif
diff --git a/src/winapi.c b/src/winapi.c
index c75d377..40449bf 100644
--- a/src/winapi.c
+++ b/src/winapi.c
@@ -46,7 +46,7 @@ HANDLE CreateFile(const char *file, int mode, int x, int y, int flags, int flags
}
fd = open(file, O_RDONLY);
if (fd == -1) {
- perror("CreateFile");
+ /* perror("CreateFile"); */
return INVALID_HANDLE_VALUE;
}
break;
@@ -75,37 +75,47 @@ HANDLE CreateFileA(const char *file, int write, int x, int y, int flags, int fla
return CreateFile(file, write, x, y, flags, flags2, z);
}
-int WriteFile(HANDLE file, const void *data, int len, /* unsigned long */ void *byteswritten, int x)
+int WriteFile(HANDLE file, const void *data, int len, void *byteswritten, int lpOverlapped)
{
- unsigned long *bw;
+ unsigned long *bw, i;
/*
- fprintf(stderr, "WriteFile(%d, %p, %d, %p, %d)\n", file, data, len, byteswritten, x);
+ fprintf(stderr, "WriteFile(%d, %p, %d, %p, %d)\n", file, data, len, byteswritten, lpOverlapped);
*/
bw = (unsigned long *)byteswritten;
+ *bw = 0;
- *bw = write(file, data, len);
-
- return 0;
+ i = write(file, data, len);
+ if (i == -1) {
+ return 0;
+ } else {
+ *bw = i;
+ return 1;
+ }
}
-int ReadFile(HANDLE file, void *data, int len, /* unsigned long */ void *bytesread, int x)
+int ReadFile(HANDLE file, void *data, int len, void *bytesread, int lpOverlapped)
{
- unsigned long *br;
+ unsigned long *br, i;
/*
- fprintf(stderr, "ReadFile(%d, %p, %d, %p, %d)\n", file, data, len, bytesread, x);
+ fprintf(stderr, "ReadFile(%d, %p, %d, %p, %d)\n", file, data, len, bytesread, lpOverlapped);
*/
br = (unsigned long *)bytesread;
+ *br = 0;
- *br = read(file, data, len);
-
- return 1; /* TODO: what is the correct return value? */
+ i = read(file, data, len);
+ if (i == -1) {
+ return 0;
+ } else {
+ *br = i;
+ return 1;
+ }
}
-int GetFileSize(HANDLE file, int x)
+int GetFileSize(HANDLE file, int lpFileSizeHigh)
{
struct stat buf;
/*
- fprintf(stderr, "GetFileSize(%d, %d)\n", file, x);
+ fprintf(stderr, "GetFileSize(%d, %d)\n", file, lpFileSizeHigh);
*/
if (fstat(file, &buf) == -1)
return -1;
@@ -117,16 +127,23 @@ int CloseHandle(HANDLE file)
/*
fprintf(stderr, "CloseHandle(%d)\n", file);
*/
- close(file);
+ if (close(file) == -1)
+ return 0;
+ else
+ return 1;
return 0;
}
int DeleteFile(const char *file)
{
+/*
fprintf(stderr, "DeleteFile(%s)\n", file);
-
- return -1;
+*/
+ if (unlink(file) == -1)
+ return 0;
+ else
+ return 1;
}
int DeleteFileA(const char *file)
@@ -138,21 +155,25 @@ int GetDiskFreeSpace(int x, unsigned long *a, unsigned long *b, unsigned long *c
{
fprintf(stderr, "GetDiskFreeSpace(%d, %p, %p, %p, %p)\n", x, a, b, c, d);
- return -1;
+ return 0;
}
-int CreateDirectory(char *dir, int x)
+int CreateDirectory(char *dir, int lpSecurityAttributes)
{
- fprintf(stderr, "CreateDirectory(%s, %d)\n", dir, x);
-
- return -1;
+/*
+ fprintf(stderr, "CreateDirectory(%s, %d)\n", dir, lpSecurityAttributes);
+*/
+ if (mkdir(dir, S_IRWXU) == -1)
+ return 0;
+ else
+ return 1;
}
int MoveFile(const char *newfile, const char *oldfile)
{
fprintf(stderr, "MoveFile(%s, %s)\n", newfile, oldfile);
- return -1;
+ return 0;
}
int MoveFileA(const char *newfile, const char *oldfile)
@@ -164,14 +185,14 @@ int CopyFile(const char *newfile, const char *oldfile, int x)
{
fprintf(stderr, "CopyFile(%s, %s, %d)\n", newfile, oldfile, x);
- return -1;
+ return 0;
}
int GetFileAttributes(const char *file)
{
fprintf(stderr, "GetFileAttributes(%s)\n", file);
- return -1;
+ return 0;
}
int GetFileAttributesA(const char *file)
@@ -183,21 +204,20 @@ int SetFilePointer(HANDLE file, int x, int y, int z)
{
fprintf(stderr, "SetFilePointer(%d, %d, %d, %d)\n", file, x, y, z);
- return -1;
+ return 0;
}
int SetEndOfFile(HANDLE file)
{
fprintf(stderr, "SetEndOfFile(%d)\n", file);
- return -1;
+ return 0;
}
/* time in miliseconds */
-struct timeval tv0;
-
unsigned int timeGetTime()
{
+ static struct timeval tv0;
struct timeval tv1;
int secs, usecs;