-
Notifications
You must be signed in to change notification settings - Fork 7
Failed or given up attempts
In my search for new things to hooks, I made some attempts to study and possibly hook some functions that seemed promising, but then gave up, for various reasons. In this article, I will list most of those attempts and give some info about their status:
004679A0 buildingAddon
Helper: Bool32 buildingAddon(CUnit* unit, u32 hpGain, u32 someFlag)
I may be able to make the code, the function was studied properly, the main issue is that despite the name mentioning Addon, this can be used to build buildings, but also units, so the problem is in which file put the code.
u32 function_00473FB0(CUnit* unit, u32 playerId, int x, int y, u32 unitId, u32 unk1, u32 unk2, u32 unk3, u32 unk4);
void placebuildingRefineryCheck(CUnit* unit); //0048E1E0
void doPlacebuildingChecking(CUnit* unit); //0048E210
void placebuildingNormalProc(); //0048E490
void pracebuildingProc(); //0048E6E0
void issuePlacebuildingOrder(u8 buildOrderId, u32 unitToBuildId); //0048E730
Those were actually hooked in the IncompleteExperimental branch under hooks/interface/place_building hooks.
I just threw around all functions around a certain theme, without being 100% sure it would work properly, and there may have been other reasons I didn't want to mix them with the rest of the code back then.
I don't know if those functions would still work (due to changes to scbwdata.h and other stuffs), or if I will try to take some or all their content into the official branch one day, but it isn't planned at this time.
004967E0 centerviewUnitGroup
According to my notes, it seems I failed to implement this so badly I didn't even keep even a partial attempt of translating the code.Maybe the name is wrong and thus don't help to understand the code doing something different, but I'm not sure anymore.
CreateInitialTeamMeleeUnits
Such a function could have existed (in hooks/create_init_units), but since I had no way to test it, I dropped it.And since the name isn't the official one from my reference file, I even lost the address at which it would exist, and I didn't keep the attempt to translate the code either.
004BB600 SetCooperativeLevel
Useless. The function manipulate unknown objects, but it still seems obvious it doesn't do what the name suggest.
I still keep the code analysis just in case, but I doubt there would be any use to hook that even if the objects it use were identified.
void updateButtonSet_Sub458E90(CUnit* unit);
May be to refresh the button of the current order.A call to this was found nowhere.That function has been deemed as not useful, but I have the code analysis available if needed.
void updateButtonSet_Sub458EF0(u32 unknown_argument);
May be to display an icon and text?Attempt to convert it into code failed, troublesome code like add esp
appeared.My code analysis of it got stopped, so even an attempt to make a partial hook on just a part of the function could be difficult since I could not follow the context.
void updateButtonSet_Sub459150(char* message, u16 value_to_insert);
Issue identical as the previous function.
void updateButtonSet_Sub459770();
Probably related to the mouse and its position relative to the dialog.Maybe define which dialog is under the mouse?
Code analysis is old and not very helpful, but from it, it doesn't seem the function would be very useful.
void updateButtonSet_Sub4593A0(BinDlg* dialog, BinDlg* anotherDialog);
Maybe swapping on/off button ?Also deal with upgrade (shield/armor/offense) button.
It seems I dropped it in the past due to my lack of knowledge in switch code.
The code analysis is incomplete, but the function probably would not be useful.
void disconnectAddOn_Sub464930(CUnit* unit);
Based on code analysis, it didn't seem useful to have a hook for it.
bool ordersSpell_Sub_4926D0(CUnit* unit, u8 techId, u16* techEnergyCost, u32 sightRange,u32 stat_txt_tbl_index);
Use a lot stat_txt_tbl stuff, some asm seemed hard to deal with at the time, but it probably mainly deal with failed attempts to use a spell, with the failure being decided elsewhere, so probably not useful.
void RemoveUnitRefsFromTarget(CUnit* unit, CUnit* target);
Based on code analysis, a hook should not be useful.If the function effect is needed but may not be enough, would be better to call the helper then add the code performing additional removals after the call to the helper.
Code analysis available if needed.
void ordersRescuePassive(CUnit* unit); //4A1EF0
I got interested in that mechanism in the past, but ended up dropping it.The old code analysis is available if I try again in the future, though I would probably rewrite it all.
void changeUnitButtonSet(CUnit* unit, u16 buttonSetId); //4E5D60
That function perform some checks that may cancel the change, but it probably isn't useful enough to hook.
The code is available if needed.
void hideAndDisableUnit(CUnit* unit); //4E6340
void showAndEnableUnit(CUnit* unit); //4E6490
Probably more useful as helpers than dissected into hooks.Code analysis partially available.
void setNextWaypoint_Sub4EB290(CUnit* unit); //4EB290
Old analysis deemed it not useful enough to be hooked.
void unitSetRetreatPoint(CUnit* unit, u8 angleValue); //4011A0
bool getCloserToDestination_sub402BE0(CUnit* unit); //402BE0
bool checkForCloseUnit_sub464290(CUnit* unit); //464290
Used in siege transform. Deemed not useful enough to be hooked back then, but code analysis should still be available.
Old unit_morph hooks
Old building_morph hooks
Those hooks moved into the unhooked folder during Update 3.999 should have most if not all their features covered by the other existing hooks.If not all, I should definitely have tried to fix it back then, meaning if something is missing, it would probably have been tried and given up.
Unlike other entries in this list, it may be more likely that I could work on a missing feature from old version, but of course only if it's neither covered by an existing hook, nor part of a function in this list.
00423F70 BTNSACT_UseTech
00424440 BTNSACT_Move
0048CAF0 issueTriTargetOrder
Given up as those functions do little, and are before the order is broadcast to all players, meaning it would be likely to cause desync.The RECV functions are more reliable for modding, and are more likely to have what a modder is looking for.
0043F320 ParasiteHit
Based on the name, one could believe this would be a short function that should be hooked in hooks/weapons/wpnspellhit.h but the name is actually wrong.
The actual function is 515 lines of asm code, and obviously, it's not about the parasite spell hitting.
Started a code analysis, but gave up when seeing it wasn't productive.
It is a function that manage some AI action(s).
00466170 sub_466170 void killAllHangarUnits(CUnit* unit);
00468770 sub_468770 void freeResourceContainer(CUnit* resource);
Not hooked but used by hooked function in unit_destructor_special.cpp special case.
0049F4A0 sub_49F4A0 void unitDestructorSpecialHook(CUnit* unit);
Hooked directly in main .cpp file (instead of _inject.cpp file), and use the above unhooked functions in the same .cpp
004568F0 statdata_UnitWireframeUpdate
Studied because a bit of the code was modified in the old building_morph hook.
That hooked code was moved into hooks/interface/wireframe.cpp
The full code of the function was given up (unidentified objects, call to an extern function, and other troublesome stuff were there).
004E6700 orders_NukeTrain
Didn't seem to have a kind of complexity that would make a hook useful to change the behavior, so not hooked.
The studied code is available.
00479410 unreferenced_sub_479410
Investigated because it was just after 00479200 orders_NukeGround
and it is calling it.
Not the only place that call orders_NukeGround so use unknown.
The analyzed code is available if necessary.
Basically the action is "IF a ghost orderTarget is a nuke, perform orders_NukeGround ELSE go idle / next order.
0041C400 void updateDialog(BinDlg* dialog);
Attempt to hook it a long time ago that failed.Maybe would be more successful if tried again with my current knowledge/ability, but would not be that useful as it deal also with stuff outside a game (meaning menus and stuff), and interesting (because more specialized) code would probably be elsewhere.
hooks/orders/research_upgrade_orders.cpp
While I did manage to hook stuff, there's some asm code in the middle of my functions with a comment "code I could not understand enough to convert".
This is definitely a bad thing, the code is probably performing indirectly some basic mathematic tricks not covered directly by an instruction (or optimized).
struct CGame
Analyzed.
Various elements from this structure exist in scbwdata.h.
Deleting them to implement the full structure could be less user-friendly and introduce lots of useless elements that cannot be used for modding and make things more confusing, so wasn't implemented.
Depending on what possible future hooks would need, more elements could be introduced on an individual basis.
struct GameData
struct Got
Analyzed, but not implemented for the same reasons as struct CGame
.
00491C20 secondaryOrd_CloakNearbyUnits
void cloakNearbyUnitsHook(CUnit* cloaker);
Should be properly hooked and working, but there's a gap in analyzed code for some reason, so there's a little risk (unless I just was lazy when I hooked it or double-checked it because I could see without analysis that the C code corresponded well enough to the asm code).
00491790 secondaryOrd_Cloak
Not hooked, but the full code was converted instead of being just called in the helper of hooks/cloak_nearby_units.cpp.
00454ED0 void CUnit::reduceDefensiveMatrixHp(s32 amount)
Not hooked because the behavior is basic enough and should not require any modding.
The code is mostly analyzed if needed, though some parts aren't.
00427A80 replayStatBtns
Not hooked, research given up due to weird calculation that could not be understood, and add esp commands may cause trouble too.
00459B00 statbtn_DLG_Interact
Not hooked, nothing much happen directly in it, functions called within would be more useful.
Analyzed code is available if needed.
00414C90 sub_414C90
Not hooked nor researched but related to BinDlg and allocate 0x56 of memory, so good to know as a reference for base shape of BinDlg structure.
004C35F0 BINDLG_BlitSurface
Not hooked, some kind of drawing function for dialog components.
The available code analysis maybe will help me to identify some constants or behaviors in/for future hooks.
00418100 registerUserDialogAction
Not hooked as it didn't allow to manipulate things needed for the research at the time.
Code analysis available if needed.
00418EB0 genericDlgInteract
00418C40 genericCommonInteract
Only studied in the context of InitializeDialog and Extended Button Set research.
Code analysis incomplete, and what was done rely on an implementation of data related to the research at the time, and not generic enough to be usable if there was an attempt to hook it.
00459B90 load_statbtn_BIN
Not hooked due to add esp
code (related to sprintf_s
), but also for a jump in a function invoked in a full game crash (probably not a good idea to hook something like that).
Incomplete code analysis available.
00458B30 sub_458B30 (statBtn_dlg_CharPress?)
Not hooked due to the use of an unknown structure, the use of add esp
code, and the fact that the function don't write anything directly (thus editing it would probably change nothing).
Any effect the function would have would come from a call to sub_417EB0
or dialog->fxnInteract
.
May have a return value (0 or result of fxnInteract).
0048E190 cmdRECV_PlaceBuilding
Not hooked since do almost nothing and everything significant happen in cmdRECV_PlaceBuildingAddon
and cmdRECV_PlaceBuildingNormal
that are hooked.