shuffle descriptions on objects o_low to o_high */
| 110 | |
| 111 | /* shuffle descriptions on objects o_low to o_high */ |
| 112 | staticfn void |
| 113 | shuffle(int o_low, int o_high, boolean domaterial) |
| 114 | { |
| 115 | int i, j, num_to_shuffle; |
| 116 | short sw; |
| 117 | int color; |
| 118 | |
| 119 | for (num_to_shuffle = 0, j = o_low; j <= o_high; j++) |
| 120 | if (!objects[j].oc_name_known) |
| 121 | num_to_shuffle++; |
| 122 | if (num_to_shuffle < 2) |
| 123 | return; |
| 124 | |
| 125 | for (j = o_low; j <= o_high; j++) { |
| 126 | if (objects[j].oc_name_known) |
| 127 | continue; |
| 128 | do |
| 129 | i = j + rn2(o_high - j + 1); |
| 130 | while (objects[i].oc_name_known); |
| 131 | sw = objects[j].oc_descr_idx; |
| 132 | objects[j].oc_descr_idx = objects[i].oc_descr_idx; |
| 133 | objects[i].oc_descr_idx = sw; |
| 134 | sw = objects[j].oc_tough; |
| 135 | objects[j].oc_tough = objects[i].oc_tough; |
| 136 | objects[i].oc_tough = sw; |
| 137 | color = objects[j].oc_color; |
| 138 | objects[j].oc_color = objects[i].oc_color; |
| 139 | objects[i].oc_color = color; |
| 140 | |
| 141 | /* shuffle material */ |
| 142 | if (domaterial) { |
| 143 | sw = objects[j].oc_material; |
| 144 | objects[j].oc_material = objects[i].oc_material; |
| 145 | objects[i].oc_material = sw; |
| 146 | } |
| 147 | } |
| 148 | } |
| 149 | |
| 150 | void |
| 151 | init_objects(void) |