- How come that under debugger spell reflection code works perfectly and gets bugged when executed normally.
Are you using IDA? I'm not familiar with the OnFocus() code, but there may be some graphical changes or other wacky stuff going on when you lose/regain focus of the main window. I've had the game crash on me sometimes when switching back to the game window due to some sound code issues.
- Minor issue, but is it possible to fix that halo which is supposed to appear when reflecting spells?
Don't know what this is. I haven't had any time to look at the issue overall yet, so reading your progress is interesting.
the problem is that function(464BFB) runs way too often, because it is fired for every creature. So i find it hard to debug the one fired for an exact character who should actually reflect the spell.
Question: do you(asc64, probably i'm asking you : D) do you know what that function(464BFB) is? Probably it is some kind of CCreature::UpdateAI or something. If so, what is in this CCreature with 12 offset? How often is that UpdateAI fired and under which circumstances?
464BFB void CProtectedSplList::Update(CCreatureObject&)
It is called during 88BFE3 CCreatureObject::AIUpdate(), pretty much exclusively. Can't remember what it does, been a while since I looked at that proc. AI update is performed every tick if I remember correctly (15 ticks [also called AI updates] to one second)
If the process runs without a bug under debugger and with it if executed normally, I can try and run it as if it was started with debugger attached. The only difference I know that causes such behavior is that debugger overrides global memory allocation procedures(malloc? VirtualAlloc?) with its own. If we assume that those debugger allocators set blocks of allocated memory to zeros, it can change behavior of running program if the memory is broken somewhere(uninitialized variable in heap?). So what if we try and replace current allocator(A50608) with our own, that will force all allocated memory to zero values?
We can also set the allocated memory to values like 0xcdcdcdcd so that such errors may be easily tracked(memory access breakpoints on "read" from block 0xcdcdcdcd). What do you say? Is it possible to replace global memory allocator? Is it worth trying?
TobEx tries to use the embedded memory allocator whenever new resources are added to the game, especially instances that TobEx doesn't remove later. Saved me problems of dealing with more than one heap space. Local instances are still handled in TobEx.dll heap space. Confusing, I know. Maybe there is a better way to do this.
There were some compilation errors(MSVS 2010 professional, tobex 0.20):
void* IECPtrList::GetHead() const { return (*this).ToCPtrList().GetHead(); }
cptrlistex.cpp(54): error C2440: 'return' : cannot convert from 'const void *' to 'void *' Conversion loses qualifiers
And a few similar methods. I have fixed them simply commenting. they still persist in v0.22, check it out.
When compiled in debug, it says:
Debug(): CBaldurChitin has incorrect size 0x724C (expected 0x720C)
and same for CTlkTbl
then program fails without any messages. i have managed to attach a debugger to tobex.dll, and it seems that crash occurs in CRuleTable.
maybe it's because i am using headers and libs from detoured 3.0(i have somehow failed to compile 2.1)? if i do not add any patches/hooks at all(comment all of them), BG still crashes when i try to load a game. that's a shame, but because of these errors i cannot test my nullifying allocator.
is it safe to take tobex.dll and tobexloader.exe from version 22 and test them or should i stick to v20 i'm currently using(with bwp 9.10)? i have tried updating current tobex 0.20 to version 0.22 via setup-tobex, but it attempted to install/reinstall a few millions of other mods and failed somewhere in the middle lol. of course i have a backup, so that's no problem.
Are you compiling under MFC4.2 libraries? Newer version of the library have lots of changes to structs and stuffs the whole thing up. I spent a huge amount of time wrestling with this, since it also appears that the libraries I am using have slightly different code from that statically linked to BGMain. I haven't worked out exactly which MFC4.2 build it is using.
TobEx 0022 uses Detours Express 3.0, so you can simply slot that in. Probably better to use the most current revision anyway. Can you understand
WeiDU code? If you can, you can manually update. Copy over the new TobEx.dll and make any changes as specified in the TobEx.tpa for an update.
If it is CTlkTbl size that is incorrect causing CBaldurChitin size to be wrong, it could be some of the vector objects being the wrong size in your MFC version you are trying to statically link. CMapPtrToString and such.
Edited by Ascension64, 30 December 2011 - 08:51 PM.