Merge pull request #65 from AttorneyOnline/char-select-fix

Fix character select menu being bugged on Akashi
This commit is contained in:
scatterflower 2021-04-08 14:10:02 -05:00 committed by GitHub
commit 036c2907a1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 11 deletions

View File

@ -321,7 +321,7 @@ class AOClient : public QObject {
* *
* @param char_id The character ID of the client's new character. * @param char_id The character ID of the client's new character.
*/ */
void changeCharacter(int char_id); bool changeCharacter(int char_id);
/** /**
* @brief Changes the client's in-character position. * @brief Changes the client's in-character position.

View File

@ -134,22 +134,22 @@ void AOClient::changeArea(int new_area)
sendServerMessage("Area " + server->area_names[current_area] + " is spectate-only; to chat IC you will need to be invited by the CM."); sendServerMessage("Area " + server->area_names[current_area] + " is spectate-only; to chat IC you will need to be invited by the CM.");
} }
void AOClient::changeCharacter(int char_id) bool AOClient::changeCharacter(int char_id)
{ {
AreaData* area = server->areas[current_area]; AreaData* area = server->areas[current_area];
if (current_char != "") {
area->characters_taken.removeAll(server->getCharID(current_char));
}
if(char_id >= server->characters.length()) if(char_id >= server->characters.length())
return; return false;
if (char_id >= 0) { if (char_id >= 0) {
QString char_selected = server->characters[char_id]; QString char_selected = server->characters[char_id];
bool taken = area->characters_taken.contains(char_id); bool taken = area->characters_taken.contains(char_id);
if (taken || char_selected == "") if (taken || char_selected == "")
return; return false;
if (current_char != "") {
area->characters_taken.removeAll(server->getCharID(current_char));
}
area->characters_taken.append(char_id); area->characters_taken.append(char_id);
current_char = char_selected; current_char = char_selected;
@ -162,6 +162,7 @@ void AOClient::changeCharacter(int char_id)
server->updateCharsTaken(area); server->updateCharsTaken(area);
sendPacket("PV", {QString::number(id), "CID", QString::number(char_id)}); sendPacket("PV", {QString::number(id), "CID", QString::number(char_id)});
return true;
} }
void AOClient::changePosition(QString new_pos) void AOClient::changePosition(QString new_pos)

View File

@ -143,13 +143,14 @@ void AOClient::pktCharPassword(AreaData* area, int argc, QStringList argv, AOPac
void AOClient::pktSelectChar(AreaData* area, int argc, QStringList argv, AOPacket packet) void AOClient::pktSelectChar(AreaData* area, int argc, QStringList argv, AOPacket packet)
{ {
bool argument_ok; bool argument_ok;
char_id = argv[1].toInt(&argument_ok); int selected_char_id = argv[1].toInt(&argument_ok);
if (!argument_ok) { if (!argument_ok) {
char_id = -1; selected_char_id = -1;
return; return;
} }
changeCharacter(char_id); if (changeCharacter(selected_char_id))
char_id = selected_char_id;
} }
void AOClient::pktIcChat(AreaData* area, int argc, QStringList argv, AOPacket packet) void AOClient::pktIcChat(AreaData* area, int argc, QStringList argv, AOPacket packet)