Atrinik Server  4.0
map_info.c
Go to the documentation of this file.
1 /*************************************************************************
2  * Atrinik, a Multiplayer Online Role Playing Game *
3  * *
4  * Copyright (C) 2009-2014 Alex Tokar and Atrinik Development Team *
5  * *
6  * Fork from Crossfire (Multiplayer game for X-windows). *
7  * *
8  * This program is free software; you can redistribute it and/or modify *
9  * it under the terms of the GNU General Public License as published by *
10  * the Free Software Foundation; either version 2 of the License, or *
11  * (at your option) any later version. *
12  * *
13  * This program is distributed in the hope that it will be useful, *
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16  * GNU General Public License for more details. *
17  * *
18  * You should have received a copy of the GNU General Public License *
19  * along with this program; if not, write to the Free Software *
20  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
21  * *
22  * The author can be reached at admin@atrinik.org *
23  ************************************************************************/
24 
32 #include <global.h>
33 #include <object.h>
34 #include <object_methods.h>
35 
37 static void
38 init_func (object *op)
39 {
40  HARD_ASSERT(op != NULL);
41 
42  if (op->map == NULL) {
43  LOG(ERROR,
44  "Map info object not on map: %s",
45  object_get_str(op));
46  return;
47  }
48 
49  for (int x = op->x; x <= op->x + op->stats.hp; x++) {
50  for (int y = op->y; y <= op->y + op->stats.sp; y++) {
51  if (OUT_OF_MAP(op->map, x, y)) {
52  LOG(ERROR,
53  "Map info object spans invalid area: %s",
54  object_get_str(op));
55  return;
56  }
57 
58  MapSpace *msp = GET_MAP_SPACE_PTR(op->map, x, y);
59  msp->map_info = op;
60  msp->map_info_count = op->count;
61 
62  if (QUERY_FLAG(op, FLAG_NO_MAGIC)) {
64  }
65 
66  if (QUERY_FLAG(op, FLAG_NO_PVP)) {
68  }
69 
70  if (QUERY_FLAG(op, FLAG_STAND_STILL)) {
72  }
73 
74  if (QUERY_FLAG(op, FLAG_CURSED)) {
76  }
77 
78  if (QUERY_FLAG(op, FLAG_IS_MAGICAL)) {
80  }
81 
82  if (QUERY_FLAG(op, FLAG_DAMNED)) {
84  }
85  }
86  }
87 }
88 
93 {
94  OBJECT_METHODS(MAP_INFO)->init_func = init_func;
95 }
#define MSP_EXTRA_NO_HARM
Definition: map.h:320
#define FLAG_CURSED
Definition: define.h:1154
static void init_func(object *op)
Definition: map_info.c:38
#define FLAG_NO_MAGIC
Definition: define.h:1032
#define OUT_OF_MAP(M, X, Y)
Definition: map.h:240
int16_t sp
Definition: living.h:78
#define QUERY_FLAG(xyz, p)
Definition: define.h:761
#define FLAG_STAND_STILL
Definition: define.h:1133
int32_t hp
Definition: living.h:72
#define MSP_EXTRA_IS_BALCONY
Definition: map.h:328
#define FLAG_DAMNED
Definition: define.h:1158
int16_t y
Definition: object.h:276
const char * object_get_str(const object *op)
Definition: object.c:3151
object * map_info
Definition: map.h:345
struct mapdef * map
Definition: object.h:139
#define MAP_INFO
Definition: define.h:514
#define MSP_EXTRA_NO_MAGIC
Definition: map.h:324
OBJECT_TYPE_INIT_DEFINE(map_info)
Definition: map_info.c:92
#define MSP_EXTRA_IS_BUILDING
Definition: map.h:326
int16_t x
Definition: object.h:273
#define MSP_EXTRA_IS_OVERLOOK
Definition: map.h:330
#define FLAG_NO_PVP
Definition: define.h:1166
tag_t count
Definition: object.h:142
tag_t map_info_count
Definition: map.h:360
living stats
Definition: object.h:481
#define OBJECT_METHODS(type)
uint8_t extra_flags
Definition: map.h:390
#define FLAG_IS_MAGICAL
Definition: define.h:1129
#define MSP_EXTRA_NO_PVP
Definition: map.h:322