… | |
… | |
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; |
… | |
… | |
1286 | if (op->env) |
1283 | if (op->env) |
1287 | { |
1284 | { |
1288 | LOG (llevError, "insert_ob_in_map called for object in an inventory (proceeding)"); |
1285 | LOG (llevError, "insert_ob_in_map called for object in an inventory (proceeding)"); |
1289 | op->remove (); |
1286 | op->remove (); |
1290 | } |
1287 | } |
|
|
1288 | |
|
|
1289 | if (op->face && !face_info (op->face))//D TODO: remove soon |
|
|
1290 | {//D |
|
|
1291 | LOG (llevError | logBacktrace, "op->face out of bounds: %s", op->debug_desc ());//D |
|
|
1292 | op->face = 1;//D |
|
|
1293 | }//D |
1291 | |
1294 | |
1292 | /* Ideally, the caller figures this out. However, it complicates a lot |
1295 | /* Ideally, the caller figures this out. However, it complicates a lot |
1293 | * of areas of callers (eg, anything that uses find_free_spot would now |
1296 | * of areas of callers (eg, anything that uses find_free_spot would now |
1294 | * need extra work |
1297 | * need extra work |
1295 | */ |
1298 | */ |
… | |
… | |
1539 | |
1542 | |
1540 | nrof -= nr; |
1543 | nrof -= nr; |
1541 | |
1544 | |
1542 | if (nrof) |
1545 | if (nrof) |
1543 | { |
1546 | { |
1544 | adjust_weight (env, -weight * nr); // carrying == 0 |
1547 | adjust_weight (env, -weight * max (1, nr)); // carrying == 0 |
1545 | |
1548 | |
1546 | if (object *pl = visible_to ()) |
1549 | if (object *pl = visible_to ()) |
1547 | esrv_update_item (UPD_NROF, pl, this); |
1550 | esrv_update_item (UPD_NROF, pl, this); |
1548 | |
1551 | |
1549 | return true; |
1552 | return true; |