MCPcopy Index your code
hub / github.com/NetHack/NetHack / fixup_oil

Function fixup_oil

src/mkobj.c:2024–2048  ·  view source on GitHub ↗

potions of oil use their obj->age field differently from other potions so changing potion type to or from oil needs to have that fixed up */

Source from the content-addressed store, hash-verified

2022/* potions of oil use their obj->age field differently from other potions
2023 so changing potion type to or from oil needs to have that fixed up */
2024void
2025fixup_oil(
2026 struct obj *potion, /* potion that just had its otyp changed */
2027 struct obj *source) /* item used to create potion; might be Null */
2028{
2029 if (potion->otyp == POT_OIL) {
2030 if (source && source->otyp == POT_OIL) {
2031 /* potion of oil being used to set potion's otyp to oil;
2032 source might be partly used */
2033 potion->age = source->age;
2034 } else {
2035 /* non-oil is being turned into oil; change absolute age
2036 (turn created) into relative age (amount remaining /
2037 burn time available) */
2038 potion->age = MAX_OIL_IN_FLASK;
2039 }
2040 } else if (source && source->otyp == POT_OIL) {
2041 /* potion is no longer oil, being turned into non-oil */
2042 if (potion->age == source->age)
2043 potion->age = svm.moves;
2044 /* when source is a partly used oil, mark potion as diluted */
2045 if (source->age < MAX_OIL_IN_FLASK)
2046 potion->odiluted = 1;
2047 }
2048}
2049
2050/* return TRUE if the corpse has special timing;
2051 lizards and lichen don't rot, trolls and Riders auto-revive */

Callers 3

potion_dipFunction · 0.85
hornoplentyFunction · 0.85
poly_objFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected