diff --git a/.github/workflows/arma.yml b/.github/workflows/arma.yml index 73aca4269..034443d2b 100644 --- a/.github/workflows/arma.yml +++ b/.github/workflows/arma.yml @@ -11,7 +11,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout the source code - uses: actions/checkout@v4 + uses: actions/checkout@v7 - name: Validate SQF run: python3 tools/sqf_validator.py - name: Validate Config @@ -23,7 +23,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout the source code - uses: actions/checkout@v4 + uses: actions/checkout@v7 - name: Lint (sqflint) uses: arma-actions/sqflint@master continue-on-error: true # No failure due to many false-positives @@ -32,14 +32,14 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout the source code - uses: actions/checkout@v4 + uses: actions/checkout@v7 - name: Setup HEMTT uses: arma-actions/hemtt@v1 - name: Run HEMTT build run: chmod +x hemtt/hemtt && hemtt/hemtt build - name: Rename build folder run: mv .hemttout/build .hemttout/@theseus_mods - - uses: actions/upload-artifact@v4 + - uses: actions/upload-artifact@v7 with: name: TheseusMods_${{ github.sha }}-nobin path: .hemttout/@* diff --git a/.github/workflows/extensions.yml b/.github/workflows/extensions.yml index 4a7df07f2..344d2f9eb 100644 --- a/.github/workflows/extensions.yml +++ b/.github/workflows/extensions.yml @@ -19,27 +19,32 @@ jobs: include: - toolchain: stable-x86_64-unknown-linux-gnu os: ubuntu-latest - from: libapollo_client.so + prefix: lib + ext: .so to: _x64.so - toolchain: stable-x86_64-pc-windows-msvc os: windows-latest - from: apollo_client.dll + prefix: "" + ext: .dll to: _x64.dll - - toolchain: stable-i686-pc-windows-msvc - os: windows-latest - from: apollo_client.dll - to: .dll runs-on: ${{ matrix.os }} steps: - name: Checkout the source code - uses: actions/checkout@v4 + uses: actions/checkout@v7 - name: Install Rust Toolchain run: rustup toolchain install ${{ matrix.toolchain }} + - name: Test + run: cd extensions && cargo +${{ matrix.toolchain }} test - name: Build run: cd extensions && cargo +${{ matrix.toolchain }} build --release - name: Move - run: mkdir release && cp extensions/target/release/${{ matrix.from }} release/tac_apollo_client${{ matrix.to }} - - uses: actions/upload-artifact@v4 + shell: bash + run: | + mkdir release + for name in apollo_client apollo_server; do + cp extensions/target/release/${{ matrix.prefix }}${name}${{ matrix.ext }} release/tac_${name}${{ matrix.to }} + done + - uses: actions/upload-artifact@v7 with: name: extensions-${{ matrix.toolchain }}-${{ github.sha }} path: release diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 96c060472..dae4332cd 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -10,7 +10,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout the source code - uses: actions/checkout@v4 + uses: actions/checkout@v7 - name: Install Python packages run: | pip3 install wheel diff --git a/README.md b/README.md index e4a6ee97b..896bbdd97 100644 --- a/README.md +++ b/README.md @@ -49,7 +49,22 @@ _Replace `hemtt` with `hemtt.exe` on Windows._ ### Extensions **Requirements:** -- Rust (>= 1.59) +- Rust (>= 1.88, edition 2024) +- 64-bit only (`_x64`): Arma 3 no longer runs 32-bit, so there are no x86 builds +- Linux: OpenSSL development files (`libssl-dev`, `pkg-config`) to build; OpenSSL 3 (`libssl3`) where the `.so` is loaded. Windows uses its own TLS (schannel) Extensions builds must be invoked manually or via CI: - Run `$ cargo build [--release]` in `extensions` directory +- Run `$ cargo test` in `extensions` directory + +Both live in the mod folder (`tac_apollo_*_x64.dll` / `.so`); only servers load `tac_apollo_server`. They use the development website unless the server is the live one, as does testing without a server. + +- `tac_apollo_client`: loaded by players' games, reads players' loadouts, lockers, items and trainings from Minotaur's Apollo API (`/apollo/v1/client`) on the website the server uses. + - Log: `logs/tac_apollo_client.log`. +- `tac_apollo_server`: loaded by game servers, saves and loads players, vehicles and lockers through Minotaur's Apollo API (`/apollo/v1/server`). + - Log: `logs/tac_apollo_server.log`. + - End-to-end test against a running Minotaur: see `extensions/apollo-server/tests/minotaur.rs`. +- Settings, as environment variables (game servers run in Docker): + - `APOLLO_SERVER_TOKEN` (required on servers): from that website's admin (Chronos · Apollo › Game servers). + - `APOLLO_SERVER_LIVE=true` on the live server only: it and its players use the live website. + - `APOLLO_LIVE_URL` / `APOLLO_DEV_URL`, only if the live / development website isn't the usual one (`https://www.theseus-aegis.com` / `https://srv.theseus-aegis.com/minotaur`), e.g. `APOLLO_DEV_URL=http://localhost:8000` for a local Minotaur. Both extensions read them; players don't need to set anything. diff --git a/addons/apollo/README.md b/addons/apollo/README.md index 0fff99d15..20f18578d 100644 --- a/addons/apollo/README.md +++ b/addons/apollo/README.md @@ -2,6 +2,28 @@ Adds Apollo in-game persistence system (part of Chronos). +## Persistent vehicles + +- **Saving:** every 60 s the server saves each persistent vehicle (`fnc_vehicleSaveServer`): one SQF array of `[key, value]` pairs (`fnc_vehicleSingletonSave`), sent with apollo-server's `storeVehicle`. Minotaur keeps it (`apollo/vehicles.py`). +- **Loading:** Minotaur sends the same pairs back as data, in pieces (`getVehicle`), and `fnc_vehicleSingletonLoad` makes the vehicle from them (`fnc_setCargo` for inventories). Minotaur sends no SQF code: a new saved property needs its save here, its field in Minotaur, and its load here. +- **Saved:** position and tilt, damage and hit points, fuel, lock, customization, cargo (backpacks, uniforms and vests with their contents, magazines with their rounds, weapons with their attachments), turret magazines, pylons, ACE cargo, ACE fuel (finite) and ACE ammo (the "limited" supply's count, or the "only specific magazines" supply's magazines), grad_trenches progress. +- **Settings** (TAC Apollo › Vehicles, all on by default): a mission can turn off objects that aren't vehicles (trenches, sandbags, fortifications, crates), static weapons (with ACE CSW tripods), turret ammo, pylons, ACE cargo, and ACE fuel and ammo supply. Each is then neither saved nor loaded (a vehicle keeps what it's made with). +- **Persistent:** vehicles loaded from Chronos, objects added with Zeus "Add object to Chronos", and what players place, a second later (`fnc_registerPlaced`, if its setting is on): static weapons (ACE CSW `deployWeaponSucceeded`, vanilla `WeaponAssembled`), trenches (`ace_trenches_placed`), ACE fortify objects (`acex_fortify_objectPlaced`), and, with no event for them, ACE sandbags and tripods (server class init handlers). Objects that exist before the vehicles are loaded (the mission's) aren't. All go through `fnc_registerVehicle`. +- **Removal:** a persistent vehicle is removed from Chronos a second after it's deleted (packed up, deleted in Zeus, a wreck cleaned up; a `Deleted` handler from `fnc_registerVehicle`, `removeVehicle`). A mission ending runs no more timers, so it removes nothing. Any that went without the handler are removed at the next save round. A vehicle loaded as ACE cargo is saved inside its carrier only. +- **Round-trip test** (test servers only): from the debug console, `[cursorObject] remoteExec ["tac_apollo_fnc_testVehicleRoundTrip", 2]` saves the vehicle, deletes it, loads it back with the same functions as a restart, and reports the differences (RPT and chat). + +## Deaths + +A player's death is registered when they're killed (`fnc_handleKilled`, `playerDied`), with the loadout and variables at that moment and the death's key (its bodybag's ID). The respawn only reloads the player (`fnc_handleRespawn`, `playerRespawned`); if the killed event didn't register the death, the server registers it then. A player who leaves while dead isn't saved, and their corpse stays for its bodybag. + +## Locker (Armory) + +The Armory's stash and take go through `fnc_lockerAction` (and kits through `fnc_lockerTakeKit`). Minotaur replies with data only: nothing for a stash (the box is changed here once it accepted), `[class, count, rounds]` entries for what to add to the box when taking (`fnc_lockerQueue`). `fnc_boxCargo` adds or removes by the item's type. + +**Stash All** (the Armory's Stash screen): one server event; `fnc_lockerStashAll` empties backpacks, vests and uniforms into the box, then stashes each class with `fnc_lockerAction` (weapons first, then what they leave behind with the rest), as a single stash works it out (`tac_armory_fnc_getStashVariant`). What the locker refuses stays in the box; `lockerStashAllDone` tells the player. + +The mod, apollo-server and Minotaur must be updated together: the save format, the data replies and `removeVehicle` are new (apollo-server stays 1.0.0 until the end of development). + ### Authors - [Jonpas](https://github.com/jonpas) diff --git a/addons/apollo/XEH_PREP.hpp b/addons/apollo/XEH_PREP.hpp index 49d558aed..a971b30b1 100644 --- a/addons/apollo/XEH_PREP.hpp +++ b/addons/apollo/XEH_PREP.hpp @@ -1,14 +1,33 @@ +PREP(bodybagReturn); +PREP(boxCargo); PREP(callExt); +PREP(callServerExt); PREP(endMissionError); +PREP(getCargo); +PREP(getLoadout); PREP(getPlayerInfo); +PREP(getRadios); +PREP(getScopeDials); +PREP(getVariables); PREP(handleDisconnect); PREP(handleKilled); PREP(handleRespawn); -PREP(invokeJavaMethod); PREP(lockerAction); +PREP(lockerQueue); +PREP(lockerStashAll); +PREP(lockerTakeKit); PREP(playerLoadClient); PREP(playerSaveClient); PREP(playerSingletonSave); +PREP(registerPlaced); +PREP(registerVehicle); +PREP(runtimeApply); +PREP(runtimeSave); +PREP(setCargo); +PREP(setRadios); +PREP(setScopeAdjustment); +PREP(setVariables); +PREP(testVehicleRoundTrip); PREP(vehicleLoad); PREP(vehicleSaveServer); PREP(vehicleSingletonLoad); diff --git a/addons/apollo/XEH_postInitClient.sqf b/addons/apollo/XEH_postInitClient.sqf index 6131b3b7e..c06475c5a 100644 --- a/addons/apollo/XEH_postInitClient.sqf +++ b/addons/apollo/XEH_postInitClient.sqf @@ -3,6 +3,21 @@ // Exit on Headless if (!hasInterface) exitWith {}; +// Static weapons the player deploys (ACE CSW or vanilla assembly) are made persistent by the server, +// a second later so it has the new object +if (GVAR(enabled)) then { + ["ace_csw_deployWeaponSucceeded", { + params ["_weapon"]; + [{[QGVAR(staticWeaponDeployed), _this] call CBA_fnc_serverEvent}, [_weapon], 1] call CBA_fnc_waitAndExecute; + }] call CBA_fnc_addEventHandler; + + ["CAManBase", "WeaponAssembled", { + params ["_unit", "_weapon"]; + if (!local _unit || {!(_weapon isKindOf "StaticWeapon")}) exitWith {}; + [{[QGVAR(staticWeaponDeployed), _this] call CBA_fnc_serverEvent}, [_weapon], 1] call CBA_fnc_waitAndExecute; + }] call CBA_fnc_addClassEventHandler; +}; + [QGVAR(initialized), { // Check ApolloClient presenece and version private _apolloClientReturn = "tac_apollo_client" callExtension ["version", []]; // ["1.0.0", 0, 0] @@ -20,6 +35,9 @@ if (!hasInterface) exitWith {}; ["Your connection has been terminated - Unknown error with Chronos!"] call FUNC(endMissionError); }] call CBA_fnc_addEventHandler; + // Back as before a disconnect (mission only, FUNC(runtimeSave)) + [QGVAR(runtimeApply), FUNC(runtimeApply)] call CBA_fnc_addEventHandler; + // Load player after Respawn EH [QGVAR(reinitializePlayer), { params ["_player", "_registeredDeath"]; diff --git a/addons/apollo/XEH_postInitServer.sqf b/addons/apollo/XEH_postInitServer.sqf index 4e9a43012..bf54ed323 100644 --- a/addons/apollo/XEH_postInitServer.sqf +++ b/addons/apollo/XEH_postInitServer.sqf @@ -2,25 +2,21 @@ if (!GVAR(enabled)) exitWith { TRACE_1("Apollo Disabled",GVAR(enabled)) }; -// Check JNI presence -private _jniReturn = "jni" callExtension ["version", []]; // ["1.0.0", 0, 0] -_jniReturn params ["_jniVersion"]; -if (_jniVersion != REQUIRED_JNI_VERSION) exitWith { - ERROR_2("Failed to initialize - Wrong JNI extension version (active: %1 - required: %2)!",_jniVersion,REQUIRED_JNI_VERSION); +// Check Apollo Server presence +private _serverReturn = "tac_apollo_server" callExtension ["version", []]; // ["1.0.0", 0, 0] +_serverReturn params ["_serverVersion"]; +if (_serverVersion != REQUIRED_APOLLOSERVER_VERSION) exitWith { + ERROR_2("Failed to initialize - Wrong Apollo Server extension version (active: %1 - required: %2)!",_serverVersion,REQUIRED_APOLLOSERVER_VERSION); }; -// Set server type (debug or live) globally -private _serverType = ["getServerType"] call FUNC(invokeJavaMethod); -if (_serverType == "error") exitWith { - ERROR_1("Failed to initialize - Invalid server type (%1)!",_serverType); -}; -GVAR(isDebug) = [false, true] select (_serverType isEqualTo "debug"); -publicVariable QGVAR(isDebug); +// Website the server uses (live or development), players use the same +GVAR(liveApi) = ("tac_apollo_server" callExtension ["getApi", []]) select 0 == "live"; +publicVariable QGVAR(liveApi); // Reset server if map/mission changed from last saved private _resetError = false; if (GVAR(allowServerReset)) then { - private _reset = ["resetServer", GVAR(enabledPlayers), GVAR(enabledVehicles), serverName, worldName, missionName] call FUNC(invokeJavaMethod); + private _reset = ["resetServer", GVAR(enabledPlayers), GVAR(enabledVehicles), serverName, worldName, missionName] call FUNC(callServerExt); if (_reset == "error") exitWith {_resetError = true; }; if (_reset == "none") exitWith { INFO_3("Server reset not performed (server: %1, map: %2, mission: %3)",serverName,worldName,missionName); }; INFO_3("Server reset successfully (server: %1, map: %2, mission: %3)",serverName,worldName,missionName); @@ -29,20 +25,69 @@ if (_resetError) exitWith { ERROR_3("Server failed to reset after map change! (s if (GVAR(enabledVehicles)) then { call FUNC(vehicleLoad); + + // What players place is persistent, each with its setting (FUNC(registerPlaced)); removed from + // Chronos when it's deleted (packed up, dug out) + [QGVAR(staticWeaponDeployed), { + params ["_weapon"]; + [_weapon, GVAR(vehiclesStaticWeapons)] call FUNC(registerPlaced); + }] call CBA_fnc_addEventHandler; + ["ace_trenches_placed", { + params ["", "_trench"]; + [_trench, GVAR(vehiclesObjects)] call FUNC(registerPlaced); + }] call CBA_fnc_addEventHandler; + ["acex_fortify_objectPlaced", { + params ["", "", "_object"]; + [_object, GVAR(vehiclesObjects)] call FUNC(registerPlaced); + }] call CBA_fnc_addEventHandler; + // No event for these: their objects as they're made from now on (placement previews are local, or + // another class); a CSW tripod goes with static weapons + { + [_x, "init", { + params ["_object"]; + [_object, [GVAR(vehiclesObjects), GVAR(vehiclesStaticWeapons)] select (_object isKindOf "ace_csw_baseTripod")] call FUNC(registerPlaced); + }, true, ["ACE_SandbagObject_NoGeo"]] call CBA_fnc_addClassEventHandler; + } forEach ["ACE_SandbagObject", "ACE_TripodObject", "ace_csw_baseTripod"]; }; if (GVAR(enabledPlayers)) then { // Save player [QGVAR(savePlayer), { - params ["_player", "_name", "_type"]; - [_player, getPlayerUID _player, _name, _type] call FUNC(playerSingletonSave); + params ["_player", "_name", "_type", ["_variables", nil], ["_radios", nil], ["_dials", []]]; + private _uid = getPlayerUID _player; + // What only the player's machine knows, for this and the disconnect save + if (!isNil "_variables") then { + _player setVariable [QGVAR(clientState), [_variables, _radios, _dials]]; + }; + [_player, _uid, _name, _type] call FUNC(playerSingletonSave); + + // Reconnected: back as they were when they left (mission only) + if (_type == "validate") then { + private _runtime = GVAR(playerRuntimeData) deleteAt _uid; + if (isNil "_runtime") exitWith {}; + _runtime params ["_team", "_vehicle", "_seat", "_medical", "_runtimeRadios", ["_runtimeDials", []]]; + [QGVAR(runtimeApply), [_player, _team, _vehicle, _seat, _medical, _runtimeRadios, _runtimeDials], _player] call CBA_fnc_targetEvent; + }; }] call CBA_fnc_addEventHandler; - // Player died + // Player killed: the death registered at once (FUNC(handleKilled)), the reply kept for the respawn [QGVAR(playerDied), { - params ["_player", "_killerUID"]; + params ["_player", "_uid", ["_deathKey", ""], ["_deathLoadout", []], ["_deathVariables", []]]; TRACE_1("Player Died",_this); - private _registeredDeath = ["playerDied", getPlayerUID _player, _killerUID] call FUNC(invokeJavaMethod); + GVAR(playerRuntimeData) deleteAt _uid; // a respawn starts fresh + GVAR(deathsRegistered) set [_uid, ["playerDied", _uid, _deathKey, _deathLoadout, _deathVariables] call FUNC(callServerExt)]; + }] call CBA_fnc_addEventHandler; + + // Player respawned: reloaded (basic gear); a death the killed event didn't register is registered now + [QGVAR(playerRespawned), { + params ["_player", "_corpse"]; + TRACE_1("Player Respawned",_this); + private _uid = getPlayerUID _player; + private _registeredDeath = GVAR(deathsRegistered) deleteAt _uid; + if (isNil "_registeredDeath") then { + GVAR(playerRuntimeData) deleteAt _uid; + _registeredDeath = ["playerDied", _uid, _corpse getVariable [QGVAR(deathKey), ""], _corpse getVariable [QGVAR(deathLoadout), []], _corpse getVariable [QGVAR(deathVariables), []]] call FUNC(callServerExt); + }; [QGVAR(reinitializePlayer), [_player, _registeredDeath], _player] call CBA_fnc_targetEvent; }] call CBA_fnc_addEventHandler; @@ -54,5 +99,8 @@ if (GVAR(enabledPlayers)) then { }; [QGVAR(lockerAction), FUNC(lockerAction)] call CBA_fnc_addEventHandler; +[QGVAR(lockerTakeKit), FUNC(lockerTakeKit)] call CBA_fnc_addEventHandler; +[QGVAR(lockerStashAll), FUNC(lockerStashAll)] call CBA_fnc_addEventHandler; +[QGVAR(bodybagReturn), FUNC(bodybagReturn)] call CBA_fnc_addEventHandler; -INFO_3("Server loaded successfully (Players: %1 - Vehicles: %2 - Debug: %3)",GVAR(enabledPlayers),GVAR(enabledVehicles),GVAR(isDebug)); +INFO_3("Server loaded successfully (Players: %1 - Vehicles: %2 - Live API: %3)",GVAR(enabledPlayers),GVAR(enabledVehicles),GVAR(liveApi)); diff --git a/addons/apollo/XEH_preInit.sqf b/addons/apollo/XEH_preInit.sqf index 2aefa1d3a..62b48a3dc 100644 --- a/addons/apollo/XEH_preInit.sqf +++ b/addons/apollo/XEH_preInit.sqf @@ -10,9 +10,11 @@ PREP_RECOMPILE_END; if (isServer) then { GVAR(vehiclesLoaded) = false; - GVAR(vehiclesList) = []; + GVAR(vehicles) = createHashMap; // vehicle ID -> object, the persistent ones (FUNC(registerVehicle)) + GVAR(playerRuntimeData) = createHashMap; // UID -> state kept for the mission (FUNC(runtimeSave)) + GVAR(deathsRegistered) = createHashMap; // UID -> playerDied's reply, from the death until the respawn }; -GVAR(isDebug) = false; +GVAR(liveApi) = false; // the live website only when the server uses it, otherwise the development one ADDON = true; diff --git a/addons/apollo/functions/fnc_bodybagReturn.sqf b/addons/apollo/functions/fnc_bodybagReturn.sqf new file mode 100644 index 000000000..11c474d28 --- /dev/null +++ b/addons/apollo/functions/fnc_bodybagReturn.sqf @@ -0,0 +1,83 @@ +#include "..\script_component.hpp" +/* + * Author: Jonpas + * Sends a bodybag at base to the website, where its owner chooses what goes back into their locker + * ("Return to owner"). What's in the bag is capped by what went into it (tac_bodybag_contents); the + * website caps it by the loadout at death. Deletes the bag once sent and tells the returner (and the + * owner, if on the server) what can be claimed. + * + * Arguments: + * 0: Bodybag + * 1: Returner + * + * Return Value: + * None + * + * Example: + * [cursorObject, player] call tac_apollo_fnc_bodybagReturn + * + * Public: No + */ + +params ["_bodybag", "_returner"]; + +if (isNull _bodybag || {_bodybag getVariable ["tac_bodybag_busy", false]}) exitWith {}; +_bodybag setVariable ["tac_bodybag_busy", true, true]; + +private _ownerUID = _bodybag getVariable ["tac_bodybag_ownerUID", ""]; +private _ownerName = _bodybag getVariable ["tac_bodybag_ownerName", ""]; +private _deathKey = _bodybag getVariable ["tac_bodybag_deathKey", ""]; +private _record = _bodybag getVariable ["tac_bodybag_contents", createHashMap]; + +// Count the bag, containers in it included +private _counts = createHashMap; +private _fnc_add = { + params ["_cargo"]; + _cargo params ["_classes", "_amounts"]; + { + private _class = toLowerANSI _x; + _counts set [_class, (_counts getOrDefault [_class, 0]) + (_amounts select _forEachIndex)]; + } forEach _classes; +}; +{ + [getItemCargo _x] call _fnc_add; + [getWeaponCargo _x] call _fnc_add; + [getMagazineCargo _x] call _fnc_add; + [getBackpackCargo _x] call _fnc_add; +} forEach ([_bodybag] + ((everyContainer _bodybag) apply {_x select 1})); + +// Only what went into the bag (items stuffed in on the way are deleted with it) +private _contents = []; +{ + private _count = _y min (_record getOrDefault [_x, 0]); + if (_count > 0) then { + _contents pushBack [_x, _count]; + }; +} forEach _counts; + +private _reply = ["bodybagReturn", _ownerUID, _deathKey, _contents] call FUNC(callServerExt); +private _parsed = parseSimpleArray ([_reply, "[]"] select (_reply == "error")); +_parsed params [["_result", "error"], ["_name", _ownerName], ["_returnable", 0], ["_lost", []]]; +TRACE_2("Bodybag Return",_ownerUID,_reply); + +private _owner = (allPlayers select {getPlayerUID _x == _ownerUID}) param [0, objNull]; +private _text = switch (_result) do { + case "ok": { + private _lostText = (_lost apply {format ["%1x %2 (%3)", _x select 1, _x select 0, _x select 2]}) joinString ", "; + format [localize LSTRING(BodybagSent), _name, _returnable, [_lostText, "-"] select (_lostText == "")] + }; + case "already": {format [localize LSTRING(BodybagAlready), _name]}; + case "gone": {format [localize LSTRING(BodybagGone), _name]}; + case "error": { + _bodybag setVariable ["tac_bodybag_busy", false, true]; + localize ([LSTRING(BodybagFailed), LSTRING(BodybagRespawn)] select ((_parsed param [1, ""]) == "respawn")) + }; +}; + +if (_result != "error") then { + deleteVehicle _bodybag; + if (!isNull _owner && {_owner != _returner}) then { + _text remoteExecCall ["hint", _owner]; + }; +}; +_text remoteExecCall ["hint", _returner]; diff --git a/addons/apollo/functions/fnc_boxCargo.sqf b/addons/apollo/functions/fnc_boxCargo.sqf new file mode 100644 index 000000000..018d6d3fe --- /dev/null +++ b/addons/apollo/functions/fnc_boxCargo.sqf @@ -0,0 +1,65 @@ +#include "..\script_component.hpp" +/* + * Author: Jonpas + * Adds items to the Armory's box or removes them from it, by the item's type (as the Armory does + * without Chronos). Server only. + * + * Arguments: + * 0: Box + * 1: Class Name + * 2: Count + * 3: Add (true) or remove (false) + * 4: Magazine Rounds (default: -1, adding: full, removing: any) + * 5: Keep Magazines (removing a weapon) (default: false) + * + * Return Value: + * None + * + * Example: + * [box, "30Rnd_65x39_caseless_mag", 2, true, 12] call tac_apollo_fnc_boxCargo + * + * Public: No + */ + +params ["_box", "_class", "_count", "_add", ["_rounds", -1], ["_keepMagazines", false]]; + +if (_count <= 0) exitWith {}; + +private _isBackpack = [_class] call ACEFUNC(backpacks,isBackpack); +private _itemType = ([_class] call ACEFUNC(common,getItemType)) select 0; + +if (_add) then { + switch (true) do { + case (_isBackpack): { + _box addBackpackCargoGlobal [_class, _count]; + }; + case (_itemType == "weapon"): { + _box addWeaponCargoGlobal [_class, _count]; + }; + case (_itemType == "magazine"): { + if (_rounds < 0) then { + _box addMagazineCargoGlobal [_class, _count]; + } else { + _box addMagazineAmmoCargo [_class, _count, _rounds]; + }; + }; + default { + _box addItemCargoGlobal [_class, _count]; + }; + }; +} else { + switch (true) do { + case (_isBackpack): { + [_box, _class, _count, true] call CBA_fnc_removeBackpackCargo; + }; + case (_itemType == "weapon"): { + [_box, _class, _count, _keepMagazines] call CBA_fnc_removeWeaponCargo; + }; + case (_itemType == "magazine"): { + [_box, _class, _count, _rounds] call CBA_fnc_removeMagazineCargo; + }; + default { + [_box, _class, _count, true] call CBA_fnc_removeItemCargo; + }; + }; +}; diff --git a/addons/apollo/functions/fnc_callExt.sqf b/addons/apollo/functions/fnc_callExt.sqf index 1c44593d8..f51f9285b 100644 --- a/addons/apollo/functions/fnc_callExt.sqf +++ b/addons/apollo/functions/fnc_callExt.sqf @@ -14,7 +14,7 @@ * Extension Result * * Example: - * ["getAccessibleItemClasses", []] call tac_apollo_fnc_callExt + * ["getAccessibleItemClasses", [, ]] call tac_apollo_fnc_callExt * * Public: No */ diff --git a/addons/apollo/functions/fnc_callServerExt.sqf b/addons/apollo/functions/fnc_callServerExt.sqf new file mode 100644 index 000000000..b664e6e33 --- /dev/null +++ b/addons/apollo/functions/fnc_callServerExt.sqf @@ -0,0 +1,33 @@ +#include "..\script_component.hpp" +/* + * Author: Jonpas + * Calls the Apollo Server extension (Chronos persistence through Minotaur's game API) and returns its answer. + * Non-string arguments are passed as their string representation. + * + * Arguments: + * 0: Command + * 1-inf: Arguments + * + * Return Value: + * Extension Return Value + * + * Example: + * ["storeInfantry", "save", "76561198000000000", "Name", [1, 2, 3], 90, [], "", []] call tac_apollo_fnc_callServerExt + * + * Public: No + */ + +params ["_command"]; + +if (isNil "_this" || {!(_this isEqualType [])} || {_this isEqualTo []} || {!(_command isEqualType "")}) exitWith {""}; + +private _arguments = (_this select [1]) apply {[str _x, _x] select (_x isEqualType "")}; + +private _return = "tac_apollo_server" callExtension [_command, _arguments]; +_return params ["_result", "_returnCode", "_errorCode"]; + +if (_returnCode != 0 || {!(_errorCode in EXT_VALID_ERROR_CODES)} || {_result == "error"}) then { + ERROR_4("Apollo Server failed! [command: %1, result: %2, return: %3, error: %4]",_command,_result,_returnCode,_errorCode); +}; + +_result diff --git a/addons/apollo/functions/fnc_getCargo.sqf b/addons/apollo/functions/fnc_getCargo.sqf new file mode 100644 index 000000000..f8e5586e2 --- /dev/null +++ b/addons/apollo/functions/fnc_getCargo.sqf @@ -0,0 +1,36 @@ +#include "..\script_component.hpp" +/* + * Author: Jonpas + * Returns what's in an object's inventory, for saving: items, magazines with their rounds, + * weapons with their attachments and loaded magazines, and containers (backpacks, uniforms, + * vests) with what's in them. + * + * Arguments: + * 0: Object + * + * Return Value: + * [items, magazines, weapons, containers] + * + * Example: + * [vehicle] call tac_apollo_fnc_getCargo + * + * Public: No + */ + +params ["_object"]; + +private _items = itemCargo _object; +private _containers = (everyContainer _object) apply { + _x params ["_class", "_container"]; + private _isBackpack = getNumber (configFile >> "CfgVehicles" >> _class >> "isBackpack") == 1; + // Uniforms and vests are also in itemCargo: saved as containers only + if (!_isBackpack) then { + private _index = _items find _class; + if (_index != -1) then { + _items deleteAt _index; + }; + }; + [_class, _isBackpack, [itemCargo _container, magazinesAmmoCargo _container, weaponsItemsCargo _container]] +}; + +[_items, magazinesAmmoCargo _object, weaponsItemsCargo _object, _containers] diff --git a/addons/apollo/functions/fnc_getLoadout.sqf b/addons/apollo/functions/fnc_getLoadout.sqf new file mode 100644 index 000000000..d7e97d9ae --- /dev/null +++ b/addons/apollo/functions/fnc_getLoadout.sqf @@ -0,0 +1,28 @@ +#include "..\script_component.hpp" +/* + * Author: Jonpas + * Returns a unit's loadout as Apollo saves it: ACRE radios filtered. Earplugs in the ears and the gunbag's weapon + * are kept apart (FUNC(getVariables)). + * + * Arguments: + * 0: Unit + * + * Return Value: + * Loadout + * + * Example: + * [player] call tac_apollo_fnc_getLoadout + * + * Public: No + */ + +params ["_unit"]; + +private _loadout = getUnitLoadout _unit; + +// Filter ACRE2 +if (["acre_api"] call ACEFUNC(common,isModLoaded)) then { + _loadout = [_loadout] call acre_api_fnc_filterUnitLoadout; +}; + +_loadout diff --git a/addons/apollo/functions/fnc_getPlayerInfo.sqf b/addons/apollo/functions/fnc_getPlayerInfo.sqf index daf7dc826..cb4530634 100644 --- a/addons/apollo/functions/fnc_getPlayerInfo.sqf +++ b/addons/apollo/functions/fnc_getPlayerInfo.sqf @@ -31,7 +31,7 @@ if (_playerUID isEqualTo "_SP_PLAYER_" || {_playerUID isEqualTo "_SP_AI_"}) exit [] }; -private _result = [_type, [_playerUID]] call FUNC(callExt); +private _result = [_type, [_playerUID, GVAR(liveApi)]] call FUNC(callExt); if (!isNil "_result") then { _result diff --git a/addons/apollo/functions/fnc_getRadios.sqf b/addons/apollo/functions/fnc_getRadios.sqf new file mode 100644 index 000000000..756aa69ad --- /dev/null +++ b/addons/apollo/functions/fnc_getRadios.sqf @@ -0,0 +1,27 @@ +#include "..\script_component.hpp" +/* + * Author: Jonpas + * Returns the local player's ACRE radio settings, kept for the mission so a reconnect gets them back + * (FUNC(setRadios)). Radios get new IDs on load, so they're kept by base class, in order. + * + * Arguments: + * None + * + * Return Value: + * [[[base radio, channel, volume, spatial], ...], active radio index, [multi push-to-talk radio indexes]] or [] + * + * Example: + * [] call tac_apollo_fnc_getRadios + * + * Public: No + */ + +if (!(["acre_api"] call ACEFUNC(common,isModLoaded)) || {!([] call acre_api_fnc_isInitialized)}) exitWith {[]}; + +private _list = [] call acre_api_fnc_getCurrentRadioList; +private _radios = _list apply { + [[_x] call acre_api_fnc_getBaseRadio, [_x] call acre_api_fnc_getRadioChannel, [_x] call acre_api_fnc_getRadioVolume, [_x] call acre_api_fnc_getRadioSpatial] +}; +private _ptt = ([] call acre_api_fnc_getMultiPushToTalkAssignment) apply {_list find _x}; + +[_radios, _list find ([] call acre_api_fnc_getCurrentRadio), _ptt] diff --git a/addons/apollo/functions/fnc_getScopeDials.sqf b/addons/apollo/functions/fnc_getScopeDials.sqf new file mode 100644 index 000000000..bec36c871 --- /dev/null +++ b/addons/apollo/functions/fnc_getScopeDials.sqf @@ -0,0 +1,34 @@ +#include "..\script_component.hpp" +/* + * Author: Jonpas + * Returns the ACE scope dials (elevation and windage) of the unit's weapons, kept for the mission only so a reconnect + * gets them back (FUNC(runtimeApply)); a new mission starts with them at zero, as ACE resets them on every load. + * The zero reference is kept across missions instead (FUNC(getVariables)). + * + * Arguments: + * 0: Unit + * + * Return Value: + * [[slot, weapon, optic, elevation, windage, simplified zeroing], ...] + * + * Example: + * [player] call tac_apollo_fnc_getScopeDials + * + * Public: No + */ + +params ["_unit"]; + +if !(missionNamespace getVariable [QACEGVAR(scopes,enabled), false]) exitWith {[]}; + +private _simplified = missionNamespace getVariable [QACEGVAR(scopes,simplifiedZeroing), false]; +private _adjustments = _unit getVariable [QACEGVAR(scopes,adjustment), []]; +private _dials = []; +{ + (_adjustments param [_forEachIndex, []]) params [["_elevation", 0], ["_windage", 0]]; + if (_x != "" && {_elevation isEqualType 0} && {_windage isEqualType 0}) then { + _dials pushBack [_forEachIndex, _x, (_unit weaponAccessories _x) param [2, ""], _elevation, _windage, _simplified]; + }; +} forEach [primaryWeapon _unit, secondaryWeapon _unit, handgunWeapon _unit]; + +_dials diff --git a/addons/apollo/functions/fnc_getVariables.sqf b/addons/apollo/functions/fnc_getVariables.sqf new file mode 100644 index 000000000..cd1a031f8 --- /dev/null +++ b/addons/apollo/functions/fnc_getVariables.sqf @@ -0,0 +1,100 @@ +#include "..\script_component.hpp" +/* + * Author: Jonpas + * Returns what's kept across missions out of the loadout, as [name, value] pairs for the website. + * Run where the unit is local (safety and zeroing are only known there). + * - insignia: the insignia class ("" none) + * - earplugs: in the ears (ACE Hearing) + * - gunbag_weapon: the weapon in an ACE gunbag ([weapon, [attachments], [[magazine, rounds], ...]] or []) + * - zeroing: per equipped weapon [weapon, optic, [[muzzle, muzzle name, distance, step], ...], ACE scopes zero reference] + * (each muzzle's zeroing; the ACE dials, elevation and windage, are kept for the mission only: FUNC(getScopeDials)) + * - safety: [[weapon, muzzle], ...] on safe (ACE safe mode) + * - base_items: [[class, base], ...] for items in the loadout in another state (tac_armory_fnc_getBaseVariant); + * Minotaur doesn't keep it for the player, it only learns which item each class is + * + * Arguments: + * 0: Unit + * + * Return Value: + * Variables + * + * Example: + * [player] call tac_apollo_fnc_getVariables + * + * Public: No + */ + +params ["_unit"]; + +// ACE keeps earplugs and the gunbag's weapon in CBA's extended loadout +private _extended = (_unit call CBA_fnc_getLoadout) param [1, createHashMap]; +if !(_extended isEqualType createHashMap) then { _extended = createHashMap; }; + +private _weapons = [primaryWeapon _unit, secondaryWeapon _unit, handgunWeapon _unit]; +private _adjustments = _unit getVariable [QACEGVAR(scopes,adjustment), []]; + +private _zeroing = []; +{ + if (_x != "") then { + private _weapon = _x; + private _optic = (_unit weaponAccessories _weapon) param [2, ""]; + private _zero = (_adjustments param [_forEachIndex, []]) param [2, 0]; + if !(_zero isEqualType 0) then { _zero = 0; }; + + // Every muzzle (the main one is the weapon's own class); a muzzle's name for the website ("" for the main one) + private _muzzles = []; + { + // [distance, step]; step -1 is a laser rangefinder's distance, which isn't kept + (_unit currentZeroing [_weapon, _x]) params [["_distance", 0], ["_step", -1]]; + if (_step >= 0 && {_distance > 0}) then { + private _name = ["", getText (configFile >> "CfgWeapons" >> _weapon >> _x >> "displayName")] select (_x != _weapon); + _muzzles pushBack [_x, _name, _distance, _step]; + }; + } forEach (_weapon call ACEFUNC(common,getWeaponMuzzles)); + + if (_muzzles isNotEqualTo [] || {_zero != 0}) then { + _zeroing pushBack [_weapon, _optic, _muzzles, _zero]; + }; + }; +} forEach _weapons; + +// A hashmap of weapon -> muzzles (a hashmap or an array) in current ACE, an array of weapons before +private _safety = []; +private _equipped = (_weapons - [""]) apply {toLowerANSI _x}; +private _safed = _unit getVariable [QACEGVAR(safemode,safedWeapons), []]; +if (_safed isEqualType createHashMap) then { + { + if ((toLowerANSI _x) in _equipped) then { + private _weapon = _x; + private _muzzles = switch (true) do { + case (_y isEqualType createHashMap): {keys _y}; + case (_y isEqualType []): {_y}; + default {[_weapon]}; + }; + { _safety pushBack [_weapon, _x]; } forEach _muzzles; + }; + } forEach _safed; +} else { + { if ((toLowerANSI _x) in _equipped) then { _safety pushBack [_x, _x]; }; } forEach _safed; +}; + +// Items in the loadout in another state (a 2D or PiP optic, a switched laser or light, a loaded +// disposable launcher) and the item each is, as when stashing: Minotaur counts them as that item +// (kits, the Inventory page). Looked up once per class. +if (isNil QGVAR(baseItems)) then { GVAR(baseItems) = createHashMap; }; +private _baseItems = []; +{ + private _base = GVAR(baseItems) getOrDefaultCall [_x, {[_x] call EFUNC(armory,getBaseVariant)}, true]; + if (_base != _x) then { + _baseItems pushBack [_x, _base]; + }; +} forEach (((flatten getUnitLoadout _unit) select {_x isEqualType "" && {_x != ""}}) arrayIntersect []); + +[ + ["insignia", [_unit] call BIS_fnc_getUnitInsignia], + ["earplugs", _extended getOrDefault ["ace_earplugs", _unit getVariable ["ACE_hasEarPlugsIn", false]]], + ["gunbag_weapon", _extended getOrDefault [QACEGVAR(gunbag,gunbagWeapon), []]], + ["zeroing", _zeroing], + ["safety", _safety], + ["base_items", _baseItems] +] diff --git a/addons/apollo/functions/fnc_handleDisconnect.sqf b/addons/apollo/functions/fnc_handleDisconnect.sqf index 2de63f50c..efbc6e1f5 100644 --- a/addons/apollo/functions/fnc_handleDisconnect.sqf +++ b/addons/apollo/functions/fnc_handleDisconnect.sqf @@ -1,7 +1,9 @@ #include "..\script_component.hpp" /* * Author: Jonpas - * Handles save and corpse removal on disconnect. + * Handles save and corpse removal on disconnect; keeps the state a reconnect gets back (mission only). + * Dead (killed, not respawned yet): the death is registered already, so nothing is saved and the + * corpse stays (its gear goes into its bodybag; the player comes back with basic gear). * * Arguments: * 0: Unit @@ -27,6 +29,13 @@ if (isNull _unit || {_lastSavedTime == -1}) exitWith { ERROR_2("Player not saved on disconnect - UID (%1) or LastSavedTime (%2) undefined!",_uid,_lastSavedTime); }; +// Dead: registered when killed (FUNC(handleKilled)); the corpse is left for its bodybag +if (!alive _unit) exitWith { + GVAR(deathsRegistered) deleteAt _uid; + INFO_2("Player '%1' (%2) left while dead, not saved",_name,_uid); +}; + [_unit, _uid, _name, "save"] call FUNC(playerSingletonSave); +[_unit, _uid] call FUNC(runtimeSave); deleteVehicle _unit; diff --git a/addons/apollo/functions/fnc_handleKilled.sqf b/addons/apollo/functions/fnc_handleKilled.sqf index 022aff8db..9a29cecf0 100644 --- a/addons/apollo/functions/fnc_handleKilled.sqf +++ b/addons/apollo/functions/fnc_handleKilled.sqf @@ -1,36 +1,33 @@ #include "..\script_component.hpp" /* * Author: Jonpas - * Handles killed event (mark in backend for fresh inventory). - * Resets inventory in combination with Respawn event. UID is not valid after quick respawn in Killed event. + * Handles killed event: registers the death on the website at once (the player then respawns with + * basic gear, even if they disconnect before respawning). Stores the death's key (also its + * bodybag's ID), the loadout and the variables at the moment of death on the body, and sends them + * with the death. Runs where the unit is local: the player's machine. * * Arguments: * 0: Player - * 1: Killer * * Return Value: * None * * Example: - * [player, killer] call tac_apollo_fnc_handleKilled + * [player] call tac_apollo_fnc_handleKilled * * Public: No */ -params ["_player", "_killer"]; +params ["_player"]; TRACE_1("Handle Killed",_this); -private _killerUID = getPlayerUID _killer; +// The death's key and the loadout at the moment of death (the bodybag addon copies the key onto the bag) +private _deathKey = format ["%1-%2", getPlayerUID _player, (systemTimeUTC apply {str _x}) joinString ""]; +_player setVariable [QGVAR(deathKey), _deathKey, true]; +_player setVariable [QGVAR(deathLoadout), [_player] call FUNC(getLoadout), true]; +_player setVariable [QGVAR(deathVariables), [_player] call FUNC(getVariables), true]; -// Try to get UID from ACE3's damage source (ace_medical uses setDamage which makes killer always objNull) -if (_killerUID == "") then { - _killerUID = getPlayerUID (_player getVariable [QACEGVAR(medical,lastDamageSource), objNull]); - - // No valid UID found, assume killer was AI or Self - if (_killerUID == "") then { - _killerUID = "AI/Self"; - }; +// Only a player's own death is registered (the UID is still valid now, not always after respawning) +if (_player isEqualTo player && {GVAR(enabled)} && {GVAR(enabledPlayers)}) then { + [QGVAR(playerDied), [_player, getPlayerUID _player, _deathKey, _player getVariable QGVAR(deathLoadout), _player getVariable QGVAR(deathVariables)]] call CBA_fnc_serverEvent; }; - -// Save Killed EH data for use in Respawn EH -_player setVariable [QGVAR(killerUID), _killerUID]; diff --git a/addons/apollo/functions/fnc_handleRespawn.sqf b/addons/apollo/functions/fnc_handleRespawn.sqf index 026fde1ef..268654733 100644 --- a/addons/apollo/functions/fnc_handleRespawn.sqf +++ b/addons/apollo/functions/fnc_handleRespawn.sqf @@ -1,7 +1,8 @@ #include "..\script_component.hpp" /* * Author: Jonpas - * Handles respawn event (mark in backend for fresh inventory). + * Handles respawn event: the server reloads the player (basic gear, the death was registered when + * they were killed; if it wasn't, the server registers it now from the corpse). * * Arguments: * 0: Player @@ -19,6 +20,4 @@ params ["_player", "_corpse"]; TRACE_1("Handle Respawn",_this); -private _killerUID = _corpse getVariable [QGVAR(killerUID), ""]; - -[QGVAR(playerDied), [_player, _killerUID]] call CBA_fnc_serverEvent; +[QGVAR(playerRespawned), [_player, _corpse]] call CBA_fnc_serverEvent; diff --git a/addons/apollo/functions/fnc_invokeJavaMethod.sqf b/addons/apollo/functions/fnc_invokeJavaMethod.sqf deleted file mode 100644 index 814bd6b04..000000000 --- a/addons/apollo/functions/fnc_invokeJavaMethod.sqf +++ /dev/null @@ -1,40 +0,0 @@ -#include "..\script_component.hpp" -/* - * Author: Jonpas - * Invokes Java code through JNI extension with XML marshalling and returns the return value from extension. - * Uses + operator to bypass 8192 character limit. - * - * Arguments: - * 0: Method - * 1-inf: Arguments - * - * Return Value: - * Extension Return Value - * - * Example: - * ["someJavaMethod", "arg1", "arg2"] call tac_apollo_fnc_invokeJavaMethod - * - * Public: No - */ - -params ["_method"]; - -if (isNil "_this" || {!(_this isEqualType [])} || {_this isEqualTo []} || {!(_method isEqualType "")}) exitWith {""}; - -// Parse arguments with correct syntax -private _argument_str = ""; -_this deleteAt 0; // Errors when combined with forEach -{ - _x = [str _x, _x] select (_x isEqualType ""); - _argument_str = _argument_str + "" + _x + ""; -} count _this; - -// Return Java Extension answer -private _return = "jni" callExtension ["invokeJavaMethod", ["" + _method + "" + _argument_str + ""]]; - -_return params ["_result", "_returnCode", "_errorCode"]; -if (_returnCode != 0 || {!(_errorCode in EXT_VALID_ERROR_CODES)} || {_result == "error"}) then { - ERROR_3("JNI failed! [result: %1, return: %2, error: %3]",_result,_returnCode,_errorCode); -}; - -_result diff --git a/addons/apollo/functions/fnc_lockerAction.sqf b/addons/apollo/functions/fnc_lockerAction.sqf index be563cd54..2edf63acc 100644 --- a/addons/apollo/functions/fnc_lockerAction.sqf +++ b/addons/apollo/functions/fnc_lockerAction.sqf @@ -1,55 +1,70 @@ #include "..\script_component.hpp" /* * Author: Jonpas - * Parses locker action through extension. + * Puts an item from the box into the player's locker, or takes one out into the box, through the + * extension. The website only answers with data; the box is changed here. * * Arguments: * 0: Player - * 1: Type - * 2: Container (used by Apollo backend for item addition/removal - DO NOT REMOVE) + * 1: Type ("put" or "remove") + * 2: Container * 3: Item Class Name - * 4: Box Item ClassName + * 4: Box Item Class Name (an ACRE radio with its ID) * 5: Quantity * 6: Keep Magazines + * 7: Notify the Armory when stashed (default: true; Stash All notifies once) * * Return Value: - * None + * Done (false: refused or failed) * * Example: - * [player, "remove", box, "class", "5"] call tac_apollo_fnc_lockerAction + * [player, "remove", box, "class", "class", "5", false] call tac_apollo_fnc_lockerAction * * Public: No */ -// IGNORE_PRIVATE_WARNING(_container) - DO NOT REMOVE - Used by Apollo backend for item addition/removal -params ["_player", "_type", "_container", "_itemClass", "_itemClassBox", "_quantity", "_keepMagazines"]; +params ["_player", "_type", "_container", "_itemClass", "_itemClassBox", "_quantity", "_keepMagazines", ["_notify", true]]; private _playerID = getPlayerUID _player; +private _count = parseNumber _quantity; +private _isMagazine = isClass (configFile >> "CfgMagazines" >> _itemClassBox); -private _serverReply = ["lockerAction", _type, _playerID, _itemClass, _itemClassBox, _quantity, _keepMagazines] call FUNC(invokeJavaMethod); - -if (_serverReply == "ready") then { - // Load packages for execution of commands - private _responsePacket = []; - private _updateInfo = true; +// Stashing magazines: the fullest go first; the website keeps the rounds of the partly used ones +// among them ("" for anything else) +private _partial = ""; +private _full = getNumber (configFile >> "CfgMagazines" >> _itemClassBox >> "count"); +if (_type == "put" && {_isMagazine}) then { + private _rounds = (magazinesAmmoCargo _container select {_x select 0 == _itemClassBox}) apply {_x select 1}; + _rounds sort false; + _partial = (_rounds select [0, _count]) select {_x < _full}; +}; - while {_updateInfo} do { - private _serverReply = ["retrieveLockerQueue", _playerID] call FUNC(invokeJavaMethod); +private _serverReply = ["lockerAction", _type, _playerID, _itemClass, _itemClassBox, _quantity, _keepMagazines, _partial] call FUNC(callServerExt); +if (_serverReply != "ready") exitWith {false}; - if (_serverReply == "done") then { - { - call _x; - } forEach _responsePacket; +private _entries = [_playerID] call FUNC(lockerQueue); +if (isNil "_entries") exitWith {false}; - // Notify Armory about finalization to force refresh box contents when stashing - if (_type == "put") then { - [QGVAR(lockerActionDone), [_player], _player] call CBA_fnc_targetEvent; - }; +if (_type == "put") then { + // Remove what was stashed: of magazines the full ones, then each partly used one by its rounds + if (_isMagazine) then { + [_container, _itemClassBox, _count - count _partial, false, _full] call FUNC(boxCargo); + { + [_container, _itemClassBox, 1, false, _x] call FUNC(boxCargo); + } forEach _partial; + } else { + [_container, _itemClassBox, _count, false, -1, _keepMagazines] call FUNC(boxCargo); + }; - _responsePacket = []; - _updateInfo = false; - } else { - _responsePacket pushBack (compile _serverReply); - }; + // Notify Armory about finalization to force refresh box contents when stashing + if (_notify) then { + [QGVAR(lockerActionDone), [_player], _player] call CBA_fnc_targetEvent; }; +} else { + { + _x params ["_class", "_number", "_rounds"]; + [_container, _class, _number, true, _rounds] call FUNC(boxCargo); + } forEach _entries; }; + +true diff --git a/addons/apollo/functions/fnc_lockerQueue.sqf b/addons/apollo/functions/fnc_lockerQueue.sqf new file mode 100644 index 000000000..6cb0f83bc --- /dev/null +++ b/addons/apollo/functions/fnc_lockerQueue.sqf @@ -0,0 +1,33 @@ +#include "..\script_component.hpp" +/* + * Author: Jonpas + * Reads the website's reply to a locker request (lockerAction, lockerTakeKit) from the extension: + * what to add to the box, as data ([class, count, rounds] each, rounds -1 for full). + * + * Arguments: + * 0: Player UID + * + * Return Value: + * Entries , nil if the request failed + * + * Example: + * ["76561198000000001"] call tac_apollo_fnc_lockerQueue + * + * Public: No + */ + +params ["_playerID"]; + +private _entries = []; +private _failed = false; +while {true} do { + private _reply = ["retrieveLockerQueue", _playerID] call FUNC(callServerExt); + if (_reply == "done") exitWith {}; + if (_reply == "error") exitWith { + _failed = true; + }; + _entries pushBack (parseSimpleArray _reply); +}; + +if (_failed) exitWith {nil}; +_entries diff --git a/addons/apollo/functions/fnc_lockerStashAll.sqf b/addons/apollo/functions/fnc_lockerStashAll.sqf new file mode 100644 index 000000000..c1b58c0db --- /dev/null +++ b/addons/apollo/functions/fnc_lockerStashAll.sqf @@ -0,0 +1,72 @@ +#include "..\script_component.hpp" +/* + * Author: Jonpas + * Stashes everything in the box into the player's locker (the Armory's Stash All), each class as a + * single stash does (FUNC(lockerAction): the base variant, a disposable launcher's magazine, an + * ACRE radio's ID, partly used magazines' rounds). What backpacks, vests and uniforms hold goes + * into the box first, so it's stashed too. Weapons go first: the attachments and magazines they + * leave in the box go in the second round. What the locker refuses stays in the box. Server only. + * + * Arguments: + * 0: Player + * 1: Container + * + * Return Value: + * None + * + * Example: + * [player, box] call tac_apollo_fnc_lockerStashAll + * + * Public: No + */ + +params ["_player", "_container"]; + +// Containers' contents into the box (a container inside another comes out empty) +{ + _x params ["", "_inner"]; + ([_inner] call FUNC(getCargo)) params ["_items", "_magazines", "_weapons", "_containers"]; + { + _container addItemCargoGlobal [_x, 1]; + } forEach _items; + { + _container addMagazineAmmoCargo [_x select 0, 1, _x select 1]; + } forEach _magazines; + { + _container addWeaponWithAttachmentsCargoGlobal [_x, 1]; + } forEach _weapons; + { + _x params ["_class", "_isBackpack"]; + if (_isBackpack) then { + _container addBackpackCargoGlobal [_class, 1]; + } else { + _container addItemCargoGlobal [_class, 1]; + }; + } forEach _containers; + clearItemCargoGlobal _inner; + clearMagazineCargoGlobal _inner; + clearWeaponCargoGlobal _inner; + clearBackpackCargoGlobal _inner; +} forEach everyContainer _container; + +private _left = []; +{ + private _cargo = call _x; + { + _x params ["_classes", "_counts"]; + { + private _classBox = _x; + ([_classBox] call EFUNC(armory,getStashVariant)) params ["_class", "_keepMagazines"]; + if !([_player, "put", _container, _class, _classBox, str (_counts select _forEachIndex), _keepMagazines, false] call FUNC(lockerAction)) then { + _left pushBackUnique _classBox; + }; + } forEach _classes; + } forEach _cargo; +} forEach [ + {[getWeaponCargo _container]}, + {[getItemCargo _container, getMagazineCargo _container, getBackpackCargo _container]} +]; + +INFO_3("Stash all for %1: %2 left in the box %3",getPlayerUID _player,count _left,_left); +[QGVAR(lockerActionDone), [_player], _player] call CBA_fnc_targetEvent; +[QGVAR(lockerStashAllDone), [_player, _left], _player] call CBA_fnc_targetEvent; diff --git a/addons/apollo/functions/fnc_lockerTakeKit.sqf b/addons/apollo/functions/fnc_lockerTakeKit.sqf new file mode 100644 index 000000000..0d098cab0 --- /dev/null +++ b/addons/apollo/functions/fnc_lockerTakeKit.sqf @@ -0,0 +1,38 @@ +#include "..\script_component.hpp" +/* + * Author: Jonpas + * Takes a kit (prepared on the website) from the player's locker into the box through the extension: + * of each of its items as many as the locker has. Notifies the player when done. + * + * Arguments: + * 0: Player + * 1: Container + * 2: Kit ID + * + * Return Value: + * None + * + * Example: + * [player, box, "12"] call tac_apollo_fnc_lockerTakeKit + * + * Public: No + */ + +params ["_player", "_container", "_kitID"]; + +private _playerID = getPlayerUID _player; + +private _success = false; +if ((["lockerTakeKit", _kitID, _playerID] call FUNC(callServerExt)) == "ready") then { + private _entries = [_playerID] call FUNC(lockerQueue); + if (!isNil "_entries") then { + { + _x params ["_class", "_number", "_rounds"]; + [_container, _class, _number, true, _rounds] call FUNC(boxCargo); + } forEach _entries; + _success = true; + }; +}; + +// Notify Armory to refresh the kits (what the locker has now) +[QGVAR(lockerKitTaken), [_player, _success], _player] call CBA_fnc_targetEvent; diff --git a/addons/apollo/functions/fnc_playerLoadClient.sqf b/addons/apollo/functions/fnc_playerLoadClient.sqf index 8bbedb3a5..97e8e0840 100644 --- a/addons/apollo/functions/fnc_playerLoadClient.sqf +++ b/addons/apollo/functions/fnc_playerLoadClient.sqf @@ -26,10 +26,10 @@ TRACE_1("Loading Client",_player); // Don't load when UID is "_SP_PLAYER_" (singleplayer/editor) if (getPlayerUID _player == "_SP_PLAYER_") exitWith {false}; -private _result = ["loadPlayer", [getPlayerUID _player, GVAR(isDebug)]] call FUNC(callExt); +private _result = ["loadPlayer", [getPlayerUID _player, GVAR(liveApi)]] call FUNC(callExt); if (!isNil "_result") then { - _result params [["_dir", -1], ["_posASL", []], ["_loadout", []], ["_selectedWeapon", ""]]; + _result params [["_dir", -1], ["_posASL", []], ["_loadout", []], ["_selectedWeapon", ""], ["_variables", []]]; if (_dir != -1) then { _player setDir _dir; @@ -37,8 +37,19 @@ if (!isNil "_result") then { if (_posASL isNotEqualTo [] && {count _posASL == 3}) then { _player setPosASL _posASL; }; - _player setUnitLoadout _loadout; + // Earplugs and the gunbag's weapon go back through ACE's extended loadout hooks + private _values = createHashMapFromArray (_variables select {_x isEqualType [] && {count _x == 2}}); + private _extended = createHashMap; + if (_values getOrDefault ["earplugs", false]) then { + _extended set ["ace_earplugs", true]; + }; + private _gunbagWeapon = _values getOrDefault ["gunbag_weapon", []]; + if (_gunbagWeapon isNotEqualTo []) then { + _extended set [QACEGVAR(gunbag,gunbagWeapon), _gunbagWeapon]; + }; + [_player, [_loadout, _extended]] call CBA_fnc_setLoadout; // ACE's hook adds the gunbag weapon's weight (fixed in ACE3 after 3.21.2) _player setDamage 0; + [_player, _variables] call FUNC(setVariables); if (_selectedWeapon != "") then { _player selectWeapon _selectedWeapon; @@ -57,7 +68,7 @@ if (!isNil "_result") then { // Delay to allow Arma server to get the new loadout before attempting to validate // Validation does nothing at this moment as it was never properly implemented in the backend [{ - [QGVAR(savePlayer), [_this, profileName, "validate"]] call CBA_fnc_serverEvent; + [QGVAR(savePlayer), [_this, profileName, "validate", [_this] call FUNC(getVariables), [] call FUNC(getRadios), [_this] call FUNC(getScopeDials)]] call CBA_fnc_serverEvent; }, _player, 1] call CBA_fnc_waitAndExecute; // Has to be executed where unit is local diff --git a/addons/apollo/functions/fnc_playerSaveClient.sqf b/addons/apollo/functions/fnc_playerSaveClient.sqf index 172b9e4d3..195daeb72 100644 --- a/addons/apollo/functions/fnc_playerSaveClient.sqf +++ b/addons/apollo/functions/fnc_playerSaveClient.sqf @@ -36,7 +36,9 @@ if (_player != player || {isNull _player} || {!alive _player}) exitWith { TRACE_1("Save - Not Saving",CBA_missionTime); }; -[QGVAR(savePlayer), [_player, profileName, "save"]] call CBA_fnc_serverEvent; +// What only this machine knows goes with it: the variables kept across missions, and the radio settings and scope +// dials kept for the mission +[QGVAR(savePlayer), [_player, profileName, "save", [_player] call FUNC(getVariables), [] call FUNC(getRadios), [_player] call FUNC(getScopeDials)]] call CBA_fnc_serverEvent; TRACE_1("Save - Saving Done",_player); // Mark last saved time diff --git a/addons/apollo/functions/fnc_playerSingletonSave.sqf b/addons/apollo/functions/fnc_playerSingletonSave.sqf index 349643cf9..86efdb96e 100644 --- a/addons/apollo/functions/fnc_playerSingletonSave.sqf +++ b/addons/apollo/functions/fnc_playerSingletonSave.sqf @@ -29,31 +29,21 @@ private _playerPos = getPosASL _player; private _playerDir = getDir _player; // Loadout -private _loadout = getUnitLoadout _player; - -// Filter ACRE2 -if (["acre_api"] call ACEFUNC(common,isModLoaded)) then { - _loadout = [_loadout] call acre_api_fnc_filterUnitLoadout; -}; - -// Add earplugs to uniform if has them plugged in. -if ((_player getVariable ["ACE_hasEarPlugsIn", false]) && {((_loadout select 3) isNotEqualTo [])}) then { - ((_loadout select 3) select 1) pushBack ["ACE_EarPlugs", 1]; -}; +private _loadout = [_player] call FUNC(getLoadout); // Other private _selectedWeapon = currentWeapon _player; -// Variables TODO -private _playerVariables = []; +// Variables kept across missions, as the player's machine last sent them ([] if never: the website keeps its own) +private _playerVariables = (_player getVariable [QGVAR(clientState), []]) param [0, []]; -private _serverReply = ["storeInfantry", _type, _uid, _name, _playerPos, _playerDir, _loadout, _selectedWeapon, _playerVariables] call FUNC(invokeJavaMethod); +private _serverReply = ["storeInfantry", _type, _uid, _name, _playerPos, _playerDir, _loadout, _selectedWeapon, _playerVariables] call FUNC(callServerExt); TRACE_2("Singleton Save",_type,_serverReply); if (_type == "validate" && {_serverReply == "success"}) exitWith { // No simulation toggling due to possible lag breaking correct position and direction setting - ["infantryLoaded", _uid] call FUNC(invokeJavaMethod); + ["infantryLoaded", _uid] call FUNC(callServerExt); INFO_4("Player '%1' (%2) validated successfully (Position: %3 - Loadout: %4)",_name,_uid,_playerPos,_loadout); }; diff --git a/addons/apollo/functions/fnc_registerPlaced.sqf b/addons/apollo/functions/fnc_registerPlaced.sqf new file mode 100644 index 000000000..f5dd4ba7b --- /dev/null +++ b/addons/apollo/functions/fnc_registerPlaced.sqf @@ -0,0 +1,32 @@ +#include "..\script_component.hpp" +/* + * Author: Jonpas + * Makes an object a player placed persistent (a trench, sandbags, a fortification, a tripod, a + * deployed static weapon), if its setting is on: registered and saved a second later, once placing + * is done. Objects made before the vehicles are loaded (the mission's, Chronos' own) are left + * alone. Server only. + * + * Arguments: + * 0: Object + * 1: Its setting is on + * + * Return Value: + * None + * + * Example: + * [_trench, GVAR(vehiclesObjects)] call tac_apollo_fnc_registerPlaced + * + * Public: No + */ + +params ["_object", "_enabled"]; + +if (!_enabled || {!GVAR(vehiclesLoaded)} || {isNull _object}) exitWith {}; + +[{ + params ["_object"]; + if (isNull _object || {(_object getVariable [QGVAR(vehicleID), ""]) != ""}) exitWith {}; + [_object] call FUNC(registerVehicle); + [_object] call FUNC(vehicleSingletonSave); + INFO_2("Placed %1 made persistent (%2)",typeOf _object,_object getVariable QGVAR(vehicleID)); +}, [_object], 1] call CBA_fnc_waitAndExecute; diff --git a/addons/apollo/functions/fnc_registerVehicle.sqf b/addons/apollo/functions/fnc_registerVehicle.sqf new file mode 100644 index 000000000..967096aaa --- /dev/null +++ b/addons/apollo/functions/fnc_registerVehicle.sqf @@ -0,0 +1,52 @@ +#include "..\script_component.hpp" +/* + * Author: Jonpas + * Makes a vehicle or object persistent: it's saved with the others from now on, and removed from + * Chronos a second after it's deleted (packed up, deleted in Zeus, a wreck cleaned up). Server only. + * + * Arguments: + * 0: Vehicle + * 1: Vehicle ID (default: its own, or a new one) + * + * Return Value: + * Vehicle ID + * + * Example: + * [vehicle] call tac_apollo_fnc_registerVehicle + * + * Public: No + */ + +params ["_vehicle", ["_vehicleID", ""]]; + +if (isNull _vehicle) exitWith {""}; + +if (_vehicleID == "") then { + _vehicleID = _vehicle getVariable [QGVAR(vehicleID), ""]; +}; +if (_vehicleID == "") then { + _vehicleID = ["generateUniqueID"] call FUNC(callServerExt); +}; + +_vehicle setVariable [QGVAR(vehicleID), _vehicleID, true]; +GVAR(vehicles) set [_vehicleID, _vehicle]; + +if (isNil {_vehicle getVariable QGVAR(deletedHandler)}) then { + _vehicle setVariable [QGVAR(deletedHandler), _vehicle addEventHandler ["Deleted", { + params ["_vehicle"]; + // A second later, and only if it's still registered and gone (not replaced, as the round-trip + // test does): a mission ending deletes every object but runs no more of the mission's + // timers, so nothing is removed then + [{ + params ["_vehicleID"]; + if (_vehicleID in GVAR(vehicles) && {isNull (GVAR(vehicles) get _vehicleID)}) then { + GVAR(vehicles) deleteAt _vehicleID; + ["removeVehicle", _vehicleID] call FUNC(callServerExt); + INFO_1("Vehicle %1 deleted, removed from Chronos",_vehicleID); + }; + }, [_vehicle getVariable [QGVAR(vehicleID), ""]], 1] call CBA_fnc_waitAndExecute; + }]]; +}; + +TRACE_2("Vehicle registered",_vehicle,_vehicleID); +_vehicleID diff --git a/addons/apollo/functions/fnc_runtimeApply.sqf b/addons/apollo/functions/fnc_runtimeApply.sqf new file mode 100644 index 000000000..44a529aca --- /dev/null +++ b/addons/apollo/functions/fnc_runtimeApply.sqf @@ -0,0 +1,68 @@ +#include "..\script_component.hpp" +/* + * Author: Jonpas + * Puts a reconnecting player back as they were (see FUNC(runtimeSave)): into their vehicle (the same seat, else any + * free one, else they stay where they loaded, by the vehicle), their team, ACE medical state, radio settings and ACE + * scope dials. + * Run where the player is local, after their load. + * + * Arguments: + * 0: Player + * 1: Team (colour, in the group they're in now) + * 2: Vehicle + * 3: Seat ([] none, ["driver"], ["turret", path], ["cargo", index]) + * 4: ACE medical state (serializeState) + * 5: Radio settings (FUNC(getRadios)) + * 6: ACE scope dials (FUNC(getScopeDials)) (default: []) + * + * Return Value: + * None + * + * Example: + * [player, "MAIN", vehicle, ["cargo", 2], "", [], []] call tac_apollo_fnc_runtimeApply + * + * Public: No + */ + +params ["_player", "_team", "_vehicle", "_seat", "_medical", "_radios", ["_dials", []]]; +TRACE_1("Runtime Apply",_this); + +if (alive _vehicle && {isNull objectParent _player}) then { + _seat params [["_role", ""], ["_where", -1]]; + switch (_role) do { + case "driver": { _player moveInDriver _vehicle; }; + case "turret": { _player moveInTurret [_vehicle, _where]; }; + case "cargo": { _player moveInCargo [_vehicle, _where]; }; + }; + // The seat was taken: any free one + [{ + params ["_player", "_vehicle"]; + if (isNull objectParent _player && {alive _vehicle}) then { + _player moveInAny _vehicle; + }; + }, [_player, _vehicle], 0.5] call CBA_fnc_waitAndExecute; +}; + +if (_team != "") then { + _player assignTeam _team; +}; + +if (_medical != "" && {["ace_medical"] call ACEFUNC(common,isModLoaded)}) then { + [_player, _medical] call ACEFUNC(medical,deserializeState); +}; + +[_radios] call FUNC(setRadios); + +// Scope dials on the same weapon and optic, in the same zeroing mode, once ACE has reset them for the load +[{ + params ["_player", "_dials"]; + if (!alive _player) exitWith {}; + private _simplified = missionNamespace getVariable [QACEGVAR(scopes,simplifiedZeroing), false]; + private _weapons = [primaryWeapon _player, secondaryWeapon _player, handgunWeapon _player]; + { + _x params ["_index", "_weapon", "_optic", "_elevation", "_windage", "_wasSimplified"]; + if ((_weapons param [_index, ""]) == _weapon && {((_player weaponAccessories _weapon) param [2, ""]) == _optic} && {_wasSimplified isEqualTo _simplified}) then { + [_player, _index, _elevation, _windage] call FUNC(setScopeAdjustment); + }; + } forEach _dials; +}, [_player, _dials], 2] call CBA_fnc_waitAndExecute; diff --git a/addons/apollo/functions/fnc_runtimeSave.sqf b/addons/apollo/functions/fnc_runtimeSave.sqf new file mode 100644 index 000000000..220a433e0 --- /dev/null +++ b/addons/apollo/functions/fnc_runtimeSave.sqf @@ -0,0 +1,46 @@ +#include "..\script_component.hpp" +/* + * Author: Jonpas + * Keeps a disconnecting player's state for the rest of the mission (server memory only), so a reconnect puts them + * back as they were: team (colour, in whichever group they join), vehicle and seat, ACE medical state, radio settings and ACE scope dials + * (FUNC(runtimeApply)). + * Cleared at death, so a respawn starts fresh. Rewritten from the apollo-back-to-vehicle branch. + * + * Arguments: + * 0: Unit + * 1: UID + * + * Return Value: + * None + * + * Example: + * [unit, "76561198000000000"] call tac_apollo_fnc_runtimeSave + * + * Public: No + */ + +params ["_unit", "_uid"]; + +if (!alive _unit || {_uid == ""}) exitWith { + GVAR(playerRuntimeData) deleteAt _uid; +}; + +private _vehicle = objectParent _unit; +private _seat = []; +if (!isNull _vehicle) then { + _seat = switch (true) do { + case (driver _vehicle == _unit): {["driver"]}; + case ((_vehicle unitTurret _unit) isNotEqualTo []): {["turret", _vehicle unitTurret _unit]}; + default {["cargo", _vehicle getCargoIndex _unit]}; + }; +}; + +private _medical = ""; +if (["ace_medical"] call ACEFUNC(common,isModLoaded)) then { + _medical = [_unit] call ACEFUNC(medical,serializeState); +}; + +(_unit getVariable [QGVAR(clientState), []]) params ["", ["_radios", []], ["_dials", []]]; + +GVAR(playerRuntimeData) set [_uid, [assignedTeam _unit, _vehicle, _seat, _medical, _radios, _dials]]; +TRACE_2("Runtime Save",_uid,GVAR(playerRuntimeData) get _uid); diff --git a/addons/apollo/functions/fnc_setCargo.sqf b/addons/apollo/functions/fnc_setCargo.sqf new file mode 100644 index 000000000..e66ab47ff --- /dev/null +++ b/addons/apollo/functions/fnc_setCargo.sqf @@ -0,0 +1,61 @@ +#include "..\script_component.hpp" +/* + * Author: Jonpas + * Fills an object's inventory as Minotaur sends it back (FUNC(getCargo) saved it): items, + * magazines with their rounds, weapons with their attachments, then each container (backpack, + * uniform, vest), added and filled with its own contents. Clears the object first. + * + * Arguments: + * 0: Object + * 1: Cargo + * [[[class, count], …], [[magazine, count, rounds (-1 full)], …], [[weapon items, count], …], + * [[class, is backpack, [items, magazines, weapons]], …]] + * + * Return Value: + * None + * + * Example: + * [vehicle, [[["FirstAidKit", 2]], [], [], []]] call tac_apollo_fnc_setCargo + * + * Public: No + */ + +params ["_object", "_cargo"]; +_cargo params [["_items", []], ["_magazines", []], ["_weapons", []], ["_containers", []]]; + +clearItemCargoGlobal _object; +clearMagazineCargoGlobal _object; +clearWeaponCargoGlobal _object; +clearBackpackCargoGlobal _object; + +{ + _object addItemCargoGlobal _x; +} forEach _items; + +{ + _x params ["_class", "_count", ["_rounds", -1]]; + if (_rounds < 0) then { + _object addMagazineCargoGlobal [_class, _count]; + } else { + _object addMagazineAmmoCargo [_class, _count, _rounds]; + }; +} forEach _magazines; + +{ + _object addWeaponWithAttachmentsCargoGlobal _x; +} forEach _weapons; + +// A container is found as the one everyContainer didn't have before it was added +{ + _x params ["_class", "_isBackpack", "_contents"]; + private _before = (everyContainer _object) apply {_x select 1}; + if (_isBackpack) then { + _object addBackpackCargoGlobal [_class, 1]; + } else { + _object addItemCargoGlobal [_class, 1]; + }; + private _container = (((everyContainer _object) apply {_x select 1}) - _before) param [0, objNull]; + if (!isNull _container) then { + [_container, _contents] call FUNC(setCargo); + }; +} forEach _containers; diff --git a/addons/apollo/functions/fnc_setRadios.sqf b/addons/apollo/functions/fnc_setRadios.sqf new file mode 100644 index 000000000..ccd2b0254 --- /dev/null +++ b/addons/apollo/functions/fnc_setRadios.sqf @@ -0,0 +1,54 @@ +#include "..\script_component.hpp" +/* + * Author: Jonpas + * Puts the local player's ACRE radio settings back (see FUNC(getRadios)), matching radios by base class, in order. + * Waits for ACRE to give the radios their IDs. + * + * Arguments: + * 0: Radio settings + * + * Return Value: + * None + * + * Example: + * [[[["ACRE_PRC343", 2, 0.8, "LEFT"]], 0, [0]]] call tac_apollo_fnc_setRadios + * + * Public: No + */ + +params ["_settings"]; + +if (_settings isEqualTo [] || {!(["acre_api"] call ACEFUNC(common,isModLoaded))}) exitWith {}; + +[{[] call acre_api_fnc_isInitialized}, { + params ["_settings"]; + _settings params [["_radios", []], ["_active", -1], ["_ptt", []]]; + + private _list = [] call acre_api_fnc_getCurrentRadioList; + private _bases = _list apply {[_x] call acre_api_fnc_getBaseRadio}; + + // The saved radios' IDs now ("" if not carried any more) + private _matched = _radios apply { + _x params ["_base", "_channel", "_volume", "_spatial"]; + private _index = _bases find _base; + if (_index == -1) then { + "" + } else { + _bases set [_index, ""]; // taken: the next of that base gets the next settings + private _radio = _list select _index; + [_radio, _channel] call acre_api_fnc_setRadioChannel; + [_radio, _volume] call acre_api_fnc_setRadioVolume; + [_radio, _spatial] call acre_api_fnc_setRadioSpatial; + _radio + }; + }; + + private _activeRadio = if (_active >= 0) then {_matched param [_active, ""]} else {""}; + if (_activeRadio != "") then { + [_activeRadio] call acre_api_fnc_setCurrentRadio; + }; + private _pttRadios = ((_ptt select {_x >= 0}) apply {_matched param [_x, ""]}) - [""]; + if (_pttRadios isNotEqualTo []) then { + [_pttRadios] call acre_api_fnc_setMultiPushToTalkAssignment; + }; +}, [_settings], 30] call CBA_fnc_waitUntilAndExecute; diff --git a/addons/apollo/functions/fnc_setScopeAdjustment.sqf b/addons/apollo/functions/fnc_setScopeAdjustment.sqf new file mode 100644 index 000000000..b7a73f912 --- /dev/null +++ b/addons/apollo/functions/fnc_setScopeAdjustment.sqf @@ -0,0 +1,46 @@ +#include "..\script_component.hpp" +/* + * Author: Jonpas + * Puts ACE scope values back on a weapon slot: elevation, windage and the zero reference, each only if given and + * within the optic's turret limits (as ACE checks its own saved zero reference). Run where the unit is local, after + * ACE has seen the weapon and optic (it resets the slot when they change). + * + * Arguments: + * 0: Unit + * 1: Weapon slot (0 primary, 1 launcher, 2 handgun) + * 2: Elevation (default: nil, unchanged) + * 3: Windage (default: nil, unchanged) + * 4: Zero reference (default: nil, unchanged) + * + * Return Value: + * None + * + * Example: + * [player, 0, nil, nil, 0.2] call tac_apollo_fnc_setScopeAdjustment + * + * Public: No + */ + +params ["_unit", "_index", ["_elevation", nil], ["_windage", nil], ["_zero", nil]]; + +if !(missionNamespace getVariable [QACEGVAR(scopes,enabled), false]) exitWith {}; + +// [[min, max] elevation, its step, [min, max] windage, its step], per slot +((missionNamespace getVariable [QACEGVAR(scopes,scopeAdjust), []]) param [_index, []]) params [["_vertical", [0, 0]], "", ["_horizontal", [0, 0]]]; +_vertical params ["_minVertical", "_maxVertical"]; +_horizontal params ["_minHorizontal", "_maxHorizontal"]; + +private _adjustments = +(_unit getVariable [QACEGVAR(scopes,adjustment), [[0, 0, 0], [0, 0, 0], [0, 0, 0]]]); +private _slot = +(_adjustments select _index); +private _fnc_within = { + params ["_value", "_min", "_max"]; + _value isEqualType 0 && {_value >= _min} && {_value <= _max} +}; + +if (!isNil "_elevation" && {[_elevation, _minVertical, _maxVertical] call _fnc_within}) then { _slot set [0, _elevation]; }; +if (!isNil "_windage" && {[_windage, _minHorizontal, _maxHorizontal] call _fnc_within}) then { _slot set [1, _windage]; }; +if (!isNil "_zero" && {[_zero, _minVertical, _maxVertical] call _fnc_within}) then { _slot set [2, _zero]; }; + +if (_slot isEqualTo (_adjustments select _index)) exitWith {}; +_adjustments set [_index, _slot]; +[_unit, QACEGVAR(scopes,adjustment), _adjustments, 0.5] call ACEFUNC(common,setVariablePublic); diff --git a/addons/apollo/functions/fnc_setVariables.sqf b/addons/apollo/functions/fnc_setVariables.sqf new file mode 100644 index 000000000..1e92cc6e2 --- /dev/null +++ b/addons/apollo/functions/fnc_setVariables.sqf @@ -0,0 +1,71 @@ +#include "..\script_component.hpp" +/* + * Author: Jonpas + * Puts back what's kept across missions out of the loadout (see FUNC(getVariables)), after the loadout is set. + * Earplugs and the gunbag's weapon go back with the loadout (CBA extended loadout, ACE's own hooks), so this + * does the insignia now, and zeroing (every muzzle, and ACE's zero reference) and safety a moment later (ACE resets + * the scope adjustment when it first sees an optic), only on a weapon that's still the same (and with the same + * optic, for the main muzzle's zeroing and the zero reference). + * Run where the unit is local. + * + * Arguments: + * 0: Unit + * 1: Variables + * + * Return Value: + * None + * + * Example: + * [player, [["insignia", "tac_insignia"]]] call tac_apollo_fnc_setVariables + * + * Public: No + */ + +params ["_unit", "_variables"]; + +private _values = createHashMapFromArray (_variables select {_x isEqualType [] && {count _x == 2}}); + +private _insignia = _values getOrDefault ["insignia", ""]; +if (_insignia isEqualType "" && {_insignia != ""} && {isClass (configFile >> "CfgUnitInsignia" >> _insignia)}) then { + // The function skips a class it thinks is already on, but a new loadout's uniform has none (as ACE Arsenal does) + _unit setVariable ["BIS_fnc_setUnitInsignia_class", nil]; + [_unit, _insignia] call BIS_fnc_setUnitInsignia; +}; + +[{ + params ["_unit", "_zeroing", "_safety"]; + if (!alive _unit) exitWith {}; + private _weapons = [primaryWeapon _unit, secondaryWeapon _unit, handgunWeapon _unit] apply {toLowerANSI _x}; + + { + _x params ["_weapon", "_optic", "_muzzles", "_zero"]; + private _index = _weapons find (toLowerANSI _weapon); + if (_index == -1) then { continue; }; + private _sameOptic = ((_unit weaponAccessories _weapon) param [2, ""]) == _optic; + + // ACE's zero reference belongs to the weapon and optic + if (_sameOptic) then { + [_unit, _index, nil, nil, _zero] call FUNC(setScopeAdjustment); + }; + + { + _x params ["_muzzle", "", "_distance", "_step"]; + // The main muzzle's zeroing steps come from the optic; another muzzle's (a grenade launcher's) don't + if (_muzzle == _weapon && {!_sameOptic}) then { continue; }; + if ((_unit setWeaponZeroing [_weapon, _muzzle, _step]) && {((_unit currentZeroing [_weapon, _muzzle]) select 0) == _distance}) then { continue; }; + // Not that step any more: find the one at that distance (false: no such step) + for "_try" from 0 to 40 do { + if !(_unit setWeaponZeroing [_weapon, _muzzle, _try]) exitWith {}; + if (((_unit currentZeroing [_weapon, _muzzle]) select 0) == _distance) exitWith {}; + }; + } forEach _muzzles; + } forEach _zeroing; + + { + _x params ["_weapon", "_muzzle"]; + private _index = _weapons find (toLowerANSI _weapon); + if (_index != -1) then { + [_unit, [primaryWeapon _unit, secondaryWeapon _unit, handgunWeapon _unit] select _index, true, false, _muzzle] call ACEFUNC(safemode,setWeaponSafety); + }; + } forEach _safety; +}, [_unit, _values getOrDefault ["zeroing", []], _values getOrDefault ["safety", []]], 2] call CBA_fnc_waitAndExecute; diff --git a/addons/apollo/functions/fnc_testVehicleRoundTrip.sqf b/addons/apollo/functions/fnc_testVehicleRoundTrip.sqf new file mode 100644 index 000000000..88c8b1580 --- /dev/null +++ b/addons/apollo/functions/fnc_testVehicleRoundTrip.sqf @@ -0,0 +1,114 @@ +#include "..\script_component.hpp" +/* + * Author: Jonpas + * Tests saving and loading a vehicle: saves it, deletes it, loads it back from Chronos and compares + * what it has (cargo with containers and rounds, turret magazines, pylons, damage and hit points, + * fuel, lock, a static object's height and tilt, ACE fuel and ammo (count or magazines), trench progress, customization, + * ACE cargo), with the same functions as the real save and load. The vehicle is replaced by the loaded one. Results in the server's RPT and + * in everyone's chat. For test servers (the development website), server only. + * + * Arguments: + * 0: Vehicle + * + * Return Value: + * None + * + * Example: + * [cursorObject] remoteExec ["tac_apollo_fnc_testVehicleRoundTrip", 2] + * + * Public: No + */ + +params [["_vehicle", objNull, [objNull]]]; + +if (!isServer || {isNull _vehicle} || {!GVAR(vehiclesLoaded)}) exitWith { + ERROR_1("Vehicle round trip: needs a vehicle, on the server, once vehicles are loaded (%1)",_vehicle); +}; + +[_vehicle, [_vehicle] call FUNC(registerVehicle)] spawn { + params ["_vehicle", "_vehicleID"]; + + private _report = { + params ["_text"]; + INFO_1("Vehicle round trip: %1",_text); + [format ["Vehicle round trip: %1", _text]] remoteExecCall ["systemChat", 0]; + }; + private _sorted = { + params ["_list"]; + private _strings = _list apply {str _x}; + _strings sort true; + _strings + }; + private _snapshot = { + params ["_object"]; + ([_object] call FUNC(getCargo)) params ["_items", "_magazines", "_weapons", "_containers"]; + // Static objects (as the save classes them) are placed exactly: their height and tilt too + private _static = ({_object isKindOf _x} count ["Car", "Plane", "Helicopter", "Tank", "Ship", "ThingX"]) == 0 || + {!isNil {_object getVariable QACEGVAR(trenches,progress)}}; + [ + typeOf _object, + (getPosATL _object select [0, 2]) apply {round _x}, + round (damage _object * 100), + round (fuel _object * 100), + ((getAllHitPointsDamage _object) param [2, []]) apply {round (_x * 100)}, + locked _object, + [[], [round ((getPosATL _object select 2) * 100), (vectorUp _object) apply {round (_x * 100)}]] select _static, + round ([_object] call ACEFUNC(refuel,getFuel)), + if ((missionNamespace getVariable [QACEGVAR(rearm,supply), 0]) == 1) then {round ([_object] call ACEFUNC(rearm,getSupplyCount))} else {-1}, + _object getVariable [QACEGVAR(rearm,magazineSupply), []], + [_items] call _sorted, + [_magazines] call _sorted, + [_weapons] call _sorted, + [_containers apply {_x params ["_class", "_isBackpack", "_inside"]; [_class, _isBackpack, _inside apply {[_x] call _sorted}]}] call _sorted, + [(magazinesAllTurrets _object) apply {_x select [0, 3]}] call _sorted, + [(getAllPylonsInfo _object) apply {[_x select 0, _x select 3, _x select 4]}] call _sorted, + _object getVariable [QACEGVAR(trenches,progress), -1], + [_object] call BIS_fnc_getVehicleCustomization, + [(_object getVariable [QACEGVAR(cargo,loaded), []]) apply {if (_x isEqualType objNull) then {typeOf _x} else {_x}}] call _sorted + ] + }; + private _names = ["type", "position", "damage", "fuel", "hit points", "locked", "height and tilt", "ACE fuel", "ACE ammo", "ACE magazine supply", "items", "magazines", "weapons", "containers", "turrets", "pylons", "trench", "customization", "ACE cargo"]; + + private _before = [_vehicle] call _snapshot; + [format ["%1 (%2) saving, deleting and loading", _vehicleID, typeOf _vehicle]] call _report; + + [_vehicle] call FUNC(vehicleSingletonSave); + sleep 3; // sent in the background + + GVAR(vehicles) deleteAt _vehicleID; // so deleting it doesn't remove it from Chronos + { + if (_x isEqualType objNull) then { + GVAR(vehicles) deleteAt (_x getVariable [QGVAR(vehicleID), ""]); // a persistent one loaded: the same + deleteVehicle _x; + }; + } forEach (_vehicle getVariable [QACEGVAR(cargo,loaded), []]); + deleteVehicle _vehicle; + sleep 1; + + if ((["retrieveAllVehicles"] call FUNC(callServerExt)) != "ready") exitWith { + ["failed: vehicles not retrieved from Chronos"] call _report; + }; + private _loaded = [_vehicleID] call FUNC(vehicleSingletonLoad); + if (isNull _loaded) exitWith { + [format ["failed: %1 not loaded", _vehicleID]] call _report; + }; + [_loaded, _vehicleID] call FUNC(registerVehicle); + _loaded enableSimulationGlobal true; + sleep 20; // ACE CSW's init and a static weapon's ammo after it (up to 15 s), physics settling + + private _after = [_loaded] call _snapshot; + private _differences = []; + { + if (_x isNotEqualTo (_after select _forEachIndex)) then { + _differences pushBack (_names select _forEachIndex); + INFO_2("Vehicle round trip: %1 before %2",_names select _forEachIndex,_x); + INFO_2("Vehicle round trip: %1 after %2",_names select _forEachIndex,_after select _forEachIndex); + }; + } forEach _before; + + if (_differences isEqualTo []) then { + [format ["%1 OK, the same after loading", _vehicleID]] call _report; + } else { + [format ["%1 DIFFERS in %2 (details in the server's RPT)", _vehicleID, _differences joinString ", "]] call _report; + }; +}; diff --git a/addons/apollo/functions/fnc_vehicleLoad.sqf b/addons/apollo/functions/fnc_vehicleLoad.sqf index 22a16faf9..f887e4fe5 100644 --- a/addons/apollo/functions/fnc_vehicleLoad.sqf +++ b/addons/apollo/functions/fnc_vehicleLoad.sqf @@ -15,29 +15,32 @@ * Public: No */ -private _retrieveVehicles = ["retrieveAllVehicles"] call FUNC(invokeJavaMethod); +private _retrieveVehicles = ["retrieveAllVehicles"] call FUNC(callServerExt); if (_retrieveVehicles == "ready") then { private _vehList = []; private _updateInfo = true; while {_updateInfo} do { - private _serverReply = ["getVehicleList"] call FUNC(invokeJavaMethod); + private _serverReply = ["getVehicleList"] call FUNC(callServerExt); // All vehicle IDs retrieved if (_serverReply == "done") then { _updateInfo = false; - { - [_x] call FUNC(vehicleSingletonLoad); - } forEach _vehList; } else { _vehList pushBack _serverReply; }; }; - // Make sure all vehicles exist, save them into a global variable for API - _vehList = (_vehList apply {missionNamespace getVariable [_x, objNull]}) select {!isNull _x}; - GVAR(vehiclesList) = +_vehList; // Don't use global variable directly in case of new vehicles during this time + // Make them and make them persistent (ACE cargo objects register themselves while loading) + private _vehicles = []; + { + private _vehicle = [_x] call FUNC(vehicleSingletonLoad); + if (!isNull _vehicle) then { + [_vehicle, _x] call FUNC(registerVehicle); + _vehicles pushBack _vehicle; + }; + } forEach _vehList; // Enable simulation on all vehicles and attempt to fix physics { @@ -58,13 +61,13 @@ if (_retrieveVehicles == "ready") then { { _vehicle setHitPointDamage [_x, _hitPointsDamage select _forEachIndex, false]; } forEach _hitPoints; - } forEach _vehList; + } forEach _vehicles; // Set vehicles loaded flag GVAR(vehiclesLoaded) = true; - INFO_1("%1 vehicles loaded.",count _vehList); - TRACE_1("Vehicles loaded",_vehList); + INFO_1("%1 vehicles loaded.",count _vehicles); + TRACE_1("Vehicles loaded",_vehicles); // Start saving vehicles [FUNC(vehicleSaveServer), [], 60] call CBA_fnc_waitAndExecute; diff --git a/addons/apollo/functions/fnc_vehicleSaveServer.sqf b/addons/apollo/functions/fnc_vehicleSaveServer.sqf index f98a80681..4d8c0b49b 100644 --- a/addons/apollo/functions/fnc_vehicleSaveServer.sqf +++ b/addons/apollo/functions/fnc_vehicleSaveServer.sqf @@ -15,14 +15,28 @@ * Public: No */ -// Make safe copy in case of new vehicles during this save round -private _vehList = +GVAR(vehiclesList); +// Vehicles that are gone are removed from Chronos as they're deleted (FUNC(registerVehicle)); any +// that went without it are removed here +private _removed = []; +{ + if (isNull _y) then { + _removed pushBack _x; + } else { + // Loaded as ACE cargo: saved with the vehicle carrying it + private _carrier = attachedTo _y; + if (isNull _carrier || {!(_y in (_carrier getVariable [QACEGVAR(cargo,loaded), []]))}) then { + [_y] call FUNC(vehicleSingletonSave); + }; + }; +} forEach GVAR(vehicles); { - [_x] call FUNC(vehicleSingletonSave); -} forEach _vehList; + GVAR(vehicles) deleteAt _x; + ["removeVehicle", _x] call FUNC(callServerExt); + INFO_1("Vehicle %1 is gone, removed",_x); +} forEach _removed; -TRACE_2("Vehicles Saved",count _vehList,_vehList); +TRACE_2("Vehicles saved",count GVAR(vehicles),_removed); // Save again in 60 seconds [FUNC(vehicleSaveServer), [], 60] call CBA_fnc_waitAndExecute; diff --git a/addons/apollo/functions/fnc_vehicleSingletonLoad.sqf b/addons/apollo/functions/fnc_vehicleSingletonLoad.sqf index 15d313418..ac259635f 100644 --- a/addons/apollo/functions/fnc_vehicleSingletonLoad.sqf +++ b/addons/apollo/functions/fnc_vehicleSingletonLoad.sqf @@ -1,13 +1,15 @@ #include "..\script_component.hpp" /* * Author: Jonpas - * Loads a single vehicle. + * Loads a single vehicle: Minotaur sends its data (the [key, value] pairs FUNC(vehicleSingletonSave) + * sends, in pieces), and it's made here. Created high up with simulation off; FUNC(vehicleLoad) + * turns simulation on once every vehicle is made. Server only. * * Arguments: * 0: Vehicle ID * * Return Value: - * None + * Vehicle (objNull if it couldn't be made) * * Example: * ["TACveh1"] call tac_apollo_fnc_vehicleSingletonLoad @@ -15,22 +17,190 @@ * Public: No */ +#define SPAWN_HEIGHT 1000 +#define SPAWN_LIFT 0.5 + params ["_vehicleID"]; -private _responsePacket = []; -private _updateInfo = true; +private _pieces = []; +while {true} do { + private _reply = ["getVehicle", _vehicleID] call FUNC(callServerExt); + if (_reply in ["done", "error"]) exitWith {}; + _pieces pushBack _reply; +}; -while {_updateInfo} do { - private _serverReply = ["getVehicle", _vehicleID] call FUNC(invokeJavaMethod); +private _data = parseSimpleArray (_pieces joinString ""); +if (_data isEqualTo []) exitWith { + ERROR_1("Vehicle %1: no data from Chronos",_vehicleID); + objNull +}; +private _values = createHashMapFromArray _data; - if (_serverReply == "done") then { - { - call _x; - } forEach _responsePacket; +// Settings: what's turned off is left as the vehicle is made; objects and static weapons not made +{ + _x params ["_enabled", "_keys"]; + if (!_enabled) then { + {_values deleteAt _x} forEach _keys; + }; +} forEach [ + [GVAR(vehiclesTurrets), ["turrets"]], + [GVAR(vehiclesPylons), ["pylons"]], + [GVAR(vehiclesACECargo), ["ace_cargo"]], + [GVAR(vehiclesACESupply), ["ace_fuel", "ace_ammo", "ace_ammo_magazines"]] +]; + +private _type = _values getOrDefault ["type", ""]; +private _position = _values getOrDefault ["position", []]; +private _vehicle = missionNamespace getVariable [_vehicleID, objNull]; // only one the mission placed (Apollo) +private _csw = false; + +// Static objects (sandbags, trenches) are placed exactly as saved, the others lifted a little +private _static = (_values getOrDefault ["class", "Unknown"]) == "Unknown" || {"trench" in _values}; +private _staticWeapon = _type isKindOf "StaticWeapon" || {_type isKindOf "ace_csw_baseTripod"}; +if ((!GVAR(vehiclesStaticWeapons) && {_staticWeapon}) || {!GVAR(vehiclesObjects) && {!_staticWeapon} && {!(_type isKindOf "AllVehicles")}}) exitWith { + INFO_2("Vehicle %1 (%2) not loaded: turned off in the settings",_vehicleID,_type); + objNull +}; - _responsePacket = []; - _updateInfo = false; +if (_type != "" && {count _position == 3}) then { + _position params ["_posX", "_posY", "_posZ"]; + if (!_static) then { + _posZ = _posZ + SPAWN_LIFT; + }; + + _vehicle = createVehicle [_type, [_posX, _posY, SPAWN_HEIGHT], [], 0, "CAN_COLLIDE"]; + (_values getOrDefault ["customization", []]) params [["_textures", []], ["_animations", []]]; + if (_textures isNotEqualTo [] || {_animations isNotEqualTo []}) then { + [_vehicle, [_textures, false] select (_textures isEqualTo []), [_animations, false] select (_animations isEqualTo []), true] call BIS_fnc_initVehicle; + }; + _vehicle enableSimulationGlobal false; + _vehicle allowDamage false; + + // ACE CSW's init (about a second later) empties a static weapon: assembly mode 2, as for a + // deployed one, so it drops nothing on the ground; its saved magazines go in after that + _csw = getNumber (configOf _vehicle >> "ace_csw" >> "enabled") == 1; + if (_csw && {_values getOrDefault ["alive", true]} && {"turrets" in _values}) then { + _vehicle setVariable [QACEGVAR(csw,assemblyMode), 2, true]; + }; + + if ("direction" in _values) then { + _vehicle setDir (_values get "direction"); + }; + if ("trench" in _values && {isClass (configOf _vehicle >> "AnimationSources" >> "rise")}) then { + // A grad_trenches trench as it places one: tilted first, then at ground level (its dig + // progress is the model's "rise" animation; ACE's own trenches show it by their height). + // Tilted after placing, one on a slope would end up buried. + if ("vector" in _values) then { + _vehicle setVectorDirAndUp (_values get "vector"); + }; + _vehicle setPosATL [_posX, _posY, 0]; } else { - _responsePacket pushBack (compile _serverReply); + _vehicle setPosATL [_posX, _posY, _posZ]; + if (_static && {"vector" in _values}) then { + _vehicle setVectorDirAndUp (_values get "vector"); + }; + }; + + _vehicle setVehicleVarName _vehicleID; + missionNamespace setVariable [_vehicleID, _vehicle]; + _vehicle setVariable [QGVAR(vehicleID), _vehicleID, true]; + _vehicle setVariable ["BIS_enableRandomization", false]; + + if (_values getOrDefault ["alive", true]) then { + [_vehicle, _values getOrDefault ["cargo", []]] call FUNC(setCargo); + + // ACE cargo: a class name as is; an object made, filled and loaded (registered again if + // it's a persistent vehicle) + { + if (_x isEqualType "") then { + [_x, _vehicle, 1, true] call ACEFUNC(cargo,addCargoItem); + } else { + _x params ["_class", "_damage", "_cargo", "_cargoID"]; + private _object = createVehicle [_class, [0, 0, 0], [], 0, "CAN_COLLIDE"]; + _object setDamage _damage; + if (_cargoID != "") then { + [_object, _cargoID] call FUNC(registerVehicle); + }; + [_object, _cargo] call FUNC(setCargo); + [_object, _vehicle, true] call ACEFUNC(cargo,loadItem); + }; + } forEach (_values getOrDefault ["ace_cargo", []]); + + // Pylons: setPylonLoadout's effect is local (ACE sends it to every machine), so it's also + // sent to the players, including those who join later + private _pylons = _values getOrDefault ["pylons", []]; + { + _x params ["_index", "_turret", "_magazine", "_rounds"]; + private _loadout = [_index, _magazine, true, [_turret, []] select (_turret isEqualTo [-1])]; + _vehicle setPylonLoadout _loadout; + [_vehicle, _loadout] remoteExecCall ["setPylonLoadout", -2, format ["%1_%2_%3", QGVAR(pylon), _vehicleID, _index]]; + _vehicle setAmmoOnPylon [_index, _rounds]; + } forEach _pylons; + + // Turrets: the magazines there now taken out (but the pylons'), the saved ones put in + if ("turrets" in _values) then { + private _onPylons = _pylons apply {_x select 2}; + private _turrets = (_values get "turrets") select {!((_x select 0) in _onPylons)}; + private _fill = { + params ["_vehicle", "_turrets"]; + private _pylonMagazines = (getAllPylonsInfo _vehicle) apply {_x select 3}; + { + if !((_x select 0) in _pylonMagazines) then { + _vehicle removeMagazineTurret [_x select 0, _x select 1]; + }; + } forEach magazinesAllTurrets _vehicle; + { + _vehicle addMagazineTurret _x; + } forEach _turrets; + }; + if (_csw) then { + [{((_this select 0) getVariable [QACEGVAR(csw,initialising), true]) isEqualTo false}, _fill, [_vehicle, _turrets], 15, _fill] call CBA_fnc_waitUntilAndExecute; + } else { + [_vehicle, _turrets] call _fill; + }; + }; + + if ("ace_fuel" in _values && {!isNil QACEFUNC(refuel,setFuel)}) then { + [_vehicle, _values get "ace_fuel"] call ACEFUNC(refuel,setFuel); + }; + // ACE ammo supply as saved, if the setting still matches (limited, or magazine-specific) + private _rearmSupply = missionNamespace getVariable [QACEGVAR(rearm,supply), 0]; + if ("ace_ammo" in _values && {_rearmSupply == 1}) then { + [_vehicle, _values get "ace_ammo"] call ACEFUNC(rearm,setSupplyCount); + }; + if ("ace_ammo_magazines" in _values && {_rearmSupply == 2}) then { + _vehicle setVariable [QACEGVAR(rearm,magazineSupply), _values get "ace_ammo_magazines", true]; + }; }; }; + +if (isNull _vehicle) exitWith { + ERROR_2("Vehicle %1 (%2) not made: no type or position",_vehicleID,_type); + objNull +}; + +_vehicle allowDamage true; +_vehicle setVariable [QACEGVAR(cookoff,enableAmmoCookoff), false]; +_vehicle setDamage [_values getOrDefault ["damage", 0], false]; +{ + _vehicle setHitPointDamage [_x select 0, _x select 1, false]; +} forEach (_values getOrDefault ["hitpoints", []]); +_vehicle setFuel (_values getOrDefault ["fuel", 1]); +if ("locked" in _values) then { + _vehicle lock (_values get "locked"); +}; + +// Trench progress the next frame, once the vehicles' simulation is on: grad_trenches shows it by +// animating the trench (ACE's trenches by its position, set above) +if ("trench" in _values) then { + [{ + params ["_trench", "_progress"]; + _trench setVariable [QACEGVAR(trenches,progress), _progress, true]; + if (!isNil "grad_trenches_functions_fnc_setTrenchProgress") then { + _trench setObjectTextureGlobal [0, surfaceTexture getPosASL _trench]; + [_trench, _progress] call grad_trenches_functions_fnc_setTrenchProgress; + }; + }, [_vehicle, _values get "trench"]] call CBA_fnc_execNextFrame; +}; + +_vehicle diff --git a/addons/apollo/functions/fnc_vehicleSingletonSave.sqf b/addons/apollo/functions/fnc_vehicleSingletonSave.sqf index 2a781f44e..19a54a216 100644 --- a/addons/apollo/functions/fnc_vehicleSingletonSave.sqf +++ b/addons/apollo/functions/fnc_vehicleSingletonSave.sqf @@ -15,76 +15,106 @@ * Public: No */ -params ["_vehicleObject"]; +params ["_vehicle"]; -private _vehicleID = _vehicleObject getVariable QGVAR(vehicleID); -private _vehicleType = typeOf _vehicleObject; +private _vehicleID = _vehicle getVariable [QGVAR(vehicleID), ""]; +if (isNull _vehicle || {_vehicleID == ""}) exitWith {}; -private _hitpoints = []; -private _configHitpoints = configFile >> "CfgVehicles" >> _vehicleType >> "HitPoints"; +private _config = configOf _vehicle; +private _alive = alive _vehicle; +private _hitpoints = []; +private _configHitpoints = _config >> "HitPoints"; for "_i" from 0 to (count _configHitpoints - 1) do { - private _hitpointEntry = configName (_configHitpoints select _i); - private _hitpointHealth = _vehicleObject getHitPointDamage _hitpointEntry; - _hitpoints pushBack [_hitpointEntry, _hitpointHealth]; -}; - -private _vehiclePos = getPosATL _vehicleObject; -private _vehicleDir = getDir _vehicleObject; -private _vehicleAlive = alive _vehicleObject; -private _vehicleDamage = damage _vehicleObject; - - -private _driver = ""; -private _vehicleCrew = []; -if (_vehicleObject isKindOf "AllVehicles") then { - _driver = name (driver _vehicleObject); - { - _vehicleCrew pushBack [getPlayerUID _x, name _x]; - } forEach (crew _vehicleObject); + private _hitpoint = configName (_configHitpoints select _i); + private _damage = _vehicle getHitPointDamage _hitpoint; + if (!isNil "_damage") then { + _hitpoints pushBack [_hitpoint, _damage]; + }; }; -// Unknown class does not get height added on spawn, all other defined classes do +// Unknown class (static objects) is placed exactly as saved, all other classes get height added on spawn private _vehicleClass = switch (true) do { - case (_vehicleObject isKindOf "Car"): {"Car"}; - case (_vehicleObject isKindOf "Plane"): {"Plane"}; - case (_vehicleObject isKindOf "Helicopter"): {"Helicopter"}; - case (_vehicleObject isKindOf "Tank"): {"Tank"}; - case (_vehicleObject isKindOf "Ship"): {"Ship"}; - case (_vehicleObject isKindOf "ThingX"): {"ObjectPhysX"}; + case (_vehicle isKindOf "Car"): {"Car"}; + case (_vehicle isKindOf "Plane"): {"Plane"}; + case (_vehicle isKindOf "Helicopter"): {"Helicopter"}; + case (_vehicle isKindOf "Tank"): {"Tank"}; + case (_vehicle isKindOf "Ship"): {"Ship"}; + case (_vehicle isKindOf "ThingX"): {"ObjectPhysX"}; default {"Unknown"}; }; -private _vehicleFuel = fuel _vehicleObject; -private _vehicleLock = locked _vehicleObject; -private _vehicleCustomization = [_vehicleObject, ""] call BIS_fnc_exportVehicle; - -private _vehicleAmmo = []; -private _vehicleMagazineCargo = []; -private _vehicleItemCargo = []; -private _vehicleWeapons = []; -private _vehicleBackPacks = []; - -private _vehicleBackpackItems = []; -private _vehicleBackpackMagazines = []; -private _vehicleBackpackWeapons = []; - - -if (_vehicleAlive) then { - _vehicleAmmo = magazinesAmmo _vehicleObject; - _vehicleMagazineCargo = getMagazineCargo _vehicleObject; - _vehicleItemCargo = itemCargo _vehicleObject; - _vehicleWeapons = weaponsItemsCargo _vehicleObject; - _vehicleBackPacks = getBackpackCargo _vehicleObject; - +// Settings: static weapons (with ACE CSW tripods) and objects that aren't vehicles (trenches, +// sandbags, fortifications, crates) can be left out +private _trenchProgress = _vehicle getVariable QACEGVAR(trenches,progress); +private _staticWeapon = _vehicle isKindOf "StaticWeapon" || {_vehicle isKindOf "ace_csw_baseTripod"}; +if (!GVAR(vehiclesStaticWeapons) && {_staticWeapon}) exitWith {}; +if (!GVAR(vehiclesObjects) && {!_staticWeapon} && {!(_vehicle isKindOf "AllVehicles")}) exitWith {}; + +// [key, value] pairs, read by Minotaur (apollo/vehicles.py) +private _data = [ + ["position", getPosATL _vehicle], + ["direction", getDir _vehicle], + ["vector", [vectorDir _vehicle, vectorUp _vehicle]], + ["type", typeOf _vehicle], + ["class", _vehicleClass], + ["name", getText (_config >> "displayName")], + ["alive", _alive], + ["damage", damage _vehicle], + ["hitpoints", _hitpoints], + ["fuel", fuel _vehicle], + ["locked", locked _vehicle], + ["customization", [_vehicle] call BIS_fnc_getVehicleCustomization] // [textures, animations] +]; + +if (_alive) then { + // ACE cargo: a class name as is, a loaded object (a crate, a quad) with its damage, inventory and + // persistent vehicle ID (saved with this vehicle while it's loaded) + private _aceCargo = []; { - _x params ["", "_container"]; - _vehicleBackpackItems append (itemCargo _container); - _vehicleBackpackMagazines append (getMagazineCargo _container); - _vehicleBackpackWeapons append (weaponsItems _container); - } forEach (everyContainer _vehicleObject); + if (_x isEqualType "") then { + _aceCargo pushBack _x; + } else { + if (!isNull _x) then { + _aceCargo pushBack [typeOf _x, damage _x, [_x] call FUNC(getCargo), _x getVariable [QGVAR(vehicleID), ""]]; + }; + }; + } forEach (_vehicle getVariable [QACEGVAR(cargo,loaded), []]); + + _data pushBack ["cargo", [_vehicle] call FUNC(getCargo)]; + if (GVAR(vehiclesACECargo)) then { + _data pushBack ["ace_cargo", _aceCargo]; + }; + if (GVAR(vehiclesTurrets)) then { + _data pushBack ["turrets", magazinesAllTurrets _vehicle]; + }; + if (GVAR(vehiclesPylons)) then { + // Without the pylon objects (written as "NOID x.p3d" or , not data) + _data pushBack ["pylons", (getAllPylonsInfo _vehicle) apply {_x select [0, 5]}]; + }; + + // ACE fuel truck (finite fuel) + if (GVAR(vehiclesACESupply) && {!isNil QACEFUNC(refuel,getCapacity)} && {([_vehicle] call ACEFUNC(refuel,getCapacity)) > 0}) then { + _data pushBack ["ace_fuel", [_vehicle] call ACEFUNC(refuel,getFuel)]; + }; + + // ACE ammo truck: limited supply (a count) or magazine-specific supply (what's stored in it); + // unlimited needs nothing + private _rearmSupply = missionNamespace getVariable [QACEGVAR(rearm,supply), 0]; + if (GVAR(vehiclesACESupply) && {_rearmSupply == 2} && {!isNil {_vehicle getVariable QACEGVAR(rearm,magazineSupply)}}) then { + _data pushBack ["ace_ammo_magazines", _vehicle getVariable QACEGVAR(rearm,magazineSupply)]; + }; + if ( + GVAR(vehiclesACESupply) && {!isNil QACEFUNC(rearm,getSupplyCount)} && {_rearmSupply == 1} && + {!isNil {_vehicle getVariable QACEGVAR(rearm,currentSupply)} || {getNumber (_config >> QACEGVAR(rearm,defaultSupply)) > 0} || {getNumber (_config >> "transportAmmo") > 0}} + ) then { + _data pushBack ["ace_ammo", [_vehicle] call ACEFUNC(rearm,getSupplyCount)]; + }; }; -private _vehicleNamePretty = getText (configFile >> "CfgVehicles" >> _vehicleType >> "displayName"); +// Trench dig progress (ACE, grad_trenches) +if (!isNil "_trenchProgress") then { + _data pushBack ["trench", _trenchProgress]; +}; -["storeVehicle", _vehicleID, _vehiclePos, _vehicleDir, _vehicleType, _vehicleClass, _vehicleAlive, _vehicleDamage, _hitpoints, _vehicleFuel, _vehicleAmmo, _vehicleMagazineCargo, _vehicleItemCargo, _vehicleWeapons, _vehicleCrew, _vehicleBackPacks, _vehicleBackpackItems, _vehicleBackpackMagazines, _vehicleBackpackWeapons, _driver, _vehicleNamePretty, _vehicleLock, _vehicleCustomization] call FUNC(invokeJavaMethod); +["storeVehicle", _vehicleID, _data] call FUNC(callServerExt); diff --git a/addons/apollo/initSettings.inc.sqf b/addons/apollo/initSettings.inc.sqf index 3407e658c..6ae097b70 100644 --- a/addons/apollo/initSettings.inc.sqf +++ b/addons/apollo/initSettings.inc.sqf @@ -41,3 +41,69 @@ {}, true ] call CBA_fnc_addSetting; + +[ + QGVAR(vehiclesObjects), + "CHECKBOX", + [LSTRING(VehiclesObjects), LSTRING(VehiclesObjectsDesc)], + [format ["TAC %1", QUOTE(COMPONENT_BEAUTIFIED)], LSTRING(Vehicles)], + true, + true, + {}, + true +] call CBA_fnc_addSetting; + +[ + QGVAR(vehiclesStaticWeapons), + "CHECKBOX", + [LSTRING(VehiclesStaticWeapons), LSTRING(VehiclesStaticWeaponsDesc)], + [format ["TAC %1", QUOTE(COMPONENT_BEAUTIFIED)], LSTRING(Vehicles)], + true, + true, + {}, + true +] call CBA_fnc_addSetting; + +[ + QGVAR(vehiclesTurrets), + "CHECKBOX", + [LSTRING(VehiclesTurrets), LSTRING(VehiclesTurretsDesc)], + [format ["TAC %1", QUOTE(COMPONENT_BEAUTIFIED)], LSTRING(Vehicles)], + true, + true, + {}, + true +] call CBA_fnc_addSetting; + +[ + QGVAR(vehiclesPylons), + "CHECKBOX", + [LSTRING(VehiclesPylons), LSTRING(VehiclesPylonsDesc)], + [format ["TAC %1", QUOTE(COMPONENT_BEAUTIFIED)], LSTRING(Vehicles)], + true, + true, + {}, + true +] call CBA_fnc_addSetting; + +[ + QGVAR(vehiclesACECargo), + "CHECKBOX", + [LSTRING(VehiclesACECargo), LSTRING(VehiclesACECargoDesc)], + [format ["TAC %1", QUOTE(COMPONENT_BEAUTIFIED)], LSTRING(Vehicles)], + true, + true, + {}, + true +] call CBA_fnc_addSetting; + +[ + QGVAR(vehiclesACESupply), + "CHECKBOX", + [LSTRING(VehiclesACESupply), LSTRING(VehiclesACESupplyDesc)], + [format ["TAC %1", QUOTE(COMPONENT_BEAUTIFIED)], LSTRING(Vehicles)], + true, + true, + {}, + true +] call CBA_fnc_addSetting; diff --git a/addons/apollo/script_component.hpp b/addons/apollo/script_component.hpp index a7e9e036b..ade404276 100644 --- a/addons/apollo/script_component.hpp +++ b/addons/apollo/script_component.hpp @@ -16,8 +16,8 @@ #include "\x\tac\addons\main\script_macros.hpp" -#define REQUIRED_JNI_VERSION "1.0.0" -#define REQUIRED_APOLLOCLIENT_VERSION "1.0.0" +#define REQUIRED_APOLLOSERVER_VERSION "1.0.0" +#define REQUIRED_APOLLOCLIENT_VERSION "1.1.0" #define EXT_VALID_ERROR_CODES [0, 301] #define SAVE_DELAY_PERIODIC 30 diff --git a/addons/apollo/stringtable.xml b/addons/apollo/stringtable.xml index d3d135c4b..2ecb44d16 100644 --- a/addons/apollo/stringtable.xml +++ b/addons/apollo/stringtable.xml @@ -5,7 +5,22 @@ Allow Server Reset - Allows resetting player positions and deleting saved vehicles on map or mission change since last save. + Lets Chronos reset player positions and clear saved vehicles at the mission start (by default on a map change; each server's rule and staff's choice in Logistics › Manage). Off: nothing is reset or remembered for this mission. + + + This bodybag was sent to %1 already. + + + The bodybag couldn't be sent, try again. + + + %1 is no longer with Theseus: the bodybag was destroyed. + + + The owner's death isn't in Chronos yet (it's added when they respawn), try again later. + + + Bodybag sent to %1: %2 items to claim on the website (Logistics, Inventory). Not returnable (destroyed): %3 Enables overall persistence. @@ -37,5 +52,44 @@ Vous êtes en train d'être bougé à l'acceuil pour une réinitialisation. Du wirst wegen Neuinitialisierung zurück zur Lobby verschoben. + + Vehicles + + + ACE Cargo + + + Keeps what is loaded in vehicles' ACE cargo (objects with their inventory, and persistent vehicles loaded into others). + + + ACE Fuel and Ammo Supply + + + Keeps what ACE fuel and ammo trucks have left (finite fuel; limited or magazine-specific ammo supply). + + + Objects + + + Makes objects players place persistent (trenches, sandbags, fortifications, tripods) and keeps the saved objects that aren't vehicles (those, crates, other objects added to Chronos), with a trench's dig progress. + + + Pylons + + + Keeps aircraft pylon loadouts and their ammo. + + + Static Weapons + + + Makes static weapons and ACE CSW tripods persistent when a player deploys one, and keeps the saved ones. + + + Turret Ammo + + + Keeps the magazines and ammo left in vehicles' turrets. Off: vehicles come back with what they're made with. + diff --git a/addons/armory/Dialog.hpp b/addons/armory/Dialog.hpp index 92aa8a3ae..7e7ceea35 100644 --- a/addons/armory/Dialog.hpp +++ b/addons/armory/Dialog.hpp @@ -12,43 +12,64 @@ // Translate by rows and find top of grid #define Y_PART(num) (H_PART(num) + (safeZoneY + (safeZoneH - SIZEY) / 2)) -#define PIC_X X_PART(11.15) -#define PIC_Y Y_PART(2.8) -#define PIC_W W_PART(8.5) -#define PIC_H H_PART(2.2) -#define BTN_Y PIC_Y -#define BTN_W PIC_W * 0.64 -#define BTN_W_WIDE BTN_W * 1.5 -#define BTN_H PIC_H - -// Col 1 -#define PIC_X_C1 PIC_X -#define BTN_X_C1 PIC_X_C1 -// Col 2 -#define PIC_X_C2 PIC_X + 0.24 -#define BTN_X_C2 PIC_X_C2 -// Col 3 -#define PIC_X_C3 PIC_X + 0.36 -#define BTN_X_C3 PIC_X_C3 - -// Offsets -#define OFFSET_Y_R2 0.11 -#define OFFSET_Y_R3 0.215 -#define OFFSET_Y_R4 0.32 -#define OFFSET_Y_R5 0.425 -#define OFFSET_Y_R6 0.53 -#define OFFSET_Y_RE 0.77 - +// The pad's screen grid (background.paa, 1024 px over 34 parts): a column every 40 px from 208 px across, a row every +// 20 px from 123 px down. Its lines are at GRID_X(0) to GRID_X(15) and GRID_Y(0) to GRID_Y(38). +#define PAD_PX(px) ((px) * 34 / 1024) +#define GRID_X(col) X_PART((3 + PAD_PX(208 + 40 * (col)))) +#define GRID_Y(row) Y_PART((-4.5 + PAD_PX(123 + 20 * (row)))) +#define GRID_W(cols) W_PART(PAD_PX(40 * (cols))) +#define GRID_H(rows) H_PART(PAD_PX(20 * (rows))) + +// Buttons: 6 columns by 3 rows, in two columns a column in from the screen's edges and a column apart +#define BTN_W GRID_W(6) +#define BTN_H GRID_H(3) +#define BTN_X_C1 GRID_X(1) +#define BTN_X_C2 GRID_X(8) +// Main menu rows 1 to 6, every 4 rows from row 5 +#define BTN_Y_R(num) GRID_Y((1 + 4 * (num))) +// Bottom row (Exit/Back, Take/Stash/Camera) and the one above it (Stash All, left of the amount) +#define BTN_Y_RE GRID_Y(34) +#define BTN_Y_RE2 GRID_Y(30) +// The camera icon: square, in the middle of its button +#define ICON_X(x) (x + (BTN_W - BTN_H) / 2) +#define ICON_W BTN_H + +// Messages (FUNC(showMessage)): a panel over the list, with OK in the middle of its bottom +#define MSG_X GRID_X(1) +#define MSG_Y GRID_Y(8) +#define MSG_W GRID_W(13) +#define MSG_H GRID_H(21) +#define MSG_OK_X GRID_X(6) +#define MSG_OK_Y GRID_Y(25) +#define MSG_OK_W GRID_W(3) + +// Text: Arma's Purista Bold, black on the pad's screen, no shadow +#define TEXT_FONT "PuristaBold" +#define TEXT_FONT_SMALL "RobotoCondensed" +#define TEXT_COLOR {0, 0, 0, 0.9} +#define TEXT_COLOR_DISABLED {0, 0, 0, 0.4} +#define BTN_TEXT_SIZE H_PART(1.4) +#define TITLE_TEXT_SIZE H_PART(1.8) +#define LABEL_TEXT_SIZE H_PART(0.9) +// Messages: about 29 characters a line (their titles 1.33 times bigger, FUNC(showMessage)) +#define MSG_TEXT_SIZE H_PART(1.2) + +// Amount: above Take/Stash, right-aligned with it +#define AMOUNT_X GRID_X(11) +#define AMOUNT_Y GRID_Y(30) +#define AMOUNT_W GRID_W(3) // Type definitions #define CT_STATIC 0 #define CT_BUTTON 1 #define CT_COMBO 4 +#define CT_STRUCTURED_TEXT 13 #define CT_LISTNBOX 102 // Style definitions #define ST_MULTI 16 #define ST_PICTURE 48 #define ST_LEFT 0x00 +#define ST_VCENTER 0x0C #define LB_TEXTURES 0x10 class ctrlStatic; @@ -60,19 +81,49 @@ class GVAR(RscPicture) { text = ""; colorText[] = {1, 1, 1, 1}; colorBackground[] = {1, 1, 1, 0}; - font = "RobotoCondensed"; + font = TEXT_FONT_SMALL; sizeEx = 0.02; - w = QUOTE(PIC_W); - h = QUOTE(PIC_H); }; +// Text on the pad's screen (titles, labels) +class GVAR(RscText) { + idc = -1; + type = CT_STATIC; + style = ST_LEFT; + text = ""; + colorText[] = TEXT_COLOR; + colorBackground[] = {0, 0, 0, 0}; + font = TEXT_FONT; + sizeEx = QUOTE(LABEL_TEXT_SIZE); + shadow = 0; +}; + +// A button's frame: a 1 px rectangle in colorText, where its button is +class GVAR(RscFrame) { + idc = -1; + type = CT_STATIC; + style = ST_FRAME; + text = ""; + colorText[] = {0, 0, 0, 0.76}; + colorBackground[] = {0, 0, 0, 0}; + font = TEXT_FONT; + sizeEx = QUOTE(H_PART(0.5)); + shadow = 0; + w = QUOTE(BTN_W); + h = QUOTE(BTN_H); +}; + +// Over its frame (GVAR(RscFrame)) or icon (GVAR(RscPicture)): the label as text, or none class GVAR(RscButton) { idc = -1; type = CT_BUTTON; - style = ST_PICTURE; - colorText[] = {1, 1, 1, 0}; - colorFocused[] = {1, 1, 1, 0}; - colorDisabled[] = {1, 1, 1, 0}; + style = QUOTE(ST_LEFT + ST_VCENTER); + colorText[] = TEXT_COLOR; + // The focused button's background blinks between these two: none, as focus moves to Export when + // the clicked button is hidden (which blinked over its icon) + colorFocused[] = {0, 0, 0, 0}; + colorBackground2[] = {0, 0, 0, 0}; + colorDisabled[] = TEXT_COLOR_DISABLED; colorBackground[] = {1, 1, 1, 0}; colorBackgroundDisabled[] = {0, 0, 0, 0}; colorBackgroundActive[] = {0, 0, 0, 0.25}; @@ -87,18 +138,38 @@ class GVAR(RscButton) { offsetY = 0; offsetPressedX = 0; offsetPressedY = 0; - font = "RobotoCondensed"; - sizeEx = 0.02; + font = TEXT_FONT; + sizeEx = QUOTE(BTN_TEXT_SIZE); + shadow = 0; text = ""; w = QUOTE(BTN_W); h = QUOTE(BTN_H); }; +// A message's text (FUNC(showMessage)): centred lines, the first one bigger +class GVAR(RscMessage) { + idc = -1; + type = CT_STRUCTURED_TEXT; + style = 0; + text = ""; + size = QUOTE(MSG_TEXT_SIZE); + colorBackground[] = {0, 0, 0, 0}; + shadow = 0; + class Attributes { + font = TEXT_FONT; + color = "#e6000000"; + align = "center"; + valign = "middle"; + shadow = 0; + size = 1; + }; +}; + class GVAR(RscCombo) { idc = -1; type = CT_COMBO; style = QUOTE(ST_LEFT + LB_TEXTURES); - font = "RobotoCondensed"; + font = TEXT_FONT_SMALL; sizeEx = 0.04; shadow = 0; colorText[] = {0, 0, 0, 1}; @@ -122,11 +193,32 @@ class GVAR(RscCombo) { }; }; +// The amount dropdown in the pad's style (framed by an RscFrame behind it), its list in the screen's colour +class GVAR(RscComboAmount): GVAR(RscCombo) { + style = ST_LEFT; + font = TEXT_FONT; + sizeEx = QUOTE(BTN_TEXT_SIZE); + colorText[] = TEXT_COLOR; + colorDisabled[] = TEXT_COLOR_DISABLED; + colorBackground[] = {0.41, 0.43, 0.18, 1}; + colorSelect[] = TEXT_COLOR; + colorSelectBackground[] = {0, 0, 0, 0.25}; + arrowEmpty = QPATHTOF(UI\iconArrow.paa); + arrowFull = QPATHTOF(UI\iconArrow.paa); + class ComboScrollBar { + color[] = {0, 0, 0, 0.6}; + arrowEmpty = "\A3\ui_f\data\gui\cfg\scrollbar\arrowEmpty_ca.paa"; + arrowFull = "\A3\ui_f\data\gui\cfg\scrollbar\arrowFull_ca.paa"; + border = "\A3\ui_f\data\gui\cfg\scrollbar\border_ca.paa"; + thumb = "\A3\ui_f\data\gui\cfg\scrollbar\thumb_ca.paa"; + }; +}; + class GVAR(RscListNBox) { idc = -1; type = CT_LISTNBOX; style = ST_MULTI; - font = "RobotoCondensed"; + font = TEXT_FONT_SMALL; sizeEx = 0.04; colorText[] = {0, 0, 0, 1}; colorDisabled[] = {0, 0, 0, 0.25}; @@ -186,18 +278,19 @@ class GVAR(Display) { }; class controls { // Title - class Title: GVAR(RscPicture) { + class Title: GVAR(RscText) { idc = TITLE; - x = QUOTE(X_PART(11.4)); - y = QUOTE(Y_PART(0.4)); - w = QUOTE(W_PART(16)); - h = QUOTE(H_PART(1.1)); + sizeEx = QUOTE(TITLE_TEXT_SIZE); + x = QUOTE(GRID_X(1)); + y = QUOTE(GRID_Y(1)); + w = QUOTE(GRID_W(13)); + h = QUOTE(GRID_H(3)); }; // Dropdown Menu class Dropdown: GVAR(RscCombo) { idc = DROPDOWN; - onLBSelChanged = QUOTE([GVAR(armoryData)] call FUNC(dialogControl_populateList)); + onLBSelChanged = QUOTE(call FUNC(dialogControl_dropdown)); x = QUOTE(X_PART(10.3)); y = QUOTE(Y_PART(2.3)); w = QUOTE(W_PART(19.3)); @@ -205,8 +298,9 @@ class GVAR(Display) { }; // Amount - class Amount: GVAR(RscPicture) { + class Amount: GVAR(RscText) { idc = AMOUNT; + text = CSTRING(Amount); x = QUOTE(X_PART(25)); y = QUOTE(Y_PART(3.9)); w = QUOTE(W_PART(4)); @@ -224,184 +318,241 @@ class GVAR(Display) { }; // Dropdown Amount Selection - class DropdownAmount: GVAR(RscCombo) { + class DropdownAmount_Frame: GVAR(RscFrame) { + idc = AMOUNTFRAME; + x = QUOTE(AMOUNT_X); + y = QUOTE(AMOUNT_Y); + w = QUOTE(AMOUNT_W); + }; + class DropdownAmount: GVAR(RscComboAmount) { // a pixel inside the frame, which its background would cover idc = DROPDOWNAMOUNT; onLBSelChanged = QUOTE(call FUNC(dialogControl_takestash)); - x = QUOTE(X_PART(24.6)); - y = QUOTE(Y_PART(20.2)); - w = QUOTE(W_PART(3.9)); - h = QUOTE(H_PART(1.3)); + x = QUOTE(AMOUNT_X + pixelW); + y = QUOTE(AMOUNT_Y + pixelH); + w = QUOTE(AMOUNT_W - 2 * pixelW); + h = QUOTE(BTN_H - 2 * pixelH); + }; + + // Message (over the list, FUNC(showMessage)) + class Message_Frame: GVAR(RscFrame) { + idc = MESSAGEFRAME; + x = QUOTE(MSG_X); + y = QUOTE(MSG_Y); + w = QUOTE(MSG_W); + h = QUOTE(MSG_H); + }; + class Message_Text: GVAR(RscMessage) { + idc = MESSAGETEXT; + x = QUOTE(MSG_X + GRID_W(0.5)); + y = QUOTE(MSG_Y); + w = QUOTE(MSG_W - GRID_W(1)); + h = QUOTE(MSG_H); + }; + class Message_Ok_Frame: GVAR(RscFrame) { + idc = MESSAGEOKFRAME; + x = QUOTE(MSG_OK_X); + y = QUOTE(MSG_OK_Y); + w = QUOTE(MSG_OK_W); + }; + class Message_Ok_Btn: GVAR(RscButton) { + idc = MESSAGEOKBTN; + onMouseButtonClick = QUOTE(call FUNC(dismissMessage)); + text = CSTRING(BtnOk); + x = QUOTE(MSG_OK_X); + y = QUOTE(MSG_OK_Y); + w = QUOTE(MSG_OK_W); }; // Exit-Back - class Main_Pic_C1_RE: GVAR(RscPicture) { - idc = BACKPIC; - x = QUOTE(PIC_X_C1); - y = QUOTE(PIC_Y + OFFSET_Y_RE); + class Main_Frame_C1_RE: GVAR(RscFrame) { + idc = BACKFRAME; + x = QUOTE(BTN_X_C1); + y = QUOTE(BTN_Y_RE); }; class Main_Btn_C1_RE: GVAR(RscButton) { idc = BACKBTN; x = QUOTE(BTN_X_C1); - y = QUOTE(BTN_Y + OFFSET_Y_RE); + y = QUOTE(BTN_Y_RE); }; // Take-Stash - class TakeStash_Pic_C1_R1: GVAR(RscPicture) { - idc = TAKESTASHPIC; - x = QUOTE(PIC_X_C3); - y = QUOTE(PIC_Y + OFFSET_Y_RE); + class TakeStash_Frame_C1_R1: GVAR(RscFrame) { + idc = TAKESTASHFRAME; + x = QUOTE(BTN_X_C2); + y = QUOTE(BTN_Y_RE); + }; + // Camera (main menu, under the Take/Stash button) + class Camera_Pic: GVAR(RscPicture) { + idc = CAMERAPIC; + x = QUOTE(ICON_X(BTN_X_C2)); + y = QUOTE(BTN_Y_RE); + w = QUOTE(ICON_W); + h = QUOTE(ICON_W); + text = QPATHTOF(UI\iconCamera.paa); }; class TakeStash_Btn_C1_R1: GVAR(RscButton) { idc = TAKESTASHBTN; - x = QUOTE(BTN_X_C3); - y = QUOTE(BTN_Y + OFFSET_Y_RE); + x = QUOTE(BTN_X_C2); + y = QUOTE(BTN_Y_RE); + }; + + // Stash All (Stash), TAKE an item (Kits): set by FUNC(dialogControl_list) and FUNC(dialogControl_takestash) + class StashAll_Frame_C1_RE2: GVAR(RscFrame) { + idc = STASHALLFRAME; + x = QUOTE(BTN_X_C1); + y = QUOTE(BTN_Y_RE2); + }; + class StashAll_Btn_C1_RE2: GVAR(RscButton) { + idc = STASHALLBTN; + x = QUOTE(BTN_X_C1); + y = QUOTE(BTN_Y_RE2); }; // MAIN MENU ONLY /* Column 1 */ // Row 1 - class Main_Pic_C1_R1: GVAR(RscPicture) { - idc = MAINPIC1; - x = QUOTE(PIC_X_C1); - y = QUOTE(PIC_Y); + class Main_Frame_C1_R1: GVAR(RscFrame) { + idc = MAINFRAME1; + x = QUOTE(BTN_X_C1); + y = QUOTE(BTN_Y_R(1)); }; class Main_Btn_C1_R1: GVAR(RscButton) { idc = MAINBTN1; x = QUOTE(BTN_X_C1); - y = QUOTE(BTN_Y); + y = QUOTE(BTN_Y_R(1)); }; // Row 2 - class Main_Pic_C1_R2: GVAR(RscPicture) { - idc = MAINPIC2; - x = QUOTE(PIC_X_C1); - y = QUOTE(PIC_Y + OFFSET_Y_R2); + class Main_Frame_C1_R2: GVAR(RscFrame) { + idc = MAINFRAME2; + x = QUOTE(BTN_X_C1); + y = QUOTE(BTN_Y_R(2)); }; class Main_Btn_C1_R2: GVAR(RscButton) { idc = MAINBTN2; x = QUOTE(BTN_X_C1); - y = QUOTE(BTN_Y + OFFSET_Y_R2); + y = QUOTE(BTN_Y_R(2)); }; // Row 3 - class Main_Pic_C1_R3: GVAR(RscPicture) { - idc = MAINPIC3; - x = QUOTE(PIC_X_C1); - y = QUOTE(PIC_Y + OFFSET_Y_R3); + class Main_Frame_C1_R3: GVAR(RscFrame) { + idc = MAINFRAME3; + x = QUOTE(BTN_X_C1); + y = QUOTE(BTN_Y_R(3)); }; class Main_Btn_C1_R3: GVAR(RscButton) { idc = MAINBTN3; x = QUOTE(BTN_X_C1); - y = QUOTE(BTN_Y + OFFSET_Y_R3); + y = QUOTE(BTN_Y_R(3)); }; // Row 4 - class Main_Pic_C1_R4: GVAR(RscPicture) { - idc = MAINPIC4; - x = QUOTE(PIC_X_C1); - y = QUOTE(PIC_Y + OFFSET_Y_R4); + class Main_Frame_C1_R4: GVAR(RscFrame) { + idc = MAINFRAME4; + x = QUOTE(BTN_X_C1); + y = QUOTE(BTN_Y_R(4)); }; class Main_Btn_C1_R4: GVAR(RscButton) { idc = MAINBTN4; x = QUOTE(BTN_X_C1); - y = QUOTE(BTN_Y + OFFSET_Y_R4); + y = QUOTE(BTN_Y_R(4)); }; // Row 5 - class Main_Pic_C1_R5: GVAR(RscPicture) { - idc = MAINPIC5; - x = QUOTE(PIC_X_C1); - y = QUOTE(PIC_Y + OFFSET_Y_R5); + class Main_Frame_C1_R5: GVAR(RscFrame) { + idc = MAINFRAME5; + x = QUOTE(BTN_X_C1); + y = QUOTE(BTN_Y_R(5)); }; class Main_Btn_C1_R5: GVAR(RscButton) { idc = MAINBTN5; x = QUOTE(BTN_X_C1); - y = QUOTE(BTN_Y + OFFSET_Y_R5); + y = QUOTE(BTN_Y_R(5)); }; // Row 6 - class Main_Pic_C1_R6: GVAR(RscPicture) { - idc = MAINPIC6; - x = QUOTE(PIC_X_C1); - y = QUOTE(PIC_Y + OFFSET_Y_R6); + class Main_Frame_C1_R6: GVAR(RscFrame) { + idc = MAINFRAME6; + x = QUOTE(BTN_X_C1); + y = QUOTE(BTN_Y_R(6)); }; class Main_Btn_C1_R6: GVAR(RscButton) { idc = MAINBTN6; x = QUOTE(BTN_X_C1); - y = QUOTE(BTN_Y + OFFSET_Y_R6); + y = QUOTE(BTN_Y_R(6)); }; /* Column 2 */ // Row 1 - class Main_Pic_C2_R1: GVAR(RscPicture) { - idc = MAINPIC7; - x = QUOTE(PIC_X_C2); - y = QUOTE(PIC_Y); + class Main_Frame_C2_R1: GVAR(RscFrame) { + idc = MAINFRAME7; + x = QUOTE(BTN_X_C2); + y = QUOTE(BTN_Y_R(1)); }; class Main_Btn_C2_R1: GVAR(RscButton) { idc = MAINBTN7; x = QUOTE(BTN_X_C2); - y = QUOTE(BTN_Y); + y = QUOTE(BTN_Y_R(1)); }; // Row 2 - class Main_Pic_C2_R2: GVAR(RscPicture) { - idc = MAINPIC8; - x = QUOTE(PIC_X_C2); - y = QUOTE(PIC_Y + OFFSET_Y_R2); + class Main_Frame_C2_R2: GVAR(RscFrame) { + idc = MAINFRAME8; + x = QUOTE(BTN_X_C2); + y = QUOTE(BTN_Y_R(2)); }; class Main_Btn_C2_R2: GVAR(RscButton) { idc = MAINBTN8; x = QUOTE(BTN_X_C2); - y = QUOTE(BTN_Y + OFFSET_Y_R2); + y = QUOTE(BTN_Y_R(2)); }; // Row 3 - class Main_Pic_C2_R3: GVAR(RscPicture) { - idc = MAINPIC9; - x = QUOTE(PIC_X_C2); - y = QUOTE(PIC_Y + OFFSET_Y_R3); + class Main_Frame_C2_R3: GVAR(RscFrame) { + idc = MAINFRAME9; + x = QUOTE(BTN_X_C2); + y = QUOTE(BTN_Y_R(3)); }; class Main_Btn_C2_R3: GVAR(RscButton) { idc = MAINBTN9; x = QUOTE(BTN_X_C2); - y = QUOTE(BTN_Y + OFFSET_Y_R3); + y = QUOTE(BTN_Y_R(3)); }; // Row 4 - class Main_Pic_C2_R4: GVAR(RscPicture) { - idc = MAINPIC10; - x = QUOTE(PIC_X_C2); - y = QUOTE(PIC_Y + OFFSET_Y_R4); + class Main_Frame_C2_R4: GVAR(RscFrame) { + idc = MAINFRAME10; + x = QUOTE(BTN_X_C2); + y = QUOTE(BTN_Y_R(4)); }; class Main_Btn_C2_R4: GVAR(RscButton) { idc = MAINBTN10; x = QUOTE(BTN_X_C2); - y = QUOTE(BTN_Y + OFFSET_Y_R4); + y = QUOTE(BTN_Y_R(4)); }; // Row 5 - class Main_Pic_C2_R5: GVAR(RscPicture) { - idc = MAINPIC11; - x = QUOTE(PIC_X_C2); - y = QUOTE(PIC_Y + OFFSET_Y_R5); + class Main_Frame_C2_R5: GVAR(RscFrame) { + idc = MAINFRAME11; + x = QUOTE(BTN_X_C2); + y = QUOTE(BTN_Y_R(5)); }; class Main_Btn_C2_R5: GVAR(RscButton) { idc = MAINBTN11; x = QUOTE(BTN_X_C2); - y = QUOTE(BTN_Y + OFFSET_Y_R5); + y = QUOTE(BTN_Y_R(5)); }; // Row 6 - class Main_Pic_C2_R6: GVAR(RscPicture) { - idc = MAINPIC12; - x = QUOTE(PIC_X_C2); - y = QUOTE(PIC_Y + OFFSET_Y_R6); + class Main_Frame_C2_R6: GVAR(RscFrame) { + idc = MAINFRAME12; + x = QUOTE(BTN_X_C2); + y = QUOTE(BTN_Y_R(6)); }; class Main_Btn_C2_R6: GVAR(RscButton) { idc = MAINBTN12; x = QUOTE(BTN_X_C2); - y = QUOTE(BTN_Y + OFFSET_Y_R6); + y = QUOTE(BTN_Y_R(6)); }; // PHYSICAL @@ -411,7 +562,7 @@ class GVAR(Display) { y = QUOTE(Y_PART(3)); w = QUOTE(W_PART(2)); h = QUOTE(H_PART(2)); - text = QPATHTOF(UI\btnExport.paa); + text = QPATHTOF(UI\iconExport.paa); }; class Export_Btn: GVAR(RscButton) { idc = EXPORTBTN; @@ -424,11 +575,18 @@ class GVAR(Display) { }; // CAMERA + class CameraFrame: GVAR(RscFrame) { + idc = CAMERAFRAME; + x = QUOTE(safeZoneX); + y = QUOTE(safeZoneY); + }; class CameraHint: GVAR(RscPicture) { idc = CAMERAHINT; - x = QUOTE(safeZoneX); + x = QUOTE(ICON_X(safeZoneX)); y = QUOTE(safeZoneY); - text = QPATHTOF(UI\btnCamera.paa); + w = QUOTE(ICON_W); + h = QUOTE(ICON_W); + text = QPATHTOF(UI\iconCamera.paa); }; class CameraExit: GVAR(RscButton) { idc = CAMERAEXIT; diff --git a/addons/armory/README.md b/addons/armory/README.md index 8d191ac2a..4b720b08a 100644 --- a/addons/armory/README.md +++ b/addons/armory/README.md @@ -2,6 +2,10 @@ Adds Armory with Chronos support. +With Chronos (TAC Apollo), items are taken from and stashed into the player's locker, kits (prepared on the website) are taken in one go, and **Stash All** puts everything in the box into the locker (see the `apollo` addon's README). + +The pad's buttons, titles and labels are text in Arma's `LCD14` font (stringtable, `FUNC(setButton)`), and the buttons' frames are drawn by the game. Only the pad (`background.paa`) and the icons (`iconCamera.paa`, `iconExport.paa`, and the amount dropdown's arrow `iconArrow.paa`) are pictures. + ### Authors - [Jonpas](https://github.com/jonpas) diff --git a/addons/armory/UI/background.paa b/addons/armory/UI/background.paa index 064c2e27f..98b54f457 100644 Binary files a/addons/armory/UI/background.paa and b/addons/armory/UI/background.paa differ diff --git a/addons/armory/UI/btnBack.paa b/addons/armory/UI/btnBack.paa deleted file mode 100644 index 3354d5fc2..000000000 Binary files a/addons/armory/UI/btnBack.paa and /dev/null differ diff --git a/addons/armory/UI/btnCamera.paa b/addons/armory/UI/btnCamera.paa deleted file mode 100644 index c18e6f2f8..000000000 Binary files a/addons/armory/UI/btnCamera.paa and /dev/null differ diff --git a/addons/armory/UI/btnCategory_ammo.paa b/addons/armory/UI/btnCategory_ammo.paa deleted file mode 100644 index 2c8d36880..000000000 Binary files a/addons/armory/UI/btnCategory_ammo.paa and /dev/null differ diff --git a/addons/armory/UI/btnCategory_attachment.paa b/addons/armory/UI/btnCategory_attachment.paa deleted file mode 100644 index 30e828981..000000000 Binary files a/addons/armory/UI/btnCategory_attachment.paa and /dev/null differ diff --git a/addons/armory/UI/btnCategory_backpack.paa b/addons/armory/UI/btnCategory_backpack.paa deleted file mode 100644 index 300717a44..000000000 Binary files a/addons/armory/UI/btnCategory_backpack.paa and /dev/null differ diff --git a/addons/armory/UI/btnCategory_insignia.paa b/addons/armory/UI/btnCategory_insignia.paa deleted file mode 100644 index e9352765f..000000000 Binary files a/addons/armory/UI/btnCategory_insignia.paa and /dev/null differ diff --git a/addons/armory/UI/btnCategory_item.paa b/addons/armory/UI/btnCategory_item.paa deleted file mode 100644 index c2fbf01f9..000000000 Binary files a/addons/armory/UI/btnCategory_item.paa and /dev/null differ diff --git a/addons/armory/UI/btnCategory_launcher.paa b/addons/armory/UI/btnCategory_launcher.paa deleted file mode 100644 index 1eaef8ddb..000000000 Binary files a/addons/armory/UI/btnCategory_launcher.paa and /dev/null differ diff --git a/addons/armory/UI/btnCategory_pistol.paa b/addons/armory/UI/btnCategory_pistol.paa deleted file mode 100644 index 842fd24bc..000000000 Binary files a/addons/armory/UI/btnCategory_pistol.paa and /dev/null differ diff --git a/addons/armory/UI/btnCategory_rifle.paa b/addons/armory/UI/btnCategory_rifle.paa deleted file mode 100644 index 218eedef0..000000000 Binary files a/addons/armory/UI/btnCategory_rifle.paa and /dev/null differ diff --git a/addons/armory/UI/btnCategory_wearable.paa b/addons/armory/UI/btnCategory_wearable.paa deleted file mode 100644 index a10d9f2d0..000000000 Binary files a/addons/armory/UI/btnCategory_wearable.paa and /dev/null differ diff --git a/addons/armory/UI/btnExit.paa b/addons/armory/UI/btnExit.paa deleted file mode 100644 index 86c2a08ee..000000000 Binary files a/addons/armory/UI/btnExit.paa and /dev/null differ diff --git a/addons/armory/UI/btnStash.paa b/addons/armory/UI/btnStash.paa deleted file mode 100644 index 349d959ae..000000000 Binary files a/addons/armory/UI/btnStash.paa and /dev/null differ diff --git a/addons/armory/UI/btnTake.paa b/addons/armory/UI/btnTake.paa deleted file mode 100644 index 4795fcbe4..000000000 Binary files a/addons/armory/UI/btnTake.paa and /dev/null differ diff --git a/addons/armory/UI/iconArrow.paa b/addons/armory/UI/iconArrow.paa new file mode 100644 index 000000000..b2694bf86 Binary files /dev/null and b/addons/armory/UI/iconArrow.paa differ diff --git a/addons/armory/UI/iconCamera.paa b/addons/armory/UI/iconCamera.paa new file mode 100644 index 000000000..c3811647d Binary files /dev/null and b/addons/armory/UI/iconCamera.paa differ diff --git a/addons/armory/UI/btnExport.paa b/addons/armory/UI/iconExport.paa similarity index 100% rename from addons/armory/UI/btnExport.paa rename to addons/armory/UI/iconExport.paa diff --git a/addons/armory/UI/textAmount.paa b/addons/armory/UI/textAmount.paa deleted file mode 100644 index cfc2f1cc9..000000000 Binary files a/addons/armory/UI/textAmount.paa and /dev/null differ diff --git a/addons/armory/UI/titleCategory_ammo.paa b/addons/armory/UI/titleCategory_ammo.paa deleted file mode 100644 index b4e8d6e38..000000000 Binary files a/addons/armory/UI/titleCategory_ammo.paa and /dev/null differ diff --git a/addons/armory/UI/titleCategory_attachment.paa b/addons/armory/UI/titleCategory_attachment.paa deleted file mode 100644 index a6d7412da..000000000 Binary files a/addons/armory/UI/titleCategory_attachment.paa and /dev/null differ diff --git a/addons/armory/UI/titleCategory_backpack.paa b/addons/armory/UI/titleCategory_backpack.paa deleted file mode 100644 index 0595a3bf9..000000000 Binary files a/addons/armory/UI/titleCategory_backpack.paa and /dev/null differ diff --git a/addons/armory/UI/titleCategory_insignia.paa b/addons/armory/UI/titleCategory_insignia.paa deleted file mode 100644 index a8d3488e9..000000000 Binary files a/addons/armory/UI/titleCategory_insignia.paa and /dev/null differ diff --git a/addons/armory/UI/titleCategory_item.paa b/addons/armory/UI/titleCategory_item.paa deleted file mode 100644 index c9c8c70ca..000000000 Binary files a/addons/armory/UI/titleCategory_item.paa and /dev/null differ diff --git a/addons/armory/UI/titleCategory_launcher.paa b/addons/armory/UI/titleCategory_launcher.paa deleted file mode 100644 index 3cbe7c9a2..000000000 Binary files a/addons/armory/UI/titleCategory_launcher.paa and /dev/null differ diff --git a/addons/armory/UI/titleCategory_pistol.paa b/addons/armory/UI/titleCategory_pistol.paa deleted file mode 100644 index 452087ac3..000000000 Binary files a/addons/armory/UI/titleCategory_pistol.paa and /dev/null differ diff --git a/addons/armory/UI/titleCategory_rifle.paa b/addons/armory/UI/titleCategory_rifle.paa deleted file mode 100644 index 70c9a353a..000000000 Binary files a/addons/armory/UI/titleCategory_rifle.paa and /dev/null differ diff --git a/addons/armory/UI/titleCategory_stash.paa b/addons/armory/UI/titleCategory_stash.paa deleted file mode 100644 index 8eca191df..000000000 Binary files a/addons/armory/UI/titleCategory_stash.paa and /dev/null differ diff --git a/addons/armory/UI/titleCategory_wearable.paa b/addons/armory/UI/titleCategory_wearable.paa deleted file mode 100644 index b724fcb80..000000000 Binary files a/addons/armory/UI/titleCategory_wearable.paa and /dev/null differ diff --git a/addons/armory/UI/title_Main.paa b/addons/armory/UI/title_Main.paa deleted file mode 100644 index fa880bf43..000000000 Binary files a/addons/armory/UI/title_Main.paa and /dev/null differ diff --git a/addons/armory/XEH_PREP.hpp b/addons/armory/XEH_PREP.hpp index f8d0a54b1..aca78038b 100644 --- a/addons/armory/XEH_PREP.hpp +++ b/addons/armory/XEH_PREP.hpp @@ -7,22 +7,32 @@ PREP(closeArmory); PREP(closeCamera); PREP(dialogControl_amountSelection); PREP(dialogControl_back); +PREP(dialogControl_dropdown); +PREP(dialogControl_kitItems); +PREP(dialogControl_kits); PREP(dialogControl_list); PREP(dialogControl_main); PREP(dialogControl_populateList); PREP(dialogControl_takestash); PREP(dialogControl); +PREP(dismissMessage); PREP(exportLoadout); PREP(extractSubCategories); PREP(getBaseVariant); PREP(getBoxContents); PREP(getDataVanilla); PREP(getDataChronos); +PREP(getStashVariant); +PREP(hideMessage); PREP(init); PREP(isCompatible); PREP(onKeyDown); PREP(openArmory); PREP(openCamera); PREP(processAction); +PREP(setButton); +PREP(showMessage); +PREP(stashAll); PREP(subtractData); +PREP(takeKit); PREP(updateData); diff --git a/addons/armory/XEH_postInitClient.sqf b/addons/armory/XEH_postInitClient.sqf index 30c4f86bd..50d4e444b 100644 --- a/addons/armory/XEH_postInitClient.sqf +++ b/addons/armory/XEH_postInitClient.sqf @@ -32,10 +32,37 @@ if (!hasInterface) exitWith {}; TRACE_1("Finish subtract on full refresh",_subtractOnFullRefresh); [_boxContents] call FUNC(updateData); + { + ctrlShow [_x, GVAR(system) == 1]; + } forEach [STASHALLFRAME, STASHALLBTN]; }; }, _player, 1] call CBA_fnc_waitUntilAndExecute; }] call CBA_fnc_addEventHandler; +// Stash All done: what the locker didn't take is still in the box +[QEGVAR(apollo,lockerStashAllDone), { + params ["_player", "_left"]; + if (_left isEqualTo []) exitWith {}; // the list shows it + private _names = _left apply { + private _displayName = getText ((_x call CBA_fnc_getItemConfig) >> "displayName"); + if (_displayName == "") then { _displayName = getText ((_x call CBA_fnc_getObjectConfig) >> "displayName"); }; + [_displayName, _x] select (_displayName == "") + }; + [LLSTRING(MsgNotStashed), [LLSTRING(MsgNotStashedText)] + _names + [LLSTRING(MsgNotStashedLeft)], true, "stash"] call FUNC(showMessage); +}] call CBA_fnc_addEventHandler; + +// Kit taken (or refused): refresh the kits, as the locker has changed +[QEGVAR(apollo,lockerKitTaken), { + params ["_player", "_success"]; + // Not over a message waiting for OK (which refreshes them) + if (!isNull (_player getVariable [QGVAR(object), objNull]) && {GVAR(selectedCategory) == "kits"} && {GVAR(messageDismissable) isNotEqualTo true}) then { + [lbCurSel DROPDOWN] call FUNC(dialogControl_kits); + }; + if (!_success) then { + [LLSTRING(MsgKitFailed), [LLSTRING(MsgKitFailedText), LLSTRING(MsgTryAgain)], true, "kits"] call FUNC(showMessage); + }; +}] call CBA_fnc_addEventHandler; + [QGVAR(Locker), "ContainerOpened", { params ["_container", "_unit"]; diff --git a/addons/armory/functions/fnc_closeArmory.sqf b/addons/armory/functions/fnc_closeArmory.sqf index efb092772..32468b476 100644 --- a/addons/armory/functions/fnc_closeArmory.sqf +++ b/addons/armory/functions/fnc_closeArmory.sqf @@ -24,3 +24,4 @@ ACE_player setVariable [QGVAR(object), nil, true]; // Clean up variables GVAR(selectedCategory) = nil; GVAR(armoryData) = nil; +GVAR(messageDismissable) = nil; diff --git a/addons/armory/functions/fnc_dialogControl.sqf b/addons/armory/functions/fnc_dialogControl.sqf index 05ab78c16..5c097ded8 100644 --- a/addons/armory/functions/fnc_dialogControl.sqf +++ b/addons/armory/functions/fnc_dialogControl.sqf @@ -29,12 +29,15 @@ if (_requestedMenu == "main") exitWith { ctrlShow [_x, true]; } forEach [ BACKGROUND, TITLE, - BACKPIC, BACKBTN, + BACKFRAME, BACKBTN, EXPORTPIC, EXPORTBTN ]; + GVAR(selectedCategory) = "main"; // no list: nothing refreshes it (XEH_postInitClient); only Export shows a message here, other messages go to hints + GVAR(messageDismissable) = false; + // Set Title - ctrlSetText [TITLE, format[QPATHTOF(UI\title_%1.paa), _requestedMenu]]; + ctrlSetText [TITLE, LLSTRING(TitleMain)]; // Show Main [true] call FUNC(dialogControl_main); @@ -47,8 +50,27 @@ if (_requestedMenu == "main") exitWith { // Hide Main [false] call FUNC(dialogControl_main); +// Kits (prepared on the website) +if (_requestedMenu == "kits") exitWith { + ctrlSetText [TITLE, LLSTRING(TitleKits)]; + [] call FUNC(dialogControl_kits); + ["back"] call FUNC(dialogControl_back); +}; + // Set Title -ctrlSetText [TITLE, format [QPATHTOF(UI\titleCategory_%1.paa), _requestedMenu]]; +private _titles = createHashMapFromArray [ + ["rifle", LLSTRING(Title_rifle)], + ["pistol", LLSTRING(Title_pistol)], + ["launcher", LLSTRING(Title_launcher)], + ["ammo", LLSTRING(Title_ammo)], + ["item", LLSTRING(Title_item)], + ["attachment", LLSTRING(Title_attachment)], + ["backpack", LLSTRING(Title_backpack)], + ["wearable", LLSTRING(Title_wearable)], + ["insignia", LLSTRING(Title_insignia)], + ["stash", LLSTRING(Title_stash)] +]; +ctrlSetText [TITLE, _titles getOrDefault [_requestedMenu, ""]]; // Show List [_requestedMenu] call FUNC(dialogControl_list); diff --git a/addons/armory/functions/fnc_dialogControl_amountSelection.sqf b/addons/armory/functions/fnc_dialogControl_amountSelection.sqf index 884961cb6..cb4c119f7 100644 --- a/addons/armory/functions/fnc_dialogControl_amountSelection.sqf +++ b/addons/armory/functions/fnc_dialogControl_amountSelection.sqf @@ -15,8 +15,7 @@ * Public: No */ -private _quantity = CTRL(NLIST) lnbData [lnbCurSelRow NLIST, 2]; -_quantity = parseNumber _quantity; +private _quantity = parseNumber (CTRL(NLIST) lnbData [lnbCurSelRow NLIST, 2]); TRACE_1("Amount of selected item",_quantity); lbClear DROPDOWNAMOUNT; @@ -30,8 +29,9 @@ for "_x" from 1 to _quantity do { if (GVAR(selectedCategory) == "stash") then { lbSetCurSel [DROPDOWNAMOUNT, _quantity - 1]; } else { - lbSetCurSel [DROPDOWNAMOUNT, 0]; }; -ctrlShow [DROPDOWNAMOUNT, true]; +{ + ctrlShow [_x, _quantity > 0]; +} forEach [AMOUNTFRAME, DROPDOWNAMOUNT]; diff --git a/addons/armory/functions/fnc_dialogControl_back.sqf b/addons/armory/functions/fnc_dialogControl_back.sqf index 69a922aa3..7c2983b81 100644 --- a/addons/armory/functions/fnc_dialogControl_back.sqf +++ b/addons/armory/functions/fnc_dialogControl_back.sqf @@ -19,14 +19,10 @@ params ["_type"]; // Set Back if (_type == "back") then { - ctrlSetText [BACKPIC, QPATHTOF(UI\btnBack.paa)]; - buttonSetAction [BACKBTN, QUOTE(['main'] call FUNC(dialogControl))]; - CTRL(BACKBTN) ctrlSetTooltip localize LSTRING(BtnBackTooltip); + [BACKBTN, LLSTRING(BtnBack), QUOTE(['main'] call FUNC(dialogControl)), LLSTRING(BtnBackTooltip)] call FUNC(setButton); }; // Set Exit (and destroy GVARs) if (_type == "exit") then { - ctrlSetText [BACKPIC, QPATHTOF(UI\btnExit.paa)]; - buttonSetAction [BACKBTN, QUOTE(closeDialog 0)]; - CTRL(BACKBTN) ctrlSetTooltip localize LSTRING(BtnExitTooltip); + [BACKBTN, LLSTRING(BtnExit), QUOTE(closeDialog 0), LLSTRING(BtnExitTooltip)] call FUNC(setButton); }; diff --git a/addons/armory/functions/fnc_dialogControl_dropdown.sqf b/addons/armory/functions/fnc_dialogControl_dropdown.sqf new file mode 100644 index 000000000..21c8ad0cc --- /dev/null +++ b/addons/armory/functions/fnc_dialogControl_dropdown.sqf @@ -0,0 +1,22 @@ +#include "..\script_component.hpp" +/* + * Author: Jonpas + * Dropdown changed: the kit to show (Kits), or the sub-category to list. + * + * Arguments: + * None + * + * Return Value: + * None + * + * Example: + * call tac_armory_fnc_dialogControl_dropdown + * + * Public: No + */ + +if (GVAR(selectedCategory) == "kits") exitWith { + [] call FUNC(dialogControl_kitItems); +}; + +[GVAR(armoryData)] call FUNC(dialogControl_populateList); diff --git a/addons/armory/functions/fnc_dialogControl_kitItems.sqf b/addons/armory/functions/fnc_dialogControl_kitItems.sqf new file mode 100644 index 000000000..6fe81832b --- /dev/null +++ b/addons/armory/functions/fnc_dialogControl_kitItems.sqf @@ -0,0 +1,59 @@ +#include "..\script_component.hpp" +/* + * Author: Jonpas + * Lists the selected kit's items: name and "in locker / in kit" (short ones in red). One can be taken on its own + * (TAKE, FUNC(dialogControl_takestash)). + * + * Arguments: + * 0: Row to select (default: -1, none) + * + * Return Value: + * None + * + * Example: + * call tac_armory_fnc_dialogControl_kitItems + * + * Public: No + */ + +params [["_select", -1]]; + +lnbClear NLIST; +private _kit = GVAR(kits) param [lbCurSel DROPDOWN, []]; +_kit params [["_kitID", -1], "", "", ["_items", []]]; + +{ + _x params ["_className", "_quantity", "_inLocker"]; + + private _configCfg = configName (configHierarchy (_className call CBA_fnc_getItemConfig) param [1, configNull]); + if (_configCfg == "") then { + _configCfg = configName (configHierarchy (_className call CBA_fnc_getObjectConfig) param [1, configNull]); + }; + + private _displayName = _className; + private _picture = ""; + if (_configCfg != "") then { + _displayName = getText (configFile >> _configCfg >> _className >> "displayName"); + _picture = getText (configFile >> _configCfg >> _className >> "picture"); + }; + private _tooltip = _displayName; + if (count _displayName > DISPLAYNAME_LENGTH + 3) then { + _displayName = [[_displayName, 0, DISPLAYNAME_LENGTH] call CBA_fnc_substr] call CBA_fnc_rightTrim; + _displayName = [_displayName, "..."] joinString ""; + }; + + private _row = lnbAddRow [NLIST, ["", _displayName, format ["%1/%2", _inLocker min _quantity, _quantity]]]; + lbSetTooltip [NLIST, _row * 3, _tooltip]; + lnbSetData [NLIST, [_row, 1], _className]; + lnbSetData [NLIST, [_row, 2], str _inLocker]; // how many can be taken (FUNC(dialogControl_amountSelection)) + lnbSetPicture [NLIST, [_row, 0], _picture]; + if (_inLocker < _quantity) then { + lnbSetColor [NLIST, [_row, 2], [1, 0.35, 0.35, 1]]; + }; +} forEach _items; + +if (_select >= 0 && {_select < count _items}) then { + lnbSetCurSelRow [NLIST, _select]; // fires onLBSelChanged (the amount, TAKE) +}; +call FUNC(dialogControl_amountSelection); +call FUNC(dialogControl_takestash); diff --git a/addons/armory/functions/fnc_dialogControl_kits.sqf b/addons/armory/functions/fnc_dialogControl_kits.sqf new file mode 100644 index 000000000..a6f099dc6 --- /dev/null +++ b/addons/armory/functions/fnc_dialogControl_kits.sqf @@ -0,0 +1,69 @@ +#include "..\script_component.hpp" +/* + * Author: Jonpas + * Sets up the Kits view: the player's kits (prepared on the website) in the dropdown, the selected kit's items in the list. + * + * Arguments: + * 0: Kit index to select (default: 0) + * + * Return Value: + * None + * + * Example: + * [] call tac_armory_fnc_dialogControl_kits + * + * Public: No + */ + +params [["_select", 0]]; +GVAR(selectedCategory) = "kits"; +call FUNC(hideMessage); + +{ + ctrlShow [_x, true]; +} forEach [DROPDOWN, NLIST]; +{ + ctrlShow [_x, false]; +} forEach [AMOUNT, AMOUNTFRAME, DROPDOWNAMOUNT, TAKESTASHFRAME, TAKESTASHBTN, STASHALLFRAME, STASHALLBTN]; + +GVAR(kits) = []; +if (GVAR(system) == 1) then { + if !(["tac_apollo"] call ACEFUNC(common,isModLoaded)) exitWith { + ERROR_MSG("Apollo is not loaded! Chronos data cannot be retrieved."); + }; + if (getPlayerUID player == "_SP_PLAYER_") exitWith {}; // single player (the editor) has no Steam ID, so no kits + private _result = ["loadKits", [getPlayerUID player, EGVAR(apollo,liveApi)]] call EFUNC(apollo,callExt); + if (isNil "_result") exitWith { + ERROR("Kits failed to load!"); + GVAR(kits) = nil; + }; + TRACE_1("Kits",_result); + GVAR(kits) = _result; +}; + +lbClear DROPDOWN; +lnbClear NLIST; +if (isNil QGVAR(kits)) exitWith { + GVAR(kits) = []; + ctrlShow [DROPDOWN, false]; + [LLSTRING(MsgOffline), [LLSTRING(MsgOfflineText), LLSTRING(MsgOfflineHelp), LLSTRING(MsgContactStaff)]] call FUNC(showMessage); +}; +if (GVAR(kits) isEqualTo []) exitWith { + ctrlShow [DROPDOWN, false]; + [LLSTRING(MsgNoKits), [LLSTRING(MsgNoKitsText), LLSTRING(MsgNoKitsWhere)]] call FUNC(showMessage); +}; + +{ + _x params ["", "_name", "_ready", "_items"]; + private _missing = 0; + { + _x params ["", "_quantity", "_inLocker"]; + _missing = _missing + ((_quantity - _inLocker) max 0); + } forEach _items; + private _status = [format [LLSTRING(KitMissing), _missing], LLSTRING(KitReady)] select _ready; + lbAdd [DROPDOWN, format ["%1 (%2)", _name, _status]]; + lbSetTooltip [DROPDOWN, _forEachIndex, _name]; +} forEach GVAR(kits); + +lbSetCurSel [DROPDOWN, (_select min (count GVAR(kits) - 1)) max 0]; // will not fire onLBSelChanged +call FUNC(dialogControl_kitItems); diff --git a/addons/armory/functions/fnc_dialogControl_list.sqf b/addons/armory/functions/fnc_dialogControl_list.sqf index bc58aed6a..a54c9bd22 100644 --- a/addons/armory/functions/fnc_dialogControl_list.sqf +++ b/addons/armory/functions/fnc_dialogControl_list.sqf @@ -17,9 +17,15 @@ params ["_selectedCategory"]; GVAR(selectedCategory) = _selectedCategory; // For FUNC(dialogControl_takestash) +call FUNC(hideMessage); + +// Stash All, in the Stash screen with Chronos +[STASHALLBTN, LLSTRING(BtnStashAll), QUOTE(call FUNC(stashAll)), LLSTRING(BtnStashAllTooltip)] call FUNC(setButton); +{ + ctrlShow [_x, _selectedCategory == "stash" && {GVAR(system) == 1}]; +} forEach [STASHALLFRAME, STASHALLBTN]; // Show Dropdown, Amount and List -ctrlSetText [AMOUNT, QPATHTOF(UI\textAmount.paa)]; { ctrlShow [_x, true]; } forEach [DROPDOWN, AMOUNT, NLIST]; @@ -37,6 +43,10 @@ if (_selectedCategory == "stash") then { _armoryData = [_selectedCategory] call FUNC(getDataChronos); if (_armoryData isEqualTo false) exitWith { _exit = true; + lbClear DROPDOWN; + lnbClear NLIST; + ctrlShow [DROPDOWN, false]; + [LLSTRING(MsgOffline), [LLSTRING(MsgOfflineText), LLSTRING(MsgOfflineHelp), LLSTRING(MsgContactStaff)]] call FUNC(showMessage); }; }; }; diff --git a/addons/armory/functions/fnc_dialogControl_main.sqf b/addons/armory/functions/fnc_dialogControl_main.sqf index de942d3c2..e69883850 100644 --- a/addons/armory/functions/fnc_dialogControl_main.sqf +++ b/addons/armory/functions/fnc_dialogControl_main.sqf @@ -17,23 +17,23 @@ params ["_show"]; -// Show/Hide Main +// Show/Hide Main (slots 1-6 are the left column, 7-12 the right, top to bottom; 5 and 11 are an empty row, 5 is Launchers hidden) { ctrlShow [_x, _show]; } forEach [ - MAINPIC1, MAINBTN1, - MAINPIC2, MAINBTN2, - MAINPIC3, MAINBTN3, - MAINPIC4, MAINBTN4, - MAINPIC5, MAINBTN5, - MAINPIC6, MAINBTN6, - MAINPIC7, MAINBTN7, - MAINPIC8, MAINBTN8, - //MAINPIC9, MAINBTN9, - MAINPIC10, MAINBTN10, - //MAINPIC11, MAINBTN11, - MAINPIC12, MAINBTN12, - TAKESTASHPIC, TAKESTASHBTN // Doubles as Camera + MAINFRAME1, MAINBTN1, + MAINFRAME2, MAINBTN2, + MAINFRAME3, MAINBTN3, + MAINFRAME4, MAINBTN4, + //MAINFRAME5, MAINBTN5, + MAINFRAME6, MAINBTN6, + MAINFRAME7, MAINBTN7, + MAINFRAME8, MAINBTN8, + MAINFRAME9, MAINBTN9, + MAINFRAME10, MAINBTN10, + //MAINFRAME11, MAINBTN11, + MAINFRAME12, MAINBTN12, + TAKESTASHFRAME, CAMERAPIC, TAKESTASHBTN // Take/Stash's button doubles as Camera ]; @@ -41,55 +41,19 @@ params ["_show"]; if (!_show) exitWith {}; // Set up Main -ctrlSetText [MAINPIC1, QPATHTOF(UI\btnCategory_rifle.paa)]; -buttonSetAction [MAINBTN1, QUOTE(['rifle'] call FUNC(dialogControl))]; -CTRL(MAINBTN1) ctrlSetTooltip localize LSTRING(BtnRiflesTooltip); - -ctrlSetText [MAINPIC2, QPATHTOF(UI\btnCategory_pistol.paa)]; -buttonSetAction [MAINBTN2, QUOTE(['pistol'] call FUNC(dialogControl))]; -CTRL(MAINBTN2) ctrlSetTooltip localize LSTRING(BtnPistolsTooltip); - -ctrlSetText [MAINPIC3, QPATHTOF(UI\btnCategory_launcher.paa)]; -buttonSetAction [MAINBTN3, QUOTE(['launcher'] call FUNC(dialogControl))]; -CTRL(MAINBTN3) ctrlSetTooltip localize LSTRING(BtnLaunchersTooltip); - -ctrlSetText [MAINPIC4, QPATHTOF(UI\btnCategory_ammo.paa)]; -buttonSetAction [MAINBTN4, QUOTE(['ammo'] call FUNC(dialogControl))]; -CTRL(MAINBTN4) ctrlSetTooltip localize LSTRING(BtnAmmoTooltip); - -ctrlSetText [MAINPIC5, QPATHTOF(UI\btnCategory_item.paa)]; -buttonSetAction [MAINBTN5, QUOTE(['item'] call FUNC(dialogControl))]; -CTRL(MAINBTN5) ctrlSetTooltip localize LSTRING(BtnItemsTooltip); - -ctrlSetText [MAINPIC6, QPATHTOF(UI\btnCategory_attachment.paa)]; -buttonSetAction [MAINBTN6, QUOTE(['attachment'] call FUNC(dialogControl))]; -CTRL(MAINBTN6) ctrlSetTooltip localize LSTRING(BtnAttachmentsTooltip); - -ctrlSetText [MAINPIC7, QPATHTOF(UI\btnCategory_backpack.paa)]; -buttonSetAction [MAINBTN7, QUOTE(['backpack'] call FUNC(dialogControl))]; -CTRL(MAINBTN7) ctrlSetTooltip localize LSTRING(BtnBackpacksTooltip); - -ctrlSetText [MAINPIC8, QPATHTOF(UI\btnCategory_wearable.paa)]; -buttonSetAction [MAINBTN8, QUOTE(['wearable'] call FUNC(dialogControl))]; -CTRL(MAINBTN8) ctrlSetTooltip localize LSTRING(BtnApparelTooltip); - -/*ctrlSetText [MAINPIC9, QPATHTOF(UI\btnCategory_.paa)]; -buttonSetAction [MAINBTN9, QUOTE([''] call FUNC(dialogControl))]; -CTRL(MAINBTN9) ctrlSetTooltip "Access ";*/ - -ctrlSetText [MAINPIC10, QPATHTOF(UI\btnCategory_insignia.paa)]; -buttonSetAction [MAINBTN10, QUOTE(['insignia'] call FUNC(dialogControl))]; -CTRL(MAINBTN10) ctrlSetTooltip localize LSTRING(BtnInsigniasTooltip); - -/*ctrlSetText [MAINPIC11, QPATHTOF(UI\btnCategory_locker.paa)]; -buttonSetAction [MAINBTN11, QUOTE([''] call FUNC(dialogControl))]; -CTRL(MAINBTN11) ctrlSetTooltip "Access ";*/ - -ctrlSetText [MAINPIC12, QPATHTOF(UI\btnStash.paa)]; -buttonSetAction [MAINBTN12, QUOTE(['stash'] call FUNC(dialogControl))]; -CTRL(MAINBTN12) ctrlSetTooltip localize LSTRING(BtnStashTooltip); - -// Camera -ctrlSetText [TAKESTASHPIC, QPATHTOF(UI\btnCamera.paa)]; +[MAINBTN1, LLSTRING(BtnRifles), QUOTE(['rifle'] call FUNC(dialogControl)), LLSTRING(BtnRiflesTooltip)] call FUNC(setButton); +[MAINBTN7, LLSTRING(BtnPistols), QUOTE(['pistol'] call FUNC(dialogControl)), LLSTRING(BtnPistolsTooltip)] call FUNC(setButton); +[MAINBTN2, LLSTRING(BtnApparel), QUOTE(['wearable'] call FUNC(dialogControl)), LLSTRING(BtnApparelTooltip)] call FUNC(setButton); +[MAINBTN8, LLSTRING(BtnBackpacks), QUOTE(['backpack'] call FUNC(dialogControl)), LLSTRING(BtnBackpacksTooltip)] call FUNC(setButton); +[MAINBTN3, LLSTRING(BtnAmmo), QUOTE(['ammo'] call FUNC(dialogControl)), LLSTRING(BtnAmmoTooltip)] call FUNC(setButton); +[MAINBTN9, LLSTRING(BtnAttachments), QUOTE(['attachment'] call FUNC(dialogControl)), LLSTRING(BtnAttachmentsTooltip)] call FUNC(setButton); +[MAINBTN4, LLSTRING(BtnItems), QUOTE(['item'] call FUNC(dialogControl)), LLSTRING(BtnItemsTooltip)] call FUNC(setButton); +[MAINBTN10, LLSTRING(BtnInsignias), QUOTE(['insignia'] call FUNC(dialogControl)), LLSTRING(BtnInsigniasTooltip)] call FUNC(setButton); +[MAINBTN5, LLSTRING(BtnLaunchers), QUOTE(['launcher'] call FUNC(dialogControl)), LLSTRING(BtnLaunchersTooltip)] call FUNC(setButton); +[MAINBTN6, LLSTRING(BtnKits), QUOTE(['kits'] call FUNC(dialogControl)), LLSTRING(BtnKitsTooltip)] call FUNC(setButton); +[MAINBTN12, LLSTRING(BtnStash), QUOTE(['stash'] call FUNC(dialogControl)), LLSTRING(BtnStashTooltip)] call FUNC(setButton); + +// Camera (an icon in Take/Stash's frame, no label) +ctrlSetText [TAKESTASHBTN, ""]; buttonSetAction [TAKESTASHBTN, QUOTE(call FUNC(openCamera))]; -CTRL(TAKESTASHBTN) ctrlSetTooltip localize LSTRING(BtnOpenCameraTooltip); +CTRL(TAKESTASHBTN) ctrlSetTooltip LLSTRING(BtnOpenCameraTooltip); diff --git a/addons/armory/functions/fnc_dialogControl_populateList.sqf b/addons/armory/functions/fnc_dialogControl_populateList.sqf index d60e3f795..4c0dd9b64 100644 --- a/addons/armory/functions/fnc_dialogControl_populateList.sqf +++ b/addons/armory/functions/fnc_dialogControl_populateList.sqf @@ -78,3 +78,23 @@ _armoryData sort true; // Errors when used in combination with forEach // Make global for sub-category selection (Dialog.hpp) GVAR(armoryData) = _armoryData; + +// Nothing to list: said on the pad, unless a message waits for OK +if (GVAR(messageDismissable) isEqualTo true) exitWith {}; +if (_rowNum > 0) exitWith { + call FUNC(hideMessage); + { + ctrlShow [_x, true]; + } forEach [DROPDOWN, NLIST, AMOUNT]; +}; + +if (GVAR(selectedCategory) == "stash") exitWith { + ctrlShow [DROPDOWN, false]; + [LLSTRING(MsgBoxEmpty), [LLSTRING(MsgBoxEmptyText)]] call FUNC(showMessage); +}; +if (_armoryData findIf {(_x select 3) > 0} == -1) exitWith { + ctrlShow [DROPDOWN, false]; + [LLSTRING(MsgNothing), [[LLSTRING(MsgNothingArmory), LLSTRING(MsgNothingLocker)] select (GVAR(system) == 1)]] call FUNC(showMessage); +}; +// Only the selected kind is empty (Compatible): another can be picked +[LLSTRING(MsgNothing), [LLSTRING(MsgNothingKind), LLSTRING(MsgNothingKindHelp)]] call FUNC(showMessage); diff --git a/addons/armory/functions/fnc_dialogControl_takestash.sqf b/addons/armory/functions/fnc_dialogControl_takestash.sqf index 701c418bb..b38a033cc 100644 --- a/addons/armory/functions/fnc_dialogControl_takestash.sqf +++ b/addons/armory/functions/fnc_dialogControl_takestash.sqf @@ -15,25 +15,38 @@ * Public: No */ +// Kits: Take kit (where Stash All is), when the locker has anything of it, and Take the selected item, when the +// locker has it +if (GVAR(selectedCategory) == "kits") exitWith { + private _items = (GVAR(kits) param [lbCurSel DROPDOWN, []]) param [3, []]; + private _takeable = _items findIf {(_x select 2) > 0} != -1; + [STASHALLBTN, LLSTRING(BtnTakeKit), QUOTE(call FUNC(takeKit)), LLSTRING(BtnTakeKitTooltip)] call FUNC(setButton); + { + ctrlShow [_x, _takeable]; + } forEach [STASHALLFRAME, STASHALLBTN]; + + private _itemTakeable = lnbCurSelRow NLIST >= 0 && {lbText [DROPDOWNAMOUNT, lbCurSel CTRL(DROPDOWNAMOUNT)] != ""}; + [TAKESTASHBTN, LLSTRING(BtnTakeItem), QUOTE(['take'] call FUNC(processAction)), LLSTRING(BtnTakeItemTooltip)] call FUNC(setButton); + { + ctrlShow [_x, _itemTakeable]; + } forEach [TAKESTASHFRAME, TAKESTASHBTN]; +}; + // Hide take/stash if quantity of dropdown amount selection is not set if (lbText [DROPDOWNAMOUNT, lbCurSel CTRL(DROPDOWNAMOUNT)] == "") exitWith { { ctrlShow [_x, false]; - } forEach [TAKESTASHPIC, TAKESTASHBTN]; + } forEach [TAKESTASHFRAME, TAKESTASHBTN]; }; if (GVAR(selectedCategory) == "stash") then { // Stash - ctrlSetText [TAKESTASHPIC, QPATHTOF(UI\btnStash.paa)]; - buttonSetAction [TAKESTASHBTN, QUOTE(['stash'] call FUNC(processAction))]; - CTRL(TAKESTASHBTN) ctrlSetTooltip localize LSTRING(BtnStashItemTooltip); + [TAKESTASHBTN, LLSTRING(BtnStashItem), QUOTE(['stash'] call FUNC(processAction)), LLSTRING(BtnStashItemTooltip)] call FUNC(setButton); } else { // Take - ctrlSetText [TAKESTASHPIC, QPATHTOF(UI\btnTake.paa)]; - buttonSetAction [TAKESTASHBTN, QUOTE(['take'] call FUNC(processAction))]; - CTRL(TAKESTASHBTN) ctrlSetTooltip localize LSTRING(BtnTakeItemTooltip); + [TAKESTASHBTN, LLSTRING(BtnTakeItem), QUOTE(['take'] call FUNC(processAction)), LLSTRING(BtnTakeItemTooltip)] call FUNC(setButton); }; { ctrlShow [_x, true]; -} forEach [TAKESTASHPIC, TAKESTASHBTN]; +} forEach [TAKESTASHFRAME, TAKESTASHBTN]; diff --git a/addons/armory/functions/fnc_dismissMessage.sqf b/addons/armory/functions/fnc_dismissMessage.sqf new file mode 100644 index 000000000..b1825cb3c --- /dev/null +++ b/addons/armory/functions/fnc_dismissMessage.sqf @@ -0,0 +1,24 @@ +#include "..\script_component.hpp" +/* + * Author: Jonpas + * OK on a message (FUNC(showMessage)): hides it and loads the screen again, as the locker or box may have changed. + * + * Arguments: + * None + * + * Return Value: + * None + * + * Example: + * call tac_armory_fnc_dismissMessage + * + * Public: No + */ + +call FUNC(hideMessage); + +if (GVAR(selectedCategory) == "kits") then { + [lbCurSel DROPDOWN] call FUNC(dialogControl_kits); +} else { + [GVAR(selectedCategory)] call FUNC(dialogControl_list); +}; diff --git a/addons/armory/functions/fnc_exportLoadout.sqf b/addons/armory/functions/fnc_exportLoadout.sqf index c36005cd2..6a2cff615 100644 --- a/addons/armory/functions/fnc_exportLoadout.sqf +++ b/addons/armory/functions/fnc_exportLoadout.sqf @@ -20,4 +20,15 @@ private _loadout = getUnitLoadout ACE_player; "ace_clipboard" callExtension (format ["%1%2", _loadout, endl]); "ace_clipboard" callExtension "--COMPLETE--"; -[LSTRING(ExportComplete), QPATHTOF(UI\btnExport.paa)] call ACEFUNC(common,displayTextPicture); +// On the pad over the main menu for a moment (no OK), then the main menu again +[false] call FUNC(dialogControl_main); +[LLSTRING(MsgExported), [LLSTRING(MsgExportedText)], false, "main"] call FUNC(showMessage); + +GVAR(exportShown) = CBA_missionTime; +[{ + params ["_shown"]; + // Not if the pad was left, or exported again since + if (isNull findDisplay DISPLAYID || {GVAR(selectedCategory) != "main"} || {GVAR(exportShown) != _shown}) exitWith {}; + call FUNC(hideMessage); + [true] call FUNC(dialogControl_main); +}, [GVAR(exportShown)], 2.5] call CBA_fnc_waitAndExecute; diff --git a/addons/armory/functions/fnc_extractSubCategories.sqf b/addons/armory/functions/fnc_extractSubCategories.sqf index 51e8f9345..fe19306d3 100644 --- a/addons/armory/functions/fnc_extractSubCategories.sqf +++ b/addons/armory/functions/fnc_extractSubCategories.sqf @@ -20,7 +20,7 @@ params ["_armoryData", "_compatible"]; private _subCategories = [ ["All", ""] ]; if (_compatible) then { - _subCategories pushBack ["Compatible", localize LSTRING(ShowOnlyCompatible)]; + _subCategories pushBack ["Compatible", LLSTRING(ShowOnlyCompatible)]; }; private _dataSubCategories = []; diff --git a/addons/armory/functions/fnc_getDataChronos.sqf b/addons/armory/functions/fnc_getDataChronos.sqf index fcd2f0daa..4eb20dd35 100644 --- a/addons/armory/functions/fnc_getDataChronos.sqf +++ b/addons/armory/functions/fnc_getDataChronos.sqf @@ -1,7 +1,7 @@ #include "..\script_component.hpp" /* * Author: DaC, Jonpas - * Gets data from Apollo Client / Athena (Chronos). + * Gets data from Apollo Client (Chronos). * * Arguments: * 0: Category @@ -23,13 +23,17 @@ if !(["tac_apollo"] call ACEFUNC(common,isModLoaded)) exitWith { false }; -private _result = ["loadArmory", [_selectedCategory, getPlayerUID player, EGVAR(apollo,isDebug)]] call EFUNC(apollo,callExt); +// Single player (the editor) has no Steam ID, so an empty locker +if (getPlayerUID player == "_SP_PLAYER_") exitWith { + [] +}; + +private _result = ["loadArmory", [_selectedCategory, getPlayerUID player, EGVAR(apollo,liveApi)]] call EFUNC(apollo,callExt); if (!isNil "_result") then { - TRACE_2("Athena Armory Data",_selectedCategory,_result); + TRACE_2("Chronos Armory Data",_selectedCategory,_result); _result } else { ERROR("Armory data failed to load!"); - [LSTRING(ChronosError), 2.5] call ACEFUNC(common,displayTextStructured); - false + false // shown on the pad (FUNC(dialogControl_list)) }; diff --git a/addons/armory/functions/fnc_getStashVariant.sqf b/addons/armory/functions/fnc_getStashVariant.sqf new file mode 100644 index 000000000..46d111911 --- /dev/null +++ b/addons/armory/functions/fnc_getStashVariant.sqf @@ -0,0 +1,33 @@ +#include "..\script_component.hpp" +/* + * Author: Jonpas + * Gets what stashing an item from the box puts into the locker: the base variant of a scripted + * optic, accessory or disposable launcher (CBA), and whether a weapon's magazines stay in the box + * (not for a disposable launcher's). + * + * Arguments: + * 0: Item Class Name in the box + * + * Return Value: + * [Item Class Name for the locker , Keep Magazines ] + * + * Example: + * ["launch_NLAW_F"] call tac_armory_fnc_getStashVariant + * + * Public: No + */ + +params ["_itemBox"]; + +private _item = _itemBox; +private _keepMagazines = true; +if (getNumber (configFile >> "CfgWeapons" >> _itemBox >> "scope") != 2) then { + _item = [_itemBox] call FUNC(getBaseVariant); + + // Clear disposable launcher magazine (passed to CBA_fnc_removeWeaponCargo) + if (isArray (configFile >> "CBA_DisposableLaunchers" >> _itemBox) || {isArray (configFile >> "CBA_DisposableLaunchers" >> _item)}) then { + _keepMagazines = false; + }; +}; + +[_item, _keepMagazines] diff --git a/addons/armory/functions/fnc_hideMessage.sqf b/addons/armory/functions/fnc_hideMessage.sqf new file mode 100644 index 000000000..e6719bad7 --- /dev/null +++ b/addons/armory/functions/fnc_hideMessage.sqf @@ -0,0 +1,21 @@ +#include "..\script_component.hpp" +/* + * Author: Jonpas + * Hides the message on the pad (FUNC(showMessage)), leaving what was under it hidden. + * + * Arguments: + * None + * + * Return Value: + * None + * + * Example: + * call tac_armory_fnc_hideMessage + * + * Public: No + */ + +{ + ctrlShow [_x, false]; +} forEach [MESSAGEFRAME, MESSAGETEXT, MESSAGEOKFRAME, MESSAGEOKBTN]; +GVAR(messageDismissable) = false; diff --git a/addons/armory/functions/fnc_init.sqf b/addons/armory/functions/fnc_init.sqf index baad4cd7c..5ec4cf86d 100644 --- a/addons/armory/functions/fnc_init.sqf +++ b/addons/armory/functions/fnc_init.sqf @@ -23,7 +23,7 @@ if !([_object] call FUNC(canAddArmory)) exitWith {}; // Add action private _armoryAction = [ QGVAR(OpenAction), - localize LSTRING(Open), + LLSTRING(Open), "", {[_this select 2] call FUNC(openArmory)}, {[_this select 2] call FUNC(canOpenArmory)}, @@ -34,3 +34,9 @@ private _armoryAction = [ [_object, 0, ["ACE_MainActions"], _armoryAction] call ACEFUNC(interact_menu,addActionToObject); _object setVariable [QGVAR(enabled), true]; + +// Known as an Armory (bodybags within reach of one can be returned to their owner: tac_bodybag_fnc_isAtBase) +if (isNil QGVAR(objects)) then { + GVAR(objects) = []; +}; +GVAR(objects) pushBackUnique _object; diff --git a/addons/armory/functions/fnc_openArmory.sqf b/addons/armory/functions/fnc_openArmory.sqf index befe2532b..95e63a975 100644 --- a/addons/armory/functions/fnc_openArmory.sqf +++ b/addons/armory/functions/fnc_openArmory.sqf @@ -23,6 +23,8 @@ _object setVariable [QGVAR(inUse), true, true]; // Set variable for later reference ACE_player setVariable [QGVAR(object), _object, true]; +GVAR(messageDismissable) = false; + // Create display and load main menu createDialog QGVAR(Display); ["main"] call FUNC(dialogControl); diff --git a/addons/armory/functions/fnc_openCamera.sqf b/addons/armory/functions/fnc_openCamera.sqf index 269af40fc..d969cdc44 100644 --- a/addons/armory/functions/fnc_openCamera.sqf +++ b/addons/armory/functions/fnc_openCamera.sqf @@ -25,7 +25,7 @@ for "_x" from STARTPROJECTID to ENDPROJECTID do { // Show camera controls { ctrlShow [_x, true]; -} forEach [CAMERAAREA, CAMERAHINT, CAMERAEXIT]; +} forEach [CAMERAAREA, CAMERAFRAME, CAMERAHINT, CAMERAEXIT]; // Prepare ACEGVAR(arsenal,center) = ACE_player; diff --git a/addons/armory/functions/fnc_processAction.sqf b/addons/armory/functions/fnc_processAction.sqf index 53f8821be..cbcc0aa03 100644 --- a/addons/armory/functions/fnc_processAction.sqf +++ b/addons/armory/functions/fnc_processAction.sqf @@ -41,7 +41,7 @@ if (isNull _object) exitWith { // Prevent taking if container is full if (_type == "take" && {!(_object canAdd _selectedItem)}) exitWith { - [LSTRING(ContainerFull), 2] call ACEFUNC(common,displayTextStructured); + [LLSTRING(MsgBoxFull), [LLSTRING(MsgBoxFullText)], true] call FUNC(showMessage); }; // Switch scripted optics and accessories (CBA) to base variants @@ -49,15 +49,10 @@ if (_type == "take" && {!(_object canAdd _selectedItem)}) exitWith { // `_selectedItem` is virtual item in Armory database private _selectedItemBox = _selectedItem; private _keepMagazines = true; -if (_type == "stash" && {getNumber (configFile >> "CfgWeapons" >> _selectedItem >> "scope") != 2}) then { - _selectedItem = [_selectedItem] call FUNC(getBaseVariant); - - // Clear disposable launcher magazine (passed to CBA_fnc_removeWeaponCargo) - private _isDisposableBox = isArray (configFile >> "CBA_DisposableLaunchers" >> _selectedItemBox); - private _isDisposable = isArray (configFile >> "CBA_DisposableLaunchers" >> _selectedItem); - if (_isDisposableBox || {_isDisposable}) then { - _keepMagazines = false; - }; +if (_type == "stash") then { + ([_selectedItemBox] call FUNC(getStashVariant)) params ["_item", "_keep"]; + _selectedItem = _item; + _keepMagazines = _keep; }; TRACE_3("Switch",_selectedItem,_selectedItemBox,_keepMagazines); @@ -127,6 +122,14 @@ if (GVAR(system) == 1) then { TRACE_7("Locker action",player,_typeChronos,_object,_selectedAmount,_selectedItem,_selectedItemBox,_keepMagazines); [QEGVAR(apollo,lockerAction), [player, _typeChronos, _object, _selectedItem, _selectedItemBox, _selectedAmount, _keepMagazines]] call CBA_fnc_serverEvent; + // Kits: subtract from the kit's item in the locker, as below + if (GVAR(selectedCategory) == "kits") exitWith { + private _row = lnbCurSelRow NLIST; + private _item = ((GVAR(kits) select lbCurSel DROPDOWN) select 3) select _row; + _item set [2, ((_item select 2) - parseNumber _selectedAmount) max 0]; + [_row] call FUNC(dialogControl_kitItems); + }; + // Update list (subtract only, due to usage of CBA functions a callback event is used for full refresh when done) private _newArmoryData = [GVAR(armoryData), _selectedItemBox, _selectedAmount] call FUNC(subtractData); [_newArmoryData] call FUNC(updateData); diff --git a/addons/armory/functions/fnc_setButton.sqf b/addons/armory/functions/fnc_setButton.sqf new file mode 100644 index 000000000..a9d5d140a --- /dev/null +++ b/addons/armory/functions/fnc_setButton.sqf @@ -0,0 +1,26 @@ +#include "..\script_component.hpp" +/* + * Author: Jonpas + * Sets up a text button: its label (in the pad's LCD font, see Dialog.hpp), what it does and its tooltip. + * Its frame is drawn by the game (GVAR(RscFrame)), shown and hidden with the button. + * + * Arguments: + * 0: Button control ID + * 1: Label + * 2: Action + * 3: Tooltip + * + * Return Value: + * None + * + * Example: + * [MAINBTN1, LLSTRING(BtnRifles), QUOTE(['rifle'] call FUNC(dialogControl)), LLSTRING(BtnRiflesTooltip)] call tac_armory_fnc_setButton + * + * Public: No + */ + +params ["_button", "_label", "_action", "_tooltip"]; + +ctrlSetText [_button, _label]; +buttonSetAction [_button, _action]; +CTRL(_button) ctrlSetTooltip _tooltip; diff --git a/addons/armory/functions/fnc_showMessage.sqf b/addons/armory/functions/fnc_showMessage.sqf new file mode 100644 index 000000000..2ba993dd1 --- /dev/null +++ b/addons/armory/functions/fnc_showMessage.sqf @@ -0,0 +1,63 @@ +#include "..\script_component.hpp" +/* + * Author: Jonpas + * Shows a message on the pad, in a panel over the list (the list, amount and Take/Stash are hidden): a title and lines + * under it. One that waits for OK (FUNC(dismissMessage)) stays until then; the others go when the list has something + * to show again (FUNC(dialogControl_populateList)) or the screen changes. + * With the pad closed, or on another screen than the one it is for, it is shown as a hint instead. + * + * Arguments: + * 0: Title + * 1: Lines (default: []) + * 2: Waits for OK (default: false) + * 3: Screen it is for (category, "kits", or "" for the one shown) (default: "") + * + * Return Value: + * None + * + * Example: + * [LLSTRING(MsgBoxFull), [LLSTRING(MsgBoxFullText)], true] call tac_armory_fnc_showMessage + * + * Public: No + */ + +params ["_title", ["_lines", []], ["_dismissable", false], ["_screen", ""]]; + +// A long list (items) ends with how many more there are +if (count _lines > 8) then { + _lines = (_lines select [0, 7]) + [format [LLSTRING(MsgMore), count _lines - 7]]; +}; + +if (isNull findDisplay DISPLAYID || {_screen != "" && {GVAR(selectedCategory) != _screen}}) exitWith { + [([_title] + _lines) joinString "
", 4] call ACEFUNC(common,displayTextStructured); +}; + +// The pad's LCD text is upper case; item names are text, not markup +private _escape = {((toUpper _this regexReplace ["&", "&"]) regexReplace ["<", "<"]) regexReplace [">", ">"]}; +private _text = format ["%1", _title call _escape]; +if (_lines isNotEqualTo []) then { + _text = _text + "

" + ((_lines apply {_x call _escape}) joinString "
"); +}; + +{ + ctrlShow [_x, false]; +} forEach [NLIST, AMOUNT, AMOUNTFRAME, DROPDOWNAMOUNT, TAKESTASHFRAME, TAKESTASHBTN]; +{ + ctrlShow [_x, true]; +} forEach [MESSAGEFRAME, MESSAGETEXT]; +{ + ctrlShow [_x, _dismissable]; +} forEach [MESSAGEOKFRAME, MESSAGEOKBTN]; +GVAR(messageDismissable) = _dismissable; + +// The text in the middle of the panel (above OK, when it has it) +(ctrlPosition CTRL(MESSAGEFRAME)) params ["", "_top", "", "_height"]; +if (_dismissable) then { + _height = ((ctrlPosition CTRL(MESSAGEOKFRAME)) select 1) - _top; +}; +private _ctrlText = CTRL(MESSAGETEXT); +_ctrlText ctrlSetStructuredText parseText _text; +private _textHeight = (ctrlTextHeight _ctrlText) min _height; +_ctrlText ctrlSetPositionY (_top + (_height - _textHeight) / 2); +_ctrlText ctrlSetPositionH _textHeight; +_ctrlText ctrlCommit 0; diff --git a/addons/armory/functions/fnc_stashAll.sqf b/addons/armory/functions/fnc_stashAll.sqf new file mode 100644 index 000000000..e2b11cb20 --- /dev/null +++ b/addons/armory/functions/fnc_stashAll.sqf @@ -0,0 +1,31 @@ +#include "..\script_component.hpp" +/* + * Author: Jonpas + * Stashes everything in the box into the locker (Chronos): one server event, the server stashes + * each item as a single stash does (EFUNC(apollo,lockerStashAll)). The list refreshes when it's + * done (lockerActionDone), with a message on the pad of what the locker didn't take (lockerStashAllDone). + * + * Arguments: + * None + * + * Return Value: + * None + * + * Example: + * call tac_armory_fnc_stashAll + * + * Public: No + */ + +private _object = ACE_player getVariable [QGVAR(object), objNull]; +if (isNull _object) exitWith { + ERROR("Object is nil"); +}; + +TRACE_1("Stash all",_object); +[QEGVAR(apollo,lockerStashAll), [player, _object]] call CBA_fnc_serverEvent; +ACE_player setVariable [QGVAR(lastStashTime), CBA_missionTime]; + +{ + ctrlShow [_x, false]; +} forEach [TAKESTASHFRAME, TAKESTASHBTN, STASHALLFRAME, STASHALLBTN]; // until the list is refreshed diff --git a/addons/armory/functions/fnc_takeKit.sqf b/addons/armory/functions/fnc_takeKit.sqf new file mode 100644 index 000000000..7b2e5384b --- /dev/null +++ b/addons/armory/functions/fnc_takeKit.sqf @@ -0,0 +1,48 @@ +#include "..\script_component.hpp" +/* + * Author: Jonpas + * Takes the selected kit from the locker into the box (Apollo / Chronos): of each item as many as the locker has. + * + * Arguments: + * None + * + * Return Value: + * None + * + * Example: + * call tac_armory_fnc_takeKit + * + * Public: No + */ + +private _kit = GVAR(kits) param [lbCurSel DROPDOWN, []]; +_kit params [["_kitID", -1], ["_name", ""], "", ["_items", []]]; +private _object = ACE_player getVariable [QGVAR(object), objNull]; + +if (_kitID isEqualTo -1 || {_items isEqualTo []}) exitWith {}; +if (isNull _object) exitWith { + ERROR("Object is nil"); +}; + +// What the locker lacks (taken anyway: whatever it has) +private _missing = []; +{ + _x params ["_className", "_quantity", "_inLocker"]; + if (_inLocker < _quantity) then { + private _displayName = getText ((_className call CBA_fnc_getItemConfig) >> "displayName"); + if (_displayName == "") then { _displayName = getText ((_className call CBA_fnc_getObjectConfig) >> "displayName"); }; + if (_displayName == "") then { _displayName = _className; }; + _missing pushBack format ["%1x %2", _quantity - _inLocker, _displayName]; + }; +} forEach _items; + +TRACE_3("Take kit",_kitID,_name,_missing); +[QEGVAR(apollo,lockerTakeKit), [player, _object, str _kitID]] call CBA_fnc_serverEvent; + +{ + ctrlShow [_x, false]; +} forEach [STASHALLFRAME, STASHALLBTN, TAKESTASHFRAME, TAKESTASHBTN]; // until the kits are refreshed (lockerKitTaken) + +if (_missing isNotEqualTo []) then { + [LLSTRING(MsgKitIncomplete), [format [LLSTRING(MsgKitIncompleteText), _name]] + _missing, true, "kits"] call FUNC(showMessage); +}; diff --git a/addons/armory/functions/fnc_updateData.sqf b/addons/armory/functions/fnc_updateData.sqf index bc336263c..281d8b0e5 100644 --- a/addons/armory/functions/fnc_updateData.sqf +++ b/addons/armory/functions/fnc_updateData.sqf @@ -19,6 +19,9 @@ params ["_newArmoryData"]; TRACE_1("Armory data update",_newArmoryData); +// A message waits for OK, which loads the screen again (FUNC(dismissMessage)) +if (GVAR(messageDismissable) isEqualTo true) exitWith {}; + [_newArmoryData] call FUNC(dialogControl_populateList); call FUNC(dialogControl_amountSelection); call FUNC(dialogControl_takestash); diff --git a/addons/armory/script_component.hpp b/addons/armory/script_component.hpp index 3bfff1463..24ca0ab31 100644 --- a/addons/armory/script_component.hpp +++ b/addons/armory/script_component.hpp @@ -36,56 +36,71 @@ #define AMOUNT 3330003 #define NLIST 3330004 #define DROPDOWNAMOUNT 3330005 +#define AMOUNTFRAME 3330020 #define BACKGROUND 3330009 +// Message (over the list) +#define MESSAGEFRAME 3330006 +#define MESSAGETEXT 3330007 +#define MESSAGEOKFRAME 3330018 +#define MESSAGEOKBTN 3330019 + // MAIN // Row 1 -#define MAINPIC1 3330050 +#define MAINFRAME1 3330050 #define MAINBTN1 3330051 -#define MAINPIC2 3330052 +#define MAINFRAME2 3330052 #define MAINBTN2 3330053 -#define MAINPIC3 3330054 +#define MAINFRAME3 3330054 #define MAINBTN3 3330055 -#define MAINPIC4 3330056 +#define MAINFRAME4 3330056 #define MAINBTN4 3330057 -#define MAINPIC5 3330058 +#define MAINFRAME5 3330058 #define MAINBTN5 3330059 -#define MAINPIC6 3330060 +#define MAINFRAME6 3330060 #define MAINBTN6 3330061 -#define MAINPIC7 3330062 +#define MAINFRAME7 3330062 #define MAINBTN7 3330063 // Row 2 -#define MAINPIC8 3330064 +#define MAINFRAME8 3330064 #define MAINBTN8 3330065 -#define MAINPIC9 3330066 +#define MAINFRAME9 3330066 #define MAINBTN9 3330067 -#define MAINPIC10 3330068 +#define MAINFRAME10 3330068 #define MAINBTN10 3330069 -#define MAINPIC11 3330070 +#define MAINFRAME11 3330070 #define MAINBTN11 3330071 -#define MAINPIC12 3330072 +#define MAINFRAME12 3330072 #define MAINBTN12 3330073 // Exit/Back -#define BACKPIC 3330010 +#define BACKFRAME 3330010 #define BACKBTN 3330011 // Take/Stash -#define TAKESTASHPIC 3330012 +#define TAKESTASHFRAME 3330012 #define TAKESTASHBTN 3330013 // Export #define EXPORTPIC 3330014 #define EXPORTBTN 3330015 +// Stash All (Chronos, Stash screen) +#define STASHALLFRAME 3330016 +#define STASHALLBTN 3330017 + // Camera #define CAMERAAREA 3330090 #define CAMERAHINT 3330091 #define CAMERAEXIT 3330092 +#define CAMERAFRAME 3330093 +#define CAMERAPIC 3330094 // in the main menu // MACROS #define CTRL(var) ((findDisplay DISPLAYID) displayCtrl var) +// A frame control's style (GVAR(RscFrame), Dialog.hpp) +#define ST_FRAME 64 // CONSTANTS diff --git a/addons/armory/stringtable.xml b/addons/armory/stringtable.xml index 77b88f391..d9cd6aa92 100644 --- a/addons/armory/stringtable.xml +++ b/addons/armory/stringtable.xml @@ -1,26 +1,44 @@ + + AMOUNT + + + AMMO + Access Ammo Accéder aux munitions Auf Munition zugreifen + + WEARABLES + Access Apparel Accéder aux vêtements Auf Bekleidung zugreifen + + ATTACHMENTS + Access Attachments Accéder aux accessoires Auf Waffenaufsätze zugreifen + + BACK + Back to Main Menu Retour au menu principal Zurück zum Hauptmenü + + BACKPACKS + Access Backpacks Accéder aux sacs à dos @@ -29,6 +47,9 @@ Close Camera + + EXIT + Exit Armory Quitter l'armurerie @@ -37,34 +58,70 @@ Export loadout to clipboard + + INSIGNIAS + Access Insignias Accéder aux insignes Auf Abzeichen zugreifen + + ITEMS + Access Items Accéder aux objets Auf Gegenstände zugreifen + + KITS + + + Kits (prepared on the website) + + + LAUNCHERS + Access Launchers Accéder aux lanceurs Auf Werfer zugreifen + + OK + Open Camera + + PISTOLS + Access Pistols Accéder aux pistolets Auf Pistolen zugreifen + + RIFLES + Access Rifles Accéder aux fusils Auf Gewehre zugreifen + + STASH + + + STASH ALL + + + Stash everything in the container + + + STASH + Stash selected item Ranger les objets sélectionnés @@ -75,20 +132,19 @@ Ranger le contenu du conteneur Containerinhalt wegpacken + + TAKE + Take selected item Prendre l'objet sélectionné Ausgewählten Gegenstand nehmen - - Athena server is down!<br/>(Contact server administrator) - Le serveur Athena est indisponible !<br/>(Contactez l'administrateur du serveur) - Athena Server ist offline!<br/>(Kontaktiere den Server Administrator) + + TAKE KIT - - Container is full! Make space for retrieval. - Le conteneur est plein ! Faites de la place pour la récupération. - Der Container ist voll! Schaffe Platz zum herausholen. + + Take kit (everything your locker has of it) Enable Armroy Locker on this object. @@ -100,14 +156,104 @@ Armurerie Waffenkammer - - Loadout exported to clipboard! + + %1 missing + + + Ready [TAC] Armory Locker [TAC] Casier d'armurerie [TAC] Waffenkammer-Spind + + Enable Automatic Locker Clearing + + + If enabled lockers will be automatically cleared by the server to prevent ghost items appearing + + + BOX EMPTY + + + PUT ITEMS IN THE BOX TO STASH THEM + + + BOX FULL + + + MAKE SPACE IN THE BOX TO TAKE MORE + + + OR CONTACT STAFF + + + LOADOUT EXPORTED + + + COPIED TO THE CLIPBOARD + + + KIT NOT TAKEN + + + YOUR LOCKER COULD NOT HAND IT OVER + + + KIT INCOMPLETE + + + TAKING %1 WITHOUT: + + + AND %1 MORE + + + NO KITS + + + PREPARE KITS ON THE WEBSITE + + + (LOGISTICS, KITS) + + + NOT ALL STASHED + + + THEY ARE STILL IN THE BOX + + + YOUR LOCKER DID NOT TAKE: + + + NOTHING HERE + + + THIS ARMORY HAS NONE OF THESE + + + NONE OF THIS KIND + + + PICK ANOTHER KIND ABOVE + + + YOUR LOCKER HAS NONE OF THESE + + + NO CONNECTION + + + TRY AGAIN LATER + + + CHRONOS IS UNREACHABLE + + + TRY AGAIN + Open Armory Locker Ouvrir le casier d'armurerie @@ -138,11 +284,41 @@ Aucun (vanilla) Keine (Vanilla) - - Enable Automatic Locker Clearing + + KITS MENU - - If enabled lockers will be automatically cleared by the server to prevent ghost items appearing + + MAIN MENU + + + AMMO MENU + + + ATTACHMENTS MENU + + + BACKPACKS MENU + + + INSIGNIAS MENU + + + ITEMS MENU + + + LAUNCHERS MENU + + + PISTOLS MENU + + + RIFLES MENU + + + STASH MENU + + + WEARABLES MENU diff --git a/addons/bodybag/XEH_PREP.hpp b/addons/bodybag/XEH_PREP.hpp index 451c66a4b..6543a435c 100644 --- a/addons/bodybag/XEH_PREP.hpp +++ b/addons/bodybag/XEH_PREP.hpp @@ -1,4 +1,6 @@ +PREP(canReturnToOwner); PREP(createBodybagBackup); PREP(getBodybagContents); +PREP(isAtBase); PREP(moveInventory); PREP(saveDroppedWeapons); diff --git a/addons/bodybag/XEH_postInit.sqf b/addons/bodybag/XEH_postInit.sqf index d0312deac..5efa30a7e 100644 --- a/addons/bodybag/XEH_postInit.sqf +++ b/addons/bodybag/XEH_postInit.sqf @@ -1,5 +1,26 @@ #include "script_component.hpp" +// "Return to owner" on bodybags at base: sent to the website (Apollo), where the owner claims the items +if (hasInterface) then { + private _action = [ + QGVAR(returnToOwner), + localize LSTRING(ReturnToOwner), + "", + {[QUOTE(tac_apollo_bodybagReturn), [_target, _player]] call CBA_fnc_serverEvent}, + {[_target] call FUNC(canReturnToOwner)}, + {}, + [], + [0, 0, 0], + 3, + [false, false, false, false, false], + { + params ["_target", "", "", "_actionData"]; + _actionData set [1, format [localize LSTRING(ReturnToOwnerName), _target getVariable [QGVAR(ownerName), ""]]]; + } + ] call ACEFUNC(interact_menu,createAction); + ["ACE_bodyBagObject", 0, ["ACE_MainActions"], _action, true] call ACEFUNC(interact_menu,addActionToClass); +}; + // Exit on clients and non-hosts if (!isServer) exitWith {}; diff --git a/addons/bodybag/functions/fnc_canReturnToOwner.sqf b/addons/bodybag/functions/fnc_canReturnToOwner.sqf new file mode 100644 index 000000000..6921c4ed0 --- /dev/null +++ b/addons/bodybag/functions/fnc_canReturnToOwner.sqf @@ -0,0 +1,24 @@ +#include "..\script_component.hpp" +/* + * Author: Jonpas + * Checks if a bodybag can be returned to its owner: it has one, it's at base, isn't being sent, and + * Apollo saves players. + * + * Arguments: + * 0: Bodybag + * + * Return Value: + * Can Return + * + * Example: + * [cursorObject] call tac_bodybag_fnc_canReturnToOwner + * + * Public: No + */ + +params ["_bodybag"]; + +(_bodybag getVariable [QGVAR(ownerUID), ""]) != "" +&& {!(_bodybag getVariable [QGVAR(busy), false])} +&& {missionNamespace getVariable ["tac_apollo_enabledPlayers", false]} +&& {[_bodybag] call FUNC(isAtBase)} diff --git a/addons/bodybag/functions/fnc_isAtBase.sqf b/addons/bodybag/functions/fnc_isAtBase.sqf new file mode 100644 index 000000000..d0f8f589b --- /dev/null +++ b/addons/bodybag/functions/fnc_isAtBase.sqf @@ -0,0 +1,22 @@ +#include "..\script_component.hpp" +/* + * Author: Jonpas + * Checks if an object is at base: within the return distance of a Locker (tac_armory_Locker, or an object + * set up as an Armory with tac_armory_fnc_init). + * + * Arguments: + * 0: Object + * + * Return Value: + * At Base + * + * Example: + * [cursorObject] call tac_bodybag_fnc_isAtBase + * + * Public: No + */ + +params ["_object"]; + +(nearestObjects [_object, ["tac_armory_Locker"], GVAR(returnDistance)]) isNotEqualTo [] +|| {(missionNamespace getVariable ["tac_armory_objects", []]) findIf {!isNull _x && {_x distance _object <= GVAR(returnDistance)}} != -1} diff --git a/addons/bodybag/functions/fnc_moveInventory.sqf b/addons/bodybag/functions/fnc_moveInventory.sqf index 18aafdd0e..66ed29315 100644 --- a/addons/bodybag/functions/fnc_moveInventory.sqf +++ b/addons/bodybag/functions/fnc_moveInventory.sqf @@ -1,7 +1,8 @@ #include "..\script_component.hpp" /* * Author: Jonpas - * Puts killed unit's inventory into the body bag. + * Puts killed unit's inventory into the body bag. Copies the owner and the death's key onto the bag and + * records (on the server) what went in, for "Return to owner". * * Arguments: * 0: Killed Unit @@ -42,6 +43,17 @@ _items append (_unit getVariable [QGVAR(droppedItems), []]); _items append (assignedItems _unit); //_weapons pushBack (binocular _unit); // dropped into inventory on death _items pushBack (_unit call CBA_fnc_binocularMagazine); +// Kept out of the inventory by ACE: earplugs in the ears, and the gunbag's weapon (the gunbag goes in empty) +if (_unit getVariable ["ACE_hasEarPlugsIn", false]) then { + _items pushBack "ACE_EarPlugs"; +}; +private _gunbagWeapon = (backpackContainer _unit) getVariable ["ace_gunbag_gunbagWeapon", []]; +if (_gunbagWeapon isNotEqualTo []) then { + _gunbagWeapon params [["_weapon", ""], ["_attachments", []], ["_magazines", []]]; + _weapons pushBack _weapon; + _items append _attachments; + _items append (_magazines apply {_x param [0, ""]}); +}; // Clear empty names and destroy items with a random chance _items = _items select {_x != "" && {random 100 > GVAR(destroyChance)} }; @@ -72,6 +84,23 @@ if (_backpack != "" && {random 100 > GVAR(destroyChance)}) then { _bodybag addBackpackCargoGlobal [_backpackNonPreset, 1]; }; +// For "Return to owner": whose bag it is, and what went in (what's stuffed in later isn't returned) +private _ownerUID = _unit getVariable [QGVAR(ownerUID), ""]; +if (_ownerUID != "") then { + private _record = createHashMap; + { + _x params ["_classes", "_amounts"]; + { + private _class = toLowerANSI _x; + _record set [_class, (_record getOrDefault [_class, 0]) + (_amounts select _forEachIndex)]; + } forEach _classes; + } forEach [getItemCargo _bodybag, getWeaponCargo _bodybag, getMagazineCargo _bodybag, getBackpackCargo _bodybag]; + _bodybag setVariable [QGVAR(contents), _record]; // server only + _bodybag setVariable [QGVAR(ownerUID), _ownerUID, true]; + _bodybag setVariable [QGVAR(ownerName), _unit getVariable [QGVAR(ownerName), ""], true]; + _bodybag setVariable [QGVAR(deathKey), _unit getVariable ["tac_apollo_deathKey", ""], true]; +}; + // Remove possible left-over ground weapon holder private _nearHolders = nearestObjects [_bodybag, ["WeaponHolderSimulated"], 3]; TRACE_1("Near Holders",_nearHolders); diff --git a/addons/bodybag/functions/fnc_saveDroppedWeapons.sqf b/addons/bodybag/functions/fnc_saveDroppedWeapons.sqf index ee2d9d6b1..497d9bba5 100644 --- a/addons/bodybag/functions/fnc_saveDroppedWeapons.sqf +++ b/addons/bodybag/functions/fnc_saveDroppedWeapons.sqf @@ -2,6 +2,7 @@ /* * Author: Jonpas * Saves dropped weapons to a variable on the unit. Workaround for restoring dropped weapons which get deleted with deleteVehicle. + * Also remembers a player's UID and name on the body, for the bodybag's "Return to owner". * * Arguments: * 0: Killed Unit @@ -38,3 +39,9 @@ _unit setVariable [QGVAR(droppedWeapons), _droppedWeapons, true]; _unit setVariable [QGVAR(droppedItems), _droppedItems, true]; TRACE_2("Dropped Weapons",_droppedWeapons,_droppedItems); + +// The owner, for "Return to owner" (the UID isn't valid on the body after respawn) +if (isPlayer _unit && {local _unit}) then { + _unit setVariable [QGVAR(ownerUID), getPlayerUID _unit, true]; + _unit setVariable [QGVAR(ownerName), name _unit, true]; +}; diff --git a/addons/bodybag/initSettings.inc.sqf b/addons/bodybag/initSettings.inc.sqf index 5d75153ef..cec4254e4 100644 --- a/addons/bodybag/initSettings.inc.sqf +++ b/addons/bodybag/initSettings.inc.sqf @@ -6,3 +6,12 @@ [0, 100, DESTROY_CHANCE_DEFAULT, 0], true ] call CBA_fnc_addSetting; + +[ + QGVAR(returnDistance), + "SLIDER", + [LSTRING(ReturnDistance), LSTRING(ReturnDistanceDesc)], + format ["TAC %1", localize "str_a3_rscdisplaywelcome_expa_parc_list6_title"], + [5, 200, 30, 0], + true +] call CBA_fnc_addSetting; diff --git a/addons/bodybag/stringtable.xml b/addons/bodybag/stringtable.xml index 95f4b4daa..c902bd667 100644 --- a/addons/bodybag/stringtable.xml +++ b/addons/bodybag/stringtable.xml @@ -19,5 +19,17 @@ Place Body in orange bodybag + + Return Distance + + + How close to a Locker a bodybag must be to be returned to its owner (meters). + + + Return to owner + + + Return to owner (%1) + diff --git a/addons/cba_settings/addon.toml b/addons/cba_settings/addon.toml new file mode 100644 index 000000000..90906baa7 --- /dev/null +++ b/addons/cba_settings/addon.toml @@ -0,0 +1,3 @@ +# CBA loads the static userconfig from \cba_settings_userconfig\cba_settings.sqf, so this addon +# keeps CBA's prefix instead of x\tac\addons\cba_settings. +ignore_pboprefix = true diff --git a/addons/main/displayEden.hpp b/addons/main/displayEden.hpp index 32a066775..c00292388 100644 --- a/addons/main/displayEden.hpp +++ b/addons/main/displayEden.hpp @@ -1,5 +1,5 @@ class ctrlMenuStrip; -class display3DEN { +class Display3DEN { class Controls { class MenuStrip: ctrlMenuStrip { class Items { diff --git a/addons/main/script_version.hpp b/addons/main/script_version.hpp index 2d4719708..263481ab2 100644 --- a/addons/main/script_version.hpp +++ b/addons/main/script_version.hpp @@ -1,4 +1,4 @@ #define MAJOR 2 #define MINOR 14 #define PATCHLVL 0 -#define BUILD 113 +#define BUILD 114 diff --git a/addons/mission_autotest/displayEden.hpp b/addons/mission_autotest/displayEden.hpp index 6bf28d9e7..44cc93d3f 100644 --- a/addons/mission_autotest/displayEden.hpp +++ b/addons/mission_autotest/displayEden.hpp @@ -1,5 +1,5 @@ class ctrlMenuStrip; -class display3DEN { +class Display3DEN { class Controls { class MenuStrip: ctrlMenuStrip { class Items { diff --git a/addons/mission_autotest/functions/fnc_testGroupSizes.sqf b/addons/mission_autotest/functions/fnc_testGroupSizes.sqf index 168d283cb..e8d60fec9 100644 --- a/addons/mission_autotest/functions/fnc_testGroupSizes.sqf +++ b/addons/mission_autotest/functions/fnc_testGroupSizes.sqf @@ -18,7 +18,8 @@ private _findings = []; { private _side = _x; - private _groupCount = {(side _x) isEqualTo _side} count allGroups; + // Groups, not units: countSide only counts units (HEMTT L-S50 suggests it anyway) + private _groupCount = count (allGroups select {side _x isEqualTo _side}); if (_groupCount > GROUP_SIZE_WARNING) then { _findings pushBack [WARNING_CODE, format [localize LSTRING(GroupLimit), _side, _groupCount]]; diff --git a/addons/shootingrange/functions/fnc_create.sqf b/addons/shootingrange/functions/fnc_create.sqf index acd37876f..b4d67ffbe 100644 --- a/addons/shootingrange/functions/fnc_create.sqf +++ b/addons/shootingrange/functions/fnc_create.sqf @@ -113,21 +113,10 @@ if (_countdownTimes isEqualTo []) then { _countdownTimes = COUNTDOWNTIMES_DEFAULT; }; -if !(_defaultDuration in _durations) then { - _durations pushBack _defaultDuration; -}; - -if !(_defaultTargetAmount in _targetAmounts) then { - _targetAmounts pushBack _defaultTargetAmount; -}; - -if !(_defaultPauseDuration in _pauseDurations) then { - _pauseDurations pushBack _defaultPauseDuration; -}; - -if !(_defaultCountdownTime in _countdownTimes) then { - _countdownTimes pushBack _defaultCountdownTime; -}; +_durations pushBackUnique _defaultDuration; +_targetAmounts pushBackUnique _defaultTargetAmount; +_pauseDurations pushBackUnique _defaultPauseDuration; +_countdownTimes pushBackUnique _defaultCountdownTime; _durations sort true; _targetAmounts sort true; diff --git a/addons/zeus/functions/fnc_moduleAddObjectToChronosServer.sqf b/addons/zeus/functions/fnc_moduleAddObjectToChronosServer.sqf index 2aceaf4dd..6457797e2 100644 --- a/addons/zeus/functions/fnc_moduleAddObjectToChronosServer.sqf +++ b/addons/zeus/functions/fnc_moduleAddObjectToChronosServer.sqf @@ -22,11 +22,7 @@ if (!EGVAR(apollo,vehiclesLoaded)) exitWith { [QGVAR(addObjectToChronosFailed), [], _player] call CBA_fnc_targetEvent; }; -// Get suitable Chronos ID -private _chronosUniqueID = ["generateUniqueID"] call EFUNC(apollo,invokeJavaMethod); - -// Make persistent -_object setVariable [QEGVAR(apollo,vehicleID), _chronosUniqueID, true]; -EGVAR(apollo,vehiclesList) pushBack _object; +// Make persistent (a new Chronos ID) +private _chronosUniqueID = [_object] call EFUNC(apollo,registerVehicle); TRACE_2("Object added to Chronos",_object,_chronosUniqueID); diff --git a/extensions/Cargo.lock b/extensions/Cargo.lock index 5f3bb328d..980d096de 100644 --- a/extensions/Cargo.lock +++ b/extensions/Cargo.lock @@ -1,47 +1,42 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] -name = "addr2line" -version = "0.24.2" +name = "aho-corasick" +version = "1.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dfbe277e56a376000877090da837660b4427aad530e3028d44e0bffe4f89a1c1" +checksum = "c982642fa9e8606056828ee9a8505737230110bb1099153c79efe865c59d12ba" dependencies = [ - "gimli", + "memchr", ] [[package]] -name = "adler2" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627" - -[[package]] -name = "aho-corasick" -version = "1.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" +name = "apollo-client-rs" +version = "1.1.0" dependencies = [ - "memchr", + "arma-rs", + "log", + "reqwest", + "simplelog", ] [[package]] -name = "apollo-client-rs" +name = "apollo-server-rs" version = "1.0.0" dependencies = [ "arma-rs", - "lazy_static", "log", "reqwest", + "serde_json", "simplelog", ] [[package]] name = "arma-rs" -version = "1.11.11" +version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e0342de1990248c43109236de498e358837c95199f8136193b990b40e3e0461" +checksum = "073088d1fe06e078aac2e63d111f13718eac51eef7a4b84b3fe674b5649271fe" dependencies = [ "arma-rs-proc", "crossbeam-channel", @@ -51,18 +46,18 @@ dependencies = [ "seq-macro", "state", "winapi", - "windows 0.58.0", + "windows 0.62.2", ] [[package]] name = "arma-rs-proc" -version = "1.11.1" +version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf67c0d0c7a59275e5ac4f3fce0cbdbcf3ba12e47bc30be6a3327d6a1bc151f8" +checksum = "3734f626a7d15aa789031a581cbeeea35ccbed6c136b7415d7ad6dc6d5caeeed" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 3.0.10", ] [[package]] @@ -71,65 +66,45 @@ version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" -[[package]] -name = "autocfg" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" - -[[package]] -name = "backtrace" -version = "0.3.74" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d82cb332cdfaed17ae235a638438ac4d4839913cc2af585c3c6746e8f8bee1a" -dependencies = [ - "addr2line", - "cfg-if", - "libc", - "miniz_oxide", - "object", - "rustc-demangle", - "windows-targets 0.52.6", -] - [[package]] name = "base64" -version = "0.22.1" +version = "0.23.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" +checksum = "ac07cdecf99051d9a5238b80f35af32cdeba5b336e55d957b318b50137e18da5" [[package]] name = "bitflags" -version = "2.8.0" +version = "2.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f68f53c83ab957f72c32642f3868eec03eb974d1fb82e453128456482613d36" +checksum = "3ded4057c258ba199e2d26386d3af3780957ecaee6c4ef4041c6b4b8b97c0b06" [[package]] name = "bumpalo" -version = "3.17.0" +version = "3.20.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1628fb46dfa0b37568d12e5edd512553eccf6a22a78e8bde00bb4aed84d5bdbf" +checksum = "87a0cf66fd1eb2fb7b822cb78370d82303750809bc6ba855f3f58e517d3238db" [[package]] name = "bytes" -version = "1.11.1" +version = "1.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e748733b7cbc798e1434b6ac524f0c1ff2ab456fe201501e6497c8417a4fc33" +checksum = "fc652a48c352aef3ea3aed32080501cf3ef6ed5da78602a020c991775b0aff04" [[package]] name = "cc" -version = "1.2.11" +version = "1.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4730490333d58093109dc02c23174c3f4d490998c3fed3cc8e82d57afedb9cf" +checksum = "33ef9e3e8154a45c7a95cff4c1299702106ad94062d7bb85fdc5d3a5afd91d45" dependencies = [ + "find-msvc-tools", "shlex", ] [[package]] name = "cfg-if" -version = "1.0.0" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +checksum = "4e7648175b45a9a48536d676f68d918270699102aa8dab5496df06904c914600" [[package]] name = "core-foundation" @@ -141,77 +116,101 @@ dependencies = [ "libc", ] +[[package]] +name = "core-foundation" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2a6cd9ae233e7f62ba4e9353e81a88df7fc8a5987b8d445b4d90c879bd156f6" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "core-foundation-sys" version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" +[[package]] +name = "core_detect" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f8f80099a98041a3d1622845c271458a2d73e688351bf3cb999266764b81d48" + [[package]] name = "crossbeam-channel" -version = "0.5.15" +version = "0.5.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82b8f8f868b36967f9606790d1903570de9ceaf870a7bf9fbbd3016d636a2cb2" +checksum = "98b0cc327b5bc766e7fda9c9260cc0fa81b43a8e240440422dff70788e3f9ef1" dependencies = [ "crossbeam-utils", ] [[package]] name = "crossbeam-utils" -version = "0.8.21" +version = "0.8.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28" +checksum = "a31eee39dddec8330830986fcd7625edb5a24ec90ea038215273bbc3adb08ac6" [[package]] name = "deranged" -version = "0.3.11" +version = "0.5.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b42b6fa04a440b495c8b04d0e71b707c585f83cb9cb28cf8cd0d976c315e31b4" -dependencies = [ - "powerfmt", -] +checksum = "9e9de72ce2ad1f90dc62fa25f0f430ef85eb4b0d8fa0be4f30373bc40a21d28e" [[package]] name = "displaydoc" -version = "0.2.5" +version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" +checksum = "c6232dd377dcc64799954cbd3a9bb882e9cdc1308ccd87b1c098f1fb2eaf82a8" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 3.0.10", ] [[package]] name = "encoding_rs" -version = "0.8.35" +version = "0.8.44" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75030f3c4f45dafd7586dd6780965a8c7e8e285a5ecb86713e63a79c5b2766f3" +checksum = "89253175e704ab869b04f9db224d38630e0211a53841a79181deae0889e169f5" dependencies = [ "cfg-if", + "core_detect", + "multiversion_no_op", + "rustversion", + "scopeguard", + "simdutf8", ] [[package]] name = "equivalent" -version = "1.0.1" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" +checksum = "00d174d5400e5e8fd687ad1049e2f578285fa914201b1af7e8b112a4546bd826" [[package]] name = "errno" -version = "0.3.10" +version = "0.3.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33d852cb9b869c2a9b3df2f71a3074817f01e1844f839a144f5fcef059a4eb5d" +checksum = "e35d6e78f4cebb90e51d543db8fe41528851d6deeef6ef21ebd4bfdc1e784776" dependencies = [ "libc", - "windows-sys 0.59.0", + "windows-sys 0.52.0", ] [[package]] name = "fastrand" -version = "2.3.0" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be" +checksum = "da7c62ceae207dd37ea5b845da6a0696c799f85e97da1ab5b7910be3c1c80223" + +[[package]] +name = "find-msvc-tools" +version = "0.1.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c66915cc5391097de7a2b0b972e8505aa33c0df401fd3a6811dbdb32881ba48" [[package]] name = "fnv" @@ -236,18 +235,18 @@ checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" [[package]] name = "form_urlencoded" -version = "1.2.1" +version = "1.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" +checksum = "cb4cb245038516f5f85277875cdaa4f7d2c9a0fa0468de06ed190163b1581fcf" dependencies = [ "percent-encoding", ] [[package]] name = "futures-channel" -version = "0.3.31" +version = "0.3.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dff15bf788c671c1934e366d07e30c1814a8ef514e1af724a602e8a2fbe1b10" +checksum = "b1f9e3d69d39e4862ffed03ed071a76f9a13ba1d9109d355b0f0aa6b15e393c4" dependencies = [ "futures-core", "futures-sink", @@ -255,33 +254,33 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.31" +version = "0.3.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e" +checksum = "92d699e522242e69e3003b94ecc1f960f3a5e015aa7c5d7486e65ad01dd94f5e" [[package]] name = "futures-io" -version = "0.3.31" +version = "0.3.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e5c1b78ca4aae1ac06c48a526a655760685149f0d465d21f37abfe57ce075c6" +checksum = "53c0fa8157de1303bfffdaa1cc2a673bfffb60102f76b0ef4441659124373fed" [[package]] name = "futures-sink" -version = "0.3.31" +version = "0.3.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e575fab7d1e0dcb8d0c7bcf9a63ee213816ab51902e6d244a95819acacf1d4f7" +checksum = "1944426bf7d03f1d14f708785e4b33efd750b36d48a157b836b3efc15ede8e1d" [[package]] name = "futures-task" -version = "0.3.31" +version = "0.3.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f90f7dce0722e95104fcb095585910c0977252f286e354b5e3bd38902cd99988" +checksum = "cd417de3d1d015fc3bfd2b1ea46dfc7bab72ef86f1cc7cc9c78e728b34a6d1fd" [[package]] name = "futures-util" -version = "0.3.31" +version = "0.3.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fa08315bb612088cc391249efdc3bc77536f16c91f6cf495e6fbe85b20a4a81" +checksum = "0d50a92467f8ba5dd6e3ee5d4bd04d73ab2e4e1c44474a0674821dfce14b79bc" dependencies = [ "futures-core", "futures-io", @@ -289,7 +288,6 @@ dependencies = [ "futures-task", "memchr", "pin-project-lite", - "pin-utils", "slab", ] @@ -308,38 +306,31 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.15" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" +checksum = "ff2abc00be7fca6ebc474524697ae276ad847ad0a6b3faa4bcb027e9a4614ad0" dependencies = [ "cfg-if", "libc", - "wasi 0.11.0+wasi-snapshot-preview1", + "wasi", ] [[package]] name = "getrandom" -version = "0.3.1" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43a49c392881ce6d5c3b8cb70f98717b7c07aabbdff06687b9030dbfbe2725f8" +checksum = "300e883d756b2e4ec94e02791f39b04b522276138852cfc41d9fb7e904106099" dependencies = [ "cfg-if", "libc", - "wasi 0.13.3+wasi-0.2.2", - "windows-targets 0.52.6", + "r-efi", ] -[[package]] -name = "gimli" -version = "0.31.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f" - [[package]] name = "h2" -version = "0.4.7" +version = "0.4.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ccae279728d634d083c00f6099cb58f01cc99c145b84b8be2f6c74618d79922e" +checksum = "7d29020232d6aa3fb1daca64c1127cf662cf97f254ae16c18c05b8ab635fc118" dependencies = [ "atomic-waker", "bytes", @@ -356,26 +347,25 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.15.2" +version = "0.17.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289" +checksum = "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a" [[package]] name = "http" -version = "1.2.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f16ca2af56261c99fba8bac40a10251ce8188205a4c448fbb745a2e4daa76fea" +checksum = "918d3568bebf352712bc2ef3d46a8bcf1a75b373be6539de198e9105cbbf9ce0" dependencies = [ "bytes", - "fnv", "itoa", ] [[package]] name = "http-body" -version = "1.0.1" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1efedce1fb8e6913f23e0c92de8e62cd5b772a67e7b3946df930a62566c93184" +checksum = "ca2a8f2913ee65f60facd6a5905613afaa448497a0230cc41ce022d93290bc2c" dependencies = [ "bytes", "http", @@ -383,12 +373,12 @@ dependencies = [ [[package]] name = "http-body-util" -version = "0.1.2" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "793429d76616a256bcb62c2a2ec2bed781c8307e797e2598c50010f2bee2544f" +checksum = "23169fe34a5fbcdd3f3862e78fb9b6fccd5f02a6dc6f732547005d45631ce71c" dependencies = [ "bytes", - "futures-util", + "futures-core", "http", "http-body", "pin-project-lite", @@ -396,19 +386,20 @@ dependencies = [ [[package]] name = "httparse" -version = "1.10.0" +version = "1.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2d708df4e7140240a16cd6ab0ab65c972d7433ab77819ea693fde9c43811e2a" +checksum = "6dbf3de79e51f3d586ab4cb9d5c3e2c14aa28ed23d180cf89b4df0454a69cc87" [[package]] name = "hyper" -version = "1.6.0" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc2b571658e38e0c01b1fdca3bbbe93c00d3d71693ff2770043f8c29bc7d6f80" +checksum = "2c3e324da4c95177d6291d4c8730197c0d1822f8a9766814a4a44fa5ab797c9c" dependencies = [ + "atomic-waker", "bytes", "futures-channel", - "futures-util", + "futures-core", "h2", "http", "http-body", @@ -422,16 +413,14 @@ dependencies = [ [[package]] name = "hyper-rustls" -version = "0.27.5" +version = "0.27.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d191583f3da1305256f22463b9bb0471acad48a4e534a5218b9963e9c1f59b2" +checksum = "dfa8e654703247911e29c23fbeaa261834bd9bb74efba2f9acddc37bfb127f53" dependencies = [ - "futures-util", "http", "hyper", "hyper-util", "rustls", - "rustls-pki-types", "tokio", "tokio-rustls", "tower-service", @@ -455,40 +444,49 @@ dependencies = [ [[package]] name = "hyper-util" -version = "0.1.10" +version = "0.1.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df2dcfbe0677734ab2f3ffa7fa7bfd4706bfdc1ef393f2ee30184aed67e631b4" +checksum = "ddc03d96684f9226b8a787cdb71488417b53ab5ea8fdb1dac946cb9431cc8bff" dependencies = [ + "base64", "bytes", "futures-channel", "futures-util", "http", "http-body", + "httparse", "hyper", + "ipnet", + "libc", + "percent-encoding", "pin-project-lite", "socket2", + "system-configuration", "tokio", "tower-service", "tracing", + "windows-registry", ] [[package]] name = "icu_collections" -version = "1.5.0" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db2fa452206ebee18c4b5c2274dbf1de17008e874b4dc4f0aea9d01ca79e4526" +checksum = "fe090a42a0d3140fed8c63263ed1fecc02422cb2f4bfe55cd8de2de1b8e105dd" dependencies = [ "displaydoc", + "potential_utf", + "utf8_iter", "yoke", "zerofrom", "zerovec", ] [[package]] -name = "icu_locid" -version = "1.5.0" +name = "icu_locale_core" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13acbb8371917fc971be86fc8057c41a64b521c184808a698c02acc242dbf637" +checksum = "25d29b57c17c6528d0dc4c2141cfa2d08200465acb537a3909c8b9b8a4a984c0" dependencies = [ "displaydoc", "litemap", @@ -497,104 +495,67 @@ dependencies = [ "zerovec", ] -[[package]] -name = "icu_locid_transform" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01d11ac35de8e40fdeda00d9e1e9d92525f3f9d887cdd7aa81d727596788b54e" -dependencies = [ - "displaydoc", - "icu_locid", - "icu_locid_transform_data", - "icu_provider", - "tinystr", - "zerovec", -] - -[[package]] -name = "icu_locid_transform_data" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fdc8ff3388f852bede6b579ad4e978ab004f139284d7b28715f773507b946f6e" - [[package]] name = "icu_normalizer" -version = "1.5.0" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19ce3e0da2ec68599d193c93d088142efd7f9c5d6fc9b803774855747dc6a84f" +checksum = "404a3b8c486f205c87fe7f23ab6894d84a4ad76d6e4671ae1981ba7def87c599" dependencies = [ - "displaydoc", "icu_collections", "icu_normalizer_data", "icu_properties", "icu_provider", "smallvec", - "utf16_iter", - "utf8_iter", - "write16", "zerovec", ] [[package]] name = "icu_normalizer_data" -version = "1.5.0" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8cafbf7aa791e9b22bec55a167906f9e1215fd475cd22adfcf660e03e989516" +checksum = "20f0088bfb7441f7a37fa0c9e20cb1e9cba1cac6b9ce8cd2a6dc44294f8e8cbc" [[package]] name = "icu_properties" -version = "1.5.1" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93d6020766cfc6302c15dbbc9c8778c37e62c14427cb7f6e601d849e092aeef5" +checksum = "2ea83d991c56158f7cf898bf86436c1dfe7c07ee82fe88951f2695c9f37a379f" dependencies = [ "displaydoc", "icu_collections", - "icu_locid_transform", + "icu_locale_core", "icu_properties_data", "icu_provider", - "tinystr", + "zerotrie", "zerovec", ] [[package]] name = "icu_properties_data" -version = "1.5.0" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67a8effbc3dd3e4ba1afa8ad918d5684b8868b3b26500753effea8d2eed19569" +checksum = "b98f29af82d02b163fe50161388350e743bb3107cc8e8c2f7314cb505faddfcf" [[package]] name = "icu_provider" -version = "1.5.0" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ed421c8a8ef78d3e2dbc98a973be2f3770cb42b606e3ab18d6237c4dfde68d9" +checksum = "413099315636c588ee8f011190b329b971a09a8fae9d157e01dcae8379468514" dependencies = [ "displaydoc", - "icu_locid", - "icu_provider_macros", - "stable_deref_trait", - "tinystr", + "icu_locale_core", "writeable", "yoke", "zerofrom", + "zerotrie", "zerovec", ] -[[package]] -name = "icu_provider_macros" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "idna" -version = "1.0.3" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "686f825264d630750a544639377bae737628043f20d38bbc029e8f29ea968a7e" +checksum = "3b0875f23caa03898994f6ddc501886a45c7d3d62d04d2d90788d47be1b1e4de" dependencies = [ "idna_adapter", "smallvec", @@ -603,9 +564,9 @@ dependencies = [ [[package]] name = "idna_adapter" -version = "1.2.0" +version = "1.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "daca1df1c957320b2cf139ac61e7bd64fed304c5040df000a745aa1de3b4ef71" +checksum = "cb68373c0d6620ef8105e855e7745e18b0d00d3bdb07fb532e434244cdb9a714" dependencies = [ "icu_normalizer", "icu_properties", @@ -613,9 +574,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.7.1" +version = "2.14.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c9c992b02b5b4c94ea26e32fe5bccb7aa7d9f390ab5c1221ff895bc7ea8b652" +checksum = "cc4e190f5d26ca7051642629da2c52fc03bde85a03197c99408dcd291734c855" dependencies = [ "equivalent", "hashbrown", @@ -623,37 +584,38 @@ dependencies = [ [[package]] name = "ipnet" -version = "2.11.0" +version = "2.12.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "469fb0b9cefa57e3ef31275ee7cacb78f2fdca44e4765491884a2b119d4eb130" +checksum = "791930b43c0d5973160d90a8f3894509f2b273430f5c5c73b668636d0287c5c0" [[package]] name = "itoa" -version = "1.0.14" +version = "1.0.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d75a2a4b1b190afb6f5425f10f6a8f959d2ea0b9c2b1d79553551850539e4674" +checksum = "3bd1574e617a9a6c1f8f8181bd7e841e1f20e4277607ef28945765188d6284d4" [[package]] name = "js-sys" -version = "0.3.77" +version = "0.3.107" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1cfaf33c695fc6e08064efbc1f72ec937429614f25eef83af942d0e227c3a28f" +checksum = "8dc09d2154098bbf4ef54eab6b117a3c24cbbffe94046b16ee6d6d4510584d3a" dependencies = [ - "once_cell", + "cfg-if", + "futures-util", "wasm-bindgen", ] [[package]] name = "lazy_static" -version = "1.5.0" +version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" +checksum = "20870f649af7073d53e38067b2a84312175d56ea15217e1b15bc83506ec50afb" [[package]] name = "libc" -version = "0.2.169" +version = "0.2.191" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5aba8db14291edd000dfcc4d620c7ebfb122c613afb886ca8803fa4e128a20a" +checksum = "65cd87c9a6d60536580b316ad985726104730a5151c99845f2490428ef91240a" [[package]] name = "link_args" @@ -663,21 +625,21 @@ checksum = "2c7721e472624c9aaad27a5eb6b7c9c6045c7a396f2efb6dabaec1b640d5e89b" [[package]] name = "linux-raw-sys" -version = "0.4.15" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d26c52dbd32dccf2d10cac7725f8eae5296885fb5703b261f7d0a0739ec807ab" +checksum = "32a66949e030da00e8c7d4434b251670a91556f4144941d37452769c25d58a53" [[package]] name = "litemap" -version = "0.7.4" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ee93343901ab17bd981295f2cf0026d4ad018c7c31ba84549a4ddbb47a45104" +checksum = "47d9d19d1d6efa0109d2f65ff4c85cddd50bd572e5a00127ab10987290bcefae" [[package]] name = "log" -version = "0.4.25" +version = "0.4.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04cbf5b083de1c7e0222a7a51dbfdba1cbe1c6ab0b15e29fff3f6c077fd9cd9f" +checksum = "5d15f86d12da44cd8d4ec3c73984537eb7f4cadcb9776a575a0a8a05ca11005c" [[package]] name = "loom" @@ -705,41 +667,38 @@ dependencies = [ [[package]] name = "memchr" -version = "2.7.4" +version = "2.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" +checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98" [[package]] name = "mime" -version = "0.3.17" +version = "0.3.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" +checksum = "d5848f5a9e8117cf94f2f90faac24a87ff81600ff8628c1e3deaab572e76bfa1" [[package]] -name = "miniz_oxide" -version = "0.8.3" +name = "mio" +version = "1.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8402cab7aefae129c6977bb0ff1b8fd9a04eb5b51efc50a70bea51cda0c7924" +checksum = "20521a903f02b0a573cd6840e9d0a5a0cc043d361fe924092cd70f8556cc9c4a" dependencies = [ - "adler2", + "libc", + "wasi", + "windows-sys 0.61.2", ] [[package]] -name = "mio" -version = "1.0.3" +name = "multiversion_no_op" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2886843bf800fba2e3377cff24abf6379b4c4d5c6681eaf9ea5b0d15090450bd" -dependencies = [ - "libc", - "wasi 0.11.0+wasi-snapshot-preview1", - "windows-sys 0.52.0", -] +checksum = "743fb55ba31b18fb1ecef6bdc9aa2743314978ac084044301a7eee33fb99a20d" [[package]] name = "native-tls" -version = "0.2.13" +version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0dab59f8e050d5df8e4dd87d9206fb6f65a483e20ac9fda365ade4fab353196c" +checksum = "465500e14ea162429d264d44189adc38b199b62b1c21eea9f69e4b73cb03bbf2" dependencies = [ "libc", "log", @@ -754,48 +713,39 @@ dependencies = [ [[package]] name = "nu-ansi-term" -version = "0.50.1" +version = "0.50.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4a28e057d01f97e61255210fcff094d74ed0466038633e95017f5beb68e4399" +checksum = "7957b9740744892f114936ab4a57b3f487491bbeafaf8083688b16841a4240e5" dependencies = [ - "windows-sys 0.52.0", + "windows-sys 0.61.2", ] [[package]] name = "num-conv" -version = "0.1.0" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" +checksum = "521739c6d2bac4aa25192232afe6841231376b2b26d4d9fae5ecf8ca5772e441" [[package]] name = "num_threads" -version = "0.1.7" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c7398b9c8b70908f6371f47ed36737907c87c52af34c268fed0bf0ceb92ead9" +checksum = "cabcc654086861f9e1bc5115258de62ef92c79b20f4615a1b0cc57c4e82027d4" dependencies = [ "libc", ] -[[package]] -name = "object" -version = "0.36.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62948e14d923ea95ea2c7c86c71013138b66525b86bdc08d2dcc262bdb497b87" -dependencies = [ - "memchr", -] - [[package]] name = "once_cell" -version = "1.20.2" +version = "1.21.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" +checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50" [[package]] name = "openssl" -version = "0.10.81" +version = "0.10.82" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77823a27f0babb03091cb9ed9ef80af3b39dbc82f97e8fa530374b7dafd87a45" +checksum = "4de8111e94a56adca7ebfe6c365b6d42f99deb69b74b6becacd4204e2f193aa2" dependencies = [ "bitflags", "cfg-if", @@ -813,20 +763,20 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.119", ] [[package]] name = "openssl-probe" -version = "0.1.6" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d05e27ee213611ffe7d6348b942e8f942b37114c00cc03cec254295a4a17852e" +checksum = "7e036b411754132fd6b74e94b74e9a13c5cf606fa93d1885c35860d3060820b1" [[package]] name = "openssl-sys" -version = "0.9.117" +version = "0.9.118" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b47e7e6bb2c38cd930d25a23b40fa52e068c10e85f3e03a7f5ba5aaca5713695" +checksum = "19c413d6ec9ebaf5e1c829d355cb3e9f783778d700f135be0921d52fce3c60ae" dependencies = [ "cc", "libc", @@ -836,57 +786,66 @@ dependencies = [ [[package]] name = "percent-encoding" -version = "2.3.1" +version = "2.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" +checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220" [[package]] name = "pin-project-lite" -version = "0.2.16" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b3cff922bd51709b605d9ead9aa71031d81447142d828eb4a6eba76fe619f9b" +checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd" [[package]] -name = "pin-utils" -version = "0.1.0" +name = "pkg-config" +version = "0.3.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" +checksum = "f6b464fbc74e149a392436b17d523f769e057cb6877f6a5c4618bc6f11800548" [[package]] -name = "pkg-config" -version = "0.3.31" +name = "potential_utf" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "953ec861398dccce10c670dfeaf3ec4911ca479e9c02154b3a215178c5f566f2" +checksum = "d83eb9bc6d8e5cf568e7a1101d60ee05e81ed50ea106026f3d18deeb046d7661" +dependencies = [ + "zerovec", +] [[package]] name = "powerfmt" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" +checksum = "4a6394b9e965e73d0a289ee54f589087e2c676aedf60885baf52c76b771e4958" [[package]] name = "proc-macro2" -version = "1.0.93" +version = "1.0.107" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60946a68e5f9d28b0dc1c21bb8a97ee7d018a8b322fa57838ba31cc878e22d99" +checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.38" +version = "1.0.47" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e4dccaaaf89514f546c693ddc140f729f958c247918a13380cccc6078391acc" +checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001" dependencies = [ "proc-macro2", ] +[[package]] +name = "r-efi" +version = "6.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf" + [[package]] name = "regex-automata" -version = "0.4.9" +version = "0.4.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908" +checksum = "ad8553b9b26413251cbf30e620595c7a41b3887f03da04579c0e6b0d6a06b4b2" dependencies = [ "aho-corasick", "memchr", @@ -895,15 +854,15 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.8.5" +version = "0.8.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" +checksum = "d6f6ff9a378485b298a5286656da665ba74413d36db0979633275d2e708145d4" [[package]] name = "reqwest" -version = "0.12.12" +version = "0.13.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43e734407157c3c2034e0258f5e4473ddb361b1e85f95a66690d67264d7cd1da" +checksum = "16a1cfa75cc186dd73d5818e510e042e40927bccc9c236b061cea97e1eb08029" dependencies = [ "base64", "bytes", @@ -919,69 +878,59 @@ dependencies = [ "hyper-rustls", "hyper-tls", "hyper-util", - "ipnet", "js-sys", "log", "mime", "native-tls", - "once_cell", "percent-encoding", "pin-project-lite", - "rustls-pemfile", + "rustls-pki-types", "serde", "serde_json", - "serde_urlencoded", "sync_wrapper", - "system-configuration", "tokio", "tokio-native-tls", "tower", + "tower-http", "tower-service", "url", "wasm-bindgen", "wasm-bindgen-futures", "web-sys", - "windows-registry", ] [[package]] name = "ring" -version = "0.17.13" +version = "0.17.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70ac5d832aa16abd7d1def883a8545280c20a60f523a370aa3a9617c2b8550ee" +checksum = "a4689e6c2294d81e88dc6261c768b63bc4fcdb852be6d1352498b114f61383b7" dependencies = [ "cc", "cfg-if", - "getrandom 0.2.15", + "getrandom 0.2.17", "libc", "untrusted", "windows-sys 0.52.0", ] -[[package]] -name = "rustc-demangle" -version = "0.1.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" - [[package]] name = "rustix" -version = "0.38.44" +version = "1.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fdb5bc1ae2baa591800df16c9ca78619bf65c0488b41b96ccec5d11220d8c154" +checksum = "e5e76742e5294153d4dde1207dbec5bdd81eef6fabdc0d2118babadabfd858aa" dependencies = [ "bitflags", "errno", "libc", "linux-raw-sys", - "windows-sys 0.59.0", + "windows-sys 0.52.0", ] [[package]] name = "rustls" -version = "0.23.22" +version = "0.23.46" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fb9263ab4eb695e42321db096e3b8fbd715a59b154d5c88d82db2175b681ba7" +checksum = "48e13bd8c0e9365c43cfa5c9e8f9ad49d3c8444926c9aac819e0e4dc503c8fdf" dependencies = [ "once_cell", "rustls-pki-types", @@ -991,25 +940,19 @@ dependencies = [ ] [[package]] -name = "rustls-pemfile" -version = "2.2.0" +name = "rustls-pki-types" +version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dce314e5fee3f39953d46bb63bb8a46d40c2f8fb7cc5a3b6cab2bde9721d6e50" +checksum = "102f35f7de7b06d8c61f1cff6592f5253e0dea431c74867aad5dfd70f44663fb" dependencies = [ - "rustls-pki-types", + "zeroize", ] -[[package]] -name = "rustls-pki-types" -version = "1.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "917ce264624a4b4db1c364dcc35bfca9ded014d0a958cd47ad3e960e988ea51c" - [[package]] name = "rustls-webpki" -version = "0.102.8" +version = "0.103.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64ca1bc8749bd4cf37b5ce386cc146580777b4e8572c7b97baf22c83f444bee9" +checksum = "e3a0760a887c14823fca5a1c970b01d47c328c696c0c64829d1df50e8f853fd5" dependencies = [ "ring", "rustls-pki-types", @@ -1018,23 +961,17 @@ dependencies = [ [[package]] name = "rustversion" -version = "1.0.19" +version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7c45b9784283f1b2e7fb61b42047c2fd678ef0960d4f6f1eba131594cc369d4" - -[[package]] -name = "ryu" -version = "1.0.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ea1a2d0a644769cc99faa24c3ad26b379b786fe7c36fd3c546254801650e6dd" +checksum = "cf54715a573b99ac80df0bc206da022bcd442c974952c7b9720069370852e21f" [[package]] name = "schannel" -version = "0.1.27" +version = "0.1.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f29ebaa345f945cec9fbbc532eb307f0fdad8161f281b6369539c8d84876b3d" +checksum = "9cb23c424d8ee841bb4d813677ca237e2a610067d594fec130f87d6093495ab5" dependencies = [ - "windows-sys 0.59.0", + "windows-sys 0.61.2", ] [[package]] @@ -1043,14 +980,20 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e1cf6437eb19a8f4a6cc0f7dca544973b0b78843adbfeb3683d1a94a0024a294" +[[package]] +name = "scopeguard" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" + [[package]] name = "security-framework" -version = "2.11.1" +version = "3.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "897b2245f0b511c87893af39b033e5ca9cce68824c4d7e7630b5a1d339658d02" +checksum = "b7f4bc775c73d9a02cde8bf7b2ec4c9d12743edf609006c7facc23998404cd1d" dependencies = [ "bitflags", - "core-foundation", + "core-foundation 0.10.1", "core-foundation-sys", "libc", "security-framework-sys", @@ -1058,9 +1001,9 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "2.14.0" +version = "2.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49db231d56a190491cb4aeda9527f1ad45345af50b0851622a7adb8c03b01c32" +checksum = "6ce2691df843ecc5d231c0b14ece2acc3efb62c0a398c7e1d875f3983ce020e3" dependencies = [ "core-foundation-sys", "libc", @@ -1068,52 +1011,51 @@ dependencies = [ [[package]] name = "seq-macro" -version = "0.3.5" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3f0bf26fd526d2a95683cd0f87bf103b8539e2ca1ef48ce002d67aad59aa0b4" +checksum = "1bc711410fbe7399f390ca1c3b60ad0f53f80e95c5eb935e52268a0e2cd49acc" [[package]] name = "serde" -version = "1.0.217" +version = "1.0.229" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02fc4265df13d6fa1d00ecff087228cc0a2b5f3c0e87e258d8b94a156e984c70" +checksum = "4148590afebada386688f18773da617792bf2ef03ffc1e4cbd2b1d45b023e0ba" dependencies = [ + "serde_core", "serde_derive", ] [[package]] -name = "serde_derive" -version = "1.0.217" +name = "serde_core" +version = "1.0.229" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a9bf7cf98d04a2b28aead066b7496853d4779c9cc183c440dbac457641e19a0" +checksum = "67dca2c9c51e58a4791a4b1ed58308b39c64224d349a935ab5039aa360942a48" dependencies = [ - "proc-macro2", - "quote", - "syn", + "serde_derive", ] [[package]] -name = "serde_json" -version = "1.0.138" +name = "serde_derive" +version = "1.0.229" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d434192e7da787e94a6ea7e9670b26a036d0ca41e0b7efb2676dd32bae872949" +checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348" dependencies = [ - "itoa", - "memchr", - "ryu", - "serde", + "proc-macro2", + "quote", + "syn 3.0.10", ] [[package]] -name = "serde_urlencoded" -version = "0.7.1" +name = "serde_json" +version = "1.0.154" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" +checksum = "e7e9cc8b1b85264074fbcc02a88680c4096b1e47df8f739dceb03bf482f04bd6" dependencies = [ - "form_urlencoded", "itoa", - "ryu", + "memchr", "serde", + "serde_core", + "zmij", ] [[package]] @@ -1127,9 +1069,15 @@ dependencies = [ [[package]] name = "shlex" -version = "1.3.0" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" +checksum = "f8fadd59c855ef2080decdef8ff161eb6661b86933c9d82e5ba29dc602a55aba" + +[[package]] +name = "simdutf8" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3a9fe34e3e7a50316060351f37187a3f546bce95496156754b601a5fa71b76e" [[package]] name = "simplelog" @@ -1144,34 +1092,31 @@ dependencies = [ [[package]] name = "slab" -version = "0.4.9" +version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" -dependencies = [ - "autocfg", -] +checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5" [[package]] name = "smallvec" -version = "1.13.2" +version = "1.16.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" +checksum = "149309498a5f7334b12ddae0cad8aba81ce785fe91755068867e017cf98fee46" [[package]] name = "socket2" -version = "0.5.8" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c970269d99b64e60ec3bd6ad27270092a5394c4e309314b18ae3fe575695fbe8" +checksum = "c3d1e2c7f27f8d4cb10542a02c49005dbd6e93095799d6f3be745fae9f8fedd4" dependencies = [ "libc", - "windows-sys 0.52.0", + "windows-sys 0.61.2", ] [[package]] name = "stable_deref_trait" -version = "1.2.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" +checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596" [[package]] name = "state" @@ -1190,9 +1135,20 @@ checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" [[package]] name = "syn" -version = "2.0.98" +version = "2.0.119" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36147f1a48ae0ec2b5b3bc5b537d267457555a10dc06f3dbc8cb11ba3006d3b1" +checksum = "872831b642d1a07999a962a351ed35b955ea2cfc8f3862091e2a240a84f17297" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "3.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ae9ccbea3a7b0b09443036490c8f34a8b1b760fd345e5c0dae0aac718faea79" dependencies = [ "proc-macro2", "quote", @@ -1210,23 +1166,23 @@ dependencies = [ [[package]] name = "synstructure" -version = "0.13.1" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" +checksum = "901704edd0dfe137f1987838ee4f259e4e063c31371bdb423f7ae38ec6f77f02" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 3.0.10", ] [[package]] name = "system-configuration" -version = "0.6.1" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c879d448e9d986b661742763247d3693ed13609438cf3d006f51f5368a5ba6b" +checksum = "a13f3d0daba03132c0aa9767f98351b3488edc2c100cda2d2ec2b04f3d8d3c8b" dependencies = [ "bitflags", - "core-foundation", + "core-foundation 0.9.4", "system-configuration-sys", ] @@ -1242,16 +1198,15 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.16.0" +version = "3.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38c246215d7d24f48ae091a2902398798e05d978b24315d6efbc00ede9a8bb91" +checksum = "32497e9a4c7b38532efcdebeef879707aa9f794296a4f0244f6f69e9bc8574bd" dependencies = [ - "cfg-if", "fastrand", - "getrandom 0.3.1", + "getrandom 0.4.3", "once_cell", "rustix", - "windows-sys 0.59.0", + "windows-sys 0.52.0", ] [[package]] @@ -1265,42 +1220,40 @@ dependencies = [ [[package]] name = "thread_local" -version = "1.1.8" +version = "1.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b9ef9bad013ada3808854ceac7b46812a6465ba368859a37e2100283d2d719c" +checksum = "1ad99c4c6d32803332c548b1af0540b357b3f5fc0be8f6c6bfe8b2e6ae784070" dependencies = [ "cfg-if", - "once_cell", ] [[package]] name = "time" -version = "0.3.37" +version = "0.3.55" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35e7868883861bd0e56d9ac6efcaaca0d6d5d82a2a7ec8209ff492c07cf37b21" +checksum = "cdb87b95ec50ddfa440816d227a17b2ccbdda963a316a727fda0fc4334f7d134" dependencies = [ "deranged", - "itoa", "libc", "num-conv", "num_threads", "powerfmt", - "serde", + "serde_core", "time-core", "time-macros", ] [[package]] name = "time-core" -version = "0.1.2" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" +checksum = "9e1c906769ad99c88eaa54e728060edef082f8e358ff32030cb7c7d315e81109" [[package]] name = "time-macros" -version = "0.2.19" +version = "0.2.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2834e6017e3e5e4b9834939793b282bc03b37a3336245fa820e35e233e2a85de" +checksum = "7e689342a48d2ea927c87ea50cabf8594854bf940e9310208848d680d668ed85" dependencies = [ "num-conv", "time-core", @@ -1308,9 +1261,9 @@ dependencies = [ [[package]] name = "tinystr" -version = "0.7.6" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9117f5d4db391c1cf6927e7bea3db74b9a1c1add8f7eda9ffd5364f40f57b82f" +checksum = "abc840c238154d58f9e86b2792261edfde565a17696e1cda1a449de27979801a" dependencies = [ "displaydoc", "zerovec", @@ -1318,17 +1271,16 @@ dependencies = [ [[package]] name = "tokio" -version = "1.44.2" +version = "1.54.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6b88822cbe49de4185e3a4cbf8321dd487cf5fe0c5c65695fef6346371e9c48" +checksum = "b52fd3255258d26fac7264ab5a76b53c13367136dc011d3d6ad4f8ed070396a3" dependencies = [ - "backtrace", "bytes", "libc", "mio", "pin-project-lite", "socket2", - "windows-sys 0.52.0", + "windows-sys 0.61.2", ] [[package]] @@ -1343,9 +1295,9 @@ dependencies = [ [[package]] name = "tokio-rustls" -version = "0.26.1" +version = "0.26.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f6d0975eaace0cf0fcadee4e4aaa5da15b5c079146f2cffb67c113be122bf37" +checksum = "c9cc2678c2cdd569ef8215e2afd7954ada2ae20b4fdd2c5fe6139a3b02d105db" dependencies = [ "rustls", "tokio", @@ -1353,22 +1305,23 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.7.13" +version = "0.7.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7fcaa8d55a2bdd6b83ace262b016eca0d79ee02818c5c1bcdf0305114081078" +checksum = "e464cf451ba96ebfc6f9b6542f17ee8b8956e33f1e40d9690624e59d7a7f8a4b" dependencies = [ "bytes", "futures-core", "futures-sink", + "libc", "pin-project-lite", "tokio", ] [[package]] name = "tower" -version = "0.5.2" +version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d039ad9159c98b70ecfd540b2573b97f7f52c3e8d9f8ad57a24b916a536975f9" +checksum = "ebe5ef63511595f1344e2d5cfa636d973292adc0eec1f0ad45fae9f0851ab1d4" dependencies = [ "futures-core", "futures-util", @@ -1379,6 +1332,24 @@ dependencies = [ "tower-service", ] +[[package]] +name = "tower-http" +version = "0.6.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4cfcf7e2740e6fc6d4d688b4ef00650406bb94adf4731e43c096c3a19fe40840" +dependencies = [ + "bitflags", + "bytes", + "futures-util", + "http", + "http-body", + "pin-project-lite", + "tower", + "tower-layer", + "tower-service", + "url", +] + [[package]] name = "tower-layer" version = "0.3.3" @@ -1393,9 +1364,9 @@ checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3" [[package]] name = "tracing" -version = "0.1.41" +version = "0.1.44" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "784e0ac535deb450455cbfa28a6f0df145ea1bb7ae51b821cf5e7927fdcfbdd0" +checksum = "63e71662fa4b2a2c3a26f570f037eb95bb1f85397f3cd8076caed2f026a6d100" dependencies = [ "pin-project-lite", "tracing-attributes", @@ -1404,20 +1375,20 @@ dependencies = [ [[package]] name = "tracing-attributes" -version = "0.1.28" +version = "0.1.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "395ae124c09f9e6918a2310af6038fba074bcf474ac352496d5910dd59a2226d" +checksum = "7490cfa5ec963746568740651ac6781f701c9c5ea257c58e057f3ba8cf69e8da" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.119", ] [[package]] name = "tracing-core" -version = "0.1.33" +version = "0.1.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e672c95779cf947c5311f83787af4fa8fffd12fb27e4993211a84bdfd9610f9c" +checksum = "db97caf9d906fbde555dd62fa95ddba9eecfd14cb388e4f491a66d74cd5fb79a" dependencies = [ "once_cell", "valuable", @@ -1436,9 +1407,9 @@ dependencies = [ [[package]] name = "tracing-subscriber" -version = "0.3.20" +version = "0.3.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2054a14f5307d601f88daf0553e1cbf472acc4f2c51afab632431cdcd72124d5" +checksum = "cb7f578e5945fb242538965c2d0b04418d38ec25c79d160cd279bf0731c8d319" dependencies = [ "matchers", "nu-ansi-term", @@ -1460,9 +1431,9 @@ checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" [[package]] name = "unicode-ident" -version = "1.0.16" +version = "1.0.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a210d160f08b701c8721ba1c726c11662f877ea6b7094007e1ca9a1041945034" +checksum = "a2c754d6c33795a1c324727428e5a7dedb5b06195f9890bdbcba760d3e246563" [[package]] name = "untrusted" @@ -1472,26 +1443,30 @@ checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" [[package]] name = "url" -version = "2.5.4" +version = "2.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32f8b686cadd1473f4bd0117a5d28d36b1ade384ea9b5069a1c40aefed7fda60" +checksum = "ff67a8a4397373c3ef660812acab3268222035010ab8680ec4215f38ba3d0eed" dependencies = [ "form_urlencoded", "idna", "percent-encoding", + "serde", ] [[package]] -name = "utf16_iter" -version = "1.0.5" +name = "utf8_iter" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8232dd3cdaed5356e0f716d285e4b40b932ac434100fe9b7e0e8e935b9e6246" +checksum = "af3bd9d3e571c26fcce9d033b87ea5ab061b8d2ffe9b7a5675d810d68f03edf0" +dependencies = [ + "utf_types", +] [[package]] -name = "utf8_iter" -version = "1.0.4" +name = "utf_types" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" +checksum = "3a3b425286980a367278453f3b6d28cdcb134b574e5a35824a6ff5eebad50bb6" [[package]] name = "valuable" @@ -1507,72 +1482,47 @@ checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" [[package]] name = "want" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e" +checksum = "ec4cdd0dd910afe868b7ef477227d8d538b46b3075031afee8a9f2acb0a2ed0b" dependencies = [ "try-lock", ] [[package]] name = "wasi" -version = "0.11.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" - -[[package]] -name = "wasi" -version = "0.13.3+wasi-0.2.2" +version = "0.11.1+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26816d2e1a4a36a2940b96c5296ce403917633dff8f3440e9b236ed6f6bacad2" -dependencies = [ - "wit-bindgen-rt", -] +checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" [[package]] name = "wasm-bindgen" -version = "0.2.100" +version = "0.2.130" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1edc8929d7499fc4e8f0be2262a241556cfc54a0bea223790e71446f2aab1ef5" +checksum = "a0181c14ddd6c7b8b0b0132a5f1ea2f32be0d893cd3ea97b6e3b28886b8a3d1c" dependencies = [ "cfg-if", - "once_cell", "rustversion", "wasm-bindgen-macro", -] - -[[package]] -name = "wasm-bindgen-backend" -version = "0.2.100" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f0a0651a5c2bc21487bde11ee802ccaf4c51935d0d3d42a6101f98161700bc6" -dependencies = [ - "bumpalo", - "log", - "proc-macro2", - "quote", - "syn", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-futures" -version = "0.4.50" +version = "0.4.80" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "555d470ec0bc3bb57890405e5d4322cc9ea83cebb085523ced7be4144dac1e61" +checksum = "5e14e0327cb5368ad60ccb22d04a9827a693c95a926d8d125e9fa39e0baec501" dependencies = [ - "cfg-if", "js-sys", - "once_cell", + "tokio", "wasm-bindgen", - "web-sys", ] [[package]] name = "wasm-bindgen-macro" -version = "0.2.100" +version = "0.2.130" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fe63fc6d09ed3792bd0897b314f53de8e16568c2b3f7982f468c0bf9bd0b407" +checksum = "6e931a02a39abdbf66966fc35902b5ed58344750a70885bed4ebb3d8eaf28ed9" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -1580,31 +1530,31 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.100" +version = "0.2.130" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ae87ea40c9f689fc23f209965b6fb8a99ad69aeeb0231408be24920604395de" +checksum = "2ca4b54280e455bd831e33a6b8e734baf432fe63fbc35c42ac14ce67a043a53a" dependencies = [ + "bumpalo", "proc-macro2", "quote", - "syn", - "wasm-bindgen-backend", + "syn 3.0.10", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.100" +version = "0.2.130" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a05d73b933a847d6cccdda8f838a22ff101ad9bf93e33684f39c1f5f0eece3d" +checksum = "3b1f9c3798725016c6ee5f2f57869ec0831e8bbc0ab0310a86e787e97f41389e" dependencies = [ "unicode-ident", ] [[package]] name = "web-sys" -version = "0.3.77" +version = "0.3.107" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33b6dd2ef9186f1f2072e409e99cd22a975331a6b3591b12c764e0e55c60d5d2" +checksum = "d7d179596ff5ec0f6de4db64d54011bde6289cc49603d3a6e4ce3f329207ab88" dependencies = [ "js-sys", "wasm-bindgen", @@ -1628,11 +1578,11 @@ checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" [[package]] name = "winapi-util" -version = "0.1.9" +version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb" +checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22" dependencies = [ - "windows-sys 0.59.0", + "windows-sys 0.61.2", ] [[package]] @@ -1652,77 +1602,114 @@ dependencies = [ [[package]] name = "windows" -version = "0.58.0" +version = "0.62.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd04d41d93c4992d421894c18c8b43496aa748dd4c081bac0dc93eb0489272b6" +checksum = "527fadee13e0c05939a6a05d5bd6eec6cd2e3dbd648b9f8e447c6518133d8580" +dependencies = [ + "windows-collections", + "windows-core", + "windows-future", + "windows-numerics", +] + +[[package]] +name = "windows-collections" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23b2d95af1a8a14a3c7367e1ed4fc9c20e0a26e79551b1454d72583c97cc6610" dependencies = [ "windows-core", - "windows-targets 0.52.6", ] [[package]] name = "windows-core" -version = "0.58.0" +version = "0.62.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ba6d44ec8c2591c134257ce647b7ea6b20335bf6379a27dac5f1641fcf59f99" +checksum = "b8e83a14d34d0623b51dce9581199302a221863196a1dde71a7663a4c2be9deb" dependencies = [ "windows-implement", "windows-interface", + "windows-link", "windows-result", "windows-strings", - "windows-targets 0.52.6", +] + +[[package]] +name = "windows-future" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1d6f90251fe18a279739e78025bd6ddc52a7e22f921070ccdc67dde84c605cb" +dependencies = [ + "windows-core", + "windows-link", + "windows-threading", ] [[package]] name = "windows-implement" -version = "0.58.0" +version = "0.60.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bbd5b46c938e506ecbce286b6628a02171d56153ba733b6c741fc627ec9579b" +checksum = "053e2e040ab57b9dc951b72c264860db7eb3b0200ba345b4e4c3b14f67855ddf" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.119", ] [[package]] name = "windows-interface" -version = "0.58.0" +version = "0.59.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "053c4c462dc91d3b1504c6fe5a726dd15e216ba718e84a0e46a88fbe5ded3515" +checksum = "3f316c4a2570ba26bbec722032c4099d8c8bc095efccdc15688708623367e358" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.119", +] + +[[package]] +name = "windows-link" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" + +[[package]] +name = "windows-numerics" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e2e40844ac143cdb44aead537bbf727de9b044e107a0f1220392177d15b0f26" +dependencies = [ + "windows-core", + "windows-link", ] [[package]] name = "windows-registry" -version = "0.2.0" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e400001bb720a623c1c69032f8e3e4cf09984deec740f007dd2b03ec864804b0" +checksum = "02752bf7fbdcce7f2a27a742f798510f3e5ad88dbe84871e5168e2120c3d5720" dependencies = [ + "windows-link", "windows-result", "windows-strings", - "windows-targets 0.52.6", ] [[package]] name = "windows-result" -version = "0.2.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d1043d8214f791817bab27572aaa8af63732e11bf84aa21a45a78d6c317ae0e" +checksum = "7781fa89eaf60850ac3d2da7af8e5242a5ea78d1a11c49bf2910bb5a73853eb5" dependencies = [ - "windows-targets 0.52.6", + "windows-link", ] [[package]] name = "windows-strings" -version = "0.1.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4cd9b125c486025df0eabcb585e62173c6c9eddcec5d117d3b6e8c30e2ee4d10" +checksum = "7837d08f69c77cf6b07689544538e017c1bfcf57e34b4c0ff58e6c2cd3b37091" dependencies = [ - "windows-result", - "windows-targets 0.52.6", + "windows-link", ] [[package]] @@ -1736,11 +1723,11 @@ dependencies = [ [[package]] name = "windows-sys" -version = "0.59.0" +version = "0.61.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" dependencies = [ - "windows-targets 0.52.6", + "windows-link", ] [[package]] @@ -1774,6 +1761,15 @@ dependencies = [ "windows_x86_64_msvc 0.52.6", ] +[[package]] +name = "windows-threading" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3949bd5b99cafdf1c7ca86b43ca564028dfe27d66958f2470940f73d86d75b37" +dependencies = [ + "windows-link", +] + [[package]] name = "windows_aarch64_gnullvm" version = "0.48.5" @@ -1864,34 +1860,18 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" -[[package]] -name = "wit-bindgen-rt" -version = "0.33.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3268f3d866458b787f390cf61f4bbb563b922d091359f9608842999eaee3943c" -dependencies = [ - "bitflags", -] - -[[package]] -name = "write16" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1890f4022759daae28ed4fe62859b1236caebfc61ede2f63ed4e695f3f6d936" - [[package]] name = "writeable" -version = "0.5.5" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e9df38ee2d2c3c5948ea468a8406ff0db0b29ae1ffde1bcf20ef305bcc95c51" +checksum = "3ad82d2a33cdc9674dc7465672f271e096168fcdbe0f799d9e6db8c5892679dc" [[package]] name = "yoke" -version = "0.7.5" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "120e6aef9aa629e3d4f52dc8cc43a015c7724194c97dfaf45180d2daf2b77f40" +checksum = "417ef3fcf6c300b7dbd25c85531a746931c02ad536f3cf4786ed1e88223340b3" dependencies = [ - "serde", "stable_deref_trait", "yoke-derive", "zerofrom", @@ -1899,48 +1879,59 @@ dependencies = [ [[package]] name = "yoke-derive" -version = "0.7.5" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2380878cad4ac9aac1e2435f3eb4020e8374b5f13c296cb75b4620ff8e229154" +checksum = "ec8ebde2db3681e8c9980cc27822030e68752690ddfa9473e739aeb4dbde6d71" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 3.0.10", "synstructure", ] [[package]] name = "zerofrom" -version = "0.1.5" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cff3ee08c995dee1859d998dea82f7374f2826091dd9cd47def953cae446cd2e" +checksum = "0ec05a11813ea801ff6d75110ad09cd0824ddba17dfe17128ea0d5f68e6c5272" dependencies = [ "zerofrom-derive", ] [[package]] name = "zerofrom-derive" -version = "0.1.5" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "595eed982f7d355beb85837f651fa22e90b3c044842dc7f2c2842c086f295808" +checksum = "f75b4683f6c7f45248d4d64056a24298c6281e0993356d7d1b4a1a962ef10d4a" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 3.0.10", "synstructure", ] [[package]] name = "zeroize" -version = "1.8.1" +version = "1.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e13084392c5e4bc371903e2935a5eaeed24905a7511356b883835e18a78f6879" + +[[package]] +name = "zerotrie" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde" +checksum = "4ea269c3bd32f0a32c321907a2ae912ba6f4649bb0fc764a15627e99a7095a3f" +dependencies = [ + "displaydoc", + "yoke", + "zerofrom", +] [[package]] name = "zerovec" -version = "0.10.4" +version = "0.11.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa2b893d79df23bfb12d5461018d408ea19dfafe76c2c7ef6d4eba614f8ff079" +checksum = "f58a2799cfe9a1670c7ea8edbd52ef8edb93cb37a7f83bf31ba9e35d9dae6a40" dependencies = [ "yoke", "zerofrom", @@ -1949,11 +1940,17 @@ dependencies = [ [[package]] name = "zerovec-derive" -version = "0.10.3" +version = "0.11.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6eafa6dfb17584ea3e2bd6e76e0cc15ad7af12b09abdd1ca55961bed9b1063c6" +checksum = "c3743ddbf47738d929cd1ae2e199d40d0162979dfe31aef8ae646d2bf00bf97a" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 3.0.10", ] + +[[package]] +name = "zmij" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29666d0abbfad1e3dc4dcf6144730dd3a3ab225bbbdac83319345b1b44ccfc1b" diff --git a/extensions/Cargo.toml b/extensions/Cargo.toml index adb2cca2b..5a1d9b5d9 100644 --- a/extensions/Cargo.toml +++ b/extensions/Cargo.toml @@ -1,8 +1,9 @@ [workspace] members = [ "apollo-client", + "apollo-server", ] -resolver = "2" +resolver = "3" [profile.release] opt-level = "z" diff --git a/extensions/apollo-client/Cargo.toml b/extensions/apollo-client/Cargo.toml index 3ce88e839..460d73642 100644 --- a/extensions/apollo-client/Cargo.toml +++ b/extensions/apollo-client/Cargo.toml @@ -1,17 +1,16 @@ [package] name = "apollo-client-rs" -version = "1.0.0" +version = "1.1.0" authors = ["Theseus Incorporated "] -edition = "2021" -rust-version = "1.59" +edition = "2024" +rust-version = "1.88" [lib] name = "apollo_client" crate-type = ["cdylib", "rlib"] [dependencies] -arma-rs = "1.11" -lazy_static = "1.5" -log = "0.4" -reqwest = { version = "0.12", features = ["blocking"] } +arma-rs = "1.13" +log = "0.4.34" +reqwest = { version = "0.13", default-features = false, features = ["blocking", "charset", "http2", "native-tls", "system-proxy"] } simplelog = "0.12" diff --git a/extensions/apollo-client/src/lib.rs b/extensions/apollo-client/src/lib.rs index 745e6948d..6e99448e7 100644 --- a/extensions/apollo-client/src/lib.rs +++ b/extensions/apollo-client/src/lib.rs @@ -1,25 +1,52 @@ use std::fs::{File, create_dir_all}; use std::path::Path; +use std::sync::{LazyLock, Mutex}; use arma_rs::{arma, Extension}; use reqwest::blocking::Client; use log::{LevelFilter, info}; use simplelog::{CombinedLogger, TermLogger, WriteLogger, Config, TerminalMode, ColorChoice}; -const REST_ENDPOINT: &str = "https://api.theseus-aegis.com/apollo"; -const LOG_PATH: &str = "./logs/tac_apollo.log"; +/// The websites (overridden by `APOLLO_LIVE_URL` and `APOLLO_DEV_URL`, the same variables as +/// apollo-server): the live one, used only when the server uses it (`live`), and the development +/// one for every other server and for testing without a server. Players don't set these, so the +/// usual websites are built in. +pub const LIVE_WEBSITE: &str = "https://www.theseus-aegis.com"; +pub const DEV_WEBSITE: &str = "https://srv.theseus-aegis.com/minotaur"; +/// Minotaur's Apollo API for players, on that website. +pub const API_PATH: &str = "/apollo/v1/client"; +const LOG_PATH: &str = "./logs/tac_apollo_client.log"; const EXT_RET_BYTES: usize = (20480 - 8) / 8; // Size used by Arma 3 as of 2022-04-18 -static mut QUEUE: String = String::new(); -static mut QUEUE_JUST_EMPTIED: bool = false; +/// A response too long for one return, handed out in parts by `get`. +struct Queue { + text: String, + just_emptied: bool, +} + +static QUEUE: Mutex = Mutex::new(Queue { text: String::new(), just_emptied: false }); +static CLIENT: LazyLock = LazyLock::new(Client::new); +static LIVE_ENDPOINT: LazyLock = LazyLock::new(|| endpoint_from(|key| std::env::var(key).ok(), true)); +static DEV_ENDPOINT: LazyLock = LazyLock::new(|| endpoint_from(|key| std::env::var(key).ok(), false)); + +fn queue() -> std::sync::MutexGuard<'static, Queue> { + QUEUE.lock().unwrap_or_else(|e| e.into_inner()) +} + +fn endpoint(live: bool) -> &'static str { + if live { &LIVE_ENDPOINT } else { &DEV_ENDPOINT } +} -lazy_static::lazy_static! { - static ref CLIENT: Client = Client::new(); +/// The live (`live`) or development website's player API, without a trailing slash. +fn endpoint_from(var: impl Fn(&str) -> Option, live: bool) -> String { + let (key, default) = if live { ("APOLLO_LIVE_URL", LIVE_WEBSITE) } else { ("APOLLO_DEV_URL", DEV_WEBSITE) }; + let website = var(key).map(|v| v.trim().to_string()).filter(|v| !v.is_empty()).unwrap_or_else(|| default.to_string()); + format!("{}{API_PATH}", website.trim_end_matches('/')) } macro_rules! url { - ($($args:expr),*) => {{ - let mut requrl: String = String::from(REST_ENDPOINT); + ($live:expr, $($args:expr),*) => {{ + let mut requrl: String = String::from(endpoint($live)); $( requrl = format!("{}/{}", requrl, $args); )* @@ -31,7 +58,10 @@ fn request(api: String) -> String { info!("Request: {}", api); match CLIENT.get(&api).send() { Ok(v) => { - let mut response = v.text().unwrap(); + let Ok(mut response) = v.text() else { + info!("Request error: unreadable response"); + return String::from("error"); + }; // Replace non-ASCII characters with a warning response = response.replace(|c: char| !c.is_ascii(), "[INVALID-CHAR]"); @@ -41,10 +71,7 @@ fn request(api: String) -> String { info!("Direct response"); response } else { - unsafe { - QUEUE.clear(); - QUEUE = response; - } + queue().text = response; info!("Queued response (max {} bytes at once)", EXT_RET_BYTES); String::from("queued") } @@ -58,77 +85,192 @@ fn request(api: String) -> String { #[arma] pub fn init() -> Extension { - let log_path = Path::new(LOG_PATH); - create_dir_all(log_path.parent().unwrap()).unwrap(); - CombinedLogger::init( - vec![ - TermLogger::new(LevelFilter::Info, Config::default(), TerminalMode::Mixed, ColorChoice::Auto), - WriteLogger::new(LevelFilter::Info, Config::default(), File::create(log_path).unwrap()), - ] - ).unwrap(); + init_logging(LevelFilter::Info); Extension::build() + .version(env!("CARGO_PKG_VERSION").to_string()) .command("loadArmory", load_armory) .command("loadPlayer", load_player) .command("getAccessibleItemClasses", get_accessible_item_classes) .command("getTrainingIdentifiers", get_training_identifiers) + .command("loadKits", load_kits) .command("get", get) .command("version", version) .finish() } pub fn init_debug() { + init_logging(LevelFilter::Trace); +} + +/// To the terminal and `LOG_PATH`; without the log file (or when already set up), as it can. +fn init_logging(level: LevelFilter) { let log_path = Path::new(LOG_PATH); - create_dir_all(log_path.parent().unwrap()).unwrap(); - CombinedLogger::init( - vec![ - TermLogger::new(LevelFilter::Trace, Config::default(), TerminalMode::Mixed, ColorChoice::Auto), - WriteLogger::new(LevelFilter::Trace, Config::default(), File::create(log_path).unwrap()), - ] - ).unwrap(); + let mut loggers: Vec> = + vec![TermLogger::new(level, Config::default(), TerminalMode::Mixed, ColorChoice::Auto)]; + if create_dir_all(log_path.parent().unwrap()).is_ok() + && let Ok(file) = File::create(log_path) + { + loggers.push(WriteLogger::new(level, Config::default(), file)); + } + let _ = CombinedLogger::init(loggers); } -pub fn load_armory(category: String, player_id: String, debug: bool) -> String { - request(url!("armory", category, player_id, debug)) +// Each takes `live`: the server uses the live website (otherwise the development one). + +/// The player's locker (all, or one category), as [class, sub-category, description, quantity] entries. +pub fn load_armory(category: String, player_id: String, live: bool) -> String { + request(url!(live, player_id, "locker", category)) } -pub fn load_player(player_id: String, debug: bool) -> String { - request(url!("loadInfantry", player_id, debug)) +/// The player's kits (prepared on the website): [[id, name, ready, [[class, quantity, in locker], ...]], ...]. +pub fn load_kits(player_id: String, live: bool) -> String { + request(url!(live, player_id, "kits")) } -pub fn get_accessible_item_classes(player_id: String) -> String { - request(url!("getAccessibleItemClasses", player_id)) +/// [direction, position, loadout, selected weapon, variables] as last saved (passed through as is). +pub fn load_player(player_id: String, live: bool) -> String { + request(url!(live, player_id, "loadout")) } -pub fn get_training_identifiers(player_id: String) -> String { - request(url!("getTrainingIdentifiers", player_id)) +pub fn get_accessible_item_classes(player_id: String, live: bool) -> String { + request(url!(live, player_id, "items")) +} + +pub fn get_training_identifiers(player_id: String, live: bool) -> String { + request(url!(live, player_id, "trainings")) } pub fn get() -> String { - unsafe { - if QUEUE.is_empty() { - if QUEUE_JUST_EMPTIED { - QUEUE_JUST_EMPTIED = false; - info!("Get: done"); - String::from("done") - } else { - info!("Get: error"); - String::from("error") - } + let mut queue = queue(); + if queue.text.is_empty() { + if queue.just_emptied { + queue.just_emptied = false; + info!("Get: done"); + String::from("done") } else { - let mut split = QUEUE.split_off(std::cmp::min(EXT_RET_BYTES, QUEUE.len())); - std::mem::swap(&mut QUEUE, &mut split); - - if QUEUE.is_empty() { - QUEUE_JUST_EMPTIED = true; - } + info!("Get: error"); + String::from("error") + } + } else { + let at = std::cmp::min(EXT_RET_BYTES, queue.text.len()); + let rest = queue.text.split_off(at); + let part = std::mem::replace(&mut queue.text, rest); - info!("Get: {} bytes", split.len()); - split + if queue.text.is_empty() { + queue.just_emptied = true; } + + info!("Get: {} bytes", part.len()); + part } } pub fn version() -> &'static str { env!("CARGO_PKG_VERSION") } + +#[cfg(test)] +mod tests { + use super::*; + use std::io::{Read, Write}; + use std::net::TcpListener; + use std::thread; + + /// The queue is shared, so tests that use it take turns. + static TURN: Mutex<()> = Mutex::new(()); + + fn turn() -> std::sync::MutexGuard<'static, ()> { + TURN.lock().unwrap_or_else(|e| e.into_inner()) + } + + fn endpoint_with(vars: &[(&str, &str)], live: bool) -> String { + endpoint_from(|key| vars.iter().find(|(k, _)| *k == key).map(|(_, v)| v.to_string()), live) + } + + /// A one-request web server answering `body`; returns its address and what was requested. + fn serve(body: &'static str) -> (String, thread::JoinHandle) { + let listener = TcpListener::bind("127.0.0.1:0").unwrap(); + let address = format!("http://{}", listener.local_addr().unwrap()); + let handle = thread::spawn(move || { + let (mut stream, _) = listener.accept().unwrap(); + let mut request = [0; 4096]; + let n = stream.read(&mut request).unwrap(); + let line = String::from_utf8_lossy(&request[..n]).lines().next().unwrap_or("").to_string(); + write!(stream, "HTTP/1.1 200 OK\r\nContent-Type: text/plain; charset=utf-8\r\nContent-Length: {}\r\nConnection: close\r\n\r\n{body}", + body.len()).unwrap(); + line + }); + (address, handle) + } + + #[test] + fn usual_websites_by_default() { + assert_eq!(endpoint_with(&[], true), "https://www.theseus-aegis.com/apollo/v1/client"); + assert_eq!(endpoint_with(&[], false), "https://srv.theseus-aegis.com/minotaur/apollo/v1/client"); + assert_eq!(endpoint_with(&[("APOLLO_LIVE_URL", " ")], true), format!("{LIVE_WEBSITE}{API_PATH}")); + } + + #[test] + fn websites_overridden() { + let vars = [("APOLLO_LIVE_URL", "https://example.com/"), ("APOLLO_DEV_URL", "http://localhost:8001")]; + assert_eq!(endpoint_with(&vars, true), "https://example.com/apollo/v1/client"); + assert_eq!(endpoint_with(&vars, false), "http://localhost:8001/apollo/v1/client"); + assert_eq!(endpoint_with(&vars[1..], true), format!("{LIVE_WEBSITE}{API_PATH}")); // only dev's set + } + + #[test] + fn urls() { + assert_eq!(url!(true, "765", "locker", "rifle"), format!("{}/765/locker/rifle", endpoint(true))); + assert_eq!(url!(false, "765", "kits"), format!("{}/765/kits", endpoint(false))); + } + + #[test] + fn short_response_directly() { + let _turn = turn(); + let (address, server) = serve("[[\"arifle_MX_F\",\"Rifle\",\"MX\",2]]"); + assert_eq!(request(format!("{address}/apollo/v1/client/765/locker/rifle")), + "[[\"arifle_MX_F\",\"Rifle\",\"MX\",2]]"); + assert_eq!(server.join().unwrap(), "GET /apollo/v1/client/765/locker/rifle HTTP/1.1"); + assert_eq!(get(), "error"); // nothing queued + } + + #[test] + fn long_response_in_parts() { + let _turn = turn(); + let body: &'static str = Box::leak("x".repeat(EXT_RET_BYTES * 2 + 10).into_boxed_str()); + let (address, server) = serve(body); + assert_eq!(request(format!("{address}/loadout")), "queued"); + server.join().unwrap(); + let parts: Vec = (0..3).map(|_| get()).collect(); + assert_eq!(parts.iter().map(String::len).collect::>(), [EXT_RET_BYTES, EXT_RET_BYTES, 10]); + assert_eq!(parts.concat(), body); + assert_eq!(get(), "done"); + assert_eq!(get(), "error"); + } + + #[test] + fn non_ascii_replaced() { + let _turn = turn(); + let (address, server) = serve("[\"Žiga\",\"12 Ŧ\"]"); + assert_eq!(request(format!("{address}/x")), "[\"[INVALID-CHAR]iga\",\"12 [INVALID-CHAR]\"]"); + server.join().unwrap(); + } + + #[test] + fn unreachable_website_is_an_error() { + let _turn = turn(); + let port = TcpListener::bind("127.0.0.1:0").unwrap().local_addr().unwrap().port(); // closed again + assert_eq!(request(format!("http://127.0.0.1:{port}/x")), "error"); + } + + #[test] + fn commands() { + let _turn = turn(); + let extension = init().testing(); + let (version, code) = extension.call("version", None); + assert_eq!((version.as_str(), code), (env!("CARGO_PKG_VERSION"), 0)); + let (reply, _) = extension.call("get", None); + assert_eq!(reply, "error"); + } +} diff --git a/extensions/apollo-client/src/main.rs b/extensions/apollo-client/src/main.rs index a7ce78cc7..c7f23559e 100644 --- a/extensions/apollo-client/src/main.rs +++ b/extensions/apollo-client/src/main.rs @@ -2,15 +2,16 @@ use apollo_client::*; fn main() { init_debug(); + // The last argument is live (false: the development website) println!("Version: {}", version()); - get_training_identifiers(String::from("76561198324654204")); // Mick - //get_training_identifiers(String::from("76561198155448656")); // Philippe - //load_player(String::from("76561198048995566"), true); + get_training_identifiers(String::from("76561198324654204"), false); // Mick + //get_training_identifiers(String::from("76561198155448656"), false); // Philippe + //load_player(String::from("76561198048995566"), false); //load_armory(String::from("item"), String::from("76561198048995566"), false); //load_armory(String::from("rifle"), String::from("76561198024182729"), false); - //get_accessible_item_classes(String::from("76561198048995566")); + //get_accessible_item_classes(String::from("76561198048995566"), false); if get() != "error" { while get() != "done" {} diff --git a/extensions/apollo-server/Cargo.toml b/extensions/apollo-server/Cargo.toml new file mode 100644 index 000000000..5616df595 --- /dev/null +++ b/extensions/apollo-server/Cargo.toml @@ -0,0 +1,17 @@ +[package] +name = "apollo-server-rs" +version = "1.0.0" +authors = ["Theseus Incorporated "] +edition = "2024" +rust-version = "1.88" + +[lib] +name = "apollo_server" +crate-type = ["cdylib", "rlib"] + +[dependencies] +arma-rs = "1.13" +log = "0.4.34" +reqwest = { version = "0.13", default-features = false, features = ["blocking", "json", "native-tls"] } +serde_json = "1.0.151" +simplelog = "0.12" diff --git a/extensions/apollo-server/src/backend.rs b/extensions/apollo-server/src/backend.rs new file mode 100644 index 000000000..361d18389 --- /dev/null +++ b/extensions/apollo-server/src/backend.rs @@ -0,0 +1,141 @@ +//! Talking to Minotaur's Apollo API (`/apollo/v1/server/...`). + +use std::time::Duration; + +use reqwest::blocking::Client; +use serde_json::Value; + +/// The websites (overridden by `APOLLO_LIVE_URL` and `APOLLO_DEV_URL`): the live one, only for the +/// live server (`APOLLO_SERVER_LIVE`), and the development one for every other server, a local one +/// included. The same variables as apollo-client. +pub const LIVE_WEBSITE: &str = "https://www.theseus-aegis.com"; +pub const DEV_WEBSITE: &str = "https://srv.theseus-aegis.com/minotaur"; +/// Minotaur's Apollo API for game servers, on that website. +pub const API_PATH: &str = "/apollo/v1/server"; +const TIMEOUT: Duration = Duration::from_secs(10); + +/// Where requests go. The real one is HTTP; tests use a fake. +pub trait Backend: Send + Sync + 'static { + /// GET `path` (relative to the API's base), the response body on success. + fn get(&self, path: &str) -> Result; + /// POST `body` as JSON to `path`, the response body on success. + fn post(&self, path: &str, body: &Value) -> Result; +} + +pub struct Config { + /// Uses the live website (told to players' apollo-client by `getApi`). + pub live: bool, + pub url: String, + pub token: String, +} + +impl Config { + /// From the environment (the server runs in Docker): + /// - `APOLLO_SERVER_TOKEN`: from the website's admin (Chronos · Apollo › Game servers); + /// - `APOLLO_SERVER_LIVE` (`1`, `true` or `yes`): the live server, using the live website; + /// without it, the development website; + /// - `APOLLO_LIVE_URL` / `APOLLO_DEV_URL`: the live / development website, if not the usual + /// ones (e.g. `http://minotaur:8000` on the same Docker network). + pub fn load() -> Self { + Self::from_env(|key| std::env::var(key).ok()) + } + + pub fn from_env(var: impl Fn(&str) -> Option) -> Self { + let live = var("APOLLO_SERVER_LIVE").is_some_and(|v| is_true(&v)); + Self { + live, + url: format!("{}{API_PATH}", website(&var, live)), + token: var("APOLLO_SERVER_TOKEN").unwrap_or_default().trim().to_string(), + } + } +} + +fn is_true(value: &str) -> bool { + matches!(value.trim().to_lowercase().as_str(), "1" | "true" | "yes") +} + +/// The live (`live`) or development website, without a trailing slash. +fn website(var: &impl Fn(&str) -> Option, live: bool) -> String { + let (key, default) = if live { ("APOLLO_LIVE_URL", LIVE_WEBSITE) } else { ("APOLLO_DEV_URL", DEV_WEBSITE) }; + var(key).map(|v| v.trim().to_string()).filter(|v| !v.is_empty()).unwrap_or_else(|| default.to_string()) + .trim_end_matches('/').to_string() +} + +pub struct Http { + client: Client, + config: Config, +} + +impl Http { + pub fn new(config: Config) -> Self { + let client = Client::builder() + .timeout(TIMEOUT) + .user_agent(concat!("tac-apollo-server/", env!("CARGO_PKG_VERSION"))) + .build() + .expect("HTTP client"); + Self { client, config } + } + + fn url(&self, path: &str) -> String { + format!("{}{}", self.config.url, path) + } + + fn finish(response: reqwest::Result) -> Result { + let response = response.map_err(|e| e.to_string())?; + let status = response.status(); + let text = response.text().map_err(|e| e.to_string())?; + if status.is_success() { + Ok(text) + } else { + Err(format!("{status}: {text}")) + } + } +} + +impl Backend for Http { + fn get(&self, path: &str) -> Result { + Self::finish(self.client.get(self.url(path)).bearer_auth(&self.config.token).send()) + } + + fn post(&self, path: &str, body: &Value) -> Result { + Self::finish(self.client.post(self.url(path)).bearer_auth(&self.config.token).json(body).send()) + } +} + +#[cfg(test)] +mod tests { + use super::*; + + fn config(vars: &[(&str, &str)]) -> Config { + let vars: Vec<(String, String)> = vars.iter().map(|(k, v)| (k.to_string(), v.to_string())).collect(); + Config::from_env(|key| vars.iter().find(|(k, _)| k == key).map(|(_, v)| v.clone())) + } + + #[test] + fn development_by_default() { + let c = config(&[("APOLLO_SERVER_TOKEN", " abc\n")]); + assert_eq!(c.url, "https://srv.theseus-aegis.com/minotaur/apollo/v1/server"); + assert!(!c.live); + assert_eq!(c.token, "abc"); + assert_eq!(config(&[]).token, ""); + } + + #[test] + fn live_picks_the_live_website() { + let c = config(&[("APOLLO_SERVER_LIVE", "true")]); + assert_eq!(c.url, "https://www.theseus-aegis.com/apollo/v1/server"); + assert!(c.live); + assert_eq!(config(&[("APOLLO_SERVER_LIVE", "1")]).url, format!("{LIVE_WEBSITE}{API_PATH}")); + assert_eq!(config(&[("APOLLO_SERVER_LIVE", "0")]).url, format!("{DEV_WEBSITE}{API_PATH}")); + assert_eq!(config(&[("APOLLO_SERVER_LIVE", "")]).url, format!("{DEV_WEBSITE}{API_PATH}")); + } + + #[test] + fn websites_overridden() { + let vars = [("APOLLO_LIVE_URL", "https://example.com/"), ("APOLLO_DEV_URL", "http://minotaur:8000")]; + assert_eq!(config(&vars).url, "http://minotaur:8000/apollo/v1/server"); + let live = [vars[0], vars[1], ("APOLLO_SERVER_LIVE", "yes")]; + assert_eq!(config(&live).url, "https://example.com/apollo/v1/server"); + assert_eq!(config(&[("APOLLO_DEV_URL", " ")]).url, format!("{DEV_WEBSITE}{API_PATH}")); // empty: the usual one + } +} diff --git a/extensions/apollo-server/src/handler.rs b/extensions/apollo-server/src/handler.rs new file mode 100644 index 000000000..55fce500d --- /dev/null +++ b/extensions/apollo-server/src/handler.rs @@ -0,0 +1,433 @@ +//! Apollo's game-server commands, answering as Apollo did, with Minotaur as the backend. +//! +//! What only matters while the game server runs stays here, as it did in Apollo's memory: +//! whether a player may be saved yet, and the queues of website replies (data, read with parseSimpleArray) the game fetches one +//! by one (locker actions, vehicles to recreate). Saves are sent in the background, in order, +//! so the game doesn't wait for them. + +use std::collections::hash_map::RandomState; +use std::collections::{HashMap, VecDeque}; +use std::hash::{BuildHasher, Hasher}; +use std::sync::mpsc::{channel, Sender}; +use std::sync::{Arc, Mutex}; +use std::thread; +use std::time::{Duration, Instant, SystemTime}; + +use log::{error, info, warn}; +use serde_json::{json, Map, Value}; + +use crate::backend::Backend; + +/// Apollo kicked a player after this many saves that came before their load was confirmed. +const BOOT_AFTER_ATTEMPTS: u32 = 3; +/// Apollo's setup time: vehicles count as loaded this long after they were requested. +const VEHICLE_SETUP: Duration = Duration::from_secs(60); +const RETRY_AFTER: Duration = Duration::from_secs(2); +const DONE: &str = "done"; +const ERROR: &str = "error"; + +/// Apollo's CanSave: saving starts once the player's load was validated. +#[derive(Default)] +struct CanSave { + can_save: bool, + attempts: u32, +} + +#[derive(Default)] +struct State { + can_save: HashMap, + locker_queues: HashMap>, + vehicle_ids: VecDeque, + vehicles: HashMap>, + vehicles_requested: Option, +} + +struct Job { + path: String, + body: Value, +} + +pub struct Handler { + backend: Arc, + state: Mutex, + saves: Mutex>, +} + +impl Handler { + pub fn new(backend: B) -> Self { + let backend = Arc::new(backend); + let (sender, receiver) = channel::(); + let worker = Arc::clone(&backend); + thread::spawn(move || { + for job in receiver { + if let Err(e) = worker.post(&job.path, &job.body) { + warn!("Save to {} failed ({e}), retrying", job.path); + thread::sleep(RETRY_AFTER); + if let Err(e) = worker.post(&job.path, &job.body) { + error!("Save to {} failed again, not saved: {e}", job.path); + } + } + } + }); + Self { backend, state: Mutex::new(State::default()), saves: Mutex::new(sender) } + } + + fn state(&self) -> std::sync::MutexGuard<'_, State> { + self.state.lock().unwrap_or_else(|e| e.into_inner()) + } + + fn save_later(&self, path: String, body: Value) { + if self.saves.lock().unwrap_or_else(|e| e.into_inner()).send(Job { path, body }).is_err() { + error!("Save queue stopped; not saved"); + } + } + + /// "none", "done" or "error" (Apollo's resetServer). + pub fn reset_server(&self, players: String, vehicles: String, server: String, map: String, mission: String) -> String { + let body = json!({"players": players, "vehicles": vehicles, "server": server, "map": map, "mission": mission}); + self.backend.post("/reset", &body).unwrap_or_else(|e| { + error!("resetServer: {e}"); + ERROR.into() + }) + } + + /// Apollo's storeInfantry: "success" for a validation, "completed" when saved, or + /// "rejected"/"terminated" while the player's load isn't confirmed (the game kicks a + /// player on "terminated"). + #[allow(clippy::too_many_arguments)] + pub fn store_infantry( + &self, kind: String, id: String, name: String, position: String, direction: String, loadout: String, + weapon: String, variables: String, + ) -> String { + if id.is_empty() { + return "rejected".into(); + } + if kind.eq_ignore_ascii_case("validate") { + return "success".into(); + } + { + let mut state = self.state(); + match state.can_save.get_mut(&id) { + None => { + // Never loaded on this server (as Apollo: count it, then terminate). + let mut entry = CanSave::default(); + entry.attempts += 1; + let terminate = entry.attempts >= BOOT_AFTER_ATTEMPTS; + state.can_save.insert(id.clone(), entry); + return if terminate { "rejected" } else { "terminated" }.into(); + } + Some(entry) if !entry.can_save => { + entry.attempts += 1; + return if entry.attempts >= BOOT_AFTER_ATTEMPTS { "terminated" } else { "rejected" }.into(); + } + Some(_) => {} + } + } + let body = json!({"name": name, "position": position, "direction": direction, "loadout": loadout, + "weapon": weapon, "variables": variables}); + self.save_later(format!("/players/{id}"), body); + "completed".into() + } + + /// The player's load was validated: saving may start. + pub fn infantry_loaded(&self, id: String) -> String { + self.state().can_save.insert(id, CanSave { can_save: true, attempts: 0 }); + DONE.into() + } + + /// Log the death and clear the player's state; saving waits for the next load. The death's + /// key (also its bodybag's ID), the loadout and the variables at the moment of death are + /// logged with it. + pub fn player_died(&self, id: String, death_key: String, loadout: String, variables: String) -> String { + self.state().can_save.insert(id.clone(), CanSave::default()); + let body = json!({"death_key": death_key, "loadout": loadout, "variables": variables}); + if let Err(e) = self.backend.post(&format!("/players/{id}/died"), &body) { + error!("playerDied {id}: {e}"); + } + DONE.into() // as Apollo: the game respawns the player either way + } + + /// Put an item into the member's locker or take one out. "ready": fetch the reply + /// with retrieve_locker_queue; "error": refused. `partial`: putting magazines in, the rounds + /// of the partly used ones among them (`[12,3]`), the rest full. + #[allow(clippy::too_many_arguments)] + pub fn locker_action( + &self, action: String, id: String, item: String, box_class: String, quantity: String, keep_magazines: String, + partial: String, + ) -> String { + let body = json!({"action": action, "item": item, "box": box_class, "quantity": quantity, + "keep_magazines": keep_magazines, "partial": partial}); + self.queue_locker(&format!("/locker/{id}"), &body, id, &format!("lockerAction {action} {item}")) + } + + /// Take a kit (prepared on the website) from the member's locker into the box: of each of + /// its items what the locker has. "ready": fetch the reply with retrieve_locker_queue. + pub fn locker_take_kit(&self, kit: String, id: String) -> String { + self.queue_locker(&format!("/kits/{id}"), &json!({"kit": kit}), id, &format!("lockerTakeKit {kit}")) + } + + /// A bodybag sent from base ("Return to owner"): its contents (`[["class", n], …]`) wait on + /// the website for the owner. The reply is the website's Arma array (`["ok", owner, n, lost]`, + /// `["already", owner]`, `["gone", owner]`, `["error", why]`), or "error". + pub fn bodybag_return(&self, id: String, death_key: String, contents: String) -> String { + let body = json!({"death_key": death_key, "contents": contents}); + match self.backend.post(&format!("/bodybags/{id}"), &body) { + Ok(reply) => reply, + Err(e) => { + error!("bodybagReturn {id} {death_key}: {e}"); + ERROR.into() + } + } + } + + fn queue_locker(&self, path: &str, body: &Value, id: String, what: &str) -> String { + let replies = match self.backend.post(path, body) { + Ok(text) => serde_json::from_str::>(&text).map_err(|e| e.to_string()), + Err(e) => Err(e), + }; + match replies { + Ok(mut replies) => { + replies.push(DONE.into()); + self.state().locker_queues.insert(id, replies.into()); + "ready".into() + } + Err(e) => { + info!("{what} for {id} refused: {e}"); + ERROR.into() + } + } + } + + pub fn retrieve_locker_queue(&self, id: String) -> String { + let mut state = self.state(); + let next = state.locker_queues.get_mut(&id).and_then(VecDeque::pop_front); + match next { + Some(reply) => { + if reply == DONE { + state.locker_queues.remove(&id); + } + reply + } + None => ERROR.into(), + } + } + + /// Fetch every saved vehicle; then get_vehicle_list gives their IDs and get_vehicle + /// each one's data in pieces (the game joins them), both ending with "done". + pub fn retrieve_all_vehicles(&self) -> String { + let vehicles = self.backend.get("/vehicles").and_then(|text| { + serde_json::from_str::>(&text).map_err(|e| e.to_string()) + }); + let vehicles = match vehicles { + Ok(v) => v, + Err(e) => { + error!("retrieveAllVehicles: {e}"); + return ERROR.into(); + } + }; + let mut state = self.state(); + state.vehicle_ids.clear(); + state.vehicles.clear(); + for (id, pieces) in vehicles { + let mut queue: VecDeque = pieces + .as_array() + .map(|a| a.iter().filter_map(|s| s.as_str().map(String::from)).collect()) + .unwrap_or_default(); + queue.push_back(DONE.into()); + state.vehicle_ids.push_back(id.clone()); + state.vehicles.insert(id, queue); + } + state.vehicle_ids.push_back(DONE.into()); + state.vehicles_requested = Some(Instant::now()); + info!("{} vehicles to load", state.vehicles.len()); + "ready".into() + } + + pub fn get_vehicle_list(&self) -> String { + self.state().vehicle_ids.pop_front().unwrap_or_else(|| DONE.into()) + } + + pub fn get_vehicle(&self, id: String) -> String { + self.state().vehicles.get_mut(&id).and_then(VecDeque::pop_front).unwrap_or_else(|| ERROR.into()) + } + + pub fn is_vehicles_all_loaded(&self) -> String { + let loaded = self.state().vehicles_requested.is_some_and(|t| t.elapsed() >= VEHICLE_SETUP); + loaded.to_string() + } + + /// Save a vehicle in the background: `data` is fnc_vehicleSingletonSave's `[key, value]` pairs + /// as text, passed on as they are (Minotaur reads them), so new keys need no new extension. + pub fn store_vehicle(&self, id: String, data: String) -> String { + self.save_later(format!("/vehicles/{id}"), json!({"data": data})); + "Store vehicle called".into() + } + + /// Remove a vehicle that no longer exists (deleted, a static weapon packed up), in the same + /// background queue as the saves, so it comes after any save still waiting. + pub fn remove_vehicle(&self, id: String) -> String { + self.save_later(format!("/vehicles/{id}/remove"), json!({})); + "Remove vehicle called".into() + } +} + +/// "TAC" and ten random letters (Apollo's generateUniqueID), for new persistent objects. +pub fn generate_unique_id() -> String { + const LETTERS: &[u8] = b"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; + let nanos = SystemTime::now().duration_since(SystemTime::UNIX_EPOCH).map(|d| d.as_nanos()).unwrap_or(0); + let mut id = String::from("TAC"); + for i in 0..10u32 { + let mut hasher = RandomState::new().build_hasher(); + hasher.write_u128(nanos); + hasher.write_u32(i); + id.push(LETTERS[(hasher.finish() % LETTERS.len() as u64) as usize] as char); + } + id +} + +#[cfg(test)] +mod tests { + use super::*; + use std::sync::Mutex as StdMutex; + + #[derive(Default)] + struct Fake { + calls: StdMutex>, + replies: StdMutex>>, + } + + impl Fake { + fn reply(self, path: &str, reply: Result<&str, &str>) -> Self { + self.replies.lock().unwrap().insert(path.into(), reply.map(String::from).map_err(String::from)); + self + } + } + + impl Backend for Arc { + fn get(&self, path: &str) -> Result { + self.calls.lock().unwrap().push((format!("GET {path}"), Value::Null)); + self.replies.lock().unwrap().get(path).cloned().unwrap_or(Err("404".into())) + } + fn post(&self, path: &str, body: &Value) -> Result { + self.calls.lock().unwrap().push((format!("POST {path}"), body.clone())); + self.replies.lock().unwrap().get(path).cloned().unwrap_or(Ok("done".into())) + } + } + + fn handler(fake: Fake) -> (Handler>, Arc) { + let fake = Arc::new(fake); + (Handler::new(Arc::clone(&fake)), fake) + } + + fn wait_for_calls(fake: &Fake, n: usize) -> Vec<(String, Value)> { + for _ in 0..200 { + if fake.calls.lock().unwrap().len() >= n { + break; + } + thread::sleep(Duration::from_millis(5)); + } + fake.calls.lock().unwrap().clone() + } + + fn s(v: &str) -> String { + v.to_string() + } + + #[test] + fn saving_waits_for_the_load() { + let (h, fake) = handler(Fake::default()); + let save = |h: &Handler>| { + h.store_infantry(s("save"), s("765"), s("Jon"), s("[1,2,3]"), s("90"), s("[]"), s(""), s("[]")) + }; + assert_eq!(h.store_infantry(s("validate"), s("765"), s(""), s(""), s(""), s(""), s(""), s("")), "success"); + assert_eq!(h.store_infantry(s("save"), s(""), s(""), s(""), s(""), s(""), s(""), s("")), "rejected"); + assert_eq!(save(&h), "terminated"); // never loaded here + assert_eq!(save(&h), "rejected"); + assert_eq!(save(&h), "terminated"); // third attempt + assert_eq!(h.infantry_loaded(s("765")), "done"); + assert_eq!(save(&h), "completed"); + let calls = wait_for_calls(&fake, 1); + assert_eq!(calls[0].0, "POST /players/765"); + assert_eq!(calls[0].1["position"], "[1,2,3]"); + assert_eq!(h.player_died(s("765"), s(""), s(""), s("")), "done"); + assert_eq!(save(&h), "rejected"); // dead: waits for the next load + } + + #[test] + fn locker_queue() { + let (h, fake) = handler(Fake::default().reply("/locker/765", Ok(r#"["_container addItemCargoGlobal [\"x\",1];"]"#))); + assert_eq!(h.locker_action(s("remove"), s("765"), s("x"), s(""), s("1"), s("false"), s("[12,3]")), "ready"); + assert_eq!(fake.calls.lock().unwrap()[0].1["partial"], "[12,3]"); + assert_eq!(h.retrieve_locker_queue(s("765")), "_container addItemCargoGlobal [\"x\",1];"); + assert_eq!(h.retrieve_locker_queue(s("765")), "done"); + assert_eq!(h.retrieve_locker_queue(s("765")), "error"); + let (h, _) = handler(Fake::default().reply("/locker/765", Err("409: error"))); + assert_eq!(h.locker_action(s("put"), s("765"), s("x"), s("x"), s("1"), s("false"), s("[12]")), "error"); + } + + #[test] + fn died_and_bodybag() { + let (h, fake) = handler(Fake::default().reply("/players/765/died", Ok("done")) + .reply("/bodybags/765", Ok(r#"["ok","Jon",2,[]]"#))); + assert_eq!(h.player_died(s("765"), s("765-20261114"), s("[[],[]]"), s(r#"[["earplugs",true]]"#)), "done"); + assert_eq!(fake.calls.lock().unwrap()[0].1["death_key"], "765-20261114"); + assert_eq!(fake.calls.lock().unwrap()[0].1["loadout"], "[[],[]]"); + assert_eq!(fake.calls.lock().unwrap()[0].1["variables"], r#"[["earplugs",true]]"#); + assert_eq!(h.bodybag_return(s("765"), s("765-20261114"), s(r#"[["x",2]]"#)), r#"["ok","Jon",2,[]]"#); + assert_eq!(fake.calls.lock().unwrap()[1].1["contents"], r#"[["x",2]]"#); + let (h, _) = handler(Fake::default().reply("/bodybags/765", Err("400: error"))); + assert_eq!(h.bodybag_return(s("765"), s("k"), s("[")), "error"); + } + + #[test] + fn kit_queue() { + let (h, fake) = handler(Fake::default().reply("/kits/765", Ok(r#"["a;", "b;"]"#))); + assert_eq!(h.locker_take_kit(s("12"), s("765")), "ready"); + assert_eq!(fake.calls.lock().unwrap()[0].1["kit"], "12"); + assert_eq!(h.retrieve_locker_queue(s("765")), "a;"); + assert_eq!(h.retrieve_locker_queue(s("765")), "b;"); + assert_eq!(h.retrieve_locker_queue(s("765")), "done"); + let (h, _) = handler(Fake::default().reply("/kits/765", Ok("[]"))); + assert_eq!(h.locker_take_kit(s("12"), s("765")), "ready"); // nothing in the locker: just done + assert_eq!(h.retrieve_locker_queue(s("765")), "done"); + let (h, _) = handler(Fake::default().reply("/kits/765", Err("409: error"))); + assert_eq!(h.locker_take_kit(s("12"), s("765")), "error"); + } + + #[test] + fn vehicles() { + let (h, _) = handler(Fake::default().reply("/vehicles", Ok(r#"{"TACa": ["TACa setFuel 1.0;"], "TACb": []}"#))); + assert_eq!(h.is_vehicles_all_loaded(), "false"); + assert_eq!(h.retrieve_all_vehicles(), "ready"); + let mut ids = vec![h.get_vehicle_list(), h.get_vehicle_list()]; + ids.sort(); + assert_eq!(ids, ["TACa", "TACb"]); + assert_eq!(h.get_vehicle_list(), "done"); + assert_eq!(h.get_vehicle(s("TACa")), "TACa setFuel 1.0;"); + assert_eq!(h.get_vehicle(s("TACa")), "done"); + assert_eq!(h.get_vehicle(s("TACb")), "done"); + assert_eq!(h.get_vehicle(s("TACx")), "error"); + let (h, _) = handler(Fake::default()); + assert_eq!(h.retrieve_all_vehicles(), "error"); + } + + #[test] + fn vehicle_save_and_removal_are_sent_in_the_background_in_order() { + let (h, fake) = handler(Fake::default()); + let data = r#"[["type","B_MRAP_01_F"],["ace_cargo",["ACE_Wheel"]]]"#; + assert_eq!(h.store_vehicle(s("TACa"), s(data)), "Store vehicle called"); + assert_eq!(h.remove_vehicle(s("TACa")), "Remove vehicle called"); + let calls = wait_for_calls(&fake, 2); + assert_eq!(calls[0].0, "POST /vehicles/TACa"); + assert_eq!(calls[0].1, json!({"data": data})); + assert_eq!(calls[1], ("POST /vehicles/TACa/remove".into(), json!({}))); + } + + #[test] + fn unique_ids() { + let id = generate_unique_id(); + assert_eq!(id.len(), 13); + assert!(id.starts_with("TAC") && id[3..].chars().all(|c| c.is_ascii_alphabetic())); + assert_ne!(generate_unique_id(), generate_unique_id()); + } +} diff --git a/extensions/apollo-server/src/lib.rs b/extensions/apollo-server/src/lib.rs new file mode 100644 index 000000000..f8425da3a --- /dev/null +++ b/extensions/apollo-server/src/lib.rs @@ -0,0 +1,164 @@ +//! Apollo Server: the game server's side of Chronos persistence (players, vehicles, lockers), +//! talking to Minotaur's Apollo API. The commands keep Apollo's names and replies. +//! +//! Settings, from the environment (the server runs in Docker): `APOLLO_SERVER_TOKEN` (from the +//! website's admin, Chronos · Apollo › Game servers), `APOLLO_SERVER_LIVE=true` on the live server +//! (every other server uses the development website), and `APOLLO_LIVE_URL` / `APOLLO_DEV_URL` +//! only if the live / development website isn't the usual one; see backend::Config. + +use std::fs::{create_dir_all, File}; +use std::path::Path; +use std::sync::OnceLock; + +use arma_rs::{arma, Extension}; +use log::{info, LevelFilter}; +use simplelog::{Config as LogConfig, WriteLogger}; + +pub mod backend; +pub mod handler; + +use backend::{Config, Http}; +use handler::Handler; + +const LOG_PATH: &str = "./logs/tac_apollo_server.log"; + +static HANDLER: OnceLock> = OnceLock::new(); +static LIVE: OnceLock = OnceLock::new(); + +fn handler() -> &'static Handler { + HANDLER.get_or_init(|| { + let config = Config::load(); + info!("Minotaur Apollo API at {}{}", config.url, if config.token.is_empty() { " (no token set!)" } else { "" }); + let _ = LIVE.set(config.live); + Handler::new(Http::new(config)) + }) +} + +#[arma] +pub fn init() -> Extension { + let log_path = Path::new(LOG_PATH); + if create_dir_all(log_path.parent().unwrap()).is_ok() + && let Ok(file) = File::create(log_path) + { + let _ = WriteLogger::init(LevelFilter::Info, LogConfig::default(), file); + } + Extension::build() + .version(env!("CARGO_PKG_VERSION").to_string()) + .command("version", version) + .command("getApi", get_api) + .command("resetServer", reset_server) + .command("storeInfantry", store_infantry) + .command("infantryLoaded", infantry_loaded) + .command("playerDied", player_died) + .command("lockerAction", locker_action) + .command("lockerTakeKit", locker_take_kit) + .command("bodybagReturn", bodybag_return) + .command("retrieveLockerQueue", retrieve_locker_queue) + .command("generateUniqueID", generate_unique_id) + .command("retrieveAllVehicles", retrieve_all_vehicles) + .command("getVehicleList", get_vehicle_list) + .command("isVehiclesAllLoaded", is_vehicles_all_loaded) + .command("getVehicle", get_vehicle) + .command("storeVehicle", store_vehicle) + .command("removeVehicle", remove_vehicle) + .finish() +} + +pub fn version() -> &'static str { + env!("CARGO_PKG_VERSION") +} + +/// "live" or "dev": the website this server uses, which players' apollo-client then uses too. +fn get_api() -> &'static str { + handler(); + if LIVE.get().copied().unwrap_or(false) { "live" } else { "dev" } +} + +fn reset_server(players: String, vehicles: String, server: String, map: String, mission: String) -> String { + handler().reset_server(players, vehicles, server, map, mission) +} + +#[allow(clippy::too_many_arguments)] +fn store_infantry( + kind: String, id: String, name: String, position: String, direction: String, loadout: String, weapon: String, + variables: String, +) -> String { + handler().store_infantry(kind, id, name, position, direction, loadout, weapon, variables) +} + +fn infantry_loaded(id: String) -> String { + handler().infantry_loaded(id) +} + +fn player_died(id: String, death_key: String, loadout: String, variables: String) -> String { + handler().player_died(id, death_key, loadout, variables) +} + +fn bodybag_return(id: String, death_key: String, contents: String) -> String { + handler().bodybag_return(id, death_key, contents) +} + +fn locker_action( + action: String, id: String, item: String, box_class: String, quantity: String, keep_magazines: String, + partial: String, +) -> String { + handler().locker_action(action, id, item, box_class, quantity, keep_magazines, partial) +} + +fn locker_take_kit(kit: String, id: String) -> String { + handler().locker_take_kit(kit, id) +} + +fn retrieve_locker_queue(id: String) -> String { + handler().retrieve_locker_queue(id) +} + +fn generate_unique_id() -> String { + handler::generate_unique_id() +} + +fn retrieve_all_vehicles() -> String { + handler().retrieve_all_vehicles() +} + +fn get_vehicle_list() -> String { + handler().get_vehicle_list() +} + +fn is_vehicles_all_loaded() -> String { + handler().is_vehicles_all_loaded() +} + +fn get_vehicle(id: String) -> String { + handler().get_vehicle(id) +} + +fn store_vehicle(id: String, data: String) -> String { + handler().store_vehicle(id, data) +} + +fn remove_vehicle(id: String) -> String { + handler().remove_vehicle(id) +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn commands_take_arma_arguments() { + let extension = init().testing(); + let (version, _) = extension.call("version", None); + assert_eq!(version, env!("CARGO_PKG_VERSION")); + let (api, _) = extension.call("getApi", None); + assert_eq!(api, if std::env::var("APOLLO_SERVER_LIVE").is_ok_and(|v| v == "true") { "live" } else { "dev" }); + let (id, code) = extension.call("generateUniqueID", None); + assert_eq!((id.len(), code), (13, 0)); + // Unknown player: no request is made, so this works without Minotaur. + let args = ["\"save\"", "\"765\"", "\"Jon\"", "\"[1,2,3]\"", "\"90\"", "\"[]\"", "\"\"", "\"[]\""]; + let (reply, code) = extension.call("storeInfantry", Some(args.iter().map(|a| a.to_string()).collect())); + assert_eq!((reply.as_str(), code), ("terminated", 0)); + let (reply, _) = extension.call("retrieveLockerQueue", Some(vec!["\"765\"".into()])); + assert_eq!(reply, "error"); + } +} diff --git a/extensions/apollo-server/tests/minotaur.rs b/extensions/apollo-server/tests/minotaur.rs new file mode 100644 index 000000000..1a1389f9c --- /dev/null +++ b/extensions/apollo-server/tests/minotaur.rs @@ -0,0 +1,74 @@ +//! Against a running Minotaur (not run by default): +//! +//! APOLLO_DEV_URL=http://localhost:8000 APOLLO_SERVER_TOKEN=... \ +//! APOLLO_TEST_PLAYER= APOLLO_TEST_ITEM= \ +//! cargo test -p apollo-server-rs --test minotaur -- --ignored +//! +//! Use the development website (or a local one): it changes that player's saved state and locker. + +use std::thread::sleep; +use std::time::Duration; + +use apollo_server::backend::{Backend, Config, Http}; +use apollo_server::handler::{generate_unique_id, Handler}; + +fn env(name: &str) -> String { + std::env::var(name).unwrap_or_else(|_| panic!("{name} not set")) +} + +#[test] +#[ignore] +fn round_trip() { + let player = env("APOLLO_TEST_PLAYER"); + let item = env("APOLLO_TEST_ITEM"); + let config = Config::load(); + let check = Http::new(Config::load()); + let h = Handler::new(Http::new(config)); + let s = |v: &str| v.to_string(); + + let mission = generate_unique_id(); + assert_eq!(h.reset_server(s("true"), s("true"), s("Test"), s("Altis"), mission.clone()), "done"); + assert_eq!(h.reset_server(s("true"), s("true"), s("Test"), s("Altis"), mission), "none"); + + let loadout = r#"[[],[],[],["U_B_CombatUniform_mcam",[["FirstAidKit",2]]],[],[],"H_HelmetB","",[],["ItemMap","","","","",""]]"#; + assert_eq!(h.infantry_loaded(player.clone()), "done"); + assert_eq!(h.store_infantry(s("save"), player.clone(), s("Test"), s("[1,2,3]"), s("45"), s(loadout), s(""), s("[]")), "completed"); + sleep(Duration::from_millis(500)); // sent in the background + + assert_eq!(h.locker_action(s("put"), player.clone(), item.clone(), item.clone(), s("2"), s("false"), s("")), "ready"); + assert_eq!(h.retrieve_locker_queue(player.clone()), "done"); // the game removes what it stashed + assert_eq!(h.locker_action(s("remove"), player.clone(), item.clone(), s(""), s("2"), s("false"), s("")), "ready"); + let entry = h.retrieve_locker_queue(player.clone()); // data: [class, count, rounds] + assert_eq!(entry.to_lowercase(), format!("[\"{}\",2,-1]", item.to_lowercase()), "{entry}"); + assert_eq!(h.locker_action(s("remove"), player.clone(), item, s(""), s("1"), s("false"), s("")), "error"); // empty now + + // What fnc_vehicleSingletonSave sends: [key, value] pairs. + let id = generate_unique_id(); + let removed = generate_unique_id(); + let data = concat!( + r#"[["position",[100,200,5]],["direction",90],["vector",[[0,1,0],[0,0,1]]],["type","B_MRAP_01_F"],"#, + r#"["class","Car"],["name","Hunter"],["alive",true],["damage",0.1],["hitpoints",[["HitEngine",0]]],"#, + r#"["fuel",1],["locked",0],["customization",[["Black",1],[]]],"#, + r#"["cargo",[["FirstAidKit"],[["SmokeShell",1]],[],[]]],["ace_cargo",["ACE_Wheel"]]]"#, + ); + h.store_vehicle(id.clone(), s(data)); + h.store_vehicle(removed.clone(), s(data)); + h.remove_vehicle(removed.clone()); + sleep(Duration::from_millis(500)); + assert_eq!(h.retrieve_all_vehicles(), "ready"); + let mut ids = vec![]; + loop { + let next = h.get_vehicle_list(); + if next == "done" { break; } + ids.push(next); + } + assert!(ids.contains(&id)); + assert!(!ids.contains(&removed)); + let first = h.get_vehicle(id.clone()); // data, in pieces the game joins + assert!(first.starts_with(r#"[["type","B_MRAP_01_F"],"#), "{first}"); + assert!(first.contains(r#"["customization",[["Black",1],[]]]"#), "{first}"); + assert_eq!(h.get_vehicle(id.clone()), "done"); + assert_eq!(h.player_died(player.clone(), s(""), s(""), s(r#"[["earplugs",true]]"#)), "done"); + // The token is still accepted, and the removed vehicle stays gone. + assert!(!check.get("/vehicles").unwrap().contains(&removed)); +}