static void dump_matrix(XmGeoMatrix geo) { printf("MATRIX: composite: %p instigator %p boxes %p\n", geo->composite, geo->instigator, geo->boxes); printf(" layouts: %p margin_w: %d margin_h: %d stretch_boxes: %d\n", geo->layouts, geo->margin_w, geo->margin_h, geo->stretch_boxes); printf(" uniform_border: %d border: %d max_major: %d boxes_minor: %d\n", geo->uniform_border, geo->border, geo->max_major, geo->boxes_minor); printf(" fill_minor: %d width: %d height: %d set: %p\n", geo->fill_minor, geo->width, geo->height, geo->set_except); printf(" almost: %p no_geo: %p extension %p destruct: %p\n", geo->almost_except, geo->no_geo_request, geo->extension, geo->ext_destructor); printf(" arrange: %p major: %d\n", geo->arrange_boxes, geo->major_order); dump_layout((XmGeoRowLayout)geo->layouts, geo->boxes); }
/** * Main random map routine. Generates a random map based on specified * parameters. * @param OutFileName * The path the map should have. * @param RP * Parameters for generation. * @return * Pointer to the generated map. */ mapstruct *generate_random_map(char *OutFileName, RMParms *RP) { char **layout; mapstruct *theMap; int i; /* pick a random seed, or use the one from the input file */ if (RP->random_seed == 0) { SRANDOM(time(0)); } else { SRANDOM(RP->random_seed); } if (RP->difficulty == 0) { /* use this instead of a map difficulty */ RP->difficulty = RP->dungeon_level; } else { RP->difficulty_given = 1; } if (RP->expand2x > 0) { RP->Xsize /= 2; RP->Ysize /= 2; } layout = layoutgen(RP); if (RP->level_increment > 0) { RP->dungeon_level += RP->level_increment; } else { RP->dungeon_level++; } /* rotate the layout randomly */ layout = rotate_layout(layout, RANDOM() % 4, RP); #ifdef RMAP_DEBUG dump_layout(layout, RP); #endif /* allocate the map and set the floor */ theMap = make_map_floor(RP->floorstyle, RP); /* set the name of the map. */ FREE_AND_COPY_HASH(theMap->path, OutFileName); FREE_AND_COPY_HASH(theMap->name, RP->dungeon_name[0] ? RP->dungeon_name : OutFileName); if (RP->bg_music[0] != '\0') { FREE_AND_COPY_HASH(theMap->bg_music, RP->bg_music); } theMap->difficulty = RP->dungeon_level; make_map_walls(theMap, layout, RP->wallstyle, RP); put_doors(theMap, layout, RP->doorstyle, RP); place_exits(theMap, layout, RP->exitstyle, RP->orientation, RP); place_monsters(theMap, RP->monsterstyle, RP->difficulty, RP); put_decor(theMap, layout, RP); unblock_exits(theMap, layout, RP); set_map_darkness(theMap, RP->darkness); for (i = 0; i < RP->Xsize; i++) { efree(layout[i]); } efree(layout); return theMap; }