add background changing

This commit is contained in:
scatterflower 2020-09-29 04:49:16 -05:00
parent 89d7fed688
commit 7c6b892fb9
10 changed files with 83 additions and 2 deletions

View File

@ -0,0 +1,22 @@
Anime
birthday
Christmas
CountyCourt
CruiseCourt
default
DGSEnglishCourt
DGSJapanCourt
DualDestinies
EnglishCourt
gs4
GS4Night
HD
Khura'in
NewCourt
RuinedCourt
Sky
SpaceCourt
Themis
TouhouCourt
WitchTrialCourt
Zetta

View File

@ -57,6 +57,7 @@ class AOClient : public QObject {
NONE = 0ULL, NONE = 0ULL,
KICK = 1ULL << 0, KICK = 1ULL << 0,
BAN = 1ULL << 1, BAN = 1ULL << 1,
BGLOCK = 1ULL << 2,
SUPER = ~0ULL SUPER = ~0ULL
}; };
@ -137,6 +138,9 @@ class AOClient : public QObject {
void cmdKick(int argc, QStringList argv); void cmdKick(int argc, QStringList argv);
void cmdChangeAuth(int argc, QStringList argv); void cmdChangeAuth(int argc, QStringList argv);
void cmdSetRootPass(int argc, QStringList argv); void cmdSetRootPass(int argc, QStringList argv);
void cmdSetBackground(int argc, QStringList argv);
void cmdBgLock(int argc, QStringList argv);
void cmdBgUnlock(int argc, QStringList argv);
// Command helper functions // Command helper functions
QStringList buildAreaList(int area_idx); QStringList buildAreaList(int area_idx);
@ -157,7 +161,11 @@ class AOClient : public QObject {
{"ban", {ACLFlags::BAN, 2, &AOClient::cmdBan}}, {"ban", {ACLFlags::BAN, 2, &AOClient::cmdBan}},
{"kick", {ACLFlags::KICK, 2, &AOClient::cmdKick}}, {"kick", {ACLFlags::KICK, 2, &AOClient::cmdKick}},
{"changeauth", {ACLFlags::SUPER, 0, &AOClient::cmdChangeAuth}}, {"changeauth", {ACLFlags::SUPER, 0, &AOClient::cmdChangeAuth}},
{"rootpass", {ACLFlags::SUPER, 1, &AOClient::cmdSetRootPass}} {"rootpass", {ACLFlags::SUPER, 1, &AOClient::cmdSetRootPass}},
{"background", {ACLFlags::NONE, 1, &AOClient::cmdSetBackground}},
{"bg", {ACLFlags::NONE, 1, &AOClient::cmdSetBackground}},
{"bglock", {ACLFlags::BGLOCK, 0, &AOClient::cmdBgLock}},
{"bgunlock", {ACLFlags::BGLOCK, 0, &AOClient::cmdBgUnlock}}
}; };
QString partial_packet; QString partial_packet;

View File

@ -39,6 +39,7 @@ class AreaData {
bool showname_allowed; bool showname_allowed;
bool locking_allowed; bool locking_allowed;
bool iniswap_allowed; bool iniswap_allowed;
bool bg_locked;
int def_hp; int def_hp;
int pro_hp; int pro_hp;

View File

@ -56,6 +56,7 @@ class Server : public QObject {
QVector<AreaData*> areas; QVector<AreaData*> areas;
QStringList area_names; QStringList area_names;
QStringList music_list; QStringList music_list;
QStringList backgrounds;
DBManager* db_manager; DBManager* db_manager;
signals: signals:

View File

@ -108,9 +108,10 @@ void AOClient::changeArea(int new_area)
server->areas[current_area]->player_count--; server->areas[current_area]->player_count--;
current_area = new_area; current_area = new_area;
arup(ARUPType::PLAYER_COUNT, true); arup(ARUPType::PLAYER_COUNT, true);
// send hp, bn, le // send le
sendPacket("HP", {"1", QString::number(server->areas[new_area]->def_hp)}); sendPacket("HP", {"1", QString::number(server->areas[new_area]->def_hp)});
sendPacket("HP", {"2", QString::number(server->areas[new_area]->pro_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[current_char]) {
server->updateCharsTaken(server->areas[current_area]); server->updateCharsTaken(server->areas[current_area]);
current_char = ""; current_char = "";

View File

@ -34,4 +34,5 @@ AreaData::AreaData(QStringList characters, QString p_name, int p_index)
status = "FREE"; status = "FREE";
def_hp = 10; def_hp = 10;
pro_hp = 10; pro_hp = 10;
bg_locked = false;
} }

View File

@ -165,6 +165,40 @@ void AOClient::cmdSetRootPass(int argc, QStringList argv)
server->db_manager->createUser("root", salt, argv[0], ACLFlags::SUPER); server->db_manager->createUser("root", salt, argv[0], ACLFlags::SUPER);
} }
void AOClient::cmdSetBackground(int argc, QStringList argv)
{
// TODO: area locks in areas.ini
// TODO: sendServerMessage but area broadcast
AreaData* area = server->areas[current_area];
if (authenticated || !area->bg_locked) {
if (server->backgrounds.contains(argv[0])) {
area->background = argv[0];
server->broadcast(AOPacket("BN", {argv[0]}), current_area);
server->broadcast(AOPacket("CT", {"Server", current_char + " changed the background to " + argv[0], "1"}), current_area);
}
else {
sendServerMessage("Invalid background name.");
}
}
else {
sendServerMessage("This area's background is locked.");
}
}
void AOClient::cmdBgLock(int argc, QStringList argv)
{
AreaData* area = server->areas[current_area];
area->bg_locked = true;
server->broadcast(AOPacket("CT", {"Server", current_char + " locked the background.", "1"}), current_area);
}
void AOClient::cmdBgUnlock(int argc, QStringList argv)
{
AreaData* area = server->areas[current_area];
area->bg_locked = false;
server->broadcast(AOPacket("CT", {"Server", current_char + " unlocked the background.", "1"}), current_area);
}
QStringList AOClient::buildAreaList(int area_idx) QStringList AOClient::buildAreaList(int area_idx)
{ {
QStringList entries; QStringList entries;

View File

@ -33,6 +33,7 @@ bool ConfigManager::initConfig()
QFileInfo areas_info("config/areas.ini"); QFileInfo areas_info("config/areas.ini");
QFileInfo characters_info("config/characters.txt"); QFileInfo characters_info("config/characters.txt");
QFileInfo music_info("config/music.txt"); QFileInfo music_info("config/music.txt");
QFileInfo backgrounds_info("config/backgrounds.txt");
if (!fileExists(&areas_info)) { if (!fileExists(&areas_info)) {
qCritical() << "areas.ini doesn't exist!"; qCritical() << "areas.ini doesn't exist!";
@ -53,6 +54,10 @@ bool ConfigManager::initConfig()
qCritical() << "music.txt doesn't exist!"; qCritical() << "music.txt doesn't exist!";
return false; return false;
} }
if (!fileExists(&backgrounds_info)) {
qCritical() << "backgrounds.txt doesn't exist!";
return false;
}
config.beginGroup("Info"); config.beginGroup("Info");
QString config_version = config.value("version", "none").toString(); QString config_version = config.value("version", "none").toString();

View File

@ -85,6 +85,7 @@ void AOClient::pktLoadingDone(AreaData* area, int argc, QStringList argv, AOPack
sendPacket("HP", {"1", QString::number(area->def_hp)}); sendPacket("HP", {"1", QString::number(area->def_hp)});
sendPacket("HP", {"2", QString::number(area->pro_hp)}); sendPacket("HP", {"2", QString::number(area->pro_hp)});
sendPacket("FA", server->area_names); sendPacket("FA", server->area_names);
sendPacket("BN", {area->background});
sendPacket("OPPASS", {"DEADBEEF"}); sendPacket("OPPASS", {"DEADBEEF"});
sendPacket("DONE"); sendPacket("DONE");
} }

View File

@ -61,6 +61,13 @@ void Server::start()
if(music_list[0].contains(".")) // Add a default category if none exists if(music_list[0].contains(".")) // Add a default category if none exists
music_list.insert(0, "==Music=="); music_list.insert(0, "==Music==");
QFile bg_file("config/backgrounds.txt");
bg_file.open(QIODevice::ReadOnly | QIODevice::Text);
while (!bg_file.atEnd()) {
backgrounds.append(bg_file.readLine().trimmed());
}
bg_file.close();
// TODO: add verification that this exists // TODO: add verification that this exists
QSettings areas_ini("config/areas.ini", QSettings::IniFormat); QSettings areas_ini("config/areas.ini", QSettings::IniFormat);
area_names = areas_ini.childGroups(); area_names = areas_ini.childGroups();