[Dynamic Zones] Implement dz switch id (#2343)

This adds the `dz_switch_id` field to doors and dynamic_zones. It will
allow for compasses to be automatically added to dz entrances and will
support moving clients to the dz on use without needing to script it.
These can be imported for switches/doors from live packet dumps.

Also removes compass packet encoders (same struct in all clients)
This commit is contained in:
hg
2022-07-30 22:00:11 -04:00
committed by GitHub
parent 1351f147f4
commit 676467cbdc
42 changed files with 349 additions and 235 deletions
@@ -75,6 +75,7 @@ public:
int max_players;
int instance_id;
int type;
int dz_switch_id;
int compass_zone_id;
float compass_x;
float compass_y;
@@ -109,6 +110,7 @@ public:
dynamic_zones.max_players,
dynamic_zones.instance_id,
dynamic_zones.type,
dynamic_zones.dz_switch_id,
dynamic_zones.compass_zone_id,
dynamic_zones.compass_x,
dynamic_zones.compass_y,
@@ -147,6 +149,7 @@ public:
entry.max_players = strtol(row[col++], nullptr, 10);
entry.instance_id = strtol(row[col++], nullptr, 10);
entry.type = strtol(row[col++], nullptr, 10);
entry.dz_switch_id = strtol(row[col++], nullptr, 10);
entry.compass_zone_id = strtol(row[col++], nullptr, 10);
entry.compass_x = strtof(row[col++], nullptr);
entry.compass_y = strtof(row[col++], nullptr);
@@ -261,6 +264,18 @@ public:
}
}
static void UpdateSwitchID(Database& db, uint32_t dz_id, int dz_switch_id)
{
if (dz_id != 0)
{
std::string query = fmt::format(SQL(
UPDATE {} SET dz_switch_id = {} WHERE {} = {};
), TableName(), dz_switch_id, PrimaryKey(), dz_id);
db.QueryDatabase(query);
}
}
struct DynamicZoneInstancePlayerCount
{
uint32_t id;