Skip to content

Commit

Permalink
[Cast System] Set Viewers limit in config.lua
Browse files Browse the repository at this point in the history
  • Loading branch information
Nottinghster committed Jul 1, 2016
1 parent 773aff2 commit 766af33
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 5 deletions.
5 changes: 4 additions & 1 deletion config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -413,4 +413,7 @@ sql_user = "root"
sql_pass = ""

-- Enable Cast System? (true or false)
enableCast = true
enableCast = true

-- Set Cast Viewers Limit
max_cast_viewers = 50
1 change: 1 addition & 0 deletions src/configmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ bool ConfigManager::loadFile(const std::string& _filename)
m_confInteger[USE_RUNE_LEVEL_REQUIREMENTS] = getGlobalBoolean(L, "use_rune_level_requirements", true);
m_confInteger[MAX_PACKETS_PER_SECOND] = getGlobalNumber(L, "max_packets_per_second", 50);
m_confInteger[ENABLE_CAST] = getGlobalBoolean(L, "enableCast", false);
m_confInteger[MAX_CAST_VIEWERS] = getGlobalNumber(L, "max_cast_viewers", 50);

m_isLoaded = true;
return true;
Expand Down
1 change: 1 addition & 0 deletions src/configmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ class ConfigManager {
USE_RUNE_LEVEL_REQUIREMENTS,
MAX_PACKETS_PER_SECOND,
ENABLE_CAST,
MAX_CAST_VIEWERS,
LAST_INTEGER_CONFIG /* this must be the last one */
};

Expand Down
2 changes: 1 addition & 1 deletion src/protocolgame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ bool ProtocolGame::connect(uint32_t playerId, const bool isLoggingIn, bool castA
return false;
}

if (_player->getCastViewerCount() >= 50)
if (_player->getCastViewerCount() >= g_config.getNumber(ConfigManager::MAX_CAST_VIEWERS))
{
disconnectClient(0x14, "This cast has reached maximum viewers limit.");
return false;
Expand Down
2 changes: 1 addition & 1 deletion src/protocollogin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ bool ProtocolLogin::parseFirstPacket(NetworkMessage& msg)
for (AutoList<Player>::listiterator it = Player::castAutoList.list.begin(); it != Player::castAutoList.list.end(); ++it)
{
std::stringstream ss;
ss << (it->second->getCastingPassword() == "" ? "" : it->second->getCastingPassword() != password ? "* " : "") << "L." << it->second->getLevel() << " " << it->second->getCastViewerCount() << "/50";
ss << (it->second->getCastingPassword() == "" ? "" : it->second->getCastingPassword() != password ? "* " : "") << "L." << it->second->getLevel() << " " << it->second->getCastViewerCount() << "/" << (int)g_config.getNumber(ConfigManager::MAX_CAST_VIEWERS);
output->AddString(it->second->getName());
output->AddString(ss.str().c_str());
output->AddU32(serverip);
Expand Down
2 changes: 0 additions & 2 deletions src/talkaction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,13 +149,11 @@ TalkActionResult_t TalkActions::onPlayerSpeak(Player* player, SpeakClasses type,
trim(param);
if (param.length() > 10)
{
//pg->sendChannelMessage("[Chat System]", "This name is too long. (Max 8. letters)", MSG_STATUS_DEFAULT, privchannel->getId());
pg->publicSendMessage(player, SPEAK_PRIVATE, "This name is too long.");
return TALKACTION_BREAK;
}
else if (param.length() <= 2)
{
//pg->sendChannelMessage("[Chat System]", "This name is too short. (Min 3. letters)", MSG_STATUS_DEFAULT, privchannel->getId());
pg->publicSendMessage(player, SPEAK_PRIVATE, "This name is too short.");
return TALKACTION_BREAK;
}
Expand Down

0 comments on commit 766af33

Please sign in to comment.