Browse Source

Added some safety checks for when no default database is specified.

pull/3/head
Jessica James 9 years ago
parent
commit
366692e2e6
  1. 8
      RenX.Ladder/RenX_Ladder.cpp

8
RenX.Ladder/RenX_Ladder.cpp

@ -91,6 +91,9 @@ GenericCommand::ResponseLine *LadderGenericCommand::trigger(const Jupiter::Reada
if (parameters.isEmpty()) if (parameters.isEmpty())
return new GenericCommand::ResponseLine("Error: Too few parameters. Syntax: ladder <name | rank>"_jrs, GenericCommand::DisplayType::PrivateError); return new GenericCommand::ResponseLine("Error: Too few parameters. Syntax: ladder <name | rank>"_jrs, GenericCommand::DisplayType::PrivateError);
if (RenX::default_ladder_database == nullptr)
return new GenericCommand::ResponseLine("Error: No default ladder database specified."_jrs, GenericCommand::DisplayType::PrivateError);
RenX::LadderDatabase::Entry *entry; RenX::LadderDatabase::Entry *entry;
size_t rank; size_t rank;
if (parameters.span("0123456789"_jrs) == parameters.size()) if (parameters.span("0123456789"_jrs) == parameters.size())
@ -147,6 +150,8 @@ void LadderGameCommand::trigger(RenX::Server *source, RenX::PlayerInfo *player,
if (parameters.isEmpty()) if (parameters.isEmpty())
{ {
if (player->steamid != 0) if (player->steamid != 0)
{
if (RenX::default_ladder_database != nullptr)
{ {
std::pair<RenX::LadderDatabase::Entry *, size_t> pair = RenX::default_ladder_database->getPlayerEntryAndIndex(player->steamid); std::pair<RenX::LadderDatabase::Entry *, size_t> pair = RenX::default_ladder_database->getPlayerEntryAndIndex(player->steamid);
if (pair.first != nullptr) if (pair.first != nullptr)
@ -154,6 +159,9 @@ void LadderGameCommand::trigger(RenX::Server *source, RenX::PlayerInfo *player,
else else
source->sendMessage(player, "Error: You have no ladder data. Get started by sticking around until the end of the match!"_jrs); source->sendMessage(player, "Error: You have no ladder data. Get started by sticking around until the end of the match!"_jrs);
} }
else
source->sendMessage(player, "Error: No default ladder database specified."_jrs);
}
else else
source->sendMessage(player, "Error: You have no ladder data, because you're not using Steam."_jrs); source->sendMessage(player, "Error: You have no ladder data, because you're not using Steam."_jrs);
} }

Loading…
Cancel
Save