Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Developer want to rework NetworkComponents #27

Closed
Ismoh opened this issue Mar 11, 2022 · 8 comments · Fixed by #52
Closed

Developer want to rework NetworkComponents #27

Ismoh opened this issue Mar 11, 2022 · 8 comments · Fixed by #52
Assignees
Labels
rework Predicts breaking changes. This will increase MAJOR version number, when merged into develop.

Comments

@Ismoh
Copy link
Owner

Ismoh commented Mar 11, 2022

Just to be clear: NetworkComponent isn't a NoitaAPI component. It's NoitaMP code.

local nc_serialised = ComponentGetValue2(variable_storage_component_id, "value_string") or nil

As you can see above, the whole network component is serialised and then saved in a VariableStorageComponent(NoitaAPI).
This leads for some reasons to problems, because desirialisation doesn't work as expected. The stored Ids are wrong and messed up, for example:
NUID = 126 -> serialised and saved to VariableStorageComponent -> loaded from this V.S.Component -> desirialised -> NUID = 1837364748. The fuijck is happening?

That's why I discussed with the mod community and came to the idea to change it completely:

  1. World is loaded
  2. If client simply despawn all entities in a specific range (keep doing this, while moving / playing the game)
  3. If server send your (in the same specific range) all entities to the clients + get pos of clients and send the servers entities to the client in the same range -> think of: your mate dont want to stick together
  4. That's enough for know :D

Instead of de-/serialising the network component, simply use the entityManager to add per each attribute of the networkComponent as a VariableStorageComponent to the entity itself:

NetworkComponent
NUID = 183
attr2 = foo
attr3 = bar

Leads to three VariableStorageComponent added to one entity. First VSC has 183 as value etc.

Have a look on this:
https://github.com/Ismoh/NoitaMP/blob/master/.debug/network%20ids%20chat%20history.PNG

@Ismoh Ismoh added bug Something isn't working. This will increase PATCH version number, when merged into develop. enhancement New feature or request. This will increase MINOR version number, when merged into develop. help_wanted Extra attention is needed labels Mar 11, 2022
@Ismoh Ismoh mentioned this issue Mar 11, 2022
@Ismoh
Copy link
Owner Author

Ismoh commented Mar 11, 2022

In addition to this see #26

@Ismoh
Copy link
Owner Author

Ismoh commented Apr 10, 2022

  • De-/serialisation is replaced with json string, which is human-readable.
  • Rework network component creation and storing: remove all entities on clients and spawn server entities on clients. Or send notification to server that there is a entity removed on Client and spawn this again on all clients with a NUID.
  • Rework and refresh cache on server and all clients. Also when saving and loading. I am thinking of a NUID file/class which handles all NUID stuff. Same as GUID class
  • only sync a defined list of entities or better to say: provide an exclude (black) list, for entities which shouldnt be synced

@Ismoh
Copy link
Owner Author

Ismoh commented Apr 11, 2022

  • De-/serialisation is replaced with json string, which is human-readable

This leads to saving and loading issues:

SpawnPlayer, because joystick is connected
Loading player: ??SAV/player
XML error in file(??SAV/player.xml) at line (1490)parsing tag (owner":{"guid":"AB4D7A8E-2928-044C-CA1C-63E67502E0E9","username":"noita_dev.exe"},"nuid":"nil","component_id":14,"local_entity_id":145}") - expected '='
XML error in file(??SAV/player.xml) at line (1491)parsing tag (VariableStorageComponent) - expected '='

Therefore I need to add one VariableStorageComponent for each field in NetworkComponent..

Ismoh added a commit that referenced this issue Apr 11, 2022
…tworkComponent a bit. EntityManger also changed. WIP!
Ismoh added a commit that referenced this issue Apr 11, 2022
…tworkComponent a bit. EntityManger also changed. WIP! 2
Ismoh added a commit that referenced this issue Apr 11, 2022
…tworkComponent a bit. EntityManger also changed. WIP! 3
Ismoh added a commit that referenced this issue Apr 11, 2022
…tworkComponent a bit. EntityManger also changed. WIP! 4
Ismoh added a commit that referenced this issue Apr 16, 2022
Function to show players names

