From da8e5459d659bca77c4053801e058de98ff86a5e Mon Sep 17 00:00:00 2001 From: Kp Date: Sun, 12 Jan 2014 19:14:16 +0000 Subject: [PATCH] Return objptridx_t from obj_create_copy --- common/main/object.h | 2 +- similar/main/object.cpp | 17 ++++++----------- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/common/main/object.h b/common/main/object.h index 67ebebbc4..ffae8f671 100644 --- a/common/main/object.h +++ b/common/main/object.h @@ -663,7 +663,7 @@ objptridx_t obj_create(enum object_type_t type, ubyte id, int segnum, const vms_ ubyte ctype, ubyte mtype, ubyte rtype); // make a copy of an object. returs num of new object -int obj_create_copy(int objnum, vms_vector *new_pos, int newsegnum); +objptridx_t obj_create_copy(int objnum, vms_vector *new_pos, int newsegnum); // remove object from the world void obj_delete(objptridx_t objnum); diff --git a/similar/main/object.cpp b/similar/main/object.cpp index 7425cccb3..bdcdb8f55 100644 --- a/similar/main/object.cpp +++ b/similar/main/object.cpp @@ -1224,18 +1224,13 @@ objptridx_t obj_create(enum object_type_t type, ubyte id,int segnum,const vms_ve #ifdef EDITOR //create a copy of an object. returns new object number -int obj_create_copy(int objnum, vms_vector *new_pos, int newsegnum) +objptridx_t obj_create_copy(int objnum, vms_vector *new_pos, int newsegnum) { - int newobjnum; - object *obj; - // Find next free object - newobjnum = obj_allocate(); + objptridx_t obj = obj_allocate(); - if (newobjnum == object_none) - return newobjnum; - - obj = &Objects[newobjnum]; + if (obj == object_none) + return obj; *obj = Objects[objnum]; @@ -1244,13 +1239,13 @@ int obj_create_copy(int objnum, vms_vector *new_pos, int newsegnum) obj->next = obj->prev = object_none; obj->segnum = segment_none; - obj_link(newobjnum,newsegnum); + obj_link(obj,newsegnum); obj->signature = obj_get_signature(); //we probably should initialize sub-structures here - return newobjnum; + return obj; } #endif