]>
git.cameronkatri.com Git - bsdgames-darwin.git/blob - hack/hack.engrave.c
1 /* $NetBSD: hack.engrave.c,v 1.5 2001/03/25 20:44:00 jsm Exp $ */
4 * Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985.
9 __RCSID("$NetBSD: hack.engrave.c,v 1.5 2001/03/25 20:44:00 jsm Exp $");
17 struct engr
*nxt_engr
;
20 unsigned engr_lth
; /* for save & restore; not length of
22 long engr_time
; /* moment engraving was (will be)
34 struct engr
*ep
= head_engr
;
36 if (x
== ep
->engr_x
&& y
== ep
->engr_y
)
40 return ((struct engr
*) 0);
48 struct engr
*ep
= engr_at(x
, y
);
51 if (ep
&& ep
->engr_time
<= moves
) {
54 if(!strcmp(s,t)) return(1);
58 if (!strncmp(s
, t
, n
))
70 if (!u
.uswallow
&& !Levitation
)
71 wipe_engr_at(u
.ux
, u
.uy
, cnt
);
75 wipe_engr_at(x
, y
, cnt
)
78 struct engr
*ep
= engr_at(x
, y
);
82 if ((ep
->engr_type
!= DUST
) || Levitation
) {
83 cnt
= rn2(1 + 50 / (cnt
+ 1)) ? 0 : 1;
85 lth
= strlen(ep
->engr_txt
);
89 if ((ch
= ep
->engr_txt
[pos
]) == ' ')
91 ep
->engr_txt
[pos
] = (ch
!= '?') ? '?' : ' ';
94 while (lth
&& ep
->engr_txt
[lth
- 1] == ' ')
95 ep
->engr_txt
[--lth
] = 0;
96 while (ep
->engr_txt
[0] == ' ')
107 struct engr
*ep
= engr_at(x
, y
);
108 if (ep
&& ep
->engr_txt
[0]) {
109 switch (ep
->engr_type
) {
111 pline("Something is written here in the dust.");
114 pline("Something is engraved here on the floor.");
117 pline("Some text has been burned here in the floor.");
120 impossible("Something is written in a very strange way.");
122 pline("You read: \"%s\".", ep
->engr_txt
);
127 make_engr_at(x
, y
, s
)
133 if ((ep
= engr_at(x
, y
)) != NULL
)
136 alloc((unsigned) (sizeof(struct engr
) + strlen(s
) + 1));
137 ep
->nxt_engr
= head_engr
;
141 ep
->engr_txt
= (char *) (ep
+ 1);
142 (void) strcpy(ep
->engr_txt
, s
);
144 ep
->engr_type
= DUST
;
145 ep
->engr_lth
= strlen(s
) + 1;
153 struct engr
*ep
, *oep
= engr_at(u
.ux
, u
.uy
);
156 int spct
; /* number of leading spaces */
161 pline("You're joking. Hahaha!"); /* riv05!a3 */
164 /* one may write with finger, weapon or wand */
165 otmp
= getobj("#-)/", "write with");
169 if (otmp
== &zeroobj
)
171 if (otmp
&& otmp
->otyp
== WAN_FIRE
&& otmp
->spe
) {
175 /* first wield otmp */
177 if (uwep
&& uwep
->cursed
) {
178 /* Andreas Bormann */
179 pline("Since your weapon is welded to your hand,");
180 pline("you use the %s.", aobjnam(uwep
, (char *) 0));
184 pline("You are now empty-handed.");
185 else if (otmp
->cursed
)
186 pline("The %s %s to your hand!",
187 aobjnam(otmp
, "weld"),
188 (otmp
->quan
== 1) ? "itself" : "themselves");
190 pline("You now wield %s.", doname(otmp
));
196 else if (otmp
->otyp
== DAGGER
|| otmp
->otyp
== TWO_HANDED_SWORD
||
197 otmp
->otyp
== CRYSKNIFE
||
198 otmp
->otyp
== LONG_SWORD
|| otmp
->otyp
== AXE
) {
200 if ((int) otmp
->spe
<= -3) {
202 pline("Your %s too dull for engraving.",
203 aobjnam(otmp
, "are"));
204 if (oep
&& oep
->engr_type
!= DUST
)
210 if (Levitation
&& type
!= BURN
) { /* riv05!a3 */
211 pline("You can't reach the floor!");
214 if (oep
&& oep
->engr_type
== DUST
) {
215 pline("You wipe out the message that was written here.");
219 if (type
== DUST
&& oep
) {
220 pline("You cannot wipe out the message that is %s in the rock.",
221 (oep
->engr_type
== BURN
) ? "burned" : "engraved");
224 pline("What do you want to %s on the floor here? ",
225 (type
== ENGRAVE
) ? "engrave" : (type
== BURN
) ? "burn" : "write");
233 if (!len
|| *buf
== '\033') {
243 nomovemsg
= "You finished writing.";
246 case ENGRAVE
: /* here otmp != 0 */
248 int len2
= (otmp
->spe
+ 3) * 2 + 1;
250 pline("Your %s dull.", aobjnam(otmp
, "get"));
255 nomovemsg
= "You cannot engrave more.";
257 otmp
->spe
-= len
/ 2;
258 nomovemsg
= "You finished engraving.";
265 len
+= strlen(oep
->engr_txt
) + spct
;
266 ep
= (struct engr
*) alloc((unsigned) (sizeof(struct engr
) + len
+ 1));
267 ep
->nxt_engr
= head_engr
;
271 sp
= (char *) (ep
+ 1); /* (char *)ep + sizeof(struct engr) */
274 (void) strcpy(sp
, oep
->engr_txt
);
275 (void) strcat(sp
, buf
);
278 (void) strcpy(sp
, buf
);
279 ep
->engr_lth
= len
+ 1;
280 ep
->engr_type
= type
;
281 ep
->engr_time
= moves
- multi
;
283 /* kludge to protect pline against excessively long texts */
284 if (len
> BUFSZ
- 20)
294 struct engr
*ep
= head_engr
;
296 if (!ep
->engr_lth
|| !ep
->engr_txt
[0]) {
300 bwrite(fd
, (char *) &(ep
->engr_lth
), sizeof(ep
->engr_lth
));
301 bwrite(fd
, (char *) ep
, sizeof(struct engr
) + ep
->engr_lth
);
304 bwrite(fd
, (char *) nul
, sizeof(unsigned));
316 mread(fd
, (char *) <h
, sizeof(unsigned));
319 ep
= (struct engr
*) alloc(sizeof(struct engr
) + lth
);
320 mread(fd
, (char *) ep
, sizeof(struct engr
) + lth
);
321 ep
->nxt_engr
= head_engr
;
322 ep
->engr_txt
= (char *) (ep
+ 1); /* Andreas Bormann */
333 head_engr
= ep
->nxt_engr
;
335 for (ept
= head_engr
; ept
; ept
= ept
->nxt_engr
) {
336 if (ept
->nxt_engr
== ep
) {
337 ept
->nxt_engr
= ep
->nxt_engr
;
341 impossible("Error in del_engr?");