1 | /* |
1 | /* |
2 | * static char *rcsid_map_c = |
2 | * static char *rcsid_map_c = |
3 | * "$Id: map.C,v 1.24 2006/09/04 16:46:32 root Exp $"; |
3 | * "$Id: map.C,v 1.27 2006/09/08 12:56: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 | |
… | |
… | |
155 | { |
155 | { |
156 | char buf[MAX_BUF]; |
156 | char buf[MAX_BUF]; |
157 | #ifndef WIN32 |
157 | #ifndef WIN32 |
158 | char *endbuf; |
158 | char *endbuf; |
159 | struct stat statbuf; |
159 | struct stat statbuf; |
160 | int mode = 0, i; |
160 | int mode = 0; |
161 | #endif |
161 | #endif |
162 | |
162 | |
163 | if (prepend_dir) |
163 | if (prepend_dir) |
164 | strcpy (buf, create_pathname(name)); |
164 | strcpy (buf, create_pathname(name)); |
165 | else |
165 | else |
… | |
… | |
704 | number_of_entries++; |
704 | number_of_entries++; |
705 | if (p) p++; |
705 | if (p) p++; |
706 | } |
706 | } |
707 | p=shop_string; |
707 | p=shop_string; |
708 | strip_endline(p); |
708 | strip_endline(p); |
709 | items=(shopitems *) CALLOC(number_of_entries+1, sizeof(shopitems)); |
709 | items = new shopitems [number_of_entries + 1]; |
710 | memset(items, 0, (sizeof(shopitems) * number_of_entries+1)); |
|
|
711 | for (i=0; i<number_of_entries; i++) { |
710 | for (i=0; i<number_of_entries; i++) { |
712 | if (!p) { |
711 | if (!p) { |
713 | LOG(llevError, "parse_shop_string: I seem to have run out of string, that shouldn't happen.\n"); |
712 | LOG(llevError, "parse_shop_string: I seem to have run out of string, that shouldn't happen.\n"); |
714 | break; |
713 | break; |
715 | } |
714 | } |
… | |
… | |
1055 | * Return the map object we load into (this can change from the passed |
1054 | * Return the map object we load into (this can change from the passed |
1056 | * option if we can't find the original map) |
1055 | * option if we can't find the original map) |
1057 | */ |
1056 | */ |
1058 | |
1057 | |
1059 | static mapstruct *load_temporary_map(mapstruct *m) { |
1058 | static mapstruct *load_temporary_map(mapstruct *m) { |
1060 | int comp; |
|
|
1061 | char buf[MAX_BUF]; |
1059 | char buf[MAX_BUF]; |
1062 | |
1060 | |
1063 | if (!m->tmpname) { |
1061 | if (!m->tmpname) { |
1064 | LOG(llevError, "No temporary filename for map %s\n", m->path); |
1062 | LOG(llevError, "No temporary filename for map %s\n", m->path); |
1065 | strcpy(buf, m->path); |
1063 | strcpy(buf, m->path); |
… | |
… | |
1199 | */ |
1197 | */ |
1200 | |
1198 | |
1201 | int |
1199 | int |
1202 | new_save_map (mapstruct * m, int flag) |
1200 | new_save_map (mapstruct * m, int flag) |
1203 | { |
1201 | { |
1204 | char filename[MAX_BUF], buf[MAX_BUF], buf_s[MAX_BUF], shop[MAX_BUF]; |
1202 | char filename[MAX_BUF], buf[MAX_BUF], shop[MAX_BUF]; |
1205 | int i; |
1203 | int i; |
1206 | |
1204 | |
1207 | if (flag && !*m->path) |
1205 | if (flag && !*m->path) |
1208 | { |
1206 | { |
1209 | LOG (llevError, "Tried to save map without path.\n"); |
1207 | LOG (llevError, "Tried to save map without path.\n"); |
… | |
… | |
1413 | if (flag && m->spaces) free_all_objects(m); |
1411 | if (flag && m->spaces) free_all_objects(m); |
1414 | if (m->name) FREE_AND_CLEAR(m->name); |
1412 | if (m->name) FREE_AND_CLEAR(m->name); |
1415 | if (m->spaces) FREE_AND_CLEAR(m->spaces); |
1413 | if (m->spaces) FREE_AND_CLEAR(m->spaces); |
1416 | if (m->msg) FREE_AND_CLEAR(m->msg); |
1414 | if (m->msg) FREE_AND_CLEAR(m->msg); |
1417 | if (m->maplore) FREE_AND_CLEAR(m->maplore); |
1415 | if (m->maplore) FREE_AND_CLEAR(m->maplore); |
1418 | if (m->shopitems) FREE_AND_CLEAR(m->shopitems); |
1416 | if (m->shopitems) delete [] m->shopitems; m->shopitems = 0; |
1419 | if (m->shoprace) FREE_AND_CLEAR(m->shoprace); |
1417 | if (m->shoprace) FREE_AND_CLEAR(m->shoprace); |
1420 | if (m->buttons) |
1418 | if (m->buttons) |
1421 | free_objectlinkpt(m->buttons); |
1419 | free_objectlinkpt(m->buttons); |
1422 | m->buttons = NULL; |
1420 | m->buttons = NULL; |
1423 | for (i=0; i<4; i++) { |
1421 | for (i=0; i<4; i++) { |
… | |
… | |
1536 | if (flags & MAP_PLAYER_UNIQUE) |
1534 | if (flags & MAP_PLAYER_UNIQUE) |
1537 | LOG(llevDebug, "Trying to load map %s.\n", name); |
1535 | LOG(llevDebug, "Trying to load map %s.\n", name); |
1538 | else |
1536 | else |
1539 | LOG(llevDebug, "Trying to load map %s.\n", create_pathname(name)); |
1537 | LOG(llevDebug, "Trying to load map %s.\n", create_pathname(name)); |
1540 | |
1538 | |
1541 | //0.427459955215454 /var/crossfire/players/Saladon/_scorn_apartment_apartments |
|
|
1542 | //0.414906024932861 |
|
|
1543 | //0.427063941955566 |
|
|
1544 | eval_pv ("$x = Event::time", 1);//D |
1539 | //eval_pv ("$x = Event::time", 1);//D |
1545 | if (!(m = load_original_map(name, (flags & MAP_PLAYER_UNIQUE)))) |
1540 | if (!(m = load_original_map(name, (flags & MAP_PLAYER_UNIQUE)))) |
1546 | return (NULL); |
1541 | return (NULL); |
1547 | eval_pv ("warn \"LOAD \", Event::time - $x", 1);//D |
1542 | //eval_pv ("warn \"LOAD \", Event::time - $x", 1);//D |
1548 | |
1543 | |
1549 | fix_auto_apply(m); /* Chests which open as default */ |
1544 | fix_auto_apply(m); /* Chests which open as default */ |
1550 | |
1545 | |
1551 | /* If a player unique map, no extra unique object file to load. |
1546 | /* If a player unique map, no extra unique object file to load. |
1552 | * if from the editor, likewise. |
1547 | * if from the editor, likewise. |
… | |
… | |
1610 | */ |
1605 | */ |
1611 | |
1606 | |
1612 | int calculate_difficulty(mapstruct *m) { |
1607 | int calculate_difficulty(mapstruct *m) { |
1613 | object *op; |
1608 | object *op; |
1614 | archetype *at; |
1609 | archetype *at; |
1615 | int x, y, i, diff; |
1610 | int x, y, i; |
1616 | long monster_cnt = 0; |
1611 | long monster_cnt = 0; |
1617 | double avgexp = 0; |
1612 | double avgexp = 0; |
1618 | sint64 total_exp = 0; |
1613 | sint64 total_exp = 0; |
1619 | |
1614 | |
1620 | if (MAP_DIFFICULTY (m)) |
1615 | if (MAP_DIFFICULTY (m)) |