Skip to content

Commit

Permalink
Fixes #194
Browse files Browse the repository at this point in the history
  • Loading branch information
DudeMcDude committed Apr 18, 2016
1 parent a80ec02 commit e02bcd0
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 21 deletions.
2 changes: 1 addition & 1 deletion TemplePlus/d20.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1437,7 +1437,7 @@ ActionErrorCode D20ActionCallbacks::ActionFrameDisarm(D20Actn* d20a)
} disarmedArgs;
disarmedArgs.weapon = weapon;
objects.floats->FloatCombatLine(d20a->d20APerformer, 200); // Counter Disarmed!
conds.AddTo(d20a->d20APerformer, "Disarmed", { ((int*)&disarmedArgs)[0], ((int*)&disarmedArgs)[1], 0,0,0,0 });
conds.AddTo(d20a->d20APerformer, "Disarmed", { ((int*)&disarmedArgs)[0], ((int*)&disarmedArgs)[1], 0,0,0,0,0,0 });
return AEC_OK;
}
else if (!failedOnce)
Expand Down
3 changes: 2 additions & 1 deletion TemplePlus/hotkeys.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,9 @@ BOOL HotkeyReplacements::HotkeyActivate(objHndl obj)
return FALSE;

auto radMenuNodeCount = temple::GetRef<int>(0x118676C0);
if (radMenuNodeCount > radMenuForHK->nodeCount)
if (radMenuNodeCount > radMenuForHK->nodeCount) {
return FALSE;
}

auto& activeRadialMenu = temple::GetRef<const RadialMenu*>(0x115B2048);
activeRadialMenu = radialMenus.GetForObj(obj);
Expand Down
53 changes: 52 additions & 1 deletion TemplePlus/radialmenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
//#include "temple_functions.h"

RadialMenus radialMenus;
int RadialMenus::standardNodeIndices[120];

static_assert(temple::validate_size<RadialMenuEntry, 0x48>::value, "Structure has an incorrect size.");
static_assert(temple::validate_size<RadialMenuNode, 0x11C>::value, "Structure has an incorrect size.");
Expand Down Expand Up @@ -93,8 +94,20 @@ class RadialMenuReplacements : public TempleFix
}

static int RmbReleasedHandler(TigMsg* msg);
void ReplaceStandardRadialNodes();


void apply() override {


// GetStandardNode
replaceFunction<int(int)>(0x100F12B0, [](int stdNode){
return radialMenus.GetStandardNode(static_cast<RadialMenuStandardNode>(stdNode));
});

ReplaceStandardRadialNodes();


// RadialMenuUpdate
replaceFunction<void(__cdecl)(objHndl)>(0x1004D1F0, [](objHndl objHnd){
auto obj = gameSystems->GetObj().GetObject(objHnd);
Expand Down Expand Up @@ -170,6 +183,44 @@ int RadialMenuReplacements::RmbReleasedHandler(TigMsg* msg)
return 1;
}

void RadialMenuReplacements::ReplaceStandardRadialNodes()
{
auto writeval = reinterpret_cast<int>(RadialMenus::standardNodeIndices);

// SetStandardNode
write(0x100F145F + 3, &writeval, sizeof(int*));
write(0x100F1441 + 3, &writeval, sizeof(int*));


write(0x100F15B9 + 3, &writeval, sizeof(int*));
write(0x100F16E7 + 3, &writeval, sizeof(int*));
write(0x100F1818 + 3, &writeval, sizeof(int*));
write(0x100F1945 + 3, &writeval, sizeof(int*));
write(0x100F1A77 + 3, &writeval, sizeof(int*));
write(0x100F1BA8 + 3, &writeval, sizeof(int*));
write(0x100F1D30 + 3, &writeval, sizeof(int*));
write(0x100F1D70 + 3, &writeval, sizeof(int*));
write(0x100F1E97 + 3, &writeval, sizeof(int*));
write(0x100F1FD0 + 3, &writeval, sizeof(int*));
write(0x100F2100 + 3, &writeval, sizeof(int*));
write(0x100F2384 + 3, &writeval, sizeof(int*));

// BuildRadialMenuNormal
write(0x100F2674 + 2, &writeval, sizeof(int*));
write(0x100F27EC + 3, &writeval, sizeof(int*));

writeval = reinterpret_cast<int>(RadialMenus::standardNodeIndices) + 8;
write(0x100F2876 + 2, &writeval, sizeof(int*));
write(0x100F28F4 + 1, &writeval, sizeof(int*));
write(0x100F2969 + 2, &writeval, sizeof(int*));
write(0x100F29E3 + 2, &writeval, sizeof(int*));
write(0x100F2A62 + 1, &writeval, sizeof(int*));
write(0x100F2AD0 + 2, &writeval, sizeof(int*));

writeval = reinterpret_cast<int>(RadialMenus::standardNodeIndices) + 0x28;
write(0x100F2B71 + 2, &writeval, sizeof(int*));
}

RadialMenuReplacements radMenuReplace;


Expand Down Expand Up @@ -197,7 +248,7 @@ const RadialMenuEntry& RadialMenus::GetLastSelected() {
}

int RadialMenus::GetStandardNode(RadialMenuStandardNode node) {
return addresses.standardNodeIndices[(int)node];
return standardNodeIndices[(int)node];
}

int RadialMenus::Sub_100F0200(objHndl objHnd, RadialMenuEntry* radEntry)
Expand Down
2 changes: 2 additions & 0 deletions TemplePlus/radialmenu.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ struct D20RadialMenuDef
class RadialMenus {
public:

static int standardNodeIndices[120];

/*
Returns the radial menu for the given object or null
if no radial menu exists.
Expand Down
20 changes: 2 additions & 18 deletions TemplePlus/ui/ui_item_creation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -550,25 +550,9 @@ uint32_t ItemCreationBuildRadialMenuEntry(DispatcherCallbackArgs args, ItemCreat
{
if (combatSys.isCombatActive()) { return 0; }
MesLine mesLine;
RadialMenuEntry radmenu;
mesLine.key = combatMesLine;
mesFuncs.GetLine_Safe(*combatSys.combatMesfileIdx, &mesLine);
//RadialMenuStructInit(&radmenu);
radmenu.text = (char*)mesLine.value;
//radmenu.field0 = (void*)mesLine.value;
RadialMenuEntryAction radEntry(combatMesLine, D20A_ITEM_CREATION, itemCreationType, helpSystemString);
radEntry.AddChildToStandard(args.objHndCaller, RadialMenuStandardNode::Feats);

radmenu.d20ActionType = D20A_ITEM_CREATION;
//radmenu.field20 = 37;

radmenu.d20ActionData1 = itemCreationType;
//radmenu.field24 = itemCreationType;

radmenu.helpId = templeFuncs.StringHash(helpSystemString);
//radmenu.field40 = templeFuncs.StringHash(helpSystemString);

radialMenus.AddChildNode(args.objHndCaller, &radmenu, radialMenus.GetStandardNode(RadialMenuStandardNode::Feats));
//radialFuncs.RadialMenuCreateEntry(args.objHndCaller, &radmenu , radialFuncs.RadialMenuArgMap_sub_100F12B0(3) ) ;

return 0;
};

Expand Down

0 comments on commit e02bcd0

Please sign in to comment.