| 141 | } |
| 142 | |
| 143 | static void PlacePlayer(int pnum) |
| 144 | { |
| 145 | int nx, ny, max, min, x, y; |
| 146 | DWORD i; |
| 147 | BOOL done; |
| 148 | |
| 149 | if (plr[pnum].plrlevel == currlevel) { |
| 150 | for (i = 0; i < 8; i++) { |
| 151 | nx = plr[pnum].WorldX + plrxoff2[i]; |
| 152 | ny = plr[pnum].WorldY + plryoff2[i]; |
| 153 | |
| 154 | if (PosOkPlayer(pnum, nx, ny)) { |
| 155 | break; |
| 156 | } |
| 157 | } |
| 158 | |
| 159 | if (!PosOkPlayer(pnum, nx, ny)) { |
| 160 | done = FALSE; |
| 161 | |
| 162 | for (max = 1, min = -1; min > -50 && !done; max++, min--) { |
| 163 | for (y = min; y <= max && !done; y++) { |
| 164 | ny = plr[pnum].WorldY + y; |
| 165 | |
| 166 | for (x = min; x <= max && !done; x++) { |
| 167 | nx = plr[pnum].WorldX + x; |
| 168 | |
| 169 | if (PosOkPlayer(pnum, nx, ny)) { |
| 170 | done = TRUE; |
| 171 | } |
| 172 | } |
| 173 | } |
| 174 | } |
| 175 | } |
| 176 | |
| 177 | plr[pnum].WorldX = nx; |
| 178 | plr[pnum].WorldY = ny; |
| 179 | |
| 180 | dPlayer[nx][ny] = pnum + 1; |
| 181 | |
| 182 | if (pnum == myplr) { |
| 183 | ViewX = nx; |
| 184 | ViewY = ny; |
| 185 | } |
| 186 | } |
| 187 | } |
| 188 | |
| 189 | /** |
| 190 | * @param pnum player index |
no test coverage detected