DataMuseum.dk

Presents historical artifacts from the history of:

DKUUG/EUUG Conference tapes

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about DKUUG/EUUG Conference tapes

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - metrics - download
Index: T s

⟦1936147e0⟧ TextFile

    Length: 5775 (0x168f)
    Types: TextFile
    Names: »support.c«

Derivation

└─⟦b20c6495f⟧ Bits:30007238 EUUGD18: Wien-båndet, efterår 1987
    └─⟦this⟧ »EUUGD18/General/Abermud/support.c« 

TextFile

/*
 * Some more basic functions
 * Note that state(obj) setobjstate(obj,val) destroy(obj)
 * are elsewhere
 *Pflags
 *	0 sex
 *	1 May not be exorcised ok
 *	2 May change pflags ok
 *	3 May use rmedit ok
 *	4 May use debugmode ok
 *	5 May use patch
 *	6 May be snooped upon
 *	7 Always Log This User
 *	8 Brief
 *	9 Invis start
*/
#include "kernel.h"
#ifdef	RCSID
static char RCS[] =
	"$Header: support.c,v 1.1 89/03/13 09:37:48 rsalz Exp $";
#endif	/* RCSID */


#define CHAR1	0x00FF
#define CHAR2	0xFF00


/* VARARGS2 */
mudlog(args, arg1, arg2)
    char *args, *arg1, *arg2;
{
    time_t tm;
    FILE *x;
    char *z;

    time(&tm);
    z = ctime(&tm);
    *strchr(z, '\n') = 0;
    if ((x = openlock(LOG_FILE, "a")) == NULL) {
	loseme();
	crapup("Log fault : Access Failure");
    }
    fprintf(x, "%s:  ", z);
    fprintf(x, args, arg1, arg2);
    fprintf(x, "\n");
    closelock(x);
}

byte_put(x, y, z)
    int *x, y, z;
{
    if (y == 1) {
	*x &= ~CHAR1;
	*x |= z;
    }
    else {
	*x &= ~CHAR2;
	*x |= ((z << 8) & CHAR2);
    }
}

byte_fetch(x, y)
    int x, y;
{
    return (y == 1 ? x : x >> 8) & CHAR1;
}

bit_fetch(x, y)
    int x, y;
{
    return (x >> (16 + y)) & 1;
}

bit_set(x, y)
    int *x, y;
{
    *x |= (1 << (16 + y));
}

bit_clear(x, y)
    int *x, y;
{
    *x &= ~(1 << (16 + y));
}

setoloc(ob, l, c)
    int ob, l, c;
{
    /* MINE LADDERS SPECIAL CASE */
    if (c == 0) {
	if (l == -1116 || l == -1117 || l == -1119 || l == -1120
	 || l == -1121 || l == -1122) {
	    l = -1124;
	    bprintf("The %s falls down the ladder\n", oname(ob));
	}
	if (l == -579 || l == -580 || l == -581) {
	    l = -563;
	    bprintf("The %s falls down the airshaft\n");
	}
	if (l >= -999 && l <= -900 && ob != 202)
	    l = -906;
    }
    objinfo[4 * ob] = l;
    objinfo[4 * ob + 3] = c;
}

ohany(mask)
    int mask;
{
    int a;

    for (mask <<= 16, a = 0; a < numobs; a++)
	if ((iscarrby(a, mynum) || ishere(a)) && (objinfo[4 * a + 2] & mask))
	    return 1;
    return 0;
}

setpsex(chr, v)
    int chr, v;
{
    if (v)
	psetflg(chr, 0);
    else
	pclrflg(chr, 0);
}

ptothlp(pl)
    int pl;
{
    int ct;
    
    for (ct = 0; ct < MAXUSERS; ct++) {
	if (ploc(ct) != ploc(pl) || phelping(ct) != pl)
	    continue;
	return ct;
    }
    return -1;
}

ptstflg(ch, x)
    int ch;
    int x;
{
    if ((x == 2 || x == 15) && op(globme))
	return 1 << x;
    return ublock[16 * ch + 9] & (1 << x);
}


int 
willhold(x, y)
    int x, y;
{
    int a;
    int b;

    for (a = 0, b = 0; a < numobs; a++)
	if (iscontin(a, x))
	    b += osize(a);
    b += osize(y);
    return b > osize(x) ? 0 : 1;
}


setpfighting(x, y)
    int x, y;
{
    int ct;

    ublock[16 * x + 14] = y;
    if (y == -1) {
	for (ct = 0; ct < 64; ct++)
	    if (pfighting(ct) == x)
		ublock[16 * ct + 14] = -1;
    }
    else
	ublock[16 * y + 14] = x;
}


/* Can't be macros because of multiple evaluations... */

otstmask(ob, v)
    int ob;
    int v;
{
    v <<= 16;
    return (objinfo[4 * ob + 2] & v) == v;
}

isavl(ob)
    int ob;
{
    return ishere(ob) ? 1 : iscarrby(ob, mynum);
}

ospare(ob)
    int ob;
{
    return otstbit(ob, 0) ? -1 : 0;
}

/* Too ugly to be a macro. */
char *
pname(chr)
    int chr;
{
    return (char *)&ublock[16 * chr];
}

#ifndef	USE_MACROS

ocarrf(ob)
    int ob;
{
    return objinfo[4 * ob + 3];
}

oloc(ob)
    int ob;
{
    return objinfo[4 * ob];
}


ploc(chr)
    int chr;
{
    return ublock[16 * chr + 4];
}

plev(chr)
    int chr;
{
    return ublock[16 * chr + 10];
}

setplev(chr, v)
    int chr, v;
{
    ublock[16 * chr + 10] = v;
}

pstr(chr)
    int chr;
{
    return ublock[16 * chr + 7];
}

setpstr(chr, v)
    int chr, v;
{
    ublock[16 * chr + 7] = v;
}

pvis(chr)
    int chr;
{
    return ublock[16 * chr + 8];
}

setpvis(chr, v)
    int chr, v;
{
    ublock[16 * chr + 8] = v;
}

psex(chr)
    int chr;
{
    return ublock[16 * chr + 9] & 1;
}

setpsexall(chr, v)
    int chr;
    int v;
{
    ublock[16 * chr + 9] = v;
}

psexall(chr)
    int chr;
{
    return ublock[16 * chr + 9];
}

char *
oname(ob)
    int ob;
{
    return objects[ob].o_name;
}

char *
olongt(ob, st)
    int ob, st;
{
    return objects[ob].o_desc[st];
}


omaxstate(ob)
    int ob;
{
    return objects[ob].o_maxstate;
}


oflannel(ob)
    int ob;
{
    return objects[ob].o_flannel;
}

obaseval(ob)
    int ob;
{
    return objects[ob].o_value;
}

ppos(chr)
    int chr;
{
    return ublock[16 * chr + 5];
}

setppos(chr, v)
    int chr, v;
{
    ublock[16 * chr + 5] = v;
}

setploc(chr, n)
    int chr, n;
{
    ublock[16 * chr + 4] = n;
}

pwpn(chr)
    int chr;
{
    return ublock[16 * chr + 11];
}

setpwpn(chr, n)
    int chr, n;
{
    ublock[16 * chr + 11] = n;
}

osetbit(ob, x)
    int ob, x;
{
    bit_set(&objinfo[4 * ob + 2], x);
}

oclrbit(ob, x)
    int ob, x;
{
    bit_clear(&objinfo[4 * ob + 2], x);
}

otstbit(ob, x)
    int ob, x;
{
    return bit_fetch(objinfo[4 * ob + 2], x);
}

osetbyte(o, x, y)
    int o, x, y;
{
    byte_put(&objinfo[4 * o + 2], x, y);
}

obyte(o, x)
    int o, x;
{
    return byte_fetch(objinfo[4 * o + 2], x);
}

phelping(x)
    int x;
{
    return ublock[16 * x + 13];
}

setphelping(x, y)
    int x, y;
{
    ublock[16 * x + 13] = y;
}

psetflg(ch, x)
    int ch;
    int x;
{
    ublock[16 * ch + 9] |= (1 << x);
}

pclrflg(ch, x)
    int ch;
    int x;
{
    ublock[16 * ch + 9] &= ~(1 << x);
}

ptstflg(ch, x)
    int ch;
    int x;
{
    return ptstflg(ch, x);
}

char *
oaltname(x)
    int x;
{
    return objects[x].o_altname;
}

osize(x)
    int x;
{
    return objects[x].o_size;
}

pfighting(x)
    int x;
{
    return ublock[16 * x + 14];
}

pscore(x)
    int x;
{
    return ublock[16 * x + 15];
}

setpscore(x, y)
    int x;
    int y;
{
    ublock[16 * x + 15] = y;
}

#endif	/* USE_MACROS */