--- a/rts/Game/WebbarBrowser.h +++ b/rts/Game/WebbarBrowser.h @@ -23,6 +23,7 @@ #include "Sim/Features/Feature.h" #include "Sim/Features/FeatureDef.h" #include "Sim/Units/CommandAI/FactoryCAI.h" +#include "Game/WebbarResourceShare.h" // Full authoritative publication for view changes, handover and paused commands. static bool webbarStateRefresh = false; @@ -125,7 +126,7 @@ // EB4 (M5) bits: 22 pose mailbox (only used when the page asks for it) | 23 removals by cause. // EB1 bits: 17 solo result from BAR game_end | 18 PvE GameRulesParams | 19 RaptorEvent/ScavEvent | // 20 display-only PvE catalog | 21 own/allied experience, self-destruct and damage reports. - MAIN_THREAD_EM_ASM({ if (Module['webbarProtocol']) Module['webbarProtocol'](9, 2147483647 /* bits 25: authorized HUD reports, 26: native UI events, 27: original awards, 29: typed creation-state admission and exact queues | bit 30: complete queue actions, original factory modifiers and owned factory provenance | bit 28: Legion carrier spawn switch and owned reactive armor (WRA1) | bit 24: read-only replay playback, controls and perspectives | bit 23: unit removals by cause (WLC1) | bit 22: pose mailbox (WEBBAR_POSE_MAILBOX, WebbarPoses.h) | bits 17-21: EB1 (above) | bit 16: match recovery stream export + resume | restore | shields | cloak | resurrection | native work effects | area resurrection | manual launch | capture | smart trajectory | energy conversion | geothermal | selectability | build restrictions | queue edit | game speed | engine memory */); }); + MAIN_THREAD_EM_ASM({ if (Module['webbarProtocol']) Module['webbarProtocol'](9, 4294967295 /* bit 31: original resource share-level commands | bits 25: authorized HUD reports, 26: native UI events, 27: original awards, 29: typed creation-state admission and exact queues | bit 30: complete queue actions, original factory modifiers and owned factory provenance | bit 28: Legion carrier spawn switch and owned reactive armor (WRA1) | bit 24: read-only replay playback, controls and perspectives | bit 23: unit removals by cause (WLC1) | bit 22: pose mailbox (WEBBAR_POSE_MAILBOX, WebbarPoses.h) | bits 17-21: EB1 (above) | bit 16: match recovery stream export + resume | restore | shields | cloak | resurrection | native work effects | area resurrection | manual launch | capture | smart trajectory | energy conversion | geothermal | selectability | build restrictions | queue edit | game speed | engine memory */); }); PublishWebbarEngineMemory(); MAIN_THREAD_EM_ASM({ if (Module['webbarIdentity']) Module['webbarIdentity']($0, $1, $2, $3); @@ -311,6 +312,8 @@ std::vector ids; if (order.count > 64 || gu->spectating || !playerHandler.IsValidPlayer(gu->myPlayerNum)) { status = 1; + } else if (order.kind == 1017 || order.kind == 1018) { + status = SetWebbarResourceShare(order.kind == 1017, order.count, order.target, order.options, order.x, order.z, order.radius); } else if (order.kind == 1010) { status = SetWebbarEnergyReserve(order.count, order.target, order.options); } else if (order.kind == 1000) { --- a/rts/Game/WebbarResourceShare.h +++ b/rts/Game/WebbarResourceShare.h @@ -0,0 +1,19 @@ +/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ +#pragma once +#include +#include + +// Spring.SetShareLevel uses the standard network message. Never mutate synced +// team state here, select another team, or infer execution from bridge admission. +static int SetWebbarResourceShare(bool metal, uint32_t count, uint32_t target, + uint32_t options, float level, float z, float radius) +{ + if (count != 0 || target != UINT32_MAX || options != 0 || z != 0.0f || radius != 0.0f || !std::isfinite(level) || level < 0.0f || level > 1.0f) return 6; + if (gu->spectating || webbarReplay::Enabled() || gs->noHelperAIs || gs->PreSimFrame() || !playerHandler.IsValidPlayer(gu->myPlayerNum) || !teamHandler.IsValidTeam(gu->myTeam)) return 1; + const auto* player = playerHandler.Player(gu->myPlayerNum); + if (player->spectator || player->team != gu->myTeam) return 1; + const CTeam* team = teamHandler.Team(gu->myTeam); + clientNet->Send(CBaseNetProtocol::Get().SendSetShare(gu->myPlayerNum, gu->myTeam, + metal ? level : team->resShare.metal, metal ? team->resShare.energy : level)); + return 0; +}