/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* hack.engrave.c - version 1.0.3 */
extern struct obj zeroobj
;
unsigned engr_lth
; /* for save & restore; not length of text */
long engr_time
; /* moment engraving was (will be) finished */
engr_at(x
,y
) register xchar x
,y
; {
register struct engr
*ep
= head_engr
;
if(x
== ep
->engr_x
&& y
== ep
->engr_y
)
return((struct engr
*) 0);
sengr_at(s
,x
,y
) register char *s
; register xchar x
,y
; {
register struct engr
*ep
= engr_at(x
,y
);
if(ep
&& ep
->engr_time
<= moves
) {
if(!strcmp(s,t)) return(1);
if(!strncmp(s
,t
,n
)) return(1);
if(!u
.uswallow
&& !Levitation
)
wipe_engr_at(u
.ux
, u
.uy
, cnt
);
wipe_engr_at(x
,y
,cnt
) register xchar x
,y
,cnt
; {
register struct engr
*ep
= engr_at(x
,y
);
if((ep
->engr_type
!= DUST
) || Levitation
) {
cnt
= rn2(1 + 50/(cnt
+1)) ? 0 : 1;
lth
= strlen(ep
->engr_txt
);
if((ch
= ep
->engr_txt
[pos
]) == ' ')
ep
->engr_txt
[pos
] = (ch
!= '?') ? '?' : ' ';
while(lth
&& ep
->engr_txt
[lth
-1] == ' ')
while(ep
->engr_txt
[0] == ' ')
if(!ep
->engr_txt
[0]) del_engr(ep
);
read_engr_at(x
,y
) register int x
,y
; {
register struct engr
*ep
= engr_at(x
,y
);
if(ep
&& ep
->engr_txt
[0]) {
pline("Something is written here in the dust.");
pline("Something is engraved here on the floor.");
pline("Some text has been burned here in the floor.");
impossible("Something is written in a very strange way.");
pline("You read: \"%s\".", ep
->engr_txt
);
register struct engr
*ep
;
alloc((unsigned)(sizeof(struct engr
) + strlen(s
) + 1));
ep
->nxt_engr
= head_engr
;
ep
->engr_txt
= (char *)(ep
+ 1);
(void) strcpy(ep
->engr_txt
, s
);
ep
->engr_lth
= strlen(s
) + 1;
register struct engr
*ep
, *oep
= engr_at(u
.ux
,u
.uy
);
int spct
; /* number of leading spaces */
register struct obj
*otmp
;
pline("You're joking. Hahaha!"); /* riv05!a3 */
/* one may write with finger, weapon or wand */
otmp
= getobj("#-)/", "write with");
if(otmp
&& otmp
->otyp
== WAN_FIRE
&& otmp
->spe
) {
if(uwep
&& uwep
->cursed
) {
pline("Since your weapon is welded to your hand,");
pline("you use the %s.", aobjnam(uwep
, (char *) 0));
pline("You are now empty-handed.");
pline("The %s %s to your hand!",
(otmp
->quan
== 1) ? "itself" : "themselves");
pline("You now wield %s.", doname(otmp
));
if(otmp
->otyp
== DAGGER
|| otmp
->otyp
== TWO_HANDED_SWORD
||
otmp
->otyp
== CRYSKNIFE
||
otmp
->otyp
== LONG_SWORD
|| otmp
->otyp
== AXE
) {
if((int)otmp
->spe
<= -3) {
pline("Your %s too dull for engraving.",
if(oep
&& oep
->engr_type
!= DUST
) return(1);
if(Levitation
&& type
!= BURN
){ /* riv05!a3 */
pline("You can't reach the floor!");
if(oep
&& oep
->engr_type
== DUST
){
pline("You wipe out the message that was written here.");
pline("You cannot wipe out the message that is %s in the rock.",
(oep
->engr_type
== BURN
) ? "burned" : "engraved");
pline("What do you want to %s on the floor here? ",
(type
== ENGRAVE
) ? "engrave" : (type
== BURN
) ? "burn" : "write");
while(*sp
== ' ') spct
++, sp
++;
if(!len
|| *buf
== '\033') {
if(type
== BURN
) otmp
->spe
++;
nomovemsg
= "You finished writing.";
case ENGRAVE
: /* here otmp != 0 */
{ int len2
= (otmp
->spe
+ 3) * 2 + 1;
pline("Your %s dull.", aobjnam(otmp
, "get"));
nomovemsg
= "You cannot engrave more.";
nomovemsg
= "You finished engraving.";
if(oep
) len
+= strlen(oep
->engr_txt
) + spct
;
ep
= (struct engr
*) alloc((unsigned)(sizeof(struct engr
) + len
+ 1));
ep
->nxt_engr
= head_engr
;
sp
= (char *)(ep
+ 1); /* (char *)ep + sizeof(struct engr) */
(void) strcpy(sp
, oep
->engr_txt
);
ep
->engr_time
= moves
-multi
;
/* kludge to protect pline against excessively long texts */
if(len
> BUFSZ
-20) sp
[BUFSZ
-20] = 0;
save_engravings(fd
) int fd
; {
register struct engr
*ep
= head_engr
;
if(!ep
->engr_lth
|| !ep
->engr_txt
[0]){
bwrite(fd
, (char *) & (ep
->engr_lth
), sizeof(ep
->engr_lth
));
bwrite(fd
, (char *) ep
, sizeof(struct engr
) + ep
->engr_lth
);
bwrite(fd
, (char *) nul
, sizeof(unsigned));
rest_engravings(fd
) int fd
; {
register struct engr
*ep
;
mread(fd
, (char *) <h
, sizeof(unsigned));
ep
= (struct engr
*) alloc(sizeof(struct engr
) + lth
);
mread(fd
, (char *) ep
, sizeof(struct engr
) + lth
);
ep
->nxt_engr
= head_engr
;
ep
->engr_txt
= (char *) (ep
+ 1); /* Andreas Bormann */
del_engr(ep
) register struct engr
*ep
; {
register struct engr
*ept
;
head_engr
= ep
->nxt_engr
;
for(ept
= head_engr
; ept
; ept
= ept
->nxt_engr
) {
if(ept
->nxt_engr
== ep
) {
ept
->nxt_engr
= ep
->nxt_engr
;
impossible("Error in del_engr?");