| Mirage Source http://www.miragesource.net/forums/ |
|
| Map Editor - Byte Arrays :-( http://www.miragesource.net/forums/viewtopic.php?f=201&t=716 |
Page 1 of 1 |
| Author: | Obsidian [ Sat Nov 04, 2006 8:35 pm ] |
| Post subject: | Map Editor - Byte Arrays :-( |
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. anyone have any ideas? |
|
| Author: | Misunderstood [ Sat Nov 04, 2006 8:58 pm ] |
| Post subject: | |
How would any of us be able to tell what you did wrong with what you provided unless we were psychic? Gotta say more... |
|
| Author: | Obsidian [ Sat Nov 04, 2006 9:12 pm ] |
| Post subject: | |
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 |
|
| Author: | Misunderstood [ Sat Nov 04, 2006 9:16 pm ] |
| Post subject: | |
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... |
|
| Author: | Obsidian [ Sat Nov 04, 2006 9:17 pm ] |
| Post subject: | |
updated that post, maybe that can help? |
|
| Author: | Misunderstood [ Sat Nov 04, 2006 9:29 pm ] |
| Post subject: | |
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. |
|
| Author: | Verrigan [ Sun Nov 05, 2006 2:56 pm ] |
| Post subject: | |
Shouldn't: Code: Buffer = FillBuffer(VarPtr(Map(GetPlayerMap(MyIndex))), LenB(Map(GetPlayerMap(MyIndex)))) beCode: Buffer = FillBuffer(VarPtr(Map(GetPlayerMap(MyIndex))), Len(Map(GetPlayerMap(MyIndex)))) ?
Not 100% sure on that... But it was working 100% in KoC... whose files I no longer have, since my computer failed to boot up one day.. |
|
| Author: | Lea [ Sun Nov 05, 2006 3:29 pm ] |
| Post subject: | |
I notice you us MsgBox alen() on the client side, and MsgBox len() on the server side... Have you tried messing around with switching LenB() aLen() and Len() around with eachother? Here's my code, client side SendMap() Code: Public Sub SendMap() Dim Buffer() As Byte Buffer = "" Buffer = AddLongToBuffer(Buffer, Player(MyIndex).Map) Buffer = AddToBuffer(Buffer, VarPtr(Map), LenB(Map)) Call SendDataNew(Buffer, SMsgMapData) End Sub Server Side HandleMapData: 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 Mapnum As Integer 'Dim nMap As MapRec Dim i As Integer, X As Long, Y As Long If HasAccess(Index, ADMIN_MAPPER) = 0 Then Exit Sub 'Call ClearMapNpcs 'Call ClearMapItems Buffer = "" Buffer = FillBuffer(StartAddr, ByteLen) Mapnum = GetLongFromBuffer(Buffer, True) 'Debug.Print aLen(Buffer) 'Debug.Print "Start = " & Buffer(LBound(Buffer)) 'Debug.Print "End = " & Buffer(UBound(Buffer)) 'Call CopyMemory(ByVal VarPtr(Map(MapNum)), ByVal VarPtr(Buffer(0)), aLen(Buffer)) 'Debug.Print "Sizeof: Map(" & MapNum & "): " & LenB(Map(MapNum)) & vbCrLf & "Sizeof: Buffer: " & aLen(Buffer) Call CopyMemory(ByVal VarPtr(Map(Mapnum)), Buffer(0), aLen(Buffer)) For i = 1 To MAX_MAP_NPCS tStr = tStr & " " & STR(Map(Mapnum).Npc(i)) Next i Debug.Print "NPC's that we recieve from the client: " & tStr 'Spawn NPCs Call RewriteMapNPCs(Mapnum) 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 AS FAR AS I KNOW, this code WAS working in Valkoria, before I messed up other stuff. As you can see from the comments, I had some troubles of my own. We managed to get through it... it was tough though. Here's my UDTs for reference. Code: Type MapRec
Name As String * NAME_LENGTH 'MapName() 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 Shop As Byte Indoors As Byte '40 Tile(0 To MAX_MAPX, 0 To MAX_MAPY) As TileRec '15 per, 15x11 Npc(1 To MAX_MAP_NPCS) As Byte End Type Type TileRec Ground As Integer Mask As Integer Anim As Integer Fringe As Integer Type As Byte Data1 As Integer Data2 As Integer Data3 As Integer End Type |
|
| Author: | Obsidian [ Sun Nov 05, 2006 10:14 pm ] |
| Post subject: | |
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. |
|
| Author: | Spodi [ Sun Nov 05, 2006 10:17 pm ] |
| Post subject: | |
Watch out when you use CopyMemory, you'll break stuff fast if you dont use it right. |
|
| Author: | Obsidian [ Sun Nov 05, 2006 10:19 pm ] |
| Post subject: | |
okay that's what i thought. hmmm i'm going to try to play around a bit more with that then |
|
| Page 1 of 1 | All times are UTC |
| Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |
|