diff --git a/include/corelib.h b/include/corelib.h index 9666868..024aa95 100644 --- a/include/corelib.h +++ b/include/corelib.h @@ -203,7 +203,7 @@ namespace Math // static inline void SineCosine (float rad, float *sine, float *cosine) { -#if defined (_WIN32) && defined (_MSC_VER) +#if defined (_WIN32) && defined (_MSC_VER) && !defined (__clang__) __asm { fld dword ptr[rad] @@ -223,7 +223,8 @@ namespace Math *cosine = _cos; *sine = _sin; #else - #error "SineConsine not defined." + *sine = sinf (rad); + *cosine = cosf (rad); #endif } @@ -616,7 +617,7 @@ public: // inline static const Vector &GetZero (void) { - static const Vector &s_zero = Vector (0.0f, 0.0f, 0.0f); + static const Vector s_zero = Vector (0.0f, 0.0f, 0.0f); return s_zero; } @@ -2754,21 +2755,6 @@ public: return strcmp (m_bufferPtr, string.m_bufferPtr); } - // - // Function: CompareI - // Compares string with other string without case check. - // - // Parameters: - // string - String t compare with. - // - // Returns: - // Zero if they are equal. - // - int CompareI (String &string) const - { - return strcmpi (m_bufferPtr, string.m_bufferPtr); - } - // // Function: Compare // Compares string with other string. @@ -2784,21 +2770,6 @@ public: return strcmp (m_bufferPtr, str); } - // - // Function: CompareI - // Compares string with other string without case check. - // - // Parameters: - // str - String to compare with. - // - // Returns: - // Zero if they are equal. - // - int CompareI (const char *str) const - { - return stricmp (m_bufferPtr, str); - } - // // Function: Collate // Collate the string. diff --git a/project/yapb.vcxproj b/project/yapb.vcxproj index c308152..aa5f5aa 100644 --- a/project/yapb.vcxproj +++ b/project/yapb.vcxproj @@ -30,9 +30,7 @@ - - Level4 - + @@ -180,23 +178,17 @@ AnySuitable - true + false Speed false ..\mmgr;..\include\engine;..\include;%(AdditionalIncludeDirectories) NDEBUG;WIN32;%(PreprocessorDefinitions) - true false - MultiThreaded - false StreamingSIMDExtensions2 - false - false - NotUsing - core.h + + .\release\inf\yapb.pch .\release\asm\ - .\release\obj\ .\release\inf\ Level4 true @@ -209,9 +201,11 @@ Full AVXI AVXI - false - false false + + true + true + MultiThreaded NDEBUG;%(PreprocessorDefinitions) @@ -228,7 +222,7 @@ .\release\yapb.dll true user32.dll;ws2_32.dll;%(DelayLoadDLLs) - false + Debug false Windows false @@ -245,6 +239,7 @@ Default + true diff --git a/source/basecode.cpp b/source/basecode.cpp index 2ff9092..00f409f 100644 --- a/source/basecode.cpp +++ b/source/basecode.cpp @@ -1242,7 +1242,7 @@ void Bot::CheckMessageQueue (void) } } - if (m_radioSelect != Radio_ReportingIn && g_radioInsteadVoice || yb_communication_type.GetInt () != 2 || g_chatterFactory[m_radioSelect].IsEmpty () || g_gameVersion == CSV_OLD) + if ((m_radioSelect != Radio_ReportingIn && g_radioInsteadVoice) || yb_communication_type.GetInt () != 2 || g_chatterFactory[m_radioSelect].IsEmpty () || g_gameVersion == CSV_OLD) { if (m_radioSelect < Radio_GoGoGo) FakeClientCommand (GetEntity (), "radio1"); @@ -2128,29 +2128,25 @@ void Bot::PushTask (TaskID id, float desire, int data, float time, bool resume) DeleteSearchNodes (); IgnoreCollisionShortly (); + int taskId = GetTaskId (); + // leader bot? - if (m_isLeader && GetTaskId () == TASK_SEEKCOVER) + if (m_isLeader && taskId == TASK_SEEKCOVER) CommandTeam (); // reorganize team if fleeing - if (GetTaskId () == TASK_CAMP) + if (taskId == TASK_CAMP) SelectBestWeapon (); // this is best place to handle some voice commands report team some info if (Random.Long (0, 100) < 95) { - switch (GetTaskId ()) - { - case TASK_BLINDED: + if (taskId == TASK_BLINDED) InstantChatterMessage (Chatter_GotBlinded); - break; - - case TASK_PLANTBOMB: + else if (taskId == TASK_PLANTBOMB) InstantChatterMessage (Chatter_PlantingC4); - break; - } } - if (Random.Long (0, 100) < 80 && GetTaskId () == TASK_CAMP) + if (Random.Long (0, 100) < 80 && taskId == TASK_CAMP) { if ((g_mapType & MAP_DE) && g_bombPlanted) ChatterMessage (Chatter_GuardDroppedC4); @@ -4440,6 +4436,10 @@ void Bot::RunTask_PickupItem () switch (m_pickupType) { + case PICKUP_DROPPED_C4: + case PICKUP_NONE: + break; + case PICKUP_WEAPON: m_aimFlags |= AIM_NAVPOINT; diff --git a/source/chatlib.cpp b/source/chatlib.cpp index 9720c12..9f084de 100644 --- a/source/chatlib.cpp +++ b/source/chatlib.cpp @@ -15,8 +15,8 @@ void StripTags (char *buffer) { // this function strips 'clan' tags specified below in given string buffer - char *tagOpen[] = {"-=", "-[", "-]", "-}", "-{", "<[", "<]", "[-", "]-", "{-", "}-", "[[", "[", "{", "]", "}", "<", ">", "-", "|", "=", "+", "(", ")"}; - char *tagClose[] = {"=-", "]-", "[-", "{-", "}-", "]>", "[>", "-]", "-[", "-}", "-{", "]]", "]", "}", "[", "{", ">", "<", "-", "|", "=", "+", ")", "("}; + const char *tagOpen[] = {"-=", "-[", "-]", "-}", "-{", "<[", "<]", "[-", "]-", "{-", "}-", "[[", "[", "{", "]", "}", "<", ">", "-", "|", "=", "+", "(", ")"}; + const char *tagClose[] = {"=-", "]-", "[-", "{-", "}-", "]>", "[>", "-]", "-[", "-}", "-{", "]]", "]", "}", "[", "{", ">", "<", "-", "|", "=", "+", ")", "("}; int index, fieldStart, fieldStop, i; int length = strlen (buffer); // get length of string diff --git a/source/combat.cpp b/source/combat.cpp index efcd2f7..67f3ac5 100644 --- a/source/combat.cpp +++ b/source/combat.cpp @@ -869,7 +869,7 @@ WeaponSelectEnd: { if (distance >= 750.0f && !IsShieldDrawn ()) pev->button |= IN_ATTACK2; // draw the shield - else if (IsShieldDrawn () || (!IsEntityNull (m_enemy) && (m_enemy->v.button & IN_RELOAD) || !IsEnemyViewable(m_enemy))) + else if (IsShieldDrawn () || (!IsEntityNull (m_enemy) && ((m_enemy->v.button & IN_RELOAD) || !IsEnemyViewable(m_enemy)))) pev->button |= IN_ATTACK2; // draw out the shield m_shieldCheckTime = GetWorldTime () + 1.0f; diff --git a/source/interface.cpp b/source/interface.cpp index f291263..e3ffd5c 100644 --- a/source/interface.cpp +++ b/source/interface.cpp @@ -2206,9 +2206,6 @@ void StartFrame (void) } bots.CalculatePingOffsets (); - if (g_bombPlanted) - waypoints.SetBombPosition (); - if (g_isMetamod) { static cvar_t *csdm_active; @@ -3208,18 +3205,23 @@ void ConVarWrapper::PushRegisteredConVarsToEngine (bool gameVars) } } -#define LINK_ENTITY(entityFunction) \ -export void entityFunction (entvars_t *pev) \ +static void LinkEntity_Helper (EntityPtr_t &entAddress, const char *name, entvars_t *pev) +{ + // here we're see an ugliest hack :) + if (entAddress == NULL || g_gameVersion == CSV_CZERO) + entAddress = g_gameLib->GetFuncAddr (name); + + if (entAddress == NULL) + return; + + entAddress (pev); +} + +#define LINK_ENTITY(entityName) \ +export void entityName (entvars_t *pev) \ { \ - static EntityPtr_t entity_addr = NULL; \ - \ - if (entity_addr == NULL) \ - entity_addr = g_gameLib->GetFuncAddr (#entityFunction); \ - \ - if (entity_addr == NULL) \ - return; \ - \ - (*entity_addr) (pev); \ + static EntityPtr_t addr = NULL; \ + LinkEntity_Helper (addr, #entityName, pev); \ } \ // entities in counter-strike... diff --git a/source/manager.cpp b/source/manager.cpp index 9217d97..40c6dca 100644 --- a/source/manager.cpp +++ b/source/manager.cpp @@ -91,6 +91,9 @@ void BotManager::TouchWithKillerEntity (Bot *bot) MDLL_Touch (m_killerEntity, bot->GetEntity ()); } +// it's already defined in interface.cpp +extern "C" void player (entvars_t *pev); + void BotManager::CallGameEntity (entvars_t *vars) { // this function calls gamedll player() function, in case to create player entity in game @@ -100,14 +103,7 @@ void BotManager::CallGameEntity (entvars_t *vars) CALL_GAME_ENTITY (PLID, "player", vars); return; } - - static EntityPtr_t playerFunction = NULL; - - if (playerFunction == NULL) - playerFunction = g_gameLib->GetFuncAddr ("player"); - - if (playerFunction != NULL) - (*playerFunction) (vars); + player (vars); } int BotManager::CreateBot (const String &name, int difficulty, int personality, int team, int member) @@ -851,7 +847,7 @@ Bot::Bot (edict_t *bot, int difficulty, int personality, int team, int member, c char rejectReason[128]; int clientIndex = IndexOfEntity (bot); - memset (this, 0, sizeof (*this)); + memset (reinterpret_cast (this), 0, sizeof (*this)); pev = &bot->v; @@ -1477,7 +1473,13 @@ void BotManager::UpdateActiveGrenades (void) // search the map for any type of grenade while (!IsEntityNull (grenade = FIND_ENTITY_BY_CLASSNAME (grenade, "grenade"))) + { + // do not count c4 as a grenade + if (strcmp (STRING (grenade->v.model) + 9, "c4.mdl") == 0) + continue; + m_activeGrenades.Push (grenade); + } } const Array &BotManager::GetActiveGrenades (void) diff --git a/source/waypoint.cpp b/source/waypoint.cpp index 1e13e1d..7d0393b 100644 --- a/source/waypoint.cpp +++ b/source/waypoint.cpp @@ -1565,7 +1565,7 @@ void Waypoint::Think (void) float distance = (m_paths[i]->origin - g_hostEntity->v.origin).GetLength (); // check if waypoint is whitin a distance, and is visible - if (distance < 1024.0f && ((::IsVisible (m_paths[i]->origin, g_hostEntity) && IsInViewCone (m_paths[i]->origin, g_hostEntity)) || !IsAlive (g_hostEntity) || distance < 512.0f)) + if (distance < 512.0f && ((::IsVisible (m_paths[i]->origin, g_hostEntity) && IsInViewCone (m_paths[i]->origin, g_hostEntity)) || !IsAlive (g_hostEntity) || distance < 128.0f)) { // check the distance if (distance < nearestDistance) @@ -1574,7 +1574,7 @@ void Waypoint::Think (void) nearestDistance = distance; } - if (m_waypointDisplayTime[i] + 1.0f < GetWorldTime ()) + if (m_waypointDisplayTime[i] + 0.8f < GetWorldTime ()) { float nodeHeight = 0.0f;