ported to Android CS 1.6

fixed console spam with yb_quota when no waypoints on map
fixed autovacate feature once again
This commit is contained in:
jeefo 2015-12-26 01:31:46 +03:00
commit 579971c5ff
6 changed files with 57 additions and 39 deletions

View file

@ -84,11 +84,15 @@ using namespace Math;
#include <netdb.h>
#include <arpa/inet.h>
#define DLL_ENTRYPOINT void _fini (void)
#define DLL_ENTRYPOINT __attribute__((destructor)) void _fini (void)
#define DLL_DETACHING TRUE
#define DLL_RETENTRY return
#define DLL_GIVEFNPTRSTODLL extern "C" void __attribute__((visibility("default")))
#if defined (__ANDROID__)
#define PLATFORM_ANDROID 1
#endif
typedef int (*EntityAPI_t) (gamefuncs_t *, int);
typedef int (*NewEntityAPI_t) (newgamefuncs_t *, int *);
typedef int (*BlendAPI_t) (int, void **, void *, float (*)[3][4], float (*)[128][3][4]);

View file

@ -201,27 +201,29 @@ namespace Math
// sin - Output for Sine.
// cos - Output for Cosine.
//
static inline void SineCosine (float rad, float *sin, float *cos)
static inline void SineCosine (float rad, float *sine, float *cosine)
{
#if defined (_WIN32) && defined (_MSC_VER)
__asm
{
fld dword ptr[rad]
fsincos
mov ebx, [cos]
mov ebx, [cosine]
fstp dword ptr[ebx]
mov ebx, [sin]
mov ebx, [sine]
fstp dword ptr[ebx]
}
#elif defined (__ANDROID__)
*sine = sinf (rad);
*cosine = cosf (rad);
#elif defined (__linux__) || defined (GCC) || defined (__APPLE__)
register double _cos, _sin;
__asm __volatile__ ("fsincos" : "=t" (_cos), "=u" (_sin) : "0" (rad));
*cos = _cos;
*sin = _sin;
*cosine = _cos;
*sine = _sin;
#else
*sin = sinf (rad);
*cos = cosf (rad);
#error "SineConsine not defined."
#endif
}

View file

@ -4933,11 +4933,23 @@ void Bot::BotAI (void)
pev->button |= IN_MOVELEFT;
}
if (!IsEntityNull (g_hostEntity) && yb_debug.GetInt () >= 1)
{
int specIndex = g_hostEntity->v.iuser2;
bool displayDebugOverlay = false;
if (specIndex == IndexOfEntity (GetEntity ()))
if (g_hostEntity->v.iuser2 == IndexOfEntity (GetEntity ()))
displayDebugOverlay = true;
if (!displayDebugOverlay && yb_debug.GetInt () >= 2)
{
Bot *nearest = NULL;
if (FindNearestPlayer (reinterpret_cast <void **> (&nearest), g_hostEntity, 128.0f, true, true, true, true) && nearest == this)
displayDebugOverlay = true;
}
if (displayDebugOverlay)
{
static float timeDebugUpdate = 0.0f;
static int index, goal, taskID;

View file

@ -1076,7 +1076,7 @@ int ClientConnect (edict_t *ent, const char *name, const char *addr, char reject
extern ConVar yb_autovacate;
extern ConVar yb_quota;
if (yb_autovacate.GetBool () && !IsValidBot (ent))
if (yb_autovacate.GetBool () && !IsValidBot (ent) && ent != g_hostEntity)
bots.RemoveRandom ();
if (g_isMetamod)
@ -1101,7 +1101,7 @@ void ClientDisconnect (edict_t *ent)
extern ConVar yb_autovacate;
extern ConVar yb_quota;
if (yb_autovacate.GetBool () && IsValidPlayer (ent) && !IsValidBot (ent) && yb_quota.GetInt () < GetMaxClients () - 1)
if (yb_autovacate.GetBool () && IsValidPlayer (ent) && !IsValidBot (ent) && ent != g_hostEntity && yb_quota.GetInt () < GetMaxClients () - 1)
bots.AddRandom ();
int i = IndexOfEntity (ent) - 1;
@ -3016,6 +3016,26 @@ DLL_GIVEFNPTRSTODLL GiveFnptrsToDll (enginefuncs_t *functionTable, globalvars_t
// register our cvars
convars.PushRegisteredConVarsToEngine ();
#ifdef PLATFORM_ANDROID
g_gameVersion = CSV_OLD; // temporary, until opensource client dll get BotVoice message
if (g_isMetamod)
return; // we should stop the attempt for loading the real gamedll, since metamod handle this for us
#ifdef LOAD_HARDFP
#define GAME_SERVER_DLL "libserver_hardfp.so"
#else
#define GAME_SERVER_DLL "libserver.so"
#endif
char gameDLLName[256];
snprintf (gameDLLName, sizeof (gameDLLName), "%s/%s", getenv ("XASH3D_GAMELIBDIR"), GAME_SERVER_DLL);
g_gameLib = new Library (gameDLLName);
if (!g_gameLib->IsLoaded ())
AddLogEntry (true, LL_FATAL | LL_IGNORE, "Unable to load gamedll \"%s\". Exiting... (gamedir: %s)", gameDLLName, GetModName ());
#else
static struct ModSupport
{
char name[10];
@ -3075,35 +3095,12 @@ DLL_GIVEFNPTRSTODLL GiveFnptrsToDll (enginefuncs_t *functionTable, globalvars_t
);
g_gameLib = new Library (gameDLLName);
if (!g_gameLib->IsLoaded ())
{
// try to extract the game dll out of the steam cache
AddLogEntry (true, LL_WARNING | LL_IGNORE, "Trying to extract dll '%s' out of the steam cache", gameDLLName);
int size;
unsigned char *buffer = (*g_engfuncs.pfnLoadFileForMe) (gameDLLName, &size);
if (buffer)
{
CreatePath (const_cast <char *> (FormatBuffer ("%s/dlls", GetModName ())));
File fp (gameDLLName, "wb");
if (fp.IsValid ())
{
// dump the game dll file and then close it
fp.Write (buffer, size);
fp.Close ();
}
FREE_FILE (buffer);
}
g_gameLib->LoadLib (gameDLLName);
if (!g_gameLib->IsLoaded ())
AddLogEntry (true, LL_FATAL | LL_IGNORE, "Unable to load gamedll \"%s\". Exiting... (gamedir: %s)", gameDLLName, GetModName ());
}
}
else
AddLogEntry (true, LL_FATAL | LL_IGNORE, "Mod that you has started, not supported by this bot (gamedir: %s)", GetModName ());
#endif
g_funcPointers = g_gameLib->GetFuncAddr <FuncPointers_t> ("GiveFnptrsToDll");
g_entityAPI = g_gameLib->GetFuncAddr <EntityAPI_t> ("GetEntityAPI");

View file

@ -341,6 +341,9 @@ void BotManager::MaintainBotQuota (void)
// this function keeps number of bots up to date, and don't allow to maintain bot creation
// while creation process in process.
if (g_numWaypoints < 1 || g_waypointsChanged)
return;
if (yb_join_after_player.GetInt () > 0 && GetHumansJoinedTeam () == 0)
{
RemoveAll (false);

View file

@ -984,7 +984,7 @@ void Waypoint::InitVisibilityTab (void)
m_visibilityIndex = 0;
m_redoneVisibility = true;
AddLogEntry (true, LL_DEFAULT, "Vistable, not exists, vistable will be rebuilded");
AddLogEntry (true, LL_DEFAULT, "Vistable doesn't, vistable will be rebuilded");
return;
}