void make_engr_at(struct level *lev, int x, int y, const char *s, long e_time, xchar e_type) { struct engr *ep; size_t engr_len; if (!s || !*s) return; engr_len = strlen(s); if ((ep = engr_at(lev, x, y)) != 0) del_engr(ep, lev); ep = newengr(engr_len + 1); memset(ep, 0, sizeof (struct engr) + engr_len + 1); ep->nxt_engr = lev->lev_engr; lev->lev_engr = ep; ep->engr_x = x; ep->engr_y = y; ep->engr_txt = (char *)(ep + 1); strncpy(ep->engr_txt, s, engr_len); ep->engr_txt[engr_len] = '\0'; while (ep->engr_txt[0] == ' ') ep->engr_txt++; ep->engr_time = e_time; /* the caller shouldn't be asking for a random engrave type except during polymorph; if they do anyway, using the poly_engrave RNG isn't the end of the world */ ep->engr_type = e_type > 0 ? e_type : 1 + rn2_on_rng(MAX_RND_ENGR - 1, rng_poly_engrave); ep->engr_lth = engr_len + 1; }
void make_engr_at(struct level *lev, int x, int y, const char *s, long e_time, xchar e_type) { struct engr *ep; if ((ep = engr_at(lev, x,y)) != 0) del_engr(ep, lev); ep = newengr(strlen(s) + 1); memset(ep, 0, sizeof(struct engr) + strlen(s) + 1); ep->nxt_engr = lev->lev_engr; lev->lev_engr = ep; ep->engr_x = x; ep->engr_y = y; ep->engr_txt = (char *)(ep + 1); strcpy(ep->engr_txt, s); while (ep->engr_txt[0] == ' ') ep->engr_txt++; /* engraving Elbereth shows wisdom */ if (!in_mklev && !strcmp(s, "Elbereth")) exercise(A_WIS, TRUE); ep->engr_time = e_time; ep->engr_type = e_type > 0 ? e_type : rnd(N_ENGRAVE-1); ep->engr_lth = strlen(s) + 1; }