Crossfire Server, Trunk
common_apply.cpp
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 */
28 #include <global.h>
29 #include <ob_methods.h>
30 #include <ob_types.h>
31 #include <sproto.h>
32 
34 
35 method_ret common_pre_ob_move_on(object *trap, object *victim, object *originator) {
36  /* If player is DM, only 2 cases to consider:
37  * - exits
38  * - opened containers on the ground, which should be closed.
39  */
41  && trap->type != EXIT
42  && trap->type != SIGN
43  && trap->type != CONTAINER
44  && !QUERY_FLAG(trap, FLAG_APPLIED))
45  return METHOD_ERROR;
46 
47  /* The following was changed because it was causing perfectly correct
48  * maps to fail. 1) it's not an error to recurse:
49  * rune detonates, summoning monster. monster lands on nearby rune.
50  * nearby rune detonates. This sort of recursion is expected and
51  * proper. This code was causing needless crashes.
52  */
53  if (ob_move_on_recursion_depth >= 500) {
54  LOG(llevDebug, "WARNING: move_apply(): aborting recursion [trap arch %s, name %s; victim arch %s, name %s]\n", trap->arch->name, trap->name, victim->arch->name, victim->name);
55  return METHOD_ERROR;
56  }
58  trap = HEAD(trap);
59 
60  if (events_execute_object_event(trap, EVENT_TRIGGER, originator, victim, NULL, SCRIPT_FIX_ALL) != 0) {
62  return METHOD_ERROR;
63  }
64  return METHOD_OK;
65 }
66 
67 void common_post_ob_move_on(object *trap, object *victim, object *originator) {
68  (void)trap;
69  (void)victim;
70  (void)originator;
72  if (ob_move_on_recursion_depth < 0) /* Safety net :) */
74 }
global.h
LOG
void LOG(LogLevel logLevel, const char *format,...)
Definition: logger.cpp:51
QUERY_FLAG
#define QUERY_FLAG(xyz, p)
Definition: define.h:226
common_post_ob_move_on
void common_post_ob_move_on(object *trap, object *victim, object *originator)
Definition: common_apply.cpp:67
METHOD_OK
#define METHOD_OK
Definition: ob_methods.h:15
SIGN
@ SIGN
Definition: object.h:214
FLAG_APPLIED
#define FLAG_APPLIED
Definition: define.h:235
events_execute_object_event
int events_execute_object_event(object *op, int eventcode, object *activator, object *third, const char *message, int fix)
Definition: events.cpp:292
obj::name
sstring name
Definition: object.h:317
EVENT_TRIGGER
#define EVENT_TRIGGER
Definition: events.h:34
HEAD
#define HEAD(op)
Definition: object.h:596
CONTAINER
@ CONTAINER
Definition: object.h:234
SCRIPT_FIX_ALL
#define SCRIPT_FIX_ALL
Definition: global.h:382
FLAG_WIZPASS
#define FLAG_WIZPASS
Definition: define.h:314
common_pre_ob_move_on
method_ret common_pre_ob_move_on(object *trap, object *victim, object *originator)
Definition: common_apply.cpp:35
sproto.h
nlohmann::detail::void
j template void())
Definition: json.hpp:4099
EXIT
@ EXIT
Definition: object.h:184
obj::arch
struct archt * arch
Definition: object.h:420
method_ret
char method_ret
Definition: ob_methods.h:14
ob_types.h
obj::type
uint8_t type
Definition: object.h:346
reputation.victim
victim
Definition: reputation.py:14
METHOD_ERROR
#define METHOD_ERROR
Definition: ob_methods.h:17
archt::name
sstring name
Definition: object.h:473
ob_methods.h
ob_move_on_recursion_depth
static int ob_move_on_recursion_depth
Definition: common_apply.cpp:33
llevDebug
@ llevDebug
Definition: logger.h:13