do not threat c4 as grenade

simplify linkents
several other fixes
This commit is contained in:
jeefo 2016-01-27 21:40:47 +03:00
commit a7231d87ed
8 changed files with 58 additions and 88 deletions

View file

@ -203,7 +203,7 @@ namespace Math
// //
static inline void SineCosine (float rad, float *sine, float *cosine) 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 __asm
{ {
fld dword ptr[rad] fld dword ptr[rad]
@ -223,7 +223,8 @@ namespace Math
*cosine = _cos; *cosine = _cos;
*sine = _sin; *sine = _sin;
#else #else
#error "SineConsine not defined." *sine = sinf (rad);
*cosine = cosf (rad);
#endif #endif
} }
@ -616,7 +617,7 @@ public:
// //
inline static const Vector &GetZero (void) 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; return s_zero;
} }
@ -2754,21 +2755,6 @@ public:
return strcmp (m_bufferPtr, string.m_bufferPtr); 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 // Function: Compare
// Compares string with other string. // Compares string with other string.
@ -2784,21 +2770,6 @@ public:
return strcmp (m_bufferPtr, str); 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 // Function: Collate
// Collate the string. // Collate the string.

View file

@ -30,9 +30,7 @@
<ClInclude Include="..\include\resource.h" /> <ClInclude Include="..\include\resource.h" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="..\source\basecode.cpp"> <ClCompile Include="..\source\basecode.cpp" />
<WarningLevel Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Level4</WarningLevel>
</ClCompile>
<ClCompile Include="..\source\combat.cpp" /> <ClCompile Include="..\source\combat.cpp" />
<ClCompile Include="..\source\manager.cpp" /> <ClCompile Include="..\source\manager.cpp" />
<ClCompile Include="..\source\chatlib.cpp" /> <ClCompile Include="..\source\chatlib.cpp" />
@ -180,23 +178,17 @@
</Midl> </Midl>
<ClCompile> <ClCompile>
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion> <InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
<IntrinsicFunctions>true</IntrinsicFunctions> <IntrinsicFunctions>false</IntrinsicFunctions>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed> <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<EnableFiberSafeOptimizations>false</EnableFiberSafeOptimizations> <EnableFiberSafeOptimizations>false</EnableFiberSafeOptimizations>
<AdditionalIncludeDirectories>..\mmgr;..\include\engine;..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>..\mmgr;..\include\engine;..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>NDEBUG;WIN32;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>NDEBUG;WIN32;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<ExceptionHandling>false</ExceptionHandling> <ExceptionHandling>false</ExceptionHandling>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<BufferSecurityCheck>false</BufferSecurityCheck>
<EnableEnhancedInstructionSet>StreamingSIMDExtensions2</EnableEnhancedInstructionSet> <EnableEnhancedInstructionSet>StreamingSIMDExtensions2</EnableEnhancedInstructionSet>
<TreatWChar_tAsBuiltInType>false</TreatWChar_tAsBuiltInType> <PrecompiledHeaderFile>
<RuntimeTypeInfo>false</RuntimeTypeInfo> </PrecompiledHeaderFile>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<PrecompiledHeaderFile>core.h</PrecompiledHeaderFile>
<PrecompiledHeaderOutputFile>.\release\inf\yapb.pch</PrecompiledHeaderOutputFile> <PrecompiledHeaderOutputFile>.\release\inf\yapb.pch</PrecompiledHeaderOutputFile>
<AssemblerListingLocation>.\release\asm\</AssemblerListingLocation> <AssemblerListingLocation>.\release\asm\</AssemblerListingLocation>
<ObjectFileName>.\release\obj\</ObjectFileName>
<ProgramDataBaseFileName>.\release\inf\</ProgramDataBaseFileName> <ProgramDataBaseFileName>.\release\inf\</ProgramDataBaseFileName>
<WarningLevel>Level4</WarningLevel> <WarningLevel>Level4</WarningLevel>
<SuppressStartupBanner>true</SuppressStartupBanner> <SuppressStartupBanner>true</SuppressStartupBanner>
@ -209,9 +201,11 @@
<Optimization>Full</Optimization> <Optimization>Full</Optimization>
<GenerateAlternateCodePaths>AVXI</GenerateAlternateCodePaths> <GenerateAlternateCodePaths>AVXI</GenerateAlternateCodePaths>
<UseProcessorExtensions>AVXI</UseProcessorExtensions> <UseProcessorExtensions>AVXI</UseProcessorExtensions>
<DisableLanguageExtensions>false</DisableLanguageExtensions>
<ForceConformanceInForLoopScope>false</ForceConformanceInForLoopScope>
<MinimalRebuild>false</MinimalRebuild> <MinimalRebuild>false</MinimalRebuild>
<PrecompiledHeaderOutputFileDirectory />
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<OmitFramePointers>true</OmitFramePointers>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
</ClCompile> </ClCompile>
<ResourceCompile> <ResourceCompile>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
@ -228,7 +222,7 @@
<OutputFile>.\release\yapb.dll</OutputFile> <OutputFile>.\release\yapb.dll</OutputFile>
<SuppressStartupBanner>true</SuppressStartupBanner> <SuppressStartupBanner>true</SuppressStartupBanner>
<DelayLoadDLLs>user32.dll;ws2_32.dll;%(DelayLoadDLLs)</DelayLoadDLLs> <DelayLoadDLLs>user32.dll;ws2_32.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
<GenerateDebugInformation>false</GenerateDebugInformation> <GenerateDebugInformation>Debug</GenerateDebugInformation>
<GenerateMapFile>false</GenerateMapFile> <GenerateMapFile>false</GenerateMapFile>
<SubSystem>Windows</SubSystem> <SubSystem>Windows</SubSystem>
<OptimizeReferences>false</OptimizeReferences> <OptimizeReferences>false</OptimizeReferences>
@ -245,6 +239,7 @@
<ImageHasSafeExceptionHandlers> <ImageHasSafeExceptionHandlers>
</ImageHasSafeExceptionHandlers> </ImageHasSafeExceptionHandlers>
<LinkTimeCodeGeneration>Default</LinkTimeCodeGeneration> <LinkTimeCodeGeneration>Default</LinkTimeCodeGeneration>
<FullProgramDatabaseFile>true</FullProgramDatabaseFile>
</Link> </Link>
<PostBuildEvent> <PostBuildEvent>
<Command> <Command>

