Atrinik Server  4.0
floor.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 
30 #include <global.h>
31 #include <object.h>
32 
43 mapstruct *make_map_floor(char *floorstyle, RMParms *RP)
44 {
45  char styledirname[256], stylefilepath[256];
46  mapstruct *style_map = NULL, *newMap = NULL;
47  int x, y;
48 
49  /* Allocate the map */
50  newMap = get_empty_map(RP->Xsize, RP->Ysize);
51 
52  /* Get the style map */
53  strncpy(styledirname, "/styles/floorstyles", sizeof(styledirname) - 1);
54  snprintf(stylefilepath, sizeof(stylefilepath), "%s/%s", styledirname, floorstyle);
55  style_map = find_style(styledirname, floorstyle, -1);
56 
57  if (style_map == NULL) {
58  return newMap;
59  }
60 
61  /* Fill up the map with the given floor style */
62  for (x = 0; x < RP->Xsize; x++) {
63  for (y = 0; y < RP->Ysize; y++) {
64  object *the_floor = pick_random_object(style_map), *thisfloor = object_get();
65 
66  object_copy(thisfloor, the_floor, false);
67  thisfloor->x = x;
68  thisfloor->y = y;
69 
70  object_insert_map(thisfloor, newMap, thisfloor, INS_NO_MERGE | INS_NO_WALK_ON);
71  }
72  }
73 
74  return newMap;
75 }
object * object_get(void)
Definition: object.c:993
void object_copy(object *op, const object *src, bool no_speed)
Definition: object.c:886
mapstruct * find_style(const char *dirname, const char *stylename, int difficulty)
Definition: style.c:169
#define INS_NO_WALK_ON
Definition: object.h:570
mapstruct * get_empty_map(int sizex, int sizey)
Definition: map.c:985
object * pick_random_object(mapstruct *style)
Definition: style.c:286
int Ysize
Definition: random_map.h:77
object * object_insert_map(object *op, mapstruct *m, object *originator, int flag)
Definition: object.c:1741
int Xsize
Definition: random_map.h:74
#define INS_NO_MERGE
Definition: object.h:564
mapstruct * make_map_floor(char *floorstyle, RMParms *RP)
Definition: floor.c:43
Definition: map.h:536