1
0
forked from mirrors/0ad

fix: reset promoted worker metadata

fix: #7471
(cherry picked from commit 6b87a9b932)
Signed-off-by: Itms <itms@wildfiregames.com>
This commit is contained in:
Langbart
2025-01-08 01:35:37 +01:00
committed by Itms
parent beee5b2b8b
commit 19fda90656
2 changed files with 12 additions and 5 deletions
@@ -657,7 +657,7 @@ PETRA.BaseManager.prototype.reassignIdleWorkers = function(gameState, idleWorker
// Support elephant can only be builders
if (ent.hasClass("Support") && ent.hasClass("Elephant"))
{
ent.setMetadata(PlayerID, "subrole", "idle");
ent.setMetadata(PlayerID, "subrole", PETRA.Worker.SUBROLE_IDLE);
continue;
}
@@ -157,10 +157,17 @@ PETRA.BasesManager.prototype.checkEvents = function(gameState, events)
const base = this.getBaseByID(baseID);
// Promoted workers should be reset - their new gathering rates/capabilities might differ meaningfully.
if (ent.getMetadata(PlayerID, "role") === PETRA.Worker.ROLE_WORKER) {
ent.deleteAllMetadata(PlayerID);
ent.setMetadata(PlayerID, "base", baseID);
base.assignRolelessUnits(undefined, [ent]);
if (ent.getMetadata(PlayerID, "role") === PETRA.Worker.ROLE_WORKER)
{
ent.setMetadata(PlayerID, "subrole", PETRA.Worker.SUBROLE_IDLE);
if (!ent.isGatherer())
{
// TODO: Find a way to properly reset the metadata, as this is currently done selectively
ent.setMetadata(PlayerID, "gather-type", undefined);
ent.setMetadata(PlayerID, "supply", undefined);
ent.setMetadata(PlayerID, "role", undefined);
base.assignRolelessUnits(gameState, [ent]);
}
continue;
}