Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
SetHighMaxMap
#1
I know this is useless, but my internet was down yesterday so I thought I should do something:

Code:
Public Sub SetHighMaxMap()
Dim FilePath As String
Dim f As Long, i 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
            End If
        Close
    Next i
End Sub

This could be usefull for Engines (not games), cause in a engine you might set the max_maps = 1000, and you only use 15 maps.. Tongue So then it will only loop to 15.

This can easily be done for all the different MAX_ thingys, but I don't think its a good idea. Just thought I should post it. Tongue

ps. some types are needed for it to work.

At least I have my head focused at optimizations Tongue
Reply
#2
What if for whatever reason the map doesn't use tile 0/0 and keeps it blank causing it to not be detected by this code? Or even if the tile is used but it's used by something other then ground?

Just some thoughts, but nice little code either way =)
Reply
#3
Well under:
Code:
If HighMap(i).HighTile(0, 0).Ground  0 Then
                HIGH_MAX_MAPS = i
            End If
You could have:

Code:
If HighMap(i).HighTile(0, 0).Mask  0 Then
                HIGH_MAX_MAPS = i
            End If
Code:
If HighMap(i).HighTile(0, 0).Fringe  0 Then
                HIGH_MAX_MAPS = i
            End If
Because you most have a gfx on one of the layer if you dont want it black. And now if you have a house on the middle of a map, with warp to it. You can just put a tile in the top left. Or make a loop to check for a tile on all layers. The purpose with my code was that you be aware of what tile it checks. And so the SetHighMap sub would run fast.
Reply
#4
How many "For i = 1 To MAX_MAPS" loops are there?
Reply
#5
I don't know, havn't counted, but I know there are one in the game loop server side. And there some client side too Tongue
Reply
#6
IMO the most important of all MS's "For" is the AI one, it executes all the time and if it's smaller than max_maps it can speed up a lot the server.
Reply
#7
Not that I know if this works for sure, I don't have my VB installed to test it and I haven't touched coding in a long time >< but stealing Spodi's example for clearing players try this:


Code:
Public Sub SetHighMaxMap()
Dim FilePath As String
Dim f As Long, i As Long
Dim EmptyMap As Maprec

    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)  EmptyMap Then
                HIGH_MAX_MAPS = i
            End If
        Close
    Next i
End Sub
I added
Code:
Dim EmptyMap As Maprec
to the top and changed
Code:
If HighMap(i).HighTile(0, 0).Ground  0 Then
to
Code:
If HighMap(i)  EmptyMap Then

Just an idea, don't know if it'll work =) Seems logical enough though =P
Reply
#8
Yeah, it does seem logical =P Seems to work fine from what I can see. Cant try it now thought. Is it worth making a tut from? I can do it for all the different MAX_ if its usefull.
Reply
#9
It'd be a nice little tutorial if you did it for a few of the "max" objects.
But you'd have to make it work with the current version of MS meaning you'd have to tell them where to define the HIGH_MAX_MAPS variable, etc etc!

Otherwise, yeah, go for it =)
Reply
#10
Yeah I know. Well I know what Grim told me. It's never good to use non-constant variables for loops. And I don't know what speed changes it will be. But I guess I can complete a tutorial for it.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)