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

Method OnGenericPaste

editor/WorldObjectsGenericDialog.cpp:1272–1337  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1270}
1271
1272void CWorldObjectsGenericDialog::OnGenericPaste() {
1273 char temp_name[PAGENAME_LEN + 10]; // need to add some space for the "CopyxOf"
1274 int n;
1275
1276 ASSERT(Network_up);
1277
1278 ASSERT(Copy_object.type != OBJ_NONE);
1279
1280 if (Copy_object.type != m_type) {
1281 if (OutrageMessageBox(MBOX_YESNO, "You are about to paste a %s object as a %s. Is this OK?",
1282 Object_type_names[Copy_object.type], Object_type_names[m_type]) != IDYES)
1283 return;
1284 }
1285
1286 // Get the name of the new object
1287 strcpy(temp_name, Copy_object.name);
1288 if (FindObjectIDName(temp_name) != -1) {
1289 int c = 2;
1290 sprintf(temp_name, "CopyOf%s", Copy_object.name);
1291 do { // Make sure the name not already in use
1292 if (FindObjectIDName(temp_name) == -1)
1293 break;
1294 sprintf(temp_name, "Copy%dOf%s", c, Copy_object.name);
1295 c++;
1296 } while (1);
1297 }
1298
1299 if (!InputObjectName(temp_name, sizeof(temp_name), "Object name", "Enter a name for your object:", this)) // bail
1300 return;
1301
1302 // Get a slot for this object
1303 n = AllocObjectID(m_type, true, true, true);
1304
1305 if (n == -1) {
1306 OutrageMessageBox("Cannot paste object: There are no free object slots.");
1307 return;
1308 }
1309
1310 // Copy into new slot
1311 Object_info[n] = Copy_object;
1312
1313 Object_info[n].description = Copy_object.description;
1314 Copy_object.description = NULL;
1315
1316 // Set type and name
1317 Object_info[n].type = m_type;
1318 strcpy(Object_info[n].name, temp_name);
1319
1320 // Increment the used count of the polymodels
1321 Poly_models[Object_info[m_current].render_handle].used++;
1322 if (Object_info[m_current].med_render_handle != -1)
1323 Poly_models[Object_info[m_current].med_render_handle].used++;
1324 if (Object_info[m_current].lo_render_handle != -1)
1325 Poly_models[Object_info[m_current].lo_render_handle].used++;
1326
1327 // Make this the current item
1328 m_current = n;
1329

Callers

nothing calls this directly

Calls 6

OutrageMessageBoxFunction · 0.85
FindObjectIDNameFunction · 0.85
InputObjectNameFunction · 0.85
AllocObjectIDFunction · 0.85
mng_AllocTrackLockFunction · 0.85
RemapStaticIDsFunction · 0.85

Tested by

no test coverage detected