Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Don't load the map twice
#1
in the checkmap packet...find this:
Code:
If FileExist(MAP_PATH & "map" & x & MAP_EXT, True) Then
            ' Check to see if the revisions match
            If GetMapRevision(x) = y Then
                ' We do so we dont need the map
                
                ' Load the map
                Call LoadMap(x)
                
                Call SendData("needmap" & SEP_CHAR & "no" & SEP_CHAR & END_CHAR)
                Exit Sub
            End If
        End If

well then lets carry on.
you know what getmaprevision does? it loads the map, then if it is the same, it loads it again? wtf!

soooo
make a new function in mod datebase called getMap, something like this
Code:
Public Function getMap(ByVal MapNum As Long) As MapRec
Dim FileName As String
Dim f As Long

    FileName = App.Path & MAP_PATH & "map" & MapNum & MAP_EXT
        
    f = FreeFile
    Open FileName For Binary As #f
        Get #f, , getMap
    Close #f
End Function

though it would be better if you just made loadmap a function with this code from above and have every instance of call loadmap(mapnum) (or most anyway) be changed to SaveMap=LoadMap(mapNum)

now change the first code I showed(the part in the checkmap packet)
change it to something like thiiiis:
Code:
If FileExist(MAP_PATH & "map" & x & MAP_EXT, True) Then
            ' Check to see if the revisions match
            Dim tempMap As MapRec
            tempMap = getMap(x)
            If tempMap.Revision = y Then
                SaveMap = tempMap
              
                Call SendData("needmap" & SEP_CHAR & "no" & SEP_CHAR & END_CHAR)
                Exit Sub
            End If
        End If

[If you did it the other way and made loadMap a function instead of making a redundant getMap function then good for you, you should then be smart enough to know what to do(change get for load here)]

tada, I sound like an idiot, but you SHOULD get what im sayin, why didnt anyone notice this before? gah.
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)