… | |
… | |
158 | unblock_exits (theMap, layout, RP); |
158 | unblock_exits (theMap, layout, RP); |
159 | |
159 | |
160 | /* free the layout */ |
160 | /* free the layout */ |
161 | for (i = 0; i < RP->Xsize; i++) |
161 | for (i = 0; i < RP->Xsize; i++) |
162 | free (layout[i]); |
162 | free (layout[i]); |
|
|
163 | |
163 | free (layout); |
164 | free (layout); |
164 | |
165 | |
165 | theMap->msg = strdup (buf); |
166 | theMap->msg = strdup (buf); |
|
|
167 | theMap->in_memory = MAP_IN_MEMORY; |
166 | |
168 | |
167 | return theMap; |
169 | return theMap; |
168 | } |
170 | } |
169 | |
171 | |
170 | /* function selects the layout function and gives it whatever |
172 | /* function selects the layout function and gives it whatever |
… | |
… | |
570 | |
572 | |
571 | return 0; |
573 | return 0; |
572 | } |
574 | } |
573 | |
575 | |
574 | /* puts doors at appropriate locations in a layout. */ |
576 | /* puts doors at appropriate locations in a layout. */ |
575 | |
|
|
576 | void |
577 | void |
577 | doorify_layout (char **maze, random_map_params * RP) |
578 | doorify_layout (char **maze, random_map_params * RP) |
578 | { |
579 | { |
579 | int ndoors = RP->Xsize * RP->Ysize / 60; /* reasonable number of doors. */ |
580 | int ndoors = RP->Xsize * RP->Ysize / 60; /* reasonable number of doors. */ |
580 | char *doorlist_x; |
581 | char *doorlist_x; |
… | |
… | |
597 | doorlist_x[doorlocs] = i; |
598 | doorlist_x[doorlocs] = i; |
598 | doorlist_y[doorlocs] = j; |
599 | doorlist_y[doorlocs] = j; |
599 | doorlocs++; |
600 | doorlocs++; |
600 | } |
601 | } |
601 | } |
602 | } |
|
|
603 | |
602 | while (ndoors > 0 && doorlocs > 0) |
604 | while (ndoors > 0 && doorlocs > 0) |
603 | { |
605 | { |
604 | int di; |
606 | int di; |
605 | int sindex; |
607 | int sindex; |
606 | |
608 | |
… | |
… | |
616 | /* reduce the size of the list */ |
618 | /* reduce the size of the list */ |
617 | doorlocs--; |
619 | doorlocs--; |
618 | doorlist_x[di] = doorlist_x[doorlocs]; |
620 | doorlist_x[di] = doorlist_x[doorlocs]; |
619 | doorlist_y[di] = doorlist_y[doorlocs]; |
621 | doorlist_y[di] = doorlist_y[doorlocs]; |
620 | } |
622 | } |
|
|
623 | |
621 | free (doorlist_x); |
624 | free (doorlist_x); |
622 | free (doorlist_y); |
625 | free (doorlist_y); |
623 | } |
626 | } |
624 | |
|
|
625 | |
627 | |
626 | void |
628 | void |
627 | write_map_parameters_to_string (char *buf, random_map_params * RP) |
629 | write_map_parameters_to_string (char *buf, random_map_params * RP) |
628 | { |
630 | { |
629 | char small_buf[256]; |
631 | char small_buf[256]; |
… | |
… | |
890 | { |
892 | { |
891 | sprintf (small_buf, "layoutoptions1 %d\n", layoutoptions1_n); |
893 | sprintf (small_buf, "layoutoptions1 %d\n", layoutoptions1_n); |
892 | strcat (buf, small_buf); |
894 | strcat (buf, small_buf); |
893 | } |
895 | } |
894 | |
896 | |
895 | |
|
|
896 | if (layoutoptions2_n) |
897 | if (layoutoptions2_n) |
897 | { |
898 | { |
898 | sprintf (small_buf, "layoutoptions2 %d\n", layoutoptions2_n); |
899 | sprintf (small_buf, "layoutoptions2 %d\n", layoutoptions2_n); |
899 | strcat (buf, small_buf); |
900 | strcat (buf, small_buf); |
900 | } |
901 | } |