ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/random_maps/floor.C
(Generate patch)

Comparing deliantra/server/random_maps/floor.C (file contents):
Revision 1.4 by root, Sun Sep 10 16:06:37 2006 UTC vs.
Revision 1.14 by root, Sat Feb 17 23:32:11 2007 UTC

1
2/* 1/*
3 * static char *rcsid_floor_c = 2 * CrossFire, A Multiplayer game
4 * "$Id: floor.C,v 1.4 2006/09/10 16:06:37 root Exp $"; 3 *
4 * Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team
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 * The authors can be reached via e-mail at <crossfire@schmorp.de>
5 */ 23 */
6
7/*
8 CrossFire, A Multiplayer game for X-windows
9
10 Copyright (C) 2002 Mark Wedel & Crossfire Development Team
11 Copyright (C) 1992 Frank Tore Johansen
12
13 This program is free software; you can redistribute it and/or modify
14 it under the terms of the GNU General Public License as published by
15 the Free Software Foundation; either version 2 of the License, or
16 (at your option) any later version.
17
18 This program is distributed in the hope that it will be useful,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 GNU General Public License for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with this program; if not, write to the Free Software
25 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26
27 The authors can be reached via e-mail at crossfire-devel@real-time.com
28*/
29
30 24
31#include <global.h> 25#include <global.h>
32#include <random_map.h> 26#include <random_map.h>
33#include <rproto.h> 27#include <rproto.h>
34 28
35/* make a map and layout the floor. */ 29/* make a map and layout the floor. */
30void
31maptile::make_map_floor (char **layout, char *floorstyle, random_map_params *RP)
32{
33 char styledirname[1024];
34 char stylefilepath[1024];
35 maptile *style_map = 0;
36 object *the_floor;
36 37
37mapstruct * 38 clear ();
38make_map_floor (char **layout, char *floorstyle, RMParms * RP)
39{
40 char styledirname[256];
41 char stylefilepath[256];
42 mapstruct *style_map = 0;
43 object *the_floor;
44 mapstruct *newMap = 0;
45 39
46 /* allocate the map */ 40 width = RP->Xsize;
47 newMap = get_empty_map (RP->Xsize, RP->Ysize); 41 height = RP->Ysize;
42
43 alloc ();
48 44
49 /* get the style map */ 45 /* get the style map */
50 sprintf (styledirname, "%s", "/styles/floorstyles"); 46 sprintf (styledirname, "%s", "/styles/floorstyles");
51 sprintf (stylefilepath, "%s/%s", styledirname, floorstyle); 47 sprintf (stylefilepath, "%s/%s", styledirname, floorstyle);
48
52 style_map = find_style (styledirname, floorstyle, -1); 49 style_map = find_style (styledirname, floorstyle, -1);
50
53 if (style_map == 0) 51 if (!style_map)
54 return newMap; 52 return;
55 53
56 /* fill up the map with the given floor style */ 54 /* fill up the map with the given floor style */
57 if ((the_floor = pick_random_object (style_map)) != NULL) 55 if ((the_floor = style_map->pick_random_object ()))
58 { 56 for (int x = 0; x < width; x++)
59 int i, j; 57 for (int y = 0; y < height; y++)
60 58 insert (arch_to_object (the_floor->arch), x, y, 0, INS_NO_MERGE | INS_NO_WALK_ON);
61 for (i = 0; i < RP->Xsize; i++)
62 for (j = 0; j < RP->Ysize; j++)
63 {
64 object *thisfloor = arch_to_object (the_floor->arch);
65
66 thisfloor->x = i;
67 thisfloor->y = j;
68 insert_ob_in_map (thisfloor, newMap, thisfloor, INS_NO_MERGE | INS_NO_WALK_ON);
69 }
70 }
71 return newMap;
72} 59}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines