UO::SendPacket() (POL 097 2008-02-26)

Report core bugs regarding the Ultima Online Emulator Core release (version 097). You can attach your Core Dump. One bug per post.

Moderator: POL Developer

Locked
User avatar
ncrsn
Grandmaster Poster
Posts: 255
Joined: Fri Feb 10, 2006 12:15 am

UO::SendPacket() (POL 097 2008-02-26)

Post by ncrsn »

While it is impossible to Pack() a packet object, packet's data can be saved as string and sent later using UO::SendPacket().

The problem, so it seems, is that this functions cannot handle packets correctly after their length exceeds 2000 bytes. That is enough for most cases, but sometimes packet is larger, and as a result, client receives corrupted data.

If you dare, you can test this using the following code. It contains a page of spawn region information gump, so it is not harmful. If you do test, do first .startlog (every packet is logged into /log/-acctname-.log), and afterwards, .stoplog, so you can see the problem yourself. On and after the line that begins "07d0:" there are nothing but zeros, though there should. The packet's size, however, remains correct.

I split the packet string to multiple lines so the layout won't broke: you should trim it back to just one line before testing: var text := "[string]";.

Of course any other string-formated packet sized over 2000 bytes should give the same result. They are just a pain to filter manually, so I thought I could as well lend my own test string.

Code: Select all

// Name the script how ever you may wish.

use uo;

program command( who )

    var text := "
b00d8d000000030006d8e1000000000000000009547b20706167652030207d7b206e6f646973706f7365207d7b20706
167652030207d7b20726573697a657069632030203020353132302034343020343730207d7b20726573697a65706963
20313020313020353035342034323020343230207d7b20746578742031333220313720302030207d7b2074657874203
133302031352035332031207d7b20746578742033302033302039392032207d7b207465787420333030203330203939
2033207d7b2074657874203337302033302039392034207d7b207465787420313430203430302036332035207d7b206
27574746f6e20313137203430302032313020323131203120302031303235207d7b2074657874203237302034303020
36332036207d7b2074657874203530203337302033342037207d7b20627574746f6e203135203337302034303233203
4303235203120302031303236207d7b20627574746f6e20323437203430302032313020323131203120302031303237
207d7b20627574746f6e2034302034303020323037312032303732203120302031303238207d7b20706167652030207
d7b20627574746f6e203430302034303020343030352034303037203120302031303239207d7b20706167652030207d
7b20627574746f6e2031352036302032303820323039203120302031303330207d7b2063726f70706564746578742033
35203537203332302032302036332038207d7b2074657874203330302036302039382039207d7b20627574746f6e2033
38352036302032313020323131203120302031303331207d7b20627574746f6e20313520383020323038203230392031
20302031303332207d7b2063726f707065647465787420333520373720333230203230203633203130207d7b20746578
7420333030203830203938203131207d7b20627574746f6e203338352038302032313020323131203120302031303333
207d7b20627574746f6e203135203130302032303820323039203120302031303334207d7b2063726f70706564746578
7420333520393720333230203230203633203132207d7b20746578742033303020313030203938203133207d7b20627
574746f6e20333835203130302032313020323131203120302031303335207d7b20627574746f6e20313520313230203
2303820323039203120302031303336207d7b2063726f707065647465787420333520313137203332302032302036332
03134207d7b20746578742033303020313230203938203135207d7b20627574746f6e203338352031323020323130203
23131203120302031303337207d7b20627574746f6e203135203134302032303820323039203120302031303338207d7
b2063726f70706564746578742033352031333720333230203230203633203136207d7b2074657874203330302031343
0203938203137207d7b20627574746f6e20333835203134302032313020323131203120302031303339207d7b2062757
4746f6e203135203136302032303820323039203120302031303430207d7b2063726f7070656474657874203335203135
3720333230203230203633203138207d7b20746578742033303020313630203938203139207d7b20627574746f6e20333
835203136302032313020323131203120302031303431207d7b20627574746f6e20313520313830203230382032303920
3120302031303432207d7b2063726f70706564746578742033352031373720333230203230203633203230207d7b20746
578742033303020313830203938203231207d7b20627574746f6e20333835203138302032313020323131203120302031
303433207d7b20627574746f6e203135203230302032303820323039203120302031303434207d7b2063726f707065647
46578742033352031393720333230203230203633203232207d7b20746578742033303020323030203938203233207d7
b20627574746f6e20333835203230302032313020323131203120302031303435207d7b20627574746f6e203135203232
302032303820323039203120302031303436207d7b2063726f70706564746578742033352032313720333230203230203
633203234207d7b20746578742033303020323230203938203235207d7b20627574746f6e203338352032323020323130
20323131203120302031303437207d7b20627574746f6e203135203234302032303820323039203120302031303438207
d7b2063726f70706564746578742033352032333720333230203230203633203236207d7b207465787420333030203234
30203938203237207d7b20627574746f6e20333835203234302032313020323131203120302031303439207d7b2062757
4746f6e203135203236302032303820323039203120302031303530207d7b2063726f7070656474657874203335203235
3720333230203230203633203238207d7b20746578742033303020323630203938203239207d7b20627574746f6e20333
835203236302032313020323131203120302031303531207d7b20627574746f6e20313520323830203230382032303920
3120302031303532207d7b2063726f70706564746578742033352032373720333230203230203633203330207d7b20746
578742033303020323830203938203331207d7b20627574746f6e20333835203238302032313020323131203120302031
303533207d7b20627574746f6e203135203330302032303820323039203120302031303534207d7b2063726f707065647
46578742033352032393720333230203230203633203332207d7b20746578742033303020333030203938203333207d7
b20627574746f6e20333835203330302032313020323131203120302031303535207d7b20627574746f6e203135203332
302032303820323039203120302031303536207d7b2063726f70706564746578742033352033313720333230203230203
633203334207d7b20746578742033303020333230203938203335207d7b20627574746f6e203338352033323020323130
20323131203120302031303537207d7b20627574746f6e203135203334302032303820323039203120302031303538207
d7b2063726f70706564746578742033352033333720333230203230203633203336207d7b207465787420333030203334
30203938203337207d7b20627574746f6e20333835203334302032313020323131203120302031303539207d7b2070616
7652030207d7b20746578742031303020343330203533203338207d7b2074657874203130302034343520353320333920
7d00002800140053007000610077006e00200052006500670069006f006e0020004d0061006e006100670065007200140
053007000610077006e00200052006500670069006f006e0020004d0061006e0061006700650072000b00520065006700
69006f006e0020004e0061006d0065000600530074006100740075007300050047006f00200054006f000b004100640064
00200052006500670069006f006e003f000c0045006400690074002000470072006f007500700073003f003300440065007
3007000610077006e00200041006c006c00200052006500670069006f006e0073002000280072006500670069006f006e0
073002000770069006c006c0020007200650073007000610077006e0020006e006f0072006d0061006c006c00790029000
d006200720069006700670061006e006400200066006f0072007400030035002f0035000e0062007200690074002000660
0610072006d006c0061006e00640073000500330031002f00330031000a00620072006900740020006e002000280061002
9000500310036002f00310036000a00620072006900740020006e0020002800630029000500330038002f00330038000f00
620072006900740020006e0065006100720020006e0020002800610029000500310030002f00310030000f0062007200690
0740020006e0065006100720020006e0020002800630029000500310038002f00310038001200620072006900740020006e
007700200066006f00720065007300740020002800610029000500320039002f00320039001200620072006900740020006
e007700200066006f00720065007300740020002800630029000500350033002f0035003300100062007200690074002f00
6d0069006e006f00630020007300770061006d0070000500350030002f0035003000150062007200690074005f0065005f0
074006f0077006e005f006300720065006100740075007200650073000500340030002f0034003000150062007200690074
005f0077005f0074006f0077006e005f006300720065006100740075007200650073000500330035002f0033003500130062
00720069007400610069006e0020006e006500200077006f006f00640073002000620067000500350032002f00350032001
1004200720069007400610069006e005f004700720061007600650079006100720064000500310035002f00310035000400
63006f00760065000500310030002f0031003000130063006f00760065005f006f00720063005f0066006f00720074005f0064
006f0063006b007300030033002f0033001d0053007000610077006e00200052006500670069006f006e0020005500730061
0067006500200053007400610074006900730074006900630073001700430075007200720065006e0074002000530074006
1007400750073003a0020003400300035002f003400300035
    ";
    
    SendPacket(who, text);

