added yb_join_after_player convar

This commit is contained in:
jeefo 2014-07-30 17:49:31 +04:00
commit 2541f75a74
7 changed files with 241 additions and 26 deletions

16
.gitignore vendored
View file

@ -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

View file

@ -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);

58
project/yapb.rc Normal file
View file

@ -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 <winver.h>
#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
}

View file

@ -0,0 +1,107 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="source">
<UniqueIdentifier>{8d3352c3-bb0c-4e87-bb5d-044bb9ec5e13}</UniqueIdentifier>
</Filter>
<Filter Include="include">
<UniqueIdentifier>{e529241e-773e-4084-a737-060aa8396cba}</UniqueIdentifier>
</Filter>
<Filter Include="project">
<UniqueIdentifier>{fe17a93f-cd53-4c35-b79b-969c4967865e}</UniqueIdentifier>
</Filter>
<Filter Include="include\engine">
<UniqueIdentifier>{f98ff5ec-055a-46cd-b5b1-462ef4c1c73e}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\include\compress.h">
<Filter>include</Filter>
</ClInclude>
<ClInclude Include="..\include\core.h">
<Filter>include</Filter>
</ClInclude>
<ClInclude Include="..\include\corelib.h">
<Filter>include</Filter>
</ClInclude>
<ClInclude Include="..\include\globals.h">
<Filter>include</Filter>
</ClInclude>
<ClInclude Include="..\include\resource.h">
<Filter>include</Filter>
</ClInclude>
<ClInclude Include="..\include\engine\archtypes.h">
<Filter>include\engine</Filter>
</ClInclude>
<ClInclude Include="..\include\engine\const.h">
<Filter>include\engine</Filter>
</ClInclude>
<ClInclude Include="..\include\engine\dllapi.h">
<Filter>include\engine</Filter>
</ClInclude>
<ClInclude Include="..\include\engine\eiface.h">
<Filter>include\engine</Filter>
</ClInclude>
<ClInclude Include="..\include\engine\enginecallback.h">
<Filter>include\engine</Filter>
</ClInclude>
<ClInclude Include="..\include\engine\extdll.h">
<Filter>include\engine</Filter>
</ClInclude>
<ClInclude Include="..\include\engine\meta_api.h">
<Filter>include\engine</Filter>
</ClInclude>
<ClInclude Include="..\include\engine\mutil.h">
<Filter>include\engine</Filter>
</ClInclude>
<ClInclude Include="..\include\engine\plinfo.h">
<Filter>include\engine</Filter>
</ClInclude>
<ClInclude Include="..\include\engine\progdefs.h">
<Filter>include\engine</Filter>
</ClInclude>
<ClInclude Include="..\include\engine\sdk_util.h">
<Filter>include\engine</Filter>
</ClInclude>
<ClInclude Include="..\include\engine\util.h">
<Filter>include\engine</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\source\basecode.cpp">
<Filter>source</Filter>
</ClCompile>
<ClCompile Include="..\source\botmanager.cpp">
<Filter>source</Filter>
</ClCompile>
<ClCompile Include="..\source\chatlib.cpp">
<Filter>source</Filter>
</ClCompile>
<ClCompile Include="..\source\combat.cpp">
<Filter>source</Filter>
</ClCompile>
<ClCompile Include="..\source\globals.cpp">
<Filter>source</Filter>
</ClCompile>
<ClCompile Include="..\source\interface.cpp">
<Filter>source</Filter>
</ClCompile>
<ClCompile Include="..\source\navigate.cpp">
<Filter>source</Filter>
</ClCompile>
<ClCompile Include="..\source\netmsg.cpp">
<Filter>source</Filter>
</ClCompile>
<ClCompile Include="..\source\support.cpp">
<Filter>source</Filter>
</ClCompile>
<ClCompile Include="..\source\waypoint.cpp">
<Filter>source</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="yapb.rc">
<Filter>project</Filter>
</ResourceCompile>
</ItemGroup>
</Project>

View file

@ -3139,7 +3139,6 @@ void Bot::Think (void)
{
SecondThink ();
// update timer to one second
secondThinkTimer = GetWorldTime () + 1.05;
}

View file

@ -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;

View file

@ -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;