Going to create a follow up issue to add this function after #27 was merged.
@Ismoh Ismoh added rework Predicts breaking changes. This will increase MAJOR version number, when merged into develop. and removed help_wanted Extra attention is needed labels Apr 16, 2022
@Ismoh
Copy link
Owner Author

Ismoh commented Apr 24, 2022

Notes of today! Everytihng in the comments above isn't up to date anymore because it doesnt work. Game still crashing!

  • Rename Nuid to NuidUtils, which should be a static class ✔️
  • NuidUtil is only accessible by server_class ✔️
  • it returns the latest/current nuid ✔️
  • latest/current means: if globals are set, get highest nuid. Entity updates globals by a nuid_updater noita component. If entity was found and does not have any nuid, NetworkVscUtil will add the VariableStorageComponents. ✔️
  • Update/set nuid is only possible, as long as nuid in vsc is empty
  • Rename entity_manager to EntityUtils, which is also a static class ✔️
  • EntityUtil runs on server:update and client:update ✔️
  • get entity in radius only run on server ✔️
  • remove/despawn entities only run on client ✔️
  • get entities in radius depending on its components: currently only velocityComponent ✔️ Special thanks to @TheHorscht !
  • EntityUtil syncs entity values (health, pos, velocity, kill/death, etc) on client to server and server send this to all clients besides the one who sent it
  • adds NuidUpdater to the entity by default, if not exists already ✔️
  • convertPhysicsObjectsBackToEntities function is static and runs in modPreInit to i.e. convert the minecart back to an entity

yes, using TextFileGetContent, replace the value using string.gsub, then TextFileSetContent
Will be done in #50

  • Rename NetworkVscValues to NetworkVscUtils ✔️
  • adds all VariableStorageComponents to a specific entity provided by EntityUtil ✔️
  • updates/set nuid to entity, if not already set ( - Update/set nuid is only possible, as long as nuid in vsc is empty) ✔️
  • get/return all values by nuid ✔️
  • add a function to check, if the entity still exists ✔️
  • GlobalsUtil
  • set entityId to -99 (despawned), when entity died ✔️
  • set entityId to "outdated", when nuid_updater updates the entityId after loading a savegame new entityId will be set to the already set nuid
  • Rework nuid_updater
  • Try to use GlobalUtils if possible ✔️
  • rewrite functions ✔️
  • make use of executed_on_added and _removed ✔️
  • get rid of death function in adding the noita component and in the script itself ✔️

Something left?

@Ismoh
Copy link
Owner Author

Ismoh commented Apr 26, 2022

Last commit looks really promising!
No crashes yet and only two lua errors, I don't know yet.
We'll see!

@Ismoh
Copy link
Owner Author

Ismoh commented Apr 29, 2022

  • everytime entity_id or entityId is passed as a parameter, first check on top of the function, if entity still exists with EntityGetIsAlive(entity_id)

I am pretty sure this is reason for the client crash: when a projectile is shot by server near to the ground, there is no time left to set the nuid on client. Client tries to set nuid on a non existing entity.

Should be double checked in #37, when #27 is done.

Ismoh added a commit that referenced this issue May 1, 2022
…ctise. I had to often 'stack overflow' error, when requiring modules. Rework NetworkComponents #27
@Ismoh Ismoh changed the title Rework NetworkComponents Developer want to rework NetworkComponents May 3, 2022
@Ismoh
Copy link
Owner Author

Ismoh commented May 3, 2022

  • Mod settings
  • Add documentation for debug mod settings ✔️
  • Add include and exclude config file and use it in ModSettings. This might not work because ModSettings does not allow unsafe functions. Does dofile work? A lua file might work well! ✔️
  • Add documentation for include and exclude lua file. Use EntityUtils in that file to put it in the correct global. ✔️

Ismoh added a commit that referenced this issue May 11, 2022
Ismoh added a commit that referenced this issue May 11, 2022
@Ismoh Ismoh linked a pull request May 11, 2022 that will close this issue
@Ismoh
Copy link
Owner Author

Ismoh commented May 15, 2022

PR merged. Closing this.

@Ismoh Ismoh closed this as completed May 15, 2022
Ismoh added a commit that referenced this issue Sep 24, 2022
* Clean up 2 in Developer want to rework NetworkComponents #27

* Clean up 3 in Developer want to rework NetworkComponents #27

* Developer want to rework NetworkComponents #27 Trying to fix workflows.

