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

Comparing deliantra/server/random_maps/random_map.C (file contents):
Revision 1.3 by root, Sun Sep 10 16:06:37 2006 UTC vs.
Revision 1.6 by root, Fri Sep 29 20:12:32 2006 UTC

1
2/*
3 * static char *rcsid_random_map_c =
4 * "$Id: random_map.C,v 1.3 2006/09/10 16:06:37 root Exp $";
5 */
6
7/* 1/*
8 CrossFire, A Multiplayer game for X-windows 2 CrossFire, A Multiplayer game for X-windows
9 3
10 Copyright (C) 2001 Mark Wedel & Crossfire Development Team 4 Copyright (C) 2001 Mark Wedel & Crossfire Development Team
11 Copyright (C) 1992 Frank Tore Johansen 5 Copyright (C) 1992 Frank Tore Johansen
22 16
23 You should have received a copy of the GNU General Public License 17 You should have received a copy of the GNU General Public License
24 along with this program; if not, write to the Free Software 18 along with this program; if not, write to the Free Software
25 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 20
27 The authors can be reached via e-mail at crossfire-devel@real-time.com 21 The authors can be reached via e-mail at <crossfire@schmorp.de>
28*/ 22*/
29 23
30#include <time.h> 24#include <time.h>
31#include <stdio.h> 25#include <stdio.h>
32#include <global.h> 26#include <global.h>
56 } 50 }
57 } 51 }
58 printf ("\n"); 52 printf ("\n");
59} 53}
60EXTERN FILE *logfile; 54EXTERN FILE *logfile;
61mapstruct * 55maptile *
62generate_random_map (const char *OutFileName, RMParms * RP) 56generate_random_map (const char *OutFileName, RMParms * RP)
63{ 57{
64 char **layout, buf[HUGE_BUF]; 58 char **layout, buf[HUGE_BUF];
65 mapstruct *theMap; 59 maptile *theMap;
66 int i; 60 int i;
67 61
68 /* pick a random seed, or use the one from the input file */ 62 /* pick a random seed, or use the one from the input file */
69 if (RP->random_seed == 0) 63 if (RP->random_seed == 0)
70 RP->random_seed = time (0); 64 RP->random_seed = time (0);
74 write_map_parameters_to_string (buf, RP); 68 write_map_parameters_to_string (buf, RP);
75 69
76 if (RP->difficulty == 0) 70 if (RP->difficulty == 0)
77 { 71 {
78 RP->difficulty = RP->dungeon_level; /* use this instead of a map difficulty */ 72 RP->difficulty = RP->dungeon_level; /* use this instead of a map difficulty */
73
79 if (RP->difficulty_increase > 0.001) 74 if (RP->difficulty_increase > 0.001)
80 {
81 RP->difficulty = (int) ((float) RP->dungeon_level * RP->difficulty_increase); 75 RP->difficulty = (int) ((float) RP->dungeon_level * RP->difficulty_increase);
76
82 if (RP->difficulty < 1) 77 if (RP->difficulty < 1)
83 RP->difficulty = 1; 78 RP->difficulty = 1;
84 }
85 } 79 }
86 else 80 else
87 RP->difficulty_given = 1; 81 RP->difficulty_given = 1;
88 82
89 if (RP->Xsize < MIN_RANDOM_MAP_SIZE) 83 if (RP->Xsize < MIN_RANDOM_MAP_SIZE)
90 RP->Xsize = MIN_RANDOM_MAP_SIZE + RANDOM () % 25 + 5; 84 RP->Xsize = MIN_RANDOM_MAP_SIZE + RANDOM () % 25 + 5;
85
91 if (RP->Ysize < MIN_RANDOM_MAP_SIZE) 86 if (RP->Ysize < MIN_RANDOM_MAP_SIZE)
92 RP->Ysize = MIN_RANDOM_MAP_SIZE + RANDOM () % 25 + 5; 87 RP->Ysize = MIN_RANDOM_MAP_SIZE + RANDOM () % 25 + 5;
93 88
94 if (RP->expand2x > 0) 89 if (RP->expand2x > 0)
95 { 90 {
167 162
168 theMap->msg = strdup_local (buf); 163 theMap->msg = strdup_local (buf);
169 164
170 return theMap; 165 return theMap;
171} 166}
172
173 167
174/* function selects the layout function and gives it whatever 168/* function selects the layout function and gives it whatever
175 arguments it needs. */ 169 arguments it needs. */
176char ** 170char **
177layoutgen (RMParms * RP) 171layoutgen (RMParms * RP)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines