Author Topic: [MOD] Sector Manager  (Read 2363 times)

Laserzwei

  • Sr. Member
  • ****
  • Status:
    Offline
    Posts:
    394
    • View Profile
on: January 13, 2019, 08:33:38 PM
A small proof-of-concept mod to keep a set of sectors loaded, while a player is online.

Features
  • Select the sectors to be kept open yourself.
  • Every player controls its own set of sectors.
  • Easy to use interface.

UI:
Spoiler: show



Note: As a serverowner you might want to set "aliveSectorsPerPlayer" to 1. As this mod will simply ignore that. Use the config file to set the max number of allowed sectors.

Install instructions
Spoiler: show

Place the contents of the "data" folder into your /steam/.../Avorion/data/ folder. This will overwrite .../entity/init.lua  and  .../player/init.lua.
If you have any other modifying one of these files you will need to merge their content.
Place the contents of the "mods" folder into your /steam/.../Avorion/mods/ folder.

From Avorion 0.23 on, this mod will be continued in the workshop (https://steamcommunity.com/sharedfiles/filedetails/?id=1694550170)
« Last Edit: May 21, 2019, 05:06:16 PM by Laserzwei »
My Mod Collection
My Discord     screw google captcha
My Github
Questions?
> PM me here on the forums!



Laserzwei

  • Sr. Member
  • ****
  • Status:
    Offline
    Posts:
    394
    • View Profile
on: January 13, 2019, 08:34:39 PM
Version history
0.2.2 for beta0.21.x [2019-02-26]
  - added musiccoordinator script to init.lua (vanilla)
0.2.1 for 0.20.x [2019-01-20]
  - removed useless servercall
  - library is now loaded as module
  - code cleanups
Spoiler: show


0.2.0 for 0.20.x [2019-01-17]
  - added init scripts, which gives all players access to the sector Manager by default.
  - Had to move files. This requires a full uninstall of the previous versions!

0.1.0 for 0.20.x [2019-01-14]
  - config is now loaded from the server
  - added a small label to indicate #sectors wanted to load / sectors available to load/currently loaded
  - added color to clickable sectorLabels to indicate they are loaded (grabs the loaded status when opening the UI)[updated pic in the OP]

0.1.0 for 0.20.x [2019-01-13]
  - initial release
« Last Edit: February 26, 2019, 07:59:48 PM by Laserzwei »
My Mod Collection
My Discord     screw google captcha
My Github
Questions?
> PM me here on the forums!



Amriel

  • Newbie
  • *
  • Status:
    Offline
    Posts:
    5
    • View Profile
on: January 13, 2019, 10:08:34 PM
A chunkloader for Avorion! Brilliant.

I'll give it a try.



Laserzwei

  • Sr. Member
  • ****
  • Status:
    Offline
    Posts:
    394
    • View Profile
on: January 17, 2019, 09:19:16 PM
Update

0.2.0 for 0.20.x [2019-01-17]
  - added init scripts, which gives all players access to the sector Manager by default and makes setting it up a cake walk.
  - Had to move files. This requires a full uninstall of the previous versions!(For the 6 downloads/downloaders)

*also not proof-of-concept anymore!
My Mod Collection
My Discord     screw google captcha
My Github
Questions?
> PM me here on the forums!



Shrooblord

  • Hero Member
  • *****
  • Status:
    Offline
    Posts:
    578
    • View Profile
on: January 18, 2019, 01:53:02 PM
We've discussed this already in private, but I just want to voice publicly also that your Sector loading functions have been a big inspiration in helping me do what I needed for my own mods.  Thank you for this work, Laser!
Shrooblord



Demiga

  • Newbie
  • *
  • Status:
    Offline
    Posts:
    1
    • View Profile
on: January 31, 2019, 01:09:07 AM
I apologize if this is abundantly obvious, but what is the point of wanting to keep multiple sectors "open" like this?  I'm still somewhat new to all this, so I'm not sure.  Is it to make loading into the sector quicker? Is this useful for solo play?

Thanks!!!



Laserzwei

  • Sr. Member
  • ****
  • Status:
    Offline
    Posts:
    394
    • View Profile
on: January 31, 2019, 06:24:20 AM
I apologize if this is abundantly obvious, but what is the point of wanting to keep multiple sectors "open" like this?  I'm still somewhat new to all this, so I'm not sure.  Is it to make loading into the sector quicker? Is this useful for solo play?

Thanks!!!
By default all sectors are unloaded (and if never visited, they aren't even created). Obviously upon joining a multiplayer- or starting your singleplayer galaxy the sector you are in will be loaded. There is a limit for how many sectors stay loaded per player. In singleplayer it's 500 and for multiplayer it's 5. Those values can be adjusted in the server.ini. Furthermore all sectors with player ships or station will get a score or weight. If I remember correctly you get +3 for stations and +1 for each ship (none for fighters). The sectors with the highest score will stay loaded.
With my mod you can choose which sectors will be kept loaded regardless of its score
My Mod Collection
My Discord     screw google captcha
My Github
Questions?
> PM me here on the forums!



kolt16

  • Newbie
  • *
  • Status:
    Offline
    Posts:
    2
    • View Profile
on: January 31, 2019, 09:02:38 AM
Is this supposed to be equivalent to the state of a system with player presence? Or it means off sector calculations for mining and  player stations run in these sectors and that's it?

I was wondering if it were possible to use a similar method to fake player presence in a sector. Keep all entities loaded ect.

(As to why am I asking this. Off sector mining for me usually does nothing, with this it does something sometimes, but not much. I use Multiverse so it may break something regarding this. In any case it's still damn annoying, so I'm looking for a solution. Don't much care how hacky it may be..)



Laserzwei

  • Sr. Member
  • ****
  • Status:
    Offline
    Posts:
    394
    • View Profile
on: January 31, 2019, 01:50:21 PM
I will give a more in depth view on which sectors may get loaded, into what state and at what time.
The default Avorion galaxy has 1,000,000 (1000 x 1000) Sectors. Keeping all of them loaded at once takes far more computional resources than anyone could reasonably afford. Hence only sectors of interest for the player are loaded. If there is no player (e.g. in multiplayer), then no sector is loaded. An unloaded sector sees no movement, no ships enter it and no other events.
When a player joins (here also used as a synonym for loading into singleplayer) a galaxy, then the sector where he was last in will be loaded. That sector will run at 20 Ticks per second. The ticks define the main game logic (this will be important later). Furthermore a player's creations (ships & stations) in other sectors may invoke loading them too. The conditions to load a sector are as follows:
With descending priority:
  • A player can never load more sectors than the `aliveSectorsPerPlayer`-config option in the server.ini (located in your galaxies save folder). Let's call it threshold. By default for singleplayer it's at 500, for multiplayer it's 5. The player's current sector couns towards those limits!
  • The sectors with the highest weight get and are kept loaded first. The weight is calculated as follows:
     
    • +1 for every ship you own in that sector
    • +3 for every station you own in that sector
      (I couldn't find the source to the exact sources, so if they are wrong or incomplete notify me!) unbekannt1984 did find the source

      If a player has more sectors with a weight > 0 than the threshold allows, only those with the highest weight will be kept loaded. There is no direct way to see the weight of a sector (and no modding interface either!), but if you have a large enough force in a sector, then you will see a dim green surrounding in the galaxymap- which is proportional in size to the number of ships and stations in that sector. There are also small white dots for every ship in a sector.


  • If you give orders to a ship which will have it move to/through other sectors, then the next sector will be loaded and the ship jumps into it. And if this target sector didn't gain enough weight through the moved ship, then it will be unload shortly after (15-20s).
  • Giving orders to a ship that is in an unloaded sector gives the following message:   "That sector isn't loaded to memory on the server. Please contact your server administrator for help."

All of this is the same with alliances, except that any player joining triggers loading the sectors to above rules. As far as I can tell the number of players has no effect on the amount of sectors that an Alliance can load at the same time.
This should conclude when, what sectors get loaded.

Sectors have 3 states:
  • unloaded: Nothin happens in there.
  • player loaded: Full action at 20 ticks/s. Here is where the fun is.
  • weak loaded
Weak loaded are the interesting ones. They weren't always part of the gameplay (added in 0.12). Before sectors -without players- would stick around for 5 minutes and then get unloaded. By default they update at 2 ticks/s, which is 1/10th of player sectors. When you notice that mining-/salvagingships give less resources per seconds its's also related to them getting less update-ticks.
But you can change the default behavior in your server.ini. To get the full updates/s change the following setting:
Quote
emptySectorUpdateInterval=0.0489999987
The long decimal number is due to float-point-arithmetic inaccuracy.



If you find anyone who asks why his ships are mining slower than when he's in the sector show them this post.
https://www.avorion.net/forum/index.php/topic,5397.msg29495.html#msg29495
« Last Edit: February 13, 2019, 11:46:04 AM by Laserzwei »
My Mod Collection
My Discord     screw google captcha
My Github
Questions?
> PM me here on the forums!



Laserzwei

  • Sr. Member
  • ****
  • Status:
    Offline
    Posts:
    394
    • View Profile
on: January 31, 2019, 01:50:46 PM
Is this supposed to be equivalent to the state of a system with player presence? Or it means off sector calculations for mining and  player stations run in these sectors and that's it?

I was wondering if it were possible to use a similar method to fake player presence in a sector. Keep all entities loaded ect.

(As to why am I asking this. Off sector mining for me usually does nothing, with this it does something sometimes, but not much. I use Multiverse so it may break something regarding this. In any case it's still damn annoying, so I'm looking for a solution. Don't much care how hacky it may be..)

I've written all I know about Vanilla sector loading in the previous post.
To go through your questions quick:
- It's no abstract simulation; it's the full vanilla sector behavior, but with a handbrake on (see the 2nd part of the last post for furthe details)
- I doubt multiverse has any effect on sector loading
My Mod Collection
My Discord     screw google captcha
My Github
Questions?
> PM me here on the forums!



kolt16

  • Newbie
  • *
  • Status:
    Offline
    Posts:
    2
    • View Profile
on: January 31, 2019, 03:41:50 PM
Ah awesome, thanks! :D

This should fix my problems.



Edit:
Btw knowing all this, my problem does look like a bug. I have 3 ships, and they get stuck like this often, even though the game should have two sectors loaded, (nowhere near the 500, nor the 5) I exit one and they get stuck, or maybe one follows the other doesn't. If I go back it gates immediately to the new system.


Anyways with Sector Manager, and changing the update interval , now mining at least seems to work, so thanks again.
« Last Edit: January 31, 2019, 04:00:11 PM by kolt16 »



unbekannt1984

  • Full Member
  • ***
  • Status:
    Offline
    Posts:
    164
    • View Profile
on: January 31, 2019, 03:58:13 PM
Hi Laser,

  • A player can never load more sectors than the `aliveSectorsPerPlayer`-config option in the server.ini (located in your galaxies save folder). Let's call it threshold. By default for singleplayer it's at 500, for multiplayer it's 5
  • The sectors with the highest weight get and are kept loaded first. The weight is calculated as follows:
     
    • +1 for every ship you own in that sector
    • +3 for every station you own in that sector
      (I couldn't find the source to the exact scores, so if they are wrong or incomplete notify me!)
found the source, but it seems to be 500+1 (singleplayer) or 5+1 (multiplayer), or whatever the serveradmin felt happy with:

Out-of-sector simulation

"We'll be adding some more means for better control of which sectors will actually get updated on multiplayer servers. For now, sectors with lots of stuff will have a higher priority."
  • Sectors with player and alliance content are updated while the player is not inside the sector
  • Default amount of updated sectors per player on multiplayer is 6 (the sector the player is in, plus 5)
    • This value can be configured in the server.ini settings and will be a lot higher for singleplayer
  • If a player has property in more than 6 sectors, this happens:
    • Each sector will have a priority score
    • The 5 sectors with the highest scores will be updated
    • The score in the sectors is 3 for each player station, plus 1 for each player ship

from the 0.12.7 (Alliance-Update) Patchnotes...



Laserzwei

  • Sr. Member
  • ****
  • Status:
    Offline
    Posts:
    394
    • View Profile
on: January 31, 2019, 05:25:22 PM
Hi Laser,

found the source, but it seems to be 500+1 (singleplayer) or 5+1 (multiplayer), or whatever the serveradmin felt happy with:
...
from the 0.12.7 (Alliance-Update) Patchnotes...
Nice, thank you!
My Mod Collection
My Discord     screw google captcha
My Github
Questions?
> PM me here on the forums!



Hammelpilaw

  • Hero Member
  • *****
  • Status:
    Offline
    Posts:
    538
    • View Profile
    • Scrap Yard - Avofactory
on: January 31, 2019, 05:35:06 PM
Hi Laser,

found the source, but it seems to be 500+1 (singleplayer) or 5+1 (multiplayer), or whatever the serveradmin felt happy with:
...
from the 0.12.7 (Alliance-Update) Patchnotes...
Nice, thank you!

In some tests few months ago I could not confirm the x+1, it seemed to be just be 5 on multiplayer default setting, not adding one for the current sector. Did not do further tests though, but I think the few tests I did were accurate.

Btw: Awesome mod, will try it sooner or later. Its been really missing in vanilla game.
Scrap Yard Galaxy
My mods and tools
My Workshop

If you find a bug in my mods please contact me.



zel0t

  • Newbie
  • *
  • Status:
    Offline
    Posts:
    5
    • View Profile
on: February 04, 2019, 05:25:34 AM
The sectors eventually go to sleep, does this not work with alliance ships. or did i not configure the mod properly.
« Last Edit: February 04, 2019, 06:29:15 AM by zel0t »