| Mirage Source http://miragesource.net/forums/ |
|
| Very Simple Optimize Max Looping http://miragesource.net/forums/viewtopic.php?f=210&t=1366 |
Page 1 of 2 |
| Author: | Bakekitsune [ Fri Feb 16, 2007 9:26 am ] |
| Post subject: | Very Simple Optimize Max Looping |
I just figured this out just then lol but im pretty sure this should work... *currently Code: public const buffer = 3
do while z<buffer for i = 1 to max_players if player(i).name <> vbnullstring z = z+1 else //do procedure end if do events z = 0 Currently many Optimize Looping procedures require heavy coding or packets and don't contain a buffer. This procedure contains a buffer, in which if player(x) has no data the buffer will allow this to happen 3 more times before it will assume the end and exit straight away. This will allow MAX_PLAYERS to be of any value and keep the memory and time at a minimum without risking a player not being read because a slot is empty before him. You can change the buffer according to what you want... for example buffer = 3 MAX_PLAYERS = 1000 player(1-6) = "bleach", "blah" , etc player(7) = "" //starts buffer player(8, 9, 10) = "bla" , "ichigo", "akira" player(11, 12, 13) = "" Exit |
|
| Author: | William [ Fri Feb 16, 2007 9:48 am ] |
| Post subject: | |
Well, it should be like this: Code: For i = 1 to MAX_PLAYERS
If Trim(Player(i).Name) = vbNullString then ' Next i kinda thing Else HIGH_PLAYER_INDEX = i End if Next i Im pretty sure that would work to the easiest part, but there are several things like this around. And I dont like this way, the MAX_ values aint that high anyway. |
|
| Author: | Bakekitsune [ Fri Feb 16, 2007 10:09 am ] |
| Post subject: | |
Lol no the whole point of this was to remove the High_Index crap and all the other codes that tries to find high_index which is pointless because it wastes memory anyway. this just exits the procedure once theres no players left and requires no extra procedures. And high index wont work unless no one has logged out since logging in actually it should be this Code: for i = 1 to max_players
if player(index).name <> vbnullstring and z < 3 then z = z + 1 //procedure goes here else z = 0 exit for next i that would give room for error if there are up to 3 indexs above the first cleared index that are cleared and havent been yet filled (which would probably never happen but you never know |
|
| Author: | William [ Fri Feb 16, 2007 10:11 am ] |
| Post subject: | |
Thats one messy code. You messed everything up in it. |
|
| Author: | Bakekitsune [ Fri Feb 16, 2007 10:18 am ] |
| Post subject: | |
lol sorry *fixed actually thanks for making me realise the error that alot has made in optimizing max_looping, that if a player is cleared it will ruin the whole procedure until someone else fills its place, which gave me the idea of the 3 index buffer. |
|
| Author: | William [ Fri Feb 16, 2007 10:40 am ] |
| Post subject: | |
Code: for i = 1 to max_players
if player(index).name <> vbnullstring and z < 3 then z = z + 1 //procedure goes here else z = 0 exit for next i Is not yet fixed =/ |
|
| Author: | Bakekitsune [ Fri Feb 16, 2007 10:50 am ] |
| Post subject: | |
lol how not? |
|
| Author: | William [ Fri Feb 16, 2007 10:52 am ] |
| Post subject: | |
You have a exit for, so it will only run once I =1. And there are no End if. |
|
| Author: | Bakekitsune [ Fri Feb 16, 2007 10:58 am ] |
| Post subject: | |
*fixed Lol no "exit for" only executes on the else after the buffer Code: for i = 1 to max_players
if player(index).name <> vbnullstring and z < 3 then z = z + 1 //procedure goes here else z = 0 exit for end if next i |
|
| Author: | William [ Fri Feb 16, 2007 11:00 am ] |
| Post subject: | |
But there was no end if before... therefore it ran each time and it exited the loop. |
|
| Author: | Bakekitsune [ Fri Feb 16, 2007 11:05 am ] |
| Post subject: | |
lol thanks I remake lol its late and im really tired from soccer no wonder theres so many mistakes Code: do while z<3
for i = 1 to max_players if player(index).name <> vbnullstring z = z+1 else //do procedure end if do events z = 0 is this ok or have i forgot something again lol |
|
| Author: | William [ Fri Feb 16, 2007 11:31 am ] |
| Post subject: | |
Code: player(index).name should be: Code: player(i).name
Still I dont understand what you are trying to do with it. |
|
| Author: | Bakekitsune [ Fri Feb 16, 2007 12:37 pm ] |
| Post subject: | |
basically if there is a slot with no information it is a slot with no player. afterwards if this is found three more times then it assumes the end and exits the loop thus saving time and RAM because it exited before getting to max_players. the 3 player buffer is there in case up to three players have left without anyone filling the slots and they are in the middle of the index range. |
|
| Author: | Robin [ Fri Jul 06, 2007 9:58 pm ] |
| Post subject: | Re: Very Simple Optimize Max Looping |
Sorry to bring up an old topic, but if you had 24 people online, and the first 4 log out without anyone logging in, you're screwed. |
|
| Page 1 of 2 | All times are UTC |
| Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |
|