Fix /switch and /randomchar
Also adds a check to /randomchar to ensure we don't select a taken character.
This commit is contained in:
parent
c70d2afbeb
commit
91bfc4a5c9
@ -82,18 +82,33 @@ void AOClient::cmdNeed(int argc, QStringList argv)
|
|||||||
|
|
||||||
void AOClient::cmdSwitch(int argc, QStringList argv)
|
void AOClient::cmdSwitch(int argc, QStringList argv)
|
||||||
{
|
{
|
||||||
int char_id = server->getCharID(argv.join(" "));
|
int selected_char_id = server->getCharID(argv.join(" "));
|
||||||
if (char_id == -1) {
|
if (selected_char_id == -1) {
|
||||||
sendServerMessage("That does not look like a valid character.");
|
sendServerMessage("That does not look like a valid character.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
changeCharacter(char_id);
|
if (changeCharacter(selected_char_id)) {
|
||||||
|
char_id = selected_char_id;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
sendServerMessage("The character you picked is either taken or invalid.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AOClient::cmdRandomChar(int argc, QStringList argv)
|
void AOClient::cmdRandomChar(int argc, QStringList argv)
|
||||||
{
|
{
|
||||||
int char_id = genRand(0, server->characters.size() - 1);
|
AreaData* area = server->areas[current_area];
|
||||||
changeCharacter(char_id);
|
int selected_char_id;
|
||||||
|
bool taken = true;
|
||||||
|
while (taken) {
|
||||||
|
selected_char_id = genRand(0, server->characters.size() - 1);
|
||||||
|
if (!area->characters_taken.contains(selected_char_id)) {
|
||||||
|
taken = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (changeCharacter(selected_char_id)) {
|
||||||
|
char_id = selected_char_id;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AOClient::cmdToggleGlobal(int argc, QStringList argv)
|
void AOClient::cmdToggleGlobal(int argc, QStringList argv)
|
||||||
|
Loading…
Reference in New Issue
Block a user