Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refuel - Add enable setting #7613

Merged
merged 30 commits into from
May 23, 2024
Merged

Conversation

Dystopian
Copy link
Contributor

@Dystopian Dystopian commented Mar 25, 2020

When merged this pull request will:

@jonpas jonpas added this to the 3.14.0 milestone Mar 26, 2020
@jonpas jonpas added the kind/enhancement Release Notes: **IMPROVED:** label Mar 26, 2020
Copy link
Contributor

@PabstMirror PabstMirror left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested in local MP on stratis looking at a map pump [getfuelCargo cursorObject, typeOf cursorObject]
server [0,"Land_FuelStation_Feed_F"]
client [1,"Land_FuelStation_Feed_F"] and can use vanilla refuel
I don't know if setFuelCargo will work on map objects the way we want

@Dystopian
Copy link
Contributor Author

Looks like terrain pumps have local fuel value and they reset it in JIP. I fixed it.

I'm implementing pump locations caching now because _worldCenter nearObjects [_x, _worldSize] is quite long operation on big maps.

@PabstMirror
Copy link
Contributor

_worldSize * sqrt(2) / 2 but I don't think it will help much 😄

I'm still worried about if setFuelCargo will be persistent,
from what I understand map objects can be "streamed" in and out of memory and changes to them may be lost

e.g. setVariable may work initially but might be lost if player moves away from the area

@Dystopian
Copy link
Contributor Author

Dystopian commented Apr 11, 2020

Added pumps locations. I don't own Contact DLC so who wants please try call compile preprocessFileLineNumbers "z\ace\addons\refuel\dev\exportTerrainRefuelPositions.sqf" in Eden Editor console when Livonia is loaded.
Will check if setFuelCargo is persistent. Also will search for workaround for damaged pumps explosion strength.

@Dystopian
Copy link
Contributor Author

Now destroyed refuel vehicles burn much longer - like did in vanilla. I didn't find good enough way to catch deadly hit so I implemented it with HandleDamage and alive on next frame. It doesn't handle 100% but it's good enough.

I'm still worried about if setFuelCargo will be persistent,
from what I understand map objects can be "streamed" in and out of memory and changes to them may be lost

Just checked if setFuelCargo is persistent in 2 hours MP session on Chernarus 2020. No pumps lost their fuel cargo. I won't be able to check it in longer session. Script returns all pumps count on map (should be the same) and array of desynced pumps (should be empty):

private _a = [];
private _c = 0;
{
    _x params ["_class", "_positions"];
    {
        {
            if (0 != getFuelCargo _x) then {
                _a pushBack ASLToAGL getPosASL _x;
            };
            _c = _c + 1;
        } forEach (_x nearObjects [_class, 30]);
    } forEach _positions;
} forEach getArray (configFile >> "ace_refuel_positions" >> worldName);
[_c, _a]

@bux
Copy link
Member

bux commented Apr 21, 2020

I don't own Contact DLC so who wants please try call compile preprocessFileLineNumbers "z\ace\addons\refuel\dev\exportTerrainRefuelPositions.sqf" in Eden Editor console when Livonia is loaded.

    Enoch[] = { /*  Livonia  */
        {"Land_FuelStation_Feed_F", {{10208,2173,0}}},
        {"Land_FuelStation_03_pump_F", {{2008,7365,0},{6259,3949,0}}}
    };

@PabstMirror
Copy link
Contributor

I was curious about another way to get map objects using
[2708,5788,0] nearestObject 65997
which is some kind of terrain builder ID
but doesn't seem to be any better than
[2708,5788,0] nearObjects ["Land_FuelStation_Feed_F", 30];

johnb432 and others added 2 commits March 25, 2024 13:22
- Use hashmaps wherever possible
- Reduced pump search radius by ~30%
- Sorted pumps alphabetically and sorted positions by "smallest" first, for consistency
addons/refuel/Cfg3DEN.hpp Outdated Show resolved Hide resolved
addons/refuel/XEH_postInit.sqf Outdated Show resolved Hide resolved
addons/refuel/XEH_preStart.sqf Outdated Show resolved Hide resolved
addons/refuel/XEH_preStart.sqf Outdated Show resolved Hide resolved
addons/refuel/XEH_preStart.sqf Outdated Show resolved Hide resolved
@LinkIsGrim LinkIsGrim modified the milestones: Ongoing, 3.17.1 Mar 26, 2024
@Dystopian
Copy link
Contributor Author

I've updated Chernarus 2020 config and added some more maps. And because export algo is not ideal I got WRONG COUNT message for Chernarus 2020 and Rosche and INCREASE DISTANCE for Farabad. In all cases I found close placed positions and replaced them with manual position. Thanks @johnb432 for added sorting :)

@johnb432
Copy link
Contributor

johnb432 commented Apr 1, 2024

restore big explosion and long burn of refuel vehicles;

I was testing this. Self-hosted, with a second PC joining as a client.

When the host shot a gas pump on Altis, it would burn long for both host and client. However, when the client shot a pump, it was a long burn for the host but a short one for the client.

@Dystopian
Copy link
Contributor Author

shot a gas pump on Altis

I always tested on Stratis and it worked. But it really doesn't work on Altis. I don't have more ideas how to handle this so I decided to remove that PR part. Also I removed it for vehicles because loop logic becomes too messy without terrain pumps. Maybe it would be implemented somehow in another PR but I don't think from me :-(

@LinkIsGrim LinkIsGrim modified the milestones: 3.17.1, 3.18.0 Apr 4, 2024
Copy link
Contributor

@johnb432 johnb432 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I've tested some, but it could use some more.

@Dystopian
Copy link
Contributor Author

I don't have more ideas

I tried to setFuelCargo 1 in BuildingChanged Mission Event Handler but it doesn't work even in SP.

@johnb432
Copy link
Contributor

johnb432 commented Apr 6, 2024

I tried to setFuelCargo 1 in BuildingChanged Mission Event Handler but it doesn't work even in SP.

Don't bother with trying to find a solution. If you do, it's best to make another PR at this point imo.

Copy link
Contributor

@LinkIsGrim LinkIsGrim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@johnb432 johnb432 merged commit 7c65f85 into acemod:master May 23, 2024
5 checks passed
blake8090 pushed a commit to blake8090/ACE3 that referenced this pull request Aug 18, 2024
* Add enable setting

* Exclude man class init

* Fix multiplayer terrain pump fuel sync

* Add terrain pumps positions

* Add vanilla fuel cargo restoring before destroying

* Add Livonia positions by bux

* Fix terrain pumps destruction

* Improve settings init

* Fix double settings category

* Check enabled var in public functions

* Fix fnc_makeSource

* Handle recent CUP Terrains changes

* Update includes

* Fix issues introduced in acemod#9133

* Change warning

Co-authored-by: johnb432 <58661205+johnb432@users.noreply.github.com>

* Optimisations and cleanup

- Use hashmaps wherever possible
- Reduced pump search radius by ~30%
- Sorted pumps alphabetically and sorted positions by "smallest" first, for consistency

* Add init debug trace

* compileScript in dev

* yoda conditions & DFUNC macro

* Wait until CBA settings are ready

* Update Chernarus 2020 and add more maps configs

* Remove vanilla fuel cargo restoring before destroying

---------

Co-authored-by: johnb432 <58661205+johnb432@users.noreply.github.com>
Co-authored-by: Grim <69561145+LinkIsGrim@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement Release Notes: **IMPROVED:**
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants