add evidence
This commit is contained in:
parent
5e83c37bcb
commit
e53fd2a02e
@ -105,12 +105,15 @@ class AOClient : public QObject {
|
||||
void pktHpBar(AreaData* area, int argc, QStringList argv, AOPacket packet);
|
||||
void pktWebSocketIp(AreaData* area, int argc, QStringList argv, AOPacket packet);
|
||||
void pktModCall(AreaData* area, int argc, QStringList argv, AOPacket packet);
|
||||
void pktAddEvidence(AreaData* area, int argc, QStringList argv, AOPacket packet);
|
||||
void pktRemoveEvidence(AreaData* area, int argc, QStringList argv, AOPacket packet);
|
||||
void pktEditEvidence(AreaData* area, int argc, QStringList argv, AOPacket packet);
|
||||
|
||||
// Packet helper functions
|
||||
void sendEvidenceList(AreaData* area);
|
||||
AOPacket validateIcPacket(AOPacket packet);
|
||||
|
||||
// Packet helper global variables
|
||||
bool last_msg_blankpost = false;
|
||||
int char_id = -1;
|
||||
int pairing_with = -1;
|
||||
QString emote = "";
|
||||
@ -139,7 +142,10 @@ class AOClient : public QObject {
|
||||
{"RT", {ACLFlags.value("NONE"), 1, &AOClient::pktWtCe}},
|
||||
{"HP", {ACLFlags.value("NONE"), 2, &AOClient::pktHpBar}},
|
||||
{"WSIP", {ACLFlags.value("NONE"), 1, &AOClient::pktWebSocketIp}},
|
||||
{"ZZ", {ACLFlags.value("NONE"), 0, &AOClient::pktModCall}}
|
||||
{"ZZ", {ACLFlags.value("NONE"), 0, &AOClient::pktModCall}},
|
||||
{"PE", {ACLFlags.value("NONE"), 3, &AOClient::pktAddEvidence}},
|
||||
{"DE", {ACLFlags.value("NONE"), 1, &AOClient::pktRemoveEvidence}},
|
||||
{"EE", {ACLFlags.value("NONE"), 4, &AOClient::pktEditEvidence}}
|
||||
};
|
||||
|
||||
// Commands
|
||||
|
@ -30,9 +30,16 @@ class AreaData {
|
||||
public:
|
||||
AreaData(QStringList p_characters, QString p_name, int p_index);
|
||||
|
||||
struct Evidence {
|
||||
QString name;
|
||||
QString description;
|
||||
QString image;
|
||||
};
|
||||
|
||||
QString name;
|
||||
int index;
|
||||
QMap<QString, bool> characters_taken;
|
||||
QList<Evidence> evidence;
|
||||
int player_count;
|
||||
QString status;
|
||||
QString current_cm;
|
||||
|
@ -107,7 +107,7 @@ void AOClient::changeArea(int new_area)
|
||||
server->areas[current_area]->player_count--;
|
||||
current_area = new_area;
|
||||
arup(ARUPType::PLAYER_COUNT, true);
|
||||
// send le
|
||||
sendEvidenceList(server->areas[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});
|
||||
|
@ -91,6 +91,7 @@ void AOClient::pktLoadingDone(AreaData* area, int argc, QStringList argv, AOPack
|
||||
server->updateCharsTaken(area);
|
||||
fullArup(); // Give client all the area data
|
||||
arup(ARUPType::PLAYER_COUNT, true); // Tell everyone there is a new player
|
||||
sendEvidenceList(area);
|
||||
|
||||
sendPacket("HP", {"1", QString::number(area->def_hp)});
|
||||
sendPacket("HP", {"2", QString::number(area->pro_hp)});
|
||||
@ -236,7 +237,7 @@ void AOClient::pktWebSocketIp(AreaData* area, int argc, QStringList argv, AOPack
|
||||
}
|
||||
}
|
||||
|
||||
void AOClient::pktModCall(AreaData *area, int argc, QStringList argv, AOPacket packet)
|
||||
void AOClient::pktModCall(AreaData* area, int argc, QStringList argv, AOPacket packet)
|
||||
{
|
||||
for (AOClient* client : server->clients) {
|
||||
if (client->authenticated)
|
||||
@ -245,6 +246,49 @@ void AOClient::pktModCall(AreaData *area, int argc, QStringList argv, AOPacket p
|
||||
area->logger->flush();
|
||||
}
|
||||
|
||||
void AOClient::pktAddEvidence(AreaData* area, int argc, QStringList argv, AOPacket packet)
|
||||
{
|
||||
AreaData::Evidence evi = {argv[0], argv[1], argv[2]};
|
||||
area->evidence.append(evi);
|
||||
sendEvidenceList(area);
|
||||
}
|
||||
|
||||
void AOClient::pktRemoveEvidence(AreaData* area, int argc, QStringList argv, AOPacket packet)
|
||||
{
|
||||
bool is_int = false;
|
||||
int idx = argv[0].toInt(&is_int);
|
||||
if (is_int) {
|
||||
area->evidence.removeAt(idx);
|
||||
}
|
||||
sendEvidenceList(area);
|
||||
}
|
||||
|
||||
void AOClient::pktEditEvidence(AreaData* area, int argc, QStringList argv, AOPacket packet)
|
||||
{
|
||||
bool is_int = false;
|
||||
int idx = argv[0].toInt(&is_int);
|
||||
AreaData::Evidence evi = {argv[1], argv[2], argv[3]};
|
||||
if (is_int) {
|
||||
area->evidence.replace(idx, evi);
|
||||
}
|
||||
sendEvidenceList(area);
|
||||
}
|
||||
|
||||
void AOClient::sendEvidenceList(AreaData* area)
|
||||
{
|
||||
QStringList evidence_list;
|
||||
QString evidence_format("%1&%2&%3");
|
||||
|
||||
for (AreaData::Evidence evidence : area->evidence) {
|
||||
evidence_list.append(evidence_format
|
||||
.arg(evidence.name)
|
||||
.arg(evidence.description)
|
||||
.arg(evidence.image));
|
||||
}
|
||||
|
||||
server->broadcast(AOPacket("LE", evidence_list), current_area);
|
||||
}
|
||||
|
||||
AOPacket AOClient::validateIcPacket(AOPacket packet)
|
||||
{
|
||||
// Welcome to the super cursed server-side IC chat validation hell
|
||||
@ -296,14 +340,6 @@ AOPacket AOClient::validateIcPacket(AOPacket packet)
|
||||
|
||||
// message text
|
||||
QString incoming_msg = incoming_args[4].toString().trimmed();
|
||||
if (incoming_msg == "") {
|
||||
if (last_msg_blankpost)
|
||||
return invalid;
|
||||
last_msg_blankpost = true;
|
||||
}
|
||||
else
|
||||
last_msg_blankpost = false;
|
||||
|
||||
if (incoming_msg == last_message)
|
||||
return invalid;
|
||||
|
||||
@ -354,8 +390,11 @@ AOPacket AOClient::validateIcPacket(AOPacket packet)
|
||||
}
|
||||
|
||||
// evidence
|
||||
// TODO: add to this once evidence is implemented
|
||||
args.append(incoming_args[11].toString());
|
||||
int evi_idx = incoming_args[11].toInt();
|
||||
AreaData* area = server->areas[current_area];
|
||||
if (evi_idx > area->evidence.length())
|
||||
return invalid;
|
||||
args.append(QString::number(evi_idx));
|
||||
|
||||
// flipping
|
||||
int flip = incoming_args[12].toInt();
|
||||
|
Loading…
Reference in New Issue
Block a user