--- deliantra/server/random_maps/random_map.C 2006/12/31 19:02:24 1.13 +++ deliantra/server/random_maps/random_map.C 2007/01/06 14:42:30 1.17 @@ -1,7 +1,7 @@ - /* CrossFire, A Multiplayer game for X-windows + Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team Copyright (C) 2001 Mark Wedel & Crossfire Development Team Copyright (C) 1992 Frank Tore Johansen @@ -53,8 +53,6 @@ printf ("\n"); } -extern FILE *logfile; - maptile * generate_random_map (const char *OutFileName, random_map_params *RP) { @@ -63,10 +61,7 @@ int i; /* pick a random seed, or use the one from the input file */ - if (RP->random_seed == 0) - RP->random_seed = time (0); - - SRANDOM (RP->random_seed); + SRANDOM (RP->random_seed ? RP->random_seed + RP->dungeon_level : time (0)); write_map_parameters_to_string (buf, RP); @@ -121,6 +116,7 @@ /* set region */ theMap->region = RP->region; + coroapi::cede (); /* create walls unless the wallstyle is "none" */ if (strcmp (RP->wallstyle, "none")) { @@ -132,30 +128,38 @@ } + coroapi::cede (); /* create exits unless the exitstyle is "none" */ if (strcmp (RP->exitstyle, "none")) place_exits (theMap, layout, RP->exitstyle, RP->orientation, RP); + coroapi::cede (); place_specials_in_map (theMap, layout, RP); + coroapi::cede (); /* create monsters unless the monsterstyle is "none" */ if (strcmp (RP->monsterstyle, "none")) place_monsters (theMap, RP->monsterstyle, RP->difficulty, RP); + coroapi::cede (); /* treasures needs to have a proper difficulty set for the map. */ theMap->difficulty = theMap->estimate_difficulty (); + coroapi::cede (); /* create treasure unless the treasurestyle is "none" */ if (strcmp (RP->treasurestyle, "none")) place_treasure (theMap, layout, RP->treasurestyle, RP->treasureoptions, RP); + coroapi::cede (); /* create decor unless the decorstyle is "none" */ if (strcmp (RP->decorstyle, "none")) put_decor (theMap, layout, RP->decorstyle, RP->decoroptions, RP); + coroapi::cede (); /* generate treasures, etc. */ theMap->fix_auto_apply (); + coroapi::cede (); unblock_exits (theMap, layout, RP); /* free the layout */ @@ -629,7 +633,7 @@ void write_map_parameters_to_string (char *buf, random_map_params *RP) { - char small_buf[256]; + char small_buf[2048]; sprintf (buf, "xsize %d\nysize %d\n", RP->Xsize, RP->Ysize); @@ -681,9 +685,9 @@ strcat (buf, small_buf); } - if (RP->final_map[0]) + if (RP->final_map.length ()) { - sprintf (small_buf, "final_map %s\n", RP->final_map); + sprintf (small_buf, "final_map %s\n", &RP->final_map); strcat (buf, small_buf); } @@ -693,9 +697,9 @@ strcat (buf, small_buf); } - if (RP->this_map[0]) + if (RP->this_map.length ()) { - sprintf (small_buf, "origin_map %s\n", RP->this_map); + sprintf (small_buf, "origin_map %s\n", &RP->this_map); strcat (buf, small_buf); } @@ -711,14 +715,12 @@ strcat (buf, small_buf); } - if (RP->layoutoptions2) { sprintf (small_buf, "layoutoptions2 %d\n", RP->layoutoptions2); strcat (buf, small_buf); } - if (RP->layoutoptions3) { sprintf (small_buf, "layoutoptions3 %d\n", RP->layoutoptions3); @@ -731,7 +733,6 @@ strcat (buf, small_buf); } - if (RP->difficulty && RP->difficulty_given) { sprintf (small_buf, "difficulty %d\n", RP->difficulty); @@ -777,16 +778,15 @@ strcat (buf, small_buf); } - if (RP->random_seed) + if (RP->treasureoptions) { - /* Add one so that the next map is a bit different */ - sprintf (small_buf, "random_seed %d\n", RP->random_seed + 1); + sprintf (small_buf, "treasureoptions %d\n", RP->treasureoptions); strcat (buf, small_buf); } - if (RP->treasureoptions) + if (RP->random_seed) { - sprintf (small_buf, "treasureoptions %d\n", RP->treasureoptions); + sprintf (small_buf, "random_seed %d\n", RP->random_seed); strcat (buf, small_buf); } } @@ -818,8 +818,7 @@ int orientation_n, int origin_x_n, int origin_y_n, int random_seed_n, int treasureoptions_n, float difficulty_increase) { - - char small_buf[256]; + char small_buf[2048]; sprintf (buf, "xsize %d\nysize %d\n", xsize_n, ysize_n); @@ -972,8 +971,6 @@ sprintf (small_buf, "treasureoptions %d\n", treasureoptions_n); strcat (buf, small_buf); } - - } /* copy an object with an inventory... i.e., duplicate the inv too. */ @@ -984,7 +981,7 @@ src_ob->copy_to (dest_ob); - for (walk = src_ob->inv; walk != NULL; walk = walk->below) + for (walk = src_ob->inv; walk; walk = walk->below) { tmp = object::create ();