]>
git.cameronkatri.com Git - bsdgames-darwin.git/blob - hack/hack.do_name.c
1 /* $NetBSD: hack.do_name.c,v 1.5 2001/03/25 20:43:59 jsm Exp $ */
4 * Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985.
9 __RCSID("$NetBSD: hack.do_name.c,v 1.5 2001/03/25 20:43:59 jsm Exp $");
23 pline("(For instructions type a ?)");
27 while ((c
= readchar()) != '.') {
28 for (i
= 0; i
< 8; i
++)
30 if (1 <= cx
+ xdir
[i
] && cx
+ xdir
[i
] <= COLNO
)
32 if (0 <= cy
+ ydir
[i
] && cy
+ ydir
[i
] <= ROWNO
- 1)
37 pline("Use [hjkl] to move the cursor to %s.", goal
);
38 pline("Type a . when you are at the right place.");
40 pline("Unknown direction: '%s' (%s).",
42 force
? "use hjkl or ." : "aborted");
63 struct monst
*mtmp
, *mtmp2
;
64 cc
= getpos(0, "the monster you want to name");
71 if (cx
== u
.ux
&& cy
== u
.uy
)
72 pline("This ugly monster is called %s and cannot be renamed.",
75 pline("There is no monster there.");
79 pline("I see no monster there.");
82 if (!cansee(cx
, cy
)) {
83 pline("I cannot see a monster there.");
86 pline("What do you want to call %s? ", lmonnam(mtmp
));
89 if (!*buf
|| *buf
== '\033')
91 lth
= strlen(buf
) + 1;
96 mtmp2
= newmonst(mtmp
->mxlth
+ lth
);
98 for (i
= 0; i
< mtmp
->mxlth
; i
++)
99 ((char *) mtmp2
->mextra
)[i
] = ((char *) mtmp
->mextra
)[i
];
100 mtmp2
->mnamelth
= lth
;
101 (void) strcpy(NAME(mtmp2
), buf
);
102 replmon(mtmp
, mtmp2
);
107 * This routine changes the address of obj . Be careful not to call it
108 * when there might be pointers around in unknown places. For now: only
109 * when obj is in the inventory.
115 struct obj
*otmp
, *otmp2
;
118 pline("What do you want to name %s? ", doname(obj
));
121 if (!*buf
|| *buf
== '\033')
123 lth
= strlen(buf
) + 1;
130 otmp2
->onamelth
= lth
;
131 (void) strcpy(ONAME(otmp2
), buf
);
133 setworn((struct obj
*) 0, obj
->owornmask
);
134 setworn(otmp2
, otmp2
->owornmask
);
137 * do freeinv(obj); etc. by hand in order to preserve the position of
138 * this object in the inventory
143 for (otmp
= invent
;; otmp
= otmp
->nobj
) {
145 panic("Do_oname: cannot find obj.");
146 if (otmp
->nobj
== obj
) {
152 obfree(obj
, otmp2
); /* now unnecessary: no pointers on bill */
154 free((char *) obj
); /* let us hope nobody else saved a pointer */
162 pline("Do you want to name an individual object? [ny] ");
163 switch (readchar()) {
167 obj
= getobj("#", "name");
172 obj
= getobj("?!=/", "call");
192 pline("Call %s %s: ", strchr(vowels
, *str
) ? "an" : "a", str
);
195 if (!*buf
|| *buf
== '\033')
197 str
= newstring(strlen(buf
) + 1);
198 (void) strcpy(str
, buf
);
199 str1
= &(objects
[obj
->otyp
].oc_uname
);
205 const char *const ghostnames
[] = {/* these names should have length < PL_NSIZ */
206 "adri", "andries", "andreas", "bert", "david", "dirk", "emile",
207 "frans", "fred", "greg", "hether", "jay", "john", "jon", "kay",
208 "kenny", "maud", "michiel", "mike", "peter", "robert", "ron",
217 static char buf
[BUFSZ
]; /* %% */
218 if (mtmp
->mnamelth
&& !vb
) {
219 (void) strcpy(buf
, NAME(mtmp
));
222 switch (mtmp
->data
->mlet
) {
225 const char *gn
= (char *) mtmp
->mextra
;
226 if (!*gn
) { /* might also look in scorefile */
227 gn
= ghostnames
[rn2(SIZE(ghostnames
))];
230 strcpy((char *) mtmp
->mextra
, !rn2(5) ? plname
: gn
);
232 (void) sprintf(buf
, "%s's ghost", gn
);
237 (void) strcpy(buf
, shkname(mtmp
));
240 /* fall into next case */
242 (void) sprintf(buf
, "the %s%s",
243 mtmp
->minvis
? "invisible " : "",
246 if (vb
&& mtmp
->mnamelth
) {
247 (void) strcat(buf
, " called ");
248 (void) strcat(buf
, NAME(mtmp
));
257 return (xmonnam(mtmp
, 1));
264 return (xmonnam(mtmp
, 0));
271 char *bp
= monnam(mtmp
);
272 if ('a' <= *bp
&& *bp
<= 'z')
282 char *bp
= monnam(mtmp
);
283 static char buf
[BUFSZ
]; /* %% */
285 if (!strncmp(bp
, "the ", 4))
287 (void) sprintf(buf
, "the %s %s", adj
, bp
);
296 char *bp
= amonnam(mtmp
, adj
);
306 char *bp
= Monnam(mtmp
);
307 if (!strncmp(bp
, "The ", 4)) {