Crossfire Server, Trunk
duplicator.cpp
Go to the documentation of this file.
1
/*
2
* Crossfire -- cooperative multi-player graphical RPG and adventure game
3
*
4
* Copyright (c) 1999-2014 Mark Wedel and the Crossfire Development Team
5
* Copyright (c) 1992 Frank Tore Johansen
6
*
7
* Crossfire is free software and comes with ABSOLUTELY NO WARRANTY. You are
8
* welcome to redistribute it under certain conditions. For details, please
9
* see COPYING and LICENSE.
10
*
11
* The authors can be reached via e-mail at <crossfire@metalforge.org>.
12
*/
13
19
#include "
global.h
"
20
21
#include <string.h>
22
23
#include "
ob_methods.h
"
24
#include "
ob_types.h
"
25
#include "
sounds.h
"
26
#include "
sproto.h
"
27
28
static
method_ret
duplicator_type_trigger
(
object
*
op
,
object
*cause,
int
state
);
29
33
void
init_type_duplicator
(
void
) {
34
register_trigger
(
DUPLICATOR
,
duplicator_type_trigger
);
35
}
36
49
static
void
move_duplicator
(
object
*
op
) {
50
object
*
tmp
;
51
52
if
(!
op
->other_arch) {
53
LOG
(
llevInfo
,
"Duplicator with no other_arch! %d %d %s\n"
,
op
->x,
op
->y,
op
->map ?
op
->map->path :
"nullmap"
);
54
return
;
55
}
56
57
if
(
op
->above == NULL)
58
return
;
59
int
count
=
op
->nrof;
60
for
(
tmp
=
op
->above;
tmp
!= NULL;
tmp
=
tmp
->above) {
61
if
(strcmp(
op
->other_arch->name,
tmp
->arch->name) == 0) {
62
if
(
op
->level <= 0) {
63
object_remove
(
tmp
);
64
object_free_drop_inventory
(
tmp
);
65
tmp
=
op
;
// Old tmp was removed, so we can't follow that linked list
66
}
else
{
67
uint64_t new_nrof = (uint64_t)
tmp
->nrof*
op
->level;
68
69
if
(new_nrof >= 1UL<<31)
70
new_nrof = 1UL<<31;
71
tmp
->nrof = new_nrof;
72
}
73
if
(
op
->stats.food) {
74
--
op
->stats.food;
75
if
(!
op
->stats.food) {
76
object_remove
(
op
);
77
object_free_drop_inventory
(
op
);
78
return
;
79
}
80
}
81
if
(
count
<= 1)
82
break
;
83
--
count
;
84
}
85
}
86
}
87
95
static
method_ret
duplicator_type_trigger
(
object
*
op
,
object
*cause,
int
state
) {
96
(
void
)cause;
97
(
void
)
state
;
98
move_duplicator
(
op
);
99
return
METHOD_OK
;
100
}
global.h
LOG
void LOG(LogLevel logLevel, const char *format,...)
Definition:
logger.cpp:58
METHOD_OK
#define METHOD_OK
Definition:
ob_methods.h:15
if
if(!(yy_init))
Definition:
loader.cpp:36428
Ice.tmp
int tmp
Definition:
Ice.py:207
duplicator_type_trigger
static method_ret duplicator_type_trigger(object *op, object *cause, int state)
Definition:
duplicator.cpp:95
move_duplicator
static void move_duplicator(object *op)
Definition:
duplicator.cpp:49
object_free_drop_inventory
void object_free_drop_inventory(object *ob)
Definition:
object.cpp:1560
init_type_duplicator
void init_type_duplicator(void)
Definition:
duplicator.cpp:33
disinfect.count
int count
Definition:
disinfect.py:7
sproto.h
nlohmann::detail::void
j template void())
Definition:
json.hpp:4099
register_trigger
void register_trigger(int ob_type, trigger_func method)
Definition:
ob_types.cpp:98
method_ret
char method_ret
Definition:
ob_methods.h:14
ob_types.h
sounds.h
llevInfo
@ llevInfo
Definition:
logger.h:12
DUPLICATOR
@ DUPLICATOR
Definition:
object.h:207
give.op
op
Definition:
give.py:33
object_remove
void object_remove(object *op)
Definition:
object.cpp:1833
ob_methods.h
dragon.state
state
Definition:
dragon.py:84
crossfire-crossfire-server
types
duplicator
duplicator.cpp
Generated by
1.8.17