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

Comparing deliantra/server/random_maps/door.C (file contents):
Revision 1.20 by root, Mon Oct 12 14:00:58 2009 UTC vs.
Revision 1.28 by root, Sat Apr 23 04:56:52 2011 UTC

1/* 1/*
2 * This file is part of Deliantra, the Roguelike Realtime MMORPG. 2 * This file is part of Deliantra, the Roguelike Realtime MMORPG.
3 * 3 *
4 * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team 4 * Copyright (©) 2005,2006,2007,2008,2009,2010,2011 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
5 * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team 5 * Copyright (©) 2002 Mark Wedel & Crossfire Development Team
6 * Copyright (©) 1992,2007 Frank Tore Johansen 6 * Copyright (©) 1992 Frank Tore Johansen
7 * 7 *
8 * Deliantra is free software: you can redistribute it and/or modify it under 8 * Deliantra is free software: you can redistribute it and/or modify it under
9 * the terms of the Affero GNU General Public License as published by the 9 * the terms of the Affero GNU General Public License as published by the
10 * Free Software Foundation, either version 3 of the License, or (at your 10 * Free Software Foundation, either version 3 of the License, or (at your
11 * option) any later version. 11 * option) any later version.
21 * 21 *
22 * The authors can be reached via e-mail to <support@deliantra.net> 22 * The authors can be reached via e-mail to <support@deliantra.net>
23 */ 23 */
24 24
25#include <global.h> 25#include <global.h>
26#include <random_map.h> 26#include <rmg.h>
27#include <rproto.h> 27#include <rproto.h>
28 28
29/* where are there adjacent doors or walls? */ 29/* where are there adjacent doors or walls? */
30int 30static int
31surround_check2 (char **layout, int i, int j, int Xsize, int Ysize) 31surround_check2 (layout &maze, int i, int j)
32{ 32{
33 /* 1 = door or wall to left, 33 /* 1 = door or wall to left,
34 2 = door or wall to right, 34 2 = door or wall to right,
35 4 = door or wall above 35 4 = door or wall above
36 8 = door or wall below */ 36 8 = door or wall below */
37 int surround_index = 0; 37 int surround_index = 0;
38 38
39 if ((i > 0) && (layout[i - 1][j] == 'D' || layout[i - 1][j] == '#')) surround_index |= 1; 39 if ((i > 0) && (maze[i - 1][j] == 'D' || maze[i - 1][j] == '#')) surround_index |= 1;
40 if ((i < Xsize - 1) && (layout[i + 1][j] == 'D' || layout[i + 1][j] == '#')) surround_index |= 2; 40 if ((i < maze.w - 1) && (maze[i + 1][j] == 'D' || maze[i + 1][j] == '#')) surround_index |= 2;
41 if ((j > 0) && (layout[i][j - 1] == 'D' || layout[i][j - 1] == '#')) surround_index |= 4; 41 if ((j > 0) && (maze[i][j - 1] == 'D' || maze[i][j - 1] == '#')) surround_index |= 4;
42 if ((j < Ysize - 1) && (layout[i][j + 1] == 'D' || layout[i][j + 1] == '#')) surround_index |= 8; 42 if ((j < maze.h - 1) && (maze[i][j + 1] == 'D' || maze[i][j + 1] == '#')) surround_index |= 8;
43 43
44 return surround_index; 44 return surround_index;
45} 45}
46 46
47void 47void
48put_doors (maptile *the_map, char **maze, const char *doorstyle, random_map_params *RP) 48put_doors (maptile *the_map, layout &maze, const char *doorstyle, random_map_params *RP)
49{ 49{
50 int i, j; 50 int i, j;
51 maptile *vdoors; 51 maptile *vdoors;
52 maptile *hdoors; 52 maptile *hdoors;
53 char doorpath[1024]; 53 char doorpath[1024];
54 54
55 if (!strcmp (doorstyle, "none")) 55 if (!strcmp (doorstyle, "none"))
56 return; 56 return;
57 57
58 vdoors = find_style ("/styles/doorstyles", doorstyle, -1); 58 vdoors = find_style ("/styles/doorstyles", doorstyle, RP->difficulty);
59 59
60 if (vdoors) 60 if (vdoors)
61 hdoors = vdoors; 61 hdoors = vdoors;
62 else 62 else
63 { 63 {
64 vdoors = find_style ("/styles/doorstyles/vdoors", doorstyle, -1); 64 vdoors = find_style ("/styles/doorstyles/vdoors", doorstyle, RP->difficulty);
65 if (!vdoors) 65 if (!vdoors)
66 return; 66 return;
67 67
68 sprintf (doorpath, "/styles/doorstyles/hdoors%s", strrchr (vdoors->path, '/')); 68 sprintf (doorpath, "/styles/doorstyles/hdoors%s", strrchr (vdoors->path, '/'));
69 hdoors = find_style (doorpath, 0, -1); 69 hdoors = find_style (doorpath, 0, RP->difficulty);
70 if (!hdoors) 70 if (!hdoors)
71 return; 71 return;
72 } 72 }
73 73
74 for (i = 0; i < RP->Xsize; i++) 74 for (i = 0; i < RP->Xsize; i++)
75 for (j = 0; j < RP->Ysize; j++) 75 for (j = 0; j < RP->Ysize; j++)
76 { 76 {
77 if (maze[i][j] == 'D') 77 if (maze[i][j] == 'D')
78 { 78 {
79 int sindex = surround_check2 (maze, i, j, RP->Xsize, RP->Ysize); 79 int sindex = surround_check2 (maze, i, j);
80 80
81 object *this_door = (sindex == 3 ? hdoors : vdoors) 81 object *this_door = (sindex == 3 ? hdoors : vdoors)
82 ->pick_random_object (rmg_rndm); 82 ->pick_random_object (rmg_rndm);
83 83
84 the_map->insert (this_door->clone (), i, j, 0, 0); 84 the_map->insert (this_door->clone (), i, j, 0, 0);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines