Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
EfeDursun125 committed Jan 14, 2024
1 parent 0bb7af4 commit 5edb045
Show file tree
Hide file tree
Showing 12 changed files with 326 additions and 374 deletions.
144 changes: 47 additions & 97 deletions source/basecode.cpp

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions source/chatlib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ ConVar ebot_chat_percent("ebot_chat_percent", "40");
void StripTags(char* buffer)
{
// first three tags for Enhanced POD-Bot (e[POD], 3[POD], E[POD])
constexpr char* tagOpen[] = { "e[P", "3[P", "E[P", "-=", "-[", "-]", "-}", "-{", "<[", "<]", "[-", "]-", "{-", "}-", "[[", "[", "{", "]", "}", "<", ">", "-", "|", "=", "+" };
constexpr char* tagClose[] = { "]", "]", "]", "=-", "]-", "[-", "{-", "}-", "]>", "[>", "-]", "-[", "-}", "-{", "]]", "]", "}", "[", "{", ">", "<", "-", "|", "=", "+" };
char* tagOpen[] = { "e[P", "3[P", "E[P", "-=", "-[", "-]", "-}", "-{", "<[", "<]", "[-", "]-", "{-", "}-", "[[", "[", "{", "]", "}", "<", ">", "-", "|", "=", "+" };
char* tagClose[] = { "]", "]", "]", "=-", "]-", "[-", "{-", "}-", "]>", "[>", "-]", "-[", "-}", "-{", "]]", "]", "}", "[", "{", ">", "<", "-", "|", "=", "+" };

int index, fieldStart, fieldStop, i;
const int length = cstrlen(buffer); // get length of string
Expand All @@ -56,7 +56,7 @@ void StripTags(char* buffer)
// have we found a tag stop?
if ((fieldStop > fieldStart) && (fieldStop < 32))
{
closeSize = static_cast<int>(cstrlen(tagClose[index]));
closeSize = cstrlen(tagClose[index]);
for (i = fieldStart; i < length - (fieldStop + closeSize - fieldStart); i++)
buffer[i] = buffer[i + (fieldStop + closeSize - fieldStart)]; // overwrite the buffer with the stripped string

Expand Down Expand Up @@ -109,7 +109,7 @@ void StripTags(char* buffer)
// this function humanize player name (i.e. trim clan and switch to lower case (sometimes))
char* HumanizeName(char* name)
{
static char outputName[256]; // create return name buffer
static char outputName[32]; // create return name buffer
cstrncpy(outputName, name, sizeof(outputName)); // copy name to new buffer

// drop tag marks, 75 percent of time
Expand All @@ -127,7 +127,7 @@ char* HumanizeName(char* name)
outputName[i] = static_cast<char>(ctolower(outputName[i])); // to lower case
}

return &outputName[0]; // return terminated string
return outputName; // return terminated string
}

// this function humanize chat string to be more handwritten
Expand Down
5 changes: 1 addition & 4 deletions source/combat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,14 +252,14 @@ bool Bot::LookupEnemy(void)
else
{
Path* path;
int8_t j;
while (srcIndex != destIndex && movePoint <= 3 && srcIndex >= 0 && destIndex >= 0)
{
path = g_waypoint->GetPath(srcIndex);
if (!IsValidWaypoint(srcIndex))
continue;

movePoint++;
int j;
for (j = 0; j < Const_MaxPathIndex; j++)
{
if (path->index[j] == srcIndex && path->connectionFlags[j] & PATHFLAG_JUMP)
Expand Down Expand Up @@ -823,14 +823,11 @@ bool Bot::KnifeAttack(float attackDistance)
if (pev->origin.z > entityOrigin.z && distanceSkipZ < squaredf(64.0f))
{
pev->button |= IN_DUCK;
m_campButtons |= IN_DUCK;
pev->button &= ~IN_JUMP;
}
else
{
pev->button &= ~IN_DUCK;
m_campButtons &= ~IN_DUCK;

if (pev->origin.z + 150.0f < entityOrigin.z && distanceSkipZ < squaredf(300.0f))
pev->button |= IN_JUMP;
}
Expand Down
20 changes: 7 additions & 13 deletions source/control.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ BotControl::~BotControl(void)
if (bot == nullptr)
continue;

free(bot);
delete bot;
bot = nullptr;
}
}
Expand Down Expand Up @@ -189,14 +189,10 @@ int BotControl::CreateBot(const String name, int skill, int personality, const i
return -2;
}

Bot* new_bot = static_cast<Bot*>(malloc(sizeof(Bot)));
if (new_bot == nullptr)
return -1;

const int index = ENTINDEX(bot) - 1;
new (new_bot) Bot(bot, skill, personality, team, member);
m_bots[index] = new_bot;
new_bot = nullptr;
m_bots[index] = new(std::nothrow) Bot(bot, skill, personality, team, member);
if (m_bots[index] == nullptr)
return -1;

ServerPrint("Connecting E-Bot - %s | Skill %d", botName, skill);
return index;
Expand Down Expand Up @@ -790,7 +786,7 @@ void BotControl::Free(void)
if (ebot_save_bot_names.GetBool())
m_savedBotNames.Push(STRING(bot->GetEntity()->v.netname));

free(bot);
delete bot;
bot = nullptr;
}
}
Expand All @@ -804,7 +800,7 @@ void BotControl::Free(const int index)
if (m_bots[index] == nullptr)
return;

