willunited Posted August 30, 2012 Author Share Posted August 30, 2012 If you withdraw a high number of item,you get subscript out of range.Ex:Withdraw 19320809813 Gold. Link to comment Share on other sites More sharing options...
Ruins of Hell Posted August 30, 2012 Share Posted August 30, 2012 Similiar topic is here: [http://www.touchofde…s-of-my-money/.](http://www.touchofdeathforums.com/community/index.php?/topic/128955-engine-is-jealous-of-my-money/.)Eclipse does have a small problem with overflow. Here's a fix which will **STOP** the player from gaining gold after a certain amount. Note that it will not put the overflow into another stack, which would be a better idea.* * *Server-sideAdd (anywhere):```' Returns 0, if there is no overflow, or the overflow, if one exists. 'Public Function AddCheckOverflow(ByVal a As Currency, ByVal b As Currency) As Long ' Currency is 8 bytes, as opposed to Long's 4 bytes. '' If a + b > 2147483647 Then ' 2147483647 = 2**31 - 1 ' AddCheckOverflow = CLng((a - 2147483647) + ![B)](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/cool.png) Else AddCheckOverflow = 0 End IfEnd Function```Then replace Function GiveInvItem with the following function:```Function GiveInvItem(ByVal index As Long, ByVal itemnum As Long, ByVal ItemVal As Long, Optional ByVal sendUpdate As Boolean = True) As Boolean Dim i As Long ' Check for subscript out of range If IsPlaying(index) = False Or itemnum <= 0 Or itemnum > MAX_ITEMS Then GiveInvItem = False Exit Function End If i = FindOpenInvSlot(index, itemnum) ' Check to see if inventory is full If i <> 0 Then If AddCheckOverflow(GetPlayerInvItemValue(index, i), ItemVal) <> 0 Then ItemVal = 2147483647 - GetPlayerInvItemValue(index, i) End If Call SetPlayerInvItemNum(index, i, itemnum) Call SetPlayerInvItemValue(index, i, GetPlayerInvItemValue(index, i) + ItemVal) If sendUpdate Then Call SendInventoryUpdate(index, i) GiveInvItem = True Else Call PlayerMsg(index, "Your inventory is full.", BrightRed) GiveInvItem = False End IfEnd Function```There are probably more errors like this. Link to comment Share on other sites More sharing options...
Joyce Posted August 31, 2012 Share Posted August 31, 2012 Not necessarily an error, just people being silly and not understanding the bounds of a LONG value and various other ones(And nobody ever implementing a proper solution, but then again why would you ever have such abysmal amounts of gold in your game?). Link to comment Share on other sites More sharing options...
Dawntide Posted August 31, 2012 Share Posted August 31, 2012 Soul it is not working. MAX_LONG was undefined, i defined it in modConstants server side.I am getting the overflow error at picking up currency from map, so how to fix it?If i paste the same code into "Sub PlayerMapGetItem(ByVal index As Long)" i get undefined ItemVal error Link to comment Share on other sites More sharing options...
Ruins of Hell Posted August 31, 2012 Share Posted August 31, 2012 > Soul it is not working. MAX_LONG was undefined, i defined it in modConstants server side.Sorry about that, I thought I changed it everywhere but I must have missed that one spot.> If i paste the same code into "Sub PlayerMapGetItem(ByVal index As Long)" i get undefined ItemVal errorYou can't just copy and paste it around, it's not a general solution. Also all of these checks should be done server-side.Anyway, in PlayerMapGetItem server-side, change:``` Call SetPlayerInvItemValue(index, n, GetPlayerInvItemValue(index, n) + MapItem(mapNum, i).Value)```to:``` If AddCheckOverflow(GetPlayerInvItemValue(index, n), MapItem(mapNum, i).Value) = 0 Then Call SetPlayerInvItemValue(index, n, GetPlayerInvItemValue(index, n) + MapItem(mapNum, i).Value) Else Call SetPlayerInvItemValue(index, n, 2147483647) End If```* * *So here's a generalization.Change:```Call SetPlayerInvItemValue(index, n, a + ![B)](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/cool.png)```to:```If AddCheckOverflow(GetPlayerInvItemValue(index, n), MapItem(mapNum, i).Value) = 0 Then Call SetPlayerInvItemValue(index, n, a + ![B)](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/cool.png)Else Call SetPlayerInvItemValue(index, n, 2147483647)End If```* * *> Not necessarily an error, just people being silly and not understanding the bounds of a LONG value and various other ones(And nobody ever implementing a proper solution, but then again why would you ever have such abysmal amounts of gold in your game?).I agree, but the engine should always be fool-proof, and not crash if someone was to manage to somehow exploit the game to gain that much gold, or if someone decides to add too much gold. Link to comment Share on other sites More sharing options...
Joyce Posted August 31, 2012 Share Posted August 31, 2012 I guess, one would assume they would have at least added a currency cap by default I suppose. Link to comment Share on other sites More sharing options...
Whackeddie99 Posted September 4, 2012 Share Posted September 4, 2012 > but then again why would you ever have such abysmal amounts of gold in your game?).2,147,483,6472.1 Bil? I know runescape players with 1 Trillion. The truth is, the higher the number, it makes the player feel rich, and sends a subliminal message that makes them want to play more. That's why you would have such abysmal amounts of gold ^-^ Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now