|
-
Apr 24th, 2005, 06:41 PM
#1
Thread Starter
Fanatic Member
OverFlow Error
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.
Code:
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)
rest of code in next post
-
Apr 24th, 2005, 06:41 PM
#2
Thread Starter
Fanatic Member
Re: OverFlow Error
Code:
'tileLayer is 4(Layer we are working with)
ElseIf TileLayer = 4 Then
'increase TextureCounter. one texture per Vertex.
'increase Textures.
TextureCounter4 = TextureCounter4 + 1
ReDim Preserve TheTextures4(TextureCounter4)
'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
TheTextures4(TextureCounter4) = 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
TheTextures4(TextureCounter4) = 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 TheTextures4(TextureCounter4)
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
TheTextures4(TextureCounter4) = TextureCounter
End If
End If
'Increase Tile Counter & Tile Placer
TileCounter4 = TileCounter4 + 1
TilePlacer = TileCounter4 * 4
'Set the 4 Corners of the square
ReDim Preserve TilesLayer4(TilePlacer + 3)
ReDim Preserve LayerTiles4(TilePlacer + 3)
LayerTiles4(TilePlacer).color = color
LayerTiles4(TilePlacer).trigger = trigger 'set trigger
LayerTiles4(TilePlacer).XSector = SectorX 'set sectors
LayerTiles4(TilePlacer).YSector = SectorY 'set sectors
LayerTiles4(TilePlacer).X = x1
LayerTiles4(TilePlacer).Y = y1
TilesLayer4(TilePlacer) = CreateTLVertex(LayerTiles4(TilePlacer).X, LayerTiles4(TilePlacer).Y, 0, 1, color, 0, 0, 0)
LayerTiles4(TilePlacer + 1).X = x2
LayerTiles4(TilePlacer + 1).Y = y2
TilesLayer4(TilePlacer + 1) = CreateTLVertex(LayerTiles4(TilePlacer + 1).X, LayerTiles4(TilePlacer + 1).Y, 0, 1, color, 0, 1, 0)
LayerTiles4(TilePlacer + 2).X = x3
LayerTiles4(TilePlacer + 2).Y = y3
TilesLayer4(TilePlacer + 2) = CreateTLVertex(LayerTiles4(TilePlacer + 2).X, LayerTiles4(TilePlacer + 2).Y, 0, 1, color, 0, 0, 1)
LayerTiles4(TilePlacer + 3).X = x4
LayerTiles4(TilePlacer + 3).Y = y4
TilesLayer4(TilePlacer + 3) = CreateTLVertex(LayerTiles4(TilePlacer + 3).X, LayerTiles4(TilePlacer + 3).Y, 0, 1, color, 0, 1, 1)
'tileLayer is 3(Layer we are working with)
ElseIf TileLayer = 3 Then
'increase TextureCounter. one texture per Vertex.
'increase Textures.
TextureCounter3 = TextureCounter3 + 1
ReDim Preserve TheTextures3(TextureCounter3)
'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
TheTextures3(TextureCounter3) = 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
TheTextures3(TextureCounter3) = 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 TheTextures3(TextureCounter3)
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
TheTextures3(TextureCounter3) = TextureCounter
End If
End If
'Increase Tile Counter & Tile Placer
TileCounter3 = TileCounter3 + 1
TilePlacer = TileCounter3 * 4
'Set the 4 Corners of the square
ReDim Preserve TilesLayer3(TilePlacer + 3)
ReDim Preserve LayerTiles3(TilePlacer + 3)
LayerTiles3(TilePlacer).color = color
LayerTiles3(TilePlacer).trigger = trigger 'set trigger
LayerTiles3(TilePlacer).XSector = SectorX 'set sectors
LayerTiles3(TilePlacer).YSector = SectorY 'set sectors
LayerTiles3(TilePlacer).X = x1
LayerTiles3(TilePlacer).Y = y1
TilesLayer3(TilePlacer) = CreateTLVertex(LayerTiles3(TilePlacer).X, LayerTiles3(TilePlacer).Y, 0, 1, color, 0, 0, 0)
LayerTiles3(TilePlacer + 1).X = x2
LayerTiles3(TilePlacer + 1).Y = y2
TilesLayer3(TilePlacer + 1) = CreateTLVertex(LayerTiles3(TilePlacer + 1).X, LayerTiles3(TilePlacer + 1).Y, 0, 1, color, 0, 1, 0)
LayerTiles3(TilePlacer + 2).X = x3
LayerTiles3(TilePlacer + 2).Y = y3
TilesLayer3(TilePlacer + 2) = CreateTLVertex(LayerTiles3(TilePlacer + 2).X, LayerTiles3(TilePlacer + 2).Y, 0, 1, color, 0, 0, 1)
LayerTiles3(TilePlacer + 3).X = x4
LayerTiles3(TilePlacer + 3).Y = y4
TilesLayer3(TilePlacer + 3) = CreateTLVertex(LayerTiles3(TilePlacer + 3).X, LayerTiles3(TilePlacer + 3).Y, 0, 1, color, 0, 1, 1)
rest of code in next post
-
Apr 24th, 2005, 06:42 PM
#3
Thread Starter
Fanatic Member
Re: OverFlow Error
Code:
'tileLayer is 2(Layer we are working with)
ElseIf TileLayer = 2 Then
'increase TextureCounter. one texture per Vertex.
'increase Textures.
TextureCounter2 = TextureCounter2 + 1
ReDim Preserve TheTextures2(TextureCounter2)
'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
Map(1, TheX, TheY).TextureRefNum = 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
Map(1, TheX, TheY).TextureRefNum = 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 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
Map(1, TheX, TheY).TextureRefNum = TextureCounter
End If
End If
'Increase Tile Counter & Tile Placer
TileCounter2 = TileCounter2 + 1
TilePlacer = TileCounter2 * 4
'Set the 4 Corners of the square
ReDim Preserve TilesLayer2(TilePlacer + 3)
Map(1, TheX, TheY).TileRefNum = TilePlacer
Map(1, TheX, TheY).color = color
Map(1, TheX, TheY).X = x1
Map(1, TheX, TheY).Y = y1
Map(1, TheX, TheY).XSector = SectorX
Map(1, TheX, TheY).YSector = SectorY
Map(1, TheX, TheY).trigger = trigger
Map(1, TheX, TheY).Used = True
TilesLayer2(TilePlacer) = CreateTLVertex(x1, y1, 0, 1, color, 0, 0, 0)
TilesLayer2(TilePlacer + 1) = CreateTLVertex(x2, y2, 0, 1, color, 0, 1, 0)
TilesLayer2(TilePlacer + 2) = CreateTLVertex(x3, y3, 0, 1, color, 0, 0, 1)
TilesLayer2(TilePlacer + 3) = CreateTLVertex(x4, y4, 0, 1, color, 0, 1, 1)
'tileLayer is 1(Layer we are working with)
ElseIf TileLayer = 1 Then
'increase TextureCounter. one texture per Vertex.
'increase Textures.
TextureCounter1 = TextureCounter1 + 1
ReDim Preserve TheTextures1(TextureCounter1)
'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
Map(0, TheX, TheY).TextureRefNum = 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
Map(0, TheX, TheY).TextureRefNum = 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 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
Map(0, TheX, TheY).TextureRefNum = TextureCounter
End If
End If
'Increase Tile Counter & Tile Placer
TileCounter1 = TileCounter1 + 1
TilePlacer = TileCounter1 * 4
'Set the 4 Corners of the square
ReDim Preserve TilesLayer1(TilePlacer + 3)
Map(0, TheX, TheY).TileRefNum = TilePlacer
Map(0, TheX, TheY).color = color
Map(0, TheX, TheY).X = x1
Map(0, TheX, TheY).Y = y1
Map(0, TheX, TheY).XSector = SectorX
Map(0, TheX, TheY).YSector = SectorY
Map(0, TheX, TheY).trigger = trigger
Map(0, TheX, TheY).Used = True
TilesLayer1(TilePlacer) = CreateTLVertex(x1, y1, 0, 1, color, 0, 0, 0)
TilesLayer1(TilePlacer + 1) = CreateTLVertex(x2, y2, 0, 1, color, 0, 1, 0)
TilesLayer1(TilePlacer + 2) = CreateTLVertex(x3, y3, 0, 1, color, 0, 0, 1)
TilesLayer1(TilePlacer + 3) = CreateTLVertex(x4, y4, 0, 1, color, 0, 1, 1)
'end of tilelayers
End If
'end if of texture check
End If
Exit Sub
ErrorHandler:
MsgBox "An error occured in" & vbNewLine & _
"Module: frmMain" & vbNewLine & _
"Procedure: PlaceTileWithoutCheck" & vbNewLine & _
"Error Number: " & Err.Number & vbNewLine & _
"Error Desc: " & Err.description
End Sub
-
Apr 24th, 2005, 06:43 PM
#4
Thread Starter
Fanatic Member
Re: OverFlow Error
or just view all the code at
www.po2.net/temp1/code.txt
-
Apr 24th, 2005, 06:46 PM
#5
Re: OverFlow Error
You know you can upload the project, rather than just code, right? Zip the whole project in a zip file and upload it. I should be able to solve the problem for ya. 
Also, put a comment with an arrow where the overflow is occuring so we know where to look. Posting all this code without verifying where it occured will just get us lost.
-
Apr 24th, 2005, 07:02 PM
#6
Thread Starter
Fanatic Member
Re: OverFlow Error
the thing is i dont know where the error occurs cause it only occurs on certain computers, hence, it doesnt error on my computer but other computers, but I do know it errors in the sub PlaceTileWithoutCheck due to the error message.
code can be downloaded below since its 3mb.
www.po2.net/temp1/NarutoWebEngine.zip
-
Apr 24th, 2005, 07:08 PM
#7
Re: OverFlow Error
Ok I'll download it. To help find where the error occured, first use this sub routine:
VB Code:
Public Sub Write_To_File(File_Path As String, Message As String)
Open File_Path For Append As #1
Print #1, Message
Close #1
End Sub
Then in every sub and function you have in there, you do something like this:
VB Code:
Public Sub Test_Sub()
On Error Goto Error_Handler
'All your code goes here
Exit Sub
Error_Handler:
Write_To_File App.Path & "\Logfile.txt", "An error occured in the Test_Sub()"
End Sub
Or do something with that to where it'll show what line it's occuring on. That I don't know how to do.
Last edited by Jacob Roman; Apr 24th, 2005 at 07:11 PM.
-
Apr 24th, 2005, 07:59 PM
#8
Re: OverFlow Error
The game just goes to fullscreen mode, making my screen all black, and stays like that. So it crashes on my computer.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|