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.136 by root, Mon Apr 21 23:35:24 2008 UTC vs.
Revision 1.140 by root, Sun May 4 20:40:52 2008 UTC

811 LOG (llevDebug, "bad luck for object crossing map borders: %s", head->debug_desc ()); 811 LOG (llevDebug, "bad luck for object crossing map borders: %s", head->debug_desc ());
812 head->destroy (); 812 head->destroy ();
813 } 813 }
814 } 814 }
815 815
816 sfree (spaces, size ()), spaces = 0; 816 sfree0 (spaces, size ());
817 } 817 }
818 818
819 if (buttons) 819 if (buttons)
820 free_objectlinkpt (buttons), buttons = 0; 820 free_objectlinkpt (buttons), buttons = 0;
821 821
822 sfree (regions, size ()); regions = 0; 822 sfree0 (regions, size ());
823 delete [] regionmap; regionmap = 0; 823 delete [] regionmap; regionmap = 0;
824} 824}
825 825
826void 826void
827maptile::clear_header () 827maptile::clear_header ()
981 981
982 if (QUERY_FLAG (op, FLAG_GENERATOR)) 982 if (QUERY_FLAG (op, FLAG_GENERATOR))
983 { 983 {
984 total_exp += op->stats.exp; 984 total_exp += op->stats.exp;
985 985
986 if (archetype *at = type_to_archetype (GENERATE_TYPE (op))) 986 if (archetype *at = op->other_arch)
987 {
987 total_exp += at->stats.exp * 8; 988 total_exp += at->stats.exp * 8;
988
989 monster_cnt++; 989 monster_cnt++;
990 }
991
992 for (object *inv = op->inv; inv; inv = inv->below)
993 {
994 total_exp += op->stats.exp * 8;
995 monster_cnt++;
996 }
990 } 997 }
991 } 998 }
992 999
993 avgexp = (double) total_exp / monster_cnt; 1000 avgexp = (double) total_exp / monster_cnt;
994 1001
1064 /* This could be made additive I guess (two lights better than 1071 /* This could be made additive I guess (two lights better than
1065 * one). But if so, it shouldn't be a simple additive - 2 1072 * one). But if so, it shouldn't be a simple additive - 2
1066 * light bulbs do not illuminate twice as far as once since 1073 * light bulbs do not illuminate twice as far as once since
1067 * it is a dissapation factor that is cubed. 1074 * it is a dissapation factor that is cubed.
1068 */ 1075 */
1069 if (tmp->glow_radius > light)
1070 light = tmp->glow_radius; 1076 light = max (light, tmp->glow_radius);
1071 1077
1072 /* This call is needed in order to update objects the player 1078 /* This call is needed in order to update objects the player
1073 * is standing in that have animations (ie, grass, fire, etc). 1079 * is standing in that have animations (ie, grass, fire, etc).
1074 * However, it also causes the look window to be re-drawn 1080 * However, it also causes the look window to be re-drawn
1075 * 3 times each time the player moves, because many of the 1081 * 3 times each time the player moves, because many of the
1587 1593
1588 return ::region::default_region (); 1594 return ::region::default_region ();
1589} 1595}
1590 1596
1591/* picks a random object from a style map. 1597/* picks a random object from a style map.
1592 * Redone by MSW so it should be faster and not use static
1593 * variables to generate tables.
1594 */ 1598 */
1595object * 1599object *
1596maptile::pick_random_object () const 1600maptile::pick_random_object (rand_gen &gen) const
1597{ 1601{
1598 /* while returning a null object will result in a crash, that 1602 /* while returning a null object will result in a crash, that
1599 * is actually preferable to an infinite loop. That is because 1603 * is actually preferable to an infinite loop. That is because
1600 * most servers will automatically restart in case of crash. 1604 * most servers will automatically restart in case of crash.
1601 * Change the logic on getting the random space - shouldn't make 1605 * Change the logic on getting the random space - shouldn't make
1602 * any difference, but this seems clearer to me. 1606 * any difference, but this seems clearer to me.
1603 */ 1607 */
1604 for (int i = 1000; --i;) 1608 for (int i = 1000; --i;)
1605 { 1609 {
1606 object *pick = at (rndm (width), rndm (height)).bot; 1610 object *pick = at (gen (width), gen (height)).bot;
1607 1611
1608 // do not prefer big monsters just because they are big. 1612 // do not prefer big monsters just because they are big.
1609 if (pick && pick->head_ () == pick) 1613 if (pick && pick->is_head ())
1610 return pick->head_ (); 1614 return pick->head_ ();
1611 } 1615 }
1612 1616
1613 // instead of crashing in the unlikely(?) case, try to return *something* 1617 // instead of crashing in the unlikely(?) case, try to return *something*
1614 return get_archetype ("blocked"); 1618 return archetype::find ("bug");
1615} 1619}
1616 1620
1617void 1621void
1618maptile::play_sound (faceidx sound, int x, int y) const 1622maptile::play_sound (faceidx sound, int x, int y) const
1619{ 1623{

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines