| Mirage Source http://miragesource.net/forums/ |
|
| Clearing array error http://miragesource.net/forums/viewtopic.php?f=201&t=3308 |
Page 1 of 1 |
| Author: | GIAKEN [ Thu Jan 24, 2008 4:33 am ] |
| Post subject: | Clearing array error |
Alrighty then...as I was looking through optimizations, I stumbled upon how to clear players and such easier: Code: Sub ClearPlayer(ByVal Index As Long) Dim EmptyPlayer As AccountRec Player(Index) = EmptyPlayer End Sub I've also stumbled upon a problem with this. For strings that are given a max length property (like Name As String * NAME_LENGTH) the value of that string is given the number of spaces the property's number is (so for Name it would be given 20 spaces, since NAME_LENGTH is 20). So now every check for If Player().Whatever = "" or vbNullString, the value will return opposite of what we want...for example: Code: Function IsLoggedIn(ByVal Index As Long) As Boolean If IsConnected(Index) And Trim$(Player(Index).Login) <> vbNullString Then MsgBox Player(Index).Login IsLoggedIn = True Else IsLoggedIn = False End If End Function That will always return true and won't let anybody login. What's the best way to solve this? I know to just set them = "", but that's too tedious...there has to be another way than going through all the Clear subs and checking all the strings in the array and making sure they're set to "". |
|
| Author: | Lea [ Thu Jan 24, 2008 5:28 am ] |
| Post subject: | Re: Clearing array error |
Setting them to something is the only option. String = vbNullString is the easiest. |
|
| Author: | GIAKEN [ Thu Jan 24, 2008 7:32 pm ] |
| Post subject: | Re: Clearing array error |
Could I just remove the fixed lengths on the strings? I don't think they're needed, really...just do a length check to verify it's good when they register and so on. |
|
| Author: | Lea [ Thu Jan 24, 2008 7:39 pm ] |
| Post subject: | Re: Clearing array error |
It makes things a bit easier, but it's not needed. Go ahead and take the limits off. You'll need to make sure everything that is a fixed length string is still working as it should. |
|
| Author: | GIAKEN [ Thu Jan 24, 2008 7:59 pm ] |
| Post subject: | Re: Clearing array error |
Alrighty then...thanks for the help. The source is looking nice |
|
| Author: | Robin [ Fri Jan 25, 2008 2:54 pm ] |
| Post subject: | Re: Clearing array error |
That's not hard |
|
| Author: | GIAKEN [ Sat Jan 26, 2008 6:33 pm ] |
| Post subject: | Re: Clearing array error |
I know, it was really simple. I just thought there was an easier way with the empty array to clean it out without giving it the spaces. |
|
| Author: | Robin [ Sat Jan 26, 2008 7:09 pm ] |
| Post subject: | Re: Clearing array error |
Oops, forgot to quote again. Was talking about this: GIAKEN wrote: It's much cleaner than Elysium's is right now.
|
|
| Page 1 of 1 | All times are UTC |
| Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |
|