Closed Ismoh closed 1 year ago
FYI: based on #27 branch
Use reliable, unsequnced and unreliable sendMode.
Reliable is default.
Reliable:
Unreliable
Other stuff:
Enough for now!
Store messageIds per session with flag SENT or ACK: messageIds = { 1 = ACK, 2 =..., 10 = SENT }
if messageIds > 128 start at 0 again
When sending any message add messageId of sender to data. Can we use sock.sentPackages for the messageId?
When receiving message, send ACK back to sender with messageId in data.
When sender got ACK from receiver, update messageIds to ACK
Store nuid per peer and resend if not ACKed. DO I NEED THIS?
Resend message, if not acked after RTT*2
if message received and already acked, ignore it.
edit sock.lua to not create server or connect to server when server or client object is initialised?
Before doing any network stuff, extend logger with categories like GUID, NUID, ENTITY, NET, NOITA_COMPONENTS, etc. ✔️
Add log level per category in modSettings. ✔️
Log file be like: TL;DR
Change log of client server to use pprint.format to get a return instead of writing to io or console: https://github.com/jagt/pprint.lua#options ✔️
Remove all callbacks and rework them step by step, also schemas. ~When connecting dont send minä, sent seed and restart client, then auto connect and sent minä.~ No need for a restart anymore.
Use apto and exe filename for unique guid ✔️
Put networking update in one function and run this is WorldPreUpdate and OnPausePreUpdate. Does it make sense to run Networking update on pre normal and postUpdate?
Add saveSlot number into saveSlot cache. ✔️
When connecting the second time, clients save directory has to be empty, otherwise seed doesnt work: Try to remove the savefolders content with start /wait, because lfs isnt able to delete. I think because the directory is still in use. see below: https://stackoverflow.com/a/13258451/3493998 https://stackoverflow.com/a/9480476/3493998
Deprecated, because solved it without restarting. Thanks to Evaisa. ✔️
Fix unit test! 😡
For the future: Sync minäs arm leg and other stuff, but make it configurable, or better to say, when threshold is reached (lag ~60ms), then only sync necessary stuff like projectiles, enemies and position of minäs
Add version to playerInfo to detect version missmatch
Add exclude include for spawning entities. Player for example do need to be spawned, but a dump copy of it.
When server got needNuid, check if entity already was spawned (client guid + localEntityId).
I think I dont need messageIds, when entityIds + guid can be used.
Add reseting guid, when development build is used, otherwise guid will be the same. Do I want to add guid check for server/client? Yes...
When sock.lua creates a new client on server object, use NoitaMP client object, instead of sock.lua client object.
Override all send functions to set acknowledge. Copy&paste acknowledge of sock.lua#Client:send
I need to add a 'cache' list for detecting, if entities moved and needs to be synced: entities[entityId] = { health, pos, velo, etc } (round health, position, velo, etc otherwise this cache is obsolete) Then getFilteredEntities After that compare In addition: use callback function in getFilteredEntities to add additionalChecks like:
If client disconnects clear list. (client only sends minä and projectiles) If entity died, remove from list.
Double check if entityId for nuid changed in GlobalsUtils, when set or removed from cache.
Only owner is allowed to send entityData?
Load entities once per world update and pass the list as parameter.?
Added tick rate and changed detection of changes, but clients fps still drop to ~29-55. I need to profile again!
Use coroutine as iterator for
config.lua:
modSettings {
radiusToDetectEntities.key = "noita-mp.radiusToDetectEntities",
radiusToDetectEntities.value = 250,
...
}
First check how long it takes to get a mod setting, by profiling ModSettingGet("foo.bar"):
local cpc = CustomProfiler.start("ModSettinGet")
local foo = ModSettingGet("bar.z")
CustomProfiler.stop("ModSettingGet", cpc)
First check how long it takes to get a mod setting, by profiling ModSettingGet("foo.bar"):
local cpc = CustomProfiler.start("ModSettinGet") local foo = ModSettingGet("bar.z") CustomProfiler.stop("ModSettingGet", cpc)
ModSettings execution is below 1ms! So this isn't the problem.
Use coroutine as iterator for
- init network entities
- sending network messages on specific tick rate (ms)
- receive network messages on preUpdate
- send network messages on postUpdate
Yield return iterator or index when execution time is greater equals 25ms (=40fps) Next frame continue on for loop
Looks like I found the issue?
I'll see, if this is the problem the next days:
It has to be EntityUtils.syncEntityData.for
!
If you are curious, have a look on frame 4559 in report.html: reports.zip
Clear caches, when entering and exiting holy mountain!
yes, use
BiomeMapGetName( x:number = camera_x, y:number = camera_y ) -> name
name = $biome_holymountain
Better to use this one?
DebugBiomeMapGetFilename( x:number = camera_x, y:number = camera_y ) -> string
If client and server have a distance of 3*radius do not sync entities only sync world changes.
Receive network messages in preworldupdate and send messages in postworldupdate?
Note: If entity has children, loop children and add nuid + send it two clients
Shouldn't this branch be merged into develop? The goals of this PR have been completed, so why hasn't it been merged?
As far as I can tell, most of the issues and PRs based off of this branch are seperate issues - not related to the client/server module rework.
It isn't merged, because other branches are based on this. But yes, it's time for it
Should we merge it after #89 is finished?
Yes. If there is stuff, not fully or correct synced, we can and should create follow up issues
This is the successor issue to #27, which is more or less done and would be to huge to continue.
TBC