diff --git a/include/aoclient.h b/include/aoclient.h index 3a1af0a..f37d4e6 100644 --- a/include/aoclient.h +++ b/include/aoclient.h @@ -22,6 +22,8 @@ #include "include/server.h" #include "include/icchatpacket.h" +#include + #include #include #include diff --git a/include/area_data.h b/include/area_data.h index 81a58dc..f725656 100644 --- a/include/area_data.h +++ b/include/area_data.h @@ -39,6 +39,9 @@ class AreaData { bool showname_allowed; bool locking_allowed; bool iniswap_allowed; + + int def_hp; + int pro_hp; }; #endif // AREA_DATA_H diff --git a/src/aoclient.cpp b/src/aoclient.cpp index 37d9dc1..00903ae 100644 --- a/src/aoclient.cpp +++ b/src/aoclient.cpp @@ -117,6 +117,8 @@ void AOClient::handlePacket(AOPacket packet) fullArup(); // Give client all the area data arup(ARUPType::PLAYER_COUNT, true); // Tell everyone there is a new player + sendPacket("HP", {"1", QString::number(area->def_hp)}); + sendPacket("HP", {"2", QString::number(area->pro_hp)}); sendPacket("FA", server->area_names); sendPacket("OPPASS", {"DEADBEEF"}); sendPacket("DONE"); @@ -201,6 +203,16 @@ void AOClient::handlePacket(AOPacket packet) last_wtce_time = QDateTime::currentDateTime().toSecsSinceEpoch(); server->broadcast(packet, current_area); } + else if (packet.header == "HP") { + if (packet.contents[0] == "1") { + area->def_hp = std::min(std::max(0, packet.contents[1].toInt()), 10); + } + else if (packet.contents[0] == "2") { + area->pro_hp = std::min(std::max(0, packet.contents[1].toInt()), 10); + } + server->broadcast(AOPacket("HP", {"1", QString::number(area->def_hp)}), area->index); + server->broadcast(AOPacket("HP", {"2", QString::number(area->pro_hp)}), area->index); + } else { qDebug() << "Unimplemented packet:" << packet.header; qDebug() << packet.contents; @@ -227,7 +239,9 @@ void AOClient::changeArea(int new_area) server->areas[current_area]->player_count--; current_area = new_area; arup(ARUPType::PLAYER_COUNT, true); - // send hp, bn, le, arup + // send hp, bn, le + sendPacket("HP", {"1", QString::number(server->areas[new_area]->def_hp)}); + sendPacket("HP", {"2", QString::number(server->areas[new_area]->pro_hp)}); if (server->areas[current_area]->characters_taken[current_char]) { server->updateCharsTaken(server->areas[current_area]); current_char = ""; diff --git a/src/area_data.cpp b/src/area_data.cpp index 545a866..31fb4b5 100644 --- a/src/area_data.cpp +++ b/src/area_data.cpp @@ -32,4 +32,6 @@ AreaData::AreaData(QStringList characters, QString p_name, int p_index) current_cm = "FREE"; locked = false; status = "FREE"; + def_hp = 10; + pro_hp = 10; }