bool dock_check_docked_one_on_one(object *objp) { // we must be docked if (!object_is_docked(objp)) return false; // our dock list must contain only one object if (objp->dock_list->next != NULL) return false; // the other guy's dock list must contain only one object if (dock_get_first_docked_object(objp)->dock_list->next != NULL) return false; // debug check to make sure that we're docked to each other Assert(objp == dock_get_first_docked_object(objp)->dock_list->docked_objp); // success return true; }
void dock_undock_all(object *objp) { Assert(objp != NULL); while (object_is_docked(objp)) { object* dockee = dock_get_first_docked_object(objp); dock_undock_objects(objp, dockee); } }
object *dock_get_hub(object *objp) { Assert(dock_check_assume_hub() && object_is_docked(objp)); // if our dock list contains only one object, it must be the hub if (objp->dock_list->next == NULL) { return dock_get_first_docked_object(objp); } // otherwise we are the hub else { return objp; } }