1 | /* |
1 | /* |
2 | * static char *rcsid_map_c = |
2 | * static char *rcsid_map_c = |
3 | * "$Id: map.C,v 1.7 2006/08/21 02:58:22 elmex Exp $"; |
3 | * "$Id: map.C,v 1.8 2006/08/26 08:44:04 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 | |
… | |
… | |
37 | |
37 | |
38 | #include "path.h" |
38 | #include "path.h" |
39 | |
39 | |
40 | |
40 | |
41 | extern int nrofallocobjects,nroffreeobjects; |
41 | extern int nrofallocobjects,nroffreeobjects; |
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); |
|
|
46 | |
42 | |
47 | /* |
43 | /* |
48 | * Returns the mapstruct which has a name matching the given argument. |
44 | * Returns the mapstruct which has a name matching the given argument. |
49 | * return NULL if no match is found. |
45 | * return NULL if no match is found. |
50 | */ |
46 | */ |
… | |
… | |
1055 | close_and_delete(fp, comp); |
1051 | close_and_delete(fp, comp); |
1056 | m->in_memory=MAP_IN_MEMORY; |
1052 | m->in_memory=MAP_IN_MEMORY; |
1057 | if (!MAP_DIFFICULTY(m)) |
1053 | if (!MAP_DIFFICULTY(m)) |
1058 | MAP_DIFFICULTY(m)=calculate_difficulty(m); |
1054 | MAP_DIFFICULTY(m)=calculate_difficulty(m); |
1059 | set_map_reset_time(m); |
1055 | set_map_reset_time(m); |
1060 | if (load_original_map_callback) |
1056 | INVOKE_MAP (LOAD, m); |
1061 | load_original_map_callback(m); |
|
|
1062 | return (m); |
1057 | return (m); |
1063 | } |
1058 | } |
1064 | |
1059 | |
1065 | /* |
1060 | /* |
1066 | * Loads a map, which has been loaded earlier, from file. |
1061 | * Loads a map, which has been loaded earlier, from file. |
… | |
… | |
1106 | |
1101 | |
1107 | m->in_memory=MAP_LOADING; |
1102 | m->in_memory=MAP_LOADING; |
1108 | load_objects (m, fp, 0); |
1103 | load_objects (m, fp, 0); |
1109 | close_and_delete(fp, comp); |
1104 | close_and_delete(fp, comp); |
1110 | m->in_memory=MAP_IN_MEMORY; |
1105 | m->in_memory=MAP_IN_MEMORY; |
1111 | if (load_temporary_map_callback) |
1106 | INVOKE_MAP (SWAPIN, m); |
1112 | load_temporary_map_callback(m); |
|
|
1113 | return m; |
1107 | return m; |
1114 | } |
1108 | } |
1115 | |
1109 | |
1116 | /* |
1110 | /* |
1117 | * Loads a map, which has been loaded earlier, from file. |
1111 | * Loads a map, which has been loaded earlier, from file. |
… | |
… | |
1681 | } |
1675 | } |
1682 | |
1676 | |
1683 | void clean_tmp_map(mapstruct *m) { |
1677 | void clean_tmp_map(mapstruct *m) { |
1684 | if(m->tmpname == NULL) |
1678 | if(m->tmpname == NULL) |
1685 | return; |
1679 | return; |
1686 | if (clean_temporary_map_callback) |
1680 | INVOKE_MAP (CLEAN, m); |
1687 | clean_temporary_map_callback (m); |
|
|
1688 | (void) unlink(m->tmpname); |
1681 | (void) unlink(m->tmpname); |
1689 | } |
1682 | } |
1690 | |
1683 | |
1691 | void free_all_maps(void) |
1684 | void free_all_maps(void) |
1692 | { |
1685 | { |