From 844a69cd50609cac8b3470f3eb6c5234e8d0c762 Mon Sep 17 00:00:00 2001 From: claywar Date: Mon, 13 May 2024 08:48:34 -0400 Subject: [PATCH] Add plaudits to char_points and RoeSparkUpdatePacket --- src/map/packets/roe_sparkupdate.cpp | 5 ++--- tools/migrations/041_plaudits.py | 28 ++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 3 deletions(-) create mode 100644 tools/migrations/041_plaudits.py diff --git a/src/map/packets/roe_sparkupdate.cpp b/src/map/packets/roe_sparkupdate.cpp index fac94d5e0d8..be47ba976b6 100644 --- a/src/map/packets/roe_sparkupdate.cpp +++ b/src/map/packets/roe_sparkupdate.cpp @@ -32,7 +32,7 @@ CRoeSparkUpdatePacket::CRoeSparkUpdatePacket(CCharEntity* PChar) this->setType(0x110); this->setSize(0x14); - const char* query = "SELECT spark_of_eminence, deeds FROM char_points WHERE charid = %d"; + const char* query = "SELECT spark_of_eminence, deeds, plaudits FROM char_points WHERE charid = %d"; uint32 vanaTime = CVanaTime::getInstance()->getVanaTime(); uint32 daysSinceEpoch = vanaTime / (60 * 60 * 24); @@ -44,8 +44,7 @@ CRoeSparkUpdatePacket::CRoeSparkUpdatePacket(CCharEntity* PChar) ref(0x04) = _sql->GetIntData(0); ref(0x08) = _sql->GetIntData(1); - ref(0x0A) = 0x00; - ref(0x0B) = 0x00; + ref(0x0A) = _sql->GetIntData(2); ref(0x0C) = daysSinceEpoch % 6; // Unity Shared Daily (0-5) ref(0x0D) = weeksSinceEpoch % 4; // Unity Leader Weekly (0-3) diff --git a/tools/migrations/041_plaudits.py b/tools/migrations/041_plaudits.py new file mode 100644 index 00000000000..6c30305cd86 --- /dev/null +++ b/tools/migrations/041_plaudits.py @@ -0,0 +1,28 @@ +import mariadb + + +def migration_name(): + return "Adding plaudits column to char_points table" + + +def check_preconditions(cur): + return + + +def needs_to_run(cur): + # Ensure waypoints column exists in char_unlocks + cur.execute("SHOW COLUMNS FROM char_points LIKE 'plaudits'") + if not cur.fetchone(): + return True + return False + + +def migrate(cur, db): + try: + cur.execute( + "ALTER TABLE char_points \ + ADD COLUMN `plaudits` smallint(5) DEFAULT 0;" + ) + db.commit() + except mariadb.Error as err: + print("Something went wrong: {}".format(err))