Mirage Source http://web.miragesource.net/forums/ |
|
Optimize MAX_ Looping http://web.miragesource.net/forums/viewtopic.php?f=210&t=892 |
Page 1 of 1 |
Author: | William [ Wed Dec 20, 2006 8:03 pm ] |
Post subject: | Optimize MAX_ Looping |
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 |
Author: | Bradyok [ Mon Jan 15, 2007 5:50 pm ] |
Post subject: | |
In most games i've seen, if they have say 1000 maps, and only use 50 of them, they still usually put a map at #1000, thus rendering this useless. Reguardless, this is a still a good tutorial. |
Author: | Obsidian [ Mon Jan 15, 2007 7:10 pm ] |
Post subject: | |
Just to point out, you don't have to use Get, , HighMap(i) You can just keep using your normal Map(i), so you don't have to point another variable at the maprec... Same with the tile part. It may also be better... to do this by the 'Revision' variable from the maprec. When maps are cleared... it is automatically set to 0. It doesn't increase unless someone edits the map... |
Author: | William [ Tue Jan 16, 2007 8:10 am ] |
Post subject: | |
NOt going to complete the tutorial, you get a hint from whats there now. ANd this sisnt really a good way. |
Author: | Matt [ Tue Jan 16, 2007 2:12 pm ] |
Post subject: | |
If it isn't a good method, then why keep the tut at all? |
Author: | Spodi [ Tue Jan 16, 2007 3:20 pm ] |
Post subject: | |
Since it is bad practice in the first place to just jump numbers like that, and good coding/designing practice goes hand-in-hand with fast code? |
Author: | William [ Tue Jan 16, 2007 3:42 pm ] |
Post subject: | |
Advocate wrote: If it isn't a good method, then why keep the tut at all? It's like high_index, it decreases the numbers of loops. But still it doesn't help much. Spodi wrote: Since it is bad practice in the first place to just jump numbers like that, and good coding/designing practice goes hand-in-hand with fast code?
Dont understand what you mean |
Author: | Spodi [ Tue Jan 16, 2007 5:11 pm ] |
Post subject: | |
Well what I mean is that you can't write well optimizations if the code is used poorly. For example, there is absolutely no point in skipping around the index of maps and leaving indexes open. Yeah you may want to sort your maps, but do that somewhere else - keep a document of the index, map name and description or whatever, since leaving 100 indexes open between maps "because you might use it later" is just dumb. William has the right idea on using the high index instead of the max index. This also prevents you from even having to specify a max maps value, since the high index does it for you. |
Author: | William [ Tue Jan 16, 2007 5:35 pm ] |
Post subject: | |
Spodi wrote: Well what I mean is that you can't write well optimizations if the code is used poorly. For example, there is absolutely no point in skipping around the index of maps and leaving indexes open. Yeah you may want to sort your maps, but do that somewhere else - keep a document of the index, map name and description or whatever, since leaving 100 indexes open between maps "because you might use it later" is just dumb. William has the right idea on using the high index instead of the max index. This also prevents you from even having to specify a max maps value, since the high index does it for you.
Yes, very true. I would not add this to a game, since you have full control over the MAX_, instead it could be added for a engine, since the users are lazy when it comes to decide the max values. |
Page 1 of 1 | All times are UTC |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |