2018-04-17 02:43:27 +02:00
|
|
|
/*
|
2018-05-01 20:51:43 +02:00
|
|
|
lib_common.c - common dynamic library code
|
|
|
|
Copyright (C) 2018 Flying With Gauss
|
2018-04-17 02:43:27 +02:00
|
|
|
|
|
|
|
This program 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 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "common.h"
|
|
|
|
#include "library.h"
|
|
|
|
#include "filesystem.h"
|
|
|
|
#include "server.h"
|
|
|
|
|
2018-05-01 20:51:43 +02:00
|
|
|
static char s_szLastError[1024] = "";
|
|
|
|
|
2018-04-17 02:43:27 +02:00
|
|
|
const char *COM_GetLibraryError()
|
|
|
|
{
|
2018-05-01 20:51:43 +02:00
|
|
|
return s_szLastError;
|
2018-04-17 02:43:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void COM_ResetLibraryError()
|
|
|
|
{
|
2018-05-01 20:51:43 +02:00
|
|
|
s_szLastError[0] = 0;
|
2018-04-17 02:43:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void COM_PushLibraryError( const char *error )
|
|
|
|
{
|
2018-05-01 20:51:43 +02:00
|
|
|
Q_strncat( s_szLastError, error, sizeof( s_szLastError ) );
|
|
|
|
Q_strncat( s_szLastError, "\n", sizeof( s_szLastError ) );
|
2018-04-17 02:43:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void *COM_FunctionFromName_SR( void *hInstance, const char *pName )
|
|
|
|
{
|
|
|
|
#ifdef XASH_ALLOW_SAVERESTORE_OFFSETS
|
|
|
|
if( !Q_memcmp( pName, "ofs:",4 ) )
|
|
|
|
return svgame.dllFuncs.pfnGameInit + Q_atoi(pName + 4);
|
|
|
|
#endif
|
|
|
|
return COM_FunctionFromName( hInstance, pName );
|
|
|
|
}
|
|
|
|
|
2018-05-01 20:51:43 +02:00
|
|
|
const char *COM_OffsetNameForFunction( void *function )
|
2018-04-17 02:43:27 +02:00
|
|
|
{
|
|
|
|
static string sname;
|
2018-06-14 19:32:31 +02:00
|
|
|
Q_snprintf( sname, MAX_STRING, "ofs:%d", (size_t)((byte*)function - (byte*)svgame.dllFuncs.pfnGameInit) );
|
2018-10-27 23:39:29 +02:00
|
|
|
Con_Reportf( "COM_OffsetNameForFunction %s\n", sname );
|
2018-04-17 02:43:27 +02:00
|
|
|
return sname;
|
|
|
|
}
|