Francesco149 / oppai-ng

difficulty and pp calculator for osu!. better, smaller, faster rewrite of https://github.com/Francesco149/oppai
The Unlicense
155 stars 36 forks source link

OPPAIAPI recalculate after multiple parameter changes without changing map #50

Closed Syriiin closed 5 years ago

Syriiin commented 5 years ago

From the python bindings, there is no OPPAIAPI exposed function to recalculate that doesn't call free_owned_map(), other than using ezpp_dup/ezpp_data_dup with autocalc mode.

This works, but what if you want to make multiple parameter changes before recalculating, such as changing both mods and accuracy? As far as I can see, currently there is no way to do this without either a wasted map reparse (from calling ezpp() with the same map), atleast one wasted calculation run (from autocalc mode), or some weird abuse of autocalc mode by toggling off and on.

I imagine this could be fixed by simply a exposing the calc() method via OPPAIAPI as ezpp_calc() (or something). Ideally p_map/p_map_mem would also be exposed as ezpp_parse/ezpp_parse_data (or something) so you wouldn't need to worry about using a different part of the API for recalculations, but that's not as major.

Francesco149 commented 5 years ago

if you need to be that efficient, don't use autocalc mode at all. for now autocalc mode is meant to recalc on every single param change for maximum simplicity. which is handy for example if you want to have a ui where you change individual params or a quick way to test from a REPL

Syriiin commented 5 years ago

yea but all but currently exposed calculate functions hit free_owned_map() and force a reparse dont they? if you know there aren't map changes, you shouldnt need to reparse, right?

Francesco149 commented 5 years ago

it only forces a re-parse if using autocalc mode. otherwise it will always use the params from the last parse https://github.com/Francesco149/oppai-ng/blob/master/oppai.c#L2356

remember that you will have to manually invalidate the params when you actually need to reparse

Francesco149 commented 5 years ago

the test suite runner uses it exactly this way to avoid re-parsing (maps are sorted by id) https://github.com/Francesco149/oppai-ng/blob/master/test/test.c#L58

Syriiin commented 5 years ago

I seeeee, cool makes sense. thanks