Forgottenserver: src folder organization

Created on 24 Feb 2017  路  12Comments  路  Source: otland/forgottenserver

I feel as though it's high-time the source files in the src folder were organized into meaningful subfolders. For example, connection, lockfree, networkmessage, outputmessage, protocol, protocolgame, protocollogin, protocolold, protocolstatus, rsa, and waitlist could all be grouped together in a network folder.

This isn't high-priority, or even necessary for that matter, but it may be worth it in the long run. Especially as more source files are added to the project.

enhancement

Most helpful comment

Because this is such a large task I've decided that the best course of action will be to split it up into smaller parts. The drawback is that there will be an interim period during which there might be a little bit of a mess, but I think it's a much better approach than one humongous patch. I'd like to ask you guys to try and split this task up into multiple issues so that each issue can be resolved with a fairly small patch (e.g. 1st issue and patch will group the lua module into separate files, the 2nd will group up networking). I've created a project so that we can group all these related issues into it and track progress.

All 12 comments

I would primarily see "luascript.cpp" as "lua/*.cpp", which is already suggested in #2169 so it's not a new idea. I guess the rest would follow as needed.

It is actually pretty hard because files are very much interconnected with includes and there will be a lot of .. and ../.. out there, but would be very good. I think it would be even better to split the server into smaller objects instead of a single target, them link together. CMake excels at that.

Not sure what you mean by splitting into smaller objects in this case, but if it's something that could help drive the required RAM to compile down, then it could solve the other issue.

@ranisalt
You can use the include_directories directive to avoid relative paths. For instance you if you had map/tile.cpp and wanted to include a network related header you could just use #include "network/whatever.h" rather than #include "../network/whatever.h" and so on.

@DSpeichert e.g. building all protocol related stuff (protocol*.(cpp|h) files) in a small library libprotocol.a, then linking against tfs executable. It should help using less RAM, too.

@diath that would become a mess of relative paths. I do prefer paths relative to the current file than to some arbitraty root folder. The more include directories, the more filename colision you might have.

Because this is such a large task I've decided that the best course of action will be to split it up into smaller parts. The drawback is that there will be an interim period during which there might be a little bit of a mess, but I think it's a much better approach than one humongous patch. I'd like to ask you guys to try and split this task up into multiple issues so that each issue can be resolved with a fairly small patch (e.g. 1st issue and patch will group the lua module into separate files, the 2nd will group up networking). I've created a project so that we can group all these related issues into it and track progress.

People still working on/interested in this?

@foxrother it should be done, and there's a project for it, so I would say there's definitely interest. However, I haven't seen any work related to it, so feel free to go for it if that's what you're intending.

@jo3bingham thought someone could be working on it silently. Not the case, apparently. :P
I'm still figuring out the source code (the what, how and why), so if you guys have any additional insights on the back of your heads, please share them 'cause I'm very interested. 馃榿

@foxrother @ranisalt said he was working on #2169, and was assigned to it, but that was 20 months ago. In an ideal world, people would assign themselves to an issue before working on it so as not to clash with someone else.

Also, I agree with this comment, this issue (or epic, in this case) should be split up into individual issues like #2169. If you want to do the Lua, you should pick that issue up. If you want to do another area, you should create a new issue, link it to the project, and assign yourself. Apart from creating new issues, you probably can't do the other things so it would be best to ask for those things in the issue comment.

@jo3bingham there are not many active contributors as of late (sadly & understandably), so even though I saw and agree with these, I had to ask it here, (since this issue shares its name with the project and seems to be where this enhancement got more attention).

I'll assign these to myself soon, thank you for explaining that.

The broader discussion on the whole src folder belongs to here, though, right?
As you pointed out, you guys already thought of creating separate network and lua folders.
If you have any other thoughts on what else could be bundled in separate folders, it would be nice to say here.
Right now I'm really not in a position to suggest these things, but I'd like to be seen as a resource to delegate tasks to (since you guys are busy). Some rough directions would suffice.

The broader discussion on the whole src folder belongs to here, though, right?

Yeah.

If you have any other thoughts on what else could be bundled in separate folders, it would be nice to say here.

IO stuff seems like a good candidate. Maybe Creature and related classes (Player/Monster/NPC)? But Lua is the biggest one; luascript.cpp is completely out-of-hand and is only getting worse.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

TwistedScorpio picture TwistedScorpio  路  5Comments

Imperians picture Imperians  路  4Comments

EPuncker picture EPuncker  路  4Comments

GoularPink picture GoularPink  路  4Comments

wo11ven picture wo11ven  路  5Comments