Jump to content

Assumptio Calculation


Ajjwidjdneidjenw

Recommended Posts


  • Group:  Members
  • Topic Count:  15
  • Topics Per Day:  0.00
  • Content Count:  161
  • Reputation:   31
  • Joined:  12/06/11
  • Last Seen:  

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
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  5
  • Topics Per Day:  0.00
  • Content Count:  149
  • Reputation:   33
  • Joined:  12/24/11
  • Last Seen:  

 

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
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  3
  • Topics Per Day:  0.00
  • Content Count:  52
  • Reputation:   6
  • Joined:  01/06/12
  • Last Seen:  

 

 

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?

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  5
  • Topics Per Day:  0.00
  • Content Count:  149
  • Reputation:   33
  • Joined:  12/24/11
  • Last Seen:  

 

 

 

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

Link to comment
Share on other sites

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.

×
×
  • Create New...