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

Function CreateViewerObject

editor/HView.cpp:273–307  ·  view source on GitHub ↗

Creates a viewer object of the specified type Parameters: view_mode - mine,terrain,or room. See constants in 3dedit.h pos - initial position of this object roomnum - initial room/terrain cell of this object Returns: object number of the object created, or -1 if at max number of viewers of that type

Source from the content-addressed store, hash-verified

271// roomnum - initial room/terrain cell of this object
272// Returns: object number of the object created, or -1 if at max number of viewers of that type
273int CreateViewerObject(int view_mode, vector *pos, int roomnum) {
274 int id;
275 object *objp;
276 int objnum = -1;
277
278 if (view_mode == VM_ROOM) {
279 id = ROOM_VIEWER_ID;
280
281 for (objnum = 0, objp = Objects; objnum <= Highest_object_index; objnum++, objp++)
282 if ((objp->type == OBJ_VIEWER) && (objp->id == id))
283 return -1; // this one already used
284 } else {
285 // for each id, loop through all objects to see if it's used
286 for (id = 0; id < MAX_VIEWERS; id++) {
287 for (objnum = 0, objp = Objects; objnum <= Highest_object_index; objnum++, objp++)
288 if ((objp->type == OBJ_VIEWER) && (objp->id == id))
289 break; // this one already used
290 if (objnum > Highest_object_index) // didn't find objec twith this id
291 break;
292 }
293
294 if (id == MAX_VIEWERS) // no unused viewer id's
295 return -1;
296 }
297
298 // Create the new object
299 objnum = ObjCreate(OBJ_VIEWER, id, roomnum, pos, NULL);
300
301 if (objnum == -1) {
302 Int3();
303 return -1;
304 }
305
306 return objnum;
307}
308
309// Returns the number (not the id) of the current viewer, in the range 0..MAX_VIEWERS
310int GetViewerNum() {

Callers 2

CreateNewViewerFunction · 0.85
SetEditorViewerFunction · 0.85

Calls 1

ObjCreateFunction · 0.85

Tested by

no test coverage detected