ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/common/map.C
(Generate patch)

Comparing deliantra/server/common/map.C (file contents):
Revision 1.10 by root, Mon Aug 28 14:05:23 2006 UTC vs.
Revision 1.12 by root, Mon Aug 28 16:52:51 2006 UTC

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.12 2006/08/28 16:52:51 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
798static int load_map_header(FILE *fp, mapstruct *m) 798static 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));
900 } else if (!strcmp(key, "attach")) {
901 m->attach = add_string (value);
898 else if (!strcmp(key,"hp") || !strcmp(key, "enter_x")) { 902 } else if (!strcmp(key,"hp") || !strcmp(key, "enter_x")) {
899 m->enter_x = atoi(value); 903 m->enter_x = atoi(value);
900 } else if (!strcmp(key,"sp") || !strcmp(key, "enter_y")) { 904 } else if (!strcmp(key,"sp") || !strcmp(key, "enter_y")) {
901 m->enter_y = atoi(value); 905 m->enter_y = atoi(value);
902 } else if (!strcmp(key,"x") || !strcmp(key, "width")) { 906 } else if (!strcmp(key,"x") || !strcmp(key, "width")) {
903 m->width = atoi(value); 907 m->width = atoi(value);
1036 object_thawer thawer (fp, filename); 1040 object_thawer thawer (fp, filename);
1037 1041
1038 m = get_linked_map(); 1042 m = get_linked_map();
1039 1043
1040 strcpy (m->path, filename); 1044 strcpy (m->path, filename);
1041 if (load_map_header(fp, m)) { 1045 if (load_map_header(thawer, m)) {
1042 LOG(llevError,"Error loading map header for %s, flags=%d\n", 1046 LOG(llevError,"Error loading map header for %s, flags=%d\n",
1043 filename, flags); 1047 filename, flags);
1044 delete_map(m); 1048 delete_map(m);
1045 return NULL; 1049 return NULL;
1046 } 1050 }
1052 close_and_delete(fp, comp); 1056 close_and_delete(fp, comp);
1053 m->in_memory=MAP_IN_MEMORY; 1057 m->in_memory=MAP_IN_MEMORY;
1054 if (!MAP_DIFFICULTY(m)) 1058 if (!MAP_DIFFICULTY(m))
1055 MAP_DIFFICULTY(m)=calculate_difficulty(m); 1059 MAP_DIFFICULTY(m)=calculate_difficulty(m);
1056 set_map_reset_time(m); 1060 set_map_reset_time(m);
1057 INVOKE_MAP (INSTANTIATE, m); 1061 m->instantiate ();
1058 return (m); 1062 return (m);
1059} 1063}
1060 1064
1061/* 1065/*
1062 * Loads a map, which has been loaded earlier, from file. 1066 * Loads a map, which has been loaded earlier, from file.
1334 if (flag != 2) 1338 if (flag != 2)
1335 for (i = 0; i < 4; i++) 1339 for (i = 0; i < 4; i++)
1336 if (m->tile_path[i]) 1340 if (m->tile_path[i])
1337 fprintf (fp, "tile_path_%d %s\n", i + 1, m->tile_path[i]); 1341 fprintf (fp, "tile_path_%d %s\n", i + 1, m->tile_path[i]);
1338 1342
1343 fp.put (m);
1339 fprintf (fp, "end\n"); 1344 fprintf (fp, "end\n");
1340 1345
1341 /* In the game save unique items in the different file, but 1346 /* In the game save unique items in the different file, but
1342 * in the editor save them to the normal map file. 1347 * in the editor save them to the normal map file.
1343 * If unique map, save files in the proper destination (set by 1348 * If unique map, save files in the proper destination (set by
1466 mapstruct *tmp, *last; 1471 mapstruct *tmp, *last;
1467 int i; 1472 int i;
1468 1473
1469 if (!m) 1474 if (!m)
1470 return; 1475 return;
1476
1477 m->clear ();
1478
1471 if (m->in_memory == MAP_IN_MEMORY) { 1479 if (m->in_memory == MAP_IN_MEMORY) {
1472 /* change to MAP_SAVING, even though we are not, 1480 /* change to MAP_SAVING, even though we are not,
1473 * so that remove_ob doesn't do as much work. 1481 * so that remove_ob doesn't do as much work.
1474 */ 1482 */
1475 m->in_memory = MAP_SAVING; 1483 m->in_memory = MAP_SAVING;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines