Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Optimize MAX_ Looping
#1
Tutorial is not yet Finished

By: William
Difficulty: 2/5

Introduction
This will make the looping smaller for all of your MAX_ (ex. MAX_MAPS, MAX_ITEMS...). So instead of looping from 1 to 1000, maybe you only have 50edited maps, then it will loop from 1 to 50 instead. Of course, if you are making your own game using a source, you can simply choose your own MAX value, and you can probably do that for a engine too. But anyway, I'll make this tutorial for all of you anyway. This is recommended for engines, since the users of the engine doesn't really consider the MAX and often has it on 1000. Which means 1000 loops for probably around 30maps for example.

Server Side
First of all, open frmServer and go into Private Sub Form_load() At the bottom of that sub, add:
Code:
Call SetHighMaxMap
Call SetHighMaxItems
Call SetHighMaxNPCS
Call SetHighMaxItems
Call SetHighMaxShops
Call SetHighMaxSpells
Now, in the bottom of modGameLogic, add:
Code:
Public Sub SetHighMaxMap()
Dim FilePath As String
Dim f As Long, i As Long, Added As Long

    For i = 1 To MAX_MAPS
        f = FreeFile
        FilePath = App.Path & "\Maps\Map" & i & ".dat"
        Open FilePath For Binary As #f
            Get #f, , HighMap(i)
            If HighMap(i).HighTile(0, 0).Ground  0 Then
                HIGH_MAX_MAPS = i
            Elseif HighMap(i).HighTile(0, 0).Mask  0 Then
                HIGH_MAX_MAPS = i
            Elseif HighMap(i).HighTile(0, 0).Fringe  0 Then
                HIGH_MAX_MAPS = i
            End if
        Close
    Next i
End Sub

Public Sub SetHighMaxItems()
End Sub
Public Sub SetHighMaxNPCS()
End Sub
Public Sub SetHighMaxItems()
End Sub
Public Sub SetHighMaxShops()
End Sub
Public Sub SetHighMaxSpells()
End Sub
Now for HIGH_MAX_MAPS replace all but these:
Code:
Sub SaveMaps()
Sub LoadMaps()
Sub CheckMaps()

Under Construction
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)