diff --git a/include/core.h b/include/core.h index ef9f421..01840b9 100644 --- a/include/core.h +++ b/include/core.h @@ -84,11 +84,15 @@ using namespace Math; #include #include - #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]); diff --git a/include/corelib.h b/include/corelib.h index 0626d82..5b5ba5b 100644 --- a/include/corelib.h +++ b/include/corelib.h @@ -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 (__linux__) || defined (GCC) || defined (__APPLE__) +#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 } diff --git a/source/basecode.cpp b/source/basecode.cpp index 0a682bb..f7c58e9 100644 --- a/source/basecode.cpp +++ b/source/basecode.cpp @@ -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 (&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; diff --git a/source/interface.cpp b/source/interface.cpp index 3de3f52..bb190dc 100644 --- a/source/interface.cpp +++ b/source/interface.cpp @@ -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]; @@ -3076,34 +3096,11 @@ 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 (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 ()); - } + 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 ("GiveFnptrsToDll"); g_entityAPI = g_gameLib->GetFuncAddr ("GetEntityAPI"); diff --git a/source/manager.cpp b/source/manager.cpp index cefe427..e49b9e3 100644 --- a/source/manager.cpp +++ b/source/manager.cpp @@ -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); diff --git a/source/waypoint.cpp b/source/waypoint.cpp index 9009ac5..640affd 100644 --- a/source/waypoint.cpp +++ b/source/waypoint.cpp @@ -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; }