* Developer want to rework NetworkComponents #27 Trying to fix workflows. 2

* Developer want to rework NetworkComponents #27 Trying to fix workflows. 3

* Developer want to rework NetworkComponents #27 Trying to fix workflows. 4

* Developer want to rework NetworkComponents #27 Trying to fix workflows. 5

* Developer want to rework NetworkComponents #27 Trying to fix workflows. 6

* #27 Trying to fix workflows. 6

* #27 Trying to fix workflows. 8

* #27 Trying to fix workflows. 9

* #27 Trying to fix workflows. 10

* #27 Trying to fix workflows. 11

* #27 Trying to fix workflows. 12

* #27 Trying to fix workflows. 13

* #27 Trying to fix workflows. 14

* #27 Trying to fix workflows. 15

* #27 Trying to fix workflows. 16

* #27 Trying to fix workflows. 17

* #27 Trying to fix workflows. 18

* #27 Trying to fix workflows. 19

* #27 Trying to fix workflows. 20

* #27 Trying to fix workflows. 21

* #27 Trying to fix workflows. 22

* #27 Trying to fix workflows. 23

* #27 Trying to fix workflows. 24

* #27 Trying to fix workflows. 25

* #27 Trying to fix workflows. 26

* #27 Trying to fix workflows. 28

* #27 Trying to fix workflows. 28

* #27 Trying to fix workflows. 29

* #27 Trying to fix workflows. 30

* #27 Trying to fix workflows. 31

