1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337
|
/*
===========================================================================
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"
#include "../win_localization.h"
#include "../sys_loadlib.h"
#include "../sys_curl.h"
#include "../sys_update_checker.h"
// 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;
static void* game_library = NULL;
static void* cgame_library = NULL;
qboolean GLimp_SpawnRenderThread(void (*function)(void))
{
return qfalse;
}
void* GLimp_RendererSleep(void)
{
return NULL;
}
void GLimp_FrontEndSleep(void)
{
}
void GLimp_WakeRenderer(void* data)
{
}
/*
==============
Sys_ShowConsole
==============
*/
void Sys_ShowConsole(int visLevel, qboolean quitOnClose)
{
}
/*
==============
SaveRegistryInfo
Used to save product info stuff into the registry.
Not useful anymore, so no need to implement.
==============
*/
qboolean SaveRegistryInfo(qboolean user, const char* pszName, void* pvBuf, long lSize)
{
return qfalse;
}
/*
==============
LoadRegistryInfo
Used to load product info stuff from the registry.
Not useful anymore, so no need to implement.
==============
*/
qboolean LoadRegistryInfo(qboolean user, const char* pszName, void* pvBuf, long* plSize)
{
return qfalse;
}
/*
==============
IsFirstRun
Returns whether or not this is the first time the game is started.
Not used anymore.
==============
*/
qboolean IsFirstRun(void)
{
return qfalse;
}
/*
==============
IsNewConfig
Returns whether or not a new hardware change is detected.
Not used anymore.
==============
*/
qboolean IsNewConfig(void)
{
return qfalse;
}
/*
==============
IsSafeMode
Returns whether or not the game was started in safe mode.
Not used anymore.
==============
*/
qboolean IsSafeMode(void)
{
return qfalse;
}
/*
==============
ClearNewConfigFlag
==============
*/
void ClearNewConfigFlag(void)
{
}
/*
==============
Sys_GetWholeClipboard
==============
*/
const char* Sys_GetWholeClipboard(void)
{
#ifndef DEDICATED
char *data = NULL;
char *cliptext;
if ((cliptext = SDL_GetClipboardText()) != NULL) {
if (cliptext[0] != 0) {
// 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
return NULL;
#endif
}
/*
==============
Sys_SetClipboard
==============
*/
void Sys_SetClipboard(const char *contents)
{
#ifndef DEDICATED
if (!contents || !contents[0]) {
return;
}
SDL_SetClipboardText(contents);
#endif
}
/*
================
RecoverLostAutodialData
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.
================
*/
void RecoverLostAutodialData(void)
{
}
/*
==============
Sys_CloseMutex
Closes the global mutex used to check if another instance is already running.
Not used anymore, as multiple instances could be useful for testing.
==============
*/
void Sys_CloseMutex(void)
{
}
/*
=================
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*);
const char* gamename = "game" DLL_SUFFIX DLL_EXT;
if (game_library)
Com_Error(ERR_FATAL, "Sys_GetGameAPI without calling Sys_UnloadGame");
game_library = Sys_LoadDll(gamename, qfalse);
//Still couldn't find it.
if (!game_library) {
Com_Printf("Sys_GetGameAPI(%s) failed: \"%s\"\n", gamename, Sys_LibraryError());
Com_Error(ERR_FATAL, "Couldn't load game");
}
Com_Printf("Sys_GetGameAPI(%s): succeeded ...\n", gamename);
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*);
const char* gamename = "cgame" DLL_SUFFIX DLL_EXT;
if (cgame_library)
Com_Error(ERR_FATAL, "Sys_GetCGameAPI without calling Sys_UnloadCGame");
cgame_library = Sys_LoadDll(gamename, qfalse);
//Still couldn't find it.
if (!cgame_library) {
Com_Printf("Sys_GetCGameAPI(%s) failed: \"%s\"\n", gamename, Sys_LibraryError());
Com_Error(ERR_FATAL, "Couldn't load game");
}
Com_Printf("Sys_GetCGameAPI(%s): succeeded ...\n", gamename);
GetCGameAPI = (void* (*)(void*))Sys_LoadFunction(cgame_library, "GetCGameAPI");
if (!GetCGameAPI)
{
Sys_UnloadCGame();
return NULL;
}
return GetCGameAPI(parms);
}
void VM_Forced_Unload_Start(void) {
}
void VM_Forced_Unload_Done(void) {
}
void Sys_InitEx()
{
Sys_InitLocalization();
Sys_InitCurl();
Sys_UpdateChecker_Init();
}
void Sys_ShutdownEx()
{
Sys_UpdateChecker_Shutdown();
Sys_ShutdownCurl();
}
void Sys_ProcessBackgroundTasks()
{
Sys_UpdateChecker_Process();
}
|