/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* hack.do_name.c - version 1.0.3 */
getpos(force
,goal
) int force
; char *goal
; {
extern char sdir
[]; /* defined in hack.c */
extern schar xdir
[], ydir
[]; /* idem */
extern char *visctrl(); /* see below */
pline("(For instructions type a ?)");
while((c
= readchar()) != '.'){
for(i
=0; i
<8; i
++) if(sdir
[i
] == c
){
if(1 <= cx
+ xdir
[i
] && cx
+ xdir
[i
] <= COLNO
)
if(0 <= cy
+ ydir
[i
] && cy
+ ydir
[i
] <= ROWNO
-1)
pline("Use [hjkl] to move the cursor to %s.", goal
);
pline("Type a . when you are at the right place.");
pline("Unknown direction: '%s' (%s).",
force
? "use hjkl or ." : "aborted");
register int cx
,cy
,lth
,i
;
register struct monst
*mtmp
, *mtmp2
;
cc
= getpos(0, "the monster you want to name");
if(cx
== u
.ux
&& cy
== u
.uy
)
pline("This ugly monster is called %s and cannot be renamed.",
pline("There is no monster there.");
pline("I see no monster there.");
pline("I cannot see a monster there.");
pline("What do you want to call %s? ", lmonnam(mtmp
));
if(!*buf
|| *buf
== '\033')
mtmp2
= newmonst(mtmp
->mxlth
+ lth
);
for(i
=0; i
<mtmp
->mxlth
; i
++)
((char *) mtmp2
->mextra
)[i
] = ((char *) mtmp
->mextra
)[i
];
(void) strcpy(NAME(mtmp2
), buf
);
* This routine changes the address of obj . Be careful not to call it
* when there might be pointers around in unknown places. For now: only
* when obj is in the inventory.
do_oname(obj
) register struct obj
*obj
; {
register struct obj
*otmp
, *otmp2
;
pline("What do you want to name %s? ", doname(obj
));
if(!*buf
|| *buf
== '\033')
(void) strcpy(ONAME(otmp2
), buf
);
setworn((struct obj
*) 0, obj
->owornmask
);
setworn(otmp2
, otmp2
->owornmask
);
/* do freeinv(obj); etc. by hand in order to preserve
the position of this object in the inventory */
if(obj
== invent
) invent
= otmp2
;
else for(otmp
= invent
; ; otmp
= otmp
->nobj
){
panic("Do_oname: cannot find obj.");
/* obfree(obj, otmp2); /* now unnecessary: no pointers on bill */
free((char *) obj
); /* let us hope nobody else saved a pointer */
register struct obj
*obj
;
pline("Do you want to name an individual object? [ny] ");
obj
= getobj("#", "name");
obj
= getobj("?!=/", "call");
register struct obj
*obj
;
pline("Call %s %s: ", index(vowels
,*str
) ? "an" : "a", str
);
if(!*buf
|| *buf
== '\033')
str
= newstring(strlen(buf
)+1);
str1
= &(objects
[obj
->otyp
].oc_uname
);
char *ghostnames
[] = { /* these names should have length < PL_NSIZ */
"adri", "andries", "andreas", "bert", "david", "dirk", "emile",
"frans", "fred", "greg", "hether", "jay", "john", "jon", "kay",
"kenny", "maud", "michiel", "mike", "peter", "robert", "ron",
xmonnam(mtmp
, vb
) register struct monst
*mtmp
; int vb
; {
static char buf
[BUFSZ
]; /* %% */
if(mtmp
->mnamelth
&& !vb
) {
(void) strcpy(buf
, NAME(mtmp
));
switch(mtmp
->data
->mlet
) {
{ register char *gn
= (char *) mtmp
->mextra
;
if(!*gn
) { /* might also look in scorefile */
gn
= ghostnames
[rn2(SIZE(ghostnames
))];
strcpy((char *) mtmp
->mextra
, !rn2(5) ? plname
: gn
);
(void) sprintf(buf
, "%s's ghost", gn
);
(void) strcpy(buf
, shkname(mtmp
));
/* fall into next case */
(void) sprintf(buf
, "the %s%s",
mtmp
->minvis
? "invisible " : "",
if(vb
&& mtmp
->mnamelth
) {
(void) strcat(buf
, " called ");
(void) strcat(buf
, NAME(mtmp
));
lmonnam(mtmp
) register struct monst
*mtmp
; {
return(xmonnam(mtmp
, 1));
monnam(mtmp
) register struct monst
*mtmp
; {
return(xmonnam(mtmp
, 0));
Monnam(mtmp
) register struct monst
*mtmp
; {
register char *bp
= monnam(mtmp
);
if('a' <= *bp
&& *bp
<= 'z') *bp
+= ('A' - 'a');
register struct monst
*mtmp
;
register char *bp
= monnam(mtmp
);
static char buf
[BUFSZ
]; /* %% */
if(!strncmp(bp
, "the ", 4)) bp
+= 4;
(void) sprintf(buf
, "the %s %s", adj
, bp
);
register struct monst
*mtmp
;
register char *bp
= amonnam(mtmp
,adj
);
Xmonnam(mtmp
) register struct monst
*mtmp
; {
register char *bp
= Monnam(mtmp
);
if(!strncmp(bp
, "The ", 4)) {