Crossfire Server, Trunk
duplicator.c
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 
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) {
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) {
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;
99  return METHOD_OK;
100 }
global.h
object_remove
void object_remove(object *op)
Definition: object.c:1819
METHOD_OK
#define METHOD_OK
Definition: ob_methods.h:15
init_type_duplicator
void init_type_duplicator(void)
Definition: duplicator.c:33
Ice.tmp
int tmp
Definition: Ice.py:207
move_duplicator
static void move_duplicator(object *op)
Definition: duplicator.c:49
disinfect.count
int count
Definition: disinfect.py:7
sproto.h
register_trigger
void register_trigger(int ob_type, trigger_func method)
Definition: ob_types.c:98
nlohmann::detail::void
j template void())
Definition: json.hpp:4099
method_ret
char method_ret
Definition: ob_methods.h:14
ob_types.h
sounds.h
llevInfo
@ llevInfo
Definition: logger.h:12
LOG
void LOG(LogLevel logLevel, const char *format,...)
Definition: logger.c:51
DUPLICATOR
@ DUPLICATOR
Definition: object.h:202
give.op
op
Definition: give.py:33
object_free_drop_inventory
void object_free_drop_inventory(object *ob)
Definition: object.c:1546
quest.state
state
Definition: quest.py:13
ob_methods.h
duplicator_type_trigger
static method_ret duplicator_type_trigger(object *op, object *cause, int state)
Definition: duplicator.c:95
if
if(!(yy_init))
Definition: loader.c:2626