occupation callback for engraving some text */
| 1264 | |
| 1265 | /* occupation callback for engraving some text */ |
| 1266 | staticfn int |
| 1267 | engrave(void) |
| 1268 | { |
| 1269 | struct engr *oep; |
| 1270 | char buf[BUFSZ]; /* holds the post-this-action engr text, including |
| 1271 | * anything already there */ |
| 1272 | const char *finishverb; /* "You finish [foo]." */ |
| 1273 | struct obj * stylus; /* shorthand for svc.context.engraving.stylus */ |
| 1274 | boolean firsttime = (svc.context.engraving.actionct == 0); |
| 1275 | int rate = 10; /* # characters that can be engraved in this action */ |
| 1276 | boolean truncate = FALSE; |
| 1277 | boolean neweng = (svc.context.engraving.actionct == 0); |
| 1278 | |
| 1279 | boolean carving = (svc.context.engraving.type == ENGRAVE |
| 1280 | || svc.context.engraving.type == HEADSTONE); |
| 1281 | boolean dulling_wep, marker; |
| 1282 | char *endc; /* points at character 1 beyond the last character to engrave |
| 1283 | * this action */ |
| 1284 | int i, space_left; |
| 1285 | |
| 1286 | if (svc.context.engraving.pos.x != u.ux |
| 1287 | || svc.context.engraving.pos.y != u.uy) { /* teleported? */ |
| 1288 | You("are unable to continue engraving."); |
| 1289 | return 0; |
| 1290 | } |
| 1291 | /* Stylus might have been taken out of inventory and destroyed somehow. |
| 1292 | * Not safe to dereference stylus until after this. */ |
| 1293 | if (svc.context.engraving.stylus == &hands_obj) { /* bare finger */ |
| 1294 | stylus = (struct obj *) 0; |
| 1295 | } else { |
| 1296 | for (stylus = gi.invent; stylus; stylus = stylus->nobj) { |
| 1297 | if (stylus == svc.context.engraving.stylus) |
| 1298 | break; |
| 1299 | } |
| 1300 | if (!stylus) { |
| 1301 | You("are unable to continue engraving."); |
| 1302 | return 0; |
| 1303 | } |
| 1304 | } |
| 1305 | |
| 1306 | dulling_wep = (carving && stylus && stylus->oclass == WEAPON_CLASS |
| 1307 | && (stylus->otyp != ATHAME || stylus->cursed)); |
| 1308 | marker = (stylus && stylus->otyp == MAGIC_MARKER |
| 1309 | && svc.context.engraving.type == MARK); |
| 1310 | |
| 1311 | svc.context.engraving.actionct++; |
| 1312 | |
| 1313 | /* sanity checks */ |
| 1314 | if (dulling_wep && !is_blade(stylus)) { |
| 1315 | impossible("carving with non-bladed weapon"); |
| 1316 | } else if (svc.context.engraving.type == MARK && !marker) { |
| 1317 | impossible("making graffiti with non-marker stylus"); |
| 1318 | } |
| 1319 | |
| 1320 | /* Step 1: Compute rate. */ |
| 1321 | if (carving && stylus |
| 1322 | && (dulling_wep || stylus->oclass == RING_CLASS |
| 1323 | || stylus->oclass == GEM_CLASS)) { |
nothing calls this directly
no test coverage detected