MultiServer: add !collect and collect_mode

CommonClient: make missing and checked location lookups faster
FactorioClient: implement reverse grant technologies for collect/forfeit/coop
This commit is contained in:
Fabian Dill
2021-10-18 22:58:29 +02:00
parent 66e198cbb6
commit 34eba2655e
9 changed files with 116 additions and 21 deletions

View File

@@ -57,6 +57,7 @@ function on_force_created(event)
local data = {}
data['earned_samples'] = {{ dict_to_lua(starting_items) }}
data["victory"] = 0
data["checked_technologies"] = {}
global.forcedata[event.force] = data
{%- if silo == 2 %}
check_spawn_silo(force)
@@ -200,7 +201,10 @@ end)
script.on_event(defines.events.on_research_finished, function(event)
local technology = event.research
if technology.researched and string.find(technology.name, "ap%-") == 1 then
dumpInfo(technology.force) --is sendable
-- check if it came from the server anyway, then we don't need to double send.
if global.forcedata[technology.force.name]["checked_technologies"][technology.name] ~= nil then
dumpInfo(technology.force) --is sendable
end
else
if FREE_SAMPLES == 0 then
return -- Nothing else to do
@@ -389,6 +393,7 @@ commands.add_command("ap-get-technology", "Grant a technology, used by the Archi
if index == -1 then -- for coop sync and restoring from an older savegame
tech = force.technologies[item_name]
if tech.researched ~= true then
global.forcedata[force.name]["checked_technologies"][tech.name] = 1 -- mark as don't send again
game.print({"", "Received [technology=" .. tech.name .. "] as it is already checked."})
game.play_sound({path="utility/research_completed"})
tech.researched = true