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.8 by root, Wed Dec 13 21:27:09 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>
55 printf ("\n"); 49 printf ("\n");
56 } 50 }
57 } 51 }
58 printf ("\n"); 52 printf ("\n");
59} 53}
60EXTERN FILE *logfile; 54
61mapstruct * 55extern FILE *logfile;
56
57maptile *
62generate_random_map (const char *OutFileName, RMParms * RP) 58generate_random_map (const char *OutFileName, RMParms * RP)
63{ 59{
64 char **layout, buf[HUGE_BUF]; 60 char **layout, buf[HUGE_BUF];
65 mapstruct *theMap; 61 maptile *theMap;
66 int i; 62 int i;
67 63
68 /* pick a random seed, or use the one from the input file */ 64 /* pick a random seed, or use the one from the input file */
69 if (RP->random_seed == 0) 65 if (RP->random_seed == 0)
70 RP->random_seed = time (0); 66 RP->random_seed = time (0);
74 write_map_parameters_to_string (buf, RP); 70 write_map_parameters_to_string (buf, RP);
75 71
76 if (RP->difficulty == 0) 72 if (RP->difficulty == 0)
77 { 73 {
78 RP->difficulty = RP->dungeon_level; /* use this instead of a map difficulty */ 74 RP->difficulty = RP->dungeon_level; /* use this instead of a map difficulty */
75
79 if (RP->difficulty_increase > 0.001) 76 if (RP->difficulty_increase > 0.001)
80 {
81 RP->difficulty = (int) ((float) RP->dungeon_level * RP->difficulty_increase); 77 RP->difficulty = (int) ((float) RP->dungeon_level * RP->difficulty_increase);
78
82 if (RP->difficulty < 1) 79 if (RP->difficulty < 1)
83 RP->difficulty = 1; 80 RP->difficulty = 1;
84 }
85 } 81 }
86 else 82 else
87 RP->difficulty_given = 1; 83 RP->difficulty_given = 1;
88 84
89 if (RP->Xsize < MIN_RANDOM_MAP_SIZE) 85 if (RP->Xsize < MIN_RANDOM_MAP_SIZE)
90 RP->Xsize = MIN_RANDOM_MAP_SIZE + RANDOM () % 25 + 5; 86 RP->Xsize = MIN_RANDOM_MAP_SIZE + RANDOM () % 25 + 5;
87
91 if (RP->Ysize < MIN_RANDOM_MAP_SIZE) 88 if (RP->Ysize < MIN_RANDOM_MAP_SIZE)
92 RP->Ysize = MIN_RANDOM_MAP_SIZE + RANDOM () % 25 + 5; 89 RP->Ysize = MIN_RANDOM_MAP_SIZE + RANDOM () % 25 + 5;
93 90
94 if (RP->expand2x > 0) 91 if (RP->expand2x > 0)
95 { 92 {
167 164
168 theMap->msg = strdup_local (buf); 165 theMap->msg = strdup_local (buf);
169 166
170 return theMap; 167 return theMap;
171} 168}
172
173 169
174/* function selects the layout function and gives it whatever 170/* function selects the layout function and gives it whatever
175 arguments it needs. */ 171 arguments it needs. */
176char ** 172char **
177layoutgen (RMParms * RP) 173layoutgen (RMParms * RP)
996void 992void
997copy_object_with_inv (object *src_ob, object *dest_ob) 993copy_object_with_inv (object *src_ob, object *dest_ob)
998{ 994{
999 object *walk, *tmp; 995 object *walk, *tmp;
1000 996
1001 copy_object (src_ob, dest_ob); 997 src_ob->copy_to (dest_ob);
1002 998
1003 for (walk = src_ob->inv; walk != NULL; walk = walk->below) 999 for (walk = src_ob->inv; walk != NULL; walk = walk->below)
1004 { 1000 {
1005 tmp = get_object (); 1001 tmp = object::create ();
1006 copy_object (walk, tmp); 1002 walk->copy_to (tmp);
1007 insert_ob_in_ob (tmp, dest_ob); 1003 insert_ob_in_ob (tmp, dest_ob);
1008 } 1004 }
1009} 1005}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines