Using the op_active_hand function.

Mulligun

Still Mildly Glowing
I'd like to use the op_active_hand function from the ddraw c++ code itself. The problem is that the function implemented as an inline asm as follows:
Code:
void __declspec(naked) op_active_hand() {
   __asm {
       mov  edx, dword ptr ds:[FO_VAR_itemCurrentItem];
       _J_RET_VAL_TYPE(VAR_TYPE_INT);
//       retn;
   }
}
doesn't return anything (void) while the original vanilla script active_hand function returns just 0 for the left and 1 for the right hand.

My question is why doesn't the c++ op_active_hand function doesn't return the expected value: 0 or 1 (like the active_hand does) and what can i do to make the op_active_hand to return the active hand value. There is an commented out retn instruction as one can see. Can i just comment out that return statement and i get the expected boolean value like in the active_hand form vanilla?
 
Man, if you can't figure it out by yourself, the answer will be useless to you.
If you want to code c++, go and learn it.
 
Man, if you can't figure it out by yourself, the answer will be useless to you.
If you want to code c++, go and learn it.
Thx for Yours "very polite" answer;-)
Can You then tell me why do i receive an error:
Code:
Exception thrown at 0x004674E5 in fallout2.exe: 0xC0000005: Access violation reading location 0x0000001C
when just trying to call the op_active_hand function (inside the C++ code in the ddraw solution)?

And PLEASE, don't tell me just to learn C++, because it's useless and rude option. Just please TRY to help me with the problem! Thx.
 
The most likely cause of the error is the dereference of a null pointer. My guess is that you are violating calling convention. op_active_hand is declared as naked so it does not generate prologue or epilogue. Because of that I have no idea how it should be used. If you just write "op_active_hand();" and game crashes, this is kinda expected behaviour.
Advice to learn C++ is wrong. First you need to learn assembler for x86 and only then learn Microsoft dialect of C++. From you not knowing that return value of function in most cases is stored in EAX register, I can say you are trying to bite a lot more than you can chew.
 
Back
Top