server:running_the_server:compressed_map_files
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
server:running_the_server:compressed_map_files [2018/03/13 03:07] – Add text about linking the map file to the map.gz file karl | server:running_the_server:compressed_map_files [2025/04/18 13:08] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
======= Compressed maps files ======= | ======= Compressed maps files ======= | ||
When operating the [[:server]] , the [[: | When operating the [[:server]] , the [[: | ||
- | [[environment_variables|CROSSFIRE_LIBDIR]]/ | + | [[environment_variables|CROSSFIRE_LIBDIR]]**/maps** can take up to 400 MB of space on the hard-disk. |
- | The server is able to operate on compressed map files, which | + | Until version 1.60.0 and below, the server is able to operate on compressed map files, which |
- | would then just take up the space of the compressed tarball they came in. | + | would then just take up the space of the compressed tarball they came in. \\ |
+ | Since around SVN revisions r14859 to r14871 in July 2011 the compression related code has been removed from the source code; \\ | ||
+ | saying that since 1.70.0 and beyond the server does not handle compressed maps files anymore. | ||
- | But it needs to find out, if the server actually | + | The compression related code is found in // |
- | such compressed | + | <code c> |
+ | /** | ||
+ | * This is a list of the suffix, uncompress and compress functions. | ||
+ | | ||
+ | * that needs to be done is to extended this. | ||
+ | * The first entry must be NULL - this is what is used for non | ||
+ | | ||
+ | */ | ||
+ | const char *uncomp[NROF_COMPRESS_METHODS][3] = { | ||
+ | { NULL, NULL, NULL }, | ||
+ | { " | ||
+ | { " | ||
+ | { " | ||
+ | }; | ||
+ | </ | ||
+ | |||
+ | And the functions are : | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
- | The simple test would be to compress the early map files HallOfSelection | + | To find out, if the server actually is able to open compressed map files, \\ |
+ | would be to compress the early map file HallOfSelection | ||
and probably the files in the //start// folder. \\ | and probably the files in the //start// folder. \\ | ||
On Linux it would be | On Linux it would be | ||
Line 15: | Line 37: | ||
* '' | * '' | ||
* '' | * '' | ||
- | * **TODO** : check for lzip, lzop, lzma, xz compressions | ||
Either the server keeps going, or would abort and send a message to the logfile as | Either the server keeps going, or would abort and send a message to the logfile as | ||
Line 23: | Line 44: | ||
> | > | ||
- | and when creating a link // | + | and when creating a link // |
> | > | ||
> | > | ||
Line 31: | Line 52: | ||
> | > | ||
> | > | ||
- | + | ||
- | When the server supports compressed map files, and it is desired to use compressed map files, | + | |
- | then some code has to filter out files inside the maps directory, | + | ---- |
+ | |||
+ | ===== Compression == | ||
+ | |||
+ | When the server supports compressed map files, and it is desired to use compressed map files, | ||
+ | then some code has to filter out files inside the maps directory, | ||
that are better left uncompressed. \\ | that are better left uncompressed. \\ | ||
:!: By all means, any .sh, .pl and .py script files need to be untouched. | :!: By all means, any .sh, .pl and .py script files need to be untouched. | ||
+ | |||
+ | The below bash code assumes that the script needs to run from a controlling terminal, \\ | ||
+ | and that it would be located in the top level of the maps directory among the \\ | ||
+ | many folders and files like HallOfSelection , regions | regions.reg , HallOfDMs . \\ | ||
+ | Furthermore it omits files, that are (permanent) apartment, private shop and guilds related. \\ | ||
+ | |||
+ | Of course, both //gzip// commands can be replaced by the desired compressor; f.ex // | ||
+ | |||
+ | In the below code **gzip** had been selected, since it allows easy recursive decompression of directories by '' | ||
+ | |||
+ | Jump to [[#End Compression]] . | ||
A shell code script to compress the map file using //gzip// could look as | A shell code script to compress the map file using //gzip// could look as | ||
Line 52: | Line 89: | ||
-a -not -wholename " | -a -not -wholename " | ||
-a -not -wholename " | -a -not -wholename " | ||
- | -a -not -wholename " | + | -a -not -wholename "*/*apartment*" |
- | -a -not -wholename " | + | -a -not -wholename "*/*Apartment*" |
- | -a -not -wholename " | + | -a -not -wholename "*/*APARTMENT*" |
+ | -a -not -wholename " | ||
+ | -a -not -wholename " | ||
+ | -a -not -wholename " | ||
+ | -a -not -wholename " | ||
+ | -a -not -whonename " | ||
+ | -a -not -wholename " | ||
+ | -a -not -wholename " | ||
-a -not -name " | -a -not -name " | ||
-a -not -name " | -a -not -name " | ||
Line 64: | Line 108: | ||
-a -not -name " | -a -not -name " | ||
-a -not -name " | -a -not -name " | ||
+ | -a -not -name " | ||
+ | -a -not -name " | ||
+ | -a -not -name " | ||
+ | -a -not -name " | ||
+ | -a -not -name " | ||
+ | -a -not -name " | ||
+ | -a -not -name " | ||
+ | -a -not -name " | ||
+ | -a -not -name " | ||
+ | -a -not -name " | ||
-a -not -name " | -a -not -name " | ||
-a -not -name " | -a -not -name " | ||
-a -not -name " | -a -not -name " | ||
-exec gzip {} \; | -exec gzip {} \; | ||
+ | |||
</ | </ | ||
- | The above code assumes that the script needs to run from a controlling terminal, | ||
- | and that it would be located in the top level of the maps directory among the | ||
- | many folders and files like HallOfSelection , regions | regions.reg , HallOfDMs . | ||
- | Furthermore it omitts (for now) files, that are (permanent) apartment related. | ||
- | Of course, both //gzip// commands can be replaced by the desired compressor; f.ex // | + | == End Compression == |
+ | Jump up to [[# | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ===== Bugs and Patches == | ||
+ | |||
+ | The code has a flaw even until version 1.60.0 of the server trying to rename(filename, | ||
+ | are identical. A bit further down, both file names get a different name by TEMP_EXT " | ||
+ | put that code there also in file // | ||
+ | <code diff> | ||
+ | if (m-> | ||
+ | char buf[MAX_BUF]; | ||
+ | snprintf(buf, | ||
+ | snprintf(final, | ||
+ | + | ||
+ | fp = popen(buf, " | ||
+ | </ | ||
+ | And probably use strcmp 2 times near and at the very end: | ||
+ | <code diff> | ||
+ | --- 1411,1461 ---- | ||
+ | } else { | ||
+ | fflush(fp2); | ||
+ | fclose (fp2); | ||
+ | unlink(final_unique); | ||
+ | ! | ||
+ | ! if ( ( strcmp(buf, final_unique) != 0 ) && rename(buf, final_unique) == -1) { | ||
+ | ! | ||
+ | ! if (m-> | ||
+ | ! | ||
+ | ! } else { | ||
+ | ! | ||
+ | ! } | ||
+ | return SAVE_ERROR_URENAME; | ||
+ | } | ||
+ | chmod (final_unique, | ||
+ | } | ||
+ | |||
+ | unlink(final); | ||
+ | ! if (rename(filename, | ||
+ | ! | ||
+ | return SAVE_ERROR_RRENAME; | ||
+ | |||
+ | unlink(final); | ||
+ | ! if ( (strcmp(filename, | ||
+ | ! | ||
+ | return SAVE_ERROR_RRENAME; | ||
+ | </ | ||
+ | |||
+ | ==== 1.11.0 == | ||
+ | |||
+ | The code is faulty in version 1.11.0 of the server, not pclose' | ||
+ | The main errors are fixed in at least version 1.50.0, so it is a little bit disturbing, \\ | ||
+ | why the compression code had been removed since 1.70.0 . | ||
+ | |||
+ | Basically it is about backporting the code from v.1.50.0 . | ||
+ | |||
+ | --- | ||
+ | 4 times pclose or fclose in **new_save_map()** ( common/ | ||
+ | otherwise hundreds of shell commands compress will still be sleeping running and visible in a terminal through **ps** output: | ||
+ | <code diff> | ||
+ | --- 1359,1402 ---- | ||
+ | if ((flag == SAVE_MODE_NORMAL || flag == SAVE_MODE_OVERLAY) && !m-> | ||
+ | char final_unique[MAX_BUF]; | ||
+ | | ||
+ | snprintf(final_unique, | ||
+ | snprintf(buf, | ||
+ | + | ||
+ | + | ||
+ | if ((fp2 = fopen (buf, " | ||
+ | ! | ||
+ | ! if (m-> | ||
+ | ! | ||
+ | ! } else { | ||
+ | ! | ||
+ | ! } | ||
+ | return SAVE_ERROR_UCREATION; | ||
+ | </ | ||
+ | **Note**: m-> | ||
+ | --- | ||
+ | |||
+ | --- | ||
+ | **res** needs to be set beforehand in **save_objects()** ( common/ | ||
+ | <code diff> | ||
+ | int save_objects (mapstruct *m, FILE *fp, FILE *fp2, int flag) { | ||
+ | ! int i, j = 0,unique=0, res=0; | ||
+ | object *op, *otmp; | ||
+ | + | ||
+ | /* first pass - save one-part objects */ | ||
+ | for(i = 0; i < MAP_WIDTH(m); | ||
+ | for (j = 0; j < MAP_HEIGHT(m); | ||
+ | </ |
server/running_the_server/compressed_map_files.1520928423.txt.gz · Last modified: (external edit)