Territory Claim


You will have to pay for territory in this planet! Each terrain lot has a price you have to pay in items. Compatible with other mods that creates teams forces for pvp/pve. Now with terrain dispute.

Content
2 months ago
0.17 - 2.0
1.84K
Environment

g Crash with Machine Upgrades mod

20 days ago
(updated 20 days ago)

Hi, a server I'm playing on runs this mod with https://mods.factorio.com/mod/machine-upgrades together. It's observes that sometimes placing a crusher crashes the server, with this stack trace:

 239.581 Error MainLoop.cpp:1468: Exception at tick 7228358: The mod Machine Upgrades (0.69.19) caused a non-recoverable error.
Please report this error to the mod author.

Error while running event machine-upgrades::on_built_entity (ID 6)
__machine-upgrades__/script/beacon-manager.lua:50: 

[color=255,125,0][font=default-semibold]This crash is caused by an incompatibility from a mod with Machine Upgrades. Please identify which mod causes the crash, and send that mod's author this report with your save file. Do not send to the developer of Machine Upgrades/Rubia.[/font][/color]

While you wait for a fix, the mod setting 'Disable Machine Upgrades' will avoid this crash, but the mod will not function!

----------------
Crash Report for the modder:
This crash happened when Machine Upgrades created a 'mupgrade-beacon', immediately asserted that it was valid, but it was destroyed (likely in the event callback of on_built_entity). This mupgrade-beacon's construction was triggered by the placement of the following entity: crusher
stack traceback:
    [C]: in function 'assert'
    __machine-upgrades__/script/beacon-manager.lua:50: in function 'try_get_beacon'
    __machine-upgrades__/script/beacon-manager.lua:62: in function 'update_entity_moduling'
    __machine-upgrades__/script/beacon-manager.lua:122: in function 'to_invoke'
    __machine-upgrades__/script/entity-modifier.lua:238: in function 'fun'
    __machine-upgrades__/script/event-lib.lua:198: in function <__machine-upgrades__/script/event-lib.lua:178>

The crashing lines look like:

    --Does not already exist. Make one, and link it!
    local new_beacon = entity.surface.create_entity{
        name = "mupgrade-beacon",
        position = center,--entity.position,
        force = "neutral",--entity.force_index,
        raise_built = true,
    }

    --error(BEACON_DESTROYED_ERROR_MSG .. entity.name) --For testing printing
    assert(new_beacon, BEACON_DESTROYED_ERROR_MSG .. entity.name)

(assertion fail here)

I located the removal of mupgrade-beacon entity to this mod's event handler, in these lines:

function On_Built(event)
[...]
local tag = get_chunk_tag_by_pos(surface,position)
if storage.claimed_chunks[tag] and (storage.claimed_chunks[tag]~=force.name and storage.claimed_chunks[tag]~='neutral') then
    if type=='entity-ghost' or type=='tile-ghost' then entity.destroy() return end
    forbidden_construction_give_back_item(event, {"cant-build-not-yours"}, color)

where

function forbidden_construction_give_back_item(event, message, color)
[...]
    if entity.valid then entity.destroy() end           

It was initially surprising to me how I was able to place other buildings, but adding a bit of instrumentation it shows storage.claimed_chunks[tag]~=force.name happened, where storage.claimed_chunks[tag] is player and force.name is neutral.

Perhaps entities placed by neutral force should be ignored by this mod? Or is this a bug in mupgrade to use neutral force instead of player force?

New response