--- deliantra/server/common/object.C 2012/01/03 11:25:31 1.352
+++ deliantra/server/common/object.C 2012/11/12 03:14:32 1.355
@@ -1,24 +1,24 @@
/*
* This file is part of Deliantra, the Roguelike Realtime MMORPG.
- *
+ *
* Copyright (©) 2005,2006,2007,2008,2009,2010,2011,2012 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
* Copyright (©) 2001 Mark Wedel & Crossfire Development Team
* Copyright (©) 1992 Frank Tore Johansen
- *
+ *
* Deliantra is free software: you can redistribute it and/or modify it under
* the terms of the Affero GNU General Public License as published by the
* Free Software Foundation, either version 3 of the License, or (at your
* option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the Affero GNU General Public License
* and the GNU General Public License along with this program. If not, see
* .
- *
+ *
* The authors can be reached via e-mail to
*/
@@ -448,12 +448,13 @@
}
// adjust weight per container type ("of holding")
-static uint32
-weight_adjust_for (object *op, uint32 weight)
+static weight_t
+weight_adjust_for (object *op, weight_t weight)
{
- return op->type == CONTAINER
- ? weight - weight * op->stats.Str / 100
- : weight;
+ if (op->type == CONTAINER)
+ weight -= weight * op->stats.Str / 100;
+
+ return weight;
}
/*
@@ -461,22 +462,22 @@
* and also updates how much the environment(s) is/are carrying.
*/
static void
-adjust_weight (object *op, sint32 sub, sint32 add)
+adjust_weight (object *op, weight_t sub, weight_t add)
{
while (op)
{
- sint32 ocarrying = op->carrying;
+ weight_t carrying = op->carrying
+ - weight_adjust_for (op, sub);
+ + weight_adjust_for (op, add);
- op->carrying -= weight_adjust_for (op, sub);
- op->carrying += weight_adjust_for (op, add);
+ sub = op->carrying;
+ op->carrying = carrying;
+ add = op->carrying;
if (object *pl = op->visible_to ())
if (pl != op) // player is handled lazily
esrv_update_item (UPD_WEIGHT, pl, op);
- sub = ocarrying;
- add = op->carrying;
-
op = op->env;
}
}
@@ -489,7 +490,7 @@
void
object::update_weight ()
{
- sint32 sum = 0;
+ weight_t sum = 0;
for (object *op = inv; op; op = op->below)
{
@@ -1608,7 +1609,7 @@
if (nrof > nr)
{
- sint64 oweight = total_weight ();
+ weight_t oweight = total_weight ();
nrof -= nr;
@@ -1702,15 +1703,15 @@
/* return the original object and remove inserted object
(client prefers the original object) */
- // carring must be 0 for mergable objects
- sint64 oweight = tmp->weight * tmp->nrof;
+ // carrying must be 0 for mergable objects
+ weight_t oweight = weight_t (tmp->weight) * tmp->nrof;
tmp->nrof += op->nrof;
if (object *pl = tmp->visible_to ())
esrv_update_item (UPD_NROF, pl, tmp);
- adjust_weight (this, oweight, tmp->weight * tmp->nrof);
+ adjust_weight (this, oweight, weight_t (tmp->weight) * tmp->nrof);
op->destroy ();
op = tmp;
@@ -2010,7 +2011,7 @@
find_free_spot (const object *ob, maptile *m, int x, int y, int start, int stop)
{
int altern[SIZEOFFREE];
- int index = 0, flag;
+ int index = 0;
for (int i = start; i < stop; i++)
{
@@ -2132,7 +2133,7 @@
int
find_dir (maptile *m, int x, int y, object *exclude)
{
- int max = SIZEOFFREE, mflags;
+ int max = SIZEOFFREE;
MoveType move_type;
if (exclude && exclude->head_ () != exclude)