03-09-2008, 06:09 PM
I changed the way MS was saving files and decided to save all the shops in one and spells in one etc.
After some testing I noticed that the server only clears the first shop, spell, item. It doesn't clear the rest after that. I think there is something wrong with my method?
Here is spells for example and since the SpellEditor LevelReq has to be set to 1 because the scroll bars minimum is 1 it gives me an error when I try to edit any spells after the first one. I hope this is making sense
.
So I clear the spell.
Setting LevelReq to 1 like the original MS did. Then my saving and loading code.
Thanks for the help!
After some testing I noticed that the server only clears the first shop, spell, item. It doesn't clear the rest after that. I think there is something wrong with my method?
Here is spells for example and since the SpellEditor LevelReq has to be set to 1 because the scroll bars minimum is 1 it gives me an error when I try to edit any spells after the first one. I hope this is making sense

So I clear the spell.
Code:
Sub ClearSpell(ByVal Index As Long)
Call ZeroMemory(ByVal VarPtr(Spell(Index)), LenB(Spell(Index)))
Spell(Index).Name = vbNullString
Spell(Index).LevelReq = 1 ' Needs to be 1 for spell editor
End Sub
Setting LevelReq to 1 like the original MS did. Then my saving and loading code.
Code:
Sub SaveSpells()
Dim i As Long
Call SetStatus("Saving Spells... ")
For i = 1 To MAX_SPELLS
If Not FileExist(GENERAL_PATH & "spells.dat") Then
Call SaveSpell(i)
End If
Next i
End Sub
Sub SaveSpell(ByVal SpellNum As Long)
Dim FileName As String
Dim f As Integer
Dim StartByte As Long
FileName = App.Path & GENERAL_PATH & "spells.dat"
f = FreeFile
StartByte = LenB(Spell(SpellNum)) * (SpellNum - 1) + 1
Open FileName For Binary As #f
Put #f, StartByte, Spell(SpellNum)
Close #f
End Sub
Sub LoadSpells()
Dim FileName As String
Dim StartByte As Long
Dim i As Long
Dim f As Long
Call CheckSpells
For i = 1 To MAX_SPELLS
FileName = App.Path & GENERAL_PATH & "spells.dat"
f = FreeFile
StartByte = LenB(Spell(i)) * (i - 1) + 1
Open FileName For Binary As #f
Get #f, StartByte, Spell(i)
Close #f
Next i
End Sub
Thanks for the help!
