Refactorio / RedMew

The RedMew scenario code for Factorio.
https://redmew.com
GNU General Public License v3.0
177 stars 80 forks source link

Updates/frontier v4 #1426

Closed RedRafe closed 3 months ago

RedRafe commented 3 months ago

Changes

Issues

These functions are pretty heavy to execute and are the ones triggering in this order when restarting, causing the bottleneck:

Main.on_game_finished(), Main.on_game_started() and especially Main.reveal_spawn_area():

function Main.reveal_spawn_area()
  local surface = RS.get_surface()
  local far_left, far_right = this.kraken_distance + this.left_boundary * 32 + 1, this.right_boundary * 32 + this.wall_width
  surface.request_to_generate_chunks({ x = 0, y = 0 }, math.ceil(math_max(far_left, far_right, this.height * 32) / 32))
  surface.force_generate_chunk_requests()

  Main.compute_silo_coordinates(this.silo_starting_x + math_random(100))
  Main.move_silo()
  Terrain.create_wall(this.right_boundary * 32, this.wall_width)

  game.forces.player.chart(surface, { { -far_left - 32, -this.height * 16 }, { far_right + 32, this.height * 16 } })
end

I've increased the gap between the surface clear and the new map regen, but wont probably be enough. Maybe I should offload the map reveal to task manager and have it consume it over multiple ticks? Dunno if you have other suggestion on the matter. S30 testing has a local save frontier-zombie... just ~30s prio map reset if you wanna take a look

Random market with item-to-item trade offers Screenshot from 2024-08-15 19-58-15

Spawn shop with upgrades Screenshot from 2024-08-16 17-22-04

Restart issue Screenshot from 2024-08-17 06-45-57

grilledham commented 3 months ago

For the .png graphics, can we move them to a mod? I'm a little concerned that those assets will increase the size of all save files even for other scenarios. Maybe 100KBs doesn't seem like much now, but I can imagine that you will want to add more later.

RedRafe commented 3 months ago

Thanks! I've postponed terrain gen for so long, it is now time to finally convert it from event-react-driven to the builder system tools (I know you're using it for crash site outposts and my first attempts with it were miserable due to math.random stuff. Hopefully I'll get a better understanding and do a better job this time).

assets -> will move file size -> (I know) I've already divided it multiple sub-modules so when it'll be time to split it I wont have to entangle each part. Only thing holding me back is sharing the global table but I know I'll have to expose it eventually so I'll bite the bullet on this too 😅

RedRafe commented 3 months ago

For surface.clear() I can maybe offload good part of it to task manager and do LuaSurface::delete_chunk(position) on ticks, and then call the clear at T-X_ticks to get rid of any remaining chunks, but I guess clear will do some extra crazy stuff so I'll keep it distant from player's comeback on surface too

RedRafe commented 3 months ago

Yes this can go in, I will PR other parts soon ™️