-
Notifications
You must be signed in to change notification settings - Fork 8
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
Project restructure #28
Project restructure #28
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These changes look good to me and the naming makes more sense from a programming perspective as the backend handles the data, not actual (maybe minor) game logic. This will alleviate a lot of confusion that has stemmed from the naming in the past.
I also like the idea of trying a new library for the Websocket, excited to see where it leads.
At request of @nexus4880 in discord I've modified the ORM to use |
This is one huge PR.
Overview
While working on implementing Arena, I noticed that the project structure was ill-suited for handling multiple games + core backend. This is why the solution underwent significant restructuring.
Solution restructuring
In discussion with @nexus4880, all
struct
types (exceptMongoId
) have been changed toclass
.To reflect that these classes should not contain any methods, the namespace
X.Models.X
has been modified toX.DTO.X
.In discussion with @nexus4880, all
FuyuBehaviour
types have been renamed toFuyuController
and use theController
suffix to signify use.In discussion with @Lacyway,
Fuyu.Server.X
has been renamed toFuyu.Backend.X
to better reflect it's use-case.Fuyu.Backend
: the backend applicationFuyu.Backend.Arena
: all arena backend codeFuyu.Backend.BSG
: code shared among BSG gamesFuyu.Backend.Common
: code shared among all backendsFuyu.Backend.Core
: Fuyu's backend (account handling mostly)Fuyu.Backend.EFT
: all EFT backend codeFuyu.Common
: a library with useful utilities and wrappersFuyu.Launcher
: the launcher applicationFuyu.Launcher.Core
: reusable launcher code (for if others want to make their own launcher)Fuyu.Plugin.Arena
: minimal patchset required to get into arena in offline modeFuyu.Plugin.Common
: code shared among all pluginsFuyu.Plugin.EFT
: minimal patchset required to get into EFT in offline modeFuyu.Test.Backend.Arena
: CI/CD validation forFuyu.Backend.Arena
Fuyu.Test.Backend.Arena
: CI/CD validation forFuyu.Backend.Core
Fuyu.Test.Backend.Arena
: CI/CD validation forFuyu.Backend.EFT
Fuyu.Test.Common
: CI/CD validation forFuyu.Common
Zlib.Managed
: a modified zlib library with EFT specific tweaksAccount system
Fuyu now has multiple account types;
Fuyu.Backend.Core.DTO.Account
is Fuyu's main account. This contains login information and which games are registered to an account. A registered game can have multiple game accounts registered to it.Fuyu.Backend.EFT.DTO.Account
andFuyu.Backend.Arena.DTO.Account
are game accounts. These have save(s) bound to them bind to them (EFT has PvP and PvE, Arena has PvP).Fuyu's main account and game accounts have separate AccountIds to prevent outside access to login information. A game account can never reach a Fuyu main account, but a Fuyu main account can reach a game account.
TL;DR: A safe way to support multiple games on the main account, with multiple game account slots per game.
While I understand that this system is complete overkill, I believe it's beneficial to make it adaptable for other games in the future.
Database and ORM
Each server has now a single Database and a single ORM. The Database contains all tables and has methods to load these tables. The ORM should be used for any access and modification to the database.
Modders can override the ORM's methods using HarmonyX to bind their own source.
This implementation is beneficial as it's easily tracable which database tables are being accessed and modified, as well as easier to deal with in IntelliSense (providing contextual names like
languageId
orCustomizationTemplate
instead ofDictionary<string, string>
).Wipe profiles
Thanks to the database rework, modders can now register their own wipe profile types.
Removal of WebSocketSharp
It is too restrictive for our use-case and hasn't been properly maintained. With research from @nexus4880,
System.Net.HttpListener
has now replaced the library. Each HTTP server now runs on it's own thread.Removal of thread optimizations
While I love doing these, I think I should keep the current code first and foremost dead-simple to work with. These can happen later when hot code loops have been identified.
Rationale
While I understand it is not beneficial to have such a huge PR, it couldn't be avoided due to the lack of separation from concerns. I could've hold off some naming changes like
HttpBehaviour
toHttpController
, but it wouldn't have mattered due to everything being touched regardless.I really hope I only have to break things once this way, it hasn't been fun to rework it all. It simply was too much. But I rather do it now while the codebase is relatively small than later.
Notes
While the tests succeed, the project cannot actually reach the main menu. I really need someone to step in and fix it as I've simply stared too long at the code. The issue occurs when reaching
/client/game/profile/list
(KeyNotFoundException
). I assume that thesessionId
is not properly registered intoEftDatabase.Sessions
.Despite the PR not working, I want to get this merged so others can resume their work and can look into fixing the issue.
The Arena project structure is there, I want to finalize the EFT setup first before making Arena bootable.
Discussion
Having EFT and Arena use different game account ids might lead into issues in the future. I have no idea how I want to solve the problem yet. Ideas are welcome!
In order for game registration to work properly, I had to use cross-server comminucation over HTTP (see
Fuyu.Backend.Core.Services.AccountService.RegisterGame()
). Suggestions for a better solution would be much appriciated!I've shortcutted the game login in the launcher by making
accountId
always 0 (seeAccount.razor
). Currently I would need to implement/account/get/game
in order to obtain theaccountId
required to start the game. We might need to think of a more elegant solution for handling this. Feedback is much appriciated!We should probably look into making
HttpListener
operate async on it's own thread in order to handle multiple requests on the same thread simultaniously.Once this is merged and I can get it to work well enough, I want to get Arena to load first into the main menu and then work on implementing the websocket server over
HttpListener
. It seems pretty doable.