rework characters_taken to be a QList<int>
This commit is contained in:
parent
eba21d9108
commit
ee9ae6d7c6
@ -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<QTimer*> timers;
|
||||
QString name;
|
||||
int index;
|
||||
QMap<QString, bool> characters_taken;
|
||||
QList<int> characters_taken;
|
||||
QList<Evidence> evidence;
|
||||
int player_count;
|
||||
enum Status {
|
||||
|
@ -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 {
|
||||
|
@ -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();
|
||||
|
@ -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"));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user