Changeset 3233
- Timestamp:
- 01/23/10 01:38:16 (7 weeks ago)
- Location:
- trunk/lua
- Files:
-
- 4 modified
-
lib.proxy.lua (modified) (13 diffs)
-
lib.uodragdrop.lua (modified) (3 diffs)
-
net/net.tooltips.lua (modified) (1 diff)
-
net/net.walk.lua (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/lua/lib.proxy.lua
r3232 r3233 17 17 gProxyHost = host 18 18 gProxyPort = port 19 gProxyPort2 = port+1 19 gProxyPort2 = port 20 --~ gProxyPort2 = port+1 20 21 21 22 gServerListenerTCP = UOProxyOpenListener(gProxyPort) 22 gServerListenerTCP2 = UOProxyOpenListener(gProxyPort2)23 --~ gServerListenerTCP2 = UOProxyOpenListener(gProxyPort2) 23 24 24 25 print("listen port opened....") … … 27 28 local listener = gServerListenerTCP 28 29 while true do 29 local newcon = listener: PopAccepted()30 local newcon = listener:IsAlive() and listener:PopAccepted() 30 31 if (not newcon) then break end 31 32 print("###############################") … … 36 37 print("#### PROXY : connection ended") 37 38 print("###############################") 38 listener = gServerListenerTCP239 --~ listener = gServerListenerTCP2 39 40 --~ print("proxy end") return 40 41 end … … 111 112 112 113 114 gLastPacketTBySender = {} 113 115 -- returns false if packet incomplete 114 116 function UOProxyHandlePacket (fifo_in,fifo_out,bIsFromClient) … … 121 123 --~ if (bIsFromServer and gProxyServerHuffmanStarted) then bInterpret = false end -- huffman comp&decomp active now 122 124 --~ if (bIsFromClient and gProxyServerHuffmanStarted) then bInterpret = false end -- not really needed but something seems bugged 123 if (gDisableProxyInterpretation) then bInterpret = false end125 --~ if (gDisableProxyInterpretation) then bInterpret = false end 124 126 local bScrambleTest = false 125 127 local bClientBlockTest = true 128 local bShortDump = false 126 129 127 130 if (bInterpret) then … … 177 180 fifo_in:PeekNetUint8(4) == 0x24) then 178 181 --~ 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 182 187 if (bScrambleTest) then 183 188 fifo_in:PokeNetUint8(5,16) … … 205 210 end 206 211 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 207 219 if (bInterpret) then 208 220 local iId = fifo_in:PeekNetUint8(0) 209 221 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 213 224 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) 216 242 217 243 if (bIsFromServer and iId == kPacket_Server_List) then -- 0xA8 … … 241 267 fifo_in:PokeNetUint8(6,math.mod(iGameServerPort,256)) -- port 242 268 243 gProxyServerHuffmanStartedNextRound = true 269 gProxyServerHuffmanStartedNextRound = true -- only after 4 byte header? 270 gDisableProxyInterpretation = true 244 271 print("+++++++++++++++++++++++++++++++++++++++++++++++") 245 272 print("+++++ adjusted kPacket_Server_Redirect") 246 273 print("+++++++++++++++++++++++++++++++++++++++++++++++") 247 gDisableProxyInterpretation = true248 274 end 249 275 … … 299 325 ]]-- 300 326 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 304 331 --~ print(FIFOHexDump(fifo_in,0,iPacketSize)) 305 332 fifo_out:PushFIFOPartRaw(fifo_in,0,iPacketSize) … … 359 386 gProxyClientSendCompFifo = CreateFIFO() 360 387 388 local fHuffmanDummy_RawIn = CreateFIFO() 389 local fHuffmanDummy_RawOut = CreateFIFO() 390 local fHuffmanDummy_DecompIn = CreateFIFO() 391 local fHuffmanDummy_DecompOut = CreateFIFO() 392 393 361 394 gPacketSizeByID[0xEF] = 21 -- protocol start... dummy here 362 395 … … 364 397 while bAlive do 365 398 -- 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 373 405 gProxyClientCon:Push(gProxyClientSendFifo) 374 406 gProxyClientSendFifo:Clear() 375 end407 --~ end 376 408 377 409 gProxyServerCon:Push(gProxyServerSendFifo) … … 385 417 gProxyClientCon:Pop(gProxyClientRecvFifo) 386 418 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 387 427 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 390 446 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 397 449 while UOProxyHandlePacket(gProxyClientRecvFifo,gProxyServerSendFifo,true) do end 398 450 … … 409 461 gProxyServerRecvCompFifo:Destroy() 410 462 gProxyClientSendCompFifo:Destroy() 463 464 fHuffmanDummy_RawIn:Destroy() 465 fHuffmanDummy_RawOut:Destroy() 466 fHuffmanDummy_DecompIn:Destroy() 467 fHuffmanDummy_DecompOut:Destroy() 411 468 end 412 469 -
trunk/lua/lib.uodragdrop.lua
r3195 r3233 374 374 x = 0xffff 375 375 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("###############################") 377 382 target = gMousePickFoundHit.item.serial 378 383 --[[ … … 408 413 elseif (dialog_under_mouse and dialog_under_mouse.dropOnMobileSerial) then 409 414 -- 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("###############################") 410 424 Send_Drop_Object(item.serial,x,y,z,dialog_under_mouse.dropOnMobileSerial) 411 425 elseif (dialog_under_mouse and dialog_under_mouse.uoSecureTrade) then … … 469 483 if (TestBit(flags,kTileDataFlag_Surface)) then iSerial = nil end -- or kTileDataFlag_Background ? 470 484 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("###############################") 471 503 end 472 504 end -
trunk/lua/net/net.tooltips.lua
r3092 r3233 19 19 --endloop - Item Info 20 20 function Send_AosToolTipRequest(objserial) 21 if (gClientDisable_kPacket_Mega_Cliloc) then return end 21 22 local out = GetSendFIFO() 22 23 out:PushNetUint8(kPacket_Mega_Cliloc) -- 0xD6 runuo : BatchQueryProperties -
trunk/lua/net/net.walk.lua
r3061 r3233 46 46 47 47 gWalkRequestAntiStuckTimeout = 0 -- Client_GetTicks() 48 gWalkRequestAntiStuckTimeoutDelay = 2000 48 49 gNextWalkRequestTime = 0 49 50 gNextWalkSequenceNumber = 0 … … 57 58 gWalkTimeout_MountRunningSpeed = 95 58 59 gWalkTimeout_DirectionChange = 60 60 gMaxWalkQueueEntries = 3 61 62 59 63 60 64 … … 78 82 WalkLog("FastWalk_Init end") 79 83 end 80 function FastWalk_PushKey (key) WalkLog("FastWalk_PushKey",key) table.insert(gFastwalkStack,key) gFastWalkKeysUsed = true end 84 function FastWalk_PushKey (key) 85 WalkLog("FastWalk_PushKey",key) 86 table.insert(gFastwalkStack,key) 87 gFastWalkKeysUsed = true 88 end 81 89 function FastWalk_PopKey () 82 90 local res = FastWalk_HasKey() and table.remove(gFastwalkStack) or 0 … … 84 92 return res 85 93 end 86 function FastWalk_Ok () return FastWalk_HasKey() or (not gFastWalkKeysUsed) end94 function FastWalk_Ok () return FastWalk_HasKey() or (not gFastWalkKeysUsed) end 87 95 function FastWalk_HasKey () return notempty(gFastwalkStack) end 88 96 function FastWalk_CountKeys () return table.getn(gFastwalkStack) end … … 188 196 -- returns false if the walk queue is full and the next request should wait 189 197 function WalkQueueOkForNextSend () 190 return countarr(gWalkRequests) <= 3198 return countarr(gWalkRequests) <= gMaxWalkQueueEntries 191 199 end 192 200 … … 203 211 if (not WalkQueueOkForNextSend()) then 204 212 if (Client_GetTicks() > gWalkRequestAntiStuckTimeout) then 205 print(" walk:walk-request-timeout,sending resync-request")213 print("++++++++++++++++++++++++++++++ walk:walk-request-timeout,sending resync-request") 206 214 Send_Movement_Resync_Request() 207 215 else … … 212 220 end 213 221 gProfiler_Walk:Section("ExecWalk:TimeCalc") 214 gWalkRequestAntiStuckTimeout = Client_GetTicks() + 2000-- might need resync222 gWalkRequestAntiStuckTimeout = Client_GetTicks() + gWalkRequestAntiStuckTimeoutDelay -- might need resync 215 223 iDir = DirWrap(iDir) 216 224 local iFullDir = BitwiseOR(iDir,bRunFlag and kWalkFlag_Run or 0) -- includes runflag … … 275 283 out:PushNetUint32(iFastKey) 276 284 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))) 278 286 end 279 287 … … 284 292 local id = input:PopNetUint8() 285 293 local iSeqNum = input:PopNetUint8() 286 --~ print("walk:accept",iSeqNum)294 print("++++++++++++++++++++++++++++++ walk:accept",iSeqNum) 287 295 local player_notoriety = input:PopNetUint8() 288 296 local playermobile = GetPlayerMobile() … … 309 317 function ResetWalkQueue () 310 318 --~ WalkLog("ResetWalkQueue start") 319 print("ResetWalkQueue,gNextWalkSequenceNumber=0") 320 print(_TRACEBACK()) 311 321 gNextWalkSequenceNumber = 0 312 322 gWalkRequests = {} … … 358 368 out:PushNetUint8(hex2num("0x00")) 359 369 out:SendPacket() 370 print("++++++++++++++++++++++++++++++ Send_Accept_Block_Movement",seqnumber) 360 371 end 361 372 … … 376 387 out:PushNetUint8(0) 377 388 out:SendPacket() 389 print("++++++++++++++++++++++++++++++ Send_Movement_Resync_Request,0,0") 378 390 end 379 391
