Example #1
0
static void
restore_time()
{
	get_tm(&g_tm, NULL);
	if (tflag_isset(0))
	{
		restore_year();
	}

	if (tflag_isset(1))
	{
		restore_mon();
	}

	if (tflag_isset(2))
	{
		restore_mday();
	}

	if (tflag_isset(3))
	{
		restore_hour();
	}

	if (tflag_isset(4))
	{
		restore_min();
	}

	if (tflag_isset(5))
	{
		restore_sec();
	}
}
Example #2
0
struct obj *restore_obj(struct memfile *mf)
{
    unsigned int oflags;
    char namelen;
    struct obj *otmp;
    
    mfmagic_check(mf, OBJ_MAGIC);
    
    namelen = mread32(mf);
    otmp = newobj(namelen);
    memset(otmp, 0, namelen + sizeof(struct obj));
    
    otmp->o_id = mread32(mf);
    otmp->owt = mread32(mf);
    otmp->quan = mread32(mf);
    otmp->corpsenm = mread32(mf);
    otmp->oeaten = mread32(mf);
    otmp->age = mread32(mf);
    otmp->owornmask = mread32(mf);
    oflags = mread32(mf);
    
    otmp->otyp = mread16(mf);
    
    otmp->ox = mread8(mf);
    otmp->oy = mread8(mf);
    otmp->spe = mread8(mf);
    otmp->oclass = mread8(mf);
    otmp->invlet = mread8(mf);
    otmp->oartifact = mread8(mf);
    otmp->where = mread8(mf);
    otmp->timed = mread8(mf);
    otmp->cobj = mread8(mf) ? (void*)1 : NULL; /* set the pointer to 1 if there will be contents */
    otmp->onamelth = namelen;
    
    otmp->cursed	= (oflags >> 31) & 1;
    otmp->blessed	= (oflags >> 30) & 1;
    otmp->unpaid	= (oflags >> 29) & 1;
    otmp->no_charge	= (oflags >> 28) & 1;
    otmp->known 	= (oflags >> 27) & 1;
    otmp->dknown	= (oflags >> 26) & 1;
    otmp->bknown	= (oflags >> 25) & 1;
    otmp->rknown	= (oflags >> 24) & 1;
    otmp->oeroded	= (oflags >> 22) & 3;
    otmp->oeroded2	= (oflags >> 20) & 3;
    otmp->oerodeproof	= (oflags >> 19) & 1;
    otmp->olocked	= (oflags >> 18) & 1;
    otmp->obroken	= (oflags >> 17) & 1;
    otmp->otrapped	= (oflags >> 16) & 1;
    otmp->recharged	= (oflags >> 13) & 7;
    otmp->lamplit	= (oflags >> 12) & 1;
    otmp->greased	= (oflags >> 11) & 1;
    otmp->oattached	= (oflags >>  9) & 3;
    otmp->in_use	= (oflags >>  8) & 1;
    otmp->was_thrown	= (oflags >>  7) & 1;
    otmp->bypass	= (oflags >>  6) & 1;
    
    if (otmp->onamelth)
	mread(mf, ONAME(otmp), otmp->onamelth);
    
    if (otmp->oattached == OATTACHED_MONST) {
	struct monst *mtmp = restore_mon(mf);
	int monlen = sizeof(struct monst) + mtmp->mnamelth + mtmp->mxlth;
	otmp = realloc_obj(otmp, monlen, mtmp, otmp->onamelth, ONAME(otmp));
	dealloc_monst(mtmp);
    } else if (otmp->oattached == OATTACHED_M_ID) {
	unsigned int mid = mread32(mf);
	otmp = obj_attach_mid(otmp, mid);
    }
    
    return otmp;
}