Closed SandroWissmann closed 2 months ago
Gosh, this is a LOT of stuff haha. It's gonna take me a long time to go through all this, and I'm afraid if you ask about every single compilation warning/return line out of place/etc. you'll find hundreds if not thousands, some of them from the original codebase, some left in there by debugging by me. My advice is to go right ahead and remove/correct them as you see fit, if you think they serve no purpose, otherwise ignore them as I might still use them in the future for printing stuff. The whole project is mostly in the "make it work" phase first, so things are always in flux and I did not bother with cleaning stuff up.
Regarding conventions: I have not given any thought about it yet, I just mostly go with the flow since no single convention fit perfectly for every case; but for class names, I think capital camelcase works well (ClassName
) and for the actual variables I always use lowercase with underscores; things like p_
and double underscores etc. aren't harmful to have if you wish, I don't mind them, I just never do it because I'm lazy.
The setting files, user files, asset files, pak, saves, maps, scores, etc. are not fully mapped yet (likely never will be), and in the original code from Julius you can see many instances of variables like unused_f61
that denote fields that were leftover from the original game development, unused, or the purpose isn't clear yet. Some of these could even be repurposed to new things and possibly new features in the game.
I've been documenting everything that I can in the comments and my notes, but if you're curious the biggest one that you can read through is this: https://banderi.github.io/ozymandias-extra/?url=pharaoh_datasheets.ods
I think I've tried compiling with C++17 before and it failed, but I'd have to double check when I can. I've only set it to C++14 because I wanted some of the struct initialization styles that aren't available before, and maybe they don't work afterwards either. Again, I'd have to double check to be sure though! I left a comment somewhere in the code about it, though.
In all honesty I'm trying to think how to move forward from here, and how to handle PRs and such (it's also my first time) because as I said, I'm really hesitant to pour much if any more work into this one; I will start fresh, and fixing rogue warnings about return lines is really a waste of time at least from my part. But at the same time, I'm amazed that other people are finding interest in this, and I don't want to stop them from contributing! This already is a huge amount of work very quickly, I could never hope to match that myself, so I commend you, but I also likely would never be able to keep up if I need to approve every single change like all these by myself. I think maybe a good compromise would be, few PRs but big, with cursory descriptions, and so long as they don't break everything I'd be happy to do a quick test and merge?
Maybe it could be less headache to have a dedicated branch as you mentioned in the other thread. Should I do that instead?
And then I guess if would just take periodically merging into master
to bring the stuff over, I guess?
I still think we should work on separate branches or mine gets merged into yours (like it is now) to avoid regressions. Otherwise it will be also a big pain because after each other commit we would need to rebase.
Another thing we can also do if you want that you also work only on a branch and also create a branch and I maybe review your changes. Just to give some advises.
I can understand that this branch stuff is new and scary. I also needed to learn it when I started professionally working with more then one person on a project. But in the end its not that horrible. I can help you here if you have questions.
Regarding this PR:
I know this change looks huge. What you should take a look at is settings.h / settings.cpp that basically changed the freestanding functions into a proper class for usage. All the other 1000 files is just the calling of the functions from the settings or changing enum to enum class. So this is always the same.
I think if we gradually convert the code like this to classes it could be very helpful.
Also maybe it is a good idea if next time I announce before what to touch so we don't touch so much the same area.
Regarding C++17: Please type g++ --version in your terminal under windows. Maybe you use an older version of mingw and thats why C++17 gives trouble. Normally there should not be something removed between 14 to 17 it was not a too big change so I think we could switch to it.
btw: Our compilers are almost the same because MinGW uses g++ which I also use directly under linux. Maybe its just the version.
Regarding review the stuff: The TODO comments were I saw something strange can also just stay and you / we think about it / fix it when we have to touch that area. At least I suggest you check settings.h / settings.cpp and let me know if this kind of style is ok for you. Because I would continue transform other parts of the code like that.
For now I would also still check if the code runs right under linux / windows. I just need to get it to work in windows vm.
Here the settings changes (can be also find in the comit):
One more question for you. In settings.cpp we read the settings from "c3.inf". I believe if it does not exists we will just create it.
However I think for Pharaoh this is the wrong file. Shouldn't it be Pharaoh.inf ?
I can at least see that it contains the player name...
Yes, I believe the correct file is Pharaoh.inf. It's not 100% backward compatible, and I haven't gotten around to check the contents yet since it wasn't much of a priority, so I just left the c3.inf for now for the engine settings.
Out of curiosity I opend c3.inf from original caesar 3 and pharaoh one with a hex editor and also realized that pharaoh one is longer.
c3.inf = 544bytes Pharaoh.inf = 560
I saw you already adapted to this new length 560.
Does it make sense If I open an issue for it to not forget it for later? Maybe even someone else sees it and will do it. Just to not forget.
Yeah, I preemptively made most of the const sizes correct for Pharaoh since they won't mind having too large a buffer.
Hmm, we could open an issue for that, though at the same time I don't want to have a million issues open for every separate thing; for that purpose, it might be better to have a comprehensive list of all the TODOs, fixes needed and missing features in the code, such as this one (I was gonna put it in the README after I clean it up a bit again)
Ok I will atleast add an todo comment inside the code were the file name is so we still see something is there to fix. Would be also good to have this list somewhere to add stuff to it.
Already there!
I just looked now and saw it. So it should be fine. still maybe add to your list. depending on if pharaoh saves more stuff in it this could be a bigger rework. there are also these weired coded values like personal savings to understand...
Ok I rebased to latest master, fixed the merge conflicts and build this again on windows and linux and it looks like it still works.
I'm looking through the changes atm;
One thing I'm noticing is that there's a need of calling instance()
every time, which I would like to avoid. Also, any particular reason for the static_cast
s? I would avoid it unless absolutely necessary, automatic casting is fine generally.
Plus, not sure if it's an automatic change by your formatter, many inclusions have been changed from "" to <> which I reserve for system headers.
The instance is like temporary until we fix all the other code and eliminate this singleton. It also shows now that we have this (ugly) singleton.
The static casts are needed because we have now a type safe enum class instead of a plain enum. I think with refactor the code around these casts should be mostly also eliminated later. Because more ints should be enums in the end.
The includes like <> in the library should be ok because they are also registered like that in CMake to refer to them like that. But if your convention here is to include all the non system files with "" instead of <> I can also change it.
Oh interesting, I didn't know CMake had it set up like that! Is it a leftover convention from the original project? In the codebase, all of the includes were originally with the "" convention, for example, in here: https://github.com/Keriew/augustus/blob/master/src/game/file_io.c
I also set up a formatter extension in CLion to help me set them automatically like that, since CLion's auto-includes use <> by mistake sometimes and it mixes them up randomly.
Ok I will check it then tomorrow and revert it to be consistent here.
Ok I pushed already the renaming of the headers. Let me know if anything else is missing.
First of all. This pull request is still a draft because two things should be done before:
Content of this pull request:
So in short I did the following:
settings.h
intoclass Settings
I also run into a function
calc_bound
in the settings which does exactly the same asstd::clamp
(Except that std::clamp is more typesafe). So I removedcalc_bound
complete and replaced it withstd::clamp
.I realized in CMake we had only C++14 but I changed it to C++17 since it is not a big step but gives us many beenfits. Let me know if thats okay.
Some questions I also have:
Should Class names be capital or do we want to follow the old style. So is it
class Settings
or classsettings
.Same question for the case. Is it
class SoundSetting
orSound_setting
orsound_setting
. I just thing we should be consistent.I run into some wired things to discuss I will mark them here with comments.
Let me also know what you think about the style. I tried to make it as clean as possible.