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

Comparing deliantra/server/random_maps/special.C (file contents):
Revision 1.40 by root, Fri Mar 26 00:59:21 2010 UTC vs.
Revision 1.50 by root, Sat Jun 26 22:10:18 2010 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,2010 Marc Alexander Lehmann / Robin Redeker / the Deliantra team 4 * Copyright (©) 2005,2006,2007,2008,2009,2010 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
5 * Copyright (©) 2002 Mark Wedel & Crossfire Development Team 5 * Copyright (©) 2002 Mark Wedel & Crossfire Development Team
6 * Copyright (©) 1992 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
76 if (!tmp->is_head ()) 76 if (!tmp->is_head ())
77 continue; 77 continue;
78 78
79 object *new_ob = tmp->deep_clone (); 79 object *new_ob = tmp->deep_clone ();
80 80
81 if (QUERY_FLAG (tmp, FLAG_IS_LINKED)) 81 if (tmp->flag [FLAG_IS_LINKED])
82 new_ob->add_link (dest_map, tmp->find_link ()->id); 82 new_ob->add_link (dest_map, tmp->find_link ()->id);
83 83
84 dest_map->insert (new_ob, x + i, y + j, 0, INS_NO_MERGE | INS_NO_WALK_ON); 84 dest_map->insert (new_ob, x + i, y + j, 0, INS_NO_MERGE | INS_NO_WALK_ON);
85 } 85 }
86} 86}
162 162
163 while (i < 0 && tries < 10) 163 while (i < 0 && tries < 10)
164 { 164 {
165 ix = rmg_rndm (map->width - 2) + 1; 165 ix = rmg_rndm (map->width - 2) + 1;
166 iy = rmg_rndm (map->height - 2) + 1; 166 iy = rmg_rndm (map->height - 2) + 1;
167 i = find_free_spot (fountain, map, ix, iy, 1, SIZEOFFREE1 + 1); 167 i = rmg_find_free_spot (fountain, map, ix, iy, 1, SIZEOFFREE1 + 1);
168 tries++; 168 tries++;
169 } 169 }
170 170
171 if (i == -1) 171 if (i == -1)
172 { /* can't place fountain */ 172 { /* can't place fountain */
176 } 176 }
177 177
178 ix += freearr_x[i]; 178 ix += freearr_x[i];
179 iy += freearr_y[i]; 179 iy += freearr_y[i];
180 potion->face = fountain->face; 180 potion->face = fountain->face;
181 SET_FLAG (potion, FLAG_NO_PICK); 181 potion->set_flag (FLAG_NO_PICK);
182 SET_FLAG (potion, FLAG_IDENTIFIED); 182 potion->set_flag (FLAG_IDENTIFIED);
183 potion->name = potion->name_pl = shstr_fountain; 183 potion->name = potion->name_pl = shstr_fountain;
184 potion->x = ix; 184 potion->x = ix;
185 potion->y = iy; 185 potion->y = iy;
186 potion->material = name_to_material (shstr_adamantium); 186 potion->material = name_to_material (shstr_adamantium);
187 fountain->x = ix; 187 fountain->x = ix;
191} 191}
192 192
193static void 193static void
194place_special_exit (maptile *map, int hole_type, random_map_params *RP) 194place_special_exit (maptile *map, int hole_type, random_map_params *RP)
195{ 195{
196 int ix, iy, i = -1;
197 char buf[16384];
198 const char *style, *decor, *mon;
199 maptile *exit_style = find_style ("/styles/misc", "obscure_exits", -1); 196 maptile *exit_style = find_style ("/styles/misc", "obscure_exits", RP->difficulty);
200 int g_xsize, g_ysize;
201
202 if (!exit_style) 197 if (!exit_style)
203 { 198 {
204 LOG (llevError, "unable to load stylemap /styles/misc obscure_exits\n"); 199 LOG (llevError, "unable to load stylemap /styles/misc obscure_exits\n");
205 return; 200 return;
206 } 201 }
211 object *the_exit = exit_style->pick_random_object (rmg_rndm)->clone (); 206 object *the_exit = exit_style->pick_random_object (rmg_rndm)->clone ();
212 207
213 // put an upper bound here, just in case 208 // put an upper bound here, just in case
214 for (int repeat = 8192; --repeat; ) 209 for (int repeat = 8192; --repeat; )
215 { 210 {
216 ix = rmg_rndm (1, map->width - 2); 211 int ix = rmg_rndm (1, map->width - 2);
217 iy = rmg_rndm (1, map->height - 2); 212 int iy = rmg_rndm (1, map->height - 2);
218 213
219 i = find_free_spot (the_exit, map, ix, iy, 1, SIZEOFFREE1 + 1); 214 int i = rmg_find_free_spot (the_exit, map, ix, iy, 1, SIZEOFFREE1 + 1);
220 if (i >= 0) 215 if (i >= 0)
221 { 216 {
222 ix += freearr_x[i]; 217 the_exit->x = ix + freearr_x[i];
223 iy += freearr_y[i]; 218 the_exit->y = iy + freearr_y[i];
224 break; 219 break;
225 } 220 }
226 } 221 }
227
228 the_exit->x = ix;
229 the_exit->y = iy;
230 222
231 if (!hole_type) 223 if (!hole_type)
232 hole_type = rmg_rndm (NR_OF_HOLE_TYPES) + 1; 224 hole_type = rmg_rndm (NR_OF_HOLE_TYPES) + 1;
225
226 const char *style, *decor, *mon;
227 int g_xsize, g_ysize;
233 228
234 switch (hole_type) 229 switch (hole_type)
235 { 230 {
236 case GLORY_HOLE: /* treasures */ 231 case GLORY_HOLE: /* treasures */
237 { 232 {
238 g_xsize = rmg_rndm (3) + 4 + RP->difficulty / 4; 233 g_xsize = rmg_rndm (3) + 4 + RP->difficulty / 4;
239 g_ysize = rmg_rndm (3) + 4 + RP->difficulty / 4; 234 g_ysize = rmg_rndm (3) + 4 + RP->difficulty / 4;
240 style = "onion"; 235 style = "onion";
241 decor = "wealth2"; 236 decor = "special_wealth";
242 mon = "none"; 237 mon = "none";
243 break; 238 break;
244 } 239 }
245 240
246 case ORC_ZONE: /* hole with orcs in it. */ 241 case ORC_ZONE: /* hole with orcs in it. */
247 { 242 {
248 g_xsize = rmg_rndm (3) + 4 + RP->difficulty / 4; 243 g_xsize = rmg_rndm (3) + 4 + RP->difficulty / 4;
249 g_ysize = rmg_rndm (3) + 4 + RP->difficulty / 4; 244 g_ysize = rmg_rndm (3) + 4 + RP->difficulty / 4;
250 style = "onion"; 245 style = "onion";
251 decor = "wealth2"; 246 decor = "special_wealth";
252 mon = "orc"; 247 mon = "orc";
253 break; 248 break;
254 } 249 }
255 250
256 case MINING_ZONE: /* hole with orcs in it. */ 251 case MINING_ZONE: /* hole with orcs in it. */
264 } 259 }
265 260
266 default: /* undefined */ 261 default: /* undefined */
267 LOG (llevError, "place_special_exit: undefined hole type %d\n", hole_type); 262 LOG (llevError, "place_special_exit: undefined hole type %d\n", hole_type);
268 return; 263 return;
269 break;
270 } 264 }
271 265
272 /* Need to be at least this size, otherwise the load 266 /* Need to be at least this size, otherwise the load
273 * code will generate new size values which are too large. 267 * code will generate new size values which are too large.
274 */ 268 */
275 if (g_xsize < MIN_RANDOM_MAP_SIZE) g_xsize = MIN_RANDOM_MAP_SIZE; 269 max_it (g_xsize, MIN_RANDOM_MAP_SIZE);
276 if (g_ysize < MIN_RANDOM_MAP_SIZE) g_ysize = MIN_RANDOM_MAP_SIZE; 270 max_it (g_ysize, MIN_RANDOM_MAP_SIZE);
277 271
278 write_parameters_to_string (buf, g_xsize, g_ysize, RP->wallstyle, RP->floorstyle, mon, 272 dynbuf_text buf;
279 "none", style, decor, "none", RP->exitstyle, 0, 0, 0, 273
280 RMOPT_WALLS_ONLY, 0, 0, 1, RP->dungeon_level, RP->dungeon_level, 274 {
281 RP->difficulty, RP->difficulty, -1, 1, 0, 0, 0, 0, RP->difficulty_increase); 275 random_map_params &rp = *new random_map_params; // for zero_intiialised to work...
276
277 //TODO: deep copy
278 rp.hv = (HV *)SvREFCNT_inc_NN ((SV *)RP->hv);
279
280 rp.xsize = g_xsize;
281 rp.ysize = g_ysize;
282
283 assign (rp.monsterstyle , mon);
284 assign (rp.treasurestyle, "none");
285 assign (rp.layoutstyle , style);
286 assign (rp.decorstyle , decor);
287
288 rp.layoutoptions1 = RMOPT_WALLS_ONLY;
289 rp.symmetry = SYMMETRY_NONE;
290 rp.dungeon_depth = RP->dungeon_level;
291 rp.dungeon_level = RP->dungeon_level;
292 rp.difficulty = RP->difficulty;
293 rp.difficulty_given = RP->difficulty;
294 rp.difficulty_increase = RP->difficulty_increase;
295 rp.decoroptions = -1;
296 rp.orientation = 1;
297 rp.random_seed = RP->random_seed + 0xdeadbeef;
298 rp.region = RP->region;
299
300 write_map_parameters_to_string (buf, &rp);
301 delete &rp;
302 }
303
282 the_exit->slaying = shstr_random_map_exit; 304 the_exit->slaying = shstr_random_map_exit;
283 the_exit->msg = buf; 305 the_exit->msg = buf;
284 306
285 insert_ob_in_map (the_exit, map, NULL, 0); 307 insert_ob_in_map (the_exit, map, NULL, 0);
286} 308}
291 switch (rmg_rndm (NUM_OF_SPECIAL_TYPES)) 313 switch (rmg_rndm (NUM_OF_SPECIAL_TYPES))
292 { 314 {
293 case SPECIAL_SUBMAP: 315 case SPECIAL_SUBMAP:
294 { 316 {
295 /* includes a special map into the random map being made. */ 317 /* includes a special map into the random map being made. */
296 maptile *special_map = find_style ("/styles/specialmaps", 0, RP->difficulty); 318 maptile *special_map = find_style ("/styles/specialmaps", 0, RP->difficulty, true);
297 319
298 if (!special_map) 320 if (!special_map)
299 break; 321 break;
300 322
301 int ix, iy; /* map insertion locatons */ 323 int ix, iy; /* map insertion locatons */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines