change curse list to int list, marked unavailable chars as taken
This commit is contained in:
parent
6dfd7d173a
commit
08ba6ef278
@ -272,7 +272,7 @@ class AOClient : public QObject {
|
||||
*/
|
||||
QTimer* afk_timer;
|
||||
|
||||
QStringList charcurse_list;
|
||||
QList<int> charcurse_list;
|
||||
|
||||
/**
|
||||
* @brief Temporary client permission if client is allowed to save a testimony to server storage.
|
||||
|
@ -259,6 +259,8 @@ class Server : public QObject {
|
||||
*/
|
||||
QStringList loadConfigFile(QString filename);
|
||||
|
||||
QStringList getCursedCharsTaken(AOClient* client, QStringList chars_taken);
|
||||
|
||||
/**
|
||||
* @brief List holding the contents of 8ball.txt, used by /8ball.
|
||||
*/
|
||||
|
@ -148,7 +148,7 @@ bool AOClient::changeCharacter(int char_id)
|
||||
if(char_id >= server->characters.length())
|
||||
return false;
|
||||
|
||||
if (is_charcursed && !charcurse_list.contains(QString::number(char_id))) {
|
||||
if (is_charcursed && !charcurse_list.contains(char_id)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -335,7 +335,7 @@ void AOClient::cmdCharCurse(int argc, QStringList argv)
|
||||
}
|
||||
|
||||
if (argc == 1) {
|
||||
target->charcurse_list.append(QString::number(server->getCharID(current_char)));
|
||||
target->charcurse_list.append(server->getCharID(current_char));
|
||||
}
|
||||
|
||||
else {
|
||||
@ -343,23 +343,23 @@ void AOClient::cmdCharCurse(int argc, QStringList argv)
|
||||
QString names = argv.join(" ");
|
||||
argv = names.split(", ");
|
||||
QString char_name;
|
||||
target->charcurse_list.clear();
|
||||
foreach (char_name, argv) {
|
||||
QString converted_char_id = QString::number(server->getCharID(char_name));
|
||||
argv.replaceInStrings(char_name, converted_char_id);
|
||||
target->charcurse_list.append(server->getCharID(char_name));
|
||||
}
|
||||
if (argv.contains("-1")) {
|
||||
if (target->charcurse_list.contains(-1)) {
|
||||
sendServerMessage("One of these characters was not found.");
|
||||
return;
|
||||
}
|
||||
target->charcurse_list = argv;
|
||||
}
|
||||
|
||||
//Kick back to char select screen
|
||||
if (!target->charcurse_list.contains(QString::number(server->getCharID(current_char)))) {
|
||||
target->current_char = "";
|
||||
if (!target->charcurse_list.contains(server->getCharID(current_char))) {
|
||||
target->changeCharacter(-1);
|
||||
target->sendPacket("DONE");
|
||||
}
|
||||
target->is_charcursed = true;
|
||||
server->updateCharsTaken(server->areas.value(current_area));
|
||||
target->sendServerMessage("You have been charcursed!");
|
||||
sendServerMessage("Charcursed player.");
|
||||
}
|
||||
@ -381,7 +381,8 @@ void AOClient::cmdUnCharCurse(int argc, QStringList argv)
|
||||
}
|
||||
target->is_charcursed = false;
|
||||
target->charcurse_list.clear();
|
||||
sendServerMessage("Uncharcursed plater.");
|
||||
server->updateCharsTaken(server->areas.value(current_area));
|
||||
sendServerMessage("Uncharcursed player.");
|
||||
target->sendServerMessage("You were uncharcursed.");
|
||||
}
|
||||
|
||||
|
@ -151,7 +151,30 @@ void Server::updateCharsTaken(AreaData* area)
|
||||
}
|
||||
|
||||
AOPacket response_cc("CharsCheck", chars_taken);
|
||||
broadcast(response_cc, area->index);
|
||||
|
||||
for (AOClient* client : clients) {
|
||||
if (client->current_area == area->index){
|
||||
if (!client->is_charcursed)
|
||||
client->sendPacket(response_cc);
|
||||
else {
|
||||
QStringList chars_taken_cursed = getCursedCharsTaken(client, chars_taken);
|
||||
AOPacket response_cc_cursed("CharsCheck", chars_taken_cursed);
|
||||
client->sendPacket(response_cc_cursed);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QStringList Server::getCursedCharsTaken(AOClient* client, QStringList chars_taken)
|
||||
{
|
||||
QStringList chars_taken_cursed;
|
||||
for (int i = 0; i < chars_taken.length(); i++) {
|
||||
if (!client->charcurse_list.contains(i))
|
||||
chars_taken_cursed.append("-1");
|
||||
else
|
||||
chars_taken_cursed.append(chars_taken.value(i));
|
||||
}
|
||||
return chars_taken_cursed;
|
||||
}
|
||||
|
||||
void Server::broadcast(AOPacket packet, int area_index)
|
||||
|
Loading…
Reference in New Issue
Block a user