home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Source Code 1994 March
/
Source_Code_CD-ROM_Walnut_Creek_March_1994.iso
/
compsrcs
/
games
/
vmsnet
/
ldb
/
part10
< prev
next >
Wrap
Internet Message Format
|
1993-04-07
|
49KB
Path: uunet!europa.eng.gtefsd.com!howland.reston.ans.net!usc!news.service.uci.edu!unogate!mvb.saic.com!dayton.saic.com!dayvd.dayton.saic.com!ake
From: ake@dayvd.dayton.saic.com (Earle Ake)
Newsgroups: vmsnet.sources.games
Subject: ldb - Long Distance Backgammon [10/16]
Date: 8 Apr 93 10:59:57 EST
Organization: Science Applications Intl Corp - Dayton, OH
Lines: 1168
Message-ID: <1993Apr8.105957.1@dayvd.dayton.saic.com>
NNTP-Posting-Host: dayvd.dayton.saic.com
Xref: uunet vmsnet.sources.games:671
-+-+-+-+-+-+-+-+ START OF PART 10 -+-+-+-+-+-+-+-+
X`09gtail`20=`20g->prev;`09/*`20move`20tail`20pointer`20back`20*/
X`09gtail->next`20=`20NULL;`09/*`20last`20game`20has`20no`20next`20*/
X`09`7D
Xelse`20`7B
X`09g->next->prev`20=`20g->prev;`09/*`20link`20back`20link`20around`20g`20*/
X`09g->prev->next`20=`20g->next;`09/*`20and`20forward`20link`20too`20*/
X`09`7D
Xif`20(g->gameid`20!=`20NULL)
X`09free(g->gameid);`09`09/*`20free`20string`20space`20*/
Xif`20(g->opname`20!=`20NULL)
X`09free(g->opname);
Xif`20(g->opaddr`20!=`20NULL)
X`09free(g->opaddr);
Xif`20(g->mycmt`20!=`20NULL)
X`09free(g->mycmt);
Xif`20(g->mycmt2`20!=`20NULL)
X`09free(g->mycmt2);
Xif`20(g->opcmt`20!=`20NULL)
X`09free(g->opcmt);
Xif`20(g->opcmt2`20!=`20NULL)
X`09free(g->opcmt2);
Xif`20(g->dispmsg`20!=`20NULL)
X`09free(g->dispmsg);
Xfree(g);`09`09`09/*`20free`20the`20memory`20*/
X`7D
X
X
X/*----------------------------------------------------------------------
X`20*`09findgame`20--`20find`20a`20game`20based`20on`20its`20game`20id
X`20*
X`20*`20This`20function`20performs`20a`20linear`20search`20through`20the`20game
V`20list
X`20*`20for`20a`20game`20id.`20`20It`20returns`20a`20pointer`20to`20the`20game,
V`20or`20NULL`20if
X`20*`20the`20game`20does`20not`20exist.
X`20*----------------------------------------------------------------------
X`20*/
X
Xstruct`20game`20*findgame(gid)
Xchar`20*gid;
X`7B
Xstruct`20game`20*g;
X
Xfor`20(g`20=`20ghead;`20g`20!=`20NULL;`20g`20=`20g->next)
X`09if`20(strcmp(gid,g->gameid)`20==`200)`09`09/*`20is`20this`20it?`20*/
X`09`09return(g);`09`09`09/*`20return`20it`20*/
Xreturn(NULL);`09`09`09`09`09/*`20no`20such`20game`20*/
X`7D
X
X
X/*---------------------------------------------------------------------------
X`20*`09addppl`20--`20allocate`20a`20people`20struct`20and`20link`20it`20into
V`20the`20list
X`20*
X`20*`20This`20function`20allocates`20a`20people`20structure`20and`20links`20it
V`20into`20the
X`20*`20people`20list.`20`20The`20head`20of`20this`20list`20is`20phead.
X`20*
X`20*`20NOTE:`20the`20memory-zeroing`20feature`20of`20calloc`20is`20depended
V`20on`20to
X`20*`09`20initialize`20the`20allocated`20people`20struct.
X`20*--------------------------------------------------------------------------
V-
X`20*/
X
Xstruct`20people`20*addppl()
X`7B
Xstruct`20people`20*p,`20*t;
X
Xfor`20(t`20=`20NULL,`20p`20=`20phead;`20p`20!=`20NULL;`20t`20=`20p,`20p`20=
V`20p->next);`20/*`20t`20=`20end`20of`20list`20*/
Xif`20(`20(p`20=`20(struct`20people`20*)calloc(sizeof(struct`20people),1))`20==
V`20NULL)
X`09fatal("Out`20of`20memory!");
Xif`20(t`20==`20NULL)
X`09phead`20=`20p;
Xelse
X`09t->next`20=`20p;
Xp->next`20=`20NULL;
Xreturn(p);
X`7D
X
X
X/*----------------------------------------------------------------------
X`20*`09findppl`20--`20find`20a`20people`20struct`20by`20address`20or`20alias
X`20*
X`20*`20This`20function`20performs`20a`20linear`20search`20through`20the`20peop
Vle`20list
X`20*`20searching`20for`20an`20address`20(if`20flag`20`26`20P_ADDR)`20or`20an
V`20alias`20(if`20flag`20`26`20P_ALIAS).
X`20*`20It`20returns`20a`20pointer`20to`20the`20struct,`20or`20NULL`20if`20the
V`20address`20does`20not`20exist.
X`20*----------------------------------------------------------------------
X`20*/
X
Xstruct`20people`20*findppl(a,flag)
Xchar`20*a;
Xint`20flag;
X`7B
Xint`20i;
Xstruct`20people`20*p;
X
Xif`20(a`20==`20NULL)
X`09fatal("NULL`20address`20in`20findppl");
Xrescan:
Xfor`20(p`20=`20phead;`20p`20!=`20NULL;`20p`20=`20p->next)`20`7B
X`09if`20(`20(flag`20`26`20P_ADDR)`20`26`26`20(strcmp(a,p->addr)`20==`200)`20)
V`20`7B`20`20`20/*`20check`20addr`20*/
X`09`09if`20(p->equiv`20!=`20NULL)`20`7B`09`09/*`20if`20equiv`20record,`20*/
X`09`09`09a`20=`20p->equiv;`09`09/*`20go`20look`20for`20base`20record`20*/
X`09`09`09goto`20rescan;
X`09`09`09`7D
X`09`09return(p);`09`09`09/*`20return`20it`20*/
X`09`09`7D
X`09if`20(p->equiv`20!=`20NULL)`09`09/*`20equiv`20records`20don't`20have`20alia
Vses`20*/
X`09`09continue;
X`09if`20(`20(flag`20`26`20P_ALIAS)`20`26`26`20(strcmp(a,p->alias)`20==`200)
V`20)`20/*`20check`20alias`20*/
X`09`09return(p);
X`09`7D
Xreturn(NULL);`09`09`09`09`09/*`20no`20such`20record`20*/
X`7D
X
X
X/*----------------------------------------------------------------------
X`20*`09newppl`20--`20create`20a`20new`20people`20struct`20for`20a`20game
X`20*
X`20*`20This`20function`20creates`20a`20new`20people`20record`20for`20a`20new
V`20opponent.`20`20It`20takes
X`20*`20a`20game`20structure,`20extracts`20the`20necessary`20information,`20and
V`20inserts
X`20*`20the`20new`20record`20into`20the`20people`20list,`20as`20well`20as`20sto
Vring`20a`20pointer
X`20*`20to`20the`20new`20people`20struct`20into`20the`20game's`20ppl`20pointer.
V
X`20*
X`20*`20The`20alias`20field`20is`20initialized`20to`20the`20first`20word`20of
V`20g->opname
X`20*`20with`20all`20upper`20case`20converted`20to`20lower.
X`20*
X`20*`20To`20handle`20people`20with`20more`20than`20one`20e-mail`20address,`20t
Vhe`20people`20list
X`20*`20is`20scanned`20for`20identical`20name`20fields.`20`20If`20one`20is`20fo
Vund,`20the
X`20*`20user`20is`20asked`20if`20these`20people`20are`20the`20same.`20`20If`20h
Ve`20answers`20yes,
X`20*`20the`20"equiv"`20field`20is`20set`20to`20the`20name`20of`20the`20existin
Vg`20people
X`20*`20record,`20and`20the`20rest`20of`20the`20record`20is`20zeroed`20out.
X`20*----------------------------------------------------------------------
X`20*/
X
Xstruct`20people`20*newppl(g)
Xstruct`20game`20*g;
X`7B
Xchar`20*a;
Xregister`20struct`20people`20*p,`20*q;
Xchar`20buf`5B80`5D;
X
Xif`20(g->opname`20==`20NULL)`20`7B`09/*`20return`20a`20struct,`20but`20don't
V`20put`20in`20list`20*/
X`09if`20(`20(p`20=`20(struct`20people`20*)`20calloc(sizeof(struct`20people),1)
V)`20==`20NULL)
X`09`09fatal("Out`20of`20memory!");
X`09p->addr`20=`20g->opaddr;`09/*`20this`20will`20keep`20everyone`20happy`20unt
Vil`20*/
X`09p->name`20=`20"UNKNOWN";`09/*`20we`20find`20out`20what`20his`20name`20is
V`20*/
X`09p->alias`20=`20"NONE";
X`09g->ppl`20=`20p;
X`09return(p);
X`09`7D
Xp`20=`20addppl();`09`09`09`09/*`20create`20new`20people`20struct`20*/
Xp->addr`20=`20save(g->opaddr);`09`09/*`20copy`20opponent's`20address`20*/
Xfor`20(q`20=`20phead;`20q`20!=`20NULL;`20q`20=`20q->next)`20`7B
X`09if`20(`20(q->name`20!=`20NULL)`20`26`26`20(strcmp(q->name,g->opname)`20==
V`200)`20)`20`7B
X`09`09printf("The`20following`20e-mail`20addresses:`5Cn`5Cn`5Ct%s`5Cn`5Ct%s
V`5Cn`5Cn",
X`09`09`09q->addr,g->opaddr);
X`09`09printf("have`20the`20same`20name.`20`5B%s`5D`5Cn",g->opname);
X`09`09printf("Do`20they`20refer`20to`20the`20same`20person?`20`5Bdefault=yes
V`5D`20`20");
X`09`09fgets(buf,sizeof(buf),stdin);
X`09`09if`20(`20(*buf`20==`20'n')`20`7C`7C`20(*buf`20==`20'N')`20)
X`09`09`09break;
X`09`09p->equiv`20=`20save(q->addr);
X`09`09g->ppl`20=`20q;
X`09`09return(q);
X`09`09`7D
X`09`7D
Xp->equiv`20=`20NULL;
Xp->name`20=`20save(g->opname);`09`09/*`20copy`20opponent's`20name`20*/
Xif`20(`20(a`20=`20strchr(g->opname,'`20'))`20!=`20NULL)`09/*`20create`20defaul
Vt`20alias`20*/
X`09*a`20=`20'`5C0';
Xp->alias`20=`20save(g->opname);`09`09/*`20first`20word`20of`20opponent's`20nam
Ve`20*/
Xif`20(a`20!=`20NULL)
X`09*a`20=`20'`20';
Xfor`20(a`20=`20p->alias;`20*a;`20a++)`09`09/*`20converted`20to`20lower`20case
V`20*/
X`09if`20(isupper(*a))
X`09`09*a`20=`20tolower(*a);
Xp->myaddr`20=`20save(g->myaddr);`09`09/*`20copy`20out`20my`20address`20*/
Xp->fence`20=`200L;`09`09`09`09/*`20no`20fence`20time`20yet`20*/
Xg->ppl`20=`20p;`09`09`09`09/*`20side`20pointer`20from`20game`20struct`20*/
Xreturn(p);
X`7D
X
X
X/*----------------------------------------------------------------------
X`20*`09printscore`20--`20print`20the`20cumulative`20score`20for`20each`20oppon
Vent
X`20*
X`20*`20This`20function`20scans`20the`20people`20file`20printing`20the`20conten
Vts`20of`20the
X`20*`20score`20field`20for`20each`20opponent.`20`20It`20also`20prints`20the
V`20total`20over
X`20*`20all`20opponents`20at`20the`20end.`20`20For`20the`20following:
X`20*`09points
X`20*`09games
X`20*`09matches
X`20*`09gammons
X`20*`09backgammons
X`20*`20the`20number`20won/lost/net`20is`20printed.`20`20Games`20in`20progress
V`20are`20not`20counted,
X`20*`20but`20games`20that`20have`20been`20completed`20are,`20even`20if`20they
V`20are`20part`20of
X`20*`20a`20match`20that`20has`20not`20completed.
X`20*----------------------------------------------------------------------
X`20*/
X
Xprintscore()
X`7B
Xregister`20struct`20people`20*p;
Xregister`20int`20i;
Xint`20total`5B10`5D;`09`09`09/*`20to`20store`20the`20total`20for`20all`20oppon
Vent's`20*/
X
Xif`20(phead`20==`20NULL)`09`09/*`20nothing`20to`20print`20*/
X`09return;
Xprintf("opponent`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20point
Vs`20`20`20`20`20games`20`20`20`20`20`20gammons`20`20backgammons`20`20matches
V`5Cn");
Xprintf("----------------------------------------------------------------------
V--------`5Cn");
Xfor`20(i`20=`200;`20i`20<`2010;`20i++)
X`09total`5Bi`5D`20=`200;
Xfor`20(p`20=`20phead;`20p`20!=`20NULL;`20p`20=`20p->next)`20`7B
X`09if`20(p->equiv`20!=`20NULL)
X`09`09continue;`09`09/*`20skip`20equiv`20records`20*/
X`09pscore(p->name,p->score);`09/*`20print`20this`20opponent`20*/
X`09for`20(i`20=`200;`20i`20<`2010;`20i++)`09/*`20keep`20running`20total`20*/
X`09`09total`5Bi`5D`20+=`20p->score`5Bi`5D;
X`09`7D
Xpscore("total",total);`09`09`09/*`20print`20the`20total`20*/
X`7D
X
X
X/*----------------------------------------------------------------------
X`20*`09pscore`20--`20print`20the`20score`20for`20one`20opponent
X`20*
X`20*`20This`20function`20is`20called`20by`20printscore`20to`20print`20each`20o
Vpponent.
X`20*`20The`20opponent`20name`20is`20in`20"name",`20and`20the`20score`20table
V`20is`20in`20"score".
X`20*----------------------------------------------------------------------
X`20*/
X
Xpscore(name,score)
Xchar`20*name;
Xint`20score`5B10`5D;
X`7B
Xstatic`20int`20sc_idx`5B`5D`20=`20`7B`202,`200,`204,`206,`208`20`7D;`09/*`20or
Vder`20to`20print`20p->score`5B`5D`20*/
Xregister`20int`20i,`20diff;
Xchar`20buf`5B30`5D;
Xchar`20c;
X
Xif`20(strlen(name)`20>`2025)`20`7B`09/*`20truncate`20name`20to`2025`20chars
V`20*/
X`09c`20=`20name`5B25`5D;
X`09name`5B25`5D`20=`20'`5C0';
X`09`7D
Xelse
X`09c`20=`20'`5C0';
Xprintf("%-25s",name);
Xif`20(c`20!=`20'`5C0')
X`09name`5B25`5D`20=`20c;`09`09/*`20restore`20name`20*/
Xfor`20(i`20=`200;`20i`20<`205;`20i++)`20`7B
X`09sprintf(buf,"%d/%d",score`5Bsc_idx`5Bi`5D`5D,score`5Bsc_idx`5Bi`5D+1`5D);
X`09buf`5B9`5D`20=`20'`5C0';`09`09/*`20truncate`20to`209`20chars`20*/
X`09if`20(strcmp(buf,"0/0")`20==`200)`09/*`20none`20won`20or`20lost`20*/
X`09`09*buf`20=`20'`5C0';`09`09/*`20just`20leave`20it`20blank`20*/
X`09printf("`20`20%-9s",buf);`09/*`20print`20with`20field`20width`20of`209`20*/
V
X`09`7D
Xprintf("`5Cn%21s","");
Xfor`20(i`20=`200;`20i`20<`205;`20i++)`20`7B
X`09diff`20=`20score`5Bsc_idx`5Bi`5D`5D`20-`20score`5Bsc_idx`5Bi`5D+1`5D;
X`09if`20(diff`20==`200)`20`7B
X`09`09if`20(`20(score`5Bsc_idx`5Bi`5D`5D`20==`200)`20`26`26`20(score`5Bsc_idx
V`5Bi`5D+1`5D`20==`200)`20)
X`09`09`09printf("`20`20`20`20`20`20`20`20`20`20`20");
X`09`09else
X`09`09`09printf("`20`20`20`20`20`20even`20");
X`09`09`7D
X`09else
X`09`09printf("`20`20`20`20`20`20%+-5d",`20diff);
X`09`7D
Xprintf("`5Cn`5Cn");
X`7D
X
X
Xilose(g,term,rsflag)
Xstruct`20game`20*g;
Xint`20term;`09`09`09/*`20T_*`20*/
Xint`20rsflag;`09`09`09/*`201`20=`20restart`20game`20if`20necessary`20*/
X`7B
Xint`20bg,`20gv;
X
Xg->state`20=`20ST_GAMEOVER;
Xg->term`20=`20term;
Xbg`20=`20gvalue(g,`26gv);
Xg->mcurrent`5BWHO_OPP`5D`20+=`20gv;`09`09/*`20bump`20match`20count`20*/
Xg->ppl->score`5BSC_GAMESLOST`5D++;`09`09/*`20inc`20games`20lost`20*/
Xg->ppl->score`5BSC_PTSLOST`5D`20+=`20gv;
Xif`20(bg`20==`201)`09`09`09/*`20gammon`20*/
X`09g->ppl->score`5BSC_GMNLOST`5D++;
Xelse`20if`20(bg`20==`202)
X`09g->ppl->score`5BSC_BGLOST`5D++;
Xendgame(g,rsflag);
X`7D
X
X
Xiwin(g,term,rsflag)
Xstruct`20game`20*g;
Xint`20term;`09`09`09/*`20T_*`20*/
Xint`20rsflag;`09`09`09/*`201`20=`20restart`20game`20if`20necessary`20*/
X`7B
Xint`20bg,`20gv;
X
Xg->state`20=`20ST_GAMEOVER;
Xg->term`20=`20term;
Xbg`20=`20gvalue(g,`26gv);
Xg->mcurrent`5BWHO_ME`5D`20+=`20gv;`09`09/*`20bump`20match`20count`20*/
Xg->ppl->score`5BSC_GAMESWON`5D++;`09`09/*`20inc`20games`20lost`20*/
Xg->ppl->score`5BSC_PTSWON`5D`20+=`20gv;
Xif`20(bg`20==`201)`09`09`09/*`20gammon`20*/
X`09g->ppl->score`5BSC_GMNWON`5D++;
Xelse`20if`20(bg`20==`202)
X`09g->ppl->score`5BSC_BGWON`5D++;
Xendgame(g,rsflag);
X`7D
X
X
Xendgame(g,rsflag)
Xstruct`20game`20*g;
Xint`20rsflag;`09`09`09`09/*`201`20=`20restart`20game`20if`20necessary`20*/
X`7B
X
Xif`20(g->ppl->fence`20<`20g->starttime)`20`20`20/*`20if`20newer`20than`20fence
V`20*/
X`09g->ppl->fence`20=`20g->starttime;`09/*`20move`20up`20fence`20*/
Xif`20(rsflag`20`26`26`20(g->flags`20`26`20F_PERM)`20`26`26`20(g->mcurrent`5BWH
VO_OPP`5D`20>=`20g->mtotal)`20)`20`7B
X`09message("Restarted`20game`20with`20%s`20(%s).`5Cn",g->opname,g->opaddr);
X`09notify`20=`20NULL;
X`09startgame(g->opaddr,g->mydir,g->mycolor,g->opcolor,
X`09`20`20`20g->flags`20`26`20(F_JACOBY`7CF_CRAWFORD`7CF_PERM`7CF_EUROPE`7CF_IN
VVERT),
X`09`20`20`20g->mtotal,0);
X`09`7D
Xif`20(`20(g->notify`20!=`20NULL)`20`26`26`20(g->mcurrent`5BWHO_OPP`5D`20>=`20g
V->mtotal)`20)
X`09sendpkt(g,NOTIFY);
X`7D
$ call unpack GAME.C;1 1430388055 ""
$!
$ create 'f'
X/*`09lock.c`09`094/28/92
X`20*
X`20*`20Copyright`201992`20`20Perry`20R.`20Ross
X`20*
X`20*`20Permission`20to`20use,`20copy,`20modify,`20and`20distribute`20this`20so
Vftware`20and`20its
X`20*`20documentation`20without`20fee`20is`20hereby`20granted,`20subject`20to
V`20the`20restrictions
X`20*`20detailed`20in`20the`20README`20file,`20which`20is`20included`20here`20b
Vy`20reference.
X`20*`20Any`20other`20use`20requires`20written`20permission`20from`20the`20auth
Vor.`20`20This`20software
X`20*`20is`20distributed`20"as`20is"`20without`20any`20warranty,`20including
V`20any`20implied
X`20*`20warranties`20of`20merchantability`20or`20fitness`20for`20a`20particular
V`20purpose.
X`20*`20The`20author`20shall`20not`20be`20liable`20for`20any`20damages`20result
Ving`20from`20the
X`20*`20use`20of`20this`20software.`20`20By`20using`20this`20software,`20the
V`20user`20agrees
X`20*`20to`20these`20terms.
X`20*/
X
X#include`20"ldb.h"
X
X
X/*----------------------------------------------------------------------
X`20*`09get_lock`20--`20attempt`20to`20open`20a`20lock`20file,`20exit`20if`20it
V`20exists
X`20*
X`20*`20This`20function`20attempts`20to`20create`20a`20file`20in`20such`20a`20w
Vay`20that,
X`20*`20if`20the`20file`20exists,`20the`20create`20will`20fail.`20`20If`20the
V`20create`20succeeds,
X`20*`20we`20"own"`20the`20ldb`20lock,`20and`20have`20the`20exclusive`20right
V`20to`20access
X`20*`20the`20ldb`20data`20files`20in`20this`20directory.`20`20If`20the`20creat
Ve`20fails,
X`20*`20some`20other`20ldb`20already`20has`20the`20lock`20and`20we`20exit.
X`20*
X`20*`20This`20uses`20the`20O_EXCL`20flag`20to`20open,`20which`20as`20far`20as
V`20I`20know`20is
X`20*`20supported`20on`20all`20UNIX`20flavors.`20`20If`20it`20isn't`20on`20your
Vs:
X`20*`09a.`20Please`20mail`20me`20at`20ross@emf780.den.mmc.com`20and`20tell`20m
Ve
X`20*`09`20`20`20what`20your`20system`20is.
X`20*`09b.`20try`20replacing`20open(fn,O_...,0644)`20with`20creat(fn,0444).
X`20*----------------------------------------------------------------------
X`20*/
X
Xget_lock(fn)
Xchar`20*fn;
X`7B
Xint`20fd;
Xstruct`20stat`20s;
X
Xif`20(`20(fd`20=`20open(fn,O_WRONLY`7CO_CREAT`7CO_EXCL,0644))`20<`200)`20`7B
X`09printf("ERROR:`20Ldb`20is`20already`20running`20in`20this`20account`20--
V`20exiting.`5Cn`5Cn");
X`09printf("If`20you`20are`20sure`20no`20other`20ldb`20is`20active,`20you`20can
V`20remove`5Cn");
X`09printf("the`20lock`20with`20the`20following`20command:`5Cn`5Cn");
X#ifdef`20VMS
X`09printf("`5Ct$`20delete`20sys$login:%s;*`5Cn",fn);
X#else
X`09if`20(*fn`20==`20'/')
X`09`09printf("`5Ct$`20rm`20%s`5Cn",fn);
X`09else
X`09`09printf("`5Ct$`20rm`20$HOME/%s`5Cn",fn);
X#endif
X`09printf(
X`09"`5CnPlease`20be`20certain`20no`20other`20ldb`20is`20running`20before`20doi
Vng`20this.`5Cn`5Cn");
X`09if`20(stat(fn,`26s)`20>=`200)
X`09`09printf("The`20lock`20file`20was`20created`20%s`5Cn",ctime(`26s.st_ctime)
V);
X`09exit(STAT_ABORT);`09/*`20DON'T`20call`20ldbexit,`20it`20calls`20release_loc
Vk`20*/
X`09`7D
Xclose(fd);`09`09/*`20success,`20close`20the`20file`20and`20return`20*/
X`7D
$ call unpack LOCK.C;1 1409310034 ""
$!
$ create 'f'
X/*`09main.c`09`098/3/91
X`20*
X`20*`20Copyright`201991`20`20Perry`20R.`20Ross
X`20*
X`20*`20Permission`20to`20use,`20copy,`20modify,`20and`20distribute`20this`20so
Vftware`20and`20its
X`20*`20documentation`20without`20fee`20is`20hereby`20granted,`20subject`20to
V`20the`20restrictions
X`20*`20detailed`20in`20the`20README`20file,`20which`20is`20included`20here`20b
Vy`20reference.
X`20*`20Any`20other`20use`20requires`20written`20permission`20from`20the`20auth
Vor.`20`20This`20software
X`20*`20is`20distributed`20"as`20is"`20without`20any`20warranty,`20including
V`20any`20implied
X`20*`20warranties`20of`20merchantability`20or`20fitness`20for`20a`20particular
V`20purpose.
X`20*`20The`20author`20shall`20not`20be`20liable`20for`20any`20damages`20result
Ving`20from`20the
X`20*`20use`20of`20this`20software.`20`20By`20using`20this`20software,`20the
V`20user`20agrees
X`20*`20to`20these`20terms.
X`20*/
X
X#include`20"ldb.h"
X
X/*============================================================================
V
X`20*`09ldb`20--`09Long`20Distance`20Backgammon
X`20*
X`20*`20The`20following`20arguments`20are`20recognized:
X`20*`09-read`09`09Mail`20is`20read,`20and`20the`20games`20are`20updated`20and
V`20saved.
X`20*`09`09`09The`20user`20is`20not`20prompted`20for`20his`20moves.
X`20*`09-play`09`09Any`20games`20that`20are`20waiting`20for`20local`20input`20a
Vre
X`20*`09`09`09displayed`20for`20the`20user`20to`20process.`20`20No`20mail`20is
V`20read.
X`20*`09-color`20xy`09The`20colors`20for`20any`20games`20started`20are`20set
V`20to`20x`20and`20y.
X`20*`09`09`09The`20first`20color`20is`20played`20by`20the`20local`20user,`20an
Vd`20the
X`20*`09`09`09other`20is`20played`20by`20the`20opponent.`20`20Legal`20color
X`20*`09`09`09characters`20are`20upper`20and`20lower`20case`20letters.
X`20*`09`09`09The`20default`20is`20"-color`20rw".
X`20*`09-direction`20up/down
X`20*`09`09`09The`20direction`20of`20play`20for`20the`20local`20user`20is`20set
V
X`20*`09`09`09to`20the`20specified`20value.`20`20The`20default`20is
X`20*`09`09`09"-direction`20up".
X`20*`09-myaddr`20addr`09Override`20the`20"myaddr"`20field`20of`20.ldbrc`20for
V`20any
X`20*`09`09`09games`20started`20by`20this`20invocation`20of`20ldb.`20`20This
X`20*`09`09`09is`20effective`20only`20for`20games`20started`20by`20-start
X`20*`09`09`09and`20only`20for`20-start's`20that`20appear`20after`20the`20-myad
Vdr
X`20*`09`09`09on`20the`20command`20line.
X`20*`09-start`20user`09A`20game`20is`20started`20with`20the`20specified`20user
V.`20`20User`20may
X`20*`09`09`09be`20either`20an`20e-mail`20address`20or`20an`20alias`20for`20an
X`20*`09`09`09opponent`20that`20has`20been`20played`20previously.
X`20*`09-remotestart`20user1`20user2
X`20*`09`09`09A`20game`20is`20started`20between`20user1`20and`20user2.`20`20The
V`20local
X`20*`09`09`09host`20sends`20a`20remote`20start`20message`20to`20user1`20instru
Vcting
X`20*`09`09`09it`20to`20start`20a`20game`20with`20user2.`20`20The`20local`20hos
Vt
X`20*`09`09`09does`20not`20participate`20thereafter`20in`20the`20game.
X`20*`09`09`09For`20the`20purposes`20of`20the`20-color`20and`20-direction`20opt
Vions,
X`20*`09`09`09user1`20is`20considered`20the`20local`20user.
X`20*`09-broadcast`20file
X`20*`09`09`09A`20file`20is`20mailed`20to`20all`20opponents.`20`20This`20is`20u
Vseful
X`20*`09`09`09for`20announcing`20vacation`20absences,`20etc.
X`20*`09-help`09`09A`20summary`20of`20available`20options`20is`20printed.`20
V`20This
X`20*`09`09`09list`20may`20be`20more`20up`20to`20date`20than`20these`20comments
V.
X`20*`09-jacoby`09`09Enables`20the`20jacoby`20rule`20for`20any`20games`20subseq
Vuently
X`20*`09`09`09started.`20`20This`20rule`20states`20that`20gammons`20or`20backga
Vmmons
X`20*`09`09`09only`20count`20as`201`20when`20neither`20player`20doubled`20durin
Vg
X`20*`09`09`09the`20game.
X`20*`09-crawford`09Enables`20the`20crawford`20rule`20for`20any`20games`20subse
Vquently
X`20*`09`09`09started.`20`20This`20rule`20prevents`20doubling`20when`20either
X`20*`09`09`09player`20is`20within`201`20point`20of`20winning`20the`20match.
X`20*`09-european`09Enables`20european`20scoring`20for`20any`20subsequently
X`20*`09`09`09created`20games.`20`20This`20rule`20makes`20backgammons`20count
X`20*`09`09`09as`20double`20games,`20rather`20than`20triple.
X`20*`09-permanent`09Marks`20any`20subsequently`20created`20games`20as`20perman
Vent.
X`20*`09`09`09Permanent`20games`20will`20be`20restarted`20whenever`20they
X`20*`09`09`09end.`20`20This`20is`20for`20people`20you`20play`20all`20the`20tim
Ve.
X`20*`09`09`09Permanent`20games`20must`20be`20deleted`20via`20-control.
X`20*`09-match`20points`09Marks`20any`20subsequently`20created`20games`20as`20m
Vatches
X`20*`09`09`09that`20play`20to`20the`20specified`20number`20of`20points.
X`20*`09`09`09Games`20will`20be`20restarted`20until`20one`20player`20wins
X`20*`09`09`09this`20number`20of`20points.
X`20*`09-control`09Enters`20control`20mode.`20`20No`20games`20may`20be`20starte
Vd
X`20*`09`09`09or`20played.`20`20Each`20game`20is`20displayed,`20along`20with
X`20*`09`09`09a`20menu`20that`20allows`20various`20administrative
X`20*`09`09`09functions`20to`20be`20performed.
X`20*`09-reconstruct`20file
X`20*`09`09`09This`20option`20allows`20you`20to`20recover`20your`20.ldbdata
X`20*`09`09`09file`20even`20if`20you`20lose`20all`20copies.`20`20Simply`20have
X`20*`09`09`09all`20your`20opponents`20send`20you`20their`20.ldbdata`20files
X`20*`09`09`09and,`20one`20by`20one,`20feed`20them`20into`20ldb`20with`20the
X`20*`09`09`09-reconstruct`20option.`20`20Ldb`20will`20scan`20the`20file,
X`20*`09`09`09find`20any`20games`20that`20have`20your`20name`20as`20the
X`20*`09`09`09opponent,`20and`20rebuild`20your`20game`20data`20using`20the
X`20*`09`09`09data`20in`20that`20game.
X`20*`09-score`09`09Print`20the`20cumulative`20score`20for`20all`20your`20oppon
Vents.
X`20*
X`20*`20If`20neither`20-read`20or`20-play`20is`20given,`20the`20default`20is
V`20to`20do`20both;`20incoming`20mail
X`20*`20is`20read,`20then`20any`20games`20requiring`20the`20user's`20attention
V`20are`20displayed.
X`20*
X`20*`20Note`20that`20the`20-start`20and`20-remotestart`20options`20use`20the
V`20color`20and`20direction
X`20*`20options`20that`20have`20been`20set`20*at`20the`20time`20the`20argument
V`20is`20processed*.
X`20*`20Thus,
X`20*
X`20*`09ldb`20-start`20joe@momma`20-color`20rb
X`20*
X`20*`20will`20NOT`20use`20the`20colors`20r`20and`20b`20for`20the`20game`20with
V`20joe,`20but
X`20*
X`20*`09ldb`20-color`20rb`20-start`20joe@momma
X`20*
X`20*`20will.`20`20The`20color`20and`20direction`20arguments`20may`20be`20chang
Ved`20between`20-start
X`20*`20and`20-remotestart`20arguments.`20`20For`20example,
X`20*
X`20*`09ldb`20-color`20wr`20-direction`20down`20-start`20user1`20-direction`20u
Vp`20-start`20user2
X`20*
X`20*`20will`20start`20a`20game`20with`20user1`20with`20your`20direction`20bein
Vg`20down,`20and`20one`20with
X`20*`20user2`20with`20your`20direction`20being`20up.
X`20*
X`20*--------------------------------------------------------------------------
V--
X`20*`09`09`09`09REVISION`20HISTORY
X`20***`20Version`2001`20`20`20Rev`200`20`20`20Patch`200
X`20*`201.`09Initial`20release.`20`20Countless`20helpful`20suggestions`20from
V`20Karen`20Ward.
X`20*
X`20***`20Version`2001`20`20`20Rev`201`20`20`20Patch`200
X`20*`201.`09The`20personal`20name`20and`20e-mail`20address`20printed`20on`20th
Ve`20top`20line
X`20*`09were`20switched.`20`20It`20makes`20more`20sense`20to`20be`20playing`20a
V`20person`20rather
X`20*`09than`20an`20address.`20`20If`20the`20e-mail`20address`20is`20too`20long
V`20to`20fit`20on
X`20*`09the`20top`20line,`20it`20is`20truncated`20and`20an`20ellipsis`20is`20ad
Vded.
X`20*`202.`09Pressing`20ESC`20while`20entering`20a`20comment`20now`20returns
V`20you`20to`20the
X`20*`09previous`20menu`20and`20discards`20the`20comment.`20`20This`20allows
V`20you`20to
X`20*`09change`20your`20mind`20after`20hitting`20"Send",`20for`20example.`20
V`20Suggested
X`20*`09by`20Franc,ois`20Pinard.
X`20*`203.`09The`20checkpoint`20code`20was`20moved`20to`20sendpkt(),`20where
V`20the`20games
X`20*`09are`20saved`20before`20the`20packet`20is`20sent.`20`20This`20removes
V`20a`20window
X`20*`09where`20a`20packet`20could`20be`20sent`20but`20ldb`20could`20croak`20be
Vfore`20saving
X`20*`09the`20game.`20`20Suggested`20by`20Earle`20Ake.
X`20*`204.`09Ldb`20will`20not`20ask`20for`20the`20second`20digit`20of`20a`20poi
Vnt`20number`20when:
X`20*`09`09The`20first`20digit`20is`203`20-`209,
X`20*`09`09The`20first`20digit`20is`201`20and`20there`20is`20no`20point`20in
V`2010`20-`2019
X`20*`09`09`09that`20could`20use`20the`20selected`20roll,`20or
X`20*`09`09The`20first`20digit`20is`202`20and`20there`20is`20no`20point`20in
V`2020`20-`2024
X`20*`09`09`09that`20could`20use`20the`20selected`20roll.
X`20*`09Suggested`20by`20Earle`20Ake`20and`20Franc,ois`20Pinard.
X`20*`205.`09When`20a`20roll`20is`20selected`20and`20a`20piece`20is`20on`20the
V`20bar,`20no`20point`20is
X`20*`09prompted`20for,`20since`20moving`20off`20the`20bar`20is`20the`20only
V`20legal`20move.
X`20*`09Suggested`20by`20Franc,ois`20Pinard.
X`20*`206.`09The`20Makefile`20now`20used`20$(CC)`20instead`20of`20cc.`20`20Sugg
Vested`20by
X`20*`09Franc,ois`20Pinard.
X`20*`207.`09A`20number`20of`20patches`20to`20make`20ldb`20run`20under`20SCO
V`20Xenix`20(and`20probably
X`20*`09SCO`20UNIX`20as`20well)`20were`20sent`20by`20Dinesh`20Vichare.
X`20*`208.`09A`20bare`20bones`20rename`20function`20is`20included`20for`20those
V`20systems`20that
X`20*`09don't`20have`20one.`20`20Suggested`20by`20Franc,ois`20Pinard.
X`20*`209.`09Comments`20are`20now`20rot13'd`20before`20they`20are`20sent.`20
V`20This`20keeps
X`20*`09them`20from`20being`20read`20while`20mail`20is`20extracted.`20`20They
V`20are
X`20*`09rotated`20back`20when`20ldb`20displays`20them.`20`20This`20is`20disable
Vd`20if`20the
X`20*`09opponent`20is`20using`20the`20old`20(1.0)`20ldb`20version,`20so`201.1
V`20and`201.0
X`20*`09ldb's`20will`20still`20work`20together.`20`20The`20only`20catch`20is
V`20when`20you`20switch
X`20*`09from`201.0`20to`201.1`20with`20games`20in`20progress,`20your`20opponent
Vs`20won't`20know
X`20*`09you've`20switched`20until`20you`20send`20them`20a`20move.`20`20As`20a
V`20result,`20the
X`20*`09comment`20from`20their`20next`20message`20will`20be`20garbled.`20`20To
V`20avoid`20this,
X`20*`09do`20"ldb`20-read"`20under`201.0,`20then`20switch`20to`201.1`20to`20pla
Vy.`20`20This`20is
X`20*`09only`20necessary`20once,`20after`20that`20your`20opponent's`20will`20kn
Vow`20you
X`20*`09are`20using`201.1`20and`20the`20messages`20will`20work`20normally.
X`20*`09Suggested`20by`20Franc,ois`20Pinard.
X`20*`2010.`09Ldb`20now`20clears`20the`20screen`20before`20exiting.`20`20Keeps
V`20wandering
X`20*`09manager`20types`20from`20seeing`20the`20remnants`20of`20a`20game.
X`20*`2011.`09The`20sequence`20number`20warning`20was`20removed`20for`20leftove
Vr`20messages
X`20*`09from`20dead`20games.
X`20*`2012.`09There`20is`20now`20a`20"Press`20<return>`20to`20continue"`20befor
Ve`20the`20screen
X`20*`09is`20drawn`20if`20any`20messages`20were`20printed.`20`20This`20lets`20y
Vou`20read
X`20*`09the`20messages`20before`20the`20screen`20is`20cleared.`20`20Suggested
V`20by
X`20*`09practically`20everybody.
X`20*`2013.`09Default`20file`20names`20for`20vms`20are`20now`20ldb.rc,`20ldb.da
Vta,`20`20and`20ldb.olddata.
X`20*`09This`20keeps`20the`20ldb`20files`20together`20and`20out`20of`20the`20wa
Vy,`20since`20vms
X`20*`09doesn't`20treat`20filenames`20with`20a`20leading`20'.'`20like`20UNIX
V`20does.
X`20*`09Suggested`20by`20Earle`20Ake.
X`20*`2014.`09There`20is`20now`20a`20debug`20setting`20in`20.ldbrc.`20`20It`20i
Vs`20a`20mask,`20with`20each
X`20*`09bit`20enabling`20debug`20info`20from`20a`20different`20piece`20of`20cod
Ve.`20`20The
X`20*`09bits`20are`20defined`20as`20DB_*`20in`20ldb.h`20Suggested`20by`20Earle
V`20Ake.
X`20*`2015.`09A`20sum`20of`20all`20rolls`20is`20kept`20in`20the`20"rolls"`20and
V`20"doubles"`20fields
X`20*`09of`20the`20game`20structure.`20`20This`20counts`20the`20number`20of`20e
Vach`20type`20of
X`20*`09roll`20you`20get,`20and`20the`20number`20of`20doubles`20of`20each`20typ
Ve.
X`20*`09The`20same`20is`20true`20for`20your`20opponent's`20rolls`20and`20double
Vs`20in
X`20*`09the`20oprolls`20and`20opdoubles`20fields.`20`20Suggested`20by`20Earle
V`20Ake.
X`20*`2016.`09The`20crawford`20and`20jacoby`20rules`20are`20now`20supported.
V`20`20They`20are`20activated
X`20*`09by`20the`20-crawford`20and`20-jacoby`20command`20line`20options,`20and
V`20can`20only
X`20*`09be`20enabled`20by`20whoever`20starts`20the`20game.`20`20If`20they`20are
V`20used`20to`20start
X`20*`09a`20game`20with`20a`20version`20of`20ldb`20that`20does`20not`20support
V`20them,`20a`20message
X`20*`09is`20printed`20and`20they`20are`20disabled.
X`20*`2017.`09Ldb`20now`20allows`20a`20game`20to`20be`20declared`20"permanent",
V`20meaning`20that
X`20*`09it`20is`20automatically`20restarted`20when`20it`20is`20over.`20`20This
V`20is`20activated
X`20*`09the`20the`20-permanent`20command`20line`20option,`20and`20can`20only
V`20be`20enabled
X`20*`09by`20whoever`20starts`20the`20game.
X`20*`2018.`09Ldb`20now`20supports`20match`20play.`20`20This`20is`20activated
V`20by`20the`20-match
X`20*`09command`20line`20options,`20which`20takes`20a`20numeric`20argument`20sp
Vecifying
X`20*`09how`20many`20points`20the`20match`20plays`20to.`20`20When`20a`20game
V`20that`20is`20part`20of
X`20*`09a`20match`20ends,`20and`20the`20specified`20number`20of`20points`20has
V`20not`20been`20reached,
X`20*`09the`20game`20is`20restarted.
X`20*`2019.`09The`20"buttons"`20in`20the`20menu`20in`20fe_curses`20now`20light
V`20up`20to`20show`20the
X`20*`09item`20that`20was`20chosen.
X`20*`2020.`09Ldb`20now`20supports`20the`20"european`20rule",`20which`20states
V`20that`20backgammons
X`20*`09only`20count`20double,`20not`20triple,`20the`20game`20value.
X`20*`2021.`09Ldb`20now`20creates`20a`20lock`20file`20when`20it`20starts`20in
V`20such`20a`20way`20as`20to
X`20*`09prevent`20multiple`20ldb`20processes`20from`20running`20in`20the`20same
V`20account`20at`20the
X`20*`09same`20time.`20`20The`20lock`20code`20does`20not`20depend`20on`20any
V`20operating`20system
X`20*`09locking`20features,`20other`20than`20O_EXCL,`20and`20so`20should`20be
V`20fairly`20portable.
X`20*`2022.`09There`20is`20now`20an`20option`20in`20.ldbrc`20to`20automatically
V`20delete`20mail
X`20*`09files`20after`20they`20have`20been`20read.`20`20It`20will`20refuse`20to
V`20delete
X`20*`09files`20that`20begin`20with`20'/'`20(on`20UNIX`20only)`20to`20help`20pr
Vevent
X`20*`09catastrophic`20mistakes.`20`20This`20option`20is`20off`20by`20default,
X`20*`09and`20should`20only`20be`20used`20with`20great`20care.
X`20*`09You`20should`20also`20read`20the`20disclaimer`20at`20the`20top`20of`20t
Vhis`20(and`20all
X`20*`09other)`20files,`20where`20it`20says`20I'm`20not`20responsible.`20`20Cav
Veat`20User.
X`20*`2023.`09A`20"timeout"`20setting`20has`20been`20added`20to`20.ldbrc.`20
V`20Games`20that`20have
X`20*`09not`20been`20accessed`20for`20more`20than`20"timeout"`20days`20(default
V`207),
X`20*`09and`20are`20waiting`20on`20remote`20input,`20have`20the`20last`20packet
V`20automatically
X`20*`09resent.`20`20If`20timeout`20is`20set`20to`200,`20automatic`20resends
V`20are`20disabled.
X`20*`2024.`09A`20"keepold"`20setting`20has`20been`20added`20to`20.ldbrc.`20
V`20Games`20that`20are`20over
X`20*`09are`20retained`20in`20.ldbdata`20for`20"keepold"`20days`20(default`207)
V,`20allowing
X`20*`09time`20for`20the`20last`20move`20to`20be`20resent`20if`20necessary.`20
V`20If`20"keepold"`20is
X`20*`09set`20to`200,`20games`20are`20deleted`20as`20soon`20as`20they`20are`20o
Vver.
X`20*`2025.`09Old`20start`20packets`20are`20now`20rejected.`20`20To`20do`20this
V,`20a`20new`20file
X`20*`09called`20the`20"people"`20file`20is`20maintained.`20`20This`20file`20is
V`20organised
X`20*`09by`20opponent`20address,`20and`20stores`20the`20start`20time`20of`20the
V`20newest`20completed
X`20*`09game,`20called`20the`20"fence".`20`20Any`20start`20packets`20not`20newe
Vr`20than`20the
X`20*`09fence`20are`20discarded.`20`20The`20only`20way`20a`20legitimate`20start
V`20packet`20would`20be
X`20*`09rejected`20is`20if`20it`20were`20not`20fed`20to`20ldb`20until`20after
V`20another`20game`20with
X`20*`09the`20same`20opponent`20had`20been`20started`20and`20finished.`20`20Thi
Vs`20should`20never
X`20*`09happen,`20but`20if`20it`20did,`20all`20that`20would`20be`20required`20t
Vo`20fix`20it`20would
X`20*`09be`20to`20have`20the`20opponent`20resend`20the`20start`20packet`20via
V`20-control.
X`20*`2026.`09The`20people`20file`20also`20stores`20the`20opponent's`20name`20a
Vnd
X`20*`09an`20alias,`20or`20nickname,`20for`20the`20opponent.`20`20The`20alias
V`20is`20initialized
X`20*`09to`20the`20first`20word`20of`20the`20opponent's`20name`20with`20all`20c
Vapitals`20changed
X`20*`09to`20lower`20case.`20`20To`20change`20an`20opponent's`20alias,`20a`20te
Vxt`20editor`20may
X`20*`09be`20used`20on`20the`20people`20file.`20`20The`20-start`20command`20wil
Vl`20take`20an
X`20*`09alias`20in`20place`20of`20an`20e-mail`20address.`20`20There`20is`20no
V`20check`20for
X`20*`09duplicate`20aliases,`20and`20if`20one`20is`20used`20in`20a`20-start`20c
Vommand,`20the
X`20*`09game`20will`20be`20started`20with`20the`20first`20record`20found`20in
V`20the`20people
X`20*`09file`20with`20that`20alias.
X`20*`2027.`09The`20people`20file`20also`20stores`20a`20record`20of`20all`20gam
Ves`20won/lost`20to
X`20*`09that`20opponent.`20`20The`20data`20stored`20includes`20games`20won/lost
V,`20points
X`20*`09won/lost,`20gammons`20won/lost,`20backgammons`20won/lost,`20and`20match
Ves`20won/lost.
X`20*`09There`20is`20currently`20no`20utility`20to`20print`20these`20out,`20but
V`20they`20can
X`20*`09be`20extracted`20from`20the`20people`20file`20manually.`20`20See`20the
V`20definitions
X`20*`09for`20SC_*`20in`20ldb.h`20to`20see`20which`20number`20is`20which.
X`20*`2028.`09There`20is`20now`20a`20way`20to`20reconstruct`20the`20.ldbdata
V`20file`20from`20your
X`20*`09opponents'`20.ldbdata`20files.`20`20Just`20have`20them`20mail`20their
V`20ldbdata
X`20*`09files`20to`20you,`20remove`20the`20mail`20header,`20and`20run:
X`20*`09`09ldb`20-reconstruct`20file
X`20*`09where`20file`20is`20the`20file`20containing`20the`20opponent's`20ldbdat
Va`20file.
X`20*`09Each`20game`20in`20that`20file`20showing`20you`20as`20the`20opponent
V`20is`20extracted
X`20*`09and`20inserted`20into`20your`20game`20list.`20`20You`20will`20be`20prom
Vpted`20for`20the
X`20*`09address`20of`20your`20opponent`20(and`20name,`20if`20they`20are`20not
V`20in`20the
X`20*`09people`20file)`20for`20each`20game`20found.
X`20*`2029.`09The`20people`20file`20has`20a`20method`20for`20handling`20people
V`20with`20multiple
X`20*`09e-mail`20addresses.`20`20When`20a`20new`20opponent`20is`20found`20with
V`20the
X`20*`09same`20name`20as`20an`20existing`20one,`20but`20a`20different`20address
V,`20the
X`20*`09user`20is`20asked`20if`20these`20addresses`20refer`20to`20the`20same
V`20person.
X`20*`09If`20they`20do,`20an`20"equiv"`20record`20is`20added`20to`20the`20peopl
Ve`20file,
X`20*`09which`20merely`20records`20that`20the`20second`20address`20refers`20to
V`20the
X`20*`09same`20person`20as`20the`20first.`20`20If`20they`20don't`20(e.g.`20John
V`20Smith),
X`20*`09two`20separate`20people`20records`20are`20created`20for`20the`20differe
Vnt`20people.
X`20*`2030.`09There`20is`20now`20a`20way`20to`20request`20a`20resend`20from`20y
Vour`20opponent`20under
X`20*`09-control.`20`20The`20menu`20item`20is`20"Get`20Resend",`20since`20"Requ
Vest`20Resend"
X`20*`09would`20have`20used`20the`20same`20first`20letter`20as`20"Resend".`20(o
Vh`20well)
X`20*`09A`20special`20packet`20is`20sent`20to`20your`20opponent;`20when`20his
V`20ldb`20receives`20it,
X`20*`09it`20will`20perform`20a`20resend`20automatically.`20`20This`20feature
V`20is`20disabled
X`20*`09if`20the`20opversion`20field`20of`20the`20game`20structure`20indicates
V`20your
X`20*`09opponent`20is`20using`20a`20pre-1.1`20version`20of`20ldb.`20`20Sending
V`20the`20resend
X`20*`09packet`20to`20an`20ldb`20older`20than`201.1`20would`20cause`20it`20to
V`20abort.`20`20Oops.
X`20*`2031.`09Any`20upper`20or`20lower`20case`20letters`20may`20now`20be`20used
V`20to`20draw`20the
X`20*`09pieces`20on`20the`20board.`20`20Previously`20only`20r,`20w,`20and`20b
V`20were`20used.
X`20*`09As`20r,`20w,`20and`20b`20stood`20for`20red,`20white,`20and`20black,`20t
Vhe`20option
X`20*`09to`20set`20them`20was`20called`20-color.`20`20While`20the`20letters`20n
Vo`20longer
X`20*`09(necessarily)`20represent`20colors,`20the`20option`20is`20still`20-colo
Vr.
X`20*`2032.`09A`20screen`20dump`20of`20a`20game`20may`20be`20obtained`20via`20t
Vhe`20-control`20menu.
X`20*`09The`20dump`20goes`20to`20ldb_screen.dmp.
X`20*
X`20*`20---`20`20The`20following`20modifications`20made`20by`20Earle`20Ake.
X`20*
X`20*`201.`09A`20context-sensitive`20help`20function`20was`20added`20that`20is
V`20activated`20by
X`20*`09pressing`20'h'`20or`20'?'`20at`20any`20time`20other`20than`20while`20co
Vmposing`20a`20message.
X`20*`202.`09The`20redraw`20key`20now`20works`20under`20VMS.`20`20Clearok()`20n
Veeded`20to`20be`20called
X`20*`09to`20force`20a`20redraw.
X`20*`203.`09The`20superkey`20function`20now`20works`20under`20VMS.`20`20It`20w
Vas`20rewritten`20to
X`20*`09spawn`20a`20subprocess`20and`20execute`20the`20supercmd`20if`20specifie
Vd.
X`20*`09The`20user`20must`20logout`20of`20the`20subprocess`20to`20resume`20the
V`20game.
X`20*`204.`09The`20.ldbrc`20file`20now`20contains`20reasonable`20defaults`20for
V`20VMS`20when
X`20*`09the`20VMS-compiled`20ldb`20creates`20it.`20`20The`20sendcmd`20setting
V`20calls
X`20*`09the`20IN%`20mailer`20by`20default.
X`20*`205.`09Old`20versions`20of`20.oldldbdata`20are`20now`20purged.
X`20*`206.`09setattr()`20and`20clrattr()`20are`20used`20instead`20of`20standout
V()`20and
X`20*`09standend()`20to`20get`20reverse`20video`20on`20VMS.`20`20standout()`20o
Vn`20VMS
X`20*`09used`20bold`20instead`20of`20reverse`20video,`20which`20made`20the`20cu
Vbe
X`20*`09look`20non-cubical.
X`20*`207.`09The`20current`20pip`20count`20for`20you`20and`20your`20opponent
V`20are`20displayed
X`20*`09above`20the`20board.`20`20These`20change`20depending`20on`20which`20boa
Vrd`20is
X`20*`09displayed,`20and`20are`20updated`20as`20you`20move.
X`20*`208.`09An`20extensive`20display`20of`20statistics`20regarding`20the`20num
Vber`20and
X`20*`09frequency`20of`20rolls`20and`20doubles`20for`20both`20users`20can`20be
V`20displayed
X`20*`09by`20pressing`20the`20%`20or`20#`20keys.`20`20This`20data`20can`20also
V`20be`20displayed
X`20*`09as`20a`20histogram.
X`20*
X`20***`20Version`2001`20`20`20Rev`202`20`20`20Patch`200
X`20***`20Note`20Rev`202`20was`20never`20officially`20released.`20`20A`20number
V`20of`20beta`20versions
X`20***`20of`201.2`20were`20distributed,`20and`20this`20led`20to`20so`20much
V`20confusion`20that`20the
X`20***`20official`20release`20was`20called`201.3.
X`20*`201.`09The`20"Get`20Resend"`20option`20in`20-control`20is`20disabled`20fo
Vr`20games
X`20*`09that`20are`20over.`20`20Patch`20by`20Earle`20Ake.
X`20*`202.`09All`20occurrences`20of`20"gets"`20have`20been`20replaced`20by`20"f
Vgets"`20to
X`20*`09avoid`20buffer`20overrun`20problems.
X`20*`203.`09Ldb`20now`20detects`20games`20where`20no`20further`20contact`20is
V`20possible`20and
X`20*`09changes`20the`20"BAR"`20indicator`20to`20"---".
X`20*`204.`09The`20"Resend"`20option`20in`20-control`20is`20disabled`20for`20ga
Vmes`20that`20are`20in
X`20*`09a`20"local"`20state`20(i.e.`20it`20is`20the`20local`20player's`20turn).
V
X`20*`205.`09The`20cumulative`20score`20from`20the`20people`20file`20can`20now
V`20be`20displayed
X`20*`09via`20the`20-score`20command`20line`20argument.`20`20This`20is`20simila
Vr`20to`20a
X`20*`09system`20implemented`20by`20Doug`20Parisek,`20but`20uses`20the`20info
V`20from`20the
X`20*`09people`20file`20rather`20than`20from`20a`20separate`20standings`20file.
V
X`20*`206.`09An`20option`20has`20been`20added`20to`20make`20ldb`20notify`20the
V`20game`20starter
X`20*`09when`20a`20game`20started`20by`20-remotestart`20has`20ended.`20`20If
V`20a
X`20*`09-notify`20<addr>`20option`20is`20on`20the`20command`20line`20before`20t
Vhe
X`20*`09-remotestart,`20the`20ldb`20from`20both`20players`20will`20send`20a`20m
Vessage
X`20*`09to`20<addr>`20when`20the`20game`20ends.`20`20This`20message`20will`20lo
Vok`20like
X`20*`09a`20normal`20ldb`20packet,`20but`20the`20opcode`20will`20be`20NOTIFY,
V`20and
X`20*`09the`20comment`20field`20will`20contain`20three`20numbers;`20these`20are
V
X`20*`09the`20termination`20code`20(T_*`20in`20ldb.h),`20the`20game`20value,
V`20and
X`20*`09the`20backgammon`20flag`20(1`20=`20gammon,`202`20=`20backgammon,`200
V`20=`20neither).
X`20*`09Note`20that`20the`20integer`20values`20of`20the`20termination`20codes
V`20changed
X`20*`09between`20rev`201.0`20and`20rev`201.1`20--`20the`20one`20in`20the`20com
Vment`20field
X`20*`09corresponds`20to`20the`20new`20codes`20(the`20ones`20found`20in`20ldb.h
V`20from
X`20*`09rev`201.1`20or`20higher).`20`20The`20comment2`20field`20contains`20the
V`20address
X`20*`09of`20the`20opponent`20played.`20`20Ldb`20itself`20has`20no`20provisions
V`20to`20read
X`20*`09notify`20packets,`20and`20would`20not`20be`20able`20to`20do`20anything
V`20useful
X`20*`09with`20them`20if`20it`20could.`20`20They`20are`20purely`20for`20the`20u
Vse`20of`20a
X`20*`09game`20starter,`20if`20anyone`20feels`20like`20writing`20one.
X`20*`207.`09Remote`20start`20packets`20left`20in`20the`20mail`20file`20no`20lo
Vnger`20start
X`20*`09a`20new`20game`20every`20time`20ldb`20is`20run.`20`20This`20is`20done
V`20by`20scanning
X`20*`09the`20game`20list`20for`20a`20game`20where`20both`20opaddr`20and`20star
Vttime`20match
X`20*`09those`20shown`20in`20the`20remotestart`20packet,`20and`20discarding`20i
Vt`20if
X`20*`09one`20is`20found.`20`20If`20it`20is`20not`20found,`20the`20address`20is
V`20looked`20up`20in
X`20*`09the`20people`20list`20and`20the`20fence`20time,`20if`20any,`20is`20chec
Vked.
X`20*`09This`20catches`20the`20case`20where`20the`20game`20started`20by`20that
V`20remotestart
X`20*`09packet`20has`20already`20finished.`20`20Bug`20found`20by`20Mark`20Rubin
V.
X`20*`208.`09The`20-remotestart`20option`20now`20supports`20the`20crawford,`20j
Vacoby,`20europe,
X`20*`09and`20permanent`20options,`20as`20well`20as`20match`20play.
X`20*`209.`09The`20crawford`20rule`20code`20has`20been`20rewritten.`20`20It`20n
Vow`20(correctly)
X`20*`09only`20disallows`20doubling`20for`20the`20first`20game`20after`20either
V`20player
X`20*`09reaches`20match`20score`20-`201.`20`20Subsequent`20games`20allow`20doub
Vling.
X`20*`09During`20the`20crawford`20rule`20game,`20the`20C`20indicator`20above
V`20the`20board
X`20*`09is`20drawn`20in`20reverse`20video.
X`20*`2010.`09Concede`20now`20scores`20a`20gammon`20if`20the`20loser`20has`20no
Vt`20borne`20off`20any
X`20*`09pieces,`20and`20a`20backgammon`20if`20the`20loser`20has`20any`20pieces
V`20in`20the`20winners
X`20*`09inner`20table.`20`20This`20fixes`20a`20bug`20where`20Concede`20could
V`20be`20used`20to
X`20*`09avoid`20a`20gammon/backgammon.
X`20*`2011.`09Ldb`20now`20scans`20the`20mail`20file(s)`20before`20checking`20fo
Vr`20access`20timeouts.
X`20*`09Previously,`20it`20would`20perform`20automatic`20resends`20for`20games
V`20when
X`20*`09a`20message`20for`20that`20game`20was`20waiting`20in`20the`20mail,`20re
Vsulting`20in`20an
X`20*`09unnecessary`20resend.`20`20This`20was`20common`20when`20returning`20fro
Vm`20vacation,
X`20*`09for`20example,`20when`20all`20games`20would`20time`20out.
X`20*`2012.`09The`20error`20messages`20displayed`20when`20a`20move`20is`20rejec
Vted`20have`20been
X`20*`09made`20more`20understandable.`20`20Previously`20the`20same`20set`20of
V`20messages
X`20*`09were`20used`20for`20the`20local`20player`20and`20for`20received`20moves
V,`20and`20the
X`20*`09wording`20was`20somewhat`20awkward`20to`20allow`20this`20double`20usage
V.`20`20Local
X`20*`09errors`20now`20use`20the`20messages`20in`20rejlcl`5B`5D,`20while`20rece
Vived`20moves`20still
X`20*`09use`20the`20messages`20in`20rejmsg`5B`5D.
X`20*`2013.`09A`20serious`20bug`20was`20fixed`20in`20rcvop.c.`20`20restart()
V`20and`20mstart()`20did`20not
X`20*`09call`20legalmoves()`20to`20regenerate`20the`20maxused`20and`20hiused
V`20fields`20of
X`20*`09the`20game`20structure.`20`20The`20consequence`20of`20this`20for`20rest
Vart()`20is`20that
X`20*`09move`20checking`20will`20not`20work`20for`20the`20first`20move`20of`20a
Vny`20game`20that`20had
X`20*`09a`20tie`20on`20an`20opening`20roll.`20`20For`20mstart(),`20which`20star
Vts`20the`20next
X`20*`09game`20of`20a`20match,`20maxused`20and`20hiused`20will`20still`20be`20w
Vhatever`20they
X`20*`09were`20for`20the`20last`20move`20of`20the`20previous`20game,`20which
V`20could`20result`20in
X`20*`09either`20allowing`20an`20illegal`20move`20or`20disallowing`20a`20legal
V`20one.
X`20*`09Bug`20found`20by`20Earle`20Ake.
X`20*`2014.`09Cbreak`20is`20now`20turned`20off`20during`20the`20supercmd.
X`20*`2015.`09Any`20printing`20character`20(other`20than`20space)`20is`20allowe
Vd`20to`20be`20used
X`20*`09to`20draw`20game`20pieces.`20`20These`20can`20be`20upper`20or`20lower
V`20case`20letters,
X`20*`09numbers,`20or`20punctuation.`20`20The`20only`20restriction`20is`20that
V`20the`20characters
X`20*`09used`20may`20not`20be`20the`20same`20for`20both`20players.`20`20This
V`20includes`20using
X`20*`09the`20upper`20and`20lower`20case`20of`20the`20same`20letter.
X`20*`2016.`09Command`20line`20options`20may`20now`20be`20abbreviated`20by`20th
Ve`20shortest
X`20*`09unique`20string.
X`20*`2017.`09If`20the`20-broadcast`20option`20is`20given`20without`20a`20file
V`20argument,`20it
X`20*`09reads`20from`20stdin.`20`20-broadcast`20also`20reads`20the`20people`20f
Vile`20instead
X`20*`09of`20the`20game`20file,`20so`20duplicate`20messages`20are`20not`20sent
V`20to`20opponents
X`20*`09with`20more`20than`20one`20game`20in`20progress.
X`20*`2018.`09The`20-start`20and`20-remotestart`20options`20are`20deferred`20un
Vtil`20after`20all
X`20*`09options`20have`20been`20scanned.`20`20This`20removes`20order`20dependen
Vcies`20in
X`20*`09command`20line`20options,`20so`20that:
X`20*`09`09ldb`20-match`207`20-start`20joe
X`20*`09and`09ldb`20-start`20joe`20-match`207
X`20*`09have`20identical`20effect.`20`20Because`20of`20this`20change,`20only
V`20one`20-start`20and
X`20*`09one`20-remotestart`20may`20be`20used`20per`20run`20of`20ldb.`20`20Sugge
Vsted`20by`20Earle`20Ake.
X`20***`20Version`2001`20`20`20Rev`202`20`20`20Patch`200
X`20*`201.`09A`20warning`20is`20printed`20if`20the`20crawford`20rule`20is`20use
Vd`20with`20a`20pre-1.3
X`20*`09version`20of`20ldb.`20`20The`20Crawford`20rule`20was`20fixed`20during
V`201.2,`20but`20many
X`20*`09beta`20versions`20were`20distributed`20before`20this`20fix`20was`20incl
Vuded.
X`20*==========================================================================
V==
X`20*/
X
Xmain(argc,argv)
Xint`20argc;
Xchar`20*argv`5B`5D;
X`7B
Xstruct`20game`20*g;
Xstruct`20people`20*p;
XFILE`20*fp;
Xchar`20subj`5B128`5D;
Xchar`20*bcfile;
Xint`20i,`20j;
Xchar`20c,`20c2;
Xint`20done;
Xint`20ldbsignal();
Xint`20flags,`20match;
Xchar`20*start_addr;
Xchar`20*rst1,`20*rst2;
X
Xghead`20=`20NULL;`09`09`09/*`20init`20game`20list`20to`20empty`20*/
Xgtail`20=`20NULL;
Xsignal(SIGINT,ldbsignal);`09/*`20set`20up`20interrupt`20trap`20to`20save`20gam
Ves`20*/
XRflag`20=`201;`09`09/*`20should`20we`20try`20to`20extract`20incoming`20mail?
V`20*/
XPflag`20=`201;`09`09/*`20should`20we`20process`20waiting`20games?`20*/
XRandomInit(time((long`20*)0));`09/*`20seed`20the`20random`20number`20generator
V`20*/
X
Xreadldbrc();`09`09/*`20read`20startup`20file`20*/
X
Xget_lock(rc.lockfile);`09/*`20is`20another`20ldb`20already`20running?`20*/
X
Xcr_mycolor`20=`20rc.defclrs`5B0`5D;`09/*`20default`20color`20when`20creating
V`20games`20*/
Xcr_opcolor`20=`20rc.defclrs`5B1`5D;
Xcr_mydir`20=`20(*rc.defdir`20==`20'u')`20?`201`20:`20-1;`09/*`20default`20dire
Vction`20*/
X
Xreadgames();`09`09/*`20load`20games`20in`20progress`20*/
X
Xmatch`20=`200;`09`09/*`20default`20to`20no`20match`20play`20*/
Xflags`20=`200;`09`09/*`20default`20to`20no`20special`20rules`20or`20perm`20gam
Ves`20*/
Xnotify`20=`20NULL;`09`09/*`20default`20to`20no`20notify`20address`20*/
Xstart_addr`20=`20NULL;`09/*`20default`20to`20no`20game`20started`20*/
Xrst1`20=`20NULL;`09`09/*`20default`20to`20no`20remote`20start`20game`20*/
Xrst2`20=`20NULL;
Xfor`20(i`20=`201;`20(i`20<`20argc)`20`26`26`20(argv`5Bi`5D`5B0`5D`20==`20'-');
V`20i++)`20`7B
+-+-+-+-+-+-+-+- END OF PART 10 +-+-+-+-+-+-+-+-