Skip to content

Commit

Permalink
Converted doubles into floats
Browse files Browse the repository at this point in the history
  • Loading branch information
APGRoboCop committed Nov 12, 2022
1 parent f96e124 commit 647d787
Show file tree
Hide file tree
Showing 17 changed files with 410 additions and 410 deletions.
228 changes: 114 additions & 114 deletions bot.cpp

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bot.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ typedef int BOOL;


// global defines
#define PLAYER_SEARCH_RADIUS (64 - 4.0)
#define PLAYER_SEARCH_RADIUS (64 - 4.0f)


// define a new bit flag for bot identification
Expand Down
14 changes: 7 additions & 7 deletions bot_chat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ void LoadBotChat()

while (bfp != nullptr)
{
char* stat = fgets(buffer, 80, bfp);
const char* stat = fgets(buffer, 80, bfp);

if (stat == nullptr)
{
Expand Down Expand Up @@ -432,7 +432,7 @@ static void BotChatGetPlayers()

for (int index = 1; index <= gpGlobals->maxClients; index++)
{
edict_t *pPlayer = INDEXENT(index);
const edict_t *pPlayer = INDEXENT(index);

// skip invalid players
if ((pPlayer) && (!pPlayer->free) && !FBitSet(pPlayer->v.flags, FL_PROXY))
Expand Down Expand Up @@ -581,7 +581,7 @@ void BotChatTaunt(bot_t& pBot, const edict_t* victim_edict)

// set chat flag and time to chat (typing one character takes 0.2sec) ...
pBot.b_bot_say = TRUE;
pBot.f_bot_say = gpGlobals->time + RANDOM_FLOAT2(0.5, 1.0) + strlen(pBot.bot_say_msg) * RANDOM_FLOAT2(0.2, 0.3);
pBot.f_bot_say = gpGlobals->time + RANDOM_FLOAT2(0.5f, 1.0f) + strlen(pBot.bot_say_msg) * RANDOM_FLOAT2(0.2f, 0.3f);
}
}

Expand All @@ -596,7 +596,7 @@ void BotChatWhine(bot_t &pBot)

// has the bot been alive for at least 15 seconds AND
if ((pBot.killer_edict != nullptr) && (bot_whine_count > 0) &&
((pBot.f_bot_spawn_time + 15.0) <= gpGlobals->time))
((pBot.f_bot_spawn_time + 15.0f) <= gpGlobals->time))
{
if ((RANDOM_LONG2(1,100) <= pBot.whine_percent))
{
Expand Down Expand Up @@ -650,7 +650,7 @@ void BotChatWhine(bot_t &pBot)

// set chat flag and time to chat (typing one character takes 0.2sec) ...
pBot.b_bot_say = TRUE;
pBot.f_bot_say = gpGlobals->time + RANDOM_FLOAT2(0.5, 1.0) + strlen(pBot.bot_say_msg) * RANDOM_FLOAT2(0.2, 0.3);
pBot.f_bot_say = gpGlobals->time + RANDOM_FLOAT2(0.5f, 1.0f) + strlen(pBot.bot_say_msg) * RANDOM_FLOAT2(0.2f, 0.3f);
}
}
}
Expand Down Expand Up @@ -713,7 +713,7 @@ void BotChatTalk(bot_t &pBot)

// set chat flag and time to chat (typing one character takes 0.2sec) ...
pBot.b_bot_say = TRUE;
pBot.f_bot_say = gpGlobals->time + RANDOM_FLOAT2(0.5, 1.0) + strlen(pBot.bot_say_msg) * RANDOM_FLOAT2(0.2, 0.3);
pBot.f_bot_say = gpGlobals->time + RANDOM_FLOAT2(0.5f, 1.0f) + strlen(pBot.bot_say_msg) * RANDOM_FLOAT2(0.2f, 0.3f);
}
}
}
Expand Down Expand Up @@ -769,7 +769,7 @@ void BotChatEndGame(bot_t &pBot)

// set chat flag and time to chat (typing one character takes 0.2sec) ...
pBot.b_bot_say = TRUE;
pBot.f_bot_say = gpGlobals->time + RANDOM_FLOAT2(0.3, 2.0) + strlen(pBot.bot_say_msg) * RANDOM_FLOAT2(0.2, 0.3);
pBot.f_bot_say = gpGlobals->time + RANDOM_FLOAT2(0.3f, 2.0f) + strlen(pBot.bot_say_msg) * RANDOM_FLOAT2(0.2f, 0.3f);
}
}

6 changes: 3 additions & 3 deletions bot_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ void BotClient_Valve_CurrentWeapon(void *p, int bot_index)
{
if (iState == 1)
{
int found = 0;
int found = 0;

bots[bot_index].current_weapon.iId = iId;
bots[bot_index].current_weapon.iClip = iClip;
Expand All @@ -132,7 +132,7 @@ void BotClient_Valve_CurrentWeapon(void *p, int bot_index)
bots[bot_index].current_weapon.iAmmo1 = bots[bot_index].m_rgAmmo[weapon_defs[iId].iAmmo1];
bots[bot_index].current_weapon.iAmmo2 = bots[bot_index].m_rgAmmo[weapon_defs[iId].iAmmo2];

bot_weapon_select_t* pSelect = &weapon_select[0];
const bot_weapon_select_t* pSelect = &weapon_select[0];

for(int i = 0; pSelect && pSelect[i].iId; i++)
{
Expand All @@ -146,7 +146,7 @@ void BotClient_Valve_CurrentWeapon(void *p, int bot_index)
}

if(!found)
bots[bot_index].current_opt_distance = 99999.0;
bots[bot_index].current_opt_distance = 99999.0f;
}
}
}
Expand Down
18 changes: 9 additions & 9 deletions bot_combat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ void BotAimPost( bot_t &pBot )
pBot.pEdict->v.angles.x = UTIL_WrapAngle (-pBot.pEdict->v.v_angle.x / 3);

pBot.b_set_special_shoot_angle = FALSE;
pBot.f_special_shoot_angle = 0.0;
pBot.f_special_shoot_angle = 0.0f;
}

