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.13 by elmex, Tue Aug 29 09:35: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.13 2006/08/29 09:35:51 elmex 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);
945 m->winddir = atoi(value); 949 m->winddir = atoi(value);
946 } else if (!strcmp(key, "sky")) { 950 } else if (!strcmp(key, "sky")) {
947 m->sky = atoi(value); 951 m->sky = atoi(value);
948 } else if (!strcmp(key, "nosmooth")) { 952 } else if (!strcmp(key, "nosmooth")) {
949 m->nosmooth = atoi(value); 953 m->nosmooth = atoi(value);
950 } else if (!strcmp(key, "safe_map")) {
951 m->safe_map = atoi(value);
952 } 954 }
953 else if (!strncmp(key,"tile_path_", 10)) { 955 else if (!strncmp(key,"tile_path_", 10)) {
954 int tile=atoi(key+10); 956 int tile=atoi(key+10);
955 957
956 if (tile<1 || tile>4) { 958 if (tile<1 || tile>4) {
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 }
1052 close_and_delete(fp, comp); 1054 close_and_delete(fp, comp);
1053 m->in_memory=MAP_IN_MEMORY; 1055 m->in_memory=MAP_IN_MEMORY;
1054 if (!MAP_DIFFICULTY(m)) 1056 if (!MAP_DIFFICULTY(m))
1055 MAP_DIFFICULTY(m)=calculate_difficulty(m); 1057 MAP_DIFFICULTY(m)=calculate_difficulty(m);
1056 set_map_reset_time(m); 1058 set_map_reset_time(m);
1057 INVOKE_MAP (INSTANTIATE, m); 1059 m->instantiate ();
1058 return (m); 1060 return (m);
1059} 1061}
1060 1062
1061/* 1063/*
1062 * Loads a map, which has been loaded earlier, from file. 1064 * Loads a map, which has been loaded earlier, from file.
1325 fprintf (fp, "winddir %d\n", m->winddir); 1327 fprintf (fp, "winddir %d\n", m->winddir);
1326 if (m->sky) 1328 if (m->sky)
1327 fprintf (fp, "sky %d\n", m->sky); 1329 fprintf (fp, "sky %d\n", m->sky);
1328 if (m->nosmooth) 1330 if (m->nosmooth)
1329 fprintf (fp, "nosmooth %d\n", m->nosmooth); 1331 fprintf (fp, "nosmooth %d\n", m->nosmooth);
1330 if (m->safe_map)
1331 fprintf (fp, "safe_map %d\n", m->safe_map);
1332 1332
1333 /* Save any tiling information, except on overlays */ 1333 /* Save any tiling information, except on overlays */
1334 if (flag != 2) 1334 if (flag != 2)
1335 for (i = 0; i < 4; i++) 1335 for (i = 0; i < 4; i++)
1336 if (m->tile_path[i]) 1336 if (m->tile_path[i])
1337 fprintf (fp, "tile_path_%d %s\n", i + 1, m->tile_path[i]); 1337 fprintf (fp, "tile_path_%d %s\n", i + 1, m->tile_path[i]);
1338 1338
1339 fp.put (m);
1339 fprintf (fp, "end\n"); 1340 fprintf (fp, "end\n");
1340 1341
1341 /* In the game save unique items in the different file, but 1342 /* In the game save unique items in the different file, but
1342 * in the editor save them to the normal map file. 1343 * in the editor save them to the normal map file.
1343 * If unique map, save files in the proper destination (set by 1344 * If unique map, save files in the proper destination (set by
1466 mapstruct *tmp, *last; 1467 mapstruct *tmp, *last;
1467 int i; 1468 int i;
1468 1469
1469 if (!m) 1470 if (!m)
1470 return; 1471 return;
1472
1473 m->clear ();
1474
1471 if (m->in_memory == MAP_IN_MEMORY) { 1475 if (m->in_memory == MAP_IN_MEMORY) {
1472 /* change to MAP_SAVING, even though we are not, 1476 /* change to MAP_SAVING, even though we are not,
1473 * so that remove_ob doesn't do as much work. 1477 * so that remove_ob doesn't do as much work.
1474 */ 1478 */
1475 m->in_memory = MAP_SAVING; 1479 m->in_memory = MAP_SAVING;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines