![]() |
Clear Player - Printable Version +- Mirage Source (https://mirage-engine.uk/forums) +-- Forum: Mirage Source (Nostalgia) (https://mirage-engine.uk/forums/forumdisplay.php?fid=61) +--- Forum: Archive (2006-2011) (https://mirage-engine.uk/forums/forumdisplay.php?fid=18) +---- Forum: Resources (https://mirage-engine.uk/forums/forumdisplay.php?fid=49) +---- Thread: Clear Player (/showthread.php?tid=428) |
Clear Player - William - 25-11-2006 If you have a unedited ClearPlayer, replace this: Code: Sub ClearPlayer(ByVal Index As Long) Code: Sub ClearPlayer(ByVal Index As Long) The change is that you put this: Code: ' Temporary vars ![]() - Spodi - 25-11-2006 How about this: Code: Sub ClearPlayer(ByVal Index As Long) Done. :wink: - William - 25-11-2006 Code: Dim EmptyPlayer as PlayerRec Does that really work? Seems logical though ![]() - Spodi - 25-11-2006 Works just fine. It is how I do it in vbGORE. :wink: - William - 25-11-2006 Seems cool ![]() ![]() - Obsidian - 26-11-2006 Yeah that works. It's how i've been doing it for a while... after i rewrote all the MS stuff in binary i realized it was easier to clear everything that way than it was to go back and do it all by hand. ![]() - Dragoons Master - 27-11-2006 I use a diferent way. I can't remember who did it, but it was someone from here(I think it was Verrigan): Declare this: Code: Public Declare Sub FillMemory Lib "kernel32.dll" Alias "RtlFillMemory" (Destination As Any, ByVal Length As Long, ByVal Fill As Byte) Code: Call FillMemory(ByVal VarPtr(Npc(Index)), LenB(Npc(Index)), 0) EDIT: Btw, I'm not using it only for Players, and I don't know why... ![]() - Spodi - 27-11-2006 Probably is faster, yeah. Thats a good idea, Verrigan. Why don't you just use ZeroMemory then, though? ZeroMemory is faster then FillMemory. - Matt - 28-11-2006 Spodi, you realize, that was DM that posted that, not Verrigan. Lol. Please don't edit your post, it will seriously make me look stupid. >. - William - 28-11-2006 DM said he got it from Verrigan. - Matt - 28-11-2006 He said he thinks he got it from Ver. And be that so, it was still DM that said it in this topic, not Ver. - Spodi - 28-11-2006 Quote:but it was someone from here(I think it was Verrigan): :wink: That sounds like something Verrigan would say, too. :wink: - Spodi - 28-11-2006 Your testing environment is pretty unrealistic, though. You're not going to be clearing 50000000 byte UDTs. Using my speed template: 1 = Zero, 2 = Fill Quote:%Faster -2.5| -3.7| -3.7| -3.7| -1.2| -2.5| -1.2| -1.2| -1.2| -1.2 1 = Fill, 2 = Zero Quote:%Faster 1.3| 2.5| 2.5| 2.5| 1.3| 0| 2.5| 1.3| 2.5| 1.3 Specs: Code: Public t(0 To 999) As Byte Code: ZeroMemory t(0), 1000 Code: FillMemory t(0), 1000, 0 Code: Private Const lngIterations As Long = 1000000 The difference is hardly even noteable, though, like you said. Just nit-picking, though. :wink: - Dragoons Master - 28-11-2006 Well, I'm having a problem with the FillMemory being used w/ the player array. When it clears a fixed-size string is does not set its text to vbnullstring, it changes to a lot of boxes, you know? so I need to use a diferent sub, like this one: Code: Sub ClearPlayer(ByVal Index As Long) - Spodi - 28-11-2006 Verrigan Wrote:I wonder why your ZeroMemory() calls are almost always faster, when mine are not. AMD. I also have a lot more loops going, while yours is just a few loops on a huge chunk of memory. FillMemory probably has a bit more of an overhead, but they both work at nearly the same speed, so since yours only has 50 calls and all the time went to the actual routine, mine has a lot more so the overhead is much more distinguishable. *shrugs* - Xlithan - 21-01-2007 Spodi Wrote:How about this: That's all we need for the entire sub? - William - 22-01-2007 That should work, just test it. - Xlithan - 22-01-2007 Can the same method be used for the other Clear subs, like ClearNPC? - William - 22-01-2007 GameBoy Wrote:Can the same method be used for the other Clear subs, like ClearNPC?yes it can. - Xlithan - 22-01-2007 Cool, I can cut down on some lines then ![]() Also, I get a type mismatch on Player(Index), should it be PlayerRec(Index) or something? - William - 22-01-2007 Then try the fillmemory instead. - Spodi - 22-01-2007 I was giving a pseudo-code, not exactly how it should be. And yes, using ZeroMemory (or FillMemory) would be better and faster. Code: ZeroMemory Player(Index), Len(Player(Index)) Something like that. - grimsk8ter11 - 22-01-2007 If PlayerRec is public them Dim EmptyPlayer as PlayerRec player(index) = emptyplayer would work |