Hi guys,
as you may have noticed there is a new branch called classesRefactoring1 in the SVN. It’s the first part of a major code refactoring and compilation unit re-organization. It will take some time to finish those steps and I hope it goes off without a hitch.
This branch includes following changes compared to the trunk revision 2479, which is at the time of writing the most recent trunk revision:
[ul]
]Introduction of pre compiled header files. STL, iostream, boost libraries, vstd library, logger functionality and some macro resides in those files.
/:m]
]Redundant include directives have been removed.
/:m]
]Include guards have been replaced consistently with #pragma once.
/:m]
]THex is now named HexField(should be named CHexField, sth. for next revision) because of a naming clash with the Hex Field class of the battle interface. You can find HexField in /lib/HexField.cpp/.h. Thats means it has now it’s own compilation unit.
/:m]
]Constants and enums have been moved to GameConstants.h. They should not be moved into PCH, because they are likely to change. Not every compilation unit should get compiled when changing this file.
/:m]
]VCMI_DLL macro has been removed. That constant is now set directly at project pre compiler definitions.
/:m]
]Macro DLL_EXPORT has been renamed to DLL_LINKAGE to avoid confusion.
/:m]
]RegisterTypes.cpp is now located in .h file. Things changed a lot and some macros related to it get unnecessary.
/:m]
]Compiler warning set to level 3
/:m]
]All project parts(client,lib,…) on Linux and Windows have now the same compilation units. Server and Client on Linux had CConsoleHandler and ThreadHelper, which was different on Windows with VS project settings. Those files are now part of the lib project consistently included with some other header files(int3.h,StartInfo.h,…)
/:m]
] I’ve removed nodrze.h and the hch folder as they were unnused. Is this okay?/:m][/ul]
Above points help mostly to reduce compile times, but this wasn’t my actual intention why I’m started the whole stuff. I mainly wanted to have two things. A better separation of classes and a consistent naming scheme of classes,enums,structs,… This is needed to keep the code consistent, to introduce some guidelines we all follow and the most important point to have things quite clearly separated. This gives us a good base for further code maintenance / refactoring and mod support.
The first part split up the classes which reside formerly in the CBattleInterface.cpp/.h unit and can now be located under client/BattleInterface. I tried to change at least as possible, so normally you can work further mostly the same way as before.
Comprehensive list of old names and new names of those classes:
CBattleAttack = CAttackAnimation
CBattleAnimation = CBattleAnimation
CBattleConsole = CBattleConsole
CBattleHero = CBattleHero
CBattleInterface = CBattleInterface
CBattleOptionsWindow = CBattleOptionsWindow
CBattleResultWindow = CBattleResultWindow
CBattleStackAnimation = CBattleStackAnimation
CDefenceAnim = CDefenceAnimation
CDummyAnim = CDummyAnimation
CBattleHex = CHexFieldControl
CMeleeAttack = CMeleeAttackAnimation
CBattleStackMoved = CMovementAnimation
CBattleMoveStart = CMovementStartAnimation
CBattleMoveEnd = CMovementEndAnimation
CReverseAnim = CReverseAnimation
CShootingAnim = CShootingAnimation
CSpellEffectAnim = CSpellEffectAnimation
SStackAttackedInfo = SStackAttackedInfo
CStackQueue = CStackQueue
SStackAttackedInfo = SStackAttackedInfo
Next steps
I don’t know about the exact course of events if we do the next steps first only for the branch and then merge with trunk or incrementelly merge branch and trunk several times.
@Tow: Could you say which way is the best to get this done right?
I don’t want to give a time schedule, as it’s not easy to say. Next steps are to split up further units like GUIClasses, AdvMapInt,… and to re-arrange them properly.
Compile times
Lib
Branch: 2:03min, Trunk: 2:56min(vc9);
Branch: 2:10min (vc10);
Branch: 2:47min, Trunk: 3:25min(gcc);
Client
Branch: 2:15min, Trunk: 3:05min(vc9);
Branch: 1:56min (vc10);
Branch: 6:42min, Trunk: 7:22min(gcc);
Server
Branch: 0:53min, Trunk: 0:38min(vc9);
Branch: 0:44min (vc10);
Branch: 0:51min, Trunk: 1:09min(gcc);
Genius
Branch: 0:25min, Trunk: 0:39min(vc9);
Branch: 0:22min (vc10);
Branch: 0:29min, Trunk: 0:32min(gcc);
Stupid
Branch: 0:11min, Trunk: 0:09min(vc9);
Branch: 0:14min (vc10);
Branch: 0:15min, Trunk: 0:09min(gcc);
ERM
Branch: 5:39min, Trunk: 3:45min(vc9);
Branch: 5:05min (vc10);
Compile times describe the time for a full rebuild. Normally you wouldn’t do that with PCH files. They should never change or only rarely. Compilation of PCH file took 10seconds on gcc and 5 seconds with vc++, so you can substract that time from all measured branch values. GCC profits most of PCH files. Client on gcc took so much time because of the slow compilation of the musichandler.cpp. ERM took much longer with PCH, don’t know why, perhaps it doesn’t make so much use of the boost library which are defined in the header file for that project. This could be adjusted. But in general compile times are definely shorter.
Coding guidelines
With that branch we also introduce a set of coding guidelines. You can see them in the wiki.
wiki.vcmi.eu/index.php?title=Coding_guidelines
They aren’t carved in stone yet, so you should wait some days till they are final.
Have a nice day,
beegee