Changeset 3233

Show
Ignore:
Timestamp:
01/23/10 01:38:16 (7 weeks ago)
Author:
ghoulsblade
Message:
dragdrop/stacking fixes and walk-config-params for pol, improved packet debugging utils
Location:
trunk/lua
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • trunk/lua/lib.proxy.lua

    r3232 r3233  
    1717        gProxyHost = host 
    1818        gProxyPort = port 
    19         gProxyPort2 = port+1 
     19        gProxyPort2 = port 
     20        --~ gProxyPort2 = port+1 
    2021         
    2122        gServerListenerTCP = UOProxyOpenListener(gProxyPort) 
    22         gServerListenerTCP2 = UOProxyOpenListener(gProxyPort2) 
     23        --~ gServerListenerTCP2 = UOProxyOpenListener(gProxyPort2) 
    2324         
    2425        print("listen port opened....") 
     
    2728                local listener = gServerListenerTCP 
    2829                while true do 
    29                         local newcon = listener:PopAccepted() 
     30                        local newcon = listener:IsAlive() and listener:PopAccepted() 
    3031                        if (not newcon) then break end 
    3132                        print("###############################") 
     
    3637                        print("#### PROXY : connection ended") 
    3738                        print("###############################") 
    38                         listener = gServerListenerTCP2 
     39                        --~ listener = gServerListenerTCP2 
    3940                        --~ print("proxy end") return 
    4041                end 
     
    111112 
    112113 
     114gLastPacketTBySender = {} 
    113115-- returns false if packet incomplete 
    114116function UOProxyHandlePacket    (fifo_in,fifo_out,bIsFromClient)  
     
    121123        --~ if (bIsFromServer and gProxyServerHuffmanStarted) then bInterpret = false end -- huffman comp&decomp active now 
    122124        --~ if (bIsFromClient and gProxyServerHuffmanStarted) then bInterpret = false end -- not really needed but something seems bugged 
    123         if (gDisableProxyInterpretation) then bInterpret = false end 
     125        --~ if (gDisableProxyInterpretation) then bInterpret = false end 
    124126        local bScrambleTest = false 
    125127        local bClientBlockTest = true 
     128        local bShortDump = false 
    126129         
    127130        if (bInterpret) then  
     
    177180                                fifo_in:PeekNetUint8(4) == 0x24) then 
    178181                                --~ fifo_in:PokeNetUint8(5,math.random(0,255)) 
    179                                 print("+++++++++++++++++++++++++++++++++++++++++++++++") 
    180                                 print("detected unknownSE") 
    181                                 print("+++++++++++++++++++++++++++++++++++++++++++++++") 
     182                                if (not bShortDump) then 
     183                                        print("+++++++++++++++++++++++++++++++++++++++++++++++") 
     184                                        print("detected unknownSE") 
     185                                        print("+++++++++++++++++++++++++++++++++++++++++++++++") 
     186                                end 
    182187                                if (bScrambleTest) then  
    183188                                        fifo_in:PokeNetUint8(5,16) 
     
    205210        end 
    206211         
     212         
     213        function Pad (str,len) 
     214                str = tostring(str) 
     215                local add = len - #str  
     216                if (add > 0) then return str..string.rep(" ",add) end  
     217                return str 
     218        end 
    207219        if (bInterpret) then  
    208220                local iId = fifo_in:PeekNetUint8(0) 
    209221                local iPacketSize = gPacketSizeByID[iId] 
    210                 print("UOProxyHandlePacket",fromname,sprintf("0x%02x",iId),gPacketTypeId2Name[iId],iPacketSize,"t="..t_since_start) 
    211                 assert(iPacketSize) 
    212                 if (iPacketSize == 0 and fifo_in:Size() < 3) then print("incomplete packet dynsize? <3") return end -- packet incomplete 
     222                assert(iPacketSize,"unknown iPacketSize for id="..hex(iId)) 
     223                if (iPacketSize == 0 and fifo_in:Size() < 3) then print("incomplete packet dynsize? <3",hex(iId)) return end -- packet incomplete 
    213224                if (iPacketSize == 0) then iPacketSize = fifo_in:PeekNetUint16(1) end 
    214                 if (fifo_in:Size() < iPacketSize) then print("incomplete packet ",fifo_in:Size(),iPacketSize) return end -- packet incomplete 
    215                  
     225                if (fifo_in:Size() < iPacketSize) then print("incomplete packet ",hex(iId),fifo_in:Size(),iPacketSize) return end -- packet incomplete 
     226                 
     227                local timediff = t_since_start - (gLastPacketTBySender[fromname] or t_since_start) 
     228                gLastPacketTBySender[fromname] = t_since_start 
     229                 
     230                local debuginfo 
     231                if (1 == 1) then -- generate some debug infos 
     232                        if (iId == kPacket_Generic_Command) then 
     233                                local iBFSubCmd = fifo_in:PeekNetUint16(3) 
     234                                debuginfo = sprintf("subcmd=%s[0x%02x]",gGenericSubCommandNamesByID[iBFSubCmd] or "???",iBFSubCmd) 
     235                        elseif (bIsFromClient and iId == kPacket_Request_Movement) then  
     236                                debuginfo = sprintf("dir=%2x,seq=%3d,fc=%x",fifo_in:PeekNetUint8(1),fifo_in:PeekNetUint8(2),fifo_in:PeekNetUint32(3)) 
     237                        elseif (iId == kPacket_Accept_Movement_Resync_Request) then  
     238                                debuginfo = sprintf(fromname..":a=%3d,b=%3d",fifo_in:PeekNetUint8(1),fifo_in:PeekNetUint8(2)) 
     239                        end 
     240                end 
     241                print("UOProxyHandlePacket",fromname,sprintf("0x%02x",iId),Pad(gPacketTypeId2Name[iId],40),Pad(iPacketSize,3),"dt="..Pad(timediff,4),debuginfo) 
    216242                 
    217243                if (bIsFromServer and iId == kPacket_Server_List) then -- 0xA8 
     
    241267                        fifo_in:PokeNetUint8(6,math.mod(iGameServerPort,256)) -- port 
    242268                         
    243                         gProxyServerHuffmanStartedNextRound = true 
     269                        gProxyServerHuffmanStartedNextRound = true  -- only after 4 byte header? 
     270                        gDisableProxyInterpretation = true 
    244271                        print("+++++++++++++++++++++++++++++++++++++++++++++++") 
    245272                        print("+++++    adjusted kPacket_Server_Redirect") 
    246273                        print("+++++++++++++++++++++++++++++++++++++++++++++++") 
    247                         gDisableProxyInterpretation = true 
    248274                end 
    249275                 
     
    299325                ]]-- 
    300326                 
    301                  
    302                 print("recv:",fromname,"t_since_start=",t_since_start)  
    303                 print(HexDumpUOPacket(fifo_in,iPacketSize,bIsFromClient," proxy")) 
     327                if (not bShortDump) then  
     328                        print("recv:",fromname,"t_since_start=",t_since_start)  
     329                        print(HexDumpUOPacket(fifo_in,iPacketSize,bIsFromClient," proxy")) 
     330                end 
    304331                --~ print(FIFOHexDump(fifo_in,0,iPacketSize)) 
    305332                fifo_out:PushFIFOPartRaw(fifo_in,0,iPacketSize)  
     
    359386        gProxyClientSendCompFifo                = CreateFIFO() 
    360387         
     388        local fHuffmanDummy_RawIn                       = CreateFIFO() 
     389        local fHuffmanDummy_RawOut                      = CreateFIFO() 
     390        local fHuffmanDummy_DecompIn            = CreateFIFO() 
     391        local fHuffmanDummy_DecompOut           = CreateFIFO() 
     392         
     393         
    361394        gPacketSizeByID[0xEF] = 21 -- protocol start... dummy here 
    362395         
     
    364397        while bAlive do 
    365398                -- send  
    366                 gProxyServerHuffmanStarted = false 
    367                 if (gProxyServerHuffmanStarted) then 
    368                         HuffmanCompress(gProxyClientSendFifo,gProxyClientSendCompFifo) -- does NOT remove data from in-fifo. compression can always be completed. 
    369                         gProxyClientCon:Push(gProxyClientSendCompFifo) 
    370                         gProxyClientSendCompFifo:Clear() 
    371                         gProxyClientSendFifo:Clear() 
    372                 else  
     399                --~ if (gProxyServerHuffmanStarted) then 
     400                        --~ HuffmanCompress(gProxyClientSendFifo,gProxyClientSendCompFifo) -- does NOT remove data from in-fifo. compression can always be completed. 
     401                        --~ gProxyClientCon:Push(gProxyClientSendCompFifo) 
     402                        --~ gProxyClientSendCompFifo:Clear() 
     403                        --~ gProxyClientSendFifo:Clear() 
     404                --~ else  
    373405                        gProxyClientCon:Push(gProxyClientSendFifo) 
    374406                        gProxyClientSendFifo:Clear() 
    375                 end 
     407                --~ end 
    376408                 
    377409                gProxyServerCon:Push(gProxyServerSendFifo) 
     
    385417                gProxyClientCon:Pop(gProxyClientRecvFifo) 
    386418                 
     419                --~ if (gProxyServerHuffmanStarted) then  
     420                        --~ gProxyServerCon:Pop(gProxyServerRecvCompFifo) 
     421                        --~ HuffmanDecompress(gProxyServerRecvCompFifo,gProxyServerRecvFifo) -- DOES remove data from gProxyServerRecvCompFifo, might not remove all if data for decompression is not yet complete 
     422                --~ else 
     423                        gProxyServerCon:Pop(gProxyServerRecvFifo) 
     424                --~ end 
     425                 
     426                -- handle packets 
    387427                if (gProxyServerHuffmanStarted) then  
    388                         gProxyServerCon:Pop(gProxyServerRecvCompFifo) 
    389                         HuffmanDecompress(gProxyServerRecvCompFifo,gProxyServerRecvFifo) -- DOES remove data from gProxyServerRecvCompFifo, might not remove all if data for decompression is not yet complete 
     428                        fHuffmanDummy_RawIn:PushFIFOPartRaw(gProxyServerRecvFifo)  -- copy from ServerRecv into huffRawIn 
     429                        HuffmanDecompress(fHuffmanDummy_RawIn,fHuffmanDummy_DecompIn)  -- decompress from huffRawIn to huffDecompIn 
     430                         
     431                        while UOProxyHandlePacket(fHuffmanDummy_DecompIn,fHuffmanDummy_DecompOut,false) do end  -- pipe packets from huffDecompIn to huffDecompOut 
     432                        HuffmanCompress(fHuffmanDummy_DecompOut,fHuffmanDummy_RawOut) -- compress from huffDecompOut to huffRawOut ... does NOT remove data from in-fifo. compression can always be completed 
     433                        fHuffmanDummy_DecompOut:Clear() -- clear huffDecompOut, as it has been completely compressed 
     434                         
     435                        local bHuffmanCompBugged = true 
     436                        if (bHuffmanCompBugged) then 
     437                                -- throw away modified/filtered output 
     438                                -- todo : show diff fHuffmanDummy_RawOut,gProxyServerRecvFifo ?    
     439                                -- ServerRecv is what we originally got from the server, as long as nothing was modified in handle, it should be the same.   maybe incomplete packets,sizediff etc.. 
     440                                fHuffmanDummy_RawOut:Clear() 
     441                                 
     442                                -- override 
     443                                gProxyClientSendFifo:PushFIFOPartRaw(gProxyServerRecvFifo)  
     444                                gProxyServerRecvFifo:Clear() 
     445                        end 
    390446                else 
    391                         gProxyServerCon:Pop(gProxyServerRecvFifo) 
    392                 end 
    393                 gProxyServerHuffmanStarted = false 
    394                  
    395                 -- handle packets 
    396                 while UOProxyHandlePacket(gProxyServerRecvFifo,gProxyClientSendFifo,false) do end 
     447                        while UOProxyHandlePacket(gProxyServerRecvFifo,gProxyClientSendFifo,false) do end 
     448                end 
    397449                while UOProxyHandlePacket(gProxyClientRecvFifo,gProxyServerSendFifo,true) do end 
    398450                 
     
    409461        gProxyServerRecvCompFifo:Destroy() 
    410462        gProxyClientSendCompFifo:Destroy() 
     463         
     464        fHuffmanDummy_RawIn:Destroy() 
     465        fHuffmanDummy_RawOut:Destroy() 
     466        fHuffmanDummy_DecompIn:Destroy() 
     467        fHuffmanDummy_DecompOut:Destroy() 
    411468end 
    412469 
  • trunk/lua/lib.uodragdrop.lua

    r3195 r3233  
    374374                        x = 0xffff 
    375375                        y = 0xffff 
    376                         z = 0 
     376                        x = gMousePickFoundHit.item.xloc or 0xffff 
     377                        y = gMousePickFoundHit.item.yloc or 0xffff 
     378                        z = gMousePickFoundHit.item.zloc or 0 
     379                        print("###############################") 
     380                        print("#### drop on other item in container : ",x,y,z) 
     381                        print("###############################") 
    377382                        target = gMousePickFoundHit.item.serial  
    378383                        --[[ 
     
    408413        elseif (dialog_under_mouse and dialog_under_mouse.dropOnMobileSerial) then 
    409414                -- support drop of stuff onto dialogs 
     415                local mobile = GetMobile(dialog_under_mouse.dropOnMobileSerial) 
     416                if (mobile) then  
     417                        x = 0xffff 
     418                        y = 0xffff 
     419                        z = 0 
     420                end 
     421                print("###############################") 
     422                print("#### drop on mobile via dialog : ",x,y,z,mobile) 
     423                print("###############################") 
    410424                Send_Drop_Object(item.serial,x,y,z,dialog_under_mouse.dropOnMobileSerial) 
    411425        elseif (dialog_under_mouse and dialog_under_mouse.uoSecureTrade) then 
     
    469483                                if (TestBit(flags,kTileDataFlag_Surface)) then iSerial = nil end   --  or kTileDataFlag_Background ? 
    470484                                if (ItemIsMulti(dynamic)) then iSerial = nil end 
     485                                if (iSerial) then  
     486                                        -- pol fix? 
     487                                        x = dynamic.xloc  
     488                                        y = dynamic.yloc  
     489                                        z = dynamic.zloc  
     490                                        print("###############################") 
     491                                        print("#### drop on other item in world : ",x,y,z) 
     492                                        print("###############################") 
     493                                end 
     494                        end 
     495                        local mobile = GetMobile(iSerial) 
     496                        if (mobile) then  
     497                                x = 0xffff 
     498                                y = 0xffff 
     499                                z = 0 
     500                                print("###############################") 
     501                                print("#### drop on mobile in world : ",x,y,z,mobile) 
     502                                print("###############################") 
    471503                        end 
    472504                end 
  • trunk/lua/net/net.tooltips.lua

    r3092 r3233  
    1919--endloop       - Item Info 
    2020function Send_AosToolTipRequest(objserial) 
     21        if (gClientDisable_kPacket_Mega_Cliloc) then return end 
    2122        local out = GetSendFIFO() 
    2223        out:PushNetUint8(kPacket_Mega_Cliloc) -- 0xD6 runuo : BatchQueryProperties 
  • trunk/lua/net/net.walk.lua

    r3061 r3233  
    4646 
    4747gWalkRequestAntiStuckTimeout = 0 -- Client_GetTicks() 
     48gWalkRequestAntiStuckTimeoutDelay = 2000 
    4849gNextWalkRequestTime = 0 
    4950gNextWalkSequenceNumber = 0 
     
    5758gWalkTimeout_MountRunningSpeed = 95 
    5859gWalkTimeout_DirectionChange = 60 
     60gMaxWalkQueueEntries = 3 
     61 
     62 
    5963 
    6064 
     
    7882        WalkLog("FastWalk_Init end")  
    7983end 
    80 function FastWalk_PushKey       (key)           WalkLog("FastWalk_PushKey",key) table.insert(gFastwalkStack,key) gFastWalkKeysUsed = true end 
     84function FastWalk_PushKey       (key)            
     85        WalkLog("FastWalk_PushKey",key)  
     86        table.insert(gFastwalkStack,key)  
     87        gFastWalkKeysUsed = true  
     88end 
    8189function FastWalk_PopKey        () 
    8290        local res = FastWalk_HasKey() and table.remove(gFastwalkStack) or 0 
     
    8492        return res  
    8593end  
    86 function FastWalk_Ok    ()                      return FastWalk_HasKey() or (not gFastWalkKeysUsed) end  
     94function FastWalk_Ok            ()                      return FastWalk_HasKey() or (not gFastWalkKeysUsed) end  
    8795function FastWalk_HasKey        ()                      return notempty(gFastwalkStack) end  
    8896function FastWalk_CountKeys     ()                      return table.getn(gFastwalkStack) end 
     
    188196-- returns false if the walk queue is full and the next request should wait 
    189197function WalkQueueOkForNextSend () 
    190         return countarr(gWalkRequests) <= 3 
     198        return countarr(gWalkRequests) <= gMaxWalkQueueEntries 
    191199end 
    192200         
     
    203211                if (not WalkQueueOkForNextSend()) then 
    204212                        if (Client_GetTicks() > gWalkRequestAntiStuckTimeout) then 
    205                                 print("walk:walk-request-timeout,sending resync-request") 
     213                                print("++++++++++++++++++++++++++++++ walk:walk-request-timeout,sending resync-request") 
    206214                                Send_Movement_Resync_Request() 
    207215                        else 
     
    212220        end 
    213221        gProfiler_Walk:Section("ExecWalk:TimeCalc") 
    214         gWalkRequestAntiStuckTimeout = Client_GetTicks() + 2000 -- might need resync 
     222        gWalkRequestAntiStuckTimeout = Client_GetTicks() + gWalkRequestAntiStuckTimeoutDelay -- might need resync 
    215223        iDir = DirWrap(iDir) 
    216224        local iFullDir = BitwiseOR(iDir,bRunFlag and kWalkFlag_Run or 0) -- includes runflag 
     
    275283        out:PushNetUint32(iFastKey) 
    276284        out:SendPacket() 
    277         --~ print("walk:request",sprintf("0x%04x",iFullDir),iSeqNum) 
     285        print("++++++++++++++++++++++++++++++ walk:request",sprintf("0x%04x",iFullDir),iSeqNum,WalkGetInterval(TestBit(iFullDir,kWalkFlag_Run))) 
    278286end 
    279287 
     
    284292        local id = input:PopNetUint8() 
    285293        local iSeqNum = input:PopNetUint8() 
    286         --~ print("walk:accept",iSeqNum) 
     294        print("++++++++++++++++++++++++++++++ walk:accept",iSeqNum) 
    287295        local player_notoriety = input:PopNetUint8() 
    288296        local playermobile = GetPlayerMobile() 
     
    309317function ResetWalkQueue () 
    310318        --~ WalkLog("ResetWalkQueue start") 
     319        print("ResetWalkQueue,gNextWalkSequenceNumber=0") 
     320        print(_TRACEBACK()) 
    311321        gNextWalkSequenceNumber = 0 
    312322        gWalkRequests = {} 
     
    358368        out:PushNetUint8(hex2num("0x00")) 
    359369        out:SendPacket() 
     370        print("++++++++++++++++++++++++++++++ Send_Accept_Block_Movement",seqnumber) 
    360371end 
    361372 
     
    376387        out:PushNetUint8(0) 
    377388        out:SendPacket() 
     389        print("++++++++++++++++++++++++++++++ Send_Movement_Resync_Request,0,0") 
    378390end 
    379391