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 t

⟦dd9851d74⟧ TextFile

    Length: 9649 (0x25b1)
    Types: TextFile
    Names: »tk.c«

Derivation

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

TextFile

/*
 *		AberMUD II   C
 *	This game systems, its code scenario and design
 *	are (C) 1987/88  Alan Cox,Jim Finnis,Richard Acott
 *
 *	This file holds the basic communications routines
 */
#include "kernel.h"
#ifdef	RCSID
static char RCS[] =
	"$Header: tk.c,v 1.1 89/03/13 09:37:53 rsalz Exp $";
#endif	/* RCSID */


static void
vcpy(dest, source, len)
    register int	*dest;
    register int	*source;
    register int	 len;
{
    while (--len >= 0)
	*dest++ = *source++;
}

mstoout(block)
    int *block;
{
    /* Print appropriate stuff from data block */
    if (debug_mode)
	bprintf("\n<%d>", block[1]);
    if (block[1] < -3)
	gamrcv(block);
    else
	bprintf("%s", (char *)&block[2]);
}


sendamsg(name)
    char *name;
{
    char prmpt[32];
    char work[200];
    char w2[200];

    for ( ; ; ) {
	pbfr();
	strcpy(prmpt, "\r");
	if (pvis(mynum))
	    strcat(prmpt, "(");
	if (debug_mode)
	    strcat(prmpt, "#");
	if (aliased)
	    strcat(prmpt, "@");
	strcat(prmpt, prm_str);

	switch (convflg) {
	case 0:
	    break;
	case 1:
	    prmpt[strlen(prmpt) - 1] = 0;
	    strcat(prmpt, "\"");
	    break;
	case 2:
	    prmpt[strlen(prmpt) - 1] = 0;
	    strcat(prmpt, "*");
	    break;
	default:
	    prmpt[strlen(prmpt) - 1] = 0;
	    strcat(prmpt, "?");
	}
	if (pvis(mynum))
	    strcat(prmpt, ")");
	pbfr();

	sprintf(work, GAMENAME, name);
	sig_alon();
	key_input(prmpt, 80);
	sig_aloff();
	strcpy(work, key_buff);
	strcat(sysbuf, "\001l");
	strcat(sysbuf, work);
	strcat(sysbuf, "\n\001");
	openworld();
	rte();
	closeworld();
	if (convflg && EQ(work, "**"))
	    convflg = 0;
	else
	    break;
    }

    if (!EMPTY(work)) {
	if (work[0] == '\"') {
	    strcpy(w2, work);
	    sprintf(work, "say %s", w2 + 1);
	}
	if (!EQ(work, "*") && work[0] == '*')
	    work[0] = 32;
	else if (convflg) {
	    strcpy(w2, work);
	    if (convflg == 1)
		sprintf(work, "say %s", w2);
	    else
		sprintf(work, "tss %s", w2);
	}
    }

    if (curmode == 1)
	gamecom(work);
    else if ((!EQ(work, ".Q") && !EQ(work, ".q")) && !EMPTY(work))
	(void)special(work, name);
    if (fighting > -1) {
	if (EMPTY(pname(fighting))) {
	    in_fight = 0;
	    fighting = -1;
	    setpfighting(mynum, -1);
	}
	if (ploc(fighting) != ploc(mynum)) {
	    in_fight = 0;
	    fighting = -1;
	    setpfighting(mynum, -1);
	}
    }
    if (in_fight)
	in_fight -= 1;
    return EQ(work, ".Q") || EQ(work, ".q");
}

send2(block)
    int *block;
{
    FILE *unit;
    int number;
    int inpbk[128];

    if (spawned)
	return;
    if ((unit = openworld()) == NULL) {
	loseme();
	crapup("\nAberMUD: FILE_ACCESS : Access failed\n");
    }
    sec_read(unit, inpbk, 0, 64);
    number = 2 * inpbk[1] - inpbk[0];
    inpbk[1]++;
    sec_write(unit, block, number, 128);
    sec_write(unit, inpbk, 0, 64);
    if (number >= 199)
	cleanup(inpbk);
    if (number >= 199)
	longwthr();
}

readamsg(channel, block, num)
    FILE *channel;
    int *block;
    int num;
{
    int buff[64], actnum;

    sec_read(channel, buff, 0, 64);
    actnum = num * 2 - buff[0];
    sec_read(channel, block, actnum, 128);
}


