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

Function ObjectPaste

editor/ObjectClipboard.cpp:122–166  ·  view source on GitHub ↗

Pastes the object in the Clipboard to the middle of the current segment Returns true on success

Source from the content-addressed store, hash-verified

120// Pastes the object in the Clipboard to the middle of the current segment
121// Returns true on success
122bool ObjectPaste() {
123 mprintf(0, "ObjectPaste()\n");
124
125 Int3(); // I'm not so sure about this routine -- by copying everything over, it may copy
126 // some data it shouldn't, such as script info.
127
128 if (!ObjectInBuffer)
129 return false;
130
131 int16_t next, prev;
132 int roomnum;
133 vector pos;
134 matrix orient;
135 vector last_pos;
136 float creation_time;
137 int handle;
138
139 if (!HObjectPlace(ClipBoardObject.type, ClipBoardObject.id)) {
140 return false;
141 }
142 mprintf(0, "Saving data...\n");
143 handle = Objects[Cur_object_index].handle;
144 next = Objects[Cur_object_index].next;
145 prev = Objects[Cur_object_index].prev;
146 roomnum = Objects[Cur_object_index].roomnum;
147 pos = Objects[Cur_object_index].pos;
148 orient = Objects[Cur_object_index].orient;
149 last_pos = Objects[Cur_object_index].last_pos;
150 creation_time = Objects[Cur_object_index].creation_time;
151
152 mprintf(0, "Overwriting with buffer data\n");
153 memcpy(&Objects[Cur_object_index], &ClipBoardObject, sizeof(object));
154
155 mprintf(0, "Restoring data...\n");
156 Objects[Cur_object_index].handle = handle;
157 Objects[Cur_object_index].next = next;
158 Objects[Cur_object_index].prev = prev;
159 Objects[Cur_object_index].roomnum = roomnum;
160 Objects[Cur_object_index].pos = pos;
161 ObjSetOrient(&Objects[Cur_object_index], &orient);
162 Objects[Cur_object_index].last_pos = last_pos;
163 Objects[Cur_object_index].creation_time = creation_time;
164
165 return true;
166}

Callers 1

OnCommandMethod · 0.85

Calls 2

HObjectPlaceFunction · 0.85
ObjSetOrientFunction · 0.85

Tested by

no test coverage detected