Skip to content

Commit

Permalink
fixing 2 bugs and migration issue
Browse files Browse the repository at this point in the history
attempting to fix github issue #164
attempting to fix github issue #172
fixing migration script issue with the 0.4.12 migration where it would chew up peoples RAM and break their computers. made it do +-1000 tiles instead of +-15000 tiles for each surface, and each force.
  • Loading branch information
kyranf committed Oct 18, 2021
1 parent 5aaec4c commit 081e86e
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 7 deletions.
6 changes: 5 additions & 1 deletion Changelist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,8 @@ changes from 0.4.8 to 0.4.9:
- added Russian language translations thanks to Varoga on Github
- added migration script to detect and add all droid units to script-tracked array
- added AI distraction custom commands for selecting nearest target instead of random target (overriding default ai behaviour of biters) thanks to Klonan


changes from 0.4.12 to 0.4.13:
- attempting to fix github issue #164
- attempting to fix github issue #172
- fixing migration script issue with the 0.4.12 migration where it would chew up peoples RAM and break their computers. made it do +-1000 tiles instead of +-15000 tiles for each surface, and each force.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Robot Army mod for Factorio V1.1+

## Version
0.4.12,
Known to be compatible with Factorio v1.1.38. Requires at least v1.1.38 due to mod script API features used.
0.4.13,
Known to be compatible with Factorio v1.1.42. Requires at least v1.1.38 due to mod script API features used.


## Description
Expand Down
2 changes: 1 addition & 1 deletion info.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{

"name": "robotarmy",
"version": "0.4.12",
"version": "0.4.13",
"title": "Robot Army",
"author": "Kyranzor",
"contact": "[email protected]",
Expand Down
8 changes: 6 additions & 2 deletions migrations/robotarmy_0.4.12.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,18 @@ end


local numUnitsAdded = 0;


Game.print_all(string.format("Robot army processing %d forces, in %d surfaces", #game.forces, #game.surfaces))

--ensure all force-specific tables and researches are handled/created
for i, force_ in pairs(game.forces) do
-- for each force
for j, surface_ in pairs(game.surfaces) do

-- get the list of units
-- for each unit in the list, check the type and name is what we want, add to the list.
local units = surface_.find_units({area = {{-15000, -15000},{15000, 15000}}, force = force_.name, condition = "same"})
local units = surface_.find_units({area = {{-1000, -1000},{1000, 1000}}, force = force_.name, condition = "same"})
for _, unitFound in pairs(units) do
if names[unitFound.name] then
if unitFound.valid then
Expand All @@ -37,4 +41,4 @@ for i, force_ in pairs(game.forces) do
end
end

Game.print_all(string.format("units added in migration script: %d", numUnitsAdded))
Game.print_all(string.format("units added in robot army migration script: %d", numUnitsAdded))
14 changes: 13 additions & 1 deletion robolib/Squad.lua
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,8 @@ end


function shouldHunt(squad)
if not squad then return false end

return (squad.command.type ~= commands.follow) and (squad.numMembers >= getSquadHuntSize(squad.force)
or (squad.command.type == commands.hunt and squad.numMembers > getSquadRetreatSize(squad.force)))
end
Expand Down Expand Up @@ -623,10 +625,20 @@ function validateSquadIntegrity(squad)
squad.unitGroupFailureTick = game.tick
end


--do another check for the unit group being valid before doing the next steps
if not squad.unitGroup or not squad.unitGroup.valid then
squad.unitGroup = recreateUnitGroupForSquad(squad, pos)
end

if not squad.unitGroup or not squad.unitGroup.valid then
return nil, false --give up
end

-- check each droid individually to confirm that it is part of the unitGroup
for key, soldier in pairs(squad.members) do
if soldier and soldier.valid and (soldier.force ~= squad.unitGroup.force) then
soldier.destroy()
soldier.destroy() --destroy the unit if they are in the squad but of the wrong force... maybe this needs more finesse, if a mod has some kind of AOE2 monk team-changing ability?
else
if not table.contains(squad.unitGroup.members, soldier) then
if not recreatedUG then
Expand Down

0 comments on commit 081e86e

Please sign in to comment.