rte()
{
    FILE *unit;
    int too, ct, block[128];

    if (spawned)
	return;
    if ((unit = openworld()) == NULL)
	crapup("AberMUD: FILE_ACCESS : Access failed\n");
    fl_com = unit;
    if (cms == -1)
	cms = findend(unit);
    too = findend(unit);
    if (cms < findstart(unit) / 2) {
	loseme();
	crapup("\nYouve been off so long that you have been disconnected\n");
    }
    for (ct = cms; ct < too; ct++) {
	readamsg(unit, block, ct);
	mstoout(block);
    }
    cms = ct;
    update();
    eorte();
    rdes = 0;
    tdes = 0;
    vdes = 0;
}

findstart(unit)
    FILE *unit;
{
    int bk[2];

    sec_read(unit, bk, 0, 1);
    return bk[0];
}

findend(unit)
    FILE *unit;
{
    int bk[3];

    sec_read(unit, bk, 0, 2);
    return bk[1];
}


talker(name)
    char *name;
{
    makebfr();
    cms = -1;
    putmeon(name);
    if (openworld() == NULL)
	crapup("Sorry AberMUD is currently unavailable");
    if (mynum == -1)
	printf("\nSorry AberMUD is full at the moment\n");
    strcpy(globme, name);
    rte();
    closeworld();
    cms = -1;
    special(".g", name);
    if (shimge[1] && my_lev < shimge[1]) {
	loseme();
	crapup("Sorry The Game Has Been Closed To You  -  Try Later");
    }
    i_setup = 1;
    while (1) {
	pbfr();
	sendamsg(name);
	if (rd_qd)
	    rte();
	rd_qd = 0;
	closeworld();
	pbfr();
    }
}


cleanup(inpbk)
    int *inpbk;
{
    int *bk;
    FILE *unit;

    unit = openworld();
    bk = NEW(int, 1280);
    sec_read(unit, bk, 101, 1280);
    sec_write(unit, bk, 1, 1280);
    sec_read(unit, bk, 121, 1280);
    sec_write(unit, bk, 21, 1280);
    sec_read(unit, bk, 141, 1280);
    sec_write(unit, bk, 41, 1280);
    sec_read(unit, bk, 161, 1280);
    sec_write(unit, bk, 61, 1280);
    sec_read(unit, bk, 181, 1280);
    sec_write(unit, bk, 81, 1280);
    free((char *)bk);
    inpbk[0] += 100;
    sec_write(unit, inpbk, 0, 64);
    revise(inpbk[0]);
}



special(string, name)
    char *string, *name;
{
    char bk[128];
    char xx[128];
    char xy[128];

    strcpy(bk, string);
    lowercase(bk);
    if (bk[0] != '.')
	return 0;
    switch (bk[1]) {
    case 'g':
	curmode = 1;
	curch = -5;
	initme();
	openworld();
	setpstr(mynum, my_str);
	setplev(mynum, my_lev);
	if (my_lev < 10)
	    setpvis(mynum, 0);
	else if (ptstflg(mynum, 9))
	    setpvis(mynum, (my_lev > 9999) ? 9999 : 10);
	setpwpn(mynum, -1);
	setpsexall(mynum, my_sex);
	setphelping(mynum, -1);
	setpscore(mynum, my_sco);
	my_sex = my_sex & 1;
	if (EQ(globme, "Fazz"))
	    strcpy(prm_str, "*----*");
	else
	    fetchprmpt(my_lev);

	sprintf(xy, "\001s%s\001%s has entered the game\n\001", name, name);
	sprintf(xx, "\001s%s\001[ %s[%s]  has entered the game ]\n\001", name, name, localname);
	sendsys(name, name, -10113, ploc(mynum), xx);
	if (my_lev > 9) {
	    if (shimge[1]) {
		bprintf("The Game is currently %s locked\n", shimge[1] > 99 ? "ARCHWIZARD" : "WIZARD");
	    }
	}
	if (shimge[0])
	    bprintf("Everything is peaceful.\n");
	rte();
	if (randperc() > 50)
	    trapch(-5);
	else {
	    curch = -183;
	    trapch(-183);
	}
	sendsys(name, name, -10000, ploc(mynum), xy);
	break;
    default:
	printf("\nUnknown . option\n");
    }
    return 1;
}


broad(mesg)
    char *mesg;
{
    char bk2[256];
    int block[128];

    strcpy(bk2, mesg);
    block[1] = -1;
    vcpy(&block[2], (int *)bk2, 126);
    rd_qd = 1;
    send2(block);
}


split(block, nam1, nam2, work, luser)
    int *block;
    char *nam1;
    char *nam2;
    char *work;
    char *luser;
{
    char q[40];
    int wkblock[128];

    vcpy(wkblock, &block[2], 126);
    vcpy((int *)work, &block[64], 64);
    GetFields((char *)(block + 2), nam1, nam2);
    strcpy(q, nam1);
    return EQ(lowercase(q), lowercase(luser));
}

trapch(chan)
    int chan;
{
    openworld();
    setploc(mynum, chan);
    lookin(chan);
}

putmeon(name)
    char *name;
{
    int ct;

    iamon = 0;
    openworld();
    while (fpbns(name) != -1) {
	if (!op(name))
	    crapup("You are already on the system...");
	strcat(name, "2");		/* In case 1 crashes */
    }
    for (ct = 0; ct < MAXUSERS; ct++)
	if (EMPTY(pname(ct)))
	    break;
    if (ct == MAXUSERS) {
	mynum = -1;
	return;
    }
    strcpy(pname(ct), name);
    setploc(ct, curch);
    setppos(ct, -1);
    setplev(ct, 1);
    setpvis(ct, 0);
    setpstr(ct, -1);
    setpwpn(ct, -1);
    setpsex(ct, 0);
    setpfighting(ct, -1);
    mynum = ct;
    iamon = 1;
}

loseme()
{
    char bk[128];

    if (aliased)
	return;
    if (mynum == -1)
	return;
    /* No interruptions while you are busy dying */
    sig_aloff();
    iamon = 0;
    /* THIS BIT IS A CRITICAL SECTION - A USER TOTALLY CRASHING HERE WILL
     * GET STUCK ON THE USERLIST FOR ABOUT 2 MINUTES OR SO */
    i_setup = 0;
    strcpy(bk, pname(mynum));
    lowercase(bk);
    openworld();
    if (EQ(lowercase(globme), bk)) {
	dumpitems();
	if (plev(mynum) > 9 && shimge[1])
	    bprintf("\nDon't forget the game is locked....\n");
	if (pvis(mynum) < 10000) {
	    sprintf(bk, "[%s has departed from AberMUD II]\n", pname(mynum));
	    if (!EMPTY(pname(mynum)))
		sendsys(pname(mynum), pname(mynum), -10113, 0, bk);
	}
	setpfighting(mynum, -1);
	if (!zapped)
	    saveme();
	pname(mynum)[0] = 0;
    }
    chksnp();
    /* We rely on world locking to assure noone nicks our place when we
     * leave before we save */
    closeworld();
}

update()
{
    int xp;

    if ((xp = cms - lasup) < 0)
	xp = -xp;
    if (xp >= 10) {
	(void)openworld();
	setppos(mynum, cms);
	lasup = cms;
    }
}

revise(cutoff)
    int cutoff;
{
    char mess[128];
    int ct;

    (void)openworld();
    for (ct = 0; ct < 16; ct++) {
	if (pname(ct)[0] && ppos(ct) < cutoff / 2 && ppos(ct) != -2) {
	    sprintf(mess, "%s%s", pname(ct), " has been timed out\n");
	    broad(mess);
	    dumpstuff(ct, ploc(ct));
	    pname(ct)[0] = 0;
	}
    }
}

lookin(room)
    int room;				/* Lords ???? */
{
    brmode = (ptstflg(mynum, 8)) ? 1 : 0;
    if (ail_blind) {
	bprintf("You are blind... you can't see a thing!\n");
	onlook();
    }
    else {
	if (plev(mynum) > 9)
	    showname(room);
	if (isdark()) {
	    bprintf("It is dark\n");
	    onlook();
	    return;
	}
	bprintf("%s\n", sdesc(ploc(mynum)));
    }

    if (*ldesc(ploc(mynum)) == '#') {
	if (plev(mynum) < 10) {
	    bprintf("%s\n", ldesc(ploc(mynum)) + 1);
	    loseme();
	    crapup("You seem to have died....");
	}
	else
	    bprintf("[DEATH ROOM]\n");
    }
    if (!brmode && !ail_blind)
	bprintf("%s", ldesc(ploc(mynum)));
    if (!ail_blind) {
	lisobs();
	if (curmode == 1)
	    lispeople();
    }
    bprintf("\n");
    onlook();
}