Crossfire Server, Trunk
identify_altar.c
Go to the documentation of this file.
1 /*
2  CrossFire, A Multiplayer game for X-windows
3 
4  Copyright (C) 2007 Mark Wedel & Crossfire Development Team
5  Copyright (C) 1992 Frank Tore Johansen
6 
7  This program is free software; you can redistribute it and/or modify
8  it under the terms of the GNU General Public License as published by
9  the Free Software Foundation; either version 2 of the License, or
10  (at your option) any later version.
11 
12  This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with this program; if not, write to the Free Software
19  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 
21  The authors can be reached via e-mail at crossfire-devel@real-time.com
22 */
23 
27 #include <global.h>
28 #include <ob_methods.h>
29 #include <ob_types.h>
30 #include <sounds.h>
31 #include <sproto.h>
32 
33 static method_ret identify_altar_type_move_on(object *altar, object *money, object *originator);
34 
40 }
41 
49 static method_ret identify_altar_type_move_on(object *altar, object *money, object *originator) {
50  object *marked;
51  int success = 0;
52  char desc[MAX_BUF];
53 
54  if (common_pre_ob_move_on(altar, money, originator) == METHOD_ERROR)
55  return METHOD_OK;
56 
57  if (originator == NULL || originator->type != PLAYER) {
58  common_post_ob_move_on(altar, money, originator);
59  return METHOD_OK;
60  }
61  /* Check for MONEY type is a special hack - it prevents 'nothing needs
62  * identifying' from being printed out more than it needs to be.
63  */
64  if (money->type != MONEY || !check_altar_sacrifice(altar, money, 0, NULL)) {
65  common_post_ob_move_on(altar, money, originator);
66  return METHOD_OK;
67  }
68  marked = find_marked_object(originator);
69  /* if the player has a marked item, identify that if it needs to be
70  * identified. IF it doesn't, then go through the player inventory.
71  */
72  if (marked && !is_identified(marked)) {
73  if (operate_altar(altar, &money)) {
76  "You have %s.",
77  ob_describe(marked, originator, 1, desc, sizeof(desc)));
78 
79  if (marked->msg) {
81  "The item has a story:");
83  marked->msg);
84  }
85  common_post_ob_move_on(altar, money, originator);
86  return METHOD_OK;
87  }
88  }
89 
90  FOR_INV_PREPARE(originator, id) {
91  if (!id->invisible && !is_identified(id)) {
92  if (operate_altar(altar, &money)) {
93  id = identify(id);
95  "You have %s.", ob_describe(id, originator, 1, desc, sizeof(desc)));
96  if (id->msg) {
98  "The item has a story:");
100  id->msg);
101  }
102  success = 1;
103  /* If no more money, might as well quit now */
104  if (money == NULL || !check_altar_sacrifice(altar, money, 0, NULL))
105  break;
106  } else {
107  LOG(llevError, "check_id_altar: Couldn't do sacrifice when we should have been able to\n");
108  break;
109  }
110  }
111  } FOR_INV_FINISH();
112  if (!success)
114  "You have nothing that needs identifying");
115  common_post_ob_move_on(altar, money, originator);
116  return METHOD_OK;
117 }
PLAYER
@ PLAYER
Definition: object.h:107
global.h
llevError
@ llevError
Definition: logger.h:11
init_type_identify_altar
void init_type_identify_altar(void)
Definition: identify_altar.c:38
METHOD_OK
#define METHOD_OK
Definition: ob_methods.h:15
check_altar_sacrifice
int check_altar_sacrifice(const object *altar, const object *sacrifice, int remove_others, int *toremove)
Definition: button.c:347
identify_altar_type_move_on
static method_ret identify_altar_type_move_on(object *altar, object *money, object *originator)
Definition: identify_altar.c:49
identify
object * identify(object *op)
Definition: item.c:1408
operate_altar
int operate_altar(object *altar, object **sacrifice)
Definition: button.c:463
MSG_TYPE_APPLY_SUCCESS
#define MSG_TYPE_APPLY_SUCCESS
Definition: newclient.h:603
common_pre_ob_move_on
method_ret common_pre_ob_move_on(object *trap, object *victim, object *originator)
Definition: common_apply.c:51
register_move_on
void register_move_on(int ob_type, move_on_func method)
Definition: ob_types.c:89
FOR_INV_FINISH
#define FOR_INV_FINISH()
Definition: define.h:675
sproto.h
MAX_BUF
#define MAX_BUF
Definition: define.h:35
ob_describe
char * ob_describe(const object *op, const object *observer, int use_media_tags, char *buf, size_t size)
Definition: ob_methods.c:91
method_ret
char method_ret
Definition: ob_methods.h:14
ob_types.h
sounds.h
altar_valkyrie.altar
altar
Definition: altar_valkyrie.py:27
obj::type
uint8_t type
Definition: object.h:341
NDI_UNIQUE
#define NDI_UNIQUE
Definition: newclient.h:262
LOG
void LOG(LogLevel logLevel, const char *format,...)
Definition: logger.c:51
MSG_TYPE_APPLY_FAILURE
#define MSG_TYPE_APPLY_FAILURE
Definition: newclient.h:604
draw_ext_info
void draw_ext_info(int flags, int pri, const object *pl, uint8_t type, uint8_t subtype, const char *message)
Definition: main.c:309
positioning_system.marked
marked
Definition: positioning_system.py:21
METHOD_ERROR
#define METHOD_ERROR
Definition: ob_methods.h:17
ob_methods.h
IDENTIFY_ALTAR
@ IDENTIFY_ALTAR
Definition: object.h:237
MSG_TYPE_APPLY
#define MSG_TYPE_APPLY
Definition: newclient.h:408
common_post_ob_move_on
void common_post_ob_move_on(object *trap, object *victim, object *originator)
Definition: common_apply.c:86
find_marked_object
object * find_marked_object(object *op)
Definition: c_object.c:1520
FOR_INV_PREPARE
#define FOR_INV_PREPARE(op_, it_)
Definition: define.h:668
draw_ext_info_format
void draw_ext_info_format(int flags, int pri, const object *pl, uint8_t type, uint8_t subtype, const char *format,...)
Definition: main.c:319
MONEY
@ MONEY
Definition: object.h:137
is_identified
int is_identified(const object *op)
Definition: item.c:1335
diamondslots.id
id
Definition: diamondslots.py:53