version 1.44 | | version 1.45 |
---|
| | |
/* | | /* |
* static char *rcsid_apply_c = | | * static char *rcsid_apply_c = |
* "$Id: apply.c,v 1.44 2001/07/14 04:11:18 mwedel Exp $"; | | * "$Id: apply.c,v 1.45 2001/09/03 06:44:55 mwedel Exp $"; |
*/ | | */ |
/* | | /* |
CrossFire, A Multiplayer game for X-windows | | CrossFire, A Multiplayer game for X-windows |
| | |
| | |
/* | | /* |
* Returns 1 if 'op' was destroyed, 0 if not. | | * Returns 1 if 'op' was destroyed, 0 if not. |
| | * Largely re-written to not use nearly as many gotos, plus |
| | * some of this code just looked plain out of date. |
| | * MSW 2001-08-29 |
*/ | | */ |
static int apply_shop_mat (object *shop_mat, object *op) | | static int apply_shop_mat (object *shop_mat, object *op) |
{ | | { |
| | |
| | |
SET_FLAG (op,FLAG_NO_APPLY); /* prevent loops */ | | SET_FLAG (op,FLAG_NO_APPLY); /* prevent loops */ |
| | |
if (op->type != PLAYER) | | if (op->type != PLAYER) { |
{ | | if (QUERY_FLAG(op, FLAG_UNPAID)) { |
if (QUERY_FLAG(op, FLAG_UNPAID)) | | |
{ | | |
/* Somebody dropped an unpaid item, just move to an adjacent place. */ | | /* Somebody dropped an unpaid item, just move to an adjacent place. */ |
int i = find_free_spot (op->arch, op->map, op->x, op->y, 1, 9); | | int i = find_free_spot (op->arch, op->map, op->x, op->y, 1, 9); |
if (i == -1) | | if (i != -1) { |
goto ret; | | |
rv = transfer_ob (op, op->x + freearr_x[i], op->y + freearr_y[i], 0, | | rv = transfer_ob (op, op->x + freearr_x[i], op->y + freearr_y[i], 0, |
shop_mat); | | shop_mat); |
goto ret; | | |
} | | } |
if (op->more || op->head) | | |
goto ret; /* Some nasty bug has to be fixed here... */ | | |
rv = teleport (shop_mat, SHOP_MAT, shop_mat); | | |
goto ret; | | |
} | | } |
| | /* Removed code that checked for multipart objects - it appears that |
if (get_payment (op)) | | * the teleport function should be able to handle this just fine. |
{ | | */ |
rv = teleport (shop_mat, SHOP_MAT, shop_mat); | | rv = teleport (shop_mat, SHOP_MAT, op); |
if ( ! rv && (tmp = get_map_ob (op->map, op->x, op->y)) != NULL | | } |
&& tmp->type != SHOP_FLOOR) | | /* immediate block below is only used for players */ |
{ | | else if (get_payment (op)) { |
| | rv = teleport (shop_mat, SHOP_MAT, op); |
| | if (shop_mat->msg) { |
| | new_draw_info (NDI_UNIQUE, 0, op, shop_mat->msg); |
| | } |
| | /* This check below is a bit simplistic - generally it should be correct, |
| | * but there is never a guarantee that the bottom space on the map is |
| | * actually the shop floor. |
| | */ |
| | else if ( ! rv && (tmp = get_map_ob (op->map, op->x, op->y)) != NULL |
| | && tmp->type != SHOP_FLOOR) { |
new_draw_info (NDI_UNIQUE, 0, op, "Thank you for visiting our shop."); | | new_draw_info (NDI_UNIQUE, 0, op, "Thank you for visiting our shop."); |
} | | } |
goto ret; | | |
} | | } |
else | | else { |
{ | | /* if we get here, a player tried to leave a shop but was not able |
| | * to afford the items he has. We try to move the player so that |
| | * they are not on the mat anymore |
| | */ |
| | |
int i = find_free_spot (op->arch, op->map, op->x, op->y, 1, 9); | | int i = find_free_spot (op->arch, op->map, op->x, op->y, 1, 9); |
if(i == -1) { | | if(i == -1) { |
LOG (llevError, "Internal shop-mat problem.\n"); | | LOG (llevError, "Internal shop-mat problem.\n"); |
goto ret; | | } else { |
} | | |
remove_ob (op); | | remove_ob (op); |
op->x += freearr_x[i]; | | op->x += freearr_x[i]; |
op->y += freearr_y[i]; | | op->y += freearr_y[i]; |
rv = insert_ob_in_map (op, op->map, shop_mat,0) == NULL; | | rv = insert_ob_in_map (op, op->map, shop_mat,0) == NULL; |
goto ret; | | } |
} | | } |
| | |
ret: | | |
CLEAR_FLAG (op, FLAG_NO_APPLY); | | CLEAR_FLAG (op, FLAG_NO_APPLY); |
return rv; | | return rv; |
} | | } |