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
#2
Wont this screw things up. Cause what if I play and get map 1,2,3.. And then the owner edits map 2. And then i wont get it again because if I have map2. Skip to reload it ?
Reply
#3
If the revision is different then it saves the map again. Otherwise, you recieve the map (and before it saves) it loads the map, then it saves the map, and loads it again.
Reply
#4
Obsidian Wrote:If the revision is different then it saves the map again. Otherwise, you recieve the map (and before it saves) it loads the map, then it saves the map, and loads it again.

Aha, okay.
Reply
#5
I cant compile this I get errors >,>

"Only comments may appear after End Sub , End Function , or End Property."

And it highlights MAP_PATH , I deleted all comments since it says so but it wont fix it
Reply
#6
This is for MSE, im guessing you have an older MS or are using elysium?

just replace whatever is the right filepath to your maps folder, in mse MAP_PATH is a constant which equals "/maps/" I think. So you can just substitute that value in.
Reply
#7
Oh no the path is /maps/ I saw it and Im using ME I wont use elysium because I want to do all by myself and learn
Reply
#8
I dunno...its problably some stupid mistake you did, happens to me all the time. Try posting the whole section (everyting in the "checkformap" packet if block).
Reply
#9
Krloz Wrote:I cant compile this I get errors >,>

"Only comments may appear after End Sub , End Function , or End Property."

And it highlights MAP_PATH , I deleted all comments since it says so but it wont fix it

It didn't ask you to delete all comments, it said that 'only comments may appear after End Sub...'

This means you have something that is not in a sub, and only lines of code with a " ' " may appear outside of a sub (or a function... or a Property)

Make sure all your code is inside a valid sub.
Reply
#10
Ok Fixed that but now everytime I try to compile I get another error

"Exit function not allowed in Sub or Property"

I tried to commenting the exit function but when I try to compile it goes to the next exit function and the same error I tried to change exit sub to exit function , didnt work,

Tried to comment every exit function I get error but It wont work o.O
Reply
#11
maybe it should be an Exit Sub instead?
Reply
#12
Ya dr.spoon ur right =D Good to see you here Tongue


Fixes for it :
Changed every exit function to exit sub.
Reply
#13
What does this have to do with my tutorial? If you have problems of your own not relating to the tutorial please make them in their own topic, I don't see exit function anywhere in my tutorial.
Reply
#14
Just posting it there if someone else has this problem... I am trying to help >,>
Reply
#15
I'm not mad at you for posting the solution..posting your solutions is good, its just, I don't think you should have asked your question here in the first place. Unless you thought it was because of this tutorial.

Its just, it wasnt my tutorial that caused the problem and its mainly for the future, post in troubleshooting, unless it actually involves the tutorial you're posting in. :\

How can you make sure? Only do one thing at a time before testing so its easier to find what may be causing the problem. Wink
Reply
#16
I get exactly the same error as him hrhr,

its the code directly beneath what you changed

Code:
' Either the revisions didn't match or we dont have the map, so we need it
        Call SendData("needmap" & SEP_CHAR & "yes" & SEP_CHAR & END_CHAR)
        Exit Function
    End If

I dont see how it was a function in the first place but meh

Edit:

lol even though i undid the stages in this tutorial its still giving me this error now. Bloody wierd, and bloody annoying...

-raises hand-

A little help? ^_^

How has the exit function sat there quite happily untill this happened? =p

Edit 2: It now disagree's with ever exit function in sub handledata, changing all to exit sub... dunno what has happened >.>
Reply
#17
You're weird. Tongue

Are you still having problems? I can't tell...
Reply
#18
So is that just an easier method Dave or what?

(I never read through the original code..)
Reply
#19
Ah. Like I said, I didn't read through the tutorial in the first place.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)