diff --git a/include/area_data.h b/include/area_data.h index a70553a..49f0a28 100644 --- a/include/area_data.h +++ b/include/area_data.h @@ -31,7 +31,7 @@ class Logger; class AreaData : public QObject { Q_OBJECT public: - AreaData(QStringList p_characters, QString p_name, int p_index); + AreaData(QString p_name, int p_index); struct Evidence { QString name; @@ -41,7 +41,7 @@ class AreaData : public QObject { QList timers; QString name; int index; - QMap characters_taken; + QList characters_taken; QList evidence; int player_count; enum Status { diff --git a/src/aoclient.cpp b/src/aoclient.cpp index 16bd350..2d8f26c 100644 --- a/src/aoclient.cpp +++ b/src/aoclient.cpp @@ -64,8 +64,7 @@ void AOClient::clientDisconnected() arup(ARUPType::PLAYER_COUNT, true); } if (current_char != "") { - server->areas[current_area]->characters_taken[current_char] = - false; + server->areas[current_area]->characters_taken.removeAll(server->getCharID(current_char)); server->updateCharsTaken(server->areas[current_area]); } bool update_locks; @@ -116,8 +115,7 @@ void AOClient::changeArea(int new_area) } if (current_char != "") { - server->areas[current_area]->characters_taken[current_char] = - false; + server->areas[current_area]->characters_taken.removeAll(server->getCharID(current_char)); server->updateCharsTaken(server->areas[current_area]); } server->areas[new_area]->player_count++; @@ -128,13 +126,13 @@ void AOClient::changeArea(int new_area) sendPacket("HP", {"1", QString::number(server->areas[new_area]->def_hp)}); sendPacket("HP", {"2", QString::number(server->areas[new_area]->pro_hp)}); sendPacket("BN", {server->areas[new_area]->background}); - if (server->areas[current_area]->characters_taken[current_char]) { + if (server->areas[current_area]->characters_taken.contains(server->getCharID(current_char))) { server->updateCharsTaken(server->areas[current_area]); current_char = ""; sendPacket("DONE"); } else { - server->areas[current_area]->characters_taken[current_char] = true; + server->areas[current_area]->characters_taken.append(server->getCharID(current_char)); server->updateCharsTaken(server->areas[current_area]); } for (QTimer* timer : server->areas[current_area]->timers) { @@ -157,7 +155,7 @@ void AOClient::changeCharacter(int char_id) AreaData* area = server->areas[current_area]; if (current_char != "") { - area->characters_taken[current_char] = false; + area->characters_taken.removeAll(server->getCharID(current_char)); } if(char_id > server->characters.length()) @@ -165,11 +163,11 @@ void AOClient::changeCharacter(int char_id) if (char_id >= 0) { QString char_selected = server->characters[char_id]; - bool taken = area->characters_taken.value(char_selected); + bool taken = area->characters_taken.contains(char_id); if (taken || char_selected == "") return; - area->characters_taken[char_selected] = true; + area->characters_taken.append(char_id); current_char = char_selected; } else { diff --git a/src/area_data.cpp b/src/area_data.cpp index c85ea25..83bfc38 100644 --- a/src/area_data.cpp +++ b/src/area_data.cpp @@ -17,13 +17,10 @@ ////////////////////////////////////////////////////////////////////////////////////// #include "include/area_data.h" -AreaData::AreaData(QStringList characters, QString p_name, int p_index) +AreaData::AreaData(QString p_name, int p_index) { name = p_name; index = p_index; - for (QString cur_char : characters) { - characters_taken.insert(cur_char, false); - } QSettings areas_ini("config/areas.ini", QSettings::IniFormat); areas_ini.beginGroup(p_name); background = areas_ini.value("background", "gs4").toString(); diff --git a/src/server.cpp b/src/server.cpp index 0f4d23a..131ec47 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -91,7 +91,7 @@ void Server::start() area_names = sanitized_area_names; for (int i = 0; i < area_names.length(); i++) { QString area_name = area_names[i]; - areas.insert(i, new AreaData(characters, area_name, i)); + areas.insert(i, new AreaData(area_name, i)); } } @@ -139,8 +139,8 @@ void Server::clientConnected() void Server::updateCharsTaken(AreaData* area) { QStringList chars_taken; - for (QString cur_char : area->characters_taken.keys()) { - chars_taken.append(area->characters_taken.value(cur_char) + for (QString cur_char : characters) { + chars_taken.append(area->characters_taken.contains(getCharID(cur_char)) ? QStringLiteral("-1") : QStringLiteral("0")); }