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.48 by root, Mon Dec 25 14:43:22 2006 UTC vs.
Revision 1.49 by root, Mon Dec 25 14:54:44 2006 UTC

32 32
33/* 33/*
34 * Returns the maptile which has a name matching the given argument. 34 * Returns the maptile which has a name matching the given argument.
35 * return NULL if no match is found. 35 * return NULL if no match is found.
36 */ 36 */
37
38maptile * 37maptile *
39has_been_loaded (const char *name) 38has_been_loaded (const char *name)
40{ 39{
41 maptile *map; 40 maptile *map;
42 41
43 if (!name || !*name) 42 if (!name || !*name)
44 return 0; 43 return 0;
44
45 for (map = first_map; map; map = map->next) 45 for (map = first_map; map; map = map->next)
46 if (!strcmp (name, map->path)) 46 if (!strcmp (name, map->path))
47 break; 47 break;
48
48 return (map); 49 return (map);
49} 50}
50 51
51/* 52/*
52 * This makes a path absolute outside the world of Crossfire. 53 * This makes a path absolute outside the world of Crossfire.
196 197
197void 198void
198dump_map (const maptile *m) 199dump_map (const maptile *m)
199{ 200{
200 LOG (llevError, "Map %s status: %d.\n", m->path, m->in_memory); 201 LOG (llevError, "Map %s status: %d.\n", m->path, m->in_memory);
201 LOG (llevError, "Size: %dx%d Start: %d,%d\n", m->width, m->height, MAP_ENTER_X (m), MAP_ENTER_Y (m)); 202 LOG (llevError, "Size: %dx%d Start: %d,%d\n", m->width, m->height, m->enter_x, m->enter_y);
202 203
203 if (m->msg != NULL) 204 if (m->msg != NULL)
204 LOG (llevError, "Message:\n%s", m->msg); 205 LOG (llevError, "Message:\n%s", m->msg);
205 206
206 if (m->maplore != NULL) 207 if (m->maplore != NULL)
610 /* first pass - save one-part objects */ 611 /* first pass - save one-part objects */
611 for (i = 0; i < m->width; i++) 612 for (i = 0; i < m->width; i++)
612 for (j = 0; j < m->height; j++) 613 for (j = 0; j < m->height; j++)
613 { 614 {
614 unique = 0; 615 unique = 0;
615 for (op = m->at (i, j).bottom; op; op = op->above) 616 for (op = m->at (i, j).bot; op; op = op->above)
616 { 617 {
617 if (op->flag [FLAG_IS_FLOOR] && op->flag [FLAG_UNIQUE]) 618 if (op->flag [FLAG_IS_FLOOR] && op->flag [FLAG_UNIQUE])
618 unique = 1; 619 unique = 1;
619 620
620 if (op->type == PLAYER) 621 if (op->type == PLAYER)
637 /* The maps used to pick up default x and y values from the 638 /* The maps used to pick up default x and y values from the
638 * map archetype. Mimic that behaviour. 639 * map archetype. Mimic that behaviour.
639 */ 640 */
640 this->width = 16; 641 this->width = 16;
641 this->height = 16; 642 this->height = 16;
642 MAP_RESET_TIMEOUT (this) = 0; 643 this->reset_timeout = 0;
643 MAP_TIMEOUT (this) = 300; 644 this->timeout = 300;
644 MAP_ENTER_X (this) = 0; 645 this->enter_x = 0;
645 MAP_ENTER_Y (this) = 0; 646 this->enter_y = 0;
646 /*set part to -1 indicating conversion to weather map not yet done */ 647 /*set part to -1 indicating conversion to weather map not yet done */
647 MAP_WORLDPARTX (this) = -1; 648 this->worldpartx = -1;
648 MAP_WORLDPARTY (this) = -1; 649 this->worldparty = -1;
649} 650}
650 651
651/* 652/*
652 * Allocates, initialises, and returns a pointer to a maptile. 653 * Allocates, initialises, and returns a pointer to a maptile.
653 * Modified to no longer take a path option which was not being 654 * Modified to no longer take a path option which was not being
1132 1133
1133 m->in_memory = MAP_LOADING; 1134 m->in_memory = MAP_LOADING;
1134 load_objects (m, thawer, flags & (MAP_BLOCK | MAP_STYLE)); 1135 load_objects (m, thawer, flags & (MAP_BLOCK | MAP_STYLE));
1135 1136
1136 m->in_memory = MAP_IN_MEMORY; 1137 m->in_memory = MAP_IN_MEMORY;
1137 if (!MAP_DIFFICULTY (m)) 1138 if (!m->difficulty)
1138 MAP_DIFFICULTY (m) = calculate_difficulty (m); 1139 m->difficulty = calculate_difficulty (m);
1139 set_map_reset_time (m); 1140 set_map_reset_time (m);
1140 m->instantiate (); 1141 m->instantiate ();
1141 return (m); 1142 return (m);
1142} 1143}
1143 1144
1458 for (int i = 0; i < m->width; i++) 1459 for (int i = 0; i < m->width; i++)
1459 for (int j = 0; j < m->height; j++) 1460 for (int j = 0; j < m->height; j++)
1460 { 1461 {
1461 mapspace &ms = m->at (i, j); 1462 mapspace &ms = m->at (i, j);
1462 1463
1463 while (object *op = ms.bottom) 1464 while (object *op = ms.bot)
1464 { 1465 {
1465 if (op->head) 1466 if (op->head)
1466 op = op->head; 1467 op = op->head;
1467 1468
1468 op->destroy_inv (false); 1469 op->destroy_inv (false);
1692 int x, y, i; 1693 int x, y, i;
1693 long monster_cnt = 0; 1694 long monster_cnt = 0;
1694 double avgexp = 0; 1695 double avgexp = 0;
1695 sint64 total_exp = 0; 1696 sint64 total_exp = 0;
1696 1697
1697 if (MAP_DIFFICULTY (m)) 1698 if (m->difficulty)
1698 { 1699 {
1699 LOG (llevDebug, "Using stored map difficulty: %d\n", MAP_DIFFICULTY (m)); 1700 LOG (llevDebug, "Using stored map difficulty: %d\n", m->difficulty);
1700 return MAP_DIFFICULTY (m); 1701 return m->difficulty;
1701 } 1702 }
1702 1703
1703 for (x = 0; x < m->width; x++) 1704 for (x = 0; x < m->width; x++)
1704 for (y = 0; y < m->height; y++) 1705 for (y = 0; y < m->height; y++)
1705 for (op = GET_MAP_OB (m, x, y); op != NULL; op = op->above) 1706 for (op = GET_MAP_OB (m, x, y); op != NULL; op = op->above)
1826 1827
1827 middle_obj = 0; 1828 middle_obj = 0;
1828 top_obj = 0; 1829 top_obj = 0;
1829 floor_obj = 0; 1830 floor_obj = 0;
1830 1831
1831 for (tmp = bottom; tmp; last = tmp, tmp = tmp->above) 1832 for (tmp = bot; tmp; last = tmp, tmp = tmp->above)
1832 { 1833 {
1833 /* This could be made additive I guess (two lights better than 1834 /* This could be made additive I guess (two lights better than
1834 * one). But if so, it shouldn't be a simple additive - 2 1835 * one). But if so, it shouldn't be a simple additive - 2
1835 * light bulbs do not illuminate twice as far as once since 1836 * light bulbs do not illuminate twice as far as once since
1836 * it is a dissapation factor that is cubed. 1837 * it is a dissapation factor that is cubed.
1986void 1987void
1987set_map_reset_time (maptile *map) 1988set_map_reset_time (maptile *map)
1988{ 1989{
1989 int timeout; 1990 int timeout;
1990 1991
1991 timeout = MAP_RESET_TIMEOUT (map); 1992 timeout = map->reset_timeout;
1992 if (timeout <= 0) 1993 if (timeout <= 0)
1993 timeout = MAP_DEFAULTRESET; 1994 timeout = MAP_DEFAULTRESET;
1994 if (timeout >= MAP_MAXRESET) 1995 if (timeout >= MAP_MAXRESET)
1995 timeout = MAP_MAXRESET; 1996 timeout = MAP_MAXRESET;
1996 MAP_WHEN_RESET (map) = time (0) + timeout; 1997 map->reset_time = time (0) + timeout;
1997} 1998}
1998 1999
1999/* this updates the orig_map->tile_map[tile_num] value after loading 2000/* this updates the orig_map->tile_map[tile_num] value after loading
2000 * the map. It also takes care of linking back the freshly loaded 2001 * the map. It also takes care of linking back the freshly loaded
2001 * maps tile_map values if it tiles back to this one. It returns 2002 * maps tile_map values if it tiles back to this one. It returns

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines