--- deliantra/server/common/map.C 2007/09/30 20:22:14 1.130 +++ deliantra/server/common/map.C 2008/05/04 20:40:52 1.140 @@ -1,11 +1,11 @@ /* - * This file is part of Crossfire TRT, the Roguelike Realtime MORPG. + * This file is part of Deliantra, the Roguelike Realtime MMORPG. * - * Copyright (©) 2005,2006,2007 Marc Alexander Lehmann / Robin Redeker / the Crossfire TRT team + * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team * Copyright (©) 2001-2003,2007 Mark Wedel & Crossfire Development Team * Copyright (©) 1992,2007 Frank Tore Johansen * - * Crossfire TRT is free software: you can redistribute it and/or modify + * Deliantra is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -18,13 +18,12 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . * - * The authors can be reached via e-mail to + * The authors can be reached via e-mail to */ #include #include "global.h" -#include "funcpoint.h" #include "loader.h" @@ -247,10 +246,9 @@ tmp = next; } - /* sum_weight will go through and calculate what all the containers are - * carrying. - */ - sum_weight (container); + // go through and calculate what all the containers are carrying. + //TODO: remove + container->update_weight (); } void @@ -309,15 +307,16 @@ { for (;;) { - coroapi::cede_to_tick_every (100); // cede once in a while + coroapi::cede_to_tick (); // cede once in a while switch (f.kw) { case KW_arch: if (object *op = object::read (f, this)) { + // TODO: why? if (op->inv) - sum_weight (op); + op->update_weight (); if (IN_RANGE_EXC (op->x, 0, width) && IN_RANGE_EXC (op->y, 0, height)) { @@ -814,13 +813,13 @@ } } - sfree (spaces, size ()), spaces = 0; + sfree0 (spaces, size ()); } if (buttons) free_objectlinkpt (buttons), buttons = 0; - sfree (regions, size ()); regions = 0; + sfree0 (regions, size ()); delete [] regionmap; regionmap = 0; } @@ -984,10 +983,17 @@ { total_exp += op->stats.exp; - if (archetype *at = type_to_archetype (GENERATE_TYPE (op))) - total_exp += at->stats.exp * 8; + if (archetype *at = op->other_arch) + { + total_exp += at->stats.exp * 8; + monster_cnt++; + } - monster_cnt++; + for (object *inv = op->inv; inv; inv = inv->below) + { + total_exp += op->stats.exp * 8; + monster_cnt++; + } } } @@ -1067,8 +1073,7 @@ * light bulbs do not illuminate twice as far as once since * it is a dissapation factor that is cubed. */ - if (tmp->glow_radius > light) - light = tmp->glow_radius; + light = max (light, tmp->glow_radius); /* This call is needed in order to update objects the player * is standing in that have animations (ie, grass, fire, etc). @@ -1223,7 +1228,7 @@ if (!tile_path[dir]) return 0; - if (tile_map[dir] && (!load || tile_map[dir]->in_memory == MAP_IN_MEMORY)) + if (tile_map[dir] && (!load || tile_map[dir]->in_memory == MAP_ACTIVE)) return 1; if ((tile_map[dir] = find_async (tile_path[dir], this, load))) @@ -1590,11 +1595,9 @@ } /* picks a random object from a style map. - * Redone by MSW so it should be faster and not use static - * variables to generate tables. */ object * -maptile::pick_random_object () const +maptile::pick_random_object (rand_gen &gen) const { /* while returning a null object will result in a crash, that * is actually preferable to an infinite loop. That is because @@ -1604,15 +1607,15 @@ */ for (int i = 1000; --i;) { - object *pick = at (rndm (width), rndm (height)).bot; + object *pick = at (gen (width), gen (height)).bot; // do not prefer big monsters just because they are big. - if (pick && pick->head_ () == pick) + if (pick && pick->is_head ()) return pick->head_ (); } // instead of crashing in the unlikely(?) case, try to return *something* - return get_archetype ("blocked"); + return archetype::find ("bug"); } void @@ -1622,11 +1625,11 @@ return; for_all_players (pl) - if (pl->observe->map == this) + if (pl->ob->map == this) if (client *ns = pl->ns) { - int dx = x - pl->observe->x; - int dy = y - pl->observe->y; + int dx = x - pl->ob->x; + int dy = y - pl->ob->y; int distance = idistance (dx, dy);