GS-Zone

Carga Comun de Init y Graficos Ir al Indice

Moderadores: Moderadores de Argentum, Especialistas de Argentum, Especialistas de Programación

19

Nota » 01 Feb 2012 20:43

Bueno, como hay que dar muchas vueltas para indexar y demas, ami no me gusta la carga de Graficos1.ind, Graficos2.ind y Graficos3.ind y los graficos comprimidos, aca les dejo como sacar, y dejarlo como en la 12.x

Cliente:

Sacamos el modCompression y remplazamos clsSurfaceManDyn por:
  1. '**************************************************************
  2. ' clsSurfaceManDyn.cls - Inherits from clsSurfaceManager. Is designed to load
  3. 'surfaces dynamically without using more than an arbitrary amount of Mb.
  4. 'For removale it uses LRU, attempting to just keep in memory those surfaces
  5. 'that are actually usefull.
  6. '
  7. ' Developed by Maraxus (Juan Martín Sotuyo Dodero - juansotuyo@hotmail.com)
  8. ' Last Modify Date: 3/06/2006
  9. '**************************************************************
  10.  
  11. '**************************************************************
  12. 'This program is free software; you can redistribute it and/or modify
  13. 'it under the terms of the GNU General Public License as published by
  14. 'the Free Software Foundation; either version 2 of the License, or
  15. 'any later version.
  16. '
  17. 'This program is distributed in the hope that it will be useful,
  18. 'but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. 'MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  20. 'Affero General Public License for more details.
  21. '
  22. 'You should have received a copy of the GNU General Public License
  23. 'along with this program; if not, write to the Free Software
  24. 'Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  25. '
  26. 'Argentum Online is based on Baronsoft's VB6 Online RPG
  27. 'You can contact the original creator of ORE at aaron@baronsoft.com
  28. 'for more information about ORE please visit http://www.baronsoft.com/
  29. '**************************************************************
  30.  
  31. Option Explicit
  32.  
  33. 'Inherit from the surface manager
  34. Implements clsSurfaceManager
  35.  
  36. Private Const BYTES_PER_MB As Long = 1048576                        '1Mb = 1024 Kb = 1024 * 1024 bytes = 1048576 bytes
  37. Private Const MIN_MEMORY_TO_USE As Long = 4 * BYTES_PER_MB          '4 Mb
  38. Private Const DEFAULT_MEMORY_TO_USE As Long = 16 * BYTES_PER_MB     '16 Mb
  39.  
  40. Private Type SURFACE_ENTRY_DYN
  41.     fileIndex As Long
  42.     lastAccess As Long
  43.     Surface As DirectDrawSurface7
  44. End Type
  45.  
  46. Private surfaceList() As SURFACE_ENTRY_DYN
  47. Private surfaceCount As Long
  48.  
  49. Private surfaceIndexes() As Long
  50. Private surfaceIndexCount As Long
  51.  
  52. Private DirectDraw As DirectDraw7
  53.  
  54. Private maxBytesToUse As Long
  55. Private usedBytes As Long
  56.  
  57. Private useVideoMemory As Boolean
  58.  
  59. Private GrhPath As String
  60.  
  61. Private Declare Function GetTickCount Lib "kernel32" () As Long
  62. Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (ByRef dest As Any, ByRef source As Any, ByVal byteCount As Long)
  63.  
  64. Private Sub Class_Initialize()
  65. '**************************************************************
  66. 'Author: Juan Martín Sotuyo Dodero
  67. 'Last Modify Date: 3/06/2006
  68. '
  69. '**************************************************************
  70.     usedBytes = 0
  71.     surfaceCount = 0
  72.     surfaceIndexCount = 0
  73.     ReDim surfaceList(0) As SURFACE_ENTRY_DYN
  74.     ReDim surfaceIndexes(0) As Long
  75.     maxBytesToUse = MIN_MEMORY_TO_USE
  76. End Sub
  77.  
  78. Private Sub Class_Terminate()
  79. '**************************************************************
  80. 'Author: Juan Martín Sotuyo Dodero
  81. 'Last Modify Date: 3/06/2006
  82. 'Clean up
  83. '**************************************************************
  84.     Dim i  As Long
  85.    
  86.     'Destroy every surface in memory
  87.     For i = 0 To surfaceCount - 1
  88.         Set surfaceList(i).Surface = Nothing
  89.     Next i
  90.    
  91.     'Destroy the arrays
  92.     Erase surfaceList
  93.     Erase surfaceIndexes
  94. End Sub
  95.  
  96. Private Sub clsSurfaceManager_Initialize(ByRef DD As DirectDraw7, ByVal videoMemory As Boolean, ByVal graphicPath As String, Optional ByVal maxMemoryUsageInMb As Long = -1)
  97. '**************************************************************
  98. 'Author: Juan Martín Sotuyo Dodero
  99. 'Last Modify Date: 3/06/2006
  100. 'Initializes the manager
  101. '**************************************************************
  102.     Set DirectDraw = DD
  103.    
  104.     useVideoMemory = videoMemory
  105.    
  106.     GrhPath = graphicPath
  107.    
  108.     If maxMemoryUsageInMb = -1 Then
  109.         maxBytesToUse = DEFAULT_MEMORY_TO_USE   ' 16 Mb by default
  110.     ElseIf maxMemoryUsageInMb * BYTES_PER_MB < MIN_MEMORY_TO_USE Then
  111.         maxBytesToUse = MIN_MEMORY_TO_USE       ' 4 Mb is the minimum allowed
  112.     Else
  113.         maxBytesToUse = maxMemoryUsageInMb * BYTES_PER_MB
  114.     End If
  115. End Sub
  116.  
  117. Private Property Get clsSurfaceManager_Surface(ByVal fileIndex As Long) As DirectDrawSurface7
  118. '**************************************************************
  119. 'Author: Juan Martín Sotuyo Dodero
  120. 'Last Modify Date: 3/06/2006
  121. 'Retrieves the requested texture
  122. '**************************************************************
  123.     Dim Index As Long
  124.    
  125.     ' Search the index on the list
  126.     Index = BinarySearch(fileIndex)
  127.    
  128.     If Index < 0 Then
  129.         'Not found, we have to load the file and add it in the position given by the negation of the index
  130.         '(it may be changed by the removal of indexes though, so we let the LoadSurface method notify us)
  131.         Index = LoadSurface(fileIndex, Not Index)
  132.     End If
  133.    
  134.     'Return it
  135.     With surfaceList(surfaceIndexes(Index))
  136.         .lastAccess = GetTickCount
  137.         Set clsSurfaceManager_Surface = .Surface
  138.     End With
  139. End Property
  140.  
  141. Private Function BinarySearch(ByVal fileIndex As Long) As Long
  142. '**************************************************************
  143. 'Author: Juan Martín Sotuyo Dodero
  144. 'Last Modify Date: 3/06/2006
  145. 'Returns the index of the surface in the list, or the negation
  146. 'of the position were it should be if not found (for binary insertion)
  147. '**************************************************************
  148.     Dim min As Long
  149.     Dim max As Long
  150.     Dim mid As Long
  151.    
  152.     min = 0
  153.     max = surfaceIndexCount - 1
  154.    
  155.     Do While min <= max
  156.         mid = (min + max) \ 2
  157.        
  158.         If surfaceList(surfaceIndexes(mid)).fileIndex < fileIndex Then
  159.             min = mid + 1
  160.         ElseIf surfaceList(surfaceIndexes(mid)).fileIndex > fileIndex Then
  161.             max = mid - 1
  162.         Else
  163.             'We found it
  164.             BinarySearch = mid
  165.             Exit Function
  166.         End If
  167.     Loop
  168.    
  169.     'Not found, return the negation of the position where it should be
  170.     '(all higher values are to the right of the list and lower values are to the left)
  171.     BinarySearch = Not min
  172. End Function
  173.  
  174. Private Function LoadSurface(ByVal fileIndex As Long, ByVal listIndex As Long) As Long
  175. '**************************************************************
  176. 'Author: Juan Martín Sotuyo Dodero
  177. 'Last Modify Date: 3/06/2006
  178. 'Loads the surface named fileIndex + ".bmp" and inserts it to the
  179. 'surface list in the listIndex position
  180. '**************************************************************
  181. On Error GoTo ErrHandler
  182.  
  183.     Dim newSurface As SURFACE_ENTRY_DYN
  184.     Dim ddsd As DDSURFACEDESC2
  185.     Dim ddck As DDCOLORKEY
  186.     Dim filePath As String
  187.    
  188.     'Store complete file path
  189.     filePath = GrhPath & CStr(fileIndex) & ".bmp"
  190.    
  191.     'Set up the surface desc
  192.     ddsd.lFlags = DDSD_CAPS Or DDSD_HEIGHT Or DDSD_WIDTH
  193.    
  194.     If useVideoMemory Then
  195.         ddsd.ddsCaps.lCaps = DDSCAPS_OFFSCREENPLAIN
  196.     Else
  197.         ddsd.ddsCaps.lCaps = DDSCAPS_OFFSCREENPLAIN Or DDSCAPS_SYSTEMMEMORY
  198.     End If
  199.    
  200.     Call surfaceDimensions(filePath, ddsd.lHeight, ddsd.lWidth)
  201.    
  202.     With newSurface
  203.         .fileIndex = fileIndex
  204.        
  205.         'Set last access time (if we didn't we would reckon this texture as the one lru)
  206.         .lastAccess = GetTickCount
  207.        
  208.         'Load surface
  209.         Set .Surface = DirectDraw.CreateSurfaceFromFile(filePath, ddsd)
  210.        
  211.         'Set colorkey
  212.         ddck.high = 0
  213.         ddck.low = 0
  214.         Call .Surface.SetColorKey(DDCKEY_SRCBLT, ddck)
  215.        
  216.         'Retrieve the updated surface desc
  217.         Call .Surface.GetSurfaceDesc(ddsd)
  218.     End With
  219.    
  220.     'Insert surface to the list at the given pos
  221.     Call InsertSurface(newSurface, listIndex)
  222.    
  223.     'Update used bytes
  224.     usedBytes = usedBytes + ddsd.lHeight * ddsd.lPitch
  225.    
  226.     Dim removedFile As Integer
  227.     'Check if we have exceeded our allowed share of memory usage
  228.     Do While usedBytes > maxBytesToUse And surfaceCount > 1
  229.         'Remove a file
  230.         removedFile = RemoveLRU
  231.        
  232.         'If no file could be removed we continue, if the file was previous to our surface we update the index
  233.         If removedFile = 0 Then
  234.             Exit Do
  235.         ElseIf removedFile < listIndex Then
  236.             listIndex = listIndex - 1
  237.         End If
  238.     Loop
  239.    
  240.     'Return the real index in wich it ended after removing any necessary files
  241.     LoadSurface = listIndex
  242. Exit Function
  243.  
  244. ErrHandler:
  245.     If err.number = DDERR_OUTOFMEMORY Or err.number = DDERR_OUTOFVIDEOMEMORY Then
  246.         If surfaceCount Then
  247.             'Remove a surface and try again
  248.             Call RemoveLRU
  249.             Resume Next
  250.         Else
  251.             MsgBox "No hay memoria disponible! El programa abortará. Cierra algunos programas e intenta de nuevo"
  252.             End
  253.         End If
  254.     Else
  255.         MsgBox "Un error inesperado ocurrió al intentar cargar el gráfico " & filePath & ". " & vbCrLf & _
  256.                 "El código de error es " & CStr(err.number) & " - " & err.Description & vbCrLf & "Copia este mensaje y notifica a los administradores.", _
  257.                 vbOKOnly Or vbCritical Or vbExclamation, "Error"
  258.         End
  259.     End If
  260. End Function
  261.  
  262. Private Sub surfaceDimensions(ByVal Archivo As String, ByRef Height As Long, ByRef Width As Long)
  263. '**************************************************************
  264. 'Author: Juan Martín Sotuyo Dodero
  265. 'Last Modify Date: 3/06/2006
  266. 'Loads the headers of a bmp file to retrieve it's dimensions at rt
  267. '**************************************************************
  268.     Dim handle As Integer
  269.     Dim bmpFileHead As BITMAPFILEHEADER
  270.     Dim bmpInfoHead As BITMAPINFOHEADER
  271.    
  272.     handle = FreeFile()
  273.     Open Archivo For Binary Access Read Lock Write As handle
  274.         Get handle, , bmpFileHead
  275.         Get handle, , bmpInfoHead
  276.     Close handle
  277.    
  278.     Height = bmpInfoHead.biHeight
  279.     Width = bmpInfoHead.biWidth
  280. End Sub
  281.  
  282. Private Sub InsertSurface(ByRef Surface As SURFACE_ENTRY_DYN, ByVal listIndex As Long)
  283. '**************************************************************
  284. 'Author: Juan Martín Sotuyo Dodero
  285. 'Last Modify Date: 3/06/2006
  286. 'Inserts the given surface in the requested position of the surface list
  287. '**************************************************************
  288. On Error GoTo ErrHandler
  289.     Dim i As Long
  290.    
  291.     'Search for an empty spot in the list
  292.     For i = 0 To surfaceCount - 1
  293.         If surfaceList(i).Surface Is Nothing Then Exit For
  294.     Next i
  295.    
  296.     'Enlarge the list if no empty spot was found
  297.     If i = surfaceCount Then
  298.         ReDim Preserve surfaceList(surfaceCount) As SURFACE_ENTRY_DYN
  299.        
  300.         'Increase surface count
  301.         surfaceCount = surfaceCount + 1
  302.     End If
  303.    
  304.     'Insert the new surface
  305.     surfaceList(i) = Surface
  306.    
  307.     'Resize the list
  308.     ReDim Preserve surfaceIndexes(surfaceIndexCount) As Long
  309.    
  310.     'Update the index list
  311.     If surfaceIndexCount > listIndex Then
  312.         'Move back the list - Copying this way is up to 6 times faster than a For
  313.         Dim tempList() As Long
  314.         ReDim tempList(surfaceIndexCount - listIndex) As Long
  315.        
  316.         CopyMemory tempList(0), surfaceIndexes(listIndex), (surfaceIndexCount - listIndex) * 4
  317.         surfaceIndexes(listIndex) = i
  318.         CopyMemory surfaceIndexes(listIndex + 1), tempList(0), (surfaceIndexCount - listIndex) * 4
  319.     Else
  320.         'We are inserting at the bottom of the list
  321.         surfaceIndexes(listIndex) = i
  322.     End If
  323.    
  324.     surfaceIndexCount = surfaceIndexCount + 1
  325. Exit Sub
  326.  
  327. ErrHandler:
  328.     MsgBox "Un error irreparable ocurrió al insertar un nuevo gráfico en la lista." & vbCrLf _
  329.             & "El cliente se cerrará" & vbCrLf _
  330.             & "Intente usar el cliente no dinámico"
  331.     End
  332. End Sub
  333.  
  334. Private Function RemoveLRU() As Integer
  335. '**************************************************************
  336. 'Author: Juan Martín Sotuyo Dodero
  337. 'Last Modify Date: 3/06/2006
  338. 'Removes the Least Recently Used surface to make some room for new ones
  339. '**************************************************************
  340.     Dim LRU As Long
  341.     Dim i As Long
  342.     Dim ddsd As DDSURFACEDESC2
  343.    
  344.     'Should never happen, but just in case....
  345.     If surfaceCount = 0 Then Exit Function
  346.    
  347.     'Initialize with the first element of the list
  348.     LRU = 0
  349.    
  350.     'Check out through the whole list for the least recently used
  351.     For i = 1 To surfaceIndexCount - 1
  352.         If surfaceList(surfaceIndexes(LRU)).lastAccess > surfaceList(surfaceIndexes(i)).lastAccess Then
  353.             LRU = i
  354.         End If
  355.     Next i
  356.    
  357.     'Store the index of the surface removed
  358.     RemoveLRU = LRU
  359.    
  360.     'Retrieve the surface desc
  361.     Call surfaceList(surfaceIndexes(LRU)).Surface.GetSurfaceDesc(ddsd)
  362.    
  363.     'Remove it
  364.     Set surfaceList(surfaceIndexes(LRU)).Surface = Nothing
  365.     surfaceList(surfaceIndexes(LRU)).fileIndex = 0
  366.    
  367.     'Move back the list (if necessary)
  368.     If LRU < surfaceIndexCount - 1 Then
  369.         CopyMemory surfaceIndexes(LRU), surfaceIndexes(LRU + 1), (surfaceIndexCount - LRU - 1) * 4
  370.     End If
  371.    
  372.     'Resize the list
  373.     ReDim Preserve surfaceIndexes(surfaceIndexCount - 1) As Long
  374.    
  375.     'Decrease index count
  376.     surfaceIndexCount = surfaceIndexCount - 1
  377.    
  378.     'Update the used bytes
  379.     usedBytes = usedBytes - ddsd.lHeight * ddsd.lPitch
  380. End Function


Remplazamos el clsSurfaceManStatic por:
  1. '**************************************************************
  2. ' clsSurfaceManStatic.cls - Inherits from clsSurfaceManager. Is designed to load
  3. ' surfaces at startup, and never deallocating them.
  4. ' This grants high performance can use a lot of RAM.
  5. '
  6. ' Developed by Maraxus (Juan Martín Sotuyo Dodero - juansotuyo@hotmail.com)
  7. ' Last Modify Date: 3/06/2006
  8. '**************************************************************
  9.  
  10. '**************************************************************
  11. 'This program is free software; you can redistribute it and/or modify
  12. 'it under the terms of the GNU General Public License as published by
  13. 'the Free Software Foundation; either version 2 of the License, or
  14. 'any later version.
  15. '
  16. 'This program is distributed in the hope that it will be useful,
  17. 'but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. 'MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  19. 'Affero General Public License for more details.
  20. '
  21. 'You should have received a copy of the GNU General Public License
  22. 'along with this program; if not, write to the Free Software
  23. 'Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  24. '
  25. 'Argentum Online is based on Baronsoft's VB6 Online RPG
  26. 'You can contact the original creator of ORE at aaron@baronsoft.com
  27. 'for more information about ORE please visit http://www.baronsoft.com/
  28. '**************************************************************
  29.  
  30. Option Explicit
  31.  
  32. 'Inherit from the surface manager
  33. Implements clsSurfaceManager
  34.  
  35. 'Size to which we resize the list when we start loading textures to prevent ReDim Preserve on each add
  36. 'Once done the list is trimmed to the proper size if it's larger than needed.
  37. 'A ReDim Preserve is executed for each surface after DEFAULT_LIST_SIZE + 1
  38. Private Const DEFAULT_LIST_SIZE As Integer = 1500
  39.  
  40. Private Type SURFACE_ENTRY_STATIC
  41.     fileIndex As Long
  42.     Surface As DirectDrawSurface7
  43. End Type
  44.  
  45. Private surfaceList() As SURFACE_ENTRY_STATIC
  46. Private surfaceCount As Long
  47.  
  48. Private DirectDraw As DirectDraw7
  49.  
  50. Private useVideoMemory As Boolean
  51.  
  52. Private Sub Class_Initialize()
  53. '**************************************************************
  54. 'Author: Juan Martín Sotuyo Dodero
  55. 'Last Modify Date: 3/06/2006
  56. '
  57. '**************************************************************
  58.     surfaceCount = 0
  59.     ReDim surfaceList(0) As SURFACE_ENTRY_STATIC
  60. End Sub
  61.  
  62. Private Sub Class_Terminate()
  63. '**************************************************************
  64. 'Author: Juan Martín Sotuyo Dodero
  65. 'Last Modify Date: 3/06/2006
  66. 'Clean up
  67. '**************************************************************
  68.     Dim i  As Long
  69.    
  70.     'Destroy every surface in memory
  71.     For i = 0 To surfaceCount - 1
  72.         Set surfaceList(i).Surface = Nothing
  73.     Next i
  74.    
  75.     'Destroy the array
  76.     Erase surfaceList
  77. End Sub
  78.  
  79. Private Sub clsSurfaceManager_Initialize(ByRef DD As DirectDraw7, ByVal videoMemory As Boolean, ByVal graphicPath As String, Optional ByVal maxMemoryUsageInMb As Long = -1&)
  80. '**************************************************************
  81. 'Author: Juan Martín Sotuyo Dodero
  82. 'Last Modify Date: 3/06/2006
  83. '
  84. '**************************************************************
  85.     Set DirectDraw = DD
  86.    
  87.     useVideoMemory = videoMemory
  88.    
  89.     Call LoadSurfaces(graphicPath)
  90. End Sub
  91.  
  92. Private Property Get clsSurfaceManager_Surface(ByVal fileIndex As Long) As DirectDrawSurface7
  93. '**************************************************************
  94. 'Author: Juan Martín Sotuyo Dodero
  95. 'Last Modify Date: 3/06/2006
  96. 'Retrieves the requested texture
  97. '**************************************************************
  98. On Error GoTo ErrHandler:
  99.     Dim Index As Long
  100.    
  101.     ' Search the index on the list
  102.     Index = BinarySearch(fileIndex)
  103.    
  104.     'Return it
  105.     Set clsSurfaceManager_Surface = surfaceList(Index).Surface
  106. Exit Property
  107.  
  108. ErrHandler:
  109.     If Index < 0 Then
  110.         MsgBox "No se encuentra el archivo " & CStr(fileIndex) & ".bmp. Reinstale el juego, " _
  111.                 & "y si el problema persiste contactese con los adminsitradores", vbOKOnly Or vbCritical Or vbExclamation, "Error"
  112.     Else
  113.         MsgBox "Un error inesperado ocurrió a intentar cargar el archivo " & CStr(fileIndex) & ".bmp. & vbcrlf" _
  114.                 & "Error: " & CStr(err.number), vbOKOnly Or vbCritical Or vbExclamation, "Error"
  115.     End If
  116.    
  117.     End
  118. End Property
  119.  
  120. Private Sub LoadSurfaces(ByVal GrhPath As String)
  121. '**************************************************************
  122. 'Author: Juan Martín Sotuyo Dodero
  123. 'Last Modify Date: 3/06/2006
  124. 'Loads all surfaces in random order and then sorts them
  125. '**************************************************************
  126. On Error Resume Next
  127.     Dim FileName As String
  128.     Dim surfaceIndex As Long
  129.    
  130.     'Set up the list at a standard value big enough to prevent using ReDim Preserve constantly (which is slow)
  131.     ReDim surfaceList(DEFAULT_LIST_SIZE) As SURFACE_ENTRY_STATIC
  132.    
  133.     FileName = Dir$(GrhPath & "*.bmp", vbArchive)
  134.    
  135.     While FileName <> ""
  136.         'Get the surface index (numeric part of the number) - NEVER use Val() here or the error won't be raised!!! - Don't use IsNumeric or hexa strings will be accepted
  137.         surfaceIndex = CLng(Left$(FileName, Len(FileName) - 4))
  138.        
  139.         If err.number = 13 Then
  140.             'Type mysmatch - the name of the file isn't numneric, therefore it isn't a surface
  141.             err.Clear
  142.         Else
  143.             'Increase surface count and resize list if needed
  144.             surfaceCount = surfaceCount + 1
  145.             If surfaceCount > DEFAULT_LIST_SIZE + 1 Then
  146.                 ReDim Preserve surfaceList(surfaceCount - 1) As SURFACE_ENTRY_STATIC
  147.             End If
  148.            
  149.             Call LoadSurface(GrhPath, surfaceIndex, surfaceCount - 1)
  150.         End If
  151.        
  152.         'Get next .bmp file
  153.         FileName = Dir$()
  154.     Wend
  155.    
  156.     'Trim the list if needed
  157.     If surfaceCount <> UBound(surfaceList) + 1 Then
  158.         ReDim Preserve surfaceList(surfaceCount - 1) As SURFACE_ENTRY_STATIC
  159.     End If
  160.    
  161.     'Sort the list
  162.     Call SortSurfaces(0, surfaceCount - 1)
  163. End Sub
  164.  
  165. Private Function BinarySearch(ByVal fileIndex As Long) As Long
  166. '**************************************************************
  167. 'Author: Juan Martín Sotuyo Dodero
  168. 'Last Modify Date: 3/06/2006
  169. 'Returns the index of the surface in the list, or the negation
  170. 'of the position were it should be if not found (for binary insertion)
  171. '**************************************************************
  172.     Dim min As Long
  173.     Dim max As Long
  174.     Dim mid As Long
  175.    
  176.     min = 0
  177.     max = surfaceCount - 1
  178.    
  179.     Do While min <= max
  180.         mid = (min + max) \ 2
  181.        
  182.         If surfaceList(mid).fileIndex < fileIndex Then
  183.             min = mid + 1
  184.         ElseIf surfaceList(mid).fileIndex > fileIndex Then
  185.             max = mid - 1
  186.         Else
  187.             'We found it
  188.             BinarySearch = mid
  189.             Exit Function
  190.         End If
  191.     Loop
  192.    
  193.     'Not found, return the negation of the position where it should be
  194.     '(all higher values are to the right of the list and lower values are to the left)
  195.     BinarySearch = Not min
  196. End Function
  197.  
  198. Private Sub LoadSurface(ByVal GrhPath As String, ByVal fileIndex As Long, ByVal listIndex As Long)
  199. '**************************************************************
  200. 'Author: Juan Martín Sotuyo Dodero
  201. 'Last Modify Date: 3/06/2006
  202. 'Loads the surface named fileIndex + ".bmp" and inserts it to the
  203. 'surface list in the listIndex position
  204. '**************************************************************
  205. On Error GoTo ErrHandler
  206.  
  207.     Dim newSurface As SURFACE_ENTRY_STATIC
  208.     Dim ddsd As DDSURFACEDESC2
  209.     Dim ddck As DDCOLORKEY
  210.     Dim filePath As String
  211.    
  212.     'Store complete file path
  213.     filePath = GrhPath & CStr(fileIndex) & ".bmp"
  214.    
  215.     'Set up the surface desc
  216.     ddsd.lFlags = DDSD_CAPS Or DDSD_HEIGHT Or DDSD_WIDTH
  217.    
  218.     If useVideoMemory Then
  219.         ddsd.ddsCaps.lCaps = DDSCAPS_OFFSCREENPLAIN
  220.     Else
  221.         ddsd.ddsCaps.lCaps = DDSCAPS_OFFSCREENPLAIN Or DDSCAPS_SYSTEMMEMORY
  222.     End If
  223.    
  224.     Call surfaceDimensions(filePath, ddsd.lHeight, ddsd.lWidth)
  225.    
  226.     With newSurface
  227.         .fileIndex = fileIndex
  228.        
  229.         'Load surface
  230.         Set .Surface = DirectDraw.CreateSurfaceFromFile(filePath, ddsd)
  231.        
  232.         'Set colorkey
  233.         ddck.high = 0
  234.         ddck.low = 0
  235.         Call .Surface.SetColorKey(DDCKEY_SRCBLT, ddck)
  236.     End With
  237.    
  238.     'Store the surface in the given index (it MUST be empty or data will be lost)
  239.     surfaceList(listIndex) = newSurface
  240. Exit Sub
  241.  
  242. ErrHandler:
  243.     MsgBox "Un error inesperado ocurrió al intentar cargar el gráfico " & filePath & ". " & vbCrLf & _
  244.             "El código de error es " & CStr(err.number) & " - " & err.Description & vbCrLf & "Copia este mensaje y notifica a los administradores.", _
  245.             vbOKOnly Or vbCritical Or vbExclamation, "Error"
  246.         End
  247. End Sub
  248.  
  249. Private Sub surfaceDimensions(ByVal Archivo As String, ByRef Height As Long, ByRef Width As Long)
  250. '**************************************************************
  251. 'Author: Juan Martín Sotuyo Dodero
  252. 'Last Modify Date: 3/06/2006
  253. 'Loads the headers of a bmp file to retrieve it's dimensions at rt
  254. '**************************************************************
  255.     Dim handle As Integer
  256.     Dim bmpFileHead As BITMAPFILEHEADER
  257.     Dim bmpInfoHead As BITMAPINFOHEADER
  258.    
  259.     handle = FreeFile()
  260.     Open Archivo For Binary Access Read Lock Write As handle
  261.         Get handle, , bmpFileHead
  262.         Get handle, , bmpInfoHead
  263.     Close handle
  264.    
  265.     Height = bmpInfoHead.biHeight
  266.     Width = bmpInfoHead.biWidth
  267. End Sub
  268.  
  269. Private Sub SortSurfaces(ByVal first As Integer, ByVal last As Integer)
  270. '**************************************************************
  271. 'Author: Juan Martín Sotuyo Dodero
  272. 'Last Modify Date: 5/04/2005
  273. 'Sorts the list using quicksort, this allows the use of BinarySearch for faster searches
  274. '**************************************************************
  275.     Dim min As Integer      'First item in the list
  276.     Dim max As Integer      'Last item in the list
  277.     Dim comp As Long        'Item used to compare
  278.     Dim temp As SURFACE_ENTRY_STATIC
  279.    
  280.     min = first
  281.     max = last
  282.    
  283.     comp = surfaceList((min + max) \ 2).fileIndex
  284.    
  285.     Do While min <= max
  286.         Do While surfaceList(min).fileIndex < comp And min < last
  287.             min = min + 1
  288.         Loop
  289.         Do While surfaceList(max).fileIndex > comp And max > first
  290.             max = max - 1
  291.         Loop
  292.         If min <= max Then
  293.             temp = surfaceList(min)
  294.             surfaceList(min) = surfaceList(max)
  295.             surfaceList(max) = temp
  296.             min = min + 1
  297.             max = max - 1
  298.         End If
  299.     Loop
  300.    
  301.     If first < max Then SortSurfaces first, max
  302.     If min < last Then SortSurfaces min, last
  303. End Sub


Buscamos:
  1. ''
  2. ' Loads grh data using the new file format.
  3. '
  4. ' @return   True if the load was successfull, False otherwise.
  5.  
  6. Private Function LoadGrhData() As Boolean


Y remplazamos toda la Function por:
  1. ''
  2. ' Loads grh data using the new file format.
  3. '
  4. ' @return   True if the load was successfull, False otherwise.
  5.  
  6. Private Function LoadGrhData() As Boolean
  7. On Error GoTo ErrorHandler
  8.     Dim Grh As Long
  9.     Dim Frame As Long
  10.     Dim grhCount As Long
  11.     Dim handle As Integer
  12.     Dim fileVersion As Long
  13.    
  14.     'Open files
  15.     handle = FreeFile()
  16.    
  17.     Open IniPath & "Graficos.ind" For Binary Access Read As handle
  18.     Seek #1, 1
  19.    
  20.     'Get file version
  21.     Get handle, , fileVersion
  22.    
  23.     'Get number of grhs
  24.     Get handle, , grhCount
  25.    
  26.     'Resize arrays
  27.     ReDim GrhData(1 To grhCount) As GrhData
  28.    
  29.     While Not EOF(handle)
  30.         Get handle, , Grh
  31.        
  32.         With GrhData(Grh)
  33.             'Get number of frames
  34.             Get handle, , .NumFrames
  35.             If .NumFrames <= 0 Then GoTo ErrorHandler
  36.            
  37.             ReDim .Frames(1 To GrhData(Grh).NumFrames)
  38.            
  39.             If .NumFrames > 1 Then
  40.                 'Read a animation GRH set
  41.                 For Frame = 1 To .NumFrames
  42.                     Get handle, , .Frames(Frame)
  43.                     If .Frames(Frame) <= 0 Or .Frames(Frame) > grhCount Then
  44.                         GoTo ErrorHandler
  45.                     End If
  46.                 Next Frame
  47.                
  48.                 Get handle, , .Speed
  49.                
  50.                 If .Speed <= 0 Then GoTo ErrorHandler
  51.                
  52.                 'Compute width and height
  53.                 .pixelHeight = GrhData(.Frames(1)).pixelHeight
  54.                 If .pixelHeight <= 0 Then GoTo ErrorHandler
  55.                
  56.                 .pixelWidth = GrhData(.Frames(1)).pixelWidth
  57.                 If .pixelWidth <= 0 Then GoTo ErrorHandler
  58.                
  59.                 .TileWidth = GrhData(.Frames(1)).TileWidth
  60.                 If .TileWidth <= 0 Then GoTo ErrorHandler
  61.                
  62.                 .TileHeight = GrhData(.Frames(1)).TileHeight
  63.                 If .TileHeight <= 0 Then GoTo ErrorHandler
  64.             Else
  65.                 'Read in normal GRH data
  66.                 Get handle, , .FileNum
  67.                 If .FileNum <= 0 Then GoTo ErrorHandler
  68.                
  69.                 Get handle, , GrhData(Grh).sX
  70.                 If .sX < 0 Then GoTo ErrorHandler
  71.                
  72.                 Get handle, , .sY
  73.                 If .sY < 0 Then GoTo ErrorHandler
  74.                
  75.                 Get handle, , .pixelWidth
  76.                 If .pixelWidth <= 0 Then GoTo ErrorHandler
  77.                
  78.                 Get handle, , .pixelHeight
  79.                 If .pixelHeight <= 0 Then GoTo ErrorHandler
  80.                
  81.                 'Compute width and height
  82.                 .TileWidth = .pixelWidth / TilePixelHeight
  83.                 .TileHeight = .pixelHeight / TilePixelWidth
  84.                
  85.                 .Frames(1) = Grh
  86.             End If
  87.         End With
  88.     Wend
  89.    
  90.     Close handle
  91.    
  92.     LoadGrhData = True
  93. Exit Function
  94.  
  95. ErrorHandler:
  96.     LoadGrhData = False
  97. End Function


Buscamos y borramos:
  1. Public GraphicsFile As String 'Que graficos.ind usamos


Buscamos y borramos:
  1. If InStr(1, ClientSetup.sGraficos, "Graficos") Then
  2.         GraphicsFile = ClientSetup.sGraficos
  3.     Else
  4.         GraphicsFile = "Graficos3.ind"
  5.     End If


Solo resta ir a la carpeta "Init" y borrar Graficos1.ind y Graficos2.ind y despues Graficos3.ind, le cambian el nombre por Graficos.ind

Saludos ^^

Imagen
Imagen
Staff Zeiked-Games
641
Dragon Ancestral [3]
Registrado: Años de membresíaAños de membresía
Ubicación: Castelar
Mensajes: 3414
Aportes: 66
Premios: 3
Usuario omnipresente (1) Embajador (2)

Nota » 01 Feb 2012 20:44

Buen Aporte!

Imagen
409
Destructor de Mentes [5]
Registrado: Años de membresía
Mensajes: 726
Aportes: 14

Nota » 01 Feb 2012 20:47

Buen aporte!

A mi tampoco me gusta :D

Imagen
@lautamarino
526
Oraculo [5]
Registrado: Octubre 2011
Mensajes: 2034
Aportes: 46
Premios: 1
Embajador (1)

Nota » 01 Feb 2012 22:14

pero y los arbolitos chicos ? :P

LyRan escribió:Buenos Dias amigos y programadores de Gs Zone, Me gustaria pedirle la amabilidad de una ayuda con un cliente editado para mi Ao casero, Osea me explico, yo juego Ao con varios amigos y ellos todos usan cheat y no me gusta eso me gustaria que alguien me ayudara a crear un cliente editado con auto poteo de ambas potas a la ves ya sea que se alla gastado Mana lanzando algun hechis y comienze a potear solo hasta estar completamente el Mana, igual para la salud y poteo rapido para ambos.
mAnco programEr
794
Oraculo [5]
Registrado: Años de membresíaAños de membresía
Ubicación: Bolivia
Mensajes: 2289
Aportes: 109

Nota » 01 Feb 2012 22:22

Te los metes bien en el .......

Buen aporte
Usuario Registrado
104
Newbie [3]
Registrado: Agosto 2011
Mensajes: 86

Nota » 01 Feb 2012 22:53

maTih.- escribió:pero y los arbolitos chicos ? :P


eh?? que arbolitos chicos?

Saludos ^^

Imagen
Imagen
Staff Zeiked-Games
641
Dragon Ancestral [3]
Registrado: Años de membresíaAños de membresía
Ubicación: Castelar
Mensajes: 3414
Aportes: 66
Premios: 3
Usuario omnipresente (1) Embajador (2)

