On about 20% of the users. they receive a OverFLow error. I cant figure out what is causing the overflow error as it does not happen to me. heres the code where the overflow error occurs.
everything is long accept x and y singles for storing the POS of the tiles.
rest of code in next postCode:Private Type TLVERTEX
X As Single
Y As Single
z As Single
rhw As Single
color As Long
specular As Long
tu As Single
tv As Single
End Type
Private Type TileStorage
X As Single
Y As Single
trigger As String
Objects() As Single
TileRefNum As Long
TextureRefNum As Long
Used As Boolean
color As Long
XSector As Long
YSector As Long
End Type
Dim TilesLayer1() As TLVERTEX
Dim TilesLayer2() As TLVERTEX
Dim TilesLayer3() As TLVERTEX
Dim TilesLayer4() As TLVERTEX
Dim TilesLayer5() As TLVERTEX
Dim CurrentTile(0 To 3) As TLVERTEX 'square that follows the mouse
Dim LayerTiles1() As TileStorage
Dim LayerTiles2() As TileStorage
Dim LayerTiles3() As TileStorage
Dim LayerTiles4() As TileStorage
Dim LayerTiles5() As TileStorage
Dim Map(0 To 4, 0 To 1039, 0 To 1039) As TileStorage
'array for sorting left to right
Dim lArray() As Long
'Counter for # of tiles depending on layer
Dim TileCounter1 As Long
Dim TileCounter2 As Long
Dim TileCounter3 As Long
Dim TileCounter4 As Long
Dim TileCounter5 As Long
'Counter for # of textures depending on layer
Dim TextureCounter As Long
Public Sub PlaceTileWithoutCheck(x1 As Single, x2 As Single, x3 As Single, x4 As Single, y1 As Single, y2 As Single, y3 As Single, y4 As Single, Texture As String, TileLayer As Integer, trigger As String, color As Long)
On Error GoTo ErrorHandler:
Dim TilePlacer As Long
Dim GoGood As Boolean
Dim TextureGood As Boolean
Dim SectorX As Long
Dim SectorY As Long
Dim TheX As Long
Dim TheY As Long
Dim i As Long
Dim z As Long
Dim a As Integer
GoGood = True
TextureGood = False
If LCase(Right(Texture, 4)) = ".bmp" Then
'get the sector that the tile is placed in
SectorX = Int((x1 + XPixelDiff) / 480) + SectorXOffset
SectorY = Int((y1 + YPixelDiff) / 480) + SectorYOffset
TheX = (x1 + XPixelDiff) / 32
TheY = (y1 + YPixelDiff) / 32
'if sector = 0 force to be sector1
If SectorX = 0 Then
SectorX = 1
End If
'if sector = 0 force to be sector1
If SectorY = 0 Then
SectorY = 1
End If
'if xsector > xmax sector, set new max sector
If SectorX > MaxXSector Then
MaxXSector = SectorX
End If
'if ysector > ymax sector set new max sector
If SectorY > MaxYSector Then
MaxYSector = SectorY
End If
'if TileLayer is 5,
If TileLayer = 5 Then
'increase TextureCounter. one texture per Vertex.
'increase Textures.
TextureCounter5 = TextureCounter5 + 1
ReDim Preserve TheTextures5(TextureCounter5)
'if first texture used
If TextureCounter = -1 Then
'increase textureCounter
'increase textures, thetextures
TextureCounter = TextureCounter + 1
ReDim Preserve Textures(TextureCounter)
ReDim Preserve TheTextures(TextureCounter)
'store texture, set texture name, and texture refrence number
Set Textures(TextureCounter) = D3DX.CreateTextureFromFileEx(D3DDevice, Texture, PicSizer.Width, PicSizer.Height, D3DX_DEFAULT, 0, D3DFMT_UNKNOWN, D3DPOOL_MANAGED, D3DX_FILTER_POINT, D3DX_FILTER_POINT, ColorKeyVal, ByVal 0, ByVal 0)
TheTextures(TextureCounter) = Texture
TheTextures5(TextureCounter5) = TextureCounter
'if not first texture used
Else
'loop threw all textures used
For a = LBound(TheTextures()) To UBound(TheTextures())
'check if texture is allready in memory
If TheTextures(a) = Texture Then
'store texture refrence number
TheTextures5(TextureCounter5) = a
TextureGood = True
Exit For
End If
Next a
'if texture not in memory
If Not TextureGood Then
'increase texturecounter
TextureCounter = TextureCounter + 1
ReDim Preserve Textures(TextureCounter)
ReDim Preserve TheTextures5(TextureCounter5)
ReDim Preserve TheTextures(TextureCounter)
'store texture in memory
Set Textures(TextureCounter) = D3DX.CreateTextureFromFileEx(D3DDevice, Texture, PicSizer.Width, PicSizer.Height, D3DX_DEFAULT, 0, D3DFMT_UNKNOWN, D3DPOOL_MANAGED, D3DX_FILTER_POINT, D3DX_FILTER_POINT, ColorKeyVal, ByVal 0, ByVal 0)
'store texture name, texture refrence number
TheTextures(TextureCounter) = Texture
TheTextures5(TextureCounter5) = TextureCounter
End If
End If
'Increase Tile Counter & Tile Placer
TileCounter5 = TileCounter5 + 1
TilePlacer = TileCounter5 * 4
'Set the 4 Corners of the square
ReDim Preserve TilesLayer5(TilePlacer + 3)
ReDim Preserve LayerTiles5(TilePlacer + 3)
LayerTiles5(TilePlacer).color = color
LayerTiles5(TilePlacer).trigger = trigger 'set trigger
LayerTiles5(TilePlacer).XSector = SectorX 'set sectors
LayerTiles5(TilePlacer).YSector = SectorY 'set sectors
LayerTiles5(TilePlacer).X = x1
LayerTiles5(TilePlacer).Y = y1
TilesLayer5(TilePlacer) = CreateTLVertex(LayerTiles5(TilePlacer).X, LayerTiles5(TilePlacer).Y, 0, 1, color, 0, 0, 0)
LayerTiles5(TilePlacer + 1).X = x2
LayerTiles5(TilePlacer + 1).Y = y2
TilesLayer5(TilePlacer + 1) = CreateTLVertex(LayerTiles5(TilePlacer + 1).X, LayerTiles5(TilePlacer + 1).Y, 0, 1, color, 0, 1, 0)
LayerTiles5(TilePlacer + 2).X = x3
LayerTiles5(TilePlacer + 2).Y = y3
TilesLayer5(TilePlacer + 2) = CreateTLVertex(LayerTiles5(TilePlacer + 2).X, LayerTiles5(TilePlacer + 2).Y, 0, 1, color, 0, 0, 1)
LayerTiles5(TilePlacer + 3).X = x4
LayerTiles5(TilePlacer + 3).Y = y4
TilesLayer5(TilePlacer + 3) = CreateTLVertex(LayerTiles5(TilePlacer + 3).X, LayerTiles5(TilePlacer + 3).Y, 0, 1, color, 0, 1, 1)
