| 989 | } |
| 990 | |
| 991 | void CWorldObjectsGenericDialog::OnGenericChangeModel() { |
| 992 | char filename[255]; |
| 993 | char curname[255]; |
| 994 | char fname[255]; |
| 995 | char dir[255]; |
| 996 | char ext[100]; |
| 997 | int img_handle; |
| 998 | int c = 1, finding_name = 1; |
| 999 | int model = 0; |
| 1000 | |
| 1001 | // Get the filename of the representing image |
| 1002 | |
| 1003 | CString filter = "Descent III files (*.pof,*.oof)|*.pof;*.oof||"; |
| 1004 | |
| 1005 | if (!OpenFileDialog(this, (LPCTSTR)filter, filename, Current_model_dir, sizeof(Current_model_dir))) |
| 1006 | return; |
| 1007 | |
| 1008 | std::filesystem::path tmp = ChangePolyModelName(filename); |
| 1009 | strcpy(curname, tmp.u8string().c_str()); |
| 1010 | |
| 1011 | ddio_SplitPath(filename, dir, fname, ext); |
| 1012 | |
| 1013 | if ((FindPolyModelName(curname)) != -1) { |
| 1014 | |
| 1015 | int answer = MessageBox("There is already a model in memory with this name. Are you sure you want to replace it?", |
| 1016 | fname, MB_YESNO); |
| 1017 | if (answer == IDNO) |
| 1018 | return; |
| 1019 | } |
| 1020 | |
| 1021 | // Okay, we selected a file. Lets do what needs to be done here. |
| 1022 | img_handle = LoadPolyModel(filename, 0); |
| 1023 | |
| 1024 | if (img_handle < 0) { |
| 1025 | OutrageMessageBox("Couldn't open that animation/model file."); |
| 1026 | return; |
| 1027 | } |
| 1028 | |
| 1029 | if (m_lod == 0) { |
| 1030 | ChangeOldModelsForObjects(Object_info[m_current].render_handle, img_handle); |
| 1031 | FreePolyModel(Object_info[m_current].render_handle); |
| 1032 | Object_info[m_current].render_handle = img_handle; |
| 1033 | } else if (m_lod == 1) { |
| 1034 | if (Object_info[m_current].med_render_handle != -1) |
| 1035 | FreePolyModel(Object_info[m_current].med_render_handle); |
| 1036 | |
| 1037 | Object_info[m_current].med_render_handle = img_handle; |
| 1038 | } else { |
| 1039 | if (Object_info[m_current].lo_render_handle != -1) |
| 1040 | FreePolyModel(Object_info[m_current].lo_render_handle); |
| 1041 | |
| 1042 | Object_info[m_current].lo_render_handle = img_handle; |
| 1043 | } |
| 1044 | |
| 1045 | // A new model might induce a new weapon stucture |
| 1046 | if (OutrageMessageBox(MBOX_YESNO, "Would you like to clear the weapon battery info?") == IDYES) { |
| 1047 | WBClearInfo(Object_info[m_current].static_wb); |
| 1048 | } |
nothing calls this directly
no test coverage detected