ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/random_maps/floor.C
Revision: 1.9
Committed: Sun Dec 31 19:02:24 2006 UTC (17 years, 5 months ago) by root
Content type: text/plain
Branch: MAIN
Changes since 1.8: +2 -1 lines
Log Message:
reindent, minor changes

File Contents

# User Rev Content
1 root 1.9
2 elmex 1.1 /*
3     CrossFire, A Multiplayer game for X-windows
4    
5     Copyright (C) 2002 Mark Wedel & Crossfire Development Team
6     Copyright (C) 1992 Frank Tore Johansen
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 root 1.5 The authors can be reached via e-mail at <crossfire@schmorp.de>
23 elmex 1.1 */
24    
25    
26     #include <global.h>
27     #include <random_map.h>
28     #include <rproto.h>
29    
30     /* make a map and layout the floor. */
31    
32 root 1.6 maptile *
33 root 1.9 make_map_floor (char **layout, char *floorstyle, random_map_params *RP)
34 root 1.4 {
35 elmex 1.1 char styledirname[256];
36     char stylefilepath[256];
37 root 1.6 maptile *style_map = 0;
38 elmex 1.1 object *the_floor;
39 root 1.6 maptile *newMap = 0;
40 root 1.4
41 elmex 1.1 /* allocate the map */
42 root 1.7 newMap = new maptile (RP->Xsize, RP->Ysize);
43 elmex 1.1
44     /* get the style map */
45 root 1.4 sprintf (styledirname, "%s", "/styles/floorstyles");
46     sprintf (stylefilepath, "%s/%s", styledirname, floorstyle);
47     style_map = find_style (styledirname, floorstyle, -1);
48     if (style_map == 0)
49     return newMap;
50 elmex 1.1
51     /* fill up the map with the given floor style */
52 root 1.4 if ((the_floor = pick_random_object (style_map)) != NULL)
53     {
54     int i, j;
55    
56     for (i = 0; i < RP->Xsize; i++)
57     for (j = 0; j < RP->Ysize; j++)
58     {
59     object *thisfloor = arch_to_object (the_floor->arch);
60    
61     thisfloor->x = i;
62     thisfloor->y = j;
63     insert_ob_in_map (thisfloor, newMap, thisfloor, INS_NO_MERGE | INS_NO_WALK_ON);
64     }
65     }
66 elmex 1.1 return newMap;
67     }