Skip to content

Commit

Permalink
Removes default empty state to be set
Browse files Browse the repository at this point in the history
* This used to break moving new machine without state
  • Loading branch information
pschoffer committed Mar 30, 2018
1 parent f0b71a7 commit 2fa6e3f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion CorsixTH/Lua/dialogs/place_objects.lua
Expand Up @@ -510,7 +510,7 @@ function UIPlaceObjects:placeObject(dont_close_if_empty)
self.world:prepareFootprintTilesForBuild(object_footprint, self.object_cell_x, self.object_cell_y)
real_obj = self.world:newObject(object.object.id,
self.object_cell_x, self.object_cell_y, self.object_orientation)
real_obj:setState(object.state or {})
real_obj:setState(object.state)
end
if room then
room.objects[real_obj] = true
Expand Down
12 changes: 12 additions & 0 deletions CorsixTH/Luatest/spec/entities/machine_spec.lua
Expand Up @@ -61,4 +61,16 @@ describe("object.lua: ", function()
assert.are.equal(machine1.times_used, machine2.times_used)
assert.are.equal(machine1.total_usage, machine2.total_usage)
end)
it("setting null state doesn't clear values", function()
local machine = createMachineWithFakeInput()
machine:updateDynamicInfo()
assert.are.equal(1, machine.times_used)
assert.are.equal(1, machine.total_usage)
machine:setState(nil)
assert.are.equal(1, machine.times_used)
assert.are.equal(1, machine.total_usage)
end)
end)

0 comments on commit 2fa6e3f

Please sign in to comment.