Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Combo Editor


escfoe2
 Share

Recommended Posts

Well as I mentioned in a previous post.  I am making a combination feature to my game that allows players to morph items together to create new things.  Well here's my problem: I can't get the damn variables to be sent through the buffer.  Im pretty much clueless on how the buffer works, everything else is fine though.

THE SPECS:
I have a type called Combo and it has 6 parts
- ComboName as String  'Name
- LevelReq as Long        ' Level Required
- Take1 as Long              ' 1st item to take
- Take2 as Long              ' 2nd item to take
- Give1 as Long              ' 1st item to give
- Give 2 as Long              ' 2nd item to give

I cannot get it to send right through this sub below:

```
Public Sub SendSaveCombo(ByVal ComboNum As Long)
Dim Buffer As clsBuffer
Dim ComboSize As Long
Dim ComboData() As Byte

    ' If debug mode, handle error then exit out
    If Options.Debug = 1 Then On Error GoTo errorhandler

    Set Buffer = New clsBuffer
    ComboSize = LenB(Combo(ComboNum))
    ReDim ComboData(ComboSize - 1)
    CopyMemory ComboData(0), ByVal VarPtr(Combo(ComboNum)), ComboSize
    Buffer.WriteLong CSaveCombo
    Buffer.WriteLong ComboNum
    Buffer.WriteBytes ComboData
    SendData Buffer.ToArray()
    Set Buffer = Nothing

    ' Error handler
    Exit Sub
errorhandler:
    HandleError "SendSaveCombo", "modClientTCP", Err.Number, Err.Description, Err.Source, Err.HelpContext
    Err.Clear
    Exit Sub
End Sub

```
That sub is based off of SendSaveItem.  When I look at the one for npcs, it's about the same too.  I don't see what I'm doing wrong but the variables in the type Combo will not send to the server.  This actually causes a fatal error in the server with what it DOES send.  I have the variables set as the user changes values on the form.  Everything is set to work right except for THIS.  If anyone can give me any advice or information on this I would greatly appreciate it.  Thanks in advance.
Link to comment
Share on other sites

You must have a CSaveCombo in the modEnumerations in the server project.
after that a sub HandleSaveCombo in modHandleData in the server project, look how CSaveNPC and HandleSaveNPC is done in modhandledata in the server.

EDIT:

> causes a fatal error in the server with what it DOES send

??? so you have a HandleSaveCombo in server side?

How are you actually saving the data of the type "Combo"?
because you can't go in the server and say "Combo(index).give1" without having a place to save it…
You must have a folder in your "server\data files\" called Combo or something, and you have to do the modDatabase things...
Link to comment
Share on other sites

I have all of the enumerators and types already set on both ends. The issue is that the Client ends up sending blank data before it even gets to the server.  I debugged it to find out why I was getting a fatal error with it.  Turns out that's why.  So on JoinGame the server sends all its little shit such as SendItems and of cource SendCombos.  I already know the combos are empty because the server isn't getting anything to save.  Like I said, as I explain this you will notice how the combos are set up just like the way items are handled.  Now when you click the save button in the combo form, it calls ComboEditorOk.  This then uses a For-Loop to call SendSaveCombo.  This is the sub I mentioned previously in my last post that is supposed to send the variable data.  It doesn't I don't understand why so I'll post all of my code below.

The save button
```
Private Sub cmdSave_Click()
    ' If debug mode, handle error then exit out
    If Options.Debug = 1 Then On Error GoTo errorhandler

    Call ComboEditorOk

    ' Error handler
    Exit Sub
errorhandler:
    HandleError "cmdSave_Click", "frmEditor_Combinations", Err.Number, Err.Description, Err.Source, Err.HelpContext
    Err.Clear
    Exit Sub
End Sub

```
ComboEditorOk
```
Public Sub ComboEditorOk()
Dim i As Long

    ' If debug mode, handle error then exit out
    If Options.Debug = 1 Then On Error GoTo errorhandler

    For i = 1 To MAX_COMBOS
        If Combo_Changed(i) Then
            Call SendSaveCombo(i)
        End If
    Next

    Unload frmEditor_Combinations
    Editor = 0
    ClearChanged_Combo

    ' Error handler
    Exit Sub
errorhandler:
    HandleError "ComboEditorOk", "modGameEditors", Err.Number, Err.Description, Err.Source, Err.HelpContext
    Err.Clear
    Exit Sub
End Sub

```
SendSaveCombo, which is where it's not correctly sending the values
```
Public Sub SendSaveCombo(ByVal ComboNum As Long)
Dim Buffer As clsBuffer
Dim ComboSize As Long
Dim ComboData() As Byte

    ' If debug mode, handle error then exit out
    If Options.Debug = 1 Then On Error GoTo errorhandler

    Set Buffer = New clsBuffer
    ComboSize = LenB(Combo(ComboNum))
    ReDim ComboData(ComboSize - 1)
    CopyMemory ComboData(0), ByVal VarPtr(Combo(ComboNum)), ComboSize
    Buffer.WriteLong CSaveCombo
    Buffer.WriteLong ComboNum
    Buffer.WriteBytes ComboData
    SendData Buffer.ToArray()
    Set Buffer = Nothing

    ' Error handler
    Exit Sub
errorhandler:
    HandleError "SendSaveCombo", "modClientTCP", Err.Number, Err.Description, Err.Source, Err.HelpContext
    Err.Clear
    Exit Sub
End Sub

```
ComboRec, the type library I have both Client and Server-Side.  This is in modTypes as it should be.
```
Public Combo(1 To MAX_COMBOS) As ComboRec

Public Type ComboRec
    ComboName As String
    LevelReq As Long
    Take1 As Long
    Take2 As Long
    Give1 As Long
    Give2 As Long
End Type

```
I have all of my variables declared.  MAX_COMBOS is declared both ends.  I can't seem to finger out what the hell I did wrong here. :/  I put a break in the SendSaveCombo sub on the line that says "Set Buffer = Nothing" and used the 'Immediate' window to check the ComboData by typing "?ComboData" and pressed entered.  Guess what I got….. "??   "  Well, it had the separation symbols in it too that you can't see but It SHOULD have the comboname, levelreq, take1, take2, give1, and give2 values in it which it doesn't.  Very frustrating...  :mad:  It'd be nice if Robin took a look-see.  Im sure he's an expert when it comes to the buffer that HE made lol  Thanks though for any and all help.  I try to do the same whenever I can.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...