Panthera Leo wrote:First, To keep things "1(1)" I've added the "map layer" array to the map class I'm writing. I did so because on examining 'map.h' I saw the array and the macros referencing it. I assumed it was a requirement, and coded it. Now that I'm almost done with it I'm looking over all the code in detail to make sure what I did lines up with what should be. I can not understand what the layers array is used for beyond 'memcpy' is currently taken care differently in my build with class inheritance:
Which "map layer" variable (or field?) are you talking of?
Panthera Leo wrote:Second, On the issue of map loading taking so much time. I'd like to change the format, or convert to byte codes. However, as I'm frequently reminded, and rightly so, that would not be "1(1)". I'd like feed back on add a "sub-system" to catch map information in binary format. Not a idea solution, but a server could write a binary version of a map file(s) along side the current map files for quicker loading, and easy indexing. On exit, or on command the files could be reset to their current format for editing or other use.
The real problem is not that map loading is too slow but that loading maps containing a huge number of objects affects unrelated players. Currently the server does all processing in one thread. Therefore any action that takes more than a fraction of a second (for example loading a huge map file) stalls all other actions (for example movement of other players).
A conversion to binary format might speed up map loading. But this speed up would be just O(1) (i.e., having a constant factor related to the number of objects within the map). Therefore the initial problem remains, no matter how fast a binary format could be loaded: players would just adapt and stuff more items into their apartments until the lag again gets noticeable.
OTOH, converting all map files into a binary format (IMO) has some severe drawbacks: all existing tools have to be adapted; simple examination or modification of map files (using less, grep, vi, sed, etc.) does not work anymore; corrupted map files (for whatever reason) cannot be fixed easily; the server has much less possibilities to detect corrupted map files, so chances are that problems will not be noticed for a long time.
Storing the binary map files just as cached versions of the original plain text files also has drawbacks: checking and converting all map files at server startup would take much time (and would require write access to map files from the user starting the server); opening swapped map files with the editor would not work anymore; two map file formats would have to be maintained.
IMO a "proper" fix could include preventing too many items per map and/or per tile. In-game explanation: there is just not more space for the items available.
Another possible fix could be to make the server multi-threaded. In such a server, loading a huge map would still cause lags. But the lags would affect only the player(s) related to this map. (But as this would definitely cause many new issues (due to race conditions), I'd vote against this change.)
That said, I'd strongly vote against a binary map file format.
Panthera Leo wrote:Third, could I include SDL in the rebuild? It would include it's own timer that would work in a "1(1)" manner. Would allow for future multi-threading and 2D GUIs.
Crossfire already needs quite a few libraries. This makes it inconvenient to just "download and compile" it. Adding yet another library would not help this situation.
Generally speaking: adding a new library is ok but should provide much improvements. Just "would allow for future ..." is not a good argument to me: Crossfire already consists of zillions of features that someone did add because "it could be useful sometime". Most of these features are not used in-game.
(All "IMO", of course.)
Panthera Leo wrote:Failing that, may I defer to "ISO C99: 7.18 Integer types <stdint.h>" to handle the uint and sint types?
AFAIK Crossfire code should be C89 (not C99). I think part of it is because no C99 Windows based compiler exists. (Ignoring gcc which I think nobody uses for compiling a Crossfire server on Windows.)
Generally speaking: I would not object switching to C99. Especially since quite often commits already add C99 specific code such as mixing declarations and statements, using // comments, or calling C99-only functions such as snprintf().