summaryrefslogtreecommitdiffstats
path: root/src/skel
diff options
context:
space:
mode:
Diffstat (limited to 'src/skel')
-rw-r--r--src/skel/crossplatform.cpp43
-rw-r--r--src/skel/glfw/glfw.cpp18
-rw-r--r--src/skel/win/win.cpp18
3 files changed, 48 insertions, 31 deletions
diff --git a/src/skel/crossplatform.cpp b/src/skel/crossplatform.cpp
index ac4bbe85..f2f9d5ee 100644
--- a/src/skel/crossplatform.cpp
+++ b/src/skel/crossplatform.cpp
@@ -26,34 +26,35 @@ void GetLocalTime_CP(SYSTEMTIME *out) {
// Compatible with Linux/POSIX and MinGW on Windows
#ifndef _WIN32
HANDLE FindFirstFile(const char* pathname, WIN32_FIND_DATA* firstfile) {
- char newpathname[32];
-
- strncpy(newpathname, pathname, 32);
- char* path = strtok(newpathname, "*");
+ char pathCopy[MAX_PATH];
+ strcpy(pathCopy, pathname);
+
+ char *folder = strtok(pathCopy, "*");
+ char *extension = strtok(NULL, "*");
+
+ // because strtok doesn't return NULL for last delimiter
+ if (extension - folder == strlen(pathname))
+ extension = nil;
// Case-sensitivity and backslashes...
- char *real = casepath(path);
- if (real) {
- real[strlen(real)] = '*';
- char *extension = strtok(NULL, "*");
- if (extension)
- strcat(real, extension);
-
- strncpy(newpathname, real, 32);
- free(real);
- path = strtok(newpathname, "*");
+ // Will be freed at the bottom
+ char *realFolder = casepath(folder);
+ if (realFolder) {
+ folder = realFolder;
}
-
- strncpy(firstfile->folder, path, sizeof(firstfile->folder));
- // Both w/ extension and w/o extension is ok
- if (strlen(path) + 1 != strlen(pathname))
- strncpy(firstfile->extension, strtok(NULL, "*"), sizeof(firstfile->extension));
+ strncpy(firstfile->folder, folder, sizeof(firstfile->folder));
+
+ if (extension)
+ strncpy(firstfile->extension, extension, sizeof(firstfile->extension));
else
- strncpy(firstfile->extension, "", sizeof(firstfile->extension));
+ firstfile->extension[0] = '\0';
+
+ if (realFolder)
+ free(realFolder);
HANDLE d;
- if ((d = (HANDLE)opendir(path)) == NULL || !FindNextFile(d, firstfile))
+ if ((d = (HANDLE)opendir(firstfile->folder)) == NULL || !FindNextFile(d, firstfile))
return NULL;
return d;
diff --git a/src/skel/glfw/glfw.cpp b/src/skel/glfw/glfw.cpp
index 118ed950..4d41a900 100644
--- a/src/skel/glfw/glfw.cpp
+++ b/src/skel/glfw/glfw.cpp
@@ -418,7 +418,7 @@ psInitialize(void)
}
else if ( verInfo.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS )
{
- if ( verInfo.dwMajorVersion > 4 || verInfo.dwMajorVersion == 4 && verInfo.dwMinorVersion == 1 )
+ if ( verInfo.dwMajorVersion > 4 || verInfo.dwMajorVersion == 4 && verInfo.dwMinorVersion != 0 )
{
debug("Operating System is Win98\n");
_dwOperatingSystemVersion = OS_WIN98;
@@ -847,7 +847,8 @@ bool IsThisJoystickBlacklisted(int i)
const char* joyname = glfwGetJoystickName(i);
- if (strncmp(joyname, gSelectedJoystickName, strlen(gSelectedJoystickName)) == 0)
+ if (gSelectedJoystickName[0] != '\0' &&
+ strncmp(joyname, gSelectedJoystickName, strlen(gSelectedJoystickName)) == 0)
return false;
return true;
@@ -1219,14 +1220,17 @@ void resizeCB(GLFWwindow* window, int width, int height) {
* memory things don't work.
*/
/* redraw window */
- if (RwInitialised && (gGameState == GS_PLAYING_GAME
#ifndef MASTER
- || gGameState == GS_ANIMVIEWER
-#endif
- ))
+ if (RwInitialised && (gGameState == GS_PLAYING_GAME || gGameState == GS_ANIMVIEWER))
{
- RsEventHandler((gGameState == GS_PLAYING_GAME ? rsIDLE : rsANIMVIEWER), (void*)TRUE);
+ RsEventHandler((gGameState == GS_PLAYING_GAME ? rsIDLE : rsANIMVIEWER), (void *)TRUE);
}
+#else
+ if (RwInitialised && gGameState == GS_PLAYING_GAME)
+ {
+ RsEventHandler(rsIDLE, (void *)TRUE);
+ }
+#endif
if (RwInitialised && height > 0 && width > 0) {
RwRect r;
diff --git a/src/skel/win/win.cpp b/src/skel/win/win.cpp
index ac46d23a..9effaa31 100644
--- a/src/skel/win/win.cpp
+++ b/src/skel/win/win.cpp
@@ -684,7 +684,7 @@ psInitialize(void)
}
else if ( verInfo.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS )
{
- if ( verInfo.dwMajorVersion > 4 || verInfo.dwMajorVersion == 4 && verInfo.dwMinorVersion == 1 )
+ if ( verInfo.dwMajorVersion > 4 || verInfo.dwMajorVersion == 4 && verInfo.dwMinorVersion != 0 )
{
debug("Operating System is Win98\n");
_dwOperatingSystemVersion = OS_WIN98;
@@ -1012,11 +1012,17 @@ MainWndProc(HWND window, UINT message, WPARAM wParam, LPARAM lParam)
RECT rect;
/* redraw window */
+#ifndef MASTER
if (RwInitialised && (gGameState == GS_PLAYING_GAME || gGameState == GS_ANIMVIEWER))
{
RsEventHandler((gGameState == GS_PLAYING_GAME ? rsIDLE : rsANIMVIEWER), (void *)TRUE);
}
-
+#else
+ if (RwInitialised && gGameState == GS_PLAYING_GAME)
+ {
+ RsEventHandler(rsIDLE, (void *)TRUE);
+ }
+#endif
/* Manually resize window */
rect.left = rect.top = 0;
rect.bottom = newPos->bottom - newPos->top;
@@ -1369,14 +1375,20 @@ UINT GetBestRefreshRate(UINT width, UINT height, UINT depth)
#endif
if ( mode.Width == width && mode.Height == height && mode.Format == format )
{
- if ( mode.RefreshRate == 0 )
+ if ( mode.RefreshRate == 0 ) {
+ // From VC
+#ifdef FIX_BUGS
+ d3d->Release();
+#endif
return 0;
+ }
if ( mode.RefreshRate < refreshRate && mode.RefreshRate >= 60 )
refreshRate = mode.RefreshRate;
}
}
+ // From VC
#ifdef FIX_BUGS
d3d->Release();
#endif