Split the liquipowder fix-dimensions hook into separate liquid and powder.

The item_liquipowder vtable is completely optimized out by MSVC.
develop
Alexander Gavrilov 2012-10-10 18:22:01 +04:00
parent 7224c8746a
commit 7c969f774f
1 changed files with 19 additions and 5 deletions

@ -34,7 +34,8 @@
#include "df/ui_build_selector.h"
#include "df/building_trapst.h"
#include "df/item_actual.h"
#include "df/item_liquipowder.h"
#include "df/item_liquid_miscst.h"
#include "df/item_powder_miscst.h"
#include "df/item_barst.h"
#include "df/item_threadst.h"
#include "df/item_clothst.h"
@ -402,8 +403,8 @@ static void correct_dimension(df::item_actual *self, int32_t &delta, int32_t dim
if (copy) copy->categorize(true);
}
struct dimension_lqp_hook : df::item_liquipowder {
typedef df::item_liquipowder interpose_base;
struct dimension_liquid_hook : df::item_liquid_miscst {
typedef df::item_liquid_miscst interpose_base;
DEFINE_VMETHOD_INTERPOSE(bool, subtractDimension, (int32_t delta))
{
@ -412,7 +413,19 @@ struct dimension_lqp_hook : df::item_liquipowder {
}
};
IMPLEMENT_VMETHOD_INTERPOSE(dimension_lqp_hook, subtractDimension);
IMPLEMENT_VMETHOD_INTERPOSE(dimension_liquid_hook, subtractDimension);
struct dimension_powder_hook : df::item_powder_miscst {
typedef df::item_powder_miscst interpose_base;
DEFINE_VMETHOD_INTERPOSE(bool, subtractDimension, (int32_t delta))
{
correct_dimension(this, delta, dimension);
return INTERPOSE_NEXT(subtractDimension)(delta);
}
};
IMPLEMENT_VMETHOD_INTERPOSE(dimension_powder_hook, subtractDimension);
struct dimension_bar_hook : df::item_barst {
typedef df::item_barst interpose_base;
@ -795,7 +808,8 @@ static command_result tweak(color_ostream &out, vector <string> &parameters)
}
else if (cmd == "fix-dimensions")
{
enable_hook(out, INTERPOSE_HOOK(dimension_lqp_hook, subtractDimension), parameters);
enable_hook(out, INTERPOSE_HOOK(dimension_liquid_hook, subtractDimension), parameters);
enable_hook(out, INTERPOSE_HOOK(dimension_powder_hook, subtractDimension), parameters);
enable_hook(out, INTERPOSE_HOOK(dimension_bar_hook, subtractDimension), parameters);
enable_hook(out, INTERPOSE_HOOK(dimension_thread_hook, subtractDimension), parameters);
enable_hook(out, INTERPOSE_HOOK(dimension_cloth_hook, subtractDimension), parameters);