Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Map Editor - Byte Arrays :-(
#1
Alright, again with the stupid byte array problems. when i send a map to the server, it doesn't save. i did an

aLen(Getplayermap(myindex))

on both (with the index change on the server), and the client outputs

64

while the server outputs

60

i believe that is the problem, but i don't know what could be causing it... all of the recs match up. :evil:

anyone have any ideas?
Reply
#2
How would any of us be able to tell what you did wrong with what you provided unless we were psychic?

Gotta say more...
Reply
#3
erm... alright.

what exactly are you looking for? i mean it sends the entire rec from the client to the server, the client sends 64, and the server picks up 60.

here's the tile and maprec for the client, and then the sub that sends the data to the server.

Code:
Type TileRec
    Ground As Integer
    Mask As Integer
    Anim As Integer
    Mask2 As Integer
    M2Anim As Integer
    Fringe As Integer
    FAnim As Integer
    Fringe2 As Integer
    F2Anim As Integer
    Type As Byte
    Data1 As Integer
    Data2 As Integer
    Data3 As Integer
    String1 As String
    String2 As String
    String3 As String
End Type

Type MapRec
    MapName(NAME_LENGTH - 1) As Byte
    Revision As Long
    Moral As Byte
    Up As Integer
    Down As Integer
    Left As Integer
    Right As Integer
    Music As Byte
    BootMap As Integer
    BootX As Byte
    BootY As Byte
    IsIndoors As Byte
    IsBank As Byte
    IsHall As Byte
    Tile() As TileRec
    Npc(1 To MAX_MAP_NPCS) As Byte
End Type



Sub SendMap()
Dim Buffer() As Byte

    Buffer = FillBuffer(VarPtr(Map(GetPlayerMap(MyIndex))), LenB(Map(GetPlayerMap(MyIndex))))
    
    MsgBox aLen(Buffer) ' Shows 64.... server shows 60
    Call SendDataNew(Buffer, SMsgMapData)
End Sub


Here's the stuff from the server:

Code:
Type TileRec
    Ground As Integer
    Mask As Integer
    Anim As Integer
    Mask2 As Integer
    M2Anim As Integer
    Fringe As Integer
    FAnim As Integer
    Fringe2 As Integer
    F2Anim As Integer
    Type As Byte
    Data1 As Integer
    Data2 As Integer
    Data3 As Integer
    String1 As String
    String2 As String
    String3 As String
End Type

Type MapRec
    MapName(NAME_LENGTH - 1) As Byte
    Revision As Long
    Moral As Byte
    Up As Integer
    Down As Integer
    Left As Integer
    Right As Integer
    Music As Byte
    BootMap As Integer
    BootX As Byte
    BootY As Byte
    IsIndoors As Byte
    IsBank As Byte
    IsHall As Byte
    Tile() As TileRec
    Npc(1 To MAX_MAP_NPCS) As Byte
End Type





Private Sub HandleMapData(ByVal Index As Long, ByVal StartAddr As Long, ByVal ByteLen As Long, ByVal ExtraVar As Long)
Dim Buffer() As Byte
Dim i As Long, MapNum As Integer
Dim nMap As MapRec
  
  If HasAccess(Index, ADMIN_MAPPER) = 0 Then Exit Sub
  
  Buffer = FillBuffer(StartAddr, ByteLen)
  MapNum = GetPlayerMap(Index)
  
  
  'ReDim Map(MapNum).Tile(0 To MAX_MAPX, 0 To MAX_MAPY) As TileRec
  
  MsgBox Len(Map(MapNum))
  Call CopyMemory(nMap, Buffer(0), aLen(Buffer))
  debug.print "passed this point!"
  Map(MapNum) = nMap
  
  Call SendMapNpcsToMap(MapNum)
  Call SpawnMapNpcs(MapNum)
  
  'Save the map
  Call SaveMap(MapNum)
  
  'Refresh map for everyone online
  For i = 1 To MAX_PLAYERS
    If IsPlaying(i) And GetPlayerMap(i) = MapNum Then
      Call PlayerWarp(i, MapNum, GetPlayerX(i), GetPlayerY(i))
    End If
  Next
End Sub
[/code]
Reply
#4
I don't know...but its not like you're saying anything. Maybe how its sent and received...because thats the code you're having problems with...
Reply
#5
updated that post, maybe that can help?
Reply
#6
Um...you use Len instead of aLen...I dunno if that makes a difference.
I assume the ByteLen variable is also 60?
Maybe its a problem in your handleData...before the HandleMapData gets called.
Reply
#7
Gah, now when i try to send the map, it crashes the VB6 that's running the server... what the hell :?

Client Send Code
Code:
Public Sub SendMap()
Dim Buffer() As Byte
  
  Buffer = FillBuffer(VarPtr(Map), LenB(Map))
  
  Call SendDataNew(Buffer, SMsgMapData)
End Sub

Server Receive Code
Code:
Private Sub HandleMapData(ByVal Index As Long, ByVal StartAddr As Long, ByVal ByteLen As Long, ByVal ExtraVar As Long)
  Dim Buffer() As Byte
  Dim i As Long, MapNum As Integer
  Dim nMap As MapRec
  
  If HasAccess(Index, ADMIN_MAPPER) = 0 Then Exit Sub
  
  Buffer = FillBuffer(StartAddr, ByteLen)
  MapNum = GetPlayerMap(Index)
  
  'MsgBox Len(Map(MapNum))
  Call CopyMemory(nMap, Buffer(0), aLen(Buffer))
  Map(MapNum) = nMap
  
  Call SendMapNpcsToMap(MapNum)
  Call SpawnMapNpcs(MapNum)
  
  'Save the map
  Call SaveMap(MapNum)
  
  'Refresh map for everyone online
  For i = 1 To MAX_PLAYERS
    If IsPlaying(i) And GetPlayerMap(i) = MapNum Then
      Call PlayerWarp(i, MapNum, GetPlayerX(i), GetPlayerY(i))
    End If
  Next
End Sub

Those were straight from the MS code that verrigan converted as an example or whatever. But it just brings up that stupid microsoft "error report" screen or whatever.
Reply
#8
Watch out when you use CopyMemory, you'll break stuff fast if you dont use it right.
Reply
#9
okay that's what i thought. hmmm i'm going to try to play around a bit more with that then
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)