Opened 11 years ago

Closed 11 years ago

#818 closed task (fixed (in master))

Revise definition and operation of cache in slay_power()

Reported by: magnate Owned by: magnate
Milestone: 3.1.1 beta Keywords: randarts
Cc:

Description

The slay_power() function (in obj-power.c) currently caches all 65536 combinations of brands and slays, to avoid looping over all 500-odd monsters more often than is necessary. In practice, <100 artifact weapons means almost no duplication occurs, and the cache is largely redundant.

With the advent of POWER_PRICING in [b7469a4] (SVN r1284), it becomes useful again - otherwise we loop over all monsters every time the player sells an ego weapon with a slay on it (which happens quite a bit in most games). So ideally we need to cache the slay permutations found in ego-item.txt, by

(1) using the eval_info() post-processing function called during init_info() of ego-item.txt to store those specific permutations in the cache.

That defines the cache and solves most of the problem, but it would be nice if we didn't recalculate the power of artifacts when they're sold. This would be achieved by

(2) adding artifact power to the artifact_type structure (just as monster power was added to the monster structure) - but we need to be careful to call store_base_power() when randarts are *not* used!

Change History (4)

comment:1 Changed 11 years ago by magnate

  • Status changed from new to assigned

comment:2 Changed 11 years ago by takkaria

Do you really need to add artifact power to artifact_type? AFAICS it'd be easier just to recalculate on sale-- is it really worth optimising for this case?

comment:3 Changed 11 years ago by magnate

No, we probably don't, you're probably right. In any event, this ticket divides neatly into the two halves, so we can do the first half and then wait for people's feedback to see if we need do to the second bit.

comment:4 Changed 11 years ago by magnate

  • Resolution set to fixed
  • Status changed from assigned to closed

Cache fixed in [75cb81e] (SVN r1371). Can always reopen if feedback indicates a need to store artifact power in the a_info structure.

Note: See TracTickets for help on using tickets.