… | |
… | |
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 |
… | |
… | |
1241 | * job preparing multi-part monsters. |
1237 | * job preparing multi-part monsters. |
1242 | */ |
1238 | */ |
1243 | object * |
1239 | object * |
1244 | insert_ob_in_map_at (object *op, maptile *m, object *originator, int flag, int x, int y) |
1240 | insert_ob_in_map_at (object *op, maptile *m, object *originator, int flag, int x, int y) |
1245 | { |
1241 | { |
|
|
1242 | op->remove (); |
|
|
1243 | |
1246 | for (object *tmp = op->head_ (); tmp; tmp = tmp->more) |
1244 | for (object *tmp = op->head_ (); tmp; tmp = tmp->more) |
1247 | { |
1245 | { |
1248 | tmp->x = x + tmp->arch->x; |
1246 | tmp->x = x + tmp->arch->x; |
1249 | tmp->y = y + tmp->arch->y; |
1247 | tmp->y = y + tmp->arch->y; |
1250 | } |
1248 | } |
… | |
… | |
1273 | * just 'op' otherwise |
1271 | * just 'op' otherwise |
1274 | */ |
1272 | */ |
1275 | object * |
1273 | object * |
1276 | insert_ob_in_map (object *op, maptile *m, object *originator, int flag) |
1274 | insert_ob_in_map (object *op, maptile *m, object *originator, int flag) |
1277 | { |
1275 | { |
|
|
1276 | if (op->is_on_map ()) |
|
|
1277 | { |
|
|
1278 | LOG (llevError, "insert_ob_in_map called for object already on map"); |
|
|
1279 | abort (); |
|
|
1280 | } |
|
|
1281 | |
|
|
1282 | if (op->env) |
|
|
1283 | { |
|
|
1284 | LOG (llevError, "insert_ob_in_map called for object in an inventory (proceeding)"); |
1278 | op->remove (); |
1285 | op->remove (); |
|
|
1286 | } |
|
|
1287 | |
|
|
1288 | if (op->face && !face_info (op->face))//D TODO: remove soon |
|
|
1289 | {//D |
|
|
1290 | LOG (llevError | logBacktrace, "op->face out of bounds: %s", op->debug_desc ());//D |
|
|
1291 | op->face = 1;//D |
|
|
1292 | }//D |
1279 | |
1293 | |
1280 | /* Ideally, the caller figures this out. However, it complicates a lot |
1294 | /* 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 |
1295 | * of areas of callers (eg, anything that uses find_free_spot would now |
1282 | * need extra work |
1296 | * need extra work |
1283 | */ |
1297 | */ |
… | |
… | |
1527 | |
1541 | |
1528 | nrof -= nr; |
1542 | nrof -= nr; |
1529 | |
1543 | |
1530 | if (nrof) |
1544 | if (nrof) |
1531 | { |
1545 | { |
1532 | adjust_weight (env, -weight * nr); // carrying == 0 |
1546 | adjust_weight (env, -weight * max (1, nr)); // carrying == 0 |
1533 | |
1547 | |
1534 | if (object *pl = visible_to ()) |
1548 | if (object *pl = visible_to ()) |
1535 | esrv_update_item (UPD_NROF, pl, this); |
1549 | esrv_update_item (UPD_NROF, pl, this); |
1536 | |
1550 | |
1537 | return true; |
1551 | return true; |