xahodo {l Wrote}:This project in its current state is a pile of spaghetti code, in which classes are used as an excuse for OO code.
I happen to be quite proud of my design as a matter of fact. The design manages to abstract most of the underlying working code into accessors methods without too complex of a call chain to get to the "tight loop" code which is speed critical. There are certainly places where it needs some reorganizing but it is not "spaghetti code" by a long shot.
xahodo {l Wrote}:Since when are things like rendering, AI and pathfinding the worry of the class which is responsible for managing the map?
They aren't. The GameMap class is responsible for managing the game map, hence its name. AI is done in the Creature class and rendering is done in ExampleFrameListener class (it uses a semaphore protected message queue to allow other threads to perform rendering ops without creating race conditions or deadlocks). The pathfinding is actually the "worry" of the GameMap class because it involves the GameMap. By putting it in there it avoids having to do accessor calls to other classes in one of the most time critical pieces of code there is.
xahodo {l Wrote}:Whichever moron decided that using the vector class from STL is a good idea? You are aware that STL uses lots and lots of exceptions and that exceptions are a definite no-no for real time games, aren't you?
The same moron that is dumb enough to respond to rants like yours, the moron who wrote the vast majority of the code (which you would know if you had bothered to check the git logs), and the moron who moderates this forum and is wondering if it is worth taking the time to figure out how to ban users who make uninformed claims without bothering to back them up with reasoned argument. As to your assertion that the STL uses lots of exceptions, that may very well be the case and is really the only legitimate point you
may have made. I say may because although I wasn't previously aware of this specific issue I
had considered the performance implications using templated STL classes instead of handrolling my own. I then weighed this consideration against the potential impact on code readability, maintainability, reliability, and cross platform issues and decided that it made
far more sense to use the STL implementations. Weighing heavily on my decision was the fact that something like 85% of security vulnerabilities in C and C++ code come from buffer overflows, which are greatly reduced by sticking to tried and tested STL code which throws exceptions when exceptional circumstances occur instead of just crashing the engine, or worse, allowing for arbitrary code execution injected by the untrusted people you are gaming with. Furthermore, you might be confusing
Real-time strategy games which are a common gaming genre and
Real-time computing which is a field of computer science dedicated to writing code to run on time critical devices where human lives are often at risk if critical routines take even slightly longer than they are supposed to. Confusing these two terms is a very common mistake as they have a lot in common.
xahodo {l Wrote}:Why not keep things simple and use a static map array (but not for the creatures) which uses 64 bits to store all information needed per tile (owner, type, precise content, etc.). If you remove creatures from the map and keep track of them individually and figure out via some hash-table which one is where (for the viewport).
Well lets see, x and y positions that's 2*16 or 32 bits for position, lets say 4 bits for color (if we set a maximum of 16 seats which I don't like), 4 bits for type, 8 bits for fullness that gives us 48 bits so far. Yeah it looks like I could get all or at least most of the information into a 64 bit unsigned int. Then I could spend a few weeks trying to debug the issues that pop up when it is ported across platforms or onto other hardware. I would also have to give up the ability to do O(log(n)) lookups on tile positions and instead go with O(n) array searches; either that or I could nix the ability to have dynamically expanding non-rectangular maps. But why worry about throwing out one of the key innovations that sets my game apart from the half-dozen other DK clones when I can save
5 whole megabytes of RAM usage.
xahodo {l Wrote}:Also; the rendering engine has no business in the map array whatsoever other then figuring out what to render where (translation: . To make sure surface irregularities are rendered correctly, there should be another map of which it is the sole job to track surface irregularities.
I really have no idea what your talking about here. The rendering engine has no more connection to the map tiles than it does to any other class representing a visible object. I don't know what you mean by surface irregularities and frankly don't care.
xahodo {l Wrote}:You also seem to forget about cache missed and hits. This will hurt performance in the long run.
Cache misses,
cache misses, CACHE MISSES?!? You, the person who keeps nagging about including scripting into the core of the game engine and wants the server to do a perodic hash of the ENTIRE game state, are concerned about cache misses. Tell me, how many cache misses does it take to equal the amount of time spent by a call to a script interpreter. Keep in mind that calling the interpreter will likely involve a processor context switch which means flushing the translation lookaside buffer, pushing the registers onto the stack, exectuing a far jump to a new segment, running the code for the interpreter which will likely muck up the cache anyway, then a far jump back, popping all the registers, converting the results of the script back into something my game engine can handle, and a slow agonizing period while the translation lookaside buffer repopulates.
I have no problem with criticism of my design choices involving the game engine. However, if you plan to tell me I should redesign a 15,000+ line codebase of (in my opinion anyway) a pretty well designed system then I would appreciate a bit more
informed criticism. You may want to start by reading the ~25 pages of documentation I wrote on how the design is structured. You may also want to have a look at the threading diagram showing how the message passing works to prevent race conditions in the code. For your conveniece you will find a PNG of that diagram attached to this message. The diagram is a bit out of date and doesn't give you a complete picture of the message semantics however it serves as a basic starting point.
-Buck