mirror of
https://github.com/Xeeynamo/sotn-decomp.git
synced 2024-11-30 08:20:37 +00:00
Adjust func_8011A4D0 to improve readability and symbol (#1124)
While tracking the calling of the weapon functions, I made a neat discovery. func_8011A4D0 is a crucial function at the heart of the game's engine. For every entity which is created by its ID, this function assigns the PfnEntityUpdate function which will run each frame for that entity. If the ID is E0-EC, or F0-FC, it reads a function from a pointer to call. It turns out that the array we were indexing into before is not a real array, because of course it does not have elements below E0. When you take the minimum offsets into consideration, it turns out that these arrays are located precisely where the two weapons (in the player's two hands) are located in memory. Because D_8017A000 and D_8017D000 are Weapon objects, we can't index into them as an array, so I had to do a bit of an ugly cast to a `PfnEntityUpdate*`, unfortunately I don't know a way to do this under our 80-character limit. Neat to discover fake symbols and clean them up, as well as to make it obvious that these two lines are dealing directly with the weapon functions.
This commit is contained in:
parent
4655a247a2
commit
027b108922
@ -107,10 +107,12 @@ void func_8011A4D0(void) {
|
||||
entity->pfnUpdate = g_DraEntityTbl[15];
|
||||
} else if (entityId >= 0xF0) {
|
||||
// Objects F0-FC
|
||||
entity->pfnUpdate = D_8017CC40[entityId];
|
||||
entity->pfnUpdate =
|
||||
((PfnEntityUpdate*)(&D_8017D000))[entityId - 0xF0];
|
||||
} else {
|
||||
// Objects E0-EC
|
||||
entity->pfnUpdate = D_80179C80[entityId];
|
||||
entity->pfnUpdate =
|
||||
((PfnEntityUpdate*)(&D_8017A000))[entityId - 0xE0];
|
||||
}
|
||||
}
|
||||
if ((temp_s2 == 0) || (entity->flags & FLAG_UNK_10000)) {
|
||||
|
@ -825,9 +825,7 @@ extern s8 D_8013B690;
|
||||
extern s32 D_8013B694;
|
||||
extern s32 D_8013B69C;
|
||||
extern PfnEntityUpdate D_8016FCC0[];
|
||||
extern PfnEntityUpdate D_80179C80[];
|
||||
extern Weapon D_8017A000;
|
||||
extern PfnEntityUpdate D_8017CC40[];
|
||||
extern Weapon D_8017D000;
|
||||
extern void (*D_80170000)(s32 arg0);
|
||||
extern ImgSrc* g_imgUnk8013C200;
|
||||
|
Loading…
Reference in New Issue
Block a user