Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Fixing CS:DE


Growlith1223
 Share

Recommended Posts

ok so i noticed that Deathbeam was making his as a custom version so im making mine into a tutorial ![:D](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/biggrin.png)

**OPTION 1**

download the source

[http://www.mediafire…r7g14cu4c0w0v7f](http://www.mediafire.com/?r7g14cu4c0w0v7f)

**OPTION 2**

Put the five classes from EN and add them into CS:DE

then

in modDirectX8 Replace the the top with

```

Option Explicit

' **********************

' ** Renders graphics **

' **********************

' DirectX8 Object

Public dX As DirectX8 'The master DirectX object.

Public D3D8 As Direct3D8 'Controls all things 3D.

Public D3DDevice8 As Direct3DDevice8 'Represents the hardware rendering.

Public Direct3DX8 As D3DX8

'The 2D (Transformed and Lit) vertex format.

Public Const FVF_TLVERTEX As Long = D3DFVF_XYZRHW Or D3DFVF_TEX1 Or D3DFVF_DIFFUSE

'The 2D (Transformed and Lit) vertex format type.

Public Type TLVERTEX

X As Single

y As Single

Z As Single

RHW As Single

color As Long

TU As Single

TV As Single

End Type

Private Vertex_List(3) As TLVERTEX '4 vertices will make a square.

'Some color depth constants to help make the DX constants more readable.

Private Const COLOR_DEPTH_16_BIT As Long = D3DFMT_R5G6B5

Private Const COLOR_DEPTH_24_BIT As Long = D3DFMT_A8R8G8B8

Private Const COLOR_DEPTH_32_BIT As Long = D3DFMT_X8R8G8B8

Public RenderingMode As Long

Public D3DWindow As D3DPRESENT_PARAMETERS 'Backbuffer and viewport description.

Public DispMode As D3DDISPLAYMODE

' Graphics Textures

Public Tex_Anim() As DX8TextureRec ' Arrays

Public Tex_Char() As DX8TextureRec

Public Tex_Face() As DX8TextureRec

Public Tex_GUI() As DX8TextureRec

Public Tex_Item() As DX8TextureRec

Public Tex_Paperdoll() As DX8TextureRec

Public Tex_Resource() As DX8TextureRec

Public Tex_Spellicon() As DX8TextureRec

Public Tex_Tileset() As DX8TextureRec

Public Tex_Buttons() As DX8TextureRec

Public Tex_Buttons_h() As DX8TextureRec

Public Tex_Buttons_c() As DX8TextureRec

Public Tex_Fog() As DX8TextureRec

Public Tex_Bars As DX8TextureRec ' Singles

Public Tex_Blood As DX8TextureRec

Public Tex_Direction As DX8TextureRec

Public Tex_Misc As DX8TextureRec

Public Tex_Target As DX8TextureRec

Public Tex_Shadow As DX8TextureRec

Public Tex_Fader As DX8TextureRec

Public Tex_Tile As DX8TextureRec

' Surfaces

Public Tex_Surface() As DX8TextureRec

Public Count_Surface As Long

' Texture count

Public NumAnimations As Long

Public NumCharacters As Long

Public NumFaces As Long

Public NumGUIs As Long

Public numitems As Long

Public NumPaperdolls As Long

Public NumResources As Long

Public NumSpellIcons As Long

Public NumTileSets As Long

Public NumFogs As Long

Public NumButtons As Long

Public NumButtons_c As Long

Public NumButtons_h As Long

'Public BackBuffer As Direct3DSurface8

'Public Const FVF As Long = D3DFVF_XYZRHW Or D3DFVF_TEX1 Or D3DFVF_DIFFUSE

'Public Const FVF_Size As Long = 28

Public gTexture() As GlobaltextureRec

Private Const TEXTURE_NULL As Long = 0

Public Type DX8TextureRec

Texture As Long

width As Long

height As Long

Path As String

TexWidth As Long

TexHeight As Long

ImageData() As Byte

HasData As Boolean

End Type

Private Type GlobaltextureRec

Texture As Direct3DTexture8

TexWidth As Long

TexHeight As Long

Loaded As Boolean

UnloadTimer As Long

Path As String

End Type

Public Type RECT

Top As Long

Left As Long

Bottom As Long

Right As Long

End Type

Private Type D3DXIMAGE_INFO_A

width As Long

height As Long

Depth As Long

MipLevels As Long

Format As CONST_D3DFORMAT

ResourceType As CONST_D3DRESOURCETYPE

ImageFileFormat As Long

End Type

Public NumTextures As Long

```

Delete all the things that relate to InitDX8 with

```

' ********************

' ** Initialization **

' ********************

Public Function InitDX8() As Boolean

' If debug mode, handle error then exit out

If Options.Debug = 1 Then On Error GoTo ErrorHandler

Set dX = New DirectX8 'Creates the DirectX object.

Set D3D8 = dX.Direct3DCreate() 'Creates the Direct3D object using the DirectX object.

Set Direct3DX8 = New D3DX8

D3D8.GetAdapterDisplayMode D3DADAPTER_DEFAULT, DispMode 'Use the current display mode that you

'are already on. Incase you are confused, I'm

'talking about your current screen resolution. ![;)](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/wink.png)

D3Dwindow.Windowed = True 'The app will be in windowed mode.

D3Dwindow.SwapEffect = D3DSWAPEFFECT_DISCARD 'Refresh when the monitor does.

D3Dwindow.BackBufferFormat = DispMode.Format 'Sets the format that was retrieved into the backbuffer.

'Creates the rendering device with some useful info, along with the info

'DispMode.Format = D3DFMT_X8R8G8B8

D3Dwindow.SwapEffect = D3DSWAPEFFECT_COPY

D3Dwindow.BackBufferCount = 1 '1 backbuffer only

D3Dwindow.BackBufferWidth = 800 ' frmMain.picScreen.ScaleWidth 'Match the backbuffer width with the display width

D3Dwindow.BackBufferHeight = 600 'frmMain.picScreen.ScaleHeight 'Match the backbuffer height with the display height

D3Dwindow.hDeviceWindow = frmMain.hWnd 'Use frmMain as the device window.

'we've already setup for Direct3D_window.

If TryCreateDirectX8Device = False Then

MsgBox "Unable to initialize DirectX8\. You may be missing dx8vb.dll or have incompatible hardware to use DirectX8."

DestroyGame

End If

With D3DDevice8

.SetVertexShader D3DFVF_XYZRHW Or D3DFVF_TEX1 Or D3DFVF_DIFFUSE

.SetRenderState D3DRS_LIGHTING, False

.SetRenderState D3DRS_SRCBLEND, D3DBLEND_SRCALPHA

.SetRenderState D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA

.SetRenderState D3DRS_ALPHABLENDENABLE, True

.SetRenderState D3DRS_FILLMODE, D3DFILL_SOLID

.SetRenderState D3DRS_CULLMODE, D3DCULL_NONE

.SetRenderState D3DRS_ZENABLE, False

.SetRenderState D3DRS_ZWRITEENABLE, False

.SetTextureStageState 0, D3DTSS_ALPHAOP, D3DTOP_MODULATE

.SetRenderState D3DRS_POINTSPRITE_ENABLE, 1

.SetRenderState D3DRS_POINTSCALE_ENABLE, 0

.SetTextureStageState 0, D3DTSS_MAGFILTER, D3DTEXF_POINT

.SetTextureStageState 0, D3DTSS_MINFILTER, D3DTEXF_POINT

End With

' Initialise the surfaces

EngineCacheTextures

' We're done

InitDX8 = True

' Error handler

Exit Function

ErrorHandler:

HandleError "InitDX8", "modGraphics", Err.Number, Err.Description, Err.Source, Err.HelpContext

Err.Clear

InitDX8 = False

Exit Function

End Function

```

add TryCreateDX8Device At the bottom

```

Function TryCreateDirectX8Device() As Boolean

Dim I As Long

On Error GoTo nexti

For I = 1 To 4

Select Case I

Case 1

Set D3DDevice8 = D3D8.CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, frmMain.hWnd, D3DCREATE_HARDWARE_VERTEXPROCESSING, D3DWindow)

TryCreateDirectX8Device = True

Exit Function

Case 2

Set D3DDevice8 = D3D8.CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, frmMain.hWnd, D3DCREATE_MIXED_VERTEXPROCESSING, D3DWindow)

TryCreateDirectX8Device = True

Exit Function

Case 3

Set D3DDevice8 = D3D8.CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, frmMain.hWnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING, D3DWindow)

TryCreateDirectX8Device = True

Exit Function

Case 4

TryCreateDirectX8Device = False

Exit Function

End Select

nexti:

Next

End Function

```

Replace EngineUnloadDirectX with

```

Public Sub EngineUnloadDirectX()

UnloadTextures

Set Direct3DX8 = Nothing

Set D3DDevice8 = Nothing

Set D3D8 = Nothing

Set dX = Nothing

End Sub

```

Replace EngineCacheTextures

```

Public Sub EngineCacheTextures()

Dim I As Long

Call CheckTilesets

Call CheckCharacters

Call CheckPaperdolls

Call CheckAnimations

Call CheckItems

Call CheckResources

Call CheckSpellIcons

Call CheckFaces

Call CheckFogs

Call CheckGUIs

Call CheckSurfaces

Call CheckButtons

Call CheckButtons_h

Call CheckButtons_c

NumTextures = NumTextures + 7

' Single Textures

ReDim Preserve gTexture(NumTextures)

Tex_Bars.Path = App.Path & Path_Graphics & "system\bars.png"

Tex_Bars.Texture = NumTextures - 6

Call LoadTexture(Tex_Bars)

Tex_Direction.Path = App.Path & Path_Graphics & "system\direction.png"

Tex_Direction.Texture = NumTextures - 5

Call LoadTexture(Tex_Direction)

Tex_Misc.Path = App.Path & Path_Graphics & "system\misc.png"

Tex_Misc.Texture = NumTextures - 4

Call LoadTexture(Tex_Misc)

Tex_Target.Path = App.Path & Path_Graphics & "system\target.png"

Tex_Target.Texture = NumTextures - 3

Call LoadTexture(Tex_Target)

Tex_Fader.Path = App.Path & Path_Graphics & "system\fader.png"

Tex_Fader.Texture = NumTextures - 2

Call LoadTexture(Tex_Fader)

Tex_Shadow.Path = App.Path & Path_Graphics & "system\shadow.png"

Tex_Shadow.Texture = NumTextures - 1

Call LoadTexture(Tex_Shadow)

EngineInitFontTextures

End Sub

```

Replace LoadTexture with

```

Function GetNearestPOT(Value As Long) As Long

Dim I As Long

Do While 2 ^ I < Value

I = I + 1

Loop

GetNearestPOT = 2 ^ I

End Function

Public Sub LoadTexture(ByRef TextureRec As DX8TextureRec)

Dim SourceBitmap As cGDIpImage, ConvertedBitmap As cGDIpImage, GDIGraphics As cGDIpRenderer, GDIToken As cGDIpToken, I As Long

Dim newWidth As Long, newHeight As Long, ImageData() As Byte, fn As Long

If Options.Debug = 1 Then On Error GoTo ErrorHandler

If TextureRec.HasData = False Then

Set GDIToken = New cGDIpToken

If GDIToken.Token = 0& Then MsgBox "GDI+ failed to load, exiting game!": DestroyGame

Set SourceBitmap = New cGDIpImage

Call SourceBitmap.LoadPicture_FileName(TextureRec.Path, GDIToken)

TextureRec.width = SourceBitmap.width

TextureRec.height = SourceBitmap.height

'

newWidth = GetNearestPOT(TextureRec.width)

newHeight = GetNearestPOT(TextureRec.height)

If newWidth <> SourceBitmap.width Or newHeight <> SourceBitmap.height Then

Set ConvertedBitmap = New cGDIpImage

Set GDIGraphics = New cGDIpRenderer

I = GDIGraphics.CreateGraphicsFromImageClass(SourceBitmap)

Call ConvertedBitmap.LoadPicture_FromNothing(newHeight, newWidth, I, GDIToken)

Call GDIGraphics.DestroyHGraphics(I)

I = GDIGraphics.CreateGraphicsFromImageClass(ConvertedBitmap)

Call GDIGraphics.AttachTokenClass(GDIToken)

Call GDIGraphics.RenderImageClassToHGraphics(SourceBitmap, I)

Call ConvertedBitmap.SaveAsPNG(ImageData)

GDIGraphics.DestroyHGraphics (I)

TextureRec.ImageData = ImageData

Set ConvertedBitmap = Nothing

Set GDIGraphics = Nothing

Set SourceBitmap = Nothing

Else

Call SourceBitmap.SaveAsPNG(ImageData)

TextureRec.ImageData = ImageData

Set SourceBitmap = Nothing

End If

Else

ImageData = TextureRec.ImageData

End If

Set gTexture(TextureRec.Texture).Texture = Direct3DX8.CreateTextureFromFileInMemoryEx(D3DDevice8, _

ImageData(0), _

UBound(ImageData) + 1, _

newWidth, _

newHeight, _

D3DX_DEFAULT, 0, D3DFMT_UNKNOWN, D3DPOOL_MANAGED, D3DX_FILTER_POINT, D3DX_FILTER_NONE, ByVal (0), ByVal 0, ByVal 0)

gTexture(TextureRec.Texture).TexWidth = newWidth

gTexture(TextureRec.Texture).TexHeight = newHeight

gTexture(TextureRec.Texture).Loaded = True

gTexture(TextureRec.Texture).UnloadTimer = GetTickCount

Exit Sub

ErrorHandler:

HandleError "LoadTexture", "modGraphics", Err.Number, Err.Description, Err.Source, Err.HelpContext

Err.Clear

Exit Sub

End Sub

```

replace UnloadTextures with

```

Public Sub UnloadTextures(Optional ByVal Complete As Boolean = False)

Dim I As Long

' If debug mode, handle error then exit out

On Error Resume Next

If Complete = False Then

For I = 1 To NumTextures

If gTexture(I).UnloadTimer > GetTickCount + 150000 Then

Set gTexture(I).Texture = Nothing

ZeroMemory ByVal VarPtr(gTexture(I)), LenB(gTexture(I))

gTexture(I).UnloadTimer = 0

gTexture(I).Loaded = False

End If

Next

Else

For I = 1 To NumTextures

Set gTexture(I).Texture = Nothing

ZeroMemory ByVal VarPtr(gTexture(I)), LenB(gTexture(I))

Next

ReDim gTexture(1)

For I = 1 To NumTileSets

Tex_Tileset(I).Texture = 0

Next

For I = 1 To numitems

Tex_Item(I).Texture = 0

Next

For I = 1 To NumCharacters

Tex_Char(I).Texture = 0

Next

For I = 1 To NumPaperdolls

Tex_Paperdoll(I).Texture = 0

Next

For I = 1 To NumResources

Tex_Resource(I).Texture = 0

Next

For I = 1 To NumAnimations

Tex_Anim(I).Texture = 0

Next

For I = 1 To NumSpellIcons

Tex_Spellicon(I).Texture = 0

Next

For I = 1 To NumFaces

Tex_Face(I).Texture = 0

Next

For I = 1 To NumGUIs

Tex_GUI(I).Texture = 0

Next

For I = 1 To NumButtons

Tex_Buttons(I).Texture = 0

Next

For I = 1 To NumButtons_c

Tex_Buttons_c(I).Texture = 0

Next

For I = 1 To NumButtons_h

Tex_Buttons_h(I).Texture = 0

Next

Tex_Misc.Texture = 0

Tex_Blood.Texture = 0

Tex_Direction.Texture = 0

Tex_Target.Texture = 0

'Tex_Selection.Texture = 0

Tex_Bars.Texture = 0

'Tex_White.Texture = 0

'Tex_Weather.Texture = 0

Tex_Fader.Texture = 0

Tex_Shadow.Texture = 0

'UnloadFontTextures

End If

' Error handler

Exit Sub

ErrorHandler:

HandleError "UnloadTextures", "modGraphics", Err.Number, Err.Description, Err.Source, Err.HelpContext

Err.Clear

Exit Sub

End Sub

```

Replace RenderTexture with

```

Public Sub RenderTexture(ByRef TextureRec As DX8TextureRec, ByVal dX As Single, ByVal dY As Single, ByVal sX As Single, ByVal sY As Single, ByVal dWidth As Single, ByVal dHeight As Single, ByVal sWidth As Single, ByVal sHeight As Single, Optional color As Long = -1)

Dim TextureNum As Long

Dim textureWidth As Long, textureHeight As Long, sourceX As Single, sourceY As Single, sourceWidth As Single, sourceHeight As Single

SetTexture TextureRec

TextureNum = TextureRec.Texture

textureWidth = gTexture(TextureNum).TexWidth

textureHeight = gTexture(TextureNum).TexHeight

If sY + sHeight > textureHeight Then Exit Sub

If sX + sWidth > textureWidth Then Exit Sub

If sX < 0 Then Exit Sub

If sY < 0 Then Exit Sub

sX = sX - 0.5

sY = sY - 0.5

dY = dY - 0.5

dX = dX - 0.5

sWidth = sWidth

sHeight = sHeight

dWidth = dWidth

dHeight = dHeight

sourceX = (sX / textureWidth)

sourceY = (sY / textureHeight)

sourceWidth = ((sX + sWidth) / textureWidth)

sourceHeight = ((sY + sHeight) / textureHeight)

Vertex_List(0) = Create_TLVertex(dX, dY, 0, 1, color, 0, sourceX + 0.000003, sourceY + 0.000003)

Vertex_List(1) = Create_TLVertex(dX + dWidth, dY, 0, 1, color, 0, sourceWidth + 0.000003, sourceY + 0.000003)

Vertex_List(2) = Create_TLVertex(dX, dY + dHeight, 0, 1, color, 0, sourceX + 0.000003, sourceHeight + 0.000003)

Vertex_List(3) = Create_TLVertex(dX + dWidth, dY + dHeight, 0, 1, color, 0, sourceWidth + 0.000003, sourceHeight + 0.000003)

Call D3DDevice8.SetTexture(0, gTexture(TextureNum).Texture)

D3DDevice8.DrawPrimitiveUP D3DPT_TRIANGLESTRIP, 2, Vertex_List(0), Len(Vertex_List(0))

End Sub

```

Replace SetTexture with

```

Public Sub SetTexture(ByRef TextureRec As DX8TextureRec)

If TextureRec.Texture > NumTextures Then TextureRec.Texture = NumTextures

If TextureRec.Texture < 0 Then TextureRec.Texture = 0

If Not TextureRec.Texture = 0 Then

If Not gTexture(TextureRec.Texture).Loaded Then

Call LoadTexture(TextureRec)

End If

End If

End Sub

```

add

```

Public Sub CheckTilesets()

Dim I As Long

' If debug mode, handle error then exit out

If Options.Debug = 1 Then On Error GoTo ErrorHandler

I = 1

NumTileSets = 1

ReDim Tex_Tileset(1)

While FileExist(GFX_PATH & "tilesets\" & I & GFX_EXT)

ReDim Preserve Tex_Tileset(NumTileSets)

NumTextures = NumTextures + 1

ReDim Preserve gTexture(NumTextures)

Tex_Tileset(NumTileSets).Path = App.Path & GFX_PATH & "tilesets\" & I & GFX_EXT

Tex_Tileset(NumTileSets).Texture = NumTextures

NumTileSets = NumTileSets + 1

I = I + 1

Wend

NumTileSets = NumTileSets - 1

For I = 1 To NumTileSets

LoadTexture Tex_Tileset(I)

Next

' Error handler

Exit Sub

ErrorHandler:

HandleError "CheckTilesets", "modDatabase", Err.Number, Err.Description, Err.Source, Err.HelpContext

Err.Clear

Exit Sub

End Sub

Public Sub CheckCharacters()

Dim I As Long

' If debug mode, handle error then exit out

If Options.Debug = 1 Then On Error GoTo ErrorHandler

I = 1

NumCharacters = 1

ReDim Tex_Char(1)

While FileExist(GFX_PATH & "characters\" & I & GFX_EXT)

ReDim Preserve Tex_Char(NumCharacters)

NumTextures = NumTextures + 1

ReDim Preserve gTexture(NumTextures)

Tex_Char(NumCharacters).Path = App.Path & "\data files\graphics\characters\" & I & ".png"

Tex_Char(NumCharacters).Texture = NumTextures

NumCharacters = NumCharacters + 1

I = I + 1

Wend

NumCharacters = NumCharacters - 1

For I = 1 To NumCharacters

LoadTexture Tex_Char(I)

Next

' Error handler

Exit Sub

ErrorHandler:

HandleError "CheckCharacters", "modDatabase", Err.Number, Err.Description, Err.Source, Err.HelpContext

Err.Clear

Exit Sub

End Sub

Public Sub CheckPaperdolls()

Dim I As Long

' If debug mode, handle error then exit out

If Options.Debug = 1 Then On Error GoTo ErrorHandler

I = 1

NumPaperdolls = 1

ReDim Tex_Paperdoll(1)

While FileExist(GFX_PATH & "paperdolls\" & I & GFX_EXT)

ReDim Preserve Tex_Paperdoll(NumPaperdolls)

NumTextures = NumTextures + 1

ReDim Preserve gTexture(NumTextures)

Tex_Paperdoll(NumPaperdolls).Path = App.Path & GFX_PATH & "paperdolls\" & I & GFX_EXT

Tex_Paperdoll(NumPaperdolls).Texture = NumTextures

NumPaperdolls = NumPaperdolls + 1

I = I + 1

Wend

NumPaperdolls = NumPaperdolls - 1

For I = 1 To NumPaperdolls

LoadTexture Tex_Paperdoll(I)

Next

' Error handler

Exit Sub

ErrorHandler:

HandleError "CheckPaperdolls", "modDatabase", Err.Number, Err.Description, Err.Source, Err.HelpContext

Err.Clear

Exit Sub

End Sub

Public Sub CheckAnimations()

Dim I As Long

' If debug mode, handle error then exit out

If Options.Debug = 1 Then On Error GoTo ErrorHandler

I = 1

NumAnimations = 1

ReDim Tex_Anim(1)

ReDim AnimationTimer(1)

While FileExist(GFX_PATH & "animations\" & I & GFX_EXT)

ReDim Preserve Tex_Anim(NumAnimations)

ReDim Preserve AnimationTimer(NumAnimations)

NumTextures = NumTextures + 1

ReDim Preserve gTexture(NumTextures)

Tex_Anim(NumAnimations).Path = App.Path & GFX_PATH & "animations\" & I & GFX_EXT

Tex_Anim(NumAnimations).Texture = NumTextures

NumAnimations = NumAnimations + 1

I = I + 1

Wend

NumAnimations = NumAnimations - 1

For I = 1 To NumAnimations

LoadTexture Tex_Anim(I)

Next

' Error handler

Exit Sub

ErrorHandler:

HandleError "CheckAnimations", "modDatabase", Err.Number, Err.Description, Err.Source, Err.HelpContext

Err.Clear

Exit Sub

End Sub

Public Sub CheckItems()

Dim I As Long

' If debug mode, handle error then exit out

If Options.Debug = 1 Then On Error GoTo ErrorHandler

I = 1

numitems = 1

ReDim Tex_Item(1)

While FileExist(GFX_PATH & "items\" & I & GFX_EXT)

ReDim Preserve Tex_Item(numitems)

NumTextures = NumTextures + 1

ReDim Preserve gTexture(NumTextures)

Tex_Item(numitems).Path = App.Path & GFX_PATH & "items\" & I & GFX_EXT

Tex_Item(numitems).Texture = NumTextures

numitems = numitems + 1

I = I + 1

Wend

numitems = numitems - 1

For I = 1 To numitems

LoadTexture Tex_Item(I)

Next

' Error handler

Exit Sub

ErrorHandler:

HandleError "CheckItems", "modDatabase", Err.Number, Err.Description, Err.Source, Err.HelpContext

Err.Clear

Exit Sub

End Sub

Public Sub CheckResources()

Dim I As Long

' If debug mode, handle error then exit out

If Options.Debug = 1 Then On Error GoTo ErrorHandler

I = 1

NumResources = 1

ReDim Tex_Resource(1)

While FileExist(GFX_PATH & "resources\" & I & GFX_EXT)

ReDim Preserve Tex_Resource(NumResources)

NumTextures = NumTextures + 1

ReDim Preserve gTexture(NumTextures)

Tex_Resource(NumResources).Path = App.Path & GFX_PATH & "resources\" & I & GFX_EXT

Tex_Resource(NumResources).Texture = NumTextures

NumResources = NumResources + 1

I = I + 1

Wend

NumResources = NumResources - 1

For I = 1 To NumResources

LoadTexture Tex_Resource(I)

Next

' Error handler

Exit Sub

ErrorHandler:

HandleError "CheckResources", "modDatabase", Err.Number, Err.Description, Err.Source, Err.HelpContext

Err.Clear

Exit Sub

End Sub

Public Sub CheckSpellIcons()

Dim I As Long

' If debug mode, handle error then exit out

If Options.Debug = 1 Then On Error GoTo ErrorHandler

I = 1

NumSpellIcons = 1

ReDim Tex_Spellicon(1)

While FileExist(GFX_PATH & "spellicons\" & I & GFX_EXT)

ReDim Preserve Tex_Spellicon(NumSpellIcons)

NumTextures = NumTextures + 1

ReDim Preserve gTexture(NumTextures)

Tex_Spellicon(NumSpellIcons).Path = App.Path & GFX_PATH & "spellicons\" & I & GFX_EXT

Tex_Spellicon(NumSpellIcons).Texture = NumTextures

NumSpellIcons = NumSpellIcons + 1

I = I + 1

Wend

NumSpellIcons = NumSpellIcons - 1

For I = 1 To NumSpellIcons

LoadTexture Tex_Spellicon(I)

Next

' Error handler

Exit Sub

ErrorHandler:

HandleError "CheckSpellIcons", "modDatabase", Err.Number, Err.Description, Err.Source, Err.HelpContext

Err.Clear

Exit Sub

End Sub

Public Sub CheckFaces()

Dim I As Long

' If debug mode, handle error then exit out

If Options.Debug = 1 Then On Error GoTo ErrorHandler

I = 1

NumFaces = 1

ReDim Tex_Face(1)

While FileExist(GFX_PATH & "Faces\" & I & GFX_EXT)

ReDim Preserve Tex_Face(NumFaces)

NumTextures = NumTextures + 1

ReDim Preserve gTexture(NumTextures)

Tex_Face(NumFaces).Path = App.Path & GFX_PATH & "faces\" & I & GFX_EXT

Tex_Face(NumFaces).Texture = NumTextures

NumFaces = NumFaces + 1

I = I + 1

Wend

NumFaces = NumFaces - 1

For I = 1 To NumFaces

LoadTexture Tex_Face(I)

Next

' Error handler

Exit Sub

ErrorHandler:

HandleError "CheckFaces", "modDatabase", Err.Number, Err.Description, Err.Source, Err.HelpContext

Err.Clear

Exit Sub

End Sub

Public Sub CheckFogs()

Dim I As Long

' If debug mode, handle error then exit out

If Options.Debug = 1 Then On Error GoTo ErrorHandler

I = 1

NumFogs = 1

ReDim Tex_Fog(1)

While FileExist(GFX_PATH & "fogs\" & I & GFX_EXT)

ReDim Preserve Tex_Fog(NumFogs)

NumTextures = NumTextures + 1

ReDim Preserve gTexture(NumTextures)

Tex_Fog(NumFogs).Path = App.Path & GFX_PATH & "fogs\" & I & GFX_EXT

Tex_Fog(NumFogs).Texture = NumTextures

NumFogs = NumFogs + 1

I = I + 1

Wend

NumFogs = NumFogs - 1

For I = 1 To NumFogs

LoadTexture Tex_Fog(I)

Next

' Error handler

Exit Sub

ErrorHandler:

HandleError "CheckFogs", "modDatabase", Err.Number, Err.Description, Err.Source, Err.HelpContext

Err.Clear

Exit Sub

End Sub

Public Sub CheckGUIs()

Dim I As Long

' If debug mode, handle error then exit out

If Options.Debug = 1 Then On Error GoTo ErrorHandler

I = 1

NumGUIs = 1

ReDim Tex_GUI(1)

While FileExist(GFX_PATH & "gui\" & I & GFX_EXT)

ReDim Preserve Tex_GUI(NumGUIs)

NumTextures = NumTextures + 1

ReDim Preserve gTexture(NumTextures)

Tex_GUI(NumGUIs).Path = App.Path & GFX_PATH & "gui\" & I & GFX_EXT

Tex_GUI(NumGUIs).Texture = NumTextures

NumGUIs = NumGUIs + 1

I = I + 1

Wend

NumGUIs = NumGUIs - 1

For I = 1 To NumGUIs

LoadTexture Tex_GUI(I)

Next

' Error handler

Exit Sub

ErrorHandler:

HandleError "CheckGUIs", "modDatabase", Err.Number, Err.Description, Err.Source, Err.HelpContext

Err.Clear

Exit Sub

End Sub

Public Sub CheckButtons()

Dim I As Long

' If debug mode, handle error then exit out

If Options.Debug = 1 Then On Error GoTo ErrorHandler

I = 1

NumButtons = 1

ReDim Tex_Buttons(1)

While FileExist(GFX_PATH & "gui\buttons\" & I & GFX_EXT)

ReDim Preserve Tex_Buttons(NumButtons)

NumTextures = NumTextures + 1

ReDim Preserve gTexture(NumTextures)

Tex_Buttons(NumButtons).Path = App.Path & GFX_PATH & "gui\buttons\" & I & GFX_EXT

Tex_Buttons(NumButtons).Texture = NumTextures

NumButtons = NumButtons + 1

I = I + 1

Wend

NumButtons = NumButtons - 1

For I = 1 To NumButtons

LoadTexture Tex_Buttons(I)

Next

' Error handler

Exit Sub

ErrorHandler:

HandleError "CheckButtons", "modDatabase", Err.Number, Err.Description, Err.Source, Err.HelpContext

Err.Clear

Exit Sub

End Sub

Public Sub CheckButtons_c()

Dim I As Long

' If debug mode, handle error then exit out

If Options.Debug = 1 Then On Error GoTo ErrorHandler

I = 1

NumButtons_c = 1

ReDim Tex_Buttons_c(1)

While FileExist(GFX_PATH & "gui\buttons\" & I & "_c" & GFX_EXT)

ReDim Preserve Tex_Buttons_c(NumButtons_c)

NumTextures = NumTextures + 1

ReDim Preserve gTexture(NumTextures)

Tex_Buttons_c(NumButtons_c).Path = App.Path & GFX_PATH & "gui\buttons\" & I & "_c" & GFX_EXT

Tex_Buttons_c(NumButtons_c).Texture = NumTextures

NumButtons_c = NumButtons_c + 1

I = I + 1

Wend

NumButtons_c = NumButtons_c - 1

For I = 1 To NumButtons_c

LoadTexture Tex_Buttons_c(I)

Next

' Error handler

Exit Sub

ErrorHandler:

HandleError "CheckButtons_c", "modDatabase", Err.Number, Err.Description, Err.Source, Err.HelpContext

Err.Clear

Exit Sub

End Sub

Public Sub CheckButtons_h()

Dim I As Long

' If debug mode, handle error then exit out

If Options.Debug = 1 Then On Error GoTo ErrorHandler

I = 1

NumButtons_h = 1

ReDim Tex_Buttons_h(1)

While FileExist(GFX_PATH & "gui\buttons\" & I & "_h" & GFX_EXT)

ReDim Preserve Tex_Buttons_h(NumButtons_h)

NumTextures = NumTextures + 1

ReDim Preserve gTexture(NumTextures)

Tex_Buttons_h(NumButtons_h).Path = App.Path & GFX_PATH & "gui\buttons\" & I & "_h" & GFX_EXT

Tex_Buttons_h(NumButtons_h).Texture = NumTextures

NumButtons_h = NumButtons_h + 1

I = I + 1

Wend

NumButtons_h = NumButtons_h - 1

For I = 1 To NumButtons_h

LoadTexture Tex_Buttons_h(I)

Next

' Error handler

Exit Sub

ErrorHandler:

HandleError "CheckButtons_h", "modDatabase", Err.Number, Err.Description, Err.Source, Err.HelpContext

Err.Clear

Exit Sub

End Sub

Public Sub CheckSurfaces()

Dim I As Long

I = 1

Count_Surface = 1

ReDim Tex_Surface(1)

Do While FileExist(Path_Surface & Count_Surface & ".png")

ReDim Preserve Tex_Surface(0 To Count_Surface)

NumTextures = NumTextures + 1

ReDim Preserve gTexture(NumTextures)

Tex_Surface(Count_Surface).Path = App.Path & Path_Surface & I & ".png"

Tex_Surface(Count_Surface).Texture = NumTextures

Count_Surface = Count_Surface + 1

I = I + 1

Loop

Count_Surface = Count_Surface - 1

For I = 1 To Count_Surface

LoadTexture Tex_Surface(I)

Next

End Sub

```
on the bottom of modDatabase

Go into modText and replace the Public Type CustomFont with

```

Private Type CustomFont

HeaderInfo As VFH

Texture As DX8TextureRec

RowPitch As Integer

RowFactor As Single

ColFactor As Single

CharHeight As Byte

End Type

```

Then replace EngineInitFontTextures with

```

Sub EngineInitFontTextures()

' FONT DEFAULT

NumTextures = NumTextures + 1

ReDim Preserve gTexture(NumTextures)

Font_Default.Texture.Texture = NumTextures

Font_Default.Texture.Path = App.Path & FONT_PATH & "texdefault.png"

LoadTexture Font_Default.Texture

' Georgia

NumTextures = NumTextures + 1

ReDim Preserve gTexture(NumTextures)

Font_Georgia.Texture.Texture = NumTextures

Font_Georgia.Texture.Path = App.Path & FONT_PATH & "georgia.png"

LoadTexture Font_Georgia.Texture

End Sub

Sub UnloadFontTextures()

UnloadFont Font_Default

UnloadFont Font_Georgia

End Sub

Sub UnloadFont(Font As CustomFont)

Font.Texture.Texture = 0

End Sub

```
let me know if i missed anything! ![^_^](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/happy.png)

My next tutorial will be the trade system!!
Link to comment
Share on other sites

This is not real fix. I fixed CS:DE in Eclipse Reborn, becouse its texture loading is alot faster and it isnt using GDI+. Otherwise i will stay with EN

One example what is describing what i am trying to say ![:P](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/tongue.png)

> Put the **five classes** from EN and add them into CS:DE
Link to comment
Share on other sites

Could you tell what is being corrected? I was a little confused by this code, you mainly use

```
TryCreateDirectX8Device Function () As Boolean
```

Why The Function of CS is better than this new sub it is you saying to replace, since **TryCreateDirectX8Device** is not complete.

You are saying to use **CheckTilesets, CheckCharacters** … besides others, but the way it is in the CS is faster because it loads the amount and puts in the DX8 memory only once.
Link to comment
Share on other sites

> This is not real fix. I fixed CS:DE in Eclipse Reborn, becouse its texture loading is alot faster and it isnt using GDI+. Otherwise i will stay with EN
>
> One example what is describing what i am trying to say ![:P](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/tongue.png)

This is a real fix and possibly better. You know why? Because it restores the stable DX8 functionality EN has and throws it over the systems and decent features that CS:DE has, your Reborn edit is trying to completely restructure the same thing. This allows EN tutorials that requires graphic work to become compatible in CS:DE which is more of an upgrade than any custom version I've seen, because it gives you the engine at a stable state and nothing more.
Link to comment
Share on other sites

> This is not real fix. I fixed CS:DE in Eclipse Reborn, becouse its texture loading is alot faster and it isnt using GDI+. Otherwise i will stay with EN
>
> One example what is describing what i am trying to say ![:P](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/tongue.png)

Please, if you have something not retarded to say, please say otherwise please be quiet…
Link to comment
Share on other sites

> Please, if you have something not retarded to say, please say otherwise please be quiet…

Sorry if i said something wrong. This isn´t fix, this is replacement ![:P](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/tongue.png) But it is doing its job.

> This is a real fix and possibly better. You know why? Because it restores the stable DX8 functionality EN has and throws it over the systems and decent features that CS:DE has, your Reborn edit is trying to completely restructure the same thing. This allows EN tutorials that requires graphic work to become compatible in CS:DE which is more of an upgrade than any custom version I've seen, because it gives you the engine at a stable state and nothing more.

Why do you think that i started Reborn? Becouse i wanted to use CS:DE method of rendering, what is faster and cleaner, and it have alot less code. And CS:DE do not have many unique features. Only NPC spells and Spell Advancement is worth of mentioning (but there is tutorial on this forums for first one, and second can be done only with one sub server side and adding few lines of code ro UDTs). So idk what do you mean by "systems and decent features that CS:DE has" ![:)](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/smile.png)
Link to comment
Share on other sites

