| 1243 | extern bool StripLeadingTrailingSpaces(char *s); |
| 1244 | |
| 1245 | void RenameRoom() { |
| 1246 | char tempname[ROOM_NAME_LEN + 1] = ""; |
| 1247 | |
| 1248 | if (Curroomp->name) { |
| 1249 | ASSERT(strlen(Curroomp->name) <= ROOM_NAME_LEN); |
| 1250 | strcpy(tempname, Curroomp->name); |
| 1251 | } |
| 1252 | |
| 1253 | try_again:; |
| 1254 | if (!InputString(tempname, ROOM_NAME_LEN, "Room Name", "Enter a new name:")) |
| 1255 | return; |
| 1256 | |
| 1257 | if (StripLeadingTrailingSpaces(tempname)) |
| 1258 | EditorMessageBox("Note: Leading and/or trailing spaces have been removed from this name (\"%s\")", tempname); |
| 1259 | |
| 1260 | int n = osipf_FindRoomName(tempname); |
| 1261 | if ((n != -1) && (n != ROOMNUM(Curroomp))) { |
| 1262 | EditorMessageBox("Room %d already has this name.", n); |
| 1263 | goto try_again; |
| 1264 | } |
| 1265 | |
| 1266 | if (Curroomp->name) { |
| 1267 | mem_free(Curroomp->name); |
| 1268 | Curroomp->name = NULL; |
| 1269 | } |
| 1270 | |
| 1271 | if (strlen(tempname)) { |
| 1272 | Curroomp->name = (char *)mem_malloc(strlen(tempname) + 1); |
| 1273 | strcpy(Curroomp->name, tempname); |
| 1274 | } |
| 1275 | |
| 1276 | World_changed = 1; |
| 1277 | } |
| 1278 | |
| 1279 | void CEditorView::OnRoomRenameRoom() { RenameRoom(); } |
| 1280 |
no test coverage detected