endprogram
Nando
POL Developer
Posts: 282
Joined: Wed Sep 17, 2008 6:53 pm
Contact:

Re: UO::SendPacket() (POL 097 2008-02-26)

Post by Nando »

There's a internal limit of 2000 bytes on the SendPacket's packet. What's the ideal size? Should it accept any?
User avatar
ncrsn
Grandmaster Poster
Posts: 255
Joined: Fri Feb 10, 2006 12:15 am

Re: UO::SendPacket() (POL 097 2008-02-26)

Post by ncrsn »

Sorry it took me a while longer to reply than I suspected.

I already talked about this with Nando at IRC, and for what I understood, either this function will be fixed to accept packets even longer than 2000 bytes or (/and) packet objects will be made packable using Basic::Pack(), which would make this bug less important to fix.

I vote for both, because I can.
MuadDib
Former Developer
Posts: 1091
Joined: Sun Feb 12, 2006 9:50 pm
Location: Cross Lanes, WV

Re: UO::SendPacket() (POL 097 2008-02-26)

Post by MuadDib »

This is going to be addressed soon.

Firstly, Buffer size (internal) will be increased from 2000 to 4096. Second, we will look at a more dynamic method also once this is done, in order to allow it to increase for the newer larger gump packets that are possible (although unsure yet if this will be needed until I investigate it more or can talk Turley into it, hehe).
MuadDib
Former Developer
Posts: 1091
Joined: Sun Feb 12, 2006 9:50 pm
Location: Cross Lanes, WV

Re: UO::SendPacket() (POL 097 2008-02-26)

Post by MuadDib »

Ok, internal size is big enough (just verified). As stated, it is only the SendPacket() function where this is an issue (and the Menu commands, as they max out at 2k, but if you send a menu over 2k in length, you got other issues at hand, lol).

We are looking at dynamically creating the buffer for this command SendPacket(). This way, it checks length, if not divisible by 2, error out due to invalid length (since each byte is 2 digits such as 00 01 etc), error out if length greater than 65k, otherwise, create the internal buffer dynamically. This should fix any issues you would have with SendPacket, without having to pass the length (and thus breaking scripts until you update them).

Unless mistaken, Turley is working on this (been discussing the overall issue and fixes with him while writing all this). So, expect this in the next core update.
Locked