Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Negative Addmoney OverflowException #23

Open
Krilliac opened this issue Feb 9, 2021 · 2 comments
Open

Negative Addmoney OverflowException #23

Krilliac opened this issue Feb 9, 2021 · 2 comments

Comments

@Krilliac
Copy link
Collaborator

Krilliac commented Feb 9, 2021

System.OverflowException
HResult=0x80131516
Message=Value was either too large or too small for a UInt64.
Source=System.Private.CoreLib
StackTrace:
at System.Decimal.ToUInt64(Decimal d)
at System.Convert.ToUInt64(Decimal value)
at Microsoft.VisualBasic.CompilerServices.Conversions.ToULong(String Value)
at Mangos.World.Handlers.WS_Commands.cmdAddMoney(CharacterObject& objCharacter, String tCopper) in D:\USB DRIVE\Work\MangosSharp\MangosSharp\Source\Services\Mangos.World\Handlers\WS_Commands.cs:line 848

@Krilliac
Copy link
Collaborator Author

Krilliac commented Feb 9, 2021

.addmoney command with negative value

@Krilliac Krilliac changed the title OverflowException Negative Addmoney OverflowException Feb 9, 2021
@ephemeron28
Copy link

ephemeron28 commented Aug 4, 2021

The .addmoney command will use the cmdAddMoney method in MangosSharp/Source/Services/Mangos.World/Handlers/WS_Commands.cs, line 852.

In line 859, ulong Copper = Conversions.ToULong(tCopper) is throwing the OverflowException since it parses a negative number in an unsigned data type.

Consider changing the line to ulong Copper = (ulong)Conversions.ToLong(tCopper); , thus using the overflowed number and evading the exception.
This will add no money to the character

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants