OK i have a 3 classes (Chessboard, NumericBoard, Dictator) and all 3 have one common property... Pieces as PieceListBase (actually each class has a different propert(1 PieceListBase, 1 PieceListNumeric, 1 PieceListGUI) PieceLIstBase is an abstract class that inherits from ArrayList and the other 2 PieceLists inherit from the base
The Dictator takes a PieceListGUI and converts it to a PieceListNumeric
Somehow after i make the conversion the values end up applying to all instances of the PieceList classes.
ie. i'm converting the location value for each piece in the pieceListGUI to a new value and setting PieceListNumeric to my converted class (i use a function to do this)
The values are passed ByVal and i can't seem to find how these values are accumulating like they do... (i end up with an arithmatic overflow eventually)
which FINALLY brings me to my question...
Could the Base Class for my PiecesList have something to do with this? i'm posting some of the code
The overflow occurs in the ConvertToNumeric Function
HEEEEEEEEELP i'm gonna lose my mind
The Dictator takes a PieceListGUI and converts it to a PieceListNumeric
Somehow after i make the conversion the values end up applying to all instances of the PieceList classes.
ie. i'm converting the location value for each piece in the pieceListGUI to a new value and setting PieceListNumeric to my converted class (i use a function to do this)
The values are passed ByVal and i can't seem to find how these values are accumulating like they do... (i end up with an arithmatic overflow eventually)
which FINALLY brings me to my question...
Could the Base Class for my PiecesList have something to do with this? i'm posting some of the code
The overflow occurs in the ConvertToNumeric Function
HEEEEEEEEELP i'm gonna lose my mind
Visual Basic:
'chessboard class
Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)
Dim squareIndex As Short
squareIndex = GetCurrentSquare(e)
myCursor.State = True
mDictator = New MasterDictator(mPieces)
If Not IsNothing(mSquare(squareIndex).Image) AndAlso mDictator.PieceGrabbedIsLegal() Then
myCursor.Image = mSquare(squareIndex).Image
myCursor.Rectangle = New Rectangle(e.X, e.Y, iSize, iSize)
'add previous square variable?
mSquare(squareIndex).Image = Nothing
Me.Refresh()
Else
myCursor.State = False
End If
End Sub
'MasterDictator class
Public Sub New(ByVal hostPieces As PieceListBase)
MyBase.New()
MyBase.Pieces = MyClass.ConvertToNumeric(hostPieces)
End Sub
Private Function ConvertToNumeric(ByVal myPieces As PieceListBase) As PieceListNumeric
'converts the locations of the pieces to the corresponding index of mNumeric.Square(x)
Dim aPiece As Piece
Dim numericPieces As New PieceListNumeric()
For Each aPiece In myPieces
If Not aPiece.Rank = Rank.Abstract Then
aPiece.Location = aPiece.Location + 26 + (4 * ((aPiece.Location \ 8) + 1) - 1)
'what in TARNATION
numericPieces.Add(aPiece)
'numericPieces.Item(aPiece.Index) = aPiece
End If
Next
Return numericPieces
End Function
Last edited by a moderator: