2023-05-24 19:03:05 +02:00
|
|
|
/*
|
|
|
|
===========================================================================
|
|
|
|
Copyright (C) 2023 the OpenMoHAA team
|
|
|
|
|
|
|
|
This file is part of OpenMoHAA source code.
|
|
|
|
|
|
|
|
OpenMoHAA source code is free software; you can redistribute it
|
|
|
|
and/or modify it under the terms of the GNU General Public License as
|
|
|
|
published by the Free Software Foundation; either version 2 of the License,
|
|
|
|
or (at your option) any later version.
|
|
|
|
|
|
|
|
OpenMoHAA source code is distributed in the hope that it will be
|
|
|
|
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with OpenMoHAA source code; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
===========================================================================
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "../sys_local.h"
|
2023-05-25 19:09:32 +02:00
|
|
|
#include "../win_localization.h"
|
|
|
|
#include "../sys_loadlib.h"
|
2025-02-23 21:30:56 +01:00
|
|
|
#include "../sys_update_checker.h"
|
2023-05-24 19:03:05 +02:00
|
|
|
|
2024-09-21 19:32:23 +02:00
|
|
|
// a pointer to the last piece of data retrieved from the clipboard is stored here,
|
|
|
|
// so that it can be cleaned up when new data is retrieved, preventing memory leaks
|
|
|
|
static void* clipboard_text = NULL;
|
|
|
|
|
2023-05-24 19:03:05 +02:00
|
|
|
static void* game_library = NULL;
|
|
|
|
static void* cgame_library = NULL;
|
2023-05-26 23:32:27 +02:00
|
|
|
qboolean GLimp_SpawnRenderThread(void (*function)(void))
|
|
|
|
{
|
|
|
|
return qfalse;
|
|
|
|
}
|
|
|
|
|
|
|
|
void* GLimp_RendererSleep(void)
|
|
|
|
{
|
2023-08-25 23:00:05 +02:00
|
|
|
return NULL;
|
2023-05-26 23:32:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void GLimp_FrontEndSleep(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void GLimp_WakeRenderer(void* data)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
==============
|
|
|
|
Sys_ShowConsole
|
|
|
|
==============
|
|
|
|
*/
|
|
|
|
void Sys_ShowConsole(int visLevel, qboolean quitOnClose)
|
|
|
|
{
|
|
|
|
}
|
2023-05-24 19:03:05 +02:00
|
|
|
|
2023-05-26 20:53:00 +02:00
|
|
|
/*
|
|
|
|
==============
|
|
|
|
SaveRegistryInfo
|
2024-09-18 00:19:05 +02:00
|
|
|
|
|
|
|
Used to save product info stuff into the registry.
|
|
|
|
Not useful anymore, so no need to implement.
|
2023-05-26 20:53:00 +02:00
|
|
|
==============
|
|
|
|
*/
|
|
|
|
qboolean SaveRegistryInfo(qboolean user, const char* pszName, void* pvBuf, long lSize)
|
|
|
|
{
|
|
|
|
return qfalse;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
==============
|
|
|
|
LoadRegistryInfo
|
2024-09-18 00:19:05 +02:00
|
|
|
|
|
|
|
Used to load product info stuff from the registry.
|
|
|
|
Not useful anymore, so no need to implement.
|
2023-05-26 20:53:00 +02:00
|
|
|
==============
|
|
|
|
*/
|
|
|
|
qboolean LoadRegistryInfo(qboolean user, const char* pszName, void* pvBuf, long* plSize)
|
|
|
|
{
|
|
|
|
return qfalse;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
==============
|
|
|
|
IsFirstRun
|
2024-09-18 00:19:05 +02:00
|
|
|
|
|
|
|
Returns whether or not this is the first time the game is started.
|
|
|
|
Not used anymore.
|
2023-05-26 20:53:00 +02:00
|
|
|
==============
|
|
|
|
*/
|
|
|
|
qboolean IsFirstRun(void)
|
|
|
|
{
|
|
|
|
return qfalse;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
==============
|
|
|
|
IsNewConfig
|
2024-09-18 00:19:05 +02:00
|
|
|
|
|
|
|
Returns whether or not a new hardware change is detected.
|
|
|
|
Not used anymore.
|
2023-05-26 20:53:00 +02:00
|
|
|
==============
|
|
|
|
*/
|
|
|
|
qboolean IsNewConfig(void)
|
|
|
|
{
|
|
|
|
return qfalse;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
==============
|
|
|
|
IsSafeMode
|
2024-09-18 00:19:05 +02:00
|
|
|
|
|
|
|
Returns whether or not the game was started in safe mode.
|
|
|
|
Not used anymore.
|
2023-05-26 20:53:00 +02:00
|
|
|
==============
|
|
|
|
*/
|
|
|
|
qboolean IsSafeMode(void)
|
|
|
|
{
|
|
|
|
return qfalse;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
==============
|
|
|
|
ClearNewConfigFlag
|
|
|
|
==============
|
|
|
|
*/
|
|
|
|
void ClearNewConfigFlag(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
==============
|
|
|
|
Sys_GetWholeClipboard
|
|
|
|
==============
|
|
|
|
*/
|
|
|
|
const char* Sys_GetWholeClipboard(void)
|
|
|
|
{
|
2024-09-21 19:32:23 +02:00
|
|
|
#ifndef DEDICATED
|
|
|
|
char *data = NULL;
|
|
|
|
char *cliptext;
|
|
|
|
|
|
|
|
if ((cliptext = SDL_GetClipboardText()) != NULL) {
|
2024-10-18 22:14:45 +02:00
|
|
|
if (cliptext[0] != 0) {
|
2024-09-21 19:32:23 +02:00
|
|
|
// It's necessary to limit buffersize to 4096 as each character
|
|
|
|
// is pasted via CharEvent, which is very-very slow and jams up the EventQueue.
|
|
|
|
// A smaller buffer doesn't jam the EventQueue up as much and avoids dropping
|
|
|
|
// characters that otherwise happens when the EventQueue is overloaded.
|
|
|
|
// FIXME: speed up paste logic so this restriction can be removed
|
|
|
|
size_t bufsize = Q_min(strlen(cliptext) + 1, 4096);
|
|
|
|
|
|
|
|
if (clipboard_text != NULL) {
|
|
|
|
// clean up previously allocated clipboard buffer
|
|
|
|
Z_Free(clipboard_text);
|
|
|
|
clipboard_text = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
data = clipboard_text = Z_Malloc(bufsize);
|
|
|
|
// Changed in OPM:
|
|
|
|
// original game skips the Windows-specific '\r' (carriage return) char here!
|
|
|
|
Q_strncpyz(data, cliptext, bufsize);
|
|
|
|
}
|
|
|
|
SDL_free(cliptext);
|
|
|
|
}
|
|
|
|
return data;
|
|
|
|
#else
|
2023-05-26 20:53:00 +02:00
|
|
|
return NULL;
|
2024-09-21 19:32:23 +02:00
|
|
|
#endif
|
2023-05-26 20:53:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
==============
|
|
|
|
Sys_SetClipboard
|
|
|
|
==============
|
|
|
|
*/
|
2024-09-21 19:32:23 +02:00
|
|
|
void Sys_SetClipboard(const char *contents)
|
2023-05-26 20:53:00 +02:00
|
|
|
{
|
2024-09-21 19:32:23 +02:00
|
|
|
#ifndef DEDICATED
|
2024-10-18 22:14:45 +02:00
|
|
|
if (!contents || !contents[0]) {
|
2024-09-21 19:32:23 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
SDL_SetClipboardText(contents);
|
|
|
|
#endif
|
2023-05-26 20:53:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
RecoverLostAutodialData
|
2024-09-18 00:19:05 +02:00
|
|
|
|
|
|
|
This functions changes the current user setting so the modem
|
|
|
|
automatically dials up whenever an attempt to connect is detected.
|
|
|
|
|
|
|
|
There is no need to implement this anymore nowadays.
|
2023-05-26 20:53:00 +02:00
|
|
|
================
|
|
|
|
*/
|
|
|
|
void RecoverLostAutodialData(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
==============
|
|
|
|
Sys_CloseMutex
|
2024-09-18 00:19:05 +02:00
|
|
|
|
|
|
|
Closes the global mutex used to check if another instance is already running.
|
|
|
|
Not used anymore, as multiple instances could be useful for testing.
|
2023-05-26 20:53:00 +02:00
|
|
|
==============
|
|
|
|
*/
|
|
|
|
void Sys_CloseMutex(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2023-05-24 19:03:05 +02:00
|
|
|
/*
|
|
|
|
=================
|
|
|
|
Sys_UnloadGame
|
|
|
|
=================
|
|
|
|
*/
|
|
|
|
void Sys_UnloadGame(void)
|
|
|
|
{
|
|
|
|
Com_Printf("------ Unloading Game ------\n");
|
|
|
|
|
|
|
|
if (game_library) {
|
|
|
|
Sys_UnloadLibrary(game_library);
|
|
|
|
}
|
|
|
|
|
|
|
|
game_library = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
=================
|
|
|
|
Sys_GetGameAPI
|
|
|
|
=================
|
|
|
|
*/
|
|
|
|
void* Sys_GetGameAPI(void* parms)
|
|
|
|
{
|
|
|
|
void* (*GetGameAPI) (void*);
|
2024-11-29 20:59:47 +01:00
|
|
|
const char* gamename = "game" ARCH_SUFFIX DLL_SUFFIX DLL_EXT;
|
2023-05-24 19:03:05 +02:00
|
|
|
|
|
|
|
if (game_library)
|
|
|
|
Com_Error(ERR_FATAL, "Sys_GetGameAPI without calling Sys_UnloadGame");
|
|
|
|
|
2023-08-25 23:00:05 +02:00
|
|
|
game_library = Sys_LoadDll(gamename, qfalse);
|
2023-05-24 19:03:05 +02:00
|
|
|
|
|
|
|
//Still couldn't find it.
|
|
|
|
if (!game_library) {
|
2023-08-25 23:00:05 +02:00
|
|
|
Com_Printf("Sys_GetGameAPI(%s) failed: \"%s\"\n", gamename, Sys_LibraryError());
|
2023-05-24 19:03:05 +02:00
|
|
|
Com_Error(ERR_FATAL, "Couldn't load game");
|
|
|
|
}
|
|
|
|
|
2023-08-25 23:00:05 +02:00
|
|
|
Com_Printf("Sys_GetGameAPI(%s): succeeded ...\n", gamename);
|
2023-05-24 19:03:05 +02:00
|
|
|
GetGameAPI = (void* (*)(void*))Sys_LoadFunction(game_library, "GetGameAPI");
|
|
|
|
|
|
|
|
if (!GetGameAPI)
|
|
|
|
{
|
|
|
|
Sys_UnloadGame();
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return GetGameAPI(parms);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
=================
|
|
|
|
Sys_UnloadCGame
|
|
|
|
=================
|
|
|
|
*/
|
|
|
|
void Sys_UnloadCGame(void)
|
|
|
|
{
|
|
|
|
Com_Printf("------ Unloading ClientGame ------\n");
|
|
|
|
|
|
|
|
if (cgame_library) {
|
|
|
|
Sys_UnloadLibrary(cgame_library);
|
|
|
|
}
|
|
|
|
|
|
|
|
cgame_library = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
=================
|
|
|
|
Sys_GetCGameAPI
|
|
|
|
=================
|
|
|
|
*/
|
|
|
|
void* Sys_GetCGameAPI(void* parms)
|
|
|
|
{
|
|
|
|
void* (*GetCGameAPI) (void*);
|
2024-11-29 20:59:47 +01:00
|
|
|
const char* gamename = "cgame" ARCH_SUFFIX DLL_SUFFIX DLL_EXT;
|
2023-05-24 19:03:05 +02:00
|
|
|
|
|
|
|
if (cgame_library)
|
|
|
|
Com_Error(ERR_FATAL, "Sys_GetCGameAPI without calling Sys_UnloadCGame");
|
|
|
|
|
2023-08-25 23:00:05 +02:00
|
|
|
cgame_library = Sys_LoadDll(gamename, qfalse);
|
2023-05-24 19:03:05 +02:00
|
|
|
|
|
|
|
//Still couldn't find it.
|
|
|
|
if (!cgame_library) {
|
2023-08-25 23:00:05 +02:00
|
|
|
Com_Printf("Sys_GetCGameAPI(%s) failed: \"%s\"\n", gamename, Sys_LibraryError());
|
2023-05-24 19:03:05 +02:00
|
|
|
Com_Error(ERR_FATAL, "Couldn't load game");
|
|
|
|
}
|
|
|
|
|
2023-08-25 23:00:05 +02:00
|
|
|
Com_Printf("Sys_GetCGameAPI(%s): succeeded ...\n", gamename);
|
2023-05-24 19:03:05 +02:00
|
|
|
GetCGameAPI = (void* (*)(void*))Sys_LoadFunction(cgame_library, "GetCGameAPI");
|
|
|
|
|
|
|
|
if (!GetCGameAPI)
|
|
|
|
{
|
|
|
|
Sys_UnloadCGame();
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return GetCGameAPI(parms);
|
|
|
|
}
|
|
|
|
|
2023-05-25 19:34:01 +02:00
|
|
|
void VM_Forced_Unload_Start(void) {
|
|
|
|
}
|
|
|
|
|
|
|
|
void VM_Forced_Unload_Done(void) {
|
|
|
|
}
|
|
|
|
|
2023-05-24 19:03:05 +02:00
|
|
|
void Sys_InitEx()
|
|
|
|
{
|
|
|
|
Sys_InitLocalization();
|
2025-02-23 21:30:56 +01:00
|
|
|
Sys_UpdateChecker_Init();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Sys_ShutdownEx()
|
|
|
|
{
|
|
|
|
Sys_UpdateChecker_Shutdown();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Sys_ProcessBackgroundTasks()
|
|
|
|
{
|
|
|
|
Sys_UpdateChecker_Process();
|
2023-05-24 19:03:05 +02:00
|
|
|
}
|