Crossfire Server, Trunk  R20513
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 <>.
12  */
19 #include "global.h"
21 #include <string.h>
23 #include "ob_methods.h"
24 #include "ob_types.h"
25 #include "sounds.h"
26 #include "sproto.h"
28 static method_ret duplicator_type_trigger(ob_methods *context, object *op, object *cause, int state);
35 }
48 static void move_duplicator(object *op) {
49  object *tmp;
51  if (!op->other_arch) {
52  LOG(llevInfo, "Duplicator with no other_arch! %d %d %s\n", op->x, op->y, op->map ? op->map->path : "nullmap");
53  return;
54  }
56  if (op->above == NULL)
57  return;
58  for (tmp = op->above; tmp != NULL; tmp = tmp->above) {
59  if (strcmp(op->other_arch->name, tmp->arch->name) == 0) {
60  if (op->level <= 0) {
61  object_remove(tmp);
63  } else {
64  uint64_t new_nrof = (uint64_t)tmp->nrof*op->level;
66  if (new_nrof >= 1UL<<31)
67  new_nrof = 1UL<<31;
68  tmp->nrof = new_nrof;
69  }
70  break;
71  }
72  }
73 }
83 static method_ret duplicator_type_trigger(ob_methods *context, object *op, object *cause, int state) {
84  move_duplicator(op);
85  return METHOD_OK;
86 }
char path[HUGE_BUF]
Filename of the map.
Definition: map.h:365
Sound-related defines.
Definition: logger.h:12
static method_ret duplicator_type_trigger(ob_methods *context, object *op, object *cause, int state)
A duplicator is triggered.
Definition: duplicator.c:83
Typedefs for ob_methods.
Definition: ob_methods.h:45
void init_type_duplicator(void)
Initializer for the duplicator object type.
Definition: duplicator.c:33
struct obj * above
Pointer to the object stacked above this one.
Definition: object.h:288
Duplicator/multiplier object.
Definition: object.h:202
Global type definitions and header inclusions.
struct archt * other_arch
Pointer used for various things - mostly used for what this objects turns into or what this object cr...
Definition: object.h:413
char method_ret
Define some standard return values for callbacks which don&#39;t need to return any other results...
Definition: ob_methods.h:14
void object_free_drop_inventory(object *ob)
Frees everything allocated by an object, removes it from the list of used objects, and puts it on the list of free objects.
Definition: object.c:1368
int16_t y
Position in the map for this object.
Definition: object.h:326
#define METHOD_OK
Definition: ob_methods.h:15
struct mapdef * map
Pointer to the map in which this object is present.
Definition: object.h:297
uint32_t nrof
How many of the objects.
Definition: object.h:333
unsigned __int64 uint64_t
Definition: win32.h:167
static void move_duplicator(object *op)
Trigger for duplicator.
Definition: duplicator.c:48
void register_trigger(int ob_type, trigger_func method)
Registers the trigger method for the given type.
Definition: ob_types.c:98
int16_t x
Definition: object.h:326
Object type variables.
struct archt * arch
Pointer to archetype.
Definition: object.h:412
void LOG(LogLevel logLevel, const char *format,...)
Logs a message to stderr, or to file.
Definition: logger.c:51
Object type functions and variables.
int16_t level
Level of creature or object.
Definition: object.h:351
const char * name
More definite name, like "generate_kobold".
Definition: object.h:466
void object_remove(object *op)
This function removes the object op from the linked list of objects which it is currently tied to...
Definition: object.c:1654