free(m_bots[index]);
delete m_bots[index];
m_bots[index] = nullptr;
}

Expand Down Expand Up @@ -1118,9 +1114,7 @@ void Bot::NewRound(void)
pev->button = 0;

m_timeCamping = 0;
m_campDirection = 0;
m_nextCampDirTime = 0;
m_campButtons = 0;
m_nextCampDirTime = 0.0f;

// clear its message queue
for (auto& message : m_messageQueue)
Expand Down
8 changes: 3 additions & 5 deletions source/engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,14 @@ void Engine::RegisterVariable(const char* variable, const char* value, const Var

newVariable.reg.flags = engineFlags;
newVariable.self = self;

cmemcpy(&m_regVars[m_regCount], &newVariable, sizeof(VarPair));
m_regCount++;
m_regVars.Push(&newVariable);
}

void Engine::PushRegisteredConVarsToEngine(void)
{
int i;
int16_t i;
VarPair* ptr;
for (i = 0; i < m_regCount; i++)
for (i = 0; i < m_regVars.Size(); i++)
{
ptr = &m_regVars[i];
if (ptr == nullptr)
Expand Down
1 change: 0 additions & 1 deletion source/globals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ bool g_bLearnJumpWaypoint = false;
bool g_leaderChoosen[2] = {false, false};
bool g_analyzewaypoints = false;
bool g_analyzeputrequirescrouch = false;
bool* g_expanded;
bool g_isXash = false;

bool g_sgdWaypoint = false;
Expand Down
8 changes: 3 additions & 5 deletions source/interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,6 @@ int BotCommandHandler_O(edict_t* ent, const String& arg0, const String& arg1, co
{;
g_waypointOn = true;
ServerPrint("Waypoint Editing Enabled");

ServerCommand("ebot wp mdl on");
}

Expand Down Expand Up @@ -3221,12 +3220,11 @@ DLL_GIVEFNPTRSTODLL GiveFnptrsToDll(enginefuncs_t* functionTable, globalvars_t*
char gameDLLName[256];

int i;
for (i = 0; s_supportedMods[i].name; i++)
for (i = 0; i < 7; i++)
{
ModSupport* mod = &s_supportedMods[i];
if (cstrcmp(mod->name, GetModName()) == 0)
if (cstrcmp(s_supportedMods[i].name, GetModName()) == 0)
{
knownMod = mod;
knownMod = &s_supportedMods[i];
break;
}
}
Expand Down
Loading

0 comments on commit 5edb045

Please sign in to comment.