mirror of
https://github.com/1dot13/source.git
synced 2026-08-12 14:10:23 +02:00
*** MERGED source code from development trunk revision 4890 up to latest current revision 5105 ***
Development Trunk (now obsolete): https://ja2svn.dyndns.org/source/ja2/branches/Wanne/JA2%201.13%20MP A detailed list of all the features (changes) is visible in the history log of the development trunk: INFO: There will be no further development in the development source trunk, so is obsolete from now on! This commit contains the following features (bugfixes are not listed): - New Feature: Show merc ranks in Strategy Screen before merc name o Toggle on/off in the ingame options screen o For each experience level (0-10) there are defined rank names in the language specific text files o Additional language text that is not translated yet is marked with // TODO.Translate - New Feature: Faster Bobby Ray Shipments o This feature is selectable in the ja2_options.ini o When activated Bobby Ray shipments will be really fast -> Overnight Express: 5 - 7 hours -> Air Service: 10, 12 or 14 hours -> Standard Service: 15, 18 or 21 hours o In a multiplayer game, this feature is disabled (because shipment arrive immediately in the destination sector) - New Feature: AP cost for manipulating the merc inventory o This feature is selectable in the start new game screen o For example, putting a weapon from hand in the backpack costs APs o The AP costs are defined in the APBPConstants.ini o In a multiplayer game, this feature is disabled - New Feature: Added possibility to set individual Gear Kit names o Set individual names in the optional new tag <mGearKitName> inside the <GEARKIT> root element (File: TableData\MercStartingGear.xml) - New Feature: Externalized the maximum purchase amount (JA2 vanilla: 10) for Bobby Rays purchases per shipment o Define the max. amount in the ja2_options.ini: BOBBY_RAY_MAX_PURCHASE_AMOUNT, Range: 10 - 100) o Nice scrolling bars to scroll through all the purchases - New Feature: Now it is possible to walk on "water" tiles or handle those tiles like "normal" tiles o (instead of showing the swimming animation and counting the APs for swimming), when the soldier is located on the second level (level > 0) - New Feature: Externalized AIM Veterans laptop site o Add maximum of 4 pages o Add new AIM to veterans page, and remove AIM from veterans page. o New XML file: OldAIMArchive.xml (language specific XML files: *.OldAIMArchive.xml) - New Feature: Added possibility to choose from 254 IMP faces o Modified IMPPortraits.xml o Added new GameDir folder "IMPFaces" which contains the IMP face portraits o Moved IMP faces in the new "IMPFaces" folder - New Feature: ARSP - All Resolution Support Project o See here: http://www.ja-galaxy-forum.com/board/ubbthreads.php?ubb=showflat&Number=298698&page=1 o Support any kind of screen resolution. This works by choosing the matching full supported resolution (640x480, 800x600, 1024x768) and then centering the graphics o See ja2.ini for defining the screen resolution - New Feature: AI Turn Speed Up (FF-MOD) o see here: http://www.ja-galaxy-forum.com/board/ubbthreads.php?ubb=showflat&Number=298699#Post298699 o When this feature is activated it allows fast enemy turns o New entry in ja2.ini to enable this feature: HIGHSPEED_TIMER = TRUE o Turn on/off auto fast turns in ingame options o New ja2_options.ini settings for fine tuning: [Clock Settings] ini block - New Feature: "Lock" / "Release" mouse cursor in tactical windowed mode, so the mouse can stay within window boundary o This is very helpful for doing scrolling with the mouse (by moving the mouse to the window edge) in windowed mode o You can toggle on/off the feature by pressing CTRL + Z. It is also possible to press CTRL + Y. So the user can decide which fits better :) o Whenever you toggle on/off a screen message appears on the tactical log to notify the player - New Feature: Weapon overheating o Basically, every shot fired from a gun increases its temperature. On higher temperatures, the gun jams more frequently o On/off toggle in the ingame options o Graphical thermometer indication on the weapon picture o New ja2_options.ini section with a few options, Section: [Tactical Weapon Overheating Settings] o XML changes (New Tags) --> AmmoTypes.xml: <temperatureModificator> --> Items.xml: <barrel>, <usOverheatingCooldownFactor> --> Weapons.xml: <usOverheatingJamThreshold>, <usOverheatingDamageThreshold>, <usOverheatingSingleShotTemperature> o Added a few barells to Items.xml (end of the file) o more infos: http://www.ja-galaxy-forum.com/board/ubbthreads.php?ubb=showflat&Number=301059&page=1 - New Feature: Resting weapons on a surfaces o You can now rest your weapon on crates, low walls, rocks, debris, open windows etc. while you are crouched. Resting will give yu the superior gun handling modifiers from PRONE position. o A little 'A' on your gun indicates if you are resting it or not. o Both settings can be turned on and off in Ja2_Options.ini under 'Tactical Gameplay Settings' - New Feature: Externalized option on whether mercs can exit sector using grid exit in turn based mode o new ja2_options.ini property: GRID_EXIT_IN_TURNBASED o This ini setting does not affect leaving sectors on map edges - Rework/Update: Ammo boxes and Ammo crates o Ammo crate items added for remaining calibers. Tweaked prices to correspond to magazines, tweaked capacities and weights to be reasonable (~800 or less). o Shift-R reload now looks at both boxes and crates in sector items and merc's inventory to reload, and tops off magazines in inventory as well. Only possible outside of combat. o Ctrl-Shift-A still creates crates as per usual, with some fixes to ensure all ammo is caught on the first press. o Shift-A now creates ammo boxes in the same loop. They mostly behave like crates, but fit in mercs inventories. o Ammo boxes are available to purchase at BR and tony, sam, etc. Individual magazines/drums/etc are no longer available. o Removed ammo crate xml tag. Added ubMagType tag to Magazines array. This allows us to differentiate between magazines, bullets, boxes and crates. o Changed ammo filtering in BR's to display boxes appropriately. Added back the "Mag:" display (changed text to "Size:") o Added ja2set.dat.xml file (WF map version in WF maps folder) to be used instead of ja2set.dat file (ja2.ini setting added) For now, if you want to play vanilla instead, just change the setting in the ini (see comments in file). o Added P4-P9Items image files (up to 5k images each) and tileslots. 1.13 core items will continue to use Guns and P1-P3Items for the foreseeable future. P4-P9 can be used by customizers/modders to avoid conflicts with Guns/P1-P3 items. TODO: Need to discuss a strategy for this in the forums. o Added in Ambient/0.bad and 32.bad to avoid an exception in the code. o Updated the XML Editor o Standardized the text on all the ammo items. - New Multiplayer Feature: Sharing same FOV (field of view) in a coop/team-dm (for friendly teams) game o You will also see enemies, that your teammate sees git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@5108 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
@@ -34,9 +34,9 @@
|
||||
#include "utilities.h"
|
||||
#endif
|
||||
|
||||
#include "GameSettings.h"
|
||||
#include "input.h"
|
||||
#include "zmouse.h"
|
||||
#include "GameSettings.h"
|
||||
|
||||
#include <vfs/Aspects/vfs_settings.h>
|
||||
#include <vfs/Core/vfs.h>
|
||||
@@ -57,6 +57,7 @@
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include <excpt.h>
|
||||
#include "ExceptionHandling.h"
|
||||
|
||||
#include "dbt.h"
|
||||
@@ -87,6 +88,8 @@ static vfs::Path s_CodePage;
|
||||
|
||||
static vfs::FileLogger *vfslog = NULL;
|
||||
|
||||
int iWindowedMode;
|
||||
|
||||
void SHOWEXCEPTION(sgp::Exception& ex)
|
||||
{
|
||||
try {
|
||||
@@ -143,11 +146,17 @@ extern BOOLEAN CheckIfGameCdromIsInCDromDrive();
|
||||
extern void QueueEvent(UINT16 ubInputEvent, UINT32 usParam, UINT32 uiParam);
|
||||
|
||||
// Prototype Declarations
|
||||
|
||||
INT32 FAR PASCAL SyncWindowProcedure(HWND hWindow, UINT16 Message, WPARAM wParam, LPARAM lParam);
|
||||
INT32 FAR PASCAL WindowProcedure(HWND hWindow, UINT16 Message, WPARAM wParam, LPARAM lParam);
|
||||
BOOLEAN InitializeStandardGamingPlatform(HINSTANCE hInstance, int sCommandShow);
|
||||
void ShutdownStandardGamingPlatform(void);
|
||||
void CreateStandardGamingPlatform(HWND hWindow);
|
||||
void GetRuntimeSettings( );
|
||||
void SafeSGPExit(void);
|
||||
|
||||
static bool CallGameLoop(bool wait);
|
||||
static CRITICAL_SECTION gcsGameLoop;
|
||||
|
||||
|
||||
int PASCAL HandledWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR pCommandLine, int sCommandShow);
|
||||
|
||||
@@ -201,6 +210,15 @@ BOOLEAN gfIgnoreMessages=FALSE;
|
||||
// GLOBAL VARIBLE, SET TO DEFAULT BUT CAN BE CHANGED BY THE GAME IF INIT FILE READ
|
||||
UINT8 gbPixelDepth = PIXEL_DEPTH;
|
||||
|
||||
INT32 FAR PASCAL SyncWindowProcedure(HWND hWindow, UINT16 Message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
INT32 retval;
|
||||
EnterCriticalSection(&gcsGameLoop);
|
||||
retval = WindowProcedure(hWindow, Message, wParam, lParam);
|
||||
LeaveCriticalSection(&gcsGameLoop);
|
||||
return retval;
|
||||
}
|
||||
|
||||
bool s_bExportStrings = false;
|
||||
extern bool g_bUseXML_Strings;// = false;
|
||||
bool g_bUseXML_Structures = false;
|
||||
@@ -509,7 +527,8 @@ INT32 FAR PASCAL WindowProcedure(HWND hWindow, UINT16 Message, WPARAM wParam, LP
|
||||
break;
|
||||
|
||||
case WM_CREATE:
|
||||
break;
|
||||
CreateStandardGamingPlatform(hWindow);
|
||||
break;
|
||||
|
||||
case WM_DESTROY:
|
||||
ShutdownStandardGamingPlatform();
|
||||
@@ -637,7 +656,7 @@ BOOLEAN InitializeStandardGamingPlatform(HINSTANCE hInstance, int sCommandShow)
|
||||
FontTranslationTable *pFontTable;
|
||||
|
||||
// now required by all (even JA2) in order to call ShutdownSGP
|
||||
atexit(SGPExit);
|
||||
atexit(SafeSGPExit);
|
||||
|
||||
// First, initialize the registry keys.
|
||||
InitializeRegistryKeys( "Wizardry8", "Wizardry8key" );
|
||||
@@ -698,6 +717,8 @@ BOOLEAN InitializeStandardGamingPlatform(HINSTANCE hInstance, int sCommandShow)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
InitializeCriticalSection(&gcsGameLoop);
|
||||
|
||||
FastDebugMsg("Initializing Video Manager");
|
||||
// Initialize DirectDraw (DirectX 2)
|
||||
if (InitializeVideoManager(hInstance, (UINT16) sCommandShow, (void *) WindowProcedure) == FALSE)
|
||||
@@ -723,7 +744,6 @@ BOOLEAN InitializeStandardGamingPlatform(HINSTANCE hInstance, int sCommandShow)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
InitializeJA2Clock();
|
||||
//InitializeJA2TimerID();
|
||||
|
||||
#ifdef USE_VFS
|
||||
@@ -873,6 +893,24 @@ BOOLEAN InitializeStandardGamingPlatform(HINSTANCE hInstance, int sCommandShow)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void TimerActivatedCallback(INT32 timer, PTR state)
|
||||
{
|
||||
if (gfApplicationActive && gfProgramIsRunning)
|
||||
{
|
||||
if (CallGameLoop(false))
|
||||
YieldProcessor();
|
||||
}
|
||||
}
|
||||
|
||||
void CreateStandardGamingPlatform(HWND hWindow)
|
||||
{
|
||||
InitializeJA2Clock();
|
||||
|
||||
if (!IsHiSpeedClockMode())
|
||||
SetTimer( hWindow, 0, 1, NULL);
|
||||
else
|
||||
AddTimerNotifyCallback(TimerActivatedCallback, hWindow);
|
||||
}
|
||||
|
||||
void ShutdownStandardGamingPlatform(void)
|
||||
{
|
||||
@@ -896,6 +934,7 @@ void ShutdownStandardGamingPlatform(void)
|
||||
//
|
||||
// Shut down the different components of the SGP
|
||||
//
|
||||
ClearTimerNotifyCallbacks();
|
||||
|
||||
// TEST
|
||||
SoundServiceStreams();
|
||||
@@ -905,7 +944,6 @@ void ShutdownStandardGamingPlatform(void)
|
||||
ShutdownGame();
|
||||
}
|
||||
|
||||
|
||||
ShutdownButtonSystem();
|
||||
MSYS_Shutdown();
|
||||
|
||||
@@ -944,6 +982,8 @@ void ShutdownStandardGamingPlatform(void)
|
||||
// down the debugging layer
|
||||
UnRegisterDebugTopic(TOPIC_SGP, "Standard Gaming Platform");
|
||||
|
||||
DeleteCriticalSection(&gcsGameLoop);
|
||||
|
||||
ShutdownDebugManager();
|
||||
|
||||
sgp::Logger::instance().shutdown();
|
||||
@@ -1023,12 +1063,25 @@ private:
|
||||
|
||||
int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR pCommandLine, int sCommandShow)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
// Use this one ONLY if you're having memory corruption issues that can be repeated in a short time
|
||||
// Otherwise it will just run out of memory.
|
||||
|
||||
/****************************************************************************************************/
|
||||
/* */
|
||||
/* DEBUG MEMORY ALLOCATION ON THE HEAP : uncomment when required */
|
||||
/* ------------------------------------------------------------------------ */
|
||||
/* */
|
||||
/* _CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF | _CRTDBG_CHECK_EVERY_1024_DF); */
|
||||
/* _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_DEBUG ); */
|
||||
/* */
|
||||
/****************************************************************************************************/
|
||||
#endif
|
||||
|
||||
//If we are to use exception handling
|
||||
#ifdef ENABLE_EXCEPTION_HANDLING
|
||||
int Result = -1;
|
||||
|
||||
|
||||
__try
|
||||
{
|
||||
Result = HandledWinMain(hInstance, hPrevInstance, pCommandLine, sCommandShow);
|
||||
@@ -1058,6 +1111,8 @@ int PASCAL HandledWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR pC
|
||||
HWND hPrevInstanceWindow;
|
||||
UINT32 uiTimer = 0;
|
||||
|
||||
|
||||
|
||||
#ifdef USE_VFS
|
||||
vfs::Log::setSharedString( getGameID() );
|
||||
#endif
|
||||
@@ -1193,9 +1248,6 @@ int PASCAL HandledWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR pC
|
||||
|
||||
FastDebugMsg("Running Game");
|
||||
|
||||
// 0verhaul: Use the smallest available timer to make sure all animation updates happen at the speed they're supposed to
|
||||
SetTimer( ghWindow, uiTimer, 1, NULL);
|
||||
|
||||
// At this point the SGP is set up, which means all I/O, Memory, tools, etc... are available. All we need to do is
|
||||
// attend to the gaming mechanics themselves
|
||||
Message.wParam = 0;
|
||||
@@ -1269,8 +1321,6 @@ int PASCAL HandledWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR pC
|
||||
}
|
||||
#endif
|
||||
|
||||
KillTimer( ghWindow, uiTimer);
|
||||
|
||||
// This is the normal exit point
|
||||
FastDebugMsg("Exiting Game");
|
||||
PostQuitMessage(0);
|
||||
@@ -1283,7 +1333,6 @@ int PASCAL HandledWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR pC
|
||||
}
|
||||
|
||||
|
||||
|
||||
void SGPExit(void)
|
||||
{
|
||||
static BOOLEAN fAlreadyExiting = FALSE;
|
||||
@@ -1326,7 +1375,12 @@ void SGPExit(void)
|
||||
|
||||
void GetRuntimeSettings( )
|
||||
{
|
||||
int iMaximize;
|
||||
|
||||
#ifndef USE_VFS
|
||||
CHAR8 zMaximize[ 50 ];
|
||||
CHAR8 zWindowedMode[ 50 ];
|
||||
|
||||
// Runtime settings - for now use INI file - later use registry
|
||||
STRING512 INIFile; // Path to the ini file
|
||||
CHAR8 zScreenResolution[ 50 ];
|
||||
@@ -1340,12 +1394,20 @@ void GetRuntimeSettings( )
|
||||
vfs::PropertyContainer oProps;
|
||||
oProps.initFromIniFile(GAME_INI_FILE);
|
||||
#endif
|
||||
iResolution = -1;
|
||||
|
||||
#ifndef USE_VFS
|
||||
if (GetPrivateProfileString( "Ja2 Settings","SCREEN_RESOLUTION", "", zScreenResolution, 50, INIFile ))
|
||||
{
|
||||
iResolution = atoi(zScreenResolution);
|
||||
}
|
||||
if (GetPrivateProfileString( "Ja2 Settings","SCREEN_MODE_WINDOWED_MAXIMIZE", "", zMaximize, 50, INIFile ))
|
||||
{
|
||||
iMaximize = atoi(zMaximize);
|
||||
}
|
||||
if (GetPrivateProfileString( "Ja2 Settings","SCREEN_MODE_WINDOWED", "", zWindowedMode, 50, INIFile ))
|
||||
{
|
||||
iWindowedMode = atoi(zWindowedMode);
|
||||
}
|
||||
#else
|
||||
vfs::String loc = oProps.getStringProperty("Ja2 Settings", L"LOCALE");
|
||||
if(!loc.empty())
|
||||
@@ -1354,6 +1416,12 @@ void GetRuntimeSettings( )
|
||||
}
|
||||
|
||||
iResolution = (int)oProps.getIntProperty(L"Ja2 Settings", L"SCREEN_RESOLUTION", -1);
|
||||
|
||||
// WANNE: Always enable
|
||||
//iMaximize = (int)oProps.getIntProperty(L"Ja2 Settings", L"SCREEN_MODE_WINDOWED_MAXIMIZE", -1);
|
||||
iMaximize = 1;
|
||||
|
||||
iWindowedMode = (int)oProps.getIntProperty(L"Ja2 Settings", L"SCREEN_MODE_WINDOWED", -1);
|
||||
|
||||
vfs::Settings::setUseUnicode( !oProps.getBoolProperty(L"Ja2 Settings", L"VFS_NO_UNICODE", false) );
|
||||
|
||||
@@ -1428,23 +1496,120 @@ void GetRuntimeSettings( )
|
||||
|
||||
switch (iResolution)
|
||||
{
|
||||
// 640x480
|
||||
case 0:
|
||||
case _640x480:
|
||||
iResX = 640;
|
||||
iResY = 480;
|
||||
break;
|
||||
// 1024x768
|
||||
case 2:
|
||||
case _800x600:
|
||||
iResX = 800;
|
||||
iResY = 600;
|
||||
break;
|
||||
case _1024x600:
|
||||
iResX = 1024;
|
||||
iResY = 600;
|
||||
break;
|
||||
case _1280x720:
|
||||
iResX = 1280;
|
||||
iResY = 720;
|
||||
break;
|
||||
case _1024x768:
|
||||
iResX = 1024;
|
||||
iResY = 768;
|
||||
break;
|
||||
// 800x600
|
||||
default:
|
||||
iResolution = 1;
|
||||
case _1280x768:
|
||||
iResX = 1280;
|
||||
iResY = 768;
|
||||
break;
|
||||
case _1360x768:
|
||||
iResX = 1360;
|
||||
iResY = 768;
|
||||
break;
|
||||
case _1366x768:
|
||||
iResX = 1366;
|
||||
iResY = 768;
|
||||
break;
|
||||
case _1280x800:
|
||||
iResX = 1280;
|
||||
iResY = 800;
|
||||
break;
|
||||
case _1440x900:
|
||||
iResX = 1440;
|
||||
iResY = 900;
|
||||
break;
|
||||
case _1600x900:
|
||||
iResX = 1600;
|
||||
iResY = 900;
|
||||
break;
|
||||
case _1280x960:
|
||||
iResX = 1280;
|
||||
iResY = 960;
|
||||
break;
|
||||
case _1440x960:
|
||||
iResX = 1440;
|
||||
iResY = 960;
|
||||
break;
|
||||
case _1770x1000:
|
||||
iResX = 1770;
|
||||
iResY = 1000;
|
||||
break;
|
||||
case _1280x1024:
|
||||
iResX = 1280;
|
||||
iResY = 1024;
|
||||
break;
|
||||
case _1360x1024:
|
||||
iResX = 1360;
|
||||
iResY = 1024;
|
||||
break;
|
||||
case _1600x1024:
|
||||
iResX = 1600;
|
||||
iResY = 1024;
|
||||
break;
|
||||
case _1440x1050:
|
||||
iResX = 1440;
|
||||
iResY = 1050;
|
||||
break;
|
||||
case _1680x1050:
|
||||
iResX = 1680;
|
||||
iResY = 1050;
|
||||
break;
|
||||
case _1920x1080:
|
||||
iResX = 1920;
|
||||
iResY = 1080;
|
||||
break;
|
||||
case _1600x1200:
|
||||
iResX = 1600;
|
||||
iResY = 1200;
|
||||
break;
|
||||
case _1920x1200:
|
||||
iResX = 1920;
|
||||
iResY = 1200;
|
||||
break;
|
||||
case _2560x1440:
|
||||
iResX = 2560;
|
||||
iResY = 1440;
|
||||
break;
|
||||
case _2560x1600:
|
||||
iResX = 2560;
|
||||
iResY = 1600;
|
||||
break;
|
||||
default: // 800x600
|
||||
iResolution = _800x600;
|
||||
iResX = 800;
|
||||
iResY = 600;
|
||||
break;
|
||||
}
|
||||
|
||||
if (iWindowedMode == 1 && iMaximize == 1)
|
||||
{
|
||||
if ((iResX - 16) >= 1024)
|
||||
iResX = iResX - 16;
|
||||
|
||||
if ((iResY - 70) >= 768)
|
||||
iResY = iResY - 70;
|
||||
}
|
||||
|
||||
// Adjust again
|
||||
|
||||
#ifndef USE_VFS
|
||||
gbPixelDepth = GetPrivateProfileInt( "SGP", "PIXEL_DEPTH", PIXEL_DEPTH, INIFile );
|
||||
|
||||
@@ -1462,14 +1627,33 @@ void GetRuntimeSettings( )
|
||||
// WANNE: Should we play the intro?
|
||||
iPlayIntro = (int) GetPrivateProfileInt( "Ja2 Settings","PLAY_INTRO", iPlayIntro, INIFile );
|
||||
#else
|
||||
gbPixelDepth = (UINT8)oProps.getIntProperty(L"SGP", L"PIXEL_DEPTH", PIXEL_DEPTH);
|
||||
gbPixelDepth = PIXEL_DEPTH;
|
||||
|
||||
SCREEN_WIDTH = (UINT16)oProps.getIntProperty(L"SGP", L"WIDTH", iResX);
|
||||
SCREEN_HEIGHT = (UINT16)oProps.getIntProperty(L"SGP", L"HEIGHT", iResY);
|
||||
SCREEN_WIDTH = iResX;
|
||||
SCREEN_HEIGHT = iResY;
|
||||
|
||||
iScreenWidthOffset = (SCREEN_WIDTH - 640) / 2;
|
||||
iScreenHeightOffset = (SCREEN_HEIGHT - 480) / 2;
|
||||
|
||||
if (iResolution >= _640x480 && iResolution < _800x600)
|
||||
{
|
||||
xResOffset = ((SCREEN_WIDTH - 640) / 2);
|
||||
yResOffset = ((SCREEN_HEIGHT - 480) / 2);
|
||||
}
|
||||
else if (iResolution < _1024x768)
|
||||
{
|
||||
xResOffset = ((SCREEN_WIDTH - 800) / 2);
|
||||
yResOffset = ((SCREEN_HEIGHT - 600) / 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
xResOffset = ((SCREEN_WIDTH - 1024) / 2);
|
||||
yResOffset = ((SCREEN_HEIGHT - 768) / 2);
|
||||
}
|
||||
|
||||
xResSize = (SCREEN_WIDTH - 2 * xResOffset); // one of the following: 1024 or 800 or 640
|
||||
yResSize = (SCREEN_HEIGHT - 2 * yResOffset); // one of the follownig: 768 or 600 or 480
|
||||
|
||||
/* Sergeant_Kolja. 2007-02-20: runtime Windowed mode instead of compile-time */
|
||||
/* 1 for Windowed, 0 for Fullscreen */
|
||||
if( !bScreenModeCmdLine )
|
||||
@@ -1484,9 +1668,28 @@ void GetRuntimeSettings( )
|
||||
s_DebugKeyboardInput = oProps.getBoolProperty(L"Ja2 Settings", L"DEBUG_KEYS", false);
|
||||
s_CodePage = oProps.getStringProperty(L"Ja2 Settings", L"CODE_PAGE");
|
||||
#endif // USE_CODE_PAGE
|
||||
|
||||
// get timer/clock initialization state
|
||||
SetHiSpeedClockMode( oProps.getBoolProperty("Ja2 Settings", "HIGHSPEED_TIMER", false) ? TRUE : FALSE );
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void SafeSGPExit(void)
|
||||
{
|
||||
// SGPExit tends to use resources that are already uninitialized so handle
|
||||
__try
|
||||
{
|
||||
SGPExit();
|
||||
}
|
||||
__except( EXCEPTION_EXECUTE_HANDLER )
|
||||
{
|
||||
// The application is in exit and best effort to clean up
|
||||
// has failed so just ignore and continue silently
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ShutdownWithErrorBox(CHAR8 *pcMessage)
|
||||
{
|
||||
strncpy(gzErrorMsg, pcMessage, 255);
|
||||
@@ -1617,3 +1820,61 @@ void ProcessJa2CommandLineBeforeInitialization(CHAR8 *pCommandLine)
|
||||
|
||||
MemFree(pCopy);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static LONG __stdcall SGPExceptionFilter(int exceptionCount, EXCEPTION_POINTERS* pExceptInfo)
|
||||
{
|
||||
#ifdef ENABLE_EXCEPTION_HANDLING
|
||||
|
||||
if (exceptionCount > 3)
|
||||
{
|
||||
// the exception handler writer can fail with exceptions too
|
||||
__try
|
||||
{
|
||||
RecordExceptionInfo(pExceptInfo);
|
||||
} __except (EXCEPTION_EXECUTE_HANDLER) {}
|
||||
AssertMsg(FALSE, "Unhanded exception processing GameLoop unable to recover.");
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
return EXCEPTION_EXECUTE_HANDLER;
|
||||
}
|
||||
|
||||
static bool CallGameLoop(bool wait)
|
||||
{
|
||||
static int numUnsuccessfulTries = 0;
|
||||
if (wait)
|
||||
{
|
||||
EnterCriticalSection(&gcsGameLoop);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( !TryEnterCriticalSection(&gcsGameLoop) )
|
||||
return false;
|
||||
}
|
||||
|
||||
__try
|
||||
{
|
||||
__try
|
||||
{
|
||||
GameLoop();
|
||||
numUnsuccessfulTries = 0;
|
||||
}
|
||||
__except( SGPExceptionFilter(++numUnsuccessfulTries, GetExceptionInformation()) )
|
||||
{
|
||||
}
|
||||
}
|
||||
__finally
|
||||
{
|
||||
LeaveCriticalSection(&gcsGameLoop);
|
||||
}
|
||||
|
||||
// Give it several attempts to recover from random exceptions and to display error screen
|
||||
if (numUnsuccessfulTries > 5)
|
||||
ShutdownWithErrorBox("Unhandled exception. Unable to recover.");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user