Refactorio / RedMew

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

Add players' logistic requests synch between instances #1401

Closed RedRafe closed 6 months ago

RedRafe commented 6 months ago

Just like the quick-bar module, allows saving/loading/deleting of the player's logistic requests between instances, accessing the data on our server.

Additionally, since the logi bars are not enabled on new games until logibots are researched, upon finishing the research of the logi tech, server will attempt at loading each player's data

(I reordered the color file alphabetically, but no changes there)

RedRafe commented 6 months ago

Resolved all. There's only one minor inconvenience left:

logistic requests are enabled when logistcs is researched. I do apply saved data at the research completion & for all players joining for the first time after that. But if a player had already joined & left, they will have to manually say /logistic-requests-load upon rejoins to apply that. Call it good, or add more logic?

Honestly I didnt want to re-apply on player joined cuz it may apply for those who already did and override some changes, but, I could always add some more logic and keep track of players that already got initialized to filter out those & make it automatic for everyone

grilledham commented 6 months ago

logistic requests are enabled when logistcs is researched. I do apply saved data at the research completion & for all players joining for the first time after that. But if a player had already joined & left, they will have to manually say /logistic-requests-load upon rejoins to apply that. Call it good, or add more logic?

That's an annoying edge case. I think it probably is worth fixing. I think keeping track of players that have been initialized as you suggest would be the way to go.

RedRafe commented 6 months ago

Updated the code, I think I got it one step further this round:

  1. I've added a bit of overhead with Force shenanigans, based on this: Force::character_logistic_requests

    true if character requester logistics is enabled.

The new logic tracks initialized forces as well, and only allows setting bar based on that param:

  1. I've moved the player_initialized logic outside the simple set_bar_callback as you suggested, so other functions will be responsible to call a set bars only when it actually possible (based on their own conditions). but players are still able to call it manually whenever they want.

An additional message is displayed (in manual mode) if server = true AND logistics = false, so players are notified their attempt at setting bars didn't go through cuz their force hasnt unlocked logistics yet