Jump to content

Recommended Posts

Posted (edited)

Hello!

I was looking through the src and stumbled upon this:

#ifndef RENEWAL
if( sc->data[SC_ASSUMPTIO] ) {
if( map_flag_vs(bl->m) )
damage = (int64)damage*2/3; //Receive 66% damage
else
damage >>= 1; //Receive 50% damage
}
#endif

So why not divide the damage by 3, then multiply it by 2? this way a 64 bit int woulnd't be required.

#ifndef RENEWAL
if( sc->data[SC_ASSUMPTIO] ) {
if( map_flag_vs(bl->m) )
damage = damage/3*2; //Receive 66% damage
else
damage >>= 1; //Receive 50% damage
}
#endif
Edited by Jeroen
Posted (edited)

 

Hello!

I was looking through the src and stumbled upon this:

#ifndef RENEWAL
if( sc->data[SC_ASSUMPTIO] ) {
if( map_flag_vs(bl->m) )
damage = (int64)damage*2/3; //Receive 66% damage
else
damage >>= 1; //Receive 50% damage
}
#endif

So why not divide the damage by 3, then multiply it by 2? this way a 64 bit int woulnd't be required.

#ifndef RENEWAL
if( sc->data[SC_ASSUMPTIO] ) {
if( map_flag_vs(bl->m) )
damage = damage/3*2; //Receive 66% damage
else
damage >>= 1; //Receive 50% damage
}
#endif

 

Dividing by 3 would make it a double which is 8 Byte = 64Bit. Same size.

Edited by Jonne
Posted

 

 

Dividing by 3 would make it a double which is 8 Byte = 64Bit. Same size.

 

 

Er, it's integer division, so it wouldn't be made into a double precision floating point number. It will still be 64 bits because damage itself is declared as an int64 though, so it's kinda moot. Why is that cast even there?

Posted

 

 

 

Dividing by 3 would make it a double which is 8 Byte = 64Bit. Same size.

 

 

Er, it's integer division, so it wouldn't be made into a double precision floating point number. It will still be 64 bits because damage itself is declared as an int64 though, so it's kinda moot. Why is that cast even there?

 

Oh yea, that might be. Maybe it gave warnings on some compiler systems? Dunno

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...