diff --git a/GpApp/HouseIO.cpp b/GpApp/HouseIO.cpp
index 948534c..eaa4b88 100644
--- a/GpApp/HouseIO.cpp
+++ b/GpApp/HouseIO.cpp
@@ -178,7 +178,7 @@ Boolean OpenHouse (void)
return(false);
#ifdef COMPILEDEMO
- if (!EqualString(theHousesSpecs[thisHouseIndex].name, "\pDemo House", false, true))
+ if (!StrCmp::EqualCaseInsensitive(theHousesSpecs[thisHouseIndex].name, "\pDemo House"))
return (false);
#endif
@@ -216,7 +216,7 @@ Boolean OpenSpecificHouse (const VFileSpec &specs)
for (i = 0; i < housesFound; i++)
{
if ((theHousesSpecs[i].m_dir == specs.m_dir) &&
- (EqualString(theHousesSpecs[i].m_name, specs.m_name, false, true)))
+ (StrCmp::EqualCaseInsensitive(theHousesSpecs[i].m_name, specs.m_name)))
{
thisHouseIndex = i;
PasStringCopy(theHousesSpecs[thisHouseIndex].m_name, thisHouseName);
diff --git a/GpApp/HouseLegal.cpp b/GpApp/HouseLegal.cpp
index 65af944..b50e71a 100644
--- a/GpApp/HouseLegal.cpp
+++ b/GpApp/HouseLegal.cpp
@@ -805,7 +805,7 @@ void CountUntitledRooms (void)
for (i = 0; i < numRooms; i++)
{
if (((*thisHouse)->rooms[i].suite != kRoomIsEmpty) &&
- (EqualString((*thisHouse)->rooms[i].name, PSTR("Untitled Room"), false, true)))
+ (StrCmp::EqualCaseInsensitive((*thisHouse)->rooms[i].name, PSTR("Untitled Room"))))
houseErrors++;
}
}
diff --git a/GpApp/SavedGames.cpp b/GpApp/SavedGames.cpp
index 2487835..4b00b28 100644
--- a/GpApp/SavedGames.cpp
+++ b/GpApp/SavedGames.cpp
@@ -226,7 +226,7 @@ return false; // TEMP fix this iwth NavServices
HLock((Handle)thisHouse);
thisHousePtr = *thisHouse;
- if (!EqualString(savedGame->house.name, thisHouseName, true, true))
+ if (!StrCmp::Equal(savedGame->house.name, thisHouseName))
{
SavedGameMismatchError(savedGame->house.name);
HSetState((Handle)thisHouse, wasState);
diff --git a/GpApp/SelectHouse.cpp b/GpApp/SelectHouse.cpp
index 0f59a4b..4571b4c 100644
--- a/GpApp/SelectHouse.cpp
+++ b/GpApp/SelectHouse.cpp
@@ -533,7 +533,7 @@ void SortHouseList (void)
h = i + 1;
while (h < housesFound)
{
- if ((EqualString(theHousesSpecs[i].m_name, theHousesSpecs[h].m_name, true, true)) &&
+ if ((StrCmp::Equal(theHousesSpecs[i].m_name, theHousesSpecs[h].m_name)) &&
(theHousesSpecs[i].m_dir == theHousesSpecs[i].m_dir))
{
theHousesSpecs[h] = theHousesSpecs[housesFound - 1];
@@ -616,7 +616,7 @@ void DoDirSearch (void)
thisHouseIndex = 0;
for (i = 0; i < housesFound; i++)
{
- if (EqualString(theHousesSpecs[i].m_name, thisHouseName, false, true))
+ if (StrCmp::Equal(theHousesSpecs[i].m_name, thisHouseName))
{
thisHouseIndex = i;
break;
@@ -627,7 +627,7 @@ void DoDirSearch (void)
demoHouseIndex = -1;
for (i = 0; i < housesFound; i++)
{
- if (EqualString(theHousesSpecs[i].m_name, PSTR("Demo House"), false, true))
+ if (StrCmp::Equal(theHousesSpecs[i].m_name, PSTR("Demo House")))
{
demoHouseIndex = i;
break;
diff --git a/GpCommon/GpDisplayDriverProperties.h b/GpCommon/GpDisplayDriverProperties.h
index 19efbee..53d49b8 100644
--- a/GpCommon/GpDisplayDriverProperties.h
+++ b/GpCommon/GpDisplayDriverProperties.h
@@ -1,6 +1,7 @@
#pragma once
#include "EGpDisplayDriverType.h"
+#include "GpDisplayDriverTickStatus.h"
struct IGpDisplayDriver;
struct IGpFiber;
@@ -8,7 +9,7 @@ struct IGpVOSEventQueue;
struct GpDisplayDriverProperties
{
- typedef void(*TickFunc_t)(void *context, IGpFiber *vosFiber);
+ typedef GpDisplayDriverTickStatus_t (*TickFunc_t)(void *context, IGpFiber *vosFiber);
typedef void(*RenderFunc_t)(void *context);
EGpDisplayDriverType m_type;
diff --git a/GpCommon/GpDisplayDriverTickStatus.h b/GpCommon/GpDisplayDriverTickStatus.h
new file mode 100644
index 0000000..73777b5
--- /dev/null
+++ b/GpCommon/GpDisplayDriverTickStatus.h
@@ -0,0 +1,15 @@
+#pragma once
+
+namespace GpDisplayDriverTickStatuses
+{
+ enum GpDisplayDriverTickStatus
+ {
+ kOK = 0,
+ kNonFatalFault = 1,
+ kFatalFault = 2,
+
+ kApplicationTerminated = 3,
+ };
+}
+
+typedef GpDisplayDriverTickStatuses::GpDisplayDriverTickStatus GpDisplayDriverTickStatus_t;
diff --git a/GpD3D/GpAppEnvironment.cpp b/GpD3D/GpAppEnvironment.cpp
index c5f225d..66d1d43 100644
--- a/GpD3D/GpAppEnvironment.cpp
+++ b/GpD3D/GpAppEnvironment.cpp
@@ -1,10 +1,12 @@
#include "GpAppEnvironment.h"
#include "GpFiberStarter.h"
#include "GpAppInterface.h"
+#include "GpDisplayDriverTickStatus.h"
#include "GpFontHandlerFactory.h"
#include "GpPLGlueAudioDriver.h"
#include "GpPLGlueDisplayDriver.h"
#include "HostSuspendCallArgument.h"
+#include "IGpDisplayDriver.h"
#include "IGpFiber.h"
#include "IGpInputDriver.h"
@@ -35,7 +37,7 @@ void GpAppEnvironment::Init()
{
}
-void GpAppEnvironment::Tick(IGpFiber *vosFiber)
+GpDisplayDriverTickStatus_t GpAppEnvironment::Tick(IGpFiber *vosFiber)
{
GpAppInterface_Get()->PL_IncrementTickCounter(1);
@@ -54,7 +56,7 @@ void GpAppEnvironment::Tick(IGpFiber *vosFiber)
m_applicationState = ApplicationState_Running;
break;
case ApplicationState_WaitingForEvents:
- return;
+ return GpDisplayDriverTickStatuses::kOK;
case ApplicationState_Running:
SynchronizeState();
m_applicationFiber->YieldTo();
@@ -75,9 +77,13 @@ void GpAppEnvironment::Tick(IGpFiber *vosFiber)
else
{
m_delaySuspendTicks--;
- return;
+ return GpDisplayDriverTickStatuses::kOK;
}
break;
+ case ApplicationState_Terminated:
+ m_applicationFiber->Destroy();
+ m_applicationFiber = nullptr;
+ return GpDisplayDriverTickStatuses::kApplicationTerminated;
default:
assert(false);
break;
@@ -124,6 +130,9 @@ void GpAppEnvironment::StaticAppThreadFunc(void *context)
void GpAppEnvironment::AppThreadFunc()
{
GpAppInterface_Get()->ApplicationMain();
+
+ m_applicationState = ApplicationState_Terminated;
+ m_vosFiber->YieldTo();
}
void GpAppEnvironment::InitializeApplicationState()
diff --git a/GpD3D/GpAppEnvironment.h b/GpD3D/GpAppEnvironment.h
index 5444336..75f9b6d 100644
--- a/GpD3D/GpAppEnvironment.h
+++ b/GpD3D/GpAppEnvironment.h
@@ -1,5 +1,6 @@
#pragma once
+#include "GpDisplayDriverTickStatus.h"
#include "GpVOSEventQueue.h"
#include "HostSuspendCallID.h"
@@ -25,7 +26,7 @@ public:
void Init();
- void Tick(IGpFiber *vosFiber);
+ GpDisplayDriverTickStatus_t Tick(IGpFiber *vosFiber);
void Render();
void SetDisplayDriver(IGpDisplayDriver *displayDriver);
diff --git a/GpD3D/GpD3D.vcxproj b/GpD3D/GpD3D.vcxproj
index a0b56eb..54109df 100644
--- a/GpD3D/GpD3D.vcxproj
+++ b/GpD3D/GpD3D.vcxproj
@@ -169,6 +169,7 @@
+
diff --git a/GpD3D/GpD3D.vcxproj.filters b/GpD3D/GpD3D.vcxproj.filters
index 77920f3..cdf2cb8 100644
--- a/GpD3D/GpD3D.vcxproj.filters
+++ b/GpD3D/GpD3D.vcxproj.filters
@@ -191,6 +191,9 @@
Header Files
+
+ Header Files
+
diff --git a/GpD3D/GpMain.cpp b/GpD3D/GpMain.cpp
index 3557e8b..c15db20 100644
--- a/GpD3D/GpMain.cpp
+++ b/GpD3D/GpMain.cpp
@@ -4,6 +4,7 @@
#include "GpFontHandlerFactory.h"
#include "GpDisplayDriverFactory.h"
#include "GpDisplayDriverProperties.h"
+#include "GpDisplayDriverTickStatus.h"
#include "GpInputDriverFactory.h"
#include "GpInputDriverProperties.h"
#include "GpGlobalConfig.h"
@@ -17,9 +18,9 @@
namespace
{
- void TickAppEnvironment(void *context, IGpFiber *vosFiber)
+ GpDisplayDriverTickStatus_t TickAppEnvironment(void *context, IGpFiber *vosFiber)
{
- static_cast(context)->Tick(vosFiber);
+ return static_cast(context)->Tick(vosFiber);
}
void RenderAppEnvironment(void *context)
diff --git a/GpDisplayDriver_D3D11/GpDisplayDriverD3D11.cpp b/GpDisplayDriver_D3D11/GpDisplayDriverD3D11.cpp
index 5b24b0f..0032798 100644
--- a/GpDisplayDriver_D3D11/GpDisplayDriverD3D11.cpp
+++ b/GpDisplayDriver_D3D11/GpDisplayDriverD3D11.cpp
@@ -309,7 +309,7 @@ bool GpDisplayDriverD3D11::InitResources()
}
-bool GpDisplayDriverD3D11::PresentFrameAndSync()
+GpDisplayDriverTickStatus_t GpDisplayDriverD3D11::PresentFrameAndSync()
{
SynchronizeCursors();
@@ -341,16 +341,16 @@ bool GpDisplayDriverD3D11::PresentFrameAndSync()
UINT lastPresentCount = 0;
if (FAILED(m_swapChain->GetLastPresentCount(&lastPresentCount)))
- return false;
+ return GpDisplayDriverTickStatuses::kNonFatalFault;
if (FAILED(m_swapChain->Present1(1, 0, &presentParams)))
- return false;
+ return GpDisplayDriverTickStatuses::kNonFatalFault;
//DebugPrintf("r: %i\n", static_cast(r));
DXGI_FRAME_STATISTICS stats;
if (FAILED(m_swapChain->GetFrameStatistics(&stats)))
- return false;
+ return GpDisplayDriverTickStatuses::kNonFatalFault;
if (stats.SyncQPCTime.QuadPart != 0)
{
@@ -440,12 +440,15 @@ bool GpDisplayDriverD3D11::PresentFrameAndSync()
m_frameTimeAccumulated += frameTimeStep;
while (m_frameTimeAccumulated >= m_frameTimeSliceSize)
{
- m_properties.m_tickFunc(m_properties.m_tickFuncContext, m_vosFiber);
+ GpDisplayDriverTickStatus_t tickStatus = m_properties.m_tickFunc(m_properties.m_tickFuncContext, m_vosFiber);
m_frameTimeAccumulated -= m_frameTimeSliceSize;
+
+ if (tickStatus != GpDisplayDriverTickStatuses::kOK)
+ return tickStatus;
}
}
- return true;
+ return GpDisplayDriverTickStatuses::kOK;
}
void GpDisplayDriverD3D11::SynchronizeCursors()
@@ -591,7 +594,9 @@ void GpDisplayDriverD3D11::Run()
}
else
{
- PresentFrameAndSync();
+ GpDisplayDriverTickStatus_t tickStatus = PresentFrameAndSync();
+ if (tickStatus == GpDisplayDriverTickStatuses::kFatalFault || tickStatus == GpDisplayDriverTickStatuses::kApplicationTerminated)
+ break;
}
}
diff --git a/GpDisplayDriver_D3D11/GpDisplayDriverD3D11.h b/GpDisplayDriver_D3D11/GpDisplayDriverD3D11.h
index 30e43e3..4dcdca8 100644
--- a/GpDisplayDriver_D3D11/GpDisplayDriverD3D11.h
+++ b/GpDisplayDriver_D3D11/GpDisplayDriverD3D11.h
@@ -70,7 +70,7 @@ private:
~GpDisplayDriverD3D11();
bool InitResources();
- bool PresentFrameAndSync();
+ GpDisplayDriverTickStatus_t PresentFrameAndSync();
void SynchronizeCursors();
void ChangeToCursor(HCURSOR cursor);
diff --git a/PortabilityLayer/PLStringCompare.cpp b/PortabilityLayer/PLStringCompare.cpp
index 67a5787..3f5aadb 100644
--- a/PortabilityLayer/PLStringCompare.cpp
+++ b/PortabilityLayer/PLStringCompare.cpp
@@ -2,69 +2,59 @@
#include "MacRoman.h"
#include
+#include
-Boolean EqualString(const PLPasStr &string1, const PLPasStr &string2, Boolean caseSensitive, Boolean diacriticSensitive)
-{
- const size_t len = string1.Length();
- if (len != string2.Length())
- return PL_FALSE;
-
- const uint8_t *chars1 = string1.UChars();
- const uint8_t *chars2 = string2.UChars();
-
- if (caseSensitive)
+namespace StrCmp
+{
+ int Compare(const PLPasStr &string1, const PLPasStr &string2)
{
- // Case sensitive
- if (diacriticSensitive)
- {
- // Diacritic sensitive
- return memcmp(chars1, chars2, len) ? PL_FALSE : PL_TRUE;
- }
+ const uint8_t *chars1 = string1.UChars();
+ const uint8_t *chars2 = string2.UChars();
+
+ const size_t len1 = string1.Length();
+ const size_t len2 = string1.Length();
+
+ const size_t shorterLen = std::min(len1, len2);
+
+ int memcmpResult = memcmp(chars1, chars2, shorterLen);
+
+ if (memcmpResult != 0)
+ return memcmpResult;
+
+ if (len1 < len2)
+ return -1;
+ else if (len2 < len1)
+ return 1;
else
- {
- // Diacritic insensitive
- for (size_t i = 0; i < len; i++)
- {
- const uint8_t c1 = chars1[i];
- const uint8_t c2 = chars2[i];
-
- if (PortabilityLayer::MacRoman::g_stripDiacritic[c1] != PortabilityLayer::MacRoman::g_stripDiacritic[c2])
- return PL_FALSE;
- }
-
- return PL_TRUE;
- }
+ return 0;
}
- else
+
+ int CompareCaseInsensitive(const PLPasStr &string1, const PLPasStr &string2)
{
- // Case insensitive
- if (diacriticSensitive)
+ const uint8_t *chars1 = string1.UChars();
+ const uint8_t *chars2 = string2.UChars();
+
+ const size_t len1 = string1.Length();
+ const size_t len2 = string1.Length();
+
+ const size_t shorterLen = std::min(len1, len2);
+
+ for (size_t i = 0; i < shorterLen; i++)
{
- // Diacritic sensitive
- for (size_t i = 0; i < len; i++)
- {
- const uint8_t c1 = chars1[i];
- const uint8_t c2 = chars2[i];
+ const uint8_t c1 = PortabilityLayer::MacRoman::g_toLower[chars1[i]];
+ const uint8_t c2 = PortabilityLayer::MacRoman::g_toLower[chars2[i]];
- if (PortabilityLayer::MacRoman::g_toLower[c1] != PortabilityLayer::MacRoman::g_toLower[c2])
- return PL_FALSE;
- }
-
- return PL_TRUE;
+ if (c1 < c2)
+ return -1;
+ if (c2 < c1)
+ return 1;
}
+
+ if (len1 < len2)
+ return -1;
+ else if (len2 < len1)
+ return 1;
else
- {
- // Diacritic insensitive
- for (size_t i = 0; i < len; i++)
- {
- const uint8_t c1 = PortabilityLayer::MacRoman::g_stripDiacritic[chars1[i]];
- const uint8_t c2 = PortabilityLayer::MacRoman::g_stripDiacritic[chars2[i]];
-
- if (PortabilityLayer::MacRoman::g_toLower[c1] != PortabilityLayer::MacRoman::g_toLower[c2])
- return PL_FALSE;
- }
-
- return PL_TRUE;
- }
+ return 0;
}
}
diff --git a/PortabilityLayer/PLStringCompare.h b/PortabilityLayer/PLStringCompare.h
index 2fd747f..7f3a2ce 100644
--- a/PortabilityLayer/PLStringCompare.h
+++ b/PortabilityLayer/PLStringCompare.h
@@ -1,10 +1,20 @@
#pragma once
-#ifndef __PL_STRINGCOMPARE_H__
-#define __PL_STRINGCOMPARE_H__
#include "PLCore.h"
#include "PLPasStr.h"
-
-Boolean EqualString(const PLPasStr &string1, const PLPasStr &string2, Boolean caseSensitive, Boolean diacriticSensitive);
-
-#endif
+
+namespace StrCmp
+{
+ int CompareCaseInsensitive(const PLPasStr &string1, const PLPasStr &string2);
+ int Compare(const PLPasStr &string1, const PLPasStr &string2);
+
+ inline bool EqualCaseInsensitive(const PLPasStr &string1, const PLPasStr &string2)
+ {
+ return CompareCaseInsensitive(string1, string2) == 0;
+ }
+
+ inline bool Equal(const PLPasStr &string1, const PLPasStr &string2)
+ {
+ return Compare(string1, string2) == 0;
+ }
+}
diff --git a/PortabilityLayer/WindowManager.cpp b/PortabilityLayer/WindowManager.cpp
index 6609bff..643d967 100644
--- a/PortabilityLayer/WindowManager.cpp
+++ b/PortabilityLayer/WindowManager.cpp
@@ -73,7 +73,8 @@ namespace PortabilityLayer
WindowImpl *m_windowStackBottom;
static WindowManagerImpl ms_instance;
- static Window ms_putInFront;
+
+ static uint8_t ms_putInFrontSentinel;
};
WindowImpl::WindowImpl()
@@ -335,7 +336,7 @@ namespace PortabilityLayer
Window *WindowManagerImpl::GetPutInFrontSentinel() const
{
- return &ms_putInFront;
+ return reinterpret_cast(&ms_putInFrontSentinel);
}
void WindowManagerImpl::RenderWindow(WindowImpl *window, IGpDisplayDriver *displayDriver)
@@ -356,7 +357,7 @@ namespace PortabilityLayer
}
WindowManagerImpl WindowManagerImpl::ms_instance;
- Window WindowManagerImpl::ms_putInFront;
+ uint8_t WindowManagerImpl::ms_putInFrontSentinel;
WindowManager *WindowManager::GetInstance()
{