MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / RenameRoom

Function RenameRoom

editor/editorView.cpp:1245–1277  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1243extern bool StripLeadingTrailingSpaces(char *s);
1244
1245void 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
1253try_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
1279void CEditorView::OnRoomRenameRoom() { RenameRoom(); }
1280

Callers 2

OnEditNameMethod · 0.85
OnRoomRenameRoomMethod · 0.85

Calls 3

InputStringFunction · 0.85
osipf_FindRoomNameFunction · 0.85

Tested by

no test coverage detected