Initializes a new object. All fields not passed in set to defaults. Returns 1 if ok, 0 if error
| 1167 | // Initializes a new object. All fields not passed in set to defaults. |
| 1168 | // Returns 1 if ok, 0 if error |
| 1169 | int ObjInit(object *objp, int type, int id, int handle, vector *pos, float creation_time, int parent_handle) { |
| 1170 | // Zero out object structure to keep weird bugs from happening in uninitialized fields. |
| 1171 | // I hate doing this because it seems sloppy, but it's probably better to do it |
| 1172 | memset(objp, 0, sizeof(object)); |
| 1173 | // Set the stuff that's passed in |
| 1174 | objp->type = type; |
| 1175 | objp->id = id; |
| 1176 | objp->handle = handle; |
| 1177 | objp->pos = objp->last_pos = *pos; |
| 1178 | objp->parent_handle = parent_handle; |
| 1179 | objp->creation_time = creation_time; |
| 1180 | objp->osiris_script = NULL; |
| 1181 | // Initialize some general stuff |
| 1182 | objp->roomnum = -1; |
| 1183 | objp->orient = Identity_matrix; |
| 1184 | objp->next = objp->prev = -1; |
| 1185 | objp->dummy_type = OBJ_NONE; |
| 1186 | objp->flags = 0; |
| 1187 | objp->size = 0; |
| 1188 | objp->change_flags = 0; |
| 1189 | objp->generic_nonvis_flags = 0; |
| 1190 | objp->generic_sent_nonvis = 0; |
| 1191 | objp->name = NULL; |
| 1192 | objp->custom_default_script_name = NULL; |
| 1193 | objp->custom_default_module_name = NULL; |
| 1194 | objp->contains_type = -1; |
| 1195 | objp->lifeleft = 0; |
| 1196 | objp->effect_info = NULL; |
| 1197 | objp->ai_info = NULL; |
| 1198 | objp->dynamic_wb = NULL; |
| 1199 | objp->attach_children = NULL; |
| 1200 | // Now initialize the type-specific data |
| 1201 | return ObjInitTypeSpecific(objp, 0); |
| 1202 | } |
| 1203 | // Re-copies data to each object from the appropriate page for that object type. |
| 1204 | // Called after an object page has changed. |
| 1205 | void ObjReInitAll() { |
no test coverage detected