Ради вашего удобства наш сайт использует cookies! Узнать больше! Мы используем cookies

VehicleSetFix — 42.17 Compatibility Patch

VehicleSetFix — 42.17 Compatibility Patch ⚠ Deprecation Notice This mod no longer provides a reliable fix and [b]should be removed from your mod list[/b]. The two approaches that could intercept [i]getVehicles():get(i)[/i] transparently both turned out to be incompatible with the game: [list] [*] [b]Patching IsoCell at the class level[/b] — not possible because [i]IsoCell[/i] is not registered as a Lua-accessible table in 42.17. [*] [b]Wrapping the [i]getCell()[/i] global[/b] — breaks vanilla map interaction. Any i that passes [i]getCell()[/i] as an argument to a Java constructor (building furniture, placing objects, constructing traps, etc.) receives a Lua proxy table instead of the expected [i]IsoCell[/i] object, causing actions to consume materials without placing anything. [/list] The only remaining approach — patching individual mod methods case by case — is not a sustainable solution and does not cover mods whose affected functions are defined as locals. [b]The correct fix is for each affected mod to update its iteration pattern from [i]get(i)[/i] to [i]iterator()[/i].[/b] If a mod in your list is still crashing with [i]"Object tried to call nil"[/i] on a [i]getVehicles()[/i] call, contact the mod author and link them to this page. [hr] [b]Fixes vehicle mod crashes introduced by the 42.17 update.[/b] The Problem In version [b]42.17[/b], Project Zomboid changed the internal return type of [i]IsoCell.getVehicles()[/i] from [i]ArrayList[/i] to [i]Set[/i]. This silently breaks any mod written for 42.16 that iterates vehicles using the [i]vehicles:get(i)[/i] pattern, since [i]Set[/i] has no such method. The result is an [i]"Object tried to call nil"[/i] crash when interacting with vehicles — opening the radial menu, refueling, etc. What This Mod Does Intercepts [i]getVehicles()[/i] calls and returns a proxy that adds [i]get(index)[/i] support, without breaking mods already updated for 42.17 that use [i]iterator()[/i]. No files from other mods are modified. How It Works The mod attempts three strategies in order, stopping at the first that succeeds. [b]Strategy 1 — IsoCell class table patch[/b] Overrides [i]IsoCell.getVehicles[/i] at the class level. Every call to [i]getVehicles()[/i] from any mod, regardless of how the cell was obtained, returns the proxy. This is the safest and most complete approach. The console will log [i]Strategy 1: patched IsoCell.getVehicles[/i] if successful. [b]Strategy 2 — getCell() global override[/b] Falls back to wrapping the [i]getCell()[/i] Lua global if the class table is not accessible. Covers mods that call [i]getCell():getVehicles()[/i] directly (e.g. RV Interior server-side). Does [b]not[/b] cover calls made via [i]playerObj:getCell():getVehicles()[/i]. [b]Strategy 3 — FindVehicleGas replacement[/b] If strategies 1 and 2 are insufficient, replaces the [i]FindVehicleGas[/i] global defined by PZK Car Pack with an iterator-based equivalent. Functionally identical to the original. Impact on Correctly Updated Mods Mods already written for 42.17 that use [i]iterator()[/i] are [b]not affected[/b]. The proxy returned by the patched [i]getVehicles()[/i] forwards all unknown method calls to the underlying Java Set via [i]__index[/i], so [i]size()[/i], [i]iterator()[/i], [i]isEmpty()[/i], [i]contains()[/i] and any other Set method continue to work normally. The one exception is [i]pairs(vehicleList)[/i] — Lua 5.1 has no [i]__pairs[/i] metamethod, so iterating the proxy with [i]pairs()[/i] will not yield vehicles. However, [i]pairs()[/i] was never a correct way to iterate a Java collection and no well-written 42.17 mod should rely on it. Known Fixed Mods [list] [*] [b]PZK Vanilla Plus Car Pack[/b] — crash in [i]FindVehicleGas[/i] when opening the vehicle menu [*] [b]PROJECT RV Interior[/b] — crash on saves migrated from 42.16 [/list] Other mods affected by the same change are also covered automatically. Compatibility [list] [*] Requires [b]42.17+[/b]. On 42.16 the mod detects the original ArrayList and does nothing. [*] Compatible with multiplayer (client and server). [*] Should be loaded [b]before[/b] the mods it fixes in the load order. [*] Does not affect existing saves. [/list] For Mod Authors If your mod iterates vehicles and broke in 42.17, the correct pattern is now: local it = cell:getVehicles():iterator() while it:hasNext() do local vehicle = it:next() -- ... end This mod is a temporary compatibility shim while affected mods are updated by their authors. [hr] Workshop ID: 3711625535 Mod ID: VehicleSetFix