| 1055 | } |
| 1056 | |
| 1057 | void CWorldObjectsGenericDialog::OnGenericChangeName() { |
| 1058 | char name[PAGENAME_LEN]; |
| 1059 | mngs_Pagelock pl; |
| 1060 | |
| 1061 | // Make sure we have this ship locked, if not reset name and bail |
| 1062 | int p = mng_FindTrackLock(Object_info[m_current].name, PAGETYPE_GENERIC); |
| 1063 | if (p == -1) { |
| 1064 | OutrageMessageBox("You must lock this object if you wish to change its name."); |
| 1065 | return; |
| 1066 | } |
| 1067 | |
| 1068 | // Get new name |
| 1069 | retry_name: |
| 1070 | strcpy(name, Object_info[m_current].name); |
| 1071 | if (!InputObjectName(name, sizeof(name), "Object name", "Enter a new name for this object:", this)) |
| 1072 | return; |
| 1073 | |
| 1074 | if (FindObjectIDName(name) != -1) { |
| 1075 | OutrageMessageBox("That name is taken, please choose another."); |
| 1076 | goto retry_name; |
| 1077 | } |
| 1078 | |
| 1079 | if (!mng_MakeLocker()) |
| 1080 | return; |
| 1081 | |
| 1082 | // Check to see if this page exists on the network. If so, we have to |
| 1083 | // rename it so we can prevent havoc |
| 1084 | strcpy(pl.name, Object_info[m_current].name); |
| 1085 | pl.pagetype = PAGETYPE_GENERIC; |
| 1086 | |
| 1087 | int ret = mng_CheckIfPageOwned(&pl, TableUser); |
| 1088 | if (ret < 0) |
| 1089 | OutrageMessageBox(ErrorString); |
| 1090 | else if (ret == 1) |
| 1091 | mng_RenamePage(Object_info[m_current].name, name, PAGETYPE_GENERIC); |
| 1092 | else if (ret == 2) { |
| 1093 | // This page has never been checked in, replace only local copy |
| 1094 | |
| 1095 | char oldname[PAGENAME_LEN]; |
| 1096 | strcpy(oldname, Object_info[m_current].name); |
| 1097 | strcpy(Object_info[m_current].name, name); |
| 1098 | |
| 1099 | mng_ReplacePage(oldname, Object_info[m_current].name, m_current, PAGETYPE_GENERIC, 1); |
| 1100 | } else if (ret == 0) { |
| 1101 | OutrageMessageBox("You don't own this page. Get Jason now!"); |
| 1102 | mng_FreeTrackLock(p); |
| 1103 | return; |
| 1104 | } |
| 1105 | |
| 1106 | // Finally, copy our new name to the appropriate arrays |
| 1107 | strcpy(GlobalTrackLocks[p].name, name); |
| 1108 | strcpy(Object_info[m_current].name, name); |
| 1109 | mng_EraseLocker(); |
| 1110 | |
| 1111 | RemapStaticIDs(); |
| 1112 | |
| 1113 | // check to see if current has been remapped |
| 1114 | if (Object_info[m_current].type != m_type) |
nothing calls this directly
no test coverage detected