void CHSInterface::SetObjectName(HS_DBREF dbObject, const HS_INT8 * pcName) { #ifdef PENNMUSH // No change in code between versions set_name(dbObject, pcName); #endif #if defined(TM3) || defined(MUX) s_Name(dbObject, (char *) pcName); #endif }
// 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; }
dbref db_read(FILE * f, int *db_format, int *db_version, int *db_flags) { dbref i, anum; char ch; const char *tstr; int header_gotten, size_gotten, nextattr_gotten; int read_attribs, read_name, read_zone, read_link, read_key, read_parent; int read_extflags, read_3flags, read_money, read_timestamps, read_new_strings; int read_powers, read_powers_player, read_powers_any; int deduce_version, deduce_name, deduce_zone, deduce_timestamps; int aflags, f1, f2, f3; BOOLEXP *tempbool; header_gotten = 0; size_gotten = 0; nextattr_gotten = 0; g_format = F_UNKNOWN; g_version = 0; g_flags = 0; read_attribs = 1; read_name = 1; read_zone = 0; read_link = 0; read_key = 1; read_parent = 0; read_money = 1; read_extflags = 0; read_3flags = 0; read_timestamps = 0; read_new_strings = 0; read_powers = 0; read_powers_player = 0; read_powers_any = 0; deduce_version = 1; deduce_zone = 1; deduce_name = 1; deduce_timestamps = 1; db_free(); for(i = 0;; i++) { switch (ch = getc(f)) { case '-': /* Misc tag */ switch (ch = getc(f)) { case 'R': /* Record number of players */ mudstate.record_players = getref(f); break; default: (void) getstring_noalloc(f, 0); } break; case '+': /* * MUX and MUSH header */ switch (ch = getc(f)) { /* * 2nd char selects * type */ case 'X': /* * MUX VERSION */ if(header_gotten) { fprintf(stderr, "\nDuplicate MUX version header entry at object %d, ignored.\n", i); tstr = getstring_noalloc(f, 0); break; } header_gotten = 1; deduce_version = 0; g_format = F_MUX; g_version = getref(f); /* * Otherwise extract feature flags */ if(g_version & V_GDBM) { read_attribs = 0; read_name = !(g_version & V_ATRNAME); } read_zone = (g_version & V_ZONE); read_link = (g_version & V_LINK); read_key = !(g_version & V_ATRKEY); read_parent = (g_version & V_PARENT); read_money = !(g_version & V_ATRMONEY); read_extflags = (g_version & V_XFLAGS); read_3flags = (g_version & V_3FLAGS); read_powers = (g_version & V_POWERS); read_new_strings = (g_version & V_QUOTED); g_flags = g_version & ~V_MASK; g_version &= V_MASK; deduce_name = 0; deduce_version = 0; deduce_zone = 0; break; case 'S': /* * SIZE */ if(size_gotten) { fprintf(stderr, "\nDuplicate size entry at object %d, ignored.\n", i); tstr = getstring_noalloc(f, 0); } else { mudstate.min_size = getref(f); } size_gotten = 1; break; case 'A': /* * USER-NAMED ATTRIBUTE */ anum = getref(f); tstr = getstring_noalloc(f, read_new_strings); if(isdigit(*tstr)) { aflags = 0; while (isdigit(*tstr)) aflags = (aflags * 10) + (*tstr++ - '0'); tstr++; /* * skip ':' */ } else { aflags = mudconf.vattr_flags; } vattr_define((char *) tstr, anum, aflags); break; case 'F': /* * OPEN USER ATTRIBUTE SLOT */ anum = getref(f); break; case 'N': /* * NEXT ATTR TO ALLOC WHEN NO * FREELIST */ if(nextattr_gotten) { fprintf(stderr, "\nDuplicate next free vattr entry at object %d, ignored.\n", i); tstr = getstring_noalloc(f, 0); } else { mudstate.attr_next = getref(f); nextattr_gotten = 1; } break; default: fprintf(stderr, "\nUnexpected character '%c' in MUX header near object #%d, ignored.\n", ch, i); tstr = getstring_noalloc(f, 0); } break; case '!': /* * MUX entry/MUSH entry/MUSE non-zoned entry */ if(deduce_version) { g_format = F_MUX; g_version = 1; deduce_name = 0; deduce_zone = 0; deduce_version = 0; } else if(deduce_zone) { deduce_zone = 0; read_zone = 0; } i = getref(f); db_grow(i + 1); if(read_name) { tstr = getstring_noalloc(f, read_new_strings); if(deduce_name) { if(isdigit(*tstr)) { read_name = 0; s_Location(i, atoi(tstr)); } else { s_Name(i, (char *) tstr); s_Location(i, getref(f)); } deduce_name = 0; } else { s_Name(i, (char *) tstr); s_Location(i, getref(f)); } } else { s_Location(i, getref(f)); } /* * ZONE on MUSE databases and some others */ if(read_zone) s_Zone(i, getref(f)); /* * else * * s_Zone(i, NOTHING); */ /* * CONTENTS and EXITS */ s_Contents(i, getref(f)); s_Exits(i, getref(f)); /* * LINK */ if(read_link) s_Link(i, getref(f)); else s_Link(i, NOTHING); /* * NEXT */ s_Next(i, getref(f)); /* * LOCK */ if(read_key) { tempbool = getboolexp(f); atr_add_raw(i, A_LOCK, unparse_boolexp_quiet(1, tempbool)); free_boolexp(tempbool); } /* * OWNER */ s_Owner(i, getref(f)); /* * PARENT: PennMUSH uses this field for ZONE * (which we use as PARENT if we * didn't already read in a * non-NOTHING parent. */ if(read_parent) { s_Parent(i, getref(f)); } else { s_Parent(i, NOTHING); } /* * PENNIES */ if(read_money) /* * if not fix in * unscraw_foreign */ s_Pennies(i, getref(f)); /* * FLAGS */ f1 = getref(f); if(read_extflags) f2 = getref(f); else f2 = 0; if(read_3flags) f3 = getref(f); else f3 = 0; s_Flags(i, f1); s_Flags2(i, f2); s_Flags3(i, f3); if(read_powers) { f1 = getref(f); f2 = getref(f); s_Powers(i, f1); s_Powers2(i, f2); } /* * ATTRIBUTES */ if(read_attribs) { if(!get_list(f, i, read_new_strings)) { fprintf(stderr, "\nError reading attrs for object #%d\n", i); return -1; } } /* * check to see if it's a player */ if(Typeof(i) == TYPE_PLAYER) { c_Connected(i); } break; case '*': /* * EOF marker */ tstr = getstring_noalloc(f, 0); if(strcmp(tstr, "**END OF DUMP***")) { fprintf(stderr, "\nBad EOF marker at object #%d\n", i); return -1; } else { /* * Fix up bizarro foreign DBs */ *db_version = g_version; *db_format = g_format; *db_flags = g_flags; load_player_names(); return mudstate.db_top; } default: fprintf(stderr, "\nIllegal character '%c' near object #%d\n", ch, i); return -1; } } }