Expose GTA CULL zones to client Lua - #5102
Conversation
Relocate GTA's fixed attribute, tunnel, and mirror arrays into bounded MTA-owned storage and adopt vanilla entries into an editable catalog. Reserve native capacity for modified originals so cleanup can always restore them. Centralize mirror enable state and refresh attribute flags before weather processing on MTA's multiplayer path. Tested with Game SA and full client Release|Win32 builds, 304 passing client tests, and in-game attribute and mirror lifecycle checks.
Register the query and mutation functions with ArgumentParser and bind mutations to the calling resource. Restore original zones and remove custom entries when the resource stops or is destroyed. Validate IDs, native flag widths, quantized geometry, and unit mirror normals before publishing changes. Tested with full client Release|Win32 and server Release|x64 builds, 304 passing client tests, invalid-input checks, resource restarts, reconnect cleanup, and custom and vanilla mirror rendering.
|
What do you think about using elements to represent zones? I mean |
Why not especially for custom zones, but what about original GTA zones? Should they also be represented as elements, and what should |
I think default cull zones shouldn't be elements in MTA. Just like default buildings aren't elements, the default water isn't an element, and default objects aren't elements. Following the same principle, only things created by MTA should be represented as MTA elements. |
Summary
This PR expose GTA attribute, tunnel and mirror CULL zones to client Lua:
engineGetCullZonesengineCreateCullZoneengineSetCullZoneengineSetCullZoneEnabledengineRemoveCullZoneengineRestoreCullZoneOriginal zones can be queried, edited, disabled and restored. Resources can also create custom zones, but cannot edit custom zones created by another resource.
Custom zones are removed and original zones are restored when the resource stops.
The GTA CULL arrays are expanded to support custom zones. Invalid zone sizes, flags and mirror normals are rejected.
Motivation
Allow maps and gamemodes to inspect and manage GTA CULL zones from Lua.
Demo
https://www.youtube.com/watch?v=17QrE21uDgM
Test plan
Test resources: mtasa-cull-zones.zip
CRUD and validation
Server:
Client:
The first
/cullstatsgives the vanilla counts./cullinvalidtries invalid geometry and mirror normals on both create and edit; it should returnPASSwithout changing the count./cullvisual all 200displays original and custom zones within 200 units./culltest attribute 8 40creates a 40-unitNO_RAINzone around the player./culledit 0 60moves it to the current position, resizes it to 60 units and removes the flag.With rainy weather, rain should be hidden by the first zone and return after the edit. The zone is then disabled, enabled and deleted.
The final
/cullstatsshould match the first one with no custom zone.Mirrors
Server:
Client:
/mirrorfloor2enters the custom mirror showroom and/mirrorfloorinfoprints the nearest mirror definition and plane. The reflection should disappear and return when toggled./mirrorvanillaenters the original barbershop./cullnearest mirrorselects its original mirror zone, which should disappear and return when disabled and restored./mirrorfloorleavereturns to the previous position.Resource cleanup
Server:
Client:
Server:
Client:
Stopping
cull-mirror-floor-testremoves its custom mirror. The attribute zone is then left active on purpose before restartingcull-zone-test. No custom zone should remain in/cullstatsafter the restart.Resource ownership and capacity
Server:
Client:
Owner A disables and claims one original mirror zone. Owner B checks that it cannot modify this zone, then fills all remaining custom mirror capacity.
Expected with the standard GTA data:
Server:
Client:
Stopping owner A should restore its original zone even while the mirror store
is full.
Expected:
Server:
Client:
Stopping owner B should remove all 191 custom zones and return to the vanilla mirror count.
Checklist