| 1 |
root |
1.4 |
|
| 2 |
elmex |
1.1 |
/* |
| 3 |
|
|
* static char *rcsid_floor_c = |
| 4 |
root |
1.4 |
* "$Id: floor.C,v 1.3 2006-09-03 09:00:09 root Exp $"; |
| 5 |
elmex |
1.1 |
*/ |
| 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 |
|
|
|
| 31 |
|
|
#include <global.h> |
| 32 |
|
|
#include <random_map.h> |
| 33 |
|
|
#include <rproto.h> |
| 34 |
|
|
|
| 35 |
|
|
/* make a map and layout the floor. */ |
| 36 |
|
|
|
| 37 |
root |
1.4 |
mapstruct * |
| 38 |
|
|
make_map_floor (char **layout, char *floorstyle, RMParms * RP) |
| 39 |
|
|
{ |
| 40 |
elmex |
1.1 |
char styledirname[256]; |
| 41 |
|
|
char stylefilepath[256]; |
| 42 |
root |
1.4 |
mapstruct *style_map = 0; |
| 43 |
elmex |
1.1 |
object *the_floor; |
| 44 |
root |
1.4 |
mapstruct *newMap = 0; |
| 45 |
|
|
|
| 46 |
elmex |
1.1 |
/* allocate the map */ |
| 47 |
root |
1.4 |
newMap = get_empty_map (RP->Xsize, RP->Ysize); |
| 48 |
elmex |
1.1 |
|
| 49 |
|
|
/* get the style map */ |
| 50 |
root |
1.4 |
sprintf (styledirname, "%s", "/styles/floorstyles"); |
| 51 |
|
|
sprintf (stylefilepath, "%s/%s", styledirname, floorstyle); |
| 52 |
|
|
style_map = find_style (styledirname, floorstyle, -1); |
| 53 |
|
|
if (style_map == 0) |
| 54 |
|
|
return newMap; |
| 55 |
elmex |
1.1 |
|
| 56 |
|
|
/* fill up the map with the given floor style */ |
| 57 |
root |
1.4 |
if ((the_floor = pick_random_object (style_map)) != NULL) |
| 58 |
|
|
{ |
| 59 |
|
|
int i, j; |
| 60 |
|
|
|
| 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 |
elmex |
1.1 |
return newMap; |
| 72 |
|
|
} |