1 | /* |
1 | /* |
2 | * static char *rcsid_object_c = |
2 | * static char *rcsid_object_c = |
3 | * "$Id: object.c,v 1.4 2006/03/31 21:16:24 root Exp $"; |
3 | * "$Id: object.c,v 1.6 2006/06/04 19:46:55 root Exp $"; |
4 | */ |
4 | */ |
5 | |
5 | |
6 | /* |
6 | /* |
7 | CrossFire, A Multiplayer game for X-windows |
7 | CrossFire, A Multiplayer game for X-windows |
8 | |
8 | |
… | |
… | |
213 | * some items equipped, and we don't want those to merge. |
213 | * some items equipped, and we don't want those to merge. |
214 | */ |
214 | */ |
215 | if (QUERY_FLAG(ob1, FLAG_APPLIED) || QUERY_FLAG(ob2, FLAG_APPLIED)) |
215 | if (QUERY_FLAG(ob1, FLAG_APPLIED) || QUERY_FLAG(ob2, FLAG_APPLIED)) |
216 | return 0; |
216 | return 0; |
217 | |
217 | |
|
|
218 | switch (ob1->type) { |
|
|
219 | case SCROLL: |
|
|
220 | if (ob1->level != ob2->level) return 0; |
|
|
221 | break; |
|
|
222 | |
|
|
223 | } |
218 | if (ob1->key_values != NULL || ob2->key_values != NULL) { |
224 | if (ob1->key_values != NULL || ob2->key_values != NULL) { |
219 | /* At least one of these has key_values. */ |
225 | /* At least one of these has key_values. */ |
220 | if ((ob1->key_values == NULL) != (ob2->key_values == NULL)) { |
226 | if ((ob1->key_values == NULL) != (ob2->key_values == NULL)) { |
221 | /* One has fields, but the other one doesn't. */ |
227 | /* One has fields, but the other one doesn't. */ |
222 | return 0; |
228 | return 0; |
223 | } else { |
|
|
224 | return compare_ob_value_lists(ob1, ob2); |
229 | } else if (!compare_ob_value_lists(ob1, ob2)) { |
|
|
230 | return 0; |
225 | } |
231 | } |
226 | } |
232 | } |
227 | |
233 | |
228 | switch (ob1->type) { |
|
|
229 | case SCROLL: |
|
|
230 | if (ob1->level != ob2->level) return 0; |
|
|
231 | break; |
|
|
232 | |
|
|
233 | } |
|
|
234 | /* Everything passes, must be OK. */ |
234 | /* Everything passes, must be OK. */ |
235 | return 1; |
235 | return 1; |
236 | } |
236 | } |
237 | |
237 | |
238 | /* |
238 | /* |
… | |
… | |
1544 | CLEAR_FLAG(op,FLAG_REMOVED); |
1544 | CLEAR_FLAG(op,FLAG_REMOVED); |
1545 | |
1545 | |
1546 | /* Debugging information so you can see the last coordinates this object had */ |
1546 | /* Debugging information so you can see the last coordinates this object had */ |
1547 | op->ox=op->x; |
1547 | op->ox=op->x; |
1548 | op->oy=op->y; |
1548 | op->oy=op->y; |
|
|
1549 | |
|
|
1550 | /* Ideally, the caller figures this out. However, it complicates a lot |
|
|
1551 | * of areas of callers (eg, anything that uses find_free_spot would now |
|
|
1552 | * need extra work |
|
|
1553 | */ |
|
|
1554 | op->map=get_map_from_coord(m, &op->x, &op->y); |
1549 | x = op->x; |
1555 | x = op->x; |
1550 | y = op->y; |
1556 | y = op->y; |
1551 | op->map=get_map_from_coord(m, &x, &y); |
|
|
1552 | |
1557 | |
1553 | /* this has to be done after we translate the coordinates. |
1558 | /* this has to be done after we translate the coordinates. |
1554 | */ |
1559 | */ |
1555 | if(op->nrof && !(flag & INS_NO_MERGE)) { |
1560 | if(op->nrof && !(flag & INS_NO_MERGE)) { |
1556 | for(tmp=GET_MAP_OB(op->map,x,y);tmp!=NULL;tmp=tmp->above) |
1561 | for(tmp=GET_MAP_OB(op->map,x,y);tmp!=NULL;tmp=tmp->above) |
1557 | if (CAN_MERGE(op,tmp)) { |
1562 | if (CAN_MERGE(op,tmp)) { |
1558 | op->nrof+=tmp->nrof; |
1563 | op->nrof+=tmp->nrof; |
1559 | remove_ob(tmp); |
1564 | remove_ob(tmp); |
1560 | free_object(tmp); |
1565 | free_object(tmp); |
1561 | } |
1566 | } |
1562 | } |
|
|
1563 | |
|
|
1564 | /* Ideally, the caller figures this out. However, it complicates a lot |
|
|
1565 | * of areas of callers (eg, anything that uses find_free_spot would now |
|
|
1566 | * need extra work |
|
|
1567 | */ |
|
|
1568 | if (op->map != m) { |
|
|
1569 | /* coordinates should not change unless map also changes */ |
|
|
1570 | op->x = x; |
|
|
1571 | op->y = y; |
|
|
1572 | } |
1567 | } |
1573 | |
1568 | |
1574 | CLEAR_FLAG(op,FLAG_APPLIED); /* hack for fixing F_APPLIED in items of dead people */ |
1569 | CLEAR_FLAG(op,FLAG_APPLIED); /* hack for fixing F_APPLIED in items of dead people */ |
1575 | CLEAR_FLAG(op, FLAG_INV_LOCKED); |
1570 | CLEAR_FLAG(op, FLAG_INV_LOCKED); |
1576 | if (!QUERY_FLAG(op, FLAG_ALIVE)) |
1571 | if (!QUERY_FLAG(op, FLAG_ALIVE)) |