* Bump codecov/codecov-action from 2 to 3

Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 2 to 3.
- [Release notes](https://github.com/codecov/codecov-action/releases)
- [Changelog](https://github.com/codecov/codecov-action/blob/master/CHANGELOG.md)
- [Commits](codecov/codecov-action@v2...v3)

---
updated-dependencies:
- dependency-name: codecov/codecov-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <[email protected]>

* #42 Trying to get associated issue and its labels

* #42 list context

* #42 changed trigger

* #42 using github cli "gh"

* #42 using github cli "gh" 2

* #42 using github cli "gh" 3

* #42 using github cli "gh" 4

* #42 Using curl for fetching issue labels

* #42 Using curl for fetching issue labels 2

* #42 Using curl for fetching issue labels 3

* #42 Using curl for fetching issue labels 4

* #42 Using curl for fetching issue labels 5

* #42 Using curl for fetching issue labels 6

* #42 Using curl for fetching issue labels 7

* #42 Using curl for fetching issue labels 8

* #42 Using curl for fetching issue labels 9

* #42 Using curl for fetching issue labels 10

* #42 Using curl for fetching issue labels 11

* #42 Using curl for fetching issue labels 12

* #42 Using curl for fetching issue labels 13

* #42 Using curl for fetching issue labels 14

* #42 Using curl for fetching issue labels 15

* #42 Using curl for fetching issue labels 16

* #42 Using curl for fetching issue labels 17

* #42 Using curl for fetching issue labels 18

* #42 Using curl for fetching issue labels 19

* #42 Using curl for fetching issue labels 20

* #42 Using curl for fetching issue labels 21

* #42 Changed in game menu icon

* #42 Changed in game menu icon 2

* #42 Trying to add label to pr/issue

* #42 Trying to add label to pr/issue 2

* #42 Trying to add label to pr/issue 3

* #42 Trying to add label to pr/issue 4

* #42 GitHub copilot is going crazy!

* #42 GitHub copilot is going crazy! 2

* #42 GitHub copilot is going crazy! 3

* #42 GitHub copilot is going crazy! 4

* #42 GitHub copilot is going crazy! 5

* #42 GitHub copilot is going crazy! 6

* #42 GitHub copilot is going crazy! 7

* #42 GitHub copilot is going crazy! 8

* #42 GitHub copilot is going crazy! 9

* #42 GitHub copilot is going crazy! 10

* #42 GitHub copilot is going crazy! 11

* #42 GitHub copilot is going crazy! 12

* #42 GitHub copilot is going crazy! 13

* #42 GitHub copilot is going crazy! 14

* #42 GitHub copilot is going crazy! 15

* #42 GitHub copilot is going crazy! 16

* #42 GitHub copilot is going crazy! 17

* #42 GitHub copilot is going crazy! 18

* #42 GitHub copilot is going crazy! 19

* #42 GitHub copilot is going crazy! 20

* #42 GitHub copilot is going crazy! 21

* #42 GitHub copilot is going crazy! 22

* #42 GitHub copilot is going crazy! 23

* #42 GitHub copilot is going crazy! 24

* #42 GitHub copilot is going crazy! 25

* #42 GitHub copilot is going crazy! 26

* #42 GitHub copilot is going crazy! 27

* #42 GitHub copilot is going crazy! 28

* #42 GitHub copilot is going crazy! 29

* #42 GitHub copilot is going crazy! 30

* #42 GitHub copilot is going crazy! 31

* #42 GitHub copilot is going crazy! 32

* #42 GitHub copilot is going crazy! 33

* #42 Let's try 'curl'!

* #42 Let's try 'curl'! 2

* #42 Let's try 'curl'! 3

* #42 Let's try 'curl'! 4

* #42 Let's try 'curl'! 5

* #42 Let's try 'curl'! 6

* #42 Let's try 'curl'! 7

* #42 Let's try 'curl'! 8

* #42 Let's try 'curl'! 9

* #42 Let's try 'curl'! 10

* #42 Let's try 'curl'! 11

* #42 Let's try 'curl'! 11

* #42 Let's try 'curl'! 12

* #42 Let's try 'curl'! 13

* #42 Let's try 'curl'! 14

* #42 Let's try 'curl'! 15

* #42 Let's try 'curl'! 16

* #42 Let's try 'curl'! 17

* #42 Let's try 'curl'! 18

* #42 Let's try 'curl'! 19

* #42 Let's try 'curl'! 20

* #42 Let's try 'curl'! 21

* #42 Let's try 'curl'! 22

* #42 Let's try 'curl'! 23

* #42 Let's try to increase version

* #42 Let's try to increase version 2

* #42 Let's try to increase version 3

* #42 Let's try to increase version 4

* #42 Let's try to increase version 5

* #42 Let's try to increase version 6

* #42 Let's try to increase version 7

* #42 Let's try to increase version 8

* #42 Let's try to increase version 9

* #42 Trying GitHubs output

* #42 Trying GitHubs output 2

* #42 Found the issue regarding "syntax error near unexpected token `newline'"

* #42 Still getting "syntax error near unexpected token `newline'"! Change bash command

* #42 Syntax error?

* #42 Oh missed some adjustment for naming. Fixed missed variable names.

* #42 Looks like GitHub copilot isn't smart enough.

* #42 And again: Looks like GitHub copilot isn't smart enough.

* #42 "Unable to parse version: v2.3.1-alpha+894; please check your version syntax, refer: https://semver.org/"

* #42 Added version file extraction pattern.

* #42 Fixing not necessary $ in labelNames.

* #42 Trying to commit and push changed version to the specific pull request.

* #42 labelNames wasn't set. git push didn't work, because no branch was checked out? "fatal: You are not currently on a branch. To push the history leading to the current (detached HEAD). state now, use 'git push origin HEAD:<name-of-remote-branch>'"

* #42 Trying to get the branch name within github action.

* #42 Found the head_ref branch name. Is '$' necessary?

* #42 '$' is necessary!

* #42 Adding commits count to version!

* #42 "[detached HEAD 1345a7c] Updated version of this PR to 2.4.0-alpha. 1 file changed, 1 insertion(+), 1 deletion(-) To https://github.com/Ismoh/NoitaMP ! [rejected] HEAD -> 42-developer-want-to-add-github-workflow-action-to-automatically-increase-the-version-of-noitamp (fetch first) error: failed to push some refs to 'https://github.com/Ismoh/NoitaMP'
     hint: Updates were rejected because the remote contains work that you do
     hint: not have locally. This is usually caused by another repository pushing
     hint: to the same ref. You may want to first integrate the remote changes
     hint: (e.g., 'git pull ...') before pushing again.
     hint: See the 'Note about fast-forwards' in 'git push --help' for details."

* #42 "You are not currently on a branch. Please specify which branch you want to merge with. See git-pull(1) for details. git pull <remote> <branch>"

* #42 "You have divergent branches and need to specify how to reconcile them." Use ref for using the merge and not the initial branch

* #42 Does "actions/checkout@v3" help?

* #42 Error: .github#L1: a step cannot have both the `uses` and `run` keys

* #42 You are not currently on a branch.
    Please specify which branch you want to merge with.
    See git-pull(1) for details.
        git pull <remote> <branch>

* #42 You are not currently on a branch.
    Please specify which branch you want to merge with.
    See git-pull(1) for details.
        git pull <remote> <branch> 2

* Updated version of this PR to 2.4.0-alpha

* #42 It's working fine, besides overwriting .version file. Should work now.

* Updated version of this PR to 2.4.0-alpha

* #42 I want githubs icon on the commit

* Updated version of this PR to 2.5.0-alpha

* #42 Fixed version

* #42 Doesnt work when merged

* #42 Use base ref instead.

* #42 Adding comment to the pull request.

* #42 Fixing syntax.

* #42 Fixing syntax 2

* #42 Fixing syntax 3

* #42 Fixing syntax 4

* #42 Fixing syntax 5

* #42 Fixing syntax 6

* #42 Fixing syntax 7

* #42 Fixing syntax 8

* #42 Fixing syntax 9

* #42 Fixing syntax 10

* #42 Fixing syntax 11

* #42 Fixing syntax 12

* #42 Fixing syntax 13

* #42 Escaping everything!

* #42 Escaping everything! doesnt help

* #42 Escaping everything! doesnt help 2

* #42 Escaping everything! doesnt help 3

* #42 Escaping everything! doesnt help 4

* #42 Found the issue.

* #42 Found the issue. 2

* #42 Found the issue. 3

* #42 Found the issue. 4

* #42 Found the issue. 5

* #42 polishing

* #42 polishing 2

* #42 polishing 3

* #42 Colon is fycking up the json body.

* #42 Colon is fycking up the json body. 2

* #42 Colon is fycking up the json body. 3

* #42 Colon is fycking up the json body. 4

* #42 Triple escape characters.

* #42 Head ref doesnt exist, after merge.

* #42 merged flag is false?

* #42 merged flag is false?

* #42 merged flag is false? 2

* #42 merged flag is false? 2

* Updated version of #65 to v2.4.0-alpha+1040

* #42 Polishing!

* #42 Made a mistake. Fixing version manually.

* Updated version to v2.4.0-alpha+1045 in #66

* Bump HardNorth/github-version-generate from 1.1.2 to 1.2.0

Bumps [HardNorth/github-version-generate](https://github.com/HardNorth/github-version-generate) from 1.1.2 to 1.2.0.
- [Release notes](https://github.com/HardNorth/github-version-generate/releases)
- [Changelog](https://github.com/HardNorth/github-version-generate/blob/develop/CHANGELOG.md)
- [Commits](HardNorth/github-version-generate@v1.1.2...v1.2.0)

---
updated-dependencies:
- dependency-name: HardNorth/github-version-generate
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>

* #72 Added changelog generator in a separated yaml file and in version.yml.

* #72 Removed changelog generator in version.yml.

* #72 Fixed non-existing tag key in changelog-generator.yml

* #72 Added changelog generator to version.yml

* #72 Fixed not working changelog generator workflow action.

* #72 Trying to get the directories working?!

* #72 Still trying to find out, where CHANGELOG.md is created.

* #72 Typo in yaml.

* #72 Changed branch from github.base_ref to github.head_ref, because CHANGELOG.md has to be changed in the PR-branch itself.

* Updated CHANGELOG.md in #73

* #72 Fixed order of workflow steps, to create first a tag, then updating CHANGELOG.md into the merged branch (github.base_ref)

* #72 Changed wording and added version file name.

* #72 Removed CHANGELOG.md, because it was generated not correctly.

* #72 Removed not working changelog-generator.yml. Renamed version.yml to version-and-changelog-update.yml.

* #72 Changed wording and order of steps for a better reading

* Updated version to v2.5.0-alpha+1065 in #73

* Updated CHANGELOG.md in #73

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: github-actions <[email protected]>
Co-authored-by: github-actions <[email protected]>
Co-authored-by: github-actions <[email protected]>
@Ismoh Ismoh added this to NoitaMP Nov 22, 2022
@Ismoh Ismoh moved this to ✅ Done in NoitaMP Nov 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
rework Predicts breaking changes. This will increase MAJOR version number, when merged into develop.
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

1 participant