Files
Client/Server/RylServerProject/RylGameServer/Commands/AutoBalanceCommand.cpp
LGram16 dd97ddec92 Restructure repository to include all source folders
Move git root from Client/ to src/ to track all source code:
- Client: Game client source (moved to Client/Client/)
- Server: Game server source
- GameTools: Development tools
- CryptoSource: Encryption utilities
- database: Database scripts
- Script: Game scripts
- rylCoder_16.02.2008_src: Legacy coder tools
- GMFont, Game: Additional resources

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-29 20:17:20 +09:00

90 lines
1.6 KiB
C++

#include "stdafx.h"
#include <Creature/CreatureManager.h>
#include "RylGameServer.h"
#include "Commands.h"
CConsoleCommand* CCMDAutoBalance::Clone(const char* szCommand, size_t nCommandLength)
{
const int MAX_BUFFER = 256;
char szBuffer[MAX_BUFFER + 1];
const char* szDelimiter = " \t\r\n";
_snprintf(szBuffer, MAX_BUFFER, "%s", szCommand);
szBuffer[MAX_BUFFER] = '\0';
char* token = strtok(szBuffer, szDelimiter);
CCMDAutoBalance* lpCMD = new CCMDAutoBalance;
if (NULL != lpCMD)
{
token = strtok(NULL, szDelimiter);
if (NULL == token)
{
lpCMD->m_cCmd = NOW_STATE;
}
else if (0 == strcmp("on", token))
{
lpCMD->m_cCmd = AUTO_BALANCE_ON;
}
else if (0 == strcmp("off", token))
{
lpCMD->m_cCmd = AUTO_BALANCE_OFF;
}
else
{
lpCMD->m_cCmd = ERROR_CMD;
}
}
return lpCMD;
}
bool CCMDAutoBalance::DoProcess()
{
const TCHAR* szMessage = 0;
switch (m_cCmd)
{
case NOW_STATE:
if (CCreatureManager::GetInstance().GetAutoBalance())
{
szMessage = _T("AutoBalance is now On");
}
else
{
szMessage = _T("AutoBalance is now Off");
}
break;
case AUTO_BALANCE_ON:
CCreatureManager::GetInstance().SetAutoBalance(true);
szMessage = _T("Turn On AutoBalance");
break;
case AUTO_BALANCE_OFF:
CCreatureManager::GetInstance().SetAutoBalance(false);
szMessage = _T("Turn Off AutoBalance");
break;
case ERROR_CMD:
default:
szMessage = _T("Invalid autobalance command");
break;
}
if(0 != szMessage)
{
CRylGameServer::GetInstance().PrintOutput(szMessage);
}
return true;
}