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.5 by root, Sat Sep 16 22:24:13 2006 UTC vs.
Revision 1.10 by root, Sat Dec 30 10:16:11 2006 UTC

49 printf ("\n"); 49 printf ("\n");
50 } 50 }
51 } 51 }
52 printf ("\n"); 52 printf ("\n");
53} 53}
54EXTERN FILE *logfile; 54
55extern FILE *logfile;
56
55maptile * 57maptile *
56generate_random_map (const char *OutFileName, RMParms * RP) 58generate_random_map (const char *OutFileName, RMParms * RP)
57{ 59{
58 char **layout, buf[HUGE_BUF]; 60 char **layout, buf[HUGE_BUF];
59 maptile *theMap; 61 maptile *theMap;
68 write_map_parameters_to_string (buf, RP); 70 write_map_parameters_to_string (buf, RP);
69 71
70 if (RP->difficulty == 0) 72 if (RP->difficulty == 0)
71 { 73 {
72 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
73 if (RP->difficulty_increase > 0.001) 76 if (RP->difficulty_increase > 0.001)
74 {
75 RP->difficulty = (int) ((float) RP->dungeon_level * RP->difficulty_increase); 77 RP->difficulty = (int) ((float) RP->dungeon_level * RP->difficulty_increase);
78
76 if (RP->difficulty < 1) 79 if (RP->difficulty < 1)
77 RP->difficulty = 1; 80 RP->difficulty = 1;
78 }
79 } 81 }
80 else 82 else
81 RP->difficulty_given = 1; 83 RP->difficulty_given = 1;
82 84
83 if (RP->Xsize < MIN_RANDOM_MAP_SIZE) 85 if (RP->Xsize < MIN_RANDOM_MAP_SIZE)
84 RP->Xsize = MIN_RANDOM_MAP_SIZE + RANDOM () % 25 + 5; 86 RP->Xsize = MIN_RANDOM_MAP_SIZE + RANDOM () % 25 + 5;
87
85 if (RP->Ysize < MIN_RANDOM_MAP_SIZE) 88 if (RP->Ysize < MIN_RANDOM_MAP_SIZE)
86 RP->Ysize = MIN_RANDOM_MAP_SIZE + RANDOM () % 25 + 5; 89 RP->Ysize = MIN_RANDOM_MAP_SIZE + RANDOM () % 25 + 5;
87 90
88 if (RP->expand2x > 0) 91 if (RP->expand2x > 0)
89 { 92 {
110 113
111 /* allocate the map and set the floor */ 114 /* allocate the map and set the floor */
112 theMap = make_map_floor (layout, RP->floorstyle, RP); 115 theMap = make_map_floor (layout, RP->floorstyle, RP);
113 116
114 /* set the name of the map. */ 117 /* set the name of the map. */
115 strcpy (theMap->path, OutFileName); 118 theMap->path = OutFileName;
116 119
117 /* set region */ 120 /* set region */
118 theMap->region = RP->region; 121 theMap->region = RP->region;
119 122
120 /* create walls unless the wallstyle is "none" */ 123 /* create walls unless the wallstyle is "none" */
137 /* create monsters unless the monsterstyle is "none" */ 140 /* create monsters unless the monsterstyle is "none" */
138 if (strcmp (RP->monsterstyle, "none")) 141 if (strcmp (RP->monsterstyle, "none"))
139 place_monsters (theMap, RP->monsterstyle, RP->difficulty, RP); 142 place_monsters (theMap, RP->monsterstyle, RP->difficulty, RP);
140 143
141 /* treasures needs to have a proper difficulty set for the map. */ 144 /* treasures needs to have a proper difficulty set for the map. */
142 theMap->difficulty = calculate_difficulty (theMap); 145 theMap->difficulty = theMap->estimate_difficulty ();
143 146
144 /* create treasure unless the treasurestyle is "none" */ 147 /* create treasure unless the treasurestyle is "none" */
145 if (strcmp (RP->treasurestyle, "none")) 148 if (strcmp (RP->treasurestyle, "none"))
146 place_treasure (theMap, layout, RP->treasurestyle, RP->treasureoptions, RP); 149 place_treasure (theMap, layout, RP->treasurestyle, RP->treasureoptions, RP);
147 150
157 /* free the layout */ 160 /* free the layout */
158 for (i = 0; i < RP->Xsize; i++) 161 for (i = 0; i < RP->Xsize; i++)
159 free (layout[i]); 162 free (layout[i]);
160 free (layout); 163 free (layout);
161 164
162 theMap->msg = strdup_local (buf); 165 theMap->msg = strdup (buf);
163 166
164 return theMap; 167 return theMap;
165} 168}
166
167 169
168/* function selects the layout function and gives it whatever 170/* function selects the layout function and gives it whatever
169 arguments it needs. */ 171 arguments it needs. */
170char ** 172char **
171layoutgen (RMParms * RP) 173layoutgen (RMParms * RP)
990void 992void
991copy_object_with_inv (object *src_ob, object *dest_ob) 993copy_object_with_inv (object *src_ob, object *dest_ob)
992{ 994{
993 object *walk, *tmp; 995 object *walk, *tmp;
994 996
995 copy_object (src_ob, dest_ob); 997 src_ob->copy_to (dest_ob);
996 998
997 for (walk = src_ob->inv; walk != NULL; walk = walk->below) 999 for (walk = src_ob->inv; walk != NULL; walk = walk->below)
998 { 1000 {
999 tmp = get_object (); 1001 tmp = object::create ();
1000 copy_object (walk, tmp); 1002 walk->copy_to (tmp);
1001 insert_ob_in_ob (tmp, dest_ob); 1003 insert_ob_in_ob (tmp, dest_ob);
1002 } 1004 }
1003} 1005}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines