diff --git a/.gitignore b/.gitignore index 6dae747..44da234 100644 --- a/.gitignore +++ b/.gitignore @@ -34,3 +34,19 @@ Icon # Files that might appear on external disk .Spotlight-V100 .Trashes + +*.pdb +*.asm +*.tlog +*.obj +*.log +*.manifest +*.map +*.res +*.lib +*.exp +*.ilk +*.opensdf +*.dll +*.sdf +*.suo \ No newline at end of file diff --git a/include/core.h b/include/core.h index 64e233b..8e47289 100644 --- a/include/core.h +++ b/include/core.h @@ -270,7 +270,8 @@ enum CollisionState enum Team { TEAM_TF = 0, - TEAM_CF + TEAM_CF, + TEAM_SPEC }; // client flags @@ -1312,6 +1313,7 @@ public: int GetHumansNum (void); int GetHumansAliveNum(void); + int GetHumansJoinedTeam (void); int GetBotsNum (void); void Think (void); @@ -1324,7 +1326,7 @@ public: void AddBot (String name, String skill, String personality, String team, String member); void FillServer (int selection, int personality = PERSONALITY_NORMAL, int skill = -1, int numToAdd = -1); - void RemoveAll (void); + void RemoveAll (bool zeroQuota = true); void RemoveRandom (void); void RemoveFromTeam (Team team, bool removeAll = false); void RemoveMenu (edict_t *ent, int selection); diff --git a/project/yapb.rc b/project/yapb.rc new file mode 100644 index 0000000..4596a5e --- /dev/null +++ b/project/yapb.rc @@ -0,0 +1,58 @@ +// +// Copyright (c) 2003-2007, by YaPB Development Team. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// +// Version: $Id$ +// + +#include +#include <../include/resource.h> + +// generated by update tool -- do not edit -- +#define PRODUCT_BUILD_TOOL 3844 + +VS_VERSION_INFO VERSIONINFO +FILEVERSION PRODUCT_VERSION_DWORD, PRODUCT_BUILD_TOOL +PRODUCTVERSION PRODUCT_VERSION_DWORD, PRODUCT_BUILD_TOOL +FILEOS 0x40004 +FILETYPE 0x2 +{ + BLOCK "StringFileInfo" + { + BLOCK "040904E4" + { + VALUE "CompanyName", PRODUCT_AUTHOR "\0" + VALUE "FileDescription", PRODUCT_DESCRIPTION "\0" + VALUE "FileVersion", PRODUCT_VERSION "\0" + VALUE "OriginalFilename", PRODUCT_ORIGINAL_NAME "\0" + VALUE "LegalCopyright", PRODUCT_COPYRIGHT "\0" + VALUE "LegalTrademarks", PRODUCT_LEGAL "\0" + VALUE "ProductName", PRODUCT_NAME "\0" + VALUE "SpecialBuild", PRODUCT_OPT_TYPE "\0" + VALUE "InternalName", PRODUCT_INTERNAL_NAME "\0" + } + } +#ifndef NOLANGINFO + BLOCK "VarFileInfo" + { + VALUE "Translation", 0x400, 1252 + } +#endif +} \ No newline at end of file diff --git a/project/yapb.vcxproj.filters b/project/yapb.vcxproj.filters new file mode 100644 index 0000000..a220a26 --- /dev/null +++ b/project/yapb.vcxproj.filters @@ -0,0 +1,107 @@ + + + + + {8d3352c3-bb0c-4e87-bb5d-044bb9ec5e13} + + + {e529241e-773e-4084-a737-060aa8396cba} + + + {fe17a93f-cd53-4c35-b79b-969c4967865e} + + + {f98ff5ec-055a-46cd-b5b1-462ef4c1c73e} + + + + + include + + + include + + + include + + + include + + + include + + + include\engine + + + include\engine + + + include\engine + + + include\engine + + + include\engine + + + include\engine + + + include\engine + + + include\engine + + + include\engine + + + include\engine + + + include\engine + + + include\engine + + + + + source + + + source + + + source + + + source + + + source + + + source + + + source + + + source + + + source + + + source + + + + + project + + + \ No newline at end of file diff --git a/source/basecode.cpp b/source/basecode.cpp index 2207d46..94eb29f 100644 --- a/source/basecode.cpp +++ b/source/basecode.cpp @@ -3138,7 +3138,6 @@ void Bot::Think (void) if (secondThinkTimer < GetWorldTime ()) { SecondThink (); - // update timer to one second secondThinkTimer = GetWorldTime () + 1.05; diff --git a/source/botmanager.cpp b/source/botmanager.cpp index ad93f76..5443405 100644 --- a/source/botmanager.cpp +++ b/source/botmanager.cpp @@ -29,6 +29,7 @@ ConVar yb_autovacate ("yb_autovacate", "-1"); ConVar yb_quota ("yb_quota", "0"); ConVar yb_quota_match ("yb_quota_match", "0"); ConVar yb_quota_match_max ("yb_quota_match_max", "0"); +ConVar yb_join_after_player ("yb_join_after_player", "0"); ConVar yb_join_team ("yb_join_team", "any"); ConVar yb_name_prefix ("yb_name_prefix", ""); @@ -126,7 +127,7 @@ int BotManager::CreateBot (String name, int skill, int personality, int team, in { bool nameFound = false; - for (int i = 0; i < 8; i++) + for (int i = 0; i < g_botNames.GetSize (); i++) { if (nameFound) break; @@ -323,6 +324,12 @@ 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 (yb_join_after_player.GetInt () > 0 && GetHumansJoinedTeam () == 0) + { + RemoveAll (false); + return; + } + if (!m_creationTab.IsEmpty () && m_maintainTime < GetWorldTime ()) { CreateQueue last = m_creationTab.Pop (); @@ -339,7 +346,7 @@ void BotManager::MaintainBotQuota (void) m_creationTab.RemoveAll (); // maximum players reached, so set quota to maximum players yb_quota.SetInt (GetBotsNum ()); } - m_maintainTime = GetWorldTime () + 0.2; + m_maintainTime = GetWorldTime () + 0.15f; } // now keep bot number up to date @@ -388,13 +395,13 @@ void BotManager::MaintainBotQuota (void) else if (yb_quota.GetInt () < 0) yb_quota.SetInt (0); - m_maintainTime = GetWorldTime () + 0.25; + m_maintainTime = GetWorldTime () + 0.15f; } } void BotManager::InitQuota (void) { - m_maintainTime = GetWorldTime () + 2.0; + m_maintainTime = GetWorldTime () + 1.5f; m_creationTab.RemoveAll (); } @@ -453,11 +460,12 @@ void BotManager::FillServer (int selection, int personality, int skill, int numT CenterPrint ("Fill Server with %s bots...", &teamDesc[selection][0]); } -void BotManager::RemoveAll (void) +void BotManager::RemoveAll (bool zeroQuota) { // this function drops all bot clients from server (this function removes only yapb's)`q - CenterPrint ("Bots are removed from server."); + if (zeroQuota) + CenterPrint ("Bots are removed from server."); for (int i = 0; i < GetMaxClients (); i++) { @@ -467,8 +475,11 @@ void BotManager::RemoveAll (void) m_creationTab.RemoveAll (); // reset cvars - yb_quota.SetInt (0); - yb_autovacate.SetInt (0); + if (zeroQuota) + { + yb_quota.SetInt (0); + yb_autovacate.SetInt (0); + } } void BotManager::RemoveFromTeam (Team team, bool removeAll) @@ -666,20 +677,6 @@ int BotManager::GetBotsNum (void) return count; } -int BotManager::GetHumansNum (void) -{ - // this function returns number of humans playing on the server - - int count = 0; - - for (int i = 0; i < GetMaxClients (); i++) - { - if ((g_clients[i].flags & CF_USED) && m_bots[i] == NULL) - count++; - } - return count; -} - Bot *BotManager::GetHighestFragsBot (int team) { Bot *highFragBot = NULL; @@ -915,6 +912,22 @@ Bot::~Bot (void) ResetTasks (); } +int BotManager::GetHumansNum (void) +{ + // this function returns number of humans playing on the server + + int count = 0; + + for (int i = 0; i < GetMaxClients (); i++) + { + Client *cl = &g_clients[i]; + + if ((cl->flags & CF_USED) && m_bots[i] == NULL && !(cl->ent->v.flags & FL_FAKECLIENT)) + count++; + } + return count; +} + int BotManager::GetHumansAliveNum (void) { // this function returns number of humans playing on the server @@ -923,7 +936,25 @@ int BotManager::GetHumansAliveNum (void) for (int i = 0; i < GetMaxClients (); i++) { - if ((g_clients[i].flags & (CF_USED | CF_ALIVE)) && m_bots[i] == NULL) + Client *cl = &g_clients[i]; + + if ((cl->flags & (CF_USED | CF_ALIVE)) && m_bots[i] == NULL && !(cl->ent->v.flags & FL_FAKECLIENT)) + count++; + } + return count; +} + +int BotManager::GetHumansJoinedTeam (void) +{ + // this function returns number of humans playing on the server + + int count = 0; + + for (int i = 0; i < GetMaxClients (); i++) + { + Client *cl = &g_clients[i]; + + if ((cl->flags & (CF_USED | CF_ALIVE)) && m_bots[i] == NULL && cl->team != TEAM_SPEC && !(cl->ent->v.flags & FL_FAKECLIENT)) count++; } return count; diff --git a/source/netmsg.cpp b/source/netmsg.cpp index d2e2a0d..7cac750 100644 --- a/source/netmsg.cpp +++ b/source/netmsg.cpp @@ -454,6 +454,8 @@ void NetworkMsg::Execute (void *p) g_clients[playerIndex - 1].realTeam = TEAM_TF; else if (PTR_TO_INT (p) == 2) g_clients[playerIndex - 1].realTeam = TEAM_CF; + else + g_clients[playerIndex - 1].realTeam = TEAM_SPEC; if (yb_csdm_mode.GetInt () == 2) g_clients[playerIndex - 1].team = playerIndex;