> This is not real fix.

That is the first decent thing he's ever said, too bad his explanation is off. The way you're handling rendering is still pretty bad, I recommend you check [this](http://www.touchofdeathforums.com/community/index.php?/topic/130272-clean-optimised-dx8/) out to see how clean optimised rendering is done. I admit mine still has problems but its an actual solution instead of a problem masker.
Link to comment
Share on other sites

> Heh, I love how some people think less code means better performance

If you think about it, most of the time it does. If someone does one thing in 5 lines of code and you do the same exact thing in 50 then you're putting 45 wasted lines of code into it.
Link to comment
Share on other sites

@Sekaru; in some aspects yes, if those 5 lines are developed properly, not going to disagree there. But for the topic of loading textures and GDI+, it actually has better performance. Though I do agree, the rendering in CS:DE was horribly ugly.

@Growlith, my comment wasn't directed at you, I actually like that you took CS:DE and added the EO3.0 functions into it, you get the convienence of CS:DE with solid texture handling.
Link to comment
Share on other sites

> @Sekaru; in some aspects yes, if those 5 lines are developed properly, not going to disagree there. But for the topic of loading textures and GDI+, it actually has better performance. Though I do agree, the rendering in CS:DE was horribly ugly.
>
> @Growlith, my comment wasn't directed at you, I actually like that you took CS:DE and added the EO3.0 functions into it, you get the convienence of CS:DE with solid texture handling.

lol my comment wasn't directed to you either, it was directed to Sekaru x3
Link to comment
Share on other sites

> @Sekaru; in some aspects yes, if those 5 lines are developed properly, not going to disagree there. But for the topic of loading textures and GDI+, it actually has better performance. Though I do agree, the rendering in CS:DE was horribly ugly.

Oh yeah I agree there. I was just generalising.

> and you're doing the same thing

Looking at that clusterfuck of code I can safely say, no, I'm not.
Link to comment
Share on other sites

what this fix does is take the rendering system from EO 3.0 and replaces the CS:DE graphics module with that one. it's a better fix because you actually know you're going to have a solid system…not to mention that it's(Deathbeam this part is for you)**it's still the same speed**.
Link to comment
Share on other sites

It would be interesting to find out something that you can take to not limit the stay of DirectX8 using graphics potency of 2, I still could not do it, nor advise using GDI has loss of performance, but I know it is possible, I've seen engines that closed source creator had achieved it.
Link to comment
Share on other sites

> what this fix does is take the rendering system from EO 3.0 and replaces the CS:DE graphics module with that one. it's a better fix because you actually know you're going to have a solid system…not to mention that it's(Deathbeam this part is for you)**it's still the same speed**.

Same **rendering** speed, but slower speed when loading textures to memory.
Link to comment
Share on other sites

> that doesn't rly matter as long as the program starts.and like Rob said, just because it's a different way doesn't mean it's bad, your arguement has been invalidated by that comment so leave please.

If you wanna that slow loading on start, they yes it doesnt matter, but if you are using loading textures when needed, then it matters.

And ok not gonna post anything here, but you stop posting stupid posts in ER thread.
Link to comment
Share on other sites

I genuinely suggest you both be quiet before you embarrass yourselves even more. Sure, the thread is hilarious but neither of you have a clue about what you're on about.
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...