ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/common/object.C
(Generate patch)

Comparing deliantra/server/common/object.C (file contents):
Revision 1.243 by root, Sat May 17 00:17:02 2008 UTC vs.
Revision 1.251 by root, Sun Jul 20 16:56:34 2008 UTC

184 if (ob1 == ob2 184 if (ob1 == ob2
185 || ob1->type != ob2->type 185 || ob1->type != ob2->type
186 || ob1->speed != ob2->speed 186 || ob1->speed != ob2->speed
187 || ob1->value != ob2->value 187 || ob1->value != ob2->value
188 || ob1->name != ob2->name) 188 || ob1->name != ob2->name)
189 return 0;
190
191 // some objects are unmergable
192 if (!ob1->nrof || !ob2->nrof)
193 return 0; 189 return 0;
194 190
195 /* Do not merge objects if nrof would overflow. First part checks 191 /* Do not merge objects if nrof would overflow. First part checks
196 * for unsigned overflow (2c), second part checks whether the result 192 * for unsigned overflow (2c), second part checks whether the result
197 * would fit into a 32 bit signed int, which is often used to hold 193 * would fit into a 32 bit signed int, which is often used to hold
349 else 345 else
350 { 346 {
351 // maybe there is a player standing on the same mapspace 347 // maybe there is a player standing on the same mapspace
352 // this will catch the case where "this" is a player 348 // this will catch the case where "this" is a player
353 if (object *pl = ms ().player ()) 349 if (object *pl = ms ().player ())
350 if ((!pl->container && pl->contr->ns && !pl->contr->ns->update_look)
354 if (!pl->container || this == pl->container) 351 || this == pl->container)
355 return pl; 352 return pl;
356 } 353 }
357 } 354 }
358 355
359 return 0; 356 return 0;
913 || map->in_memory != MAP_ACTIVE 910 || map->in_memory != MAP_ACTIVE
914 || map->no_drop 911 || map->no_drop
915 || ms ().move_block == MOVE_ALL) 912 || ms ().move_block == MOVE_ALL)
916 { 913 {
917 while (inv) 914 while (inv)
918 {
919 inv->destroy_inv (false);
920 inv->destroy (); 915 inv->destroy (true);
921 }
922 } 916 }
923 else 917 else
924 { /* Put objects in inventory onto this space */ 918 { /* Put objects in inventory onto this space */
925 while (inv) 919 while (inv)
926 { 920 {
1241 * job preparing multi-part monsters. 1235 * job preparing multi-part monsters.
1242 */ 1236 */
1243object * 1237object *
1244insert_ob_in_map_at (object *op, maptile *m, object *originator, int flag, int x, int y) 1238insert_ob_in_map_at (object *op, maptile *m, object *originator, int flag, int x, int y)
1245{ 1239{
1240 op->remove ();
1241
1246 for (object *tmp = op->head_ (); tmp; tmp = tmp->more) 1242 for (object *tmp = op->head_ (); tmp; tmp = tmp->more)
1247 { 1243 {
1248 tmp->x = x + tmp->arch->x; 1244 tmp->x = x + tmp->arch->x;
1249 tmp->y = y + tmp->arch->y; 1245 tmp->y = y + tmp->arch->y;
1250 } 1246 }
1273 * just 'op' otherwise 1269 * just 'op' otherwise
1274 */ 1270 */
1275object * 1271object *
1276insert_ob_in_map (object *op, maptile *m, object *originator, int flag) 1272insert_ob_in_map (object *op, maptile *m, object *originator, int flag)
1277{ 1273{
1274 if (op->is_on_map ())
1275 {
1276 LOG (llevError, "insert_ob_in_map called for object already on map");
1277 abort ();
1278 }
1279
1280 if (op->env)
1281 {
1282 LOG (llevError, "insert_ob_in_map called for object in an inventory (proceeding)");
1278 op->remove (); 1283 op->remove ();
1284 }
1285
1286 if (op->face && !face_info (op->face))//D TODO: remove soon
1287 {//D
1288 LOG (llevError | logBacktrace, "op->face out of bounds: %s", op->debug_desc ());//D
1289 op->face = 1;//D
1290 }//D
1279 1291
1280 /* Ideally, the caller figures this out. However, it complicates a lot 1292 /* Ideally, the caller figures this out. However, it complicates a lot
1281 * of areas of callers (eg, anything that uses find_free_spot would now 1293 * of areas of callers (eg, anything that uses find_free_spot would now
1282 * need extra work 1294 * need extra work
1283 */ 1295 */
1523 if (!nr) 1535 if (!nr)
1524 return true; 1536 return true;
1525 1537
1526 nr = min (nr, nrof); 1538 nr = min (nr, nrof);
1527 1539
1540 if (nrof > nr)
1541 {
1528 nrof -= nr; 1542 nrof -= nr;
1529
1530 if (nrof)
1531 {
1532 adjust_weight (env, -weight * nr); // carrying == 0 1543 adjust_weight (env, -weight * max (1, nr)); // carrying == 0
1533 1544
1534 if (object *pl = visible_to ()) 1545 if (object *pl = visible_to ())
1535 esrv_update_item (UPD_NROF, pl, this); 1546 esrv_update_item (UPD_NROF, pl, this);
1536 1547
1537 return true; 1548 return true;
1538 } 1549 }
1539 else 1550 else
1540 { 1551 {
1541 destroy (1); 1552 destroy ();
1542 return false; 1553 return false;
1543 } 1554 }
1544} 1555}
1545 1556
1546/* 1557/*

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines