… | |
… | |
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 |
… | |
… | |
1545 | |
1541 | |
1546 | nrof -= nr; |
1542 | nrof -= nr; |
1547 | |
1543 | |
1548 | if (nrof) |
1544 | if (nrof) |
1549 | { |
1545 | { |
1550 | adjust_weight (env, -weight * nr); // carrying == 0 |
1546 | adjust_weight (env, -weight * max (1, nr)); // carrying == 0 |
1551 | |
1547 | |
1552 | if (object *pl = visible_to ()) |
1548 | if (object *pl = visible_to ()) |
1553 | esrv_update_item (UPD_NROF, pl, this); |
1549 | esrv_update_item (UPD_NROF, pl, this); |
1554 | |
1550 | |
1555 | return true; |
1551 | return true; |