1 | /* |
1 | /* |
2 | * static char *rcsid_map_c = |
2 | * static char *rcsid_map_c = |
3 | * "$Id: map.C,v 1.10 2006/08/28 14:05:23 root Exp $"; |
3 | * "$Id: map.C,v 1.11 2006/08/28 16:12:59 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 | |
… | |
… | |
793 | * currently, there are few enough fields this is not a big deal. |
793 | * currently, there are few enough fields this is not a big deal. |
794 | * MSW 2001-07-01 |
794 | * MSW 2001-07-01 |
795 | * return 0 on success, 1 on failure. |
795 | * return 0 on success, 1 on failure. |
796 | */ |
796 | */ |
797 | |
797 | |
798 | static int load_map_header(FILE *fp, mapstruct *m) |
798 | static int load_map_header(object_thawer &fp, mapstruct *m) |
799 | { |
799 | { |
800 | char buf[HUGE_BUF], msgbuf[HUGE_BUF], maplorebuf[HUGE_BUF], *key=NULL, *value, *end; |
800 | char buf[HUGE_BUF], msgbuf[HUGE_BUF], maplorebuf[HUGE_BUF], *key=NULL, *value, *end; |
801 | int msgpos=0; |
801 | int msgpos=0; |
802 | int maplorepos=0; |
802 | int maplorepos=0; |
803 | |
803 | |
… | |
… | |
893 | } |
893 | } |
894 | /* first strcmp value on these are old names supported |
894 | /* first strcmp value on these are old names supported |
895 | * for compatibility reasons. The new values (second) are |
895 | * for compatibility reasons. The new values (second) are |
896 | * what really should be used. |
896 | * what really should be used. |
897 | */ |
897 | */ |
|
|
898 | else if (!strcmp(key,"oid")) { |
|
|
899 | fp.get (m, atoi(value)); |
898 | else if (!strcmp(key,"hp") || !strcmp(key, "enter_x")) { |
900 | } else if (!strcmp(key,"hp") || !strcmp(key, "enter_x")) { |
899 | m->enter_x = atoi(value); |
901 | m->enter_x = atoi(value); |
900 | } else if (!strcmp(key,"sp") || !strcmp(key, "enter_y")) { |
902 | } else if (!strcmp(key,"sp") || !strcmp(key, "enter_y")) { |
901 | m->enter_y = atoi(value); |
903 | m->enter_y = atoi(value); |
902 | } else if (!strcmp(key,"x") || !strcmp(key, "width")) { |
904 | } else if (!strcmp(key,"x") || !strcmp(key, "width")) { |
903 | m->width = atoi(value); |
905 | m->width = atoi(value); |
… | |
… | |
1036 | object_thawer thawer (fp, filename); |
1038 | object_thawer thawer (fp, filename); |
1037 | |
1039 | |
1038 | m = get_linked_map(); |
1040 | m = get_linked_map(); |
1039 | |
1041 | |
1040 | strcpy (m->path, filename); |
1042 | strcpy (m->path, filename); |
1041 | if (load_map_header(fp, m)) { |
1043 | if (load_map_header(thawer, m)) { |
1042 | LOG(llevError,"Error loading map header for %s, flags=%d\n", |
1044 | LOG(llevError,"Error loading map header for %s, flags=%d\n", |
1043 | filename, flags); |
1045 | filename, flags); |
1044 | delete_map(m); |
1046 | delete_map(m); |
1045 | return NULL; |
1047 | return NULL; |
1046 | } |
1048 | } |
… | |
… | |
1466 | mapstruct *tmp, *last; |
1468 | mapstruct *tmp, *last; |
1467 | int i; |
1469 | int i; |
1468 | |
1470 | |
1469 | if (!m) |
1471 | if (!m) |
1470 | return; |
1472 | return; |
|
|
1473 | |
|
|
1474 | m->clear (); |
|
|
1475 | |
1471 | if (m->in_memory == MAP_IN_MEMORY) { |
1476 | if (m->in_memory == MAP_IN_MEMORY) { |
1472 | /* change to MAP_SAVING, even though we are not, |
1477 | /* change to MAP_SAVING, even though we are not, |
1473 | * so that remove_ob doesn't do as much work. |
1478 | * so that remove_ob doesn't do as much work. |
1474 | */ |
1479 | */ |
1475 | m->in_memory = MAP_SAVING; |
1480 | m->in_memory = MAP_SAVING; |