Nota » 02 Feb 2012 13:24

Con el AOSetup, se puede elegir arboles chicos, medianos o grandes. eso corresponde al Graficos1.ind, Graficos2.ind y Graficos3.ind, creo que si alguien cambia los arbolitos se le va a armar un error de la rre put* madre, ustedes creen que esos archivos estan de adorno? xd

Samke escribió:
maTih.- escribió:pero y los arbolitos chicos ? :P


eh?? que arbolitos chicos?

Saludos ^^
Mayra Arduini (L
529
Aprendiz [7]
Registrado: Mayo 2011
Mensajes: 470
Aportes: 8

Nota » 02 Feb 2012 13:49

Feer159 escribió:Con el AOSetup, se puede elegir arboles chicos, medianos o grandes. eso corresponde al Graficos1.ind, Graficos2.ind y Graficos3.ind, creo que si alguien cambia los arbolitos se le va a armar un error de la rre put* madre, ustedes creen que esos archivos estan de adorno? xd

Samke escribió:
maTih.- escribió:pero y los arbolitos chicos ? :P


eh?? que arbolitos chicos?

Saludos ^^


Y yo quiero saber quien usa esos arbolitos?, nadie, todos usan los normales, es decision de cada 1 si le gusta o no la carga.

Saludos ^^

Imagen
Imagen
Staff Zeiked-Games
641
Dragon Ancestral [3]
Registrado: Años de membresíaAños de membresía
Ubicación: Castelar
Mensajes: 3414
Aportes: 66
Premios: 3
Usuario omnipresente (1) Embajador (2)

Nota » 02 Feb 2012 14:24

ta bueno :P

es util lo de los graficos.ind, aunke, con el tema de graficos, prefiero los comprimidos, es simple, solo cambiamos el code del indexador, o extramos los graficos en otra carpeta

pero me gusto el de los graficos, es un ahorro :P

y con el tema de los arboles, se puede hace una function como el hayagua, pero con el grh de los arboles, y dentro del ddrawgrhtranstosurface le metemos un condicional #UsaMiniArbolitos = 1 then

y le mandan resize al hayarbol = true :P

creo q ise medio bolnki pero me entiendo xD



Santty.- escribió:Si, soy hincha de tu padre, el que te gana cada vez que te cruza, el dueño del barrio, el orgullo nacional, rey de copas y el máximo ganador de copa libertadores

PROBLEM?





La gente que cuando camina mueve un poco los labios está practicando respuestas originales para discusiones que ya perdieron hace dos horas.
YPF etatizada: -Hola q carga? -Deme Néstor Súper
681
Dragon Ancestral [4]
Registrado: Años de membresíaAños de membresía
Ubicación: Mendoza
Mensajes: 3545
Aportes: 40

Nota » 02 Feb 2012 16:23

Samke escribió:
Feer159 escribió:Con el AOSetup, se puede elegir arboles chicos, medianos o grandes. eso corresponde al Graficos1.ind, Graficos2.ind y Graficos3.ind, creo que si alguien cambia los arbolitos se le va a armar un error de la rre put* madre, ustedes creen que esos archivos estan de adorno? xd

Samke escribió:
eh?? que arbolitos chicos?

Saludos ^^


Y yo quiero saber quien usa esos arbolitos?, nadie, todos usan los normales, es decision de cada 1 si le gusta o no la carga.

Saludos ^^


Todo alkon los usa, vah, yo los uso en todos los servers que juego, se me hace mas cómodo ver arbolitos mini y no unos arboles gigantes que te cagan la vida.

LyRan escribió:Buenos Dias amigos y programadores de Gs Zone, Me gustaria pedirle la amabilidad de una ayuda con un cliente editado para mi Ao casero, Osea me explico, yo juego Ao con varios amigos y ellos todos usan cheat y no me gusta eso me gustaria que alguien me ayudara a crear un cliente editado con auto poteo de ambas potas a la ves ya sea que se alla gastado Mana lanzando algun hechis y comienze a potear solo hasta estar completamente el Mana, igual para la salud y poteo rapido para ambos.
mAnco programEr
794
Oraculo [5]
Registrado: Años de membresíaAños de membresía
Ubicación: Bolivia
Mensajes: 2289
Aportes: 109

Nota » 02 Feb 2012 16:29

maTih.- escribió:
Todo alkon los usa, vah, yo los uso en todos los servers que juego, se me hace mas cómodo ver arbolitos mini y no unos arboles gigantes que te cagan la vida.


boske dork + lvl bajo + araña = casper ^^



Santty.- escribió:Si, soy hincha de tu padre, el que te gana cada vez que te cruza, el dueño del barrio, el orgullo nacional, rey de copas y el máximo ganador de copa libertadores

PROBLEM?





La gente que cuando camina mueve un poco los labios está practicando respuestas originales para discusiones que ya perdieron hace dos horas.
YPF etatizada: -Hola q carga? -Deme Néstor Súper
681
Dragon Ancestral [4]
Registrado: Años de membresíaAños de membresía
Ubicación: Mendoza
Mensajes: 3545
Aportes: 40

Nota » 02 Feb 2012 18:12

GoDKeR escribió:
maTih.- escribió:
Todo alkon los usa, vah, yo los uso en todos los servers que juego, se me hace mas cómodo ver arbolitos mini y no unos arboles gigantes que te cagan la vida.


boske dork + lvl bajo + araña = casper ^^


ahi esta el claro ejemplo de alguien que entiende el juego.

si quieren usar este post, por favor borren el Graficos2 y el Graficos3 y al Graficos1 cambienle el nombre como explica en el post :P

LyRan escribió:Buenos Dias amigos y programadores de Gs Zone, Me gustaria pedirle la amabilidad de una ayuda con un cliente editado para mi Ao casero, Osea me explico, yo juego Ao con varios amigos y ellos todos usan cheat y no me gusta eso me gustaria que alguien me ayudara a crear un cliente editado con auto poteo de ambas potas a la ves ya sea que se alla gastado Mana lanzando algun hechis y comienze a potear solo hasta estar completamente el Mana, igual para la salud y poteo rapido para ambos.
mAnco programEr
794
Oraculo [5]
Registrado: Años de membresíaAños de membresía
Ubicación: Bolivia
Mensajes: 2289
Aportes: 109

Nota » 02 Feb 2012 19:50

maTih.- escribió:
GoDKeR escribió:
maTih.- escribió:
Todo alkon los usa, vah, yo los uso en todos los servers que juego, se me hace mas cómodo ver arbolitos mini y no unos arboles gigantes que te cagan la vida.


boske dork + lvl bajo + araña = casper ^^


ahi esta el claro ejemplo de alguien que entiende el juego.

si quieren usar este post, por favor borren el Graficos2 y el Graficos3 y al Graficos1 cambienle el nombre como explica en el post :P



Aguante los arboles medianos ^_^
buen code para los que no tienen gana de indexar mucho

Imagen
Ninja en progreso
914
Dragon Ancestral [5]
Registrado: Años de membresía
Ubicación: • olivos •
Mensajes: 4094
Aportes: 13

Nota » 02 Feb 2012 20:06

YO prefieron que carge con arboles medianos ya que son casi iguales que los grandes y ademas tienen transparencia.
Usuario Registrado
104
Newbie [3]
Registrado: Agosto 2011
Mensajes: 86

Nota » 02 Feb 2012 20:55

Samke escribió:
Feer159 escribió:Con el AOSetup, se puede elegir arboles chicos, medianos o grandes. eso corresponde al Graficos1.ind, Graficos2.ind y Graficos3.ind, creo que si alguien cambia los arbolitos se le va a armar un error de la rre put* madre, ustedes creen que esos archivos estan de adorno? xd

Samke escribió:
eh?? que arbolitos chicos?

Saludos ^^


Y yo quiero saber quien usa esos arbolitos?, nadie, todos usan los normales, es decision de cada 1 si le gusta o no la carga.

Saludos ^^



no hables en plural, yo en la netbook uso arboles medianos o chicos porque me molestan.
Mayra Arduini (L
529
Aprendiz [7]
Registrado: Mayo 2011
Mensajes: 470
Aportes: 8

Siguiente

Volver a AO 0.13.x

¿Quién está conectado?

Usuarios navegando por este Foro: No hay usuarios registrados visitando el Foro y 0 invitados