View file

@ -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) if (m_radioSelect < Radio_GoGoGo)
FakeClientCommand (GetEntity (), "radio1"); FakeClientCommand (GetEntity (), "radio1");
@ -2128,29 +2128,25 @@ void Bot::PushTask (TaskID id, float desire, int data, float time, bool resume)
DeleteSearchNodes (); DeleteSearchNodes ();
IgnoreCollisionShortly (); IgnoreCollisionShortly ();
int taskId = GetTaskId ();
// leader bot? // leader bot?
if (m_isLeader && GetTaskId () == TASK_SEEKCOVER) if (m_isLeader && taskId == TASK_SEEKCOVER)
CommandTeam (); // reorganize team if fleeing CommandTeam (); // reorganize team if fleeing
if (GetTaskId () == TASK_CAMP) if (taskId == TASK_CAMP)
SelectBestWeapon (); SelectBestWeapon ();
// this is best place to handle some voice commands report team some info // this is best place to handle some voice commands report team some info
if (Random.Long (0, 100) < 95) if (Random.Long (0, 100) < 95)
{ {
switch (GetTaskId ()) if (taskId == TASK_BLINDED)
{
case TASK_BLINDED:
InstantChatterMessage (Chatter_GotBlinded); InstantChatterMessage (Chatter_GotBlinded);
break; else if (taskId == TASK_PLANTBOMB)
case TASK_PLANTBOMB:
InstantChatterMessage (Chatter_PlantingC4); 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) if ((g_mapType & MAP_DE) && g_bombPlanted)
ChatterMessage (Chatter_GuardDroppedC4); ChatterMessage (Chatter_GuardDroppedC4);
@ -4440,6 +4436,10 @@ void Bot::RunTask_PickupItem ()
switch (m_pickupType) switch (m_pickupType)
{ {
case PICKUP_DROPPED_C4:
case PICKUP_NONE:
break;
case PICKUP_WEAPON: case PICKUP_WEAPON:
m_aimFlags |= AIM_NAVPOINT; m_aimFlags |= AIM_NAVPOINT;

View file

@ -15,8 +15,8 @@ void StripTags (char *buffer)
{ {
// this function strips 'clan' tags specified below in given string buffer // this function strips 'clan' tags specified below in given string buffer
char *tagOpen[] = {"-=", "-[", "-]", "-}", "-{", "<[", "<]", "[-", "]-", "{-", "}-", "[[", "[", "{", "]", "}", "<", ">", "-", "|", "=", "+", "(", ")"}; const char *tagOpen[] = {"-=", "-[", "-]", "-}", "-{", "<[", "<]", "[-", "]-", "{-", "}-", "[[", "[", "{", "]", "}", "<", ">", "-", "|", "=", "+", "(", ")"};
char *tagClose[] = {"=-", "]-", "[-", "{-", "}-", "]>", "[>", "-]", "-[", "-}", "-{", "]]", "]", "}", "[", "{", ">", "<", "-", "|", "=", "+", ")", "("}; const char *tagClose[] = {"=-", "]-", "[-", "{-", "}-", "]>", "[>", "-]", "-[", "-}", "-{", "]]", "]", "}", "[", "{", ">", "<", "-", "|", "=", "+", ")", "("};
int index, fieldStart, fieldStop, i; int index, fieldStart, fieldStop, i;
int length = strlen (buffer); // get length of string int length = strlen (buffer); // get length of string

View file

@ -869,7 +869,7 @@ WeaponSelectEnd:
{ {
if (distance >= 750.0f && !IsShieldDrawn ()) if (distance >= 750.0f && !IsShieldDrawn ())
pev->button |= IN_ATTACK2; // draw the shield 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 pev->button |= IN_ATTACK2; // draw out the shield
m_shieldCheckTime = GetWorldTime () + 1.0f; m_shieldCheckTime = GetWorldTime () + 1.0f;

View file

@ -2206,9 +2206,6 @@ void StartFrame (void)
} }
bots.CalculatePingOffsets (); bots.CalculatePingOffsets ();
if (g_bombPlanted)
waypoints.SetBombPosition ();
if (g_isMetamod) if (g_isMetamod)
{ {
static cvar_t *csdm_active; static cvar_t *csdm_active;
@ -3208,18 +3205,23 @@ void ConVarWrapper::PushRegisteredConVarsToEngine (bool gameVars)
} }
} }
#define LINK_ENTITY(entityFunction) \ static void LinkEntity_Helper (EntityPtr_t &entAddress, const char *name, entvars_t *pev)
export void entityFunction (entvars_t *pev) \ {
// here we're see an ugliest hack :)
if (entAddress == NULL || g_gameVersion == CSV_CZERO)
entAddress = g_gameLib->GetFuncAddr <EntityPtr_t > (name);
if (entAddress == NULL)
return;
entAddress (pev);
}
#define LINK_ENTITY(entityName) \
export void entityName (entvars_t *pev) \
{ \ { \
static EntityPtr_t entity_addr = NULL; \ static EntityPtr_t addr = NULL; \
\ LinkEntity_Helper (addr, #entityName, pev); \
if (entity_addr == NULL) \
entity_addr = g_gameLib->GetFuncAddr <EntityPtr_t> (#entityFunction); \
\
if (entity_addr == NULL) \
return; \
\
(*entity_addr) (pev); \
} \ } \
// entities in counter-strike... // entities in counter-strike...

View file

@ -91,6 +91,9 @@ void BotManager::TouchWithKillerEntity (Bot *bot)
MDLL_Touch (m_killerEntity, bot->GetEntity ()); 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) void BotManager::CallGameEntity (entvars_t *vars)
{ {
// this function calls gamedll player() function, in case to create player entity in game // 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); CALL_GAME_ENTITY (PLID, "player", vars);
return; return;
} }
player (vars);
static EntityPtr_t playerFunction = NULL;
if (playerFunction == NULL)
playerFunction = g_gameLib->GetFuncAddr <EntityPtr_t> ("player");
if (playerFunction != NULL)
(*playerFunction) (vars);
} }
int BotManager::CreateBot (const String &name, int difficulty, int personality, int team, int member) 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]; char rejectReason[128];
int clientIndex = IndexOfEntity (bot); int clientIndex = IndexOfEntity (bot);
memset (this, 0, sizeof (*this)); memset (reinterpret_cast <void *> (this), 0, sizeof (*this));
pev = &bot->v; pev = &bot->v;
@ -1477,7 +1473,13 @@ void BotManager::UpdateActiveGrenades (void)
// search the map for any type of grenade // search the map for any type of grenade
while (!IsEntityNull (grenade = FIND_ENTITY_BY_CLASSNAME (grenade, "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); m_activeGrenades.Push (grenade);
}
} }
const Array <entity_t> &BotManager::GetActiveGrenades (void) const Array <entity_t> &BotManager::GetActiveGrenades (void)

View file

@ -1565,7 +1565,7 @@ void Waypoint::Think (void)
float distance = (m_paths[i]->origin - g_hostEntity->v.origin).GetLength (); float distance = (m_paths[i]->origin - g_hostEntity->v.origin).GetLength ();
// check if waypoint is whitin a distance, and is visible // 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 // check the distance
if (distance < nearestDistance) if (distance < nearestDistance)
@ -1574,7 +1574,7 @@ void Waypoint::Think (void)
nearestDistance = distance; nearestDistance = distance;
} }
if (m_waypointDisplayTime[i] + 1.0f < GetWorldTime ()) if (m_waypointDisplayTime[i] + 0.8f < GetWorldTime ())
{ {
float nodeHeight = 0.0f; float nodeHeight = 0.0f;