| 256 | } |
| 257 | |
| 258 | void CWorldObjectsDoorDialog::OnAddDoor() { |
| 259 | char filename[256], pathname[256], dir[256], ext[32]; |
| 260 | char cur_name[100]; |
| 261 | int img_handle; |
| 262 | int door_handle; |
| 263 | int c = 1, finding_name = 1; |
| 264 | |
| 265 | if (!Network_up) { |
| 266 | OutrageMessageBox("Sorry babe, the network is down. This action is a no-no.\n"); |
| 267 | return; |
| 268 | } |
| 269 | |
| 270 | // Get the filename of the representing image |
| 271 | |
| 272 | CString filter = "Descent III files (*.pof,*.oof)|*.pof;*.oof||"; |
| 273 | |
| 274 | if (!OpenFileDialog(this, (LPCSTR)filter, pathname, Current_model_dir, sizeof(Current_model_dir))) |
| 275 | return; |
| 276 | |
| 277 | // Okay, we selected a file. Lets do what needs to be done here. |
| 278 | img_handle = LoadDoorImage(pathname, 0); |
| 279 | ddio_SplitPath(pathname, dir, filename, ext); |
| 280 | |
| 281 | if (!VerifyDoorModel(img_handle)) { |
| 282 | FreePolyModel(img_handle); |
| 283 | return; |
| 284 | } |
| 285 | |
| 286 | if (img_handle < 0) { |
| 287 | OutrageMessageBox("Couldn't open that model file."); |
| 288 | return; |
| 289 | } |
| 290 | |
| 291 | // Alloc a door and give a name not already taken by some other door |
| 292 | |
| 293 | door_handle = AllocDoor(); |
| 294 | |
| 295 | while (finding_name) { |
| 296 | if (c == 1) |
| 297 | sprintf(cur_name, "%s", filename); |
| 298 | else |
| 299 | sprintf(cur_name, "%s%d", filename, c); |
| 300 | if (FindDoorName(cur_name) != -1) |
| 301 | c++; |
| 302 | else |
| 303 | finding_name = 0; |
| 304 | } |
| 305 | |
| 306 | strcpy(Doors[door_handle].name, cur_name); |
| 307 | |
| 308 | Doors[door_handle].model_handle = img_handle; |
| 309 | |
| 310 | // Finally, save a local copy of the model/anim and alloc a tracklock |
| 311 | mprintf(0, "Making a copy of this model locally...\n"); |
| 312 | |
| 313 | std::filesystem::path destname = LocalModelsDir / Poly_models[Doors[door_handle].model_handle].name; |
| 314 | cf_CopyFile(destname, pathname); |
| 315 |
nothing calls this directly
no test coverage detected