Modernizing codebase allowed?

For code related discussions and questions
Post Reply
Vincent
Trained
Trained
Posts: 103
Joined: 06 Aug 2016, 17:24

Modernizing codebase allowed?

Post by Vincent »

I'd like to improve the gfx code of wz2100. However gfx callbacks are spread throughout the whole source code.
Thus I'd like to modernize codebase to ease future improvement. Using namespace and adding directory is a first step but I intend to use c++14 where applicable and replace some structure (vector affine) with glm counterpart.
Is it OK for wz project? It will likely break compatibility with older compiler but I'm expecting better maintainability by using modern dev practice and standard structure.
Cyp
Evitcani
Evitcani
Posts: 784
Joined: 17 Jan 2010, 23:35

Re: Modernizing codebase allowed?

Post by Cyp »

We're already using at least C++11 (not sure whether that was decided, or whether it just happened).

Think someone might have tried doing something like this before, not sure whether it got finished: https://github.com/Safety0ff/warzone210 ... csfixredux

If trying to merge it, there's only 187 merge conflicts, which isn't as bad as I expected, especially since I think there have been some complete reformatting of the code since then (with astyle).
Per
Warzone 2100 Team Member
Warzone 2100 Team Member
Posts: 3780
Joined: 03 Aug 2006, 19:39

Re: Modernizing codebase allowed?

Post by Per »

Modernization would be very welcome, in general.

There are some limitations, compiler-wise, as we need to be able to cross-compile to Windows, and compile on MacOSX. I don't know what those limits are, currently, though. What are the c++14 features that you would like to use?

The codebase is very convoluted, with lots of static globals everywhere. Turning them into classes would be a good idea. We try to incrementally clean up and improve this up as we go, and patches to assist in this would be welcome. Probably a good idea to discuss ideas before coding them, if they involve larger reorganizations.
Vincent
Trained
Trained
Posts: 103
Joined: 06 Aug 2016, 17:24

Re: Modernizing codebase allowed?

Post by Vincent »

I'd rather use c++14 feature supported by MSVC since it slightly lag behind other compiler in C++14 support (afaik clang and gcc do support c++14 completly).
For instance std::make_unique is not available in c++11 but is in C++14 and constexpr behavior was slightly modified wrt const method.

A first step would be to move everything in a namespace ; I think "maths" "ui" "render" "sound" "network" "ai" namespaces would be a good starting point.
I'm also thinking of removing vector/Affine and custom matrix in favor of the one in glm.
Vincent
Trained
Trained
Posts: 103
Joined: 06 Aug 2016, 17:24

Re: Modernizing codebase allowed?

Post by Vincent »

Is it OK to use directwrite on Windows? Quesoglc has a lot of dependencies and is strongly tied to opengl fixed function. On the other hand directwrite is gfx api agnostic which would make possible to use opengl 3+ and vulkan api while retaining support for right to left layout.

Pangs is also another option for Linux but I have no experience with it.
jsnipy
New user
Posts: 2
Joined: 25 Aug 2016, 01:42

Re: Modernizing codebase allowed?

Post by jsnipy »

What are feelings about porting it to Unity? :ninja:
Vincent
Trained
Trained
Posts: 103
Joined: 06 Aug 2016, 17:24

Re: Modernizing codebase allowed?

Post by Vincent »

Why porting wz to another engine instead of improving the existing one ? It would take likely more time to improve current engine than porting to another one.
Per
Warzone 2100 Team Member
Warzone 2100 Team Member
Posts: 3780
Joined: 03 Aug 2006, 19:39

Re: Modernizing codebase allowed?

Post by Per »

Note that our codebase cannot be ported to Unity for legal reasons, even if it somehow were a good idea.
Vincent
Trained
Trained
Posts: 103
Joined: 06 Aug 2016, 17:24

Re: Modernizing codebase allowed?

Post by Vincent »

I've added shaders for water and terrain, I think only shadows are the only remaining effect that use fixed function pipeline.
Jorzi
Regular
Regular
Posts: 2063
Joined: 11 Apr 2010, 00:14

Re: Modernizing codebase allowed?

Post by Jorzi »

Hi
This sounds really interesting. How hard would it be to render a reflection map for the water (essentially mirror the camera along the water surface and render to an off-screen buffer)
ImageImage
-insert deep philosophical statement here-
Vincent
Trained
Trained
Posts: 103
Joined: 06 Aug 2016, 17:24

Re: Modernizing codebase allowed?

Post by Vincent »

Not trivial. The codebase is quite convoluted, some object are stored in a list that could be parsed twice but it will require some works.
Jorzi
Regular
Regular
Posts: 2063
Joined: 11 Apr 2010, 00:14

Re: Modernizing codebase allowed?

Post by Jorzi »

I see. Of course, not everything would need to be reflected. Just the terrain and skybox would already be quite convincing.
Either way, I appreciate what you're doing :)
ImageImage
-insert deep philosophical statement here-
jsnipy
New user
Posts: 2
Joined: 25 Aug 2016, 01:42

Re: Modernizing codebase allowed?

Post by jsnipy »

Vincent wrote:Why porting wz to another engine instead of improving the existing one ? It would take likely more time to improve current engine than porting to another one.
There are/will be limitation when it comes to testing and maybe extending the number of platforms. Current is not awful just would be good to keep it living well into the future.
Per wrote:Note that our codebase cannot be ported to Unity for legal reasons, even if it somehow were a good idea.
I had a hunch there would be something but am law nub. What aspect of unity's legal make this an issue?
Post Reply