From 06371ecc4597b34bf5f9ac3cd9bfa3c835c528f3 Mon Sep 17 00:00:00 2001 From: Steven Fuller Date: Mon, 5 Nov 2001 02:47:58 +0000 Subject: [PATCH] Re-fixed the menus and enabled another font drawing function. Fixed Profile Loading/Saving (had to disable debug mode). --- README | 7 +- src/avp/win95/frontend/avp_mp_config.cpp | 26 +++---- src/avp/win95/frontend/avp_userprofile.cpp | 81 +++++++++++++++++++++- src/avp/win95/frontend/avp_userprofile.h | 2 - src/main.c | 12 ++-- src/menus.c | 6 ++ 6 files changed, 111 insertions(+), 23 deletions(-) diff --git a/README b/README index 2e880f3..e95ce1c 100644 --- a/README +++ b/README @@ -44,13 +44,18 @@ the CFLAGS line (the one that's uncommented) in the Makefile. Rename all game files lowercase. Be sure to install SDL 1.2 (http://www.libsdl.org), nasm 0.98, and the latest OpenAL CVS (http://www.openal.org). +Create the MPConfig and User_Profiles directories if they do not exist. +(Note: Windows profiles probably do not work in Linux and vice versa) + If you have the regular edition, add -DREGULAR_EDITION to CFLAGS. relnev:~/avp/AvP Demo 3 - Alien$ ls -aenglish.txt alienavp_huds/ alienfastfile/ avp_rifs/ +aenglish.txt alienavp_huds/ alienfastfile/ avp_rifs/ MPConfig/ +User_Profiles/ relnev:~/avp/Gold Edition$ ls avp_huds/ avp_rifs/ cd tracks.txt default.cfg fastfile/ language.txt +MPConfig/ User_Profiles/ Support for the demo is not quite complete (some sounds are missing and some text is incorrect/missing). diff --git a/src/avp/win95/frontend/avp_mp_config.cpp b/src/avp/win95/frontend/avp_mp_config.cpp index f0eb85e..6bb4950 100644 --- a/src/avp/win95/frontend/avp_mp_config.cpp +++ b/src/avp/win95/frontend/avp_mp_config.cpp @@ -22,9 +22,9 @@ extern char MP_SessionName[]; extern char MP_Config_Description[]; #define MP_CONFIG_DIR "MPConfig" -#define MP_CONFIG_WILDCARD "MPConfig\\*.cfg" +#define MP_CONFIG_WILDCARD "MPConfig/*.cfg" -#define SKIRMISH_CONFIG_WILDCARD "MPConfig\\*.skirmish_cfg" +#define SKIRMISH_CONFIG_WILDCARD "MPConfig/.skirmish_cfg" static List ConfigurationFilenameList; static List ConfigurationLocalisedFilenameList; @@ -199,9 +199,9 @@ const char* GetMultiplayerConfigDescription(int index) FILE* file; char filename[200]; if(netGameData.skirmishMode) - sprintf(filename,"%s\\%s.skirmish_cfg",MP_CONFIG_DIR,name); + sprintf(filename,"%s/%s.skirmish_cfg",MP_CONFIG_DIR,name); else - sprintf(filename,"%s\\%s.cfg",MP_CONFIG_DIR,name); + sprintf(filename,"%s/%s.cfg",MP_CONFIG_DIR,name); file=fopen(filename,"rb"); if(!file) @@ -239,9 +239,9 @@ void LoadMultiplayerConfiguration(const char* name) FILE* file; char filename[200]; if(netGameData.skirmishMode) - sprintf(filename,"%s\\%s.skirmish_cfg",MP_CONFIG_DIR,name); + sprintf(filename,"%s/%s.skirmish_cfg",MP_CONFIG_DIR,name); else - sprintf(filename,"%s\\%s.cfg",MP_CONFIG_DIR,name); + sprintf(filename,"%s/%s.cfg",MP_CONFIG_DIR,name); file=fopen(filename,"rb"); if(!file) return; @@ -350,9 +350,9 @@ void SaveMultiplayerConfiguration(const char* name) FILE* file; char filename[200]; if(netGameData.skirmishMode) - sprintf(filename,"%s\\%s.skirmish_cfg",MP_CONFIG_DIR,name); + sprintf(filename,"%s/%s.skirmish_cfg",MP_CONFIG_DIR,name); else - sprintf(filename,"%s\\%s.cfg",MP_CONFIG_DIR,name); + sprintf(filename,"%s/%s.cfg",MP_CONFIG_DIR,name); CreateDirectory(MP_CONFIG_DIR,0); file=fopen(filename,"wb"); @@ -449,16 +449,16 @@ void DeleteMultiplayerConfigurationByIndex(int index) char filename[200]; if(netGameData.skirmishMode) - sprintf(filename,"%s\\%s.skirmish_cfg",MP_CONFIG_DIR,ConfigurationFilenameList[index]); + sprintf(filename,"%s/%s.skirmish_cfg",MP_CONFIG_DIR,ConfigurationFilenameList[index]); else - sprintf(filename,"%s\\%s.cfg",MP_CONFIG_DIR,ConfigurationFilenameList[index]); + sprintf(filename,"%s/%s.cfg",MP_CONFIG_DIR,ConfigurationFilenameList[index]); DeleteFile(filename); } #define IP_ADDRESS_DIR "IP_Address" -#define IP_ADDRESS_WILDCARD "IP_Address\\*.IP Address" +#define IP_ADDRESS_WILDCARD "IP_Address/*.IP Address" static List IPAddFilenameList; @@ -563,7 +563,7 @@ void SaveIPAddress(const char* name,const char* address) FILE* file; char filename[200]; - sprintf(filename,"%s\\%s.IP Address",IP_ADDRESS_DIR,name); + sprintf(filename,"%s/%s.IP Address",IP_ADDRESS_DIR,name); CreateDirectory(IP_ADDRESS_DIR,0); file=fopen(filename,"wb"); @@ -584,7 +584,7 @@ void LoadIPAddress(const char* name) FILE* file; char filename[200]; - sprintf(filename,"%s\\%s.IP Address",IP_ADDRESS_DIR,name); + sprintf(filename,"%s/%s.IP Address",IP_ADDRESS_DIR,name); file=fopen(filename,"rb"); if(!file) return; diff --git a/src/avp/win95/frontend/avp_userprofile.cpp b/src/avp/win95/frontend/avp_userprofile.cpp index d3204df..a40ac85 100644 --- a/src/avp/win95/frontend/avp_userprofile.cpp +++ b/src/avp/win95/frontend/avp_userprofile.cpp @@ -20,6 +20,11 @@ extern "C" #include "pldnet.h" #include +#include +#include +#include +#include + static int LoadUserProfiles(void); static void EmptyUserProfilesList(void); @@ -199,7 +204,79 @@ static int ProfileIsMoreRecent(AVP_USER_PROFILE *profilePtr, AVP_USER_PROFILE *p static int LoadUserProfiles(void) { - fprintf(stderr, "STUB: LoadUserProfiles()\n"); + glob_t globbuf; + const char* load_name=USER_PROFILES_WILDCARD_NAME; + + if (glob(load_name, 0, NULL, &globbuf)) + 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; + } + + for (int i = 0; i < globbuf.gl_pathc; i++) { + struct stat buf; + + if (stat(globbuf.gl_pathv[i], &buf) == -1) + continue; + + if (S_ISREG(buf.st_mode) && (access(globbuf.gl_pathv[i], R_OK) == 0)) + { + char * pszFullPath = new char [nPathLen+strlen(globbuf.gl_pathv[i])+1]; + // 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; + } + + AVP_USER_PROFILE *profilePtr = new AVP_USER_PROFILE; + unsigned long bytes_read; + + if (!ReadFile(rif_file, profilePtr, sizeof(AVP_USER_PROFILE), &bytes_read, 0)) + { + 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 @@ -435,4 +512,4 @@ extern void FixCheatModesInUserProfile(AVP_USER_PROFILE *profilePtr) } -}; // extern "C" \ No newline at end of file +}; // extern "C" diff --git a/src/avp/win95/frontend/avp_userprofile.h b/src/avp/win95/frontend/avp_userprofile.h index 2f37092..7355d09 100644 --- a/src/avp/win95/frontend/avp_userprofile.h +++ b/src/avp/win95/frontend/avp_userprofile.h @@ -144,8 +144,6 @@ typedef struct - -/* TODO: dir separator */ #define USER_PROFILES_PATH "User_Profiles/" #define USER_PROFILES_WILDCARD_NAME "User_Profiles/*.prf" #define USER_PROFILES_SUFFIX ".prf" diff --git a/src/main.c b/src/main.c index 890e8f9..232a5e0 100644 --- a/src/main.c +++ b/src/main.c @@ -100,7 +100,7 @@ int SetSoftVideoMode(int Width, int Height, int Depth) // SDL_WM_GrabInput(SDL_GRAB_ON); // SDL_ShowCursor(0); - if (isfull) { + if (isfull && !(surface->flags & SDL_FULLSCREEN)) { SDL_WM_ToggleFullScreen(surface); if (surface->flags & SDL_FULLSCREEN) SDL_ShowCursor(0); @@ -166,7 +166,7 @@ int SetOGLVideoMode(int Width, int Height) // SDL_WM_GrabInput(SDL_GRAB_ON); // SDL_ShowCursor(0); - if (isfull) { + if (isfull && !(surface->flags & SDL_FULLSCREEN)) { SDL_WM_ToggleFullScreen(surface); if (surface->flags & SDL_FULLSCREEN) SDL_ShowCursor(0); @@ -185,7 +185,8 @@ int SetOGLVideoMode(int Width, int Height) glLoadIdentity(); glEnable(GL_BLEND); - glBlendFunc(GL_ONE, GL_ONE); +// glBlendFunc(GL_ONE, GL_ONE); + glBlendFunc(GL_SRC_ALPHA, GL_ONE); glEnable(GL_DEPTH_TEST); glDepthFunc(GL_LEQUAL); @@ -592,7 +593,7 @@ void CheckForWindowsMessages() MouseVelY = 0; } - if (KeyboardInput[KEY_LEFTALT] && DebouncedKeyboardInput[KEY_CR]) { + if ((KeyboardInput[KEY_LEFTALT]||KeyboardInput[KEY_RIGHTALT]) && DebouncedKeyboardInput[KEY_CR]) { SDL_GrabMode gm; SDL_WM_ToggleFullScreen(surface); @@ -685,11 +686,12 @@ int main(int argc, char *argv[]) SetFastRandom(); GetPathFromRegistry(); - +#if 0 { extern int DebuggingCommandsActive; DebuggingCommandsActive = 1; } +#endif #if MARINE_DEMO ffInit("fastfile/mffinfo.txt","fastfile/"); diff --git a/src/menus.c b/src/menus.c index 4d0ff6e..0be521b 100644 --- a/src/menus.c +++ b/src/menus.c @@ -137,6 +137,8 @@ int RenderMenuText(char *textPtr, int x, int y, int alpha, enum AVPMENUFORMAT_ID int RenderMenuText_Clipped(char *textPtr, int x, int y, int alpha, enum AVPMENUFORMAT_ID format, int topY, int bottomY) { + return Hardware_RenderSmallMenuText(textPtr, x, y, alpha, format); + fprintf(stderr, "RenderMenuText_Clipped(%s, %d, %d, %d, %d, %d, %d)\n", textPtr, x, y, alpha, format, topY, bottomY); return 0; @@ -282,7 +284,11 @@ void InitialiseMenuGfx() } glEnable(GL_BLEND); +// glBlendFunc(GL_ONE, GL_ONE); + glBlendFunc(GL_SRC_ALPHA, GL_ONE); + glDisable(GL_DEPTH_TEST); + glEnable(GL_TEXTURE_2D); glClear(GL_COLOR_BUFFER_BIT);