magic/rare DWORD decoding in Classic
#25
hakai_no_tenshi,Apr 18 2003, 05:45 AM Wrote:Hi jarulf,

    I just tried to use the PRNG and it always returned zero ... might it have something to do with

Quote:#pragma warning( disable : 4035 ) // avoids warning for not returning any value
__declspec( naked ) unsigned int __fastcall d2rnd(struct seeddata *ptseed, unsigned int x)
{
__asm
{
push edi;
push esi;
push ebx;
mov edi,edx;
mov esi,ecx;   // no check on pointer!!
test edi,edi;   // check if x>0
jg OK;
xor eax,eax;&nbsp;&nbsp; // return 0 if x <= 0
jmp END;
OK:

You declare x as an unsigned int but test for a negative number ?? Also, i really don't know how to read assembly but why is eax being accessed when nothing has been pushed into it?

--T

edit: Also, would you know how the 32 bit hireling ID works? Apparently, setting this to a random number and correctly setting the other parameters like experience, table index and so on will result in the first mercenary in hireling.txt being chosen with the experience you set.
Ooops, my my, yeah, should probably have been a signed int. I don't think it should matter unless you send really huge values though which is not a good idea anyway.

eax is not beening accessed really, it is set to 0. xor something with itself is a common way to set it to 0 as it will always end up as 0 no matter what it held before.

Are you initializing the seed correctly by the way? If the seed is not initialized to anything (but just 0 or rather two 32 bit zero values), you always get 0 as well. You should always initialize any seed with 666 in the upper 32 bits, just as the game do! I think this might be the error you have.

I have never looked at the ID of the hirelings, sorry.
There are three types of people in the world. Those who can count and those who can't.
Reply


Messages In This Thread
magic/rare DWORD decoding in Classic - by ldw - 02-23-2003, 12:37 PM
magic/rare DWORD decoding in Classic - by Jarulf - 02-24-2003, 09:21 AM
magic/rare DWORD decoding in Classic - by Jarulf - 02-28-2003, 09:15 AM
magic/rare DWORD decoding in Classic - by FoxBat - 03-13-2003, 04:33 PM
magic/rare DWORD decoding in Classic - by Ruvanal - 03-13-2003, 09:44 PM
magic/rare DWORD decoding in Classic - by aurikan - 03-28-2003, 02:42 AM
magic/rare DWORD decoding in Classic - by Jarulf - 03-28-2003, 09:21 AM
magic/rare DWORD decoding in Classic - by Jarulf - 03-30-2003, 08:00 PM
magic/rare DWORD decoding in Classic - by Jarulf - 04-08-2003, 09:08 PM
magic/rare DWORD decoding in Classic - by Jarulf - 04-18-2003, 08:46 AM
magic/rare DWORD decoding in Classic - by Jarulf - 04-18-2003, 06:20 PM
magic/rare DWORD decoding in Classic - by Jarulf - 04-21-2003, 07:56 AM
magic/rare DWORD decoding in Classic - by Jarulf - 03-19-2005, 12:27 PM

Forum Jump:


Users browsing this thread: 2 Guest(s)