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.32 by root, Thu Oct 5 16:50:06 2006 UTC vs.
Revision 1.41 by root, Tue Dec 12 22:37:05 2006 UTC

24 24
25#include <global.h> 25#include <global.h>
26#include <funcpoint.h> 26#include <funcpoint.h>
27 27
28#include <loader.h> 28#include <loader.h>
29#ifndef WIN32 /* ---win32 exclude header */
30# include <unistd.h> 29#include <unistd.h>
31#endif /* win32 */
32 30
33#include "path.h" 31#include "path.h"
34 32
35
36extern int nrofallocobjects, nroffreeobjects;
37 33
38/* 34/*
39 * Returns the maptile which has a name matching the given argument. 35 * Returns the maptile which has a name matching the given argument.
40 * return NULL if no match is found. 36 * return NULL if no match is found.
41 */ 37 */
159int 155int
160check_path (const char *name, int prepend_dir) 156check_path (const char *name, int prepend_dir)
161{ 157{
162 char buf[MAX_BUF]; 158 char buf[MAX_BUF];
163 159
164#ifndef WIN32
165 char *endbuf; 160 char *endbuf;
166 struct stat statbuf; 161 struct stat statbuf;
167 int mode = 0; 162 int mode = 0;
168#endif
169 163
170 if (prepend_dir) 164 if (prepend_dir)
171 strcpy (buf, create_pathname (name)); 165 strcpy (buf, create_pathname (name));
172 else 166 else
173 strcpy (buf, name); 167 strcpy (buf, name);
174#ifdef WIN32 /* ***win32: check this sucker in windows style. */
175 return (_access (buf, 0));
176#else
177 168
178 /* old method (strchr(buf, '\0')) seemd very odd to me - 169 /* old method (strchr(buf, '\0')) seemd very odd to me -
179 * this method should be equivalant and is clearer. 170 * this method should be equivalant and is clearer.
180 * Can not use strcat because we need to cycle through 171 * Can not use strcat because we need to cycle through
181 * all the names. 172 * all the names.
194 if ((statbuf.st_mode & S_IWGRP && getegid () == statbuf.st_gid) || 185 if ((statbuf.st_mode & S_IWGRP && getegid () == statbuf.st_gid) ||
195 (statbuf.st_mode & S_IWUSR && geteuid () == statbuf.st_uid) || (statbuf.st_mode & S_IWOTH)) 186 (statbuf.st_mode & S_IWUSR && geteuid () == statbuf.st_uid) || (statbuf.st_mode & S_IWOTH))
196 mode |= 2; 187 mode |= 2;
197 188
198 return (mode); 189 return (mode);
199#endif
200} 190}
201 191
202/* 192/*
203 * Prints out debug-information about a map. 193 * Prints out debug-information about a map.
204 * Dumping these at llevError doesn't seem right, but is 194 * Dumping these at llevError doesn't seem right, but is
542{ 532{
543 int i, j; 533 int i, j;
544 int unique; 534 int unique;
545 object *op, *prev = NULL, *last_more = NULL, *otmp; 535 object *op, *prev = NULL, *last_more = NULL, *otmp;
546 536
547 op = get_object (); 537 op = object::create ();
548 op->map = m; /* To handle buttons correctly */ 538 op->map = m; /* To handle buttons correctly */
549 539
550 while ((i = load_object (fp, op, mapflags))) 540 while ((i = load_object (fp, op, mapflags)))
551 { 541 {
552 /* if the archetype for the object is null, means that we 542 /* if the archetype for the object is null, means that we
560 } 550 }
561 551
562 552
563 switch (i) 553 switch (i)
564 { 554 {
565 case LL_NORMAL: 555 case LL_NORMAL:
566 /* if we are loading an overlay, put the floors on the bottom */ 556 /* if we are loading an overlay, put the floors on the bottom */
567 if ((QUERY_FLAG (op, FLAG_IS_FLOOR) || QUERY_FLAG (op, FLAG_OVERLAY_FLOOR)) && mapflags & MAP_OVERLAY) 557 if ((QUERY_FLAG (op, FLAG_IS_FLOOR) || QUERY_FLAG (op, FLAG_OVERLAY_FLOOR)) && mapflags & MAP_OVERLAY)
568 insert_ob_in_map (op, m, op, INS_NO_MERGE | INS_NO_WALK_ON | INS_ABOVE_FLOOR_ONLY | INS_MAP_LOAD); 558 insert_ob_in_map (op, m, op, INS_NO_MERGE | INS_NO_WALK_ON | INS_ABOVE_FLOOR_ONLY | INS_MAP_LOAD);
569 else 559 else
570 insert_ob_in_map (op, m, op, INS_NO_MERGE | INS_NO_WALK_ON | INS_ON_TOP | INS_MAP_LOAD); 560 insert_ob_in_map (op, m, op, INS_NO_MERGE | INS_NO_WALK_ON | INS_ON_TOP | INS_MAP_LOAD);
571 561
572 if (op->inv) 562 if (op->inv)
573 sum_weight (op); 563 sum_weight (op);
574 564
575 prev = op, last_more = op; 565 prev = op, last_more = op;
576 break; 566 break;
577 567
578 case LL_MORE: 568 case LL_MORE:
579 insert_ob_in_map (op, m, op, INS_NO_MERGE | INS_NO_WALK_ON | INS_ABOVE_FLOOR_ONLY); 569 insert_ob_in_map (op, m, op, INS_NO_MERGE | INS_NO_WALK_ON | INS_ABOVE_FLOOR_ONLY);
580 op->head = prev, last_more->more = op, last_more = op; 570 op->head = prev, last_more->more = op, last_more = op;
581 break; 571 break;
582 } 572 }
583 573
584 if (mapflags & MAP_STYLE) 574 if (mapflags & MAP_STYLE)
585 remove_from_active_list (op); 575 remove_from_active_list (op);
586 576
587 op = get_object (); 577 op = object::create ();
588 op->map = m; 578 op->map = m;
589 } 579 }
590 580
591 for (i = 0; i < m->width; i++) 581 for (i = 0; i < m->width; i++)
592 { 582 {
596 /* check for unique items, or unique squares */ 586 /* check for unique items, or unique squares */
597 for (otmp = get_map_ob (m, i, j); otmp; otmp = otmp->above) 587 for (otmp = get_map_ob (m, i, j); otmp; otmp = otmp->above)
598 { 588 {
599 if (QUERY_FLAG (otmp, FLAG_UNIQUE) || QUERY_FLAG (otmp, FLAG_OBJ_SAVE_ON_OVL)) 589 if (QUERY_FLAG (otmp, FLAG_UNIQUE) || QUERY_FLAG (otmp, FLAG_OBJ_SAVE_ON_OVL))
600 unique = 1; 590 unique = 1;
591
601 if (!(mapflags & (MAP_OVERLAY | MAP_PLAYER_UNIQUE) || unique)) 592 if (!(mapflags & (MAP_OVERLAY | MAP_PLAYER_UNIQUE) || unique))
602 SET_FLAG (otmp, FLAG_OBJ_ORIGINAL); 593 SET_FLAG (otmp, FLAG_OBJ_ORIGINAL);
603 } 594 }
604 } 595 }
605 } 596 }
606 597
607 free_object (op); 598 op->destroy ();
608 link_multipart_objects (m); 599 link_multipart_objects (m);
609} 600}
610 601
611/* This saves all the objects on the map in a non destructive fashion. 602/* This saves all the objects on the map in a non destructive fashion.
612 * Modified by MSW 2001-07-01 to do in a single pass - reduces code, 603 * Modified by MSW 2001-07-01 to do in a single pass - reduces code,
645 636
646 } /* for this space */ 637 } /* for this space */
647 } /* for this j */ 638 } /* for this j */
648} 639}
649 640
641maptile::maptile ()
642{
643 in_memory = MAP_SWAPPED;
644 /* The maps used to pick up default x and y values from the
645 * map archetype. Mimic that behaviour.
646 */
647 MAP_WIDTH (this) = 16;
648 MAP_HEIGHT (this) = 16;
649 MAP_RESET_TIMEOUT (this) = 0;
650 MAP_TIMEOUT (this) = 300;
651 MAP_ENTER_X (this) = 0;
652 MAP_ENTER_Y (this) = 0;
653 /*set part to -1 indicating conversion to weather map not yet done */
654 MAP_WORLDPARTX (this) = -1;
655 MAP_WORLDPARTY (this) = -1;
656}
657
650/* 658/*
651 * Allocates, initialises, and returns a pointer to a maptile. 659 * Allocates, initialises, and returns a pointer to a maptile.
652 * Modified to no longer take a path option which was not being 660 * Modified to no longer take a path option which was not being
653 * used anyways. MSW 2001-07-01 661 * used anyways. MSW 2001-07-01
654 */ 662 */
655
656maptile * 663maptile *
657get_linked_map (void) 664get_linked_map (void)
658{ 665{
659 maptile *map = new maptile; 666 maptile *mp, *map = new maptile;
660 maptile *mp;
661 667
662 for (mp = first_map; mp != NULL && mp->next != NULL; mp = mp->next); 668 for (mp = first_map; mp && mp->next; mp = mp->next);
669
663 if (mp == NULL) 670 if (mp == NULL)
664 first_map = map; 671 first_map = map;
665 else 672 else
666 mp->next = map; 673 mp->next = map;
667 674
668 map->in_memory = MAP_SWAPPED;
669 /* The maps used to pick up default x and y values from the
670 * map archetype. Mimic that behaviour.
671 */
672 MAP_WIDTH (map) = 16;
673 MAP_HEIGHT (map) = 16;
674 MAP_RESET_TIMEOUT (map) = 0;
675 MAP_TIMEOUT (map) = 300;
676 MAP_ENTER_X (map) = 0;
677 MAP_ENTER_Y (map) = 0;
678 /*set part to -1 indicating conversion to weather map not yet done */
679 MAP_WORLDPARTX (map) = -1;
680 MAP_WORLDPARTY (map) = -1;
681 return map; 675 return map;
682} 676}
683 677
684/* 678/*
685 * Allocates the arrays contained in a maptile. 679 * Allocates the arrays contained in a maptile.
686 * This basically allocates the dynamic array of spaces for the 680 * This basically allocates the dynamic array of spaces for the
687 * map. 681 * map.
688 */ 682 */
689
690void 683void
691allocate_map (maptile *m) 684maptile::allocate ()
692{ 685{
693 m->in_memory = MAP_IN_MEMORY; 686 in_memory = MAP_IN_MEMORY;
687
694 /* Log this condition and free the storage. We could I suppose 688 /* Log this condition and free the storage. We could I suppose
695 * realloc, but if the caller is presuming the data will be intact, 689 * realloc, but if the caller is presuming the data will be intact,
696 * that is their poor assumption. 690 * that is their poor assumption.
697 */ 691 */
698 if (m->spaces) 692 if (spaces)
699 { 693 {
700 LOG (llevError, "allocate_map called with already allocated map (%s)\n", m->path); 694 LOG (llevError, "allocate_map called with already allocated map (%s)\n", path);
701 free (m->spaces); 695 free (spaces);
702 } 696 }
703 697
704 m->spaces = (MapSpace *) calloc (1, MAP_WIDTH (m) * MAP_HEIGHT (m) * sizeof (MapSpace)); 698 spaces = (MapSpace *)
699 calloc (1, width * height * sizeof (MapSpace));
705 700
706 if (m->spaces == NULL) 701 if (!spaces)
707 fatal (OUT_OF_MEMORY); 702 fatal (OUT_OF_MEMORY);
708} 703}
709 704
710/* Create and returns a map of the specific size. Used 705/* Create and returns a map of the specific size. Used
711 * in random map code and the editor. 706 * in random map code and the editor.
716 maptile *m = get_linked_map (); 711 maptile *m = get_linked_map ();
717 712
718 m->width = sizex; 713 m->width = sizex;
719 m->height = sizey; 714 m->height = sizey;
720 m->in_memory = MAP_SWAPPED; 715 m->in_memory = MAP_SWAPPED;
721 allocate_map (m); 716 m->allocate ();
717
722 return m; 718 return m;
723} 719}
724 720
725/* Takes a string from a map definition and outputs a pointer to the array of shopitems 721/* Takes a string from a map definition and outputs a pointer to the array of shopitems
726 * corresponding to that string. Memory is allocated for this, it must be freed 722 * corresponding to that string. Memory is allocated for this, it must be freed
853{ 849{
854 char buf[HUGE_BUF], msgbuf[HUGE_BUF], maplorebuf[HUGE_BUF], *key = NULL, *value, *end; 850 char buf[HUGE_BUF], msgbuf[HUGE_BUF], maplorebuf[HUGE_BUF], *key = NULL, *value, *end;
855 int msgpos = 0; 851 int msgpos = 0;
856 int maplorepos = 0; 852 int maplorepos = 0;
857 853
858 while (fgets (buf, HUGE_BUF - 1, fp) != NULL) 854 while (fgets (buf, HUGE_BUF, fp) != NULL)
859 { 855 {
860 buf[HUGE_BUF - 1] = 0; 856 buf[HUGE_BUF - 1] = 0;
861 key = buf; 857 key = buf;
858
862 while (isspace (*key)) 859 while (isspace (*key))
863 key++; 860 key++;
861
864 if (*key == 0) 862 if (*key == 0)
865 continue; /* empty line */ 863 continue; /* empty line */
864
866 value = strchr (key, ' '); 865 value = strchr (key, ' ');
866
867 if (!value) 867 if (!value)
868 { 868 {
869 end = strchr (key, '\n'); 869 if ((end = strchr (key, '\n')))
870 if (end != NULL)
871 {
872 *end = 0; 870 *end = 0;
873 }
874 } 871 }
875 else 872 else
876 { 873 {
877 *value = 0; 874 *value = 0;
878 value++; 875 value++;
879 end = strchr (value, '\n'); 876 end = strchr (value, '\n');
877
880 while (isspace (*value)) 878 while (isspace (*value))
881 { 879 {
882 value++; 880 value++;
881
883 if (*value == '\0' || value == end) 882 if (*value == '\0' || value == end)
884 { 883 {
885 /* Nothing but spaces. */ 884 /* Nothing but spaces. */
886 value = NULL; 885 value = NULL;
887 break; 886 break;
910 * that use the parameter. 909 * that use the parameter.
911 */ 910 */
912 911
913 if (!strcmp (key, "msg")) 912 if (!strcmp (key, "msg"))
914 { 913 {
915 while (fgets (buf, HUGE_BUF - 1, fp) != NULL) 914 while (fgets (buf, HUGE_BUF, fp) != NULL)
916 { 915 {
917 if (!strcmp (buf, "endmsg\n")) 916 if (!strcmp (buf, "endmsg\n"))
918 break; 917 break;
919 else 918 else
920 { 919 {
931 if (msgpos != 0) 930 if (msgpos != 0)
932 m->msg = strdup_local (msgbuf); 931 m->msg = strdup_local (msgbuf);
933 } 932 }
934 else if (!strcmp (key, "maplore")) 933 else if (!strcmp (key, "maplore"))
935 { 934 {
936 while (fgets (buf, HUGE_BUF - 1, fp) != NULL) 935 while (fgets (buf, HUGE_BUF, fp) != NULL)
937 { 936 {
938 if (!strcmp (buf, "endmaplore\n")) 937 if (!strcmp (buf, "endmaplore\n"))
939 break; 938 break;
940 else 939 else
941 { 940 {
969 /* first strcmp value on these are old names supported 968 /* first strcmp value on these are old names supported
970 * for compatibility reasons. The new values (second) are 969 * for compatibility reasons. The new values (second) are
971 * what really should be used. 970 * what really should be used.
972 */ 971 */
973 else if (!strcmp (key, "oid")) 972 else if (!strcmp (key, "oid"))
974 {
975 fp.get (m, atoi (value)); 973 fp.get (m, atoi (value));
976 }
977 else if (!strcmp (key, "attach")) 974 else if (!strcmp (key, "attach"))
978 {
979 m->attach = value; 975 m->attach = value;
980 }
981 else if (!strcmp (key, "hp") || !strcmp (key, "enter_x")) 976 else if (!strcmp (key, "hp") || !strcmp (key, "enter_x"))
982 {
983 m->enter_x = atoi (value); 977 m->enter_x = atoi (value);
984 }
985 else if (!strcmp (key, "sp") || !strcmp (key, "enter_y")) 978 else if (!strcmp (key, "sp") || !strcmp (key, "enter_y"))
986 {
987 m->enter_y = atoi (value); 979 m->enter_y = atoi (value);
988 }
989 else if (!strcmp (key, "x") || !strcmp (key, "width")) 980 else if (!strcmp (key, "x") || !strcmp (key, "width"))
990 {
991 m->width = atoi (value); 981 m->width = atoi (value);
992 }
993 else if (!strcmp (key, "y") || !strcmp (key, "height")) 982 else if (!strcmp (key, "y") || !strcmp (key, "height"))
994 {
995 m->height = atoi (value); 983 m->height = atoi (value);
996 }
997 else if (!strcmp (key, "weight") || !strcmp (key, "reset_timeout")) 984 else if (!strcmp (key, "weight") || !strcmp (key, "reset_timeout"))
998 {
999 m->reset_timeout = atoi (value); 985 m->reset_timeout = atoi (value);
1000 }
1001 else if (!strcmp (key, "value") || !strcmp (key, "swap_time")) 986 else if (!strcmp (key, "value") || !strcmp (key, "swap_time"))
1002 {
1003 m->timeout = atoi (value); 987 m->timeout = atoi (value);
1004 }
1005 else if (!strcmp (key, "level") || !strcmp (key, "difficulty")) 988 else if (!strcmp (key, "level") || !strcmp (key, "difficulty"))
1006 { 989 m->difficulty = clamp (atoi (value), 1, settings.max_level);
1007 m->difficulty = atoi (value);
1008 }
1009 else if (!strcmp (key, "invisible") || !strcmp (key, "darkness")) 990 else if (!strcmp (key, "invisible") || !strcmp (key, "darkness"))
1010 {
1011 m->darkness = atoi (value); 991 m->darkness = atoi (value);
1012 }
1013 else if (!strcmp (key, "stand_still") || !strcmp (key, "fixed_resettime")) 992 else if (!strcmp (key, "stand_still") || !strcmp (key, "fixed_resettime"))
1014 {
1015 m->fixed_resettime = atoi (value); 993 m->fixed_resettime = atoi (value);
1016 }
1017 else if (!strcmp (key, "unique")) 994 else if (!strcmp (key, "unique"))
1018 {
1019 m->unique = atoi (value); 995 m->unique = atoi (value);
1020 }
1021 else if (!strcmp (key, "template")) 996 else if (!strcmp (key, "template"))
1022 {
1023 m->templatemap = atoi (value); 997 m->templatemap = atoi (value);
1024 }
1025 else if (!strcmp (key, "region")) 998 else if (!strcmp (key, "region"))
1026 {
1027 m->region = get_region_by_name (value); 999 m->region = get_region_by_name (value);
1028 }
1029 else if (!strcmp (key, "shopitems")) 1000 else if (!strcmp (key, "shopitems"))
1030 { 1001 {
1031 *end = 0; 1002 *end = 0;
1032 m->shopitems = parse_shop_string (value); 1003 m->shopitems = parse_shop_string (value);
1033 } 1004 }
1034 else if (!strcmp (key, "shopgreed")) 1005 else if (!strcmp (key, "shopgreed"))
1035 {
1036 m->shopgreed = atof (value); 1006 m->shopgreed = atof (value);
1037 }
1038 else if (!strcmp (key, "shopmin")) 1007 else if (!strcmp (key, "shopmin"))
1039 {
1040 m->shopmin = atol (value); 1008 m->shopmin = atol (value);
1041 }
1042 else if (!strcmp (key, "shopmax")) 1009 else if (!strcmp (key, "shopmax"))
1043 {
1044 m->shopmax = atol (value); 1010 m->shopmax = atol (value);
1045 }
1046 else if (!strcmp (key, "shoprace")) 1011 else if (!strcmp (key, "shoprace"))
1047 { 1012 {
1048 *end = 0; 1013 *end = 0;
1049 m->shoprace = strdup_local (value); 1014 m->shoprace = strdup_local (value);
1050 } 1015 }
1051 else if (!strcmp (key, "outdoor")) 1016 else if (!strcmp (key, "outdoor"))
1052 {
1053 m->outdoor = atoi (value); 1017 m->outdoor = atoi (value);
1054 }
1055 else if (!strcmp (key, "temp")) 1018 else if (!strcmp (key, "temp"))
1056 {
1057 m->temp = atoi (value); 1019 m->temp = atoi (value);
1058 }
1059 else if (!strcmp (key, "pressure")) 1020 else if (!strcmp (key, "pressure"))
1060 {
1061 m->pressure = atoi (value); 1021 m->pressure = atoi (value);
1062 }
1063 else if (!strcmp (key, "humid")) 1022 else if (!strcmp (key, "humid"))
1064 {
1065 m->humid = atoi (value); 1023 m->humid = atoi (value);
1066 }
1067 else if (!strcmp (key, "windspeed")) 1024 else if (!strcmp (key, "windspeed"))
1068 {
1069 m->windspeed = atoi (value); 1025 m->windspeed = atoi (value);
1070 }
1071 else if (!strcmp (key, "winddir")) 1026 else if (!strcmp (key, "winddir"))
1072 {
1073 m->winddir = atoi (value); 1027 m->winddir = atoi (value);
1074 }
1075 else if (!strcmp (key, "sky")) 1028 else if (!strcmp (key, "sky"))
1076 {
1077 m->sky = atoi (value); 1029 m->sky = atoi (value);
1078 }
1079 else if (!strcmp (key, "nosmooth")) 1030 else if (!strcmp (key, "nosmooth"))
1080 {
1081 m->nosmooth = atoi (value); 1031 m->nosmooth = atoi (value);
1082 }
1083 else if (!strncmp (key, "tile_path_", 10)) 1032 else if (!strncmp (key, "tile_path_", 10))
1084 { 1033 {
1085 int tile = atoi (key + 10); 1034 int tile = atoi (key + 10);
1086 1035
1087 if (tile < 1 || tile > 4) 1036 if (tile < 1 || tile > 4)
1130 m->tile_path[tile - 1] = strdup_local (path); 1079 m->tile_path[tile - 1] = strdup_local (path);
1131 } 1080 }
1132 } /* end if tile direction (in)valid */ 1081 } /* end if tile direction (in)valid */
1133 } 1082 }
1134 else 1083 else
1135 {
1136 LOG (llevError, "Got unknown value in map header: %s %s\n", key, value); 1084 LOG (llevError, "Got unknown value in map header: %s %s\n", key, value);
1137 }
1138 } 1085 }
1086
1139 if (!key || strcmp (key, "end")) 1087 if (!key || strcmp (key, "end"))
1140 { 1088 {
1141 LOG (llevError, "Got premature eof on map header!\n"); 1089 LOG (llevError, "Got premature eof on map header!\n");
1142 return 1; 1090 return 1;
1143 } 1091 }
1092
1144 return 0; 1093 return 0;
1145} 1094}
1146 1095
1147/* 1096/*
1148 * Opens the file "filename" and reads information about the map 1097 * Opens the file "filename" and reads information about the map
1184 LOG (llevError, "Error loading map header for %s, flags=%d\n", filename, flags); 1133 LOG (llevError, "Error loading map header for %s, flags=%d\n", filename, flags);
1185 delete_map (m); 1134 delete_map (m);
1186 return NULL; 1135 return NULL;
1187 } 1136 }
1188 1137
1189 allocate_map (m); 1138 m->allocate ();
1190 1139
1191 m->in_memory = MAP_LOADING; 1140 m->in_memory = MAP_LOADING;
1192 load_objects (m, thawer, flags & (MAP_BLOCK | MAP_STYLE)); 1141 load_objects (m, thawer, flags & (MAP_BLOCK | MAP_STYLE));
1193 1142
1194 m->in_memory = MAP_IN_MEMORY; 1143 m->in_memory = MAP_IN_MEMORY;
1240 LOG (llevError, "Error loading map header for %s (%s)\n", m->path, m->tmpname); 1189 LOG (llevError, "Error loading map header for %s (%s)\n", m->path, m->tmpname);
1241 delete_map (m); 1190 delete_map (m);
1242 m = load_original_map (m->path, 0); 1191 m = load_original_map (m->path, 0);
1243 return NULL; 1192 return NULL;
1244 } 1193 }
1194
1245 allocate_map (m); 1195 m->allocate ();
1246 1196
1247 m->in_memory = MAP_LOADING; 1197 m->in_memory = MAP_LOADING;
1248 load_objects (m, thawer, 0); 1198 load_objects (m, thawer, 0);
1249 1199
1250 m->in_memory = MAP_IN_MEMORY; 1200 m->in_memory = MAP_IN_MEMORY;
1275 LOG (llevError, "Error loading map header for overlay %s (%s)\n", m->path, pathname); 1225 LOG (llevError, "Error loading map header for overlay %s (%s)\n", m->path, pathname);
1276 delete_map (m); 1226 delete_map (m);
1277 m = load_original_map (m->path, 0); 1227 m = load_original_map (m->path, 0);
1278 return NULL; 1228 return NULL;
1279 } 1229 }
1280 /*allocate_map(m); */ 1230 /*m->allocate ();*/
1281 1231
1282 m->in_memory = MAP_LOADING; 1232 m->in_memory = MAP_LOADING;
1283 load_objects (m, thawer, MAP_OVERLAY); 1233 load_objects (m, thawer, MAP_OVERLAY);
1284 1234
1285 m->in_memory = MAP_IN_MEMORY; 1235 m->in_memory = MAP_IN_MEMORY;
1299 1249
1300 for (i = 0; i < MAP_WIDTH (m); i++) 1250 for (i = 0; i < MAP_WIDTH (m); i++)
1301 for (j = 0; j < MAP_HEIGHT (m); j++) 1251 for (j = 0; j < MAP_HEIGHT (m); j++)
1302 { 1252 {
1303 unique = 0; 1253 unique = 0;
1254
1304 for (op = get_map_ob (m, i, j); op; op = next) 1255 for (op = get_map_ob (m, i, j); op; op = next)
1305 { 1256 {
1306 next = op->above; 1257 next = op->above;
1258
1307 if (QUERY_FLAG (op, FLAG_IS_FLOOR) && QUERY_FLAG (op, FLAG_UNIQUE)) 1259 if (QUERY_FLAG (op, FLAG_IS_FLOOR) && QUERY_FLAG (op, FLAG_UNIQUE))
1308 unique = 1; 1260 unique = 1;
1261
1309 if (op->head == NULL && (QUERY_FLAG (op, FLAG_UNIQUE) || unique)) 1262 if (op->head == NULL && (QUERY_FLAG (op, FLAG_UNIQUE) || unique))
1310 { 1263 {
1311 clean_object (op); 1264 clean_object (op);
1265
1312 if (QUERY_FLAG (op, FLAG_IS_LINKED)) 1266 if (QUERY_FLAG (op, FLAG_IS_LINKED))
1313 remove_button_link (op); 1267 remove_button_link (op);
1314 remove_ob (op); 1268
1315 free_object (op); 1269 op->destroy ();
1316 } 1270 }
1317 } 1271 }
1318 } 1272 }
1319} 1273}
1320 1274
1423 print_shop_string (m, shop); 1377 print_shop_string (m, shop);
1424 fprintf (freezer, "shopitems %s\n", shop); 1378 fprintf (freezer, "shopitems %s\n", shop);
1425 } 1379 }
1426 if (m->shopgreed) 1380 if (m->shopgreed)
1427 fprintf (freezer, "shopgreed %f\n", m->shopgreed); 1381 fprintf (freezer, "shopgreed %f\n", m->shopgreed);
1428#ifndef WIN32
1429 if (m->shopmin) 1382 if (m->shopmin)
1430 fprintf (freezer, "shopmin %llu\n", m->shopmin); 1383 fprintf (freezer, "shopmin %llu\n", m->shopmin);
1431 if (m->shopmax) 1384 if (m->shopmax)
1432 fprintf (freezer, "shopmax %llu\n", m->shopmax); 1385 fprintf (freezer, "shopmax %llu\n", m->shopmax);
1433#else
1434 if (m->shopmin)
1435 fprintf (freezer, "shopmin %I64u\n", m->shopmin);
1436 if (m->shopmax)
1437 fprintf (freezer, "shopmax %I64u\n", m->shopmax);
1438#endif
1439 if (m->shoprace) 1386 if (m->shoprace)
1440 fprintf (freezer, "shoprace %s\n", m->shoprace); 1387 fprintf (freezer, "shoprace %s\n", m->shoprace);
1441 if (m->darkness) 1388 if (m->darkness)
1442 fprintf (freezer, "darkness %d\n", m->darkness); 1389 fprintf (freezer, "darkness %d\n", m->darkness);
1443 if (m->width) 1390 if (m->width)
1522 object *tmp, *next; 1469 object *tmp, *next;
1523 1470
1524 for (tmp = op->inv; tmp; tmp = next) 1471 for (tmp = op->inv; tmp; tmp = next)
1525 { 1472 {
1526 next = tmp->below; 1473 next = tmp->below;
1474
1527 clean_object (tmp); 1475 clean_object (tmp);
1528 if (QUERY_FLAG (tmp, FLAG_IS_LINKED)) 1476 if (QUERY_FLAG (tmp, FLAG_IS_LINKED))
1529 remove_button_link (tmp); 1477 remove_button_link (tmp);
1530 remove_ob (tmp); 1478
1531 free_object (tmp); 1479 tmp->destroy ();
1532 } 1480 }
1533} 1481}
1534 1482
1535/* 1483/*
1536 * Remove and free all objects in the given map. 1484 * Remove and free all objects in the given map.
1552 if (op == previous_obj) 1500 if (op == previous_obj)
1553 { 1501 {
1554 LOG (llevDebug, "free_all_objects: Link error, bailing out.\n"); 1502 LOG (llevDebug, "free_all_objects: Link error, bailing out.\n");
1555 break; 1503 break;
1556 } 1504 }
1505
1557 previous_obj = op; 1506 previous_obj = op;
1507
1558 if (op->head != NULL) 1508 if (op->head != NULL)
1559 op = op->head; 1509 op = op->head;
1560 1510
1561 /* If the map isn't in memory, free_object will remove and 1511 /* If the map isn't in memory, free_object will remove and
1562 * free objects in op's inventory. So let it do the job. 1512 * free objects in op's inventory. So let it do the job.
1563 */ 1513 */
1564 if (m->in_memory == MAP_IN_MEMORY) 1514 if (m->in_memory == MAP_IN_MEMORY)
1565 clean_object (op); 1515 clean_object (op);
1566 remove_ob (op); 1516
1567 free_object (op); 1517 op->destroy ();
1568 } 1518 }
1569 } 1519 }
1570} 1520}
1571 1521
1572/* 1522/*

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines