Upgrade 1.0.12 to 1.0.13
From VbGORE Visual Basic Online RPG Engine
This guide will lead you through how to upgrade Version 1.0.12 to Version 1.0.13. For help, please refer to the How to upgrade article. It is highly recommended you read it before ever upgrading.
Add - Auto-saving
Open GameServer.vbp.
Find:
<vb>
'*** Cooldown ***
</vb>
Before, add:
<vb>
'Check for auto-saving
If LastUpdate_Save + UpdateRate_Save < LoopStartTime Then
LastUpdate_Save = LoopStartTime
If NumUsers > 0 Then
For i = 1 To LastUser
If UserList(i).Flags.UserLogged Then
If UserList(i).Flags.Disconnecting = 0 Then
Save_User UserList(i), i
End If
End If
Next i
End If
End If
</vb>
Find:
<vb> Private Const UpdateRate_KeepAliveClient As Long = 3000 'Sends a "keep alive" packet to the client to let them know the connection is still made with the server </vb>
After, add:
<vb> Private Const UpdateRate_Save As Long = 600000 'Time between auto-saves </vb>
Find:
<vb> Private LastUpdate_KeepAlive As Long </vb>
After, add:
<vb> Private LastUpdate_Save As Long </vb>
Find:
<vb> Dim FPS As Long 'Used for DEBUG_MapFPS </vb>
After, add:
<vb> Dim i As Integer </vb>
Fix - Data_GM_SetGMLevel
Open GameServer.vbp.
Find:
<vb> Dim TargetIndex As String </vb>
Replace with:
<vb> Dim TargetIndex As Integer </vb>
Fix - Inventory slots using constant
Open GameClient.vbp.
Find:
<vb>
Image(1 To 49) As Rectangle
</vb>
Replace with:
<vb>
Image(1 To MAX_INVENTORY_SLOTS) As Rectangle
</vb>
Find both cases of:
<vb>
For LoopC = 1 To 49
</vb>
Replace with:
<vb>
For LoopC = 1 To MAX_INVENTORY_SLOTS
</vb>
Find all 7 cases of (indenting won't always be same):
<vb>
For i = 1 To 49
</vb>
Replace with:
<vb>
For i = 1 To MAX_INVENTORY_SLOTS
</vb>
Fix - Map Editor Grh textbox
Open EditorMap.vbp.
Find:
<vb> Private Sub GrhTxt_Change() Dim i As Integer On Error GoTo ErrOut
i = Val(GrhTxt.Text) 'Check for valid range If Val(GrhTxt.Text) < 0 Then GrhTxt.Text = "0" If Val(GrhTxt.Text) > UBound(GrhData) Then Exit Sub
Engine_Init_Grh PreviewGrh, Val(GrhTxt.Text)
DrawPreview Exit Sub
ErrOut:
End Sub </vb>
Replace with:
<vb> Private Sub GrhTxt_Change() Dim i As Long On Error GoTo ErrOut
i = Val(GrhTxt.Text) 'Check for valid range If Val(GrhTxt.Text) < 0 Then GrhTxt.Text = "0" If Val(GrhTxt.Text) > UBound(GrhData) Then Exit Sub
Engine_Init_Grh PreviewGrh, Val(GrhTxt.Text)
DrawPreview Exit Sub
ErrOut:
GrhTxt.Text = "0"
End Sub </vb>
Fix - Multiple quest accepts
Open GameServer.vbp.
In sub Data_User_StartQuest, find and delete every case (4 total) of the text:
<vb>
UserList(UserIndex).Flags.QuestNPC = 0
</vb>
Find:
<vb>
'Check the distance of the user to the NPC QuestNPC = UserList(UserIndex).Flags.QuestNPC
</vb>
After, add:
<vb>
UserList(UserIndex).Flags.QuestNPC = 0
</vb>
Add - Large texture support in Map Editor
Open EditorMap.vbp.
At the top of the module Declares.bas, add:
<vb> 'Setting this to true will enable support for large textures but slow down the editor's rendering Public Const LargeTextureSupport As Boolean = True </vb>
Find:
<vb>
D3DWindow.BackBufferFormat = DispMode.Format 'Use format just retrieved
</vb>
After, add:
<vb>
If LargeTextureSupport Then
D3DWindow.BackBufferWidth = 2048
D3DWindow.BackBufferHeight = 2048
End If
</vb>
Find:
<vb>
'Display the textures drawn to the device
D3DDevice.Present ByVal 0, ByVal 0, 0, ByVal 0
</vb>
Replace with:
<vb>
'Display the textures drawn to the device
If LargeTextureSupport Then
Dim r As RECT
r.Right = 800
r.bottom = 632
D3DDevice.Present r, r, 0, ByVal 0
Else
D3DDevice.Present ByVal 0, ByVal 0, 0, ByVal 0
End If
</vb>
Fix - Stats below 0
Open GameServer.vbp.
Find:
<vb>
'Apply limit on HP/Mana/Stamina If BaseStat(SID.MinHP) > ModStat(SID.MaxHP) Then BaseStat(SID.MinHP) = ModStat(SID.MaxHP) If BaseStat(SID.MinMAN) > ModStat(SID.MaxMAN) Then BaseStat(SID.MinMAN) = ModStat(SID.MaxMAN) If BaseStat(SID.MinSTA) > ModStat(SID.MaxSTA) Then BaseStat(SID.MinSTA) = ModStat(SID.MaxSTA)
</vb>
After, add:
<vb>
'Keep the HP, Mana and Stamina above or equal to 0 If BaseStat(SID.MinHP) < 0 Then BaseStat(SID.MinHP) = 0 If BaseStat(SID.MinMAN) < 0 Then BaseStat(SID.MinMAN) = 0 If BaseStat(SID.MinSTA) < 0 Then BaseStat(SID.MinSTA) = 0
</vb>
Fix - GOREsock encryption
Open \Code\GOREsock\GameClient\GOREsock.vbp
Find:
<vb> Public Function Connect(RemoteHost As String, RemotePort As Integer) As Long 'Returns the new Sox Number / ERROR On Error Dim tmpSocket As Long Dim tmpSocketAddr As typSocketAddr </vb>
After, add:
<vb>
PacketInPos = 0 PacketOutPos = 0
</vb>
Recompile and re-add the socket to the game client through the controls page.
Fix - Emoticon rendering
Open GameClient.vbp.
Find:
<vb>
'Fade out
If CharList(CharIndex).Emoticon.Started = 0 Then 'Animation has stopped
If CharList(CharIndex).EmoDir = 2 Then
CharList(CharIndex).EmoFade = CharList(CharIndex).EmoFade - (ElapsedTime * 1.5)
If CharList(CharIndex).EmoFade <= 0 Then
CharList(CharIndex).EmoFade = 0
CharList(CharIndex).EmoDir = 0
End If
End If
End If
</vb>
Replace with:
<vb>
'Fade out
If CharList(CharIndex).Emoticon.Started = 0 Then 'Animation has stopped
If CharList(CharIndex).EmoDir = 2 Then
CharList(CharIndex).EmoFade = CharList(CharIndex).EmoFade - (ElapsedTime * 1.5)
If CharList(CharIndex).EmoFade <= 0 Then
CharList(CharIndex).EmoFade = 0
CharList(CharIndex).EmoDir = 0
End If
'Stop at the last frame, don't roll over to the first
CharList(CharIndex).Emoticon.FrameCounter = GrhData(CharList(CharIndex).Emoticon.GrhIndex).NumFrames
End If
End If
</vb>
Fix - ZeroMemory
Open GameServer.vbp.
Find:
<vb>
ZeroMemory UserList(UserIndex), Len(UserList(UserIndex))
</vb>
Replace with:
<vb>
ZeroMemory UserList(UserIndex), LenB(UserList(UserIndex))
</vb>
Find:
<vb>
ZeroMemory UserList(UserIndex), Len(UserList(UserIndex)) 'Empty the character variables
</vb>
Replace with:
<vb>
ZeroMemory UserList(UserIndex), LenB(UserList(UserIndex)) 'Empty the character variables
</vb>
Find:
<vb>
ZeroMemory NPCList(NPCIndex).Skills, Len(NPCList(NPCIndex).Skills)
</vb>
Replace with:
<vb>
ZeroMemory NPCList(NPCIndex).Skills, LenB(NPCList(NPCIndex).Skills)
</vb>
Find:
<vb>
ZeroMemory MapInfo(Map).ObjTile(X, Y).ObjInfo(i), Len(MapInfo(Map).ObjTile(X, Y).ObjInfo(i))
</vb>
Replace with:
<vb>
ZeroMemory MapInfo(Map).ObjTile(X, Y).ObjInfo(i), LenB(MapInfo(Map).ObjTile(X, Y).ObjInfo(i))
</vb>
Find:
<vb>
ZeroMemory TradeTable(TradeTableIndex), Len(TradeTable(TradeTableIndex))
</vb>
Replace with:
<vb>
ZeroMemory TradeTable(TradeTableIndex), LenB(TradeTable(TradeTableIndex))
</vb>
Find:
<vb>
ZeroMemory TradeTable(TableIndex), Len(TradeTable(TableIndex))
</vb>
Replace with:
<vb>
ZeroMemory TradeTable(TableIndex), LenB(TradeTable(TableIndex))
</vb>
Find:
<vb>
ZeroMemory NPCList(1), Len(NPCList(1))
</vb>
Replace with:
<vb>
ZeroMemory NPCList(1), LenB(NPCList(1))
</vb>
Open GameClient.vbp.
Find:
<vb>
ZeroMemory Effect(EffectIndex), Len(Effect(EffectIndex))
</vb>
Replace with:
<vb>
ZeroMemory Effect(EffectIndex), LenB(Effect(EffectIndex))
</vb>
Find:
<vb>
ZeroMemory EffectList(EffectIndex), Len(EffectList(EffectIndex))
</vb>
Replace with:
<vb>
ZeroMemory EffectList(EffectIndex), LenB(EffectList(EffectIndex))
</vb>
Find:
<vb>
ZeroMemory OBJList(ObjIndex), Len(OBJList(ObjIndex))
</vb>
Replace with:
<vb>
ZeroMemory OBJList(ObjIndex), LenB(OBJList(ObjIndex))
</vb>
Fix - Duplicate status icon update packets
Open GameServer.vbp.
Find:
<vb>
'*** Update the counters ***
If UpdateUserCounters Then 'Bless
If UserList(UserIndex).Counters.BlessCounter > 0 Then
If UserList(UserIndex).Counters.BlessCounter < timeGetTime Then
UserList(UserIndex).Skills.Bless = 0
ConBuf.PreAllocate 4
ConBuf.Put_Byte DataCode.Server_IconBlessed
ConBuf.Put_Byte 0
ConBuf.Put_Integer UserList(UserIndex).Char.CharIndex
Data_Send ToMap, UserIndex, ConBuf.Get_Buffer, UserList(UserIndex).Pos.Map, PP_StatusIcons
User_UpdateModStats UserIndex
End If
End If 'Protection
If UserList(UserIndex).Counters.ProtectCounter > 0 Then
If UserList(UserIndex).Counters.ProtectCounter < timeGetTime Then
UserList(UserIndex).Skills.Protect = 0
ConBuf.PreAllocate 4
ConBuf.Put_Byte DataCode.Server_IconProtected
ConBuf.Put_Byte 0
ConBuf.Put_Integer UserList(UserIndex).Char.CharIndex
Data_Send ToMap, UserIndex, ConBuf.Get_Buffer, UserList(UserIndex).Pos.Map, PP_StatusIcons
User_UpdateModStats UserIndex
End If
End If 'Strengthen
If UserList(UserIndex).Counters.StrengthenCounter > 0 Then
If UserList(UserIndex).Counters.StrengthenCounter < timeGetTime Then
UserList(UserIndex).Skills.Strengthen = 0
ConBuf.PreAllocate 4
ConBuf.Put_Byte DataCode.Server_IconStrengthened
ConBuf.Put_Byte 0
ConBuf.Put_Integer UserList(UserIndex).Char.CharIndex
Data_Send ToMap, UserIndex, ConBuf.Get_Buffer, UserList(UserIndex).Pos.Map, PP_StatusIcons
User_UpdateModStats UserIndex
End If
End If 'Spell exhaustion
If UserList(UserIndex).Counters.SpellExhaustion > 0 Then
If UserList(UserIndex).Counters.SpellExhaustion < timeGetTime Then
UserList(UserIndex).Counters.SpellExhaustion = 0
ConBuf.PreAllocate 4
ConBuf.Put_Byte DataCode.Server_IconSpellExhaustion
ConBuf.Put_Byte 0
ConBuf.Put_Integer UserList(UserIndex).Char.CharIndex
Data_Send ToMap, UserIndex, ConBuf.Get_Buffer, UserList(UserIndex).Pos.Map, PP_StatusIcons
End If
End If
End If
</vb>
Replace with:
<vb>
If UpdateUserCounters Then 'Bless
If UserList(UserIndex).Counters.BlessCounter > 0 Then
If UserList(UserIndex).Counters.BlessCounter < timeGetTime Then
UserList(UserIndex).Counters.BlessCounter = 0
UserList(UserIndex).Skills.Bless = 0
ConBuf.PreAllocate 4
ConBuf.Put_Byte DataCode.Server_IconBlessed
ConBuf.Put_Byte 0
ConBuf.Put_Integer UserList(UserIndex).Char.CharIndex
Data_Send ToMap, UserIndex, ConBuf.Get_Buffer, UserList(UserIndex).Pos.Map, PP_StatusIcons
User_UpdateModStats UserIndex
End If
End If 'Protection
If UserList(UserIndex).Counters.ProtectCounter > 0 Then
If UserList(UserIndex).Counters.ProtectCounter < timeGetTime Then
UserList(UserIndex).Counters.ProtectCounter = 0
UserList(UserIndex).Skills.Protect = 0
ConBuf.PreAllocate 4
ConBuf.Put_Byte DataCode.Server_IconProtected
ConBuf.Put_Byte 0
ConBuf.Put_Integer UserList(UserIndex).Char.CharIndex
Data_Send ToMap, UserIndex, ConBuf.Get_Buffer, UserList(UserIndex).Pos.Map, PP_StatusIcons
User_UpdateModStats UserIndex
End If
End If 'Strengthen
If UserList(UserIndex).Counters.StrengthenCounter > 0 Then
If UserList(UserIndex).Counters.StrengthenCounter < timeGetTime Then
UserList(UserIndex).Counters.StrengthenCounter = 0
UserList(UserIndex).Skills.Strengthen = 0
ConBuf.PreAllocate 4
ConBuf.Put_Byte DataCode.Server_IconStrengthened
ConBuf.Put_Byte 0
ConBuf.Put_Integer UserList(UserIndex).Char.CharIndex
Data_Send ToMap, UserIndex, ConBuf.Get_Buffer, UserList(UserIndex).Pos.Map, PP_StatusIcons
User_UpdateModStats UserIndex
End If
End If 'Spell exhaustion
If UserList(UserIndex).Counters.SpellExhaustion > 0 Then
If UserList(UserIndex).Counters.SpellExhaustion < timeGetTime Then
UserList(UserIndex).Counters.SpellExhaustion = 0
ConBuf.PreAllocate 4
ConBuf.Put_Byte DataCode.Server_IconSpellExhaustion
ConBuf.Put_Byte 0
ConBuf.Put_Integer UserList(UserIndex).Char.CharIndex
Data_Send ToMap, UserIndex, ConBuf.Get_Buffer, UserList(UserIndex).Pos.Map, PP_StatusIcons
End If
End If
End If
</vb>
Fix - Update client and server
Replace the \Code\Updater Client\ and \Code\Updater Server\ directories from Version 1.0.13.
Change - Faster ClosestLegalPos code
Open GameServer.vbp.
Find:
<vb>
For tX = Pos.X - LoopC To Pos.X + LoopC
</vb>
After, add:
<vb>
If (tY = Pos.Y - LoopC) Or (tY = Pos.Y + LoopC) Or (tY = Pos.X - LoopC) Or (tY = Pos.X + LoopC) Then
</vb>
In the same sub, a few lines down, find:
<vb>
Next tX
</vb>
Before, add:
<vb>
End If
</vb>
Change - Faster thrall code
Open GameServer.vbp.
Find:
<vb> Sub Data_GM_Thrall(ByRef rBuf As DataBuffer, ByVal UserIndex As Integer) </vb>
Replace the whole sub with:
<vb> Sub Data_GM_Thrall(ByRef rBuf As DataBuffer, ByVal UserIndex As Integer) '***************************************************************** 'GM creates NPCs '<NPCIndex(I)><Amount(I)> 'More info: http://www.vbgore.com/GameServer.TCP.Data_GM_Thrall '***************************************************************** Dim CharIndex As Integer Dim tIndex As Integer Dim NPCIndex As Integer Dim Amount As Integer Dim i As Long
Log "Call Data_GM_Thrall([" & ByteArrayToStr(rBuf.Get_Buffer) & "]," & UserIndex & ")", CodeTracker '//\\LOGLINE//\\
'Get the values
NPCIndex = rBuf.Get_Integer
Amount = rBuf.Get_Integer
'Check for invalid values
If UserList(UserIndex).Flags.GMLevel = 0 Then Exit Sub
If NPCIndex <= 0 Then
Log "Data_GM_Thrall: Invalid NPCIndex (" & NPCIndex & ")", InvalidPacketData '//\\LOGLINE//\\
Exit Sub
End If
If Amount <= 0 Then
Log "Data_GM_Thrall: Invalid Amount (" & Amount & ")", InvalidPacketData '//\\LOGLINE//\\
Exit Sub
End If
If Amount > 50 Then
Log "Data_GM_Thrall: Invalid Amount (" & Amount & ")", InvalidPacketData '//\\LOGLINE//\\
Exit Sub
End If
'Thrall the NPCs For i = 1 To Amount
'Load up the NPC
tIndex = Load_NPC(NPCIndex, 1)
'Error in the thrall, so obviously the next ones wont work
If tIndex < 1 Then
If i = 1 Then 'Only show the fail if this is the first NPC being thralled
ConBuf.PreAllocate 4
ConBuf.Put_Byte DataCode.Server_Message
ConBuf.Put_Byte 95
ConBuf.Put_Integer NPCIndex
Data_Send ToIndex, UserIndex, ConBuf.Get_Buffer
Exit Sub
End If
End If
'Set the NPC's start position
NPCList(tIndex).StartPos = UserList(UserIndex).Pos
'Spawn the NPC (since they are currently marked as "dead" or "inactive")
NPC_Spawn tIndex
Next i
End Sub </vb>