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
33
static
int
ob_move_on_recursion_depth
= 0;
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
*/
40
if
(
QUERY_FLAG
(
victim
,
FLAG_WIZPASS
)
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
}
57
ob_move_on_recursion_depth
++;
58
trap =
HEAD
(trap);
59
60
if
(
events_execute_object_event
(trap,
EVENT_TRIGGER
, originator,
victim
, NULL,
SCRIPT_FIX_ALL
) != 0) {
61
ob_move_on_recursion_depth
--;
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;
71
ob_move_on_recursion_depth
--;
72
if
(
ob_move_on_recursion_depth
< 0)
/* Safety net :) */
73
ob_move_on_recursion_depth
= 0;
74
}
global.h
LOG
void LOG(LogLevel logLevel, const char *format,...)
Definition:
logger.cpp:58
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
object::arch
struct archetype * arch
Definition:
object.h:424
METHOD_OK
#define METHOD_OK
Definition:
ob_methods.h:15
SIGN
@ SIGN
Definition:
object.h:216
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:299
EVENT_TRIGGER
#define EVENT_TRIGGER
Definition:
events.h:34
sword_of_souls.victim
victim
Definition:
sword_of_souls.py:12
HEAD
#define HEAD(op)
Definition:
object.h:607
CONTAINER
@ CONTAINER
Definition:
object.h:236
SCRIPT_FIX_ALL
#define SCRIPT_FIX_ALL
Definition:
global.h:389
object::type
uint8_t type
Definition:
object.h:348
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:186
method_ret
char method_ret
Definition:
ob_methods.h:14
ob_types.h
object::name
sstring name
Definition:
object.h:319
METHOD_ERROR
#define METHOD_ERROR
Definition:
ob_methods.h:17
archetype::name
sstring name
Definition:
object.h:484
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
crossfire-crossfire-server
types
common
common_apply.cpp
Generated by
1.8.17