1 | /* |
1 | /* |
2 | * static char *rcsid_map_c = |
2 | * static char *rcsid_map_c = |
3 | * "$Id: map.c,v 1.5 2006/02/22 19:08:43 root Exp $"; |
3 | * "$Id: map.c,v 1.7 2006/03/07 13:44:42 root Exp $"; |
4 | */ |
4 | */ |
5 | |
5 | |
6 | /* |
6 | /* |
7 | CrossFire, A Multiplayer game for X-windows |
7 | CrossFire, A Multiplayer game for X-windows |
8 | |
8 | |
… | |
… | |
38 | #include "path.h" |
38 | #include "path.h" |
39 | |
39 | |
40 | |
40 | |
41 | extern int nrofallocobjects,nroffreeobjects; |
41 | extern int nrofallocobjects,nroffreeobjects; |
42 | |
42 | |
|
|
43 | void (*load_original_map_callback)(mapstruct *map); |
|
|
44 | void (*load_temporary_map_callback)(mapstruct *map); |
|
|
45 | void (*clean_temporary_map_callback)(mapstruct *map); |
43 | |
46 | |
44 | /* |
47 | /* |
45 | * Returns the mapstruct which has a name matching the given argument. |
48 | * Returns the mapstruct which has a name matching the given argument. |
46 | * return NULL if no match is found. |
49 | * return NULL if no match is found. |
47 | */ |
50 | */ |
… | |
… | |
1049 | close_and_delete(fp, comp); |
1052 | close_and_delete(fp, comp); |
1050 | m->in_memory=MAP_IN_MEMORY; |
1053 | m->in_memory=MAP_IN_MEMORY; |
1051 | if (!MAP_DIFFICULTY(m)) |
1054 | if (!MAP_DIFFICULTY(m)) |
1052 | MAP_DIFFICULTY(m)=calculate_difficulty(m); |
1055 | MAP_DIFFICULTY(m)=calculate_difficulty(m); |
1053 | set_map_reset_time(m); |
1056 | set_map_reset_time(m); |
|
|
1057 | if (load_original_map_callback) |
|
|
1058 | load_original_map_callback(m); |
1054 | return (m); |
1059 | return (m); |
1055 | } |
1060 | } |
1056 | |
1061 | |
1057 | /* |
1062 | /* |
1058 | * Loads a map, which has been loaded earlier, from file. |
1063 | * Loads a map, which has been loaded earlier, from file. |
… | |
… | |
1098 | |
1103 | |
1099 | m->in_memory=MAP_LOADING; |
1104 | m->in_memory=MAP_LOADING; |
1100 | load_objects (m, fp, 0); |
1105 | load_objects (m, fp, 0); |
1101 | close_and_delete(fp, comp); |
1106 | close_and_delete(fp, comp); |
1102 | m->in_memory=MAP_IN_MEMORY; |
1107 | m->in_memory=MAP_IN_MEMORY; |
|
|
1108 | if (load_temporary_map_callback) |
|
|
1109 | load_temporary_map_callback(m); |
1103 | return m; |
1110 | return m; |
1104 | } |
1111 | } |
1105 | |
1112 | |
1106 | /* |
1113 | /* |
1107 | * Loads a map, which has been loaded earlier, from file. |
1114 | * Loads a map, which has been loaded earlier, from file. |
… | |
… | |
1657 | } |
1664 | } |
1658 | |
1665 | |
1659 | void clean_tmp_map(mapstruct *m) { |
1666 | void clean_tmp_map(mapstruct *m) { |
1660 | if(m->tmpname == NULL) |
1667 | if(m->tmpname == NULL) |
1661 | return; |
1668 | return; |
|
|
1669 | if (clean_temporary_map_callback) |
|
|
1670 | clean_temporary_map_callback (m); |
1662 | (void) unlink(m->tmpname); |
1671 | (void) unlink(m->tmpname); |
1663 | } |
1672 | } |
1664 | |
1673 | |
1665 | void free_all_maps(void) |
1674 | void free_all_maps(void) |
1666 | { |
1675 | { |