| Mirage Source http://miragesource.net/forums/ |
|
| SetHighMaxMap http://miragesource.net/forums/viewtopic.php?f=201&t=808 |
Page 1 of 1 |
| Author: | William [ Thu Dec 07, 2006 3:39 pm ] |
| Post subject: | SetHighMaxMap |
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.. 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. ps. some types are needed for it to work. At least I have my head focused at optimizations |
|
| Author: | GodSentDeath [ Thu Dec 07, 2006 6:17 pm ] |
| Post subject: | |
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 =) |
|
| Author: | William [ Thu Dec 07, 2006 8:09 pm ] |
| Post subject: | |
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. |
|
| Author: | pingu [ Thu Dec 07, 2006 10:12 pm ] |
| Post subject: | |
How many "For i = 1 To MAX_MAPS" loops are there? |
|
| Author: | William [ Thu Dec 07, 2006 10:16 pm ] |
| Post subject: | |
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 |
|
| Author: | Dragoons Master [ Fri Dec 08, 2006 12:50 am ] |
| Post subject: | |
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. |
|
| Author: | GodSentDeath [ Fri Dec 08, 2006 7:35 am ] |
| Post subject: | Re: SetHighMaxMap |
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 |
|
| Author: | William [ Fri Dec 08, 2006 2:05 pm ] |
| Post subject: | |
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. |
|
| Author: | GodSentDeath [ Sat Dec 09, 2006 11:17 pm ] |
| Post subject: | |
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 =) |
|
| Author: | William [ Sun Dec 10, 2006 8:35 pm ] |
| Post subject: | |
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. |
|
| Page 1 of 1 | All times are UTC |
| Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |
|