/* Clone an object. The new object is owned by the cloning player */ static dbref clone_object(dbref player, dbref thing, const char *newname, int preserve) { dbref clone; clone = new_object(); /* Need to figure out why this is here. */ memcpy(REFDB(clone), REFDB(thing), sizeof(struct object)); Owner(clone) = Owner(player); Name(clone) = NULL; if (newname && *newname) set_name(clone, newname); else set_name(clone, Name(thing)); s_Pennies(clone, Pennies(thing)); AttrCount(clone) = 0; atr_cpy(clone, thing); Locks(clone) = NULL; clone_locks(player, thing, clone); Zone(clone) = Zone(thing); Parent(clone) = Parent(thing); Flags(clone) = clone_flag_bitmask("FLAG", Flags(thing)); if (!preserve) { clear_flag_internal(clone, "WIZARD"); clear_flag_internal(clone, "ROYALTY"); Warnings(clone) = 0; /* zap warnings */ Powers(clone) = new_flag_bitmask("POWER"); /* zap powers */ } else { Powers(clone) = clone_flag_bitmask("POWER", Powers(thing)); if (Wizard(clone) || Royalty(clone) || Warnings(clone) || !null_flagmask("POWER", Powers(clone))) notify(player, T ("Warning: @CLONE/PRESERVE on an object with WIZ, ROY, @powers, or @warnings.")); } /* We give the clone the same modification time that its * other clone has, but update the creation time */ CreTime(clone) = mudtime; Contents(clone) = Location(clone) = Next(clone) = NOTHING; queue_event(player, "OBJECT`CREATE", "%s,%s", unparse_objid(clone), unparse_objid(thing)); return clone; }
// Clones an object and returns the HS_DBREF of the new clone. HS_DBREF CHSInterface::CloneThing(HS_DBREF model) { HS_DBREF clone; #ifdef PENNMUSH // No change in code between versions clone = new_object(); // Copy the basic information from the model to the clone. memcpy(REFDB(clone), REFDB(model), sizeof(struct object)); Owner(clone) = Owner(model); Name(clone) = NULL; // NULL-out some memory pointers we didn't really want copied. db[clone].list = NULL; // Now copy the pointer information. atr_cpy(clone, model); Locks(clone) = NULL; clone_locks(model, model, clone); Zone(clone) = Zone(model); Parent(clone) = Parent(model); Flags(clone) = clone_flag_bitmask("FLAG", Flags(model)); set_name(clone, Name(model)); s_Pennies(clone, Pennies(model)); #ifdef CREATION_TIMES /* * We give the clone the same modification time that its * other clone has, but update the creation time */ db[clone].creation_time = time((time_t *) 0); #endif db[clone].contents = db[clone].location = db[clone].next = NOTHING; #endif #if defined(TM3) || defined(MUX) clone = create_obj(Owner(model), Typeof(model), Name(model), Pennies(model)); //atr_free(clone); s_Name(clone, Name(model)); s_Pennies(clone, Pennies(model)); s_Parent(clone, Parent(model)); #ifdef TM3 atr_cpy(Owner(clone), clone, model); s_Flags(clone, Flags(model)); s_Flags2(clone, Flags2(model)); s_Flags3(clone, Flags3(model)); #endif #ifdef MUX atr_cpy(clone, model); s_Flags(clone, FLAG_WORD1, Flags(model)); s_Flags(clone, FLAG_WORD2, Flags2(model)); s_Flags(clone, FLAG_WORD3, Flags3(model)); s_Home(clone, Home(model)); #endif #endif return clone; }