// special case for m249
Expand Down Expand Up @@ -466,7 +466,7 @@ static Vector GetPredictedPlayerPosition(bot_t &pBot, edict_t * pPlayer, qboolea
const float older_diff = std::fabs(older->time - time);
const float total_diff = newer_diff + older_diff;

if(total_diff <= 0.0)
if(total_diff <= 0.0f)
{
// zero div would crash server..
// zero diff means that both data are from same time
Expand Down Expand Up @@ -633,7 +633,7 @@ static edict_t *BotFindEnemyNearestToPoint(const bot_t& pBot, const Vector& v_po

// skip this player if respawned lately
const float time_since_respawn = UTIL_GetTimeSinceRespawn(pPlayer);
if(time_since_respawn != -1.0 && time_since_respawn < skill_settings[pBot.bot_skill].respawn_react_delay)
if(time_since_respawn != -1.0f && time_since_respawn < skill_settings[pBot.bot_skill].respawn_react_delay)
continue;

// skip this player if facing wall
Expand Down Expand Up @@ -700,7 +700,7 @@ static edict_t *BotFindVisibleSoundEnemy( bot_t &pBot )
CSound *pCurrentSound;
edict_t *pMinDistanceEdict = nullptr;

float mindistance = 99999.0;
float mindistance = 99999.0f;

// walk through active sound linked list
for(int iSound = CSoundEnt::ActiveList(); iSound != SOUNDLIST_EMPTY; iSound = pCurrentSound->m_iNext)
Expand All @@ -726,7 +726,7 @@ static edict_t *BotFindVisibleSoundEnemy( bot_t &pBot )

// any enemy near sound?
Vector v_enemy = Vector(0,0,0);
edict_t * pNewEnemy = BotFindEnemyNearestToPoint(pBot, pCurrentSound->m_vecOrigin, 512.0, &v_enemy);
edict_t * pNewEnemy = BotFindEnemyNearestToPoint(pBot, pCurrentSound->m_vecOrigin, 512.0f, &v_enemy);
if(FNullEnt(pNewEnemy))
continue;

Expand Down Expand Up @@ -887,7 +887,7 @@ edict_t *pEdict = pBot.pEdict;
continue;

// cannot take damage
if((int)pBreakable->pEdict->v.takedamage == DAMAGE_NO ||
if(int(pBreakable->pEdict->v.takedamage) == DAMAGE_NO ||
pBreakable->pEdict->v.solid == SOLID_NOT ||
pBreakable->pEdict->v.deadflag == DEAD_DEAD ||
!pBreakable->material_breakable ||
Expand Down Expand Up @@ -937,7 +937,7 @@ edict_t *pEdict = pBot.pEdict;
pMonster = nullptr;
while (!FNullEnt (pMonster = UTIL_FindEntityInSphere (pMonster, pEdict->v.origin, 1000)))
{
if (!(pMonster->v.flags & FL_MONSTER) || (int)pMonster->v.takedamage == DAMAGE_NO)
if (!(pMonster->v.flags & FL_MONSTER) || int(pMonster->v.takedamage) == DAMAGE_NO)
continue; // discard anything that is not a monster

if (!IsAlive (pMonster))
Expand Down Expand Up @@ -1020,7 +1020,7 @@ edict_t *pEdict = pBot.pEdict;

// skip this player if respawned lately
float time_since_respawn = UTIL_GetTimeSinceRespawn(pPlayer);
if(time_since_respawn != -1.0 && time_since_respawn < skill_settings[pBot.bot_skill].respawn_react_delay)
if(time_since_respawn != -1.0f && time_since_respawn < skill_settings[pBot.bot_skill].respawn_react_delay)
continue;

vecEnd = GetGunPosition(pPlayer);
Expand Down Expand Up @@ -1108,7 +1108,7 @@ edict_t *pEdict = pBot.pEdict;
}

// has the bot NOT seen an ememy for at least 5 seconds (time to reload)?
else if ((pBot.f_bot_see_enemy_time > 0) && ((pBot.f_bot_see_enemy_time + 5.0) <= gpGlobals->time))
else if ((pBot.f_bot_see_enemy_time > 0) && ((pBot.f_bot_see_enemy_time + 5.0f) <= gpGlobals->time))
{
pBot.f_bot_see_enemy_time = -1; // so we won't keep reloading
pBot.v_bot_see_enemy_origin = Vector(-99999,-99999,-99999);
Expand Down
2 changes: 1 addition & 1 deletion bot_inline_funcs.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ inline Vector UTIL_GetOriginWithExtent(bot_t &pBot, edict_t *pTarget)

inline void UTIL_ParticleEffect( const Vector &vecOrigin, const Vector &vecDirection, ULONG ulColor, ULONG ulCount )
{
PARTICLE_EFFECT( vecOrigin, vecDirection, (float)ulColor, (float)ulCount );
PARTICLE_EFFECT( vecOrigin, vecDirection, float(ulColor), float(ulCount) );
}

inline qboolean FIsClassname(edict_t * pent, const char * cname)
Expand Down
42 changes: 21 additions & 21 deletions bot_navigate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ extern qboolean checked_teamplay;
extern bot_weapon_t weapon_defs[MAX_WEAPONS];

// SET THIS UP BASED ON MOD!!!
constexpr int max_drop_height = 800;
const int max_drop_height = 800;

// returns the number of degrees left to turn toward ideal pitch...
float BotChangePitch(const bot_t& pBot, float speed)
Expand Down Expand Up @@ -184,7 +184,7 @@ static qboolean BotFindWaypoint( bot_t &pBot )

for (index=0; index < 3; index++)
{
min_distance[index] = 99999.0;
min_distance[index] = 99999.0f;
min_index[index] = -1;
}

Expand Down Expand Up @@ -445,7 +445,7 @@ static void BotFindWaypointGoal( bot_t &pBot )

if(temp_index != -1)
{
if(RANDOM_FLOAT2(0.0, 1.0) < 0.5f)
if(RANDOM_FLOAT2(0.0f, 1.0f) < 0.5f)
{
const float track_time = RANDOM_FLOAT2(skill_settings[pBot.bot_skill].track_sound_time_min, skill_settings[pBot.bot_skill].track_sound_time_max);

Expand Down Expand Up @@ -709,16 +709,16 @@ qboolean BotHeadTowardWaypoint( bot_t &pBot )


// check if the bot has been trying to get to this waypoint for a while...
if ((pBot.f_waypoint_time + 5.0) < gpGlobals->time)
if ((pBot.f_waypoint_time + 5.0f) < gpGlobals->time)
{
pBot.curr_waypoint_index = -1; // forget about this waypoint
pBot.waypoint_goal = -1; // also forget about a goal
}

// no goal, no goal time
if ((pBot.waypoint_goal == -1) && (pBot.f_waypoint_goal_time > gpGlobals->time + 2) &&
(pBot.f_waypoint_goal_time != 0.0))
pBot.f_waypoint_goal_time = 0.0;
if ((pBot.waypoint_goal == -1) && (pBot.f_waypoint_goal_time > gpGlobals->time + 2.0f) &&
(pBot.f_waypoint_goal_time != 0.0f))
pBot.f_waypoint_goal_time = 0.0f;

// find new waypoint for sound we are tracking
if(pBot.wpt_goal_type == WPT_GOAL_TRACK_SOUND)
Expand All @@ -732,7 +732,7 @@ qboolean BotHeadTowardWaypoint( bot_t &pBot )
pBot.waypoint_top_of_ladder = FALSE;

// did we just come off of a ladder or are we underwater?
if (((pBot.f_end_use_ladder_time + 2.0) > gpGlobals->time) || pBot.b_in_water)
if (((pBot.f_end_use_ladder_time + 2.0f) > gpGlobals->time) || pBot.b_in_water)
{
// find the nearest visible waypoint
i = WaypointFindNearest(pEdict, REACHABLE_RANGE);
Expand Down Expand Up @@ -816,7 +816,7 @@ qboolean BotHeadTowardWaypoint( bot_t &pBot )
if (tr.flFraction < 1.0f)
{
// did we just come off of a ladder or are we under water?
if (((pBot.f_end_use_ladder_time + 2.0) > gpGlobals->time) || pBot.b_in_water)
if (((pBot.f_end_use_ladder_time + 2.0f) > gpGlobals->time) || pBot.b_in_water)
{
// find the nearest visible waypoint
i = WaypointFindNearest(pEdict, REACHABLE_RANGE);
Expand Down Expand Up @@ -892,7 +892,7 @@ qboolean BotHeadTowardWaypoint( bot_t &pBot )
{
qboolean waypoint_found = FALSE;

pBot.prev_waypoint_distance = 0.0;
pBot.prev_waypoint_distance = 0.0f;

// reeval our goal
BotEvaluateGoal( pBot );
Expand Down Expand Up @@ -1200,7 +1200,7 @@ void BotOnLadder( bot_t &pBot, float moved_distance )
pEdict->v.v_angle.x = -60; // look upwards

// check if the bot hasn't moved much since the last location...
if ((moved_distance <= 1) && (pBot.f_prev_speed >= 1.0))
if ((moved_distance <= 1) && (pBot.f_prev_speed >= 1.0f))
{
// the bot must be stuck, change directions...

Expand All @@ -1213,7 +1213,7 @@ void BotOnLadder( bot_t &pBot, float moved_distance )
pEdict->v.v_angle.x = 60; // look downwards

// check if the bot hasn't moved much since the last location...
if ((moved_distance <= 1) && (pBot.f_prev_speed >= 1.0))
if ((moved_distance <= 1) && (pBot.f_prev_speed >= 1.0f))
{
// the bot must be stuck, change directions...

Expand Down Expand Up @@ -1311,7 +1311,7 @@ void BotUseLift( bot_t &pBot, float moved_distance )
edict_t *pEdict = pBot.pEdict;

// just need to press the button once, when the flag gets set...
if (pBot.f_use_button_time + 0.0 >= gpGlobals->time)
if (pBot.f_use_button_time + 0.0f >= gpGlobals->time)
{
// aim at the button..
Vector v_target = pBot.v_use_target - GetGunPosition( pEdict );
Expand Down Expand Up @@ -1351,7 +1351,7 @@ void BotUseLift( bot_t &pBot, float moved_distance )
}

// check if the bot has waited too long for the lift to move...
else if (((pBot.f_use_button_time + 2.0) < gpGlobals->time) &&
else if (((pBot.f_use_button_time + 2.0f) < gpGlobals->time) &&
(!pBot.b_lift_moving))
{
// clear use button flag
Expand Down Expand Up @@ -1459,7 +1459,7 @@ qboolean BotStuckInCorner(const bot_t& pBot)
{
TraceResult tr;
const edict_t *pEdict = pBot.pEdict;
constexpr float offsets[1] = {0};
const float offsets[1] = {0};
const int right_first = RANDOM_LONG2(0,1);
Vector v_forward, v_right, v_up;

Expand Down Expand Up @@ -1529,14 +1529,14 @@ void BotTurnAtWall(const bot_t& pBot, const TraceResult* tr, qboolean negative)
float Y1 = Normal.y - 90;
if (RANDOM_LONG2(1, 100) <= 50)
{
Y1 = Y1 - RANDOM_FLOAT2(5.0, 20.0);
Y1 = Y1 - RANDOM_FLOAT2(5.0f, 20.0f);
}
if (Y1 < 0) Y1 += 360;

float Y2 = Normal.y + 90;
if (RANDOM_LONG2(1, 100) <= 50)
{
Y2 = Y2 + RANDOM_FLOAT2(5.0, 20.0);
Y2 = Y2 + RANDOM_FLOAT2(5.0f, 20.0f);
}
if (Y2 > 359) Y2 -= 360;

Expand Down Expand Up @@ -2111,7 +2111,7 @@ qboolean BotCheckWallOnLeft( bot_t &pBot )
// check if the trace hit something...
if (tr.flFraction < 1.0f)
{
if (pBot.f_wall_on_left < 1.0)
if (pBot.f_wall_on_left < 1.0f)
pBot.f_wall_on_left = gpGlobals->time;

return TRUE;
Expand All @@ -2136,7 +2136,7 @@ qboolean BotCheckWallOnRight( bot_t &pBot )
// check if the trace hit something...
if (tr.flFraction < 1.0f)
{
if (pBot.f_wall_on_right < 1.0)
if (pBot.f_wall_on_right < 1.0f)
pBot.f_wall_on_right = gpGlobals->time;

return TRUE;
Expand All @@ -2161,7 +2161,7 @@ qboolean BotCheckWallOnForward( bot_t &pBot )
// check if the trace hit something...
if (tr.flFraction < 1.0f)
{
if (pBot.f_wall_on_right < 1.0)
if (pBot.f_wall_on_right < 1.0f)
pBot.f_wall_on_right = gpGlobals->time;

return TRUE;
Expand All @@ -2186,7 +2186,7 @@ qboolean BotCheckWallOnBack( bot_t &pBot )
// check if the trace hit something...
if (tr.flFraction < 1.0f)
{
if (pBot.f_wall_on_right < 1.0)
if (pBot.f_wall_on_right < 1.0f)
pBot.f_wall_on_right = gpGlobals->time;

return TRUE;
Expand Down
2 changes: 1 addition & 1 deletion bot_query_hook_win32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ bool hook_sendto_function()

is_sendto_hook_setup = false;

sendto_original = (sendto_func)GetProcAddress(GetModuleHandle("wsock32.dll"), "sendto");
sendto_original = sendto_func(GetProcAddress(GetModuleHandle("wsock32.dll"), "sendto"));

//Backup old bytes of "sendto" function
memcpy(sendto_old_bytes, (void*)sendto_original, BYTES_SIZE);
Expand Down
Loading

0 comments on commit 647d787

Please sign in to comment.