From acfe321f095725b057de099c6f7445b3f405ee1f Mon Sep 17 00:00:00 2001 From: Obique Date: Sun, 2 Nov 2014 19:24:26 -0600 Subject: [PATCH] Added network packets --- lib/ControlAPI.jar | Bin 0 -> 5875 bytes src/network/packets/swg/ErrorMessage.java | 40 +++ .../packets/swg/ServerUnixEpochTime.java | 36 ++ .../packets/swg/login/AccountFeatureBits.java | 33 ++ .../swg/login/CharacterCreationDisabled.java | 50 +++ .../packets/swg/login/ClientIdMsg.java | 45 +++ .../swg/login/ClientPermissionsMessage.java | 35 ++ .../swg/login/EnumerateCharacterId.java | 103 ++++++ .../packets/swg/login/LoginClientId.java | 51 +++ .../packets/swg/login/LoginClientToken.java | 65 ++++ .../packets/swg/login/LoginClusterStatus.java | 84 +++++ .../packets/swg/login/LoginEnumCluster.java | 70 ++++ .../swg/login/OfflineServersMessage.java | 60 ++++ .../swg/login/RequestExtendedClusters.java | 28 ++ src/network/packets/swg/login/ServerId.java | 39 +++ .../packets/swg/login/ServerString.java | 39 +++ .../swg/login/StationIdHasJediSlot.java | 40 +++ .../login/creation/ApproveNameRequest.java | 41 +++ .../login/creation/ApproveNameResponse.java | 38 ++ .../login/creation/ClientCreateCharacter.java | 96 +++++ .../creation/CreateCharacterFailure.java | 60 ++++ .../creation/CreateCharacterSuccess.java | 37 ++ .../creation/DeleteCharacterRequest.java | 41 +++ .../creation/DeleteCharacterResponse.java | 34 ++ .../swg/login/creation/RandomNameRequest.java | 32 ++ .../login/creation/RandomNameResponse.java | 47 +++ .../packets/swg/zone/ChatRequestRoomList.java | 27 ++ .../packets/swg/zone/CmdSceneReady.java | 27 ++ .../zone/ConnectPlayerResponseMessage.java | 33 ++ .../swg/zone/GalaxyLoopTimesRequest.java | 27 ++ .../swg/zone/GalaxyLoopTimesResponse.java | 34 ++ .../packets/swg/zone/HeartBeatMessage.java | 28 ++ .../swg/zone/OpenedContainerMessage.java | 43 +++ .../packets/swg/zone/ParametersMessage.java | 29 ++ .../swg/zone/SceneCreateObjectByCrc.java | 61 ++++ .../packets/swg/zone/SceneDestroyObject.java | 44 +++ .../packets/swg/zone/SceneEndBaselines.java | 37 ++ .../packets/swg/zone/ServerTimeMessage.java | 38 ++ .../swg/zone/UpdateContainmentMessage.java | 47 +++ .../swg/zone/UpdatePostureMessage.java | 44 +++ .../swg/zone/UpdatePvpStatusMessage.java | 47 +++ .../swg/zone/UpdateTransformsMessage.java | 64 ++++ .../auction/AuctionQueryHeadersMessage.java | 35 ++ .../AuctionQueryHeadersResponseMessage.java | 222 ++++++++++++ .../auction/CancelLiveAuctionMessage.java | 35 ++ .../CancelLiveAuctionResponseMessage.java | 35 ++ .../swg/zone/auction/GetAuctionDetails.java | 39 +++ .../auction/GetAuctionDetailsResponse.java | 65 ++++ .../auction/IsVendorOwnerResponseMessage.java | 35 ++ .../auction/RetrieveAuctionItemMessage.java | 35 ++ .../RetrieveAuctionItemResponseMessage.java | 35 ++ .../packets/swg/zone/baselines/Baseline.java | 74 ++++ .../packets/swg/zone/baselines/CREO3.java | 81 +++++ .../packets/swg/zone/baselines/CREO6.java | 98 ++++++ .../packets/swg/zone/baselines/CREO8.java | 22 ++ .../packets/swg/zone/baselines/CREO9.java | 22 ++ .../packets/swg/zone/baselines/PLAY6.java | 28 ++ .../packets/swg/zone/baselines/PLAY9.java | 86 +++++ .../building/UpdateCellPermissionMessage.java | 47 +++ .../swg/zone/chat/ChatFriendsListUpdate.java | 47 +++ .../packets/swg/zone/chat/ChatIgnoreList.java | 86 +++++ .../chat/ChatInstantMessageToCharacter.java | 65 ++++ .../zone/chat/ChatInstantMessageToClient.java | 59 ++++ .../swg/zone/chat/ChatOnConnectAvatar.java | 35 ++ .../swg/zone/chat/ChatOnDestroyRoom.java | 58 +++ .../swg/zone/chat/ChatOnEnteredRoom.java | 78 +++++ .../swg/zone/chat/ChatOnLeaveRoom.java | 57 +++ .../chat/ChatOnReceiveRoomInvitation.java | 35 ++ .../zone/chat/ChatOnSendInstantMessage.java | 43 +++ .../swg/zone/chat/ChatOnSendRoomMessage.java | 38 ++ .../chat/ChatPersistentMessageToClient.java | 330 ++++++++++++++++++ .../swg/zone/chat/ChatRoomMessage.java | 51 +++ .../swg/zone/chat/ChatSystemMessage.java | 58 +++ .../swg/zone/chat/ConGenericMessage.java | 41 +++ .../swg/zone/chat/VoiceChatStatus.java | 33 ++ .../swg/zone/combat/GrantCommandMessage.java | 47 +++ .../swg/zone/deltas/DeltasMessage.java | 63 ++++ .../swg/zone/insertion/ChatRoomList.java | 209 +++++++++++ .../swg/zone/insertion/ChatServerStatus.java | 34 ++ .../swg/zone/insertion/CmdStartScene.java | 76 ++++ .../zone/insertion/ConnectPlayerMessage.java | 28 ++ .../swg/zone/insertion/SelectCharacter.java | 36 ++ .../CommandQueueDequeue.java | 54 +++ .../CommandQueueEnqueue.java | 39 +++ .../zone/object_controller/DataTransform.java | 47 +++ .../object_controller/ObjectController.java | 68 ++++ .../zone/object_controller/PostureUpdate.java | 45 +++ .../zone/object_controller/SpatialChat.java | 55 +++ .../zone/server_ui/SuiCreatePageMessage.java | 123 +++++++ .../zone/server_ui/SuiEventNotification.java | 64 ++++ .../zone/spatial/AttributeListMessage.java | 64 ++++ .../zone/spatial/GetMapLocationsMessage.java | 59 ++++ .../NewTicketActivityResponseMessage.java | 35 ++ .../StopClientEffectObjectByLabelMessage.java | 45 +++ 94 files changed, 5173 insertions(+) create mode 100644 lib/ControlAPI.jar create mode 100644 src/network/packets/swg/ErrorMessage.java create mode 100644 src/network/packets/swg/ServerUnixEpochTime.java create mode 100644 src/network/packets/swg/login/AccountFeatureBits.java create mode 100644 src/network/packets/swg/login/CharacterCreationDisabled.java create mode 100644 src/network/packets/swg/login/ClientIdMsg.java create mode 100644 src/network/packets/swg/login/ClientPermissionsMessage.java create mode 100644 src/network/packets/swg/login/EnumerateCharacterId.java create mode 100644 src/network/packets/swg/login/LoginClientId.java create mode 100644 src/network/packets/swg/login/LoginClientToken.java create mode 100644 src/network/packets/swg/login/LoginClusterStatus.java create mode 100644 src/network/packets/swg/login/LoginEnumCluster.java create mode 100644 src/network/packets/swg/login/OfflineServersMessage.java create mode 100644 src/network/packets/swg/login/RequestExtendedClusters.java create mode 100644 src/network/packets/swg/login/ServerId.java create mode 100644 src/network/packets/swg/login/ServerString.java create mode 100644 src/network/packets/swg/login/StationIdHasJediSlot.java create mode 100644 src/network/packets/swg/login/creation/ApproveNameRequest.java create mode 100644 src/network/packets/swg/login/creation/ApproveNameResponse.java create mode 100644 src/network/packets/swg/login/creation/ClientCreateCharacter.java create mode 100644 src/network/packets/swg/login/creation/CreateCharacterFailure.java create mode 100644 src/network/packets/swg/login/creation/CreateCharacterSuccess.java create mode 100644 src/network/packets/swg/login/creation/DeleteCharacterRequest.java create mode 100644 src/network/packets/swg/login/creation/DeleteCharacterResponse.java create mode 100644 src/network/packets/swg/login/creation/RandomNameRequest.java create mode 100644 src/network/packets/swg/login/creation/RandomNameResponse.java create mode 100644 src/network/packets/swg/zone/ChatRequestRoomList.java create mode 100644 src/network/packets/swg/zone/CmdSceneReady.java create mode 100644 src/network/packets/swg/zone/ConnectPlayerResponseMessage.java create mode 100644 src/network/packets/swg/zone/GalaxyLoopTimesRequest.java create mode 100644 src/network/packets/swg/zone/GalaxyLoopTimesResponse.java create mode 100644 src/network/packets/swg/zone/HeartBeatMessage.java create mode 100644 src/network/packets/swg/zone/OpenedContainerMessage.java create mode 100644 src/network/packets/swg/zone/ParametersMessage.java create mode 100644 src/network/packets/swg/zone/SceneCreateObjectByCrc.java create mode 100644 src/network/packets/swg/zone/SceneDestroyObject.java create mode 100644 src/network/packets/swg/zone/SceneEndBaselines.java create mode 100644 src/network/packets/swg/zone/ServerTimeMessage.java create mode 100644 src/network/packets/swg/zone/UpdateContainmentMessage.java create mode 100644 src/network/packets/swg/zone/UpdatePostureMessage.java create mode 100644 src/network/packets/swg/zone/UpdatePvpStatusMessage.java create mode 100644 src/network/packets/swg/zone/UpdateTransformsMessage.java create mode 100644 src/network/packets/swg/zone/auction/AuctionQueryHeadersMessage.java create mode 100644 src/network/packets/swg/zone/auction/AuctionQueryHeadersResponseMessage.java create mode 100644 src/network/packets/swg/zone/auction/CancelLiveAuctionMessage.java create mode 100644 src/network/packets/swg/zone/auction/CancelLiveAuctionResponseMessage.java create mode 100644 src/network/packets/swg/zone/auction/GetAuctionDetails.java create mode 100644 src/network/packets/swg/zone/auction/GetAuctionDetailsResponse.java create mode 100644 src/network/packets/swg/zone/auction/IsVendorOwnerResponseMessage.java create mode 100644 src/network/packets/swg/zone/auction/RetrieveAuctionItemMessage.java create mode 100644 src/network/packets/swg/zone/auction/RetrieveAuctionItemResponseMessage.java create mode 100644 src/network/packets/swg/zone/baselines/Baseline.java create mode 100644 src/network/packets/swg/zone/baselines/CREO3.java create mode 100644 src/network/packets/swg/zone/baselines/CREO6.java create mode 100644 src/network/packets/swg/zone/baselines/CREO8.java create mode 100644 src/network/packets/swg/zone/baselines/CREO9.java create mode 100644 src/network/packets/swg/zone/baselines/PLAY6.java create mode 100644 src/network/packets/swg/zone/baselines/PLAY9.java create mode 100644 src/network/packets/swg/zone/building/UpdateCellPermissionMessage.java create mode 100644 src/network/packets/swg/zone/chat/ChatFriendsListUpdate.java create mode 100644 src/network/packets/swg/zone/chat/ChatIgnoreList.java create mode 100644 src/network/packets/swg/zone/chat/ChatInstantMessageToCharacter.java create mode 100644 src/network/packets/swg/zone/chat/ChatInstantMessageToClient.java create mode 100644 src/network/packets/swg/zone/chat/ChatOnConnectAvatar.java create mode 100644 src/network/packets/swg/zone/chat/ChatOnDestroyRoom.java create mode 100644 src/network/packets/swg/zone/chat/ChatOnEnteredRoom.java create mode 100644 src/network/packets/swg/zone/chat/ChatOnLeaveRoom.java create mode 100644 src/network/packets/swg/zone/chat/ChatOnReceiveRoomInvitation.java create mode 100644 src/network/packets/swg/zone/chat/ChatOnSendInstantMessage.java create mode 100644 src/network/packets/swg/zone/chat/ChatOnSendRoomMessage.java create mode 100644 src/network/packets/swg/zone/chat/ChatPersistentMessageToClient.java create mode 100644 src/network/packets/swg/zone/chat/ChatRoomMessage.java create mode 100644 src/network/packets/swg/zone/chat/ChatSystemMessage.java create mode 100644 src/network/packets/swg/zone/chat/ConGenericMessage.java create mode 100644 src/network/packets/swg/zone/chat/VoiceChatStatus.java create mode 100644 src/network/packets/swg/zone/combat/GrantCommandMessage.java create mode 100644 src/network/packets/swg/zone/deltas/DeltasMessage.java create mode 100644 src/network/packets/swg/zone/insertion/ChatRoomList.java create mode 100644 src/network/packets/swg/zone/insertion/ChatServerStatus.java create mode 100644 src/network/packets/swg/zone/insertion/CmdStartScene.java create mode 100644 src/network/packets/swg/zone/insertion/ConnectPlayerMessage.java create mode 100644 src/network/packets/swg/zone/insertion/SelectCharacter.java create mode 100644 src/network/packets/swg/zone/object_controller/CommandQueueDequeue.java create mode 100644 src/network/packets/swg/zone/object_controller/CommandQueueEnqueue.java create mode 100644 src/network/packets/swg/zone/object_controller/DataTransform.java create mode 100644 src/network/packets/swg/zone/object_controller/ObjectController.java create mode 100644 src/network/packets/swg/zone/object_controller/PostureUpdate.java create mode 100644 src/network/packets/swg/zone/object_controller/SpatialChat.java create mode 100644 src/network/packets/swg/zone/server_ui/SuiCreatePageMessage.java create mode 100644 src/network/packets/swg/zone/server_ui/SuiEventNotification.java create mode 100644 src/network/packets/swg/zone/spatial/AttributeListMessage.java create mode 100644 src/network/packets/swg/zone/spatial/GetMapLocationsMessage.java create mode 100644 src/network/packets/swg/zone/spatial/NewTicketActivityResponseMessage.java create mode 100644 src/network/packets/swg/zone/spatial/StopClientEffectObjectByLabelMessage.java diff --git a/lib/ControlAPI.jar b/lib/ControlAPI.jar new file mode 100644 index 0000000000000000000000000000000000000000..a6681c4cc02ec6b522a6f18b5ac18895cceaf707 GIT binary patch literal 5875 zcma)A2Q*x3yB1{#Lqv!cqUY$nmtYJ>v{A!o(TSEYddn!oh#tL{h&~uybQ8T35-p-f zlteGVyrz3&52!NDcRA|N2Z8i_CmWBn53Sh!ef zU>!MbWpzbfH92)}u;^=Hlw?#B1T~1aonA;8k{lSvkS9 ztSqeT+^t-AEF8>ST_q2kr(^&CfCWI^9l)jtNSM_*Fa5C?k&ek-{2_I|{G%x@_s2cI z;ikBWrnu~h<%t3G1d}`9t|9F6ewVLHCzi>wA^!B?9ps7tF!6m~HmE&< zU*H+uTGCzCf<~*=*8&0rdC+`(bVy_@JQkjE1D6UeQYBCU*9UIO#v$Q2|6$n9VQ&?F zHUEx(Wyth@F#L;|-z!IraR_<$r3dZTT6bXAUeGIehh9uEK`v;7Dv||c@`B2AKGHfq zBC$GS)Hxp+X1j?04MaWMTxR9aKel{$IPdDe7C?Wxwln+*Yx0}CT!h)-fRH-f&g)*| z;mXKHi!;=?kh|ljYCpW2h#c*USXwnF(TMZuB7-ApvWqp>SB$33EfU|1`<-;C;#MDg zTA>H=)H|N&jel5LgC)pR(1;uv@|>VPHO*}(>Pjx@)#Ca0qqzgp7)?0t$HpZMRi?;C z-Js?J+CyS(s5ssBg1t~rKd#P98Vtg2d6ludKHF&W!WgUghKAm}#N+}A-}}ESvLx+( zO;DK6zF&>F!9p<*7yfl({@G6OSpO5itB#FY03JKwo!~jh07JfIf{f$mI)Ka>hwR3N zOX}-9OJelN3!_PdEC(aEk=t)uy4$K}4&I@`inMT+qw=H((V z5Lo7xkQ9an`Cx~n+h1#3cU@ENhYc5*Jql_)hDx^0sTT_%o=}oUbF&PCMwOZY+Jc5XGI5G9XjcfqP{J5(Wi=H2!~h`+p+?ndXlYV0K9JgjK@iBF5B-2KW%qy@?cL z6q@p0bhxXwVuD+I;q2#>)-pzmlX!$vZBk^_B%>0l&|O@**oE(H;*LC;}b_ZOmFnv|JGv^Z{kRNLMbUz@M;*gG4JHpRMIk;mA^2PNyu(G}-wFs_V` zt&6uXd=q=;Fm`~5SPszw^2ZRrD#`usehFEoBQ^%UDuWyL-R|?^-Ib@mnU-S@=J--7 z0Ata93v4GYVPIO9ts^03M9i1!m={2&DG%{moCy)OlYOqPNi$>The2{{vU*fqXvgtE zJ_RH3UbPbg&r}~^21V!$3FyOZcV&+4kw>lE;b?idT0g2_fKdt7;e*kZ2>7 zma&AkS-~Sgz>6CpO(jw}7PGqBRXR8pa5JfodZ{d($?}gt=o~|rZWgVv*e;=r5M4KE zlno2_5?%fhL@O{!fX12{k>+Y#{-}y!lN2cNHhNZ%+%QUsFX+r^4>KzQ9r=!Ri(20D z7}3i)!HlzfNS#2*Vw3buzms{R?hPwlKZCY6LDs8$G`qVeGM(0e;d`@de%8AFJM9g7 z6CNV){6OtSDiLFAqAGzs5a}s*cd^f9@h)95HxbkPW&>wU&Qe2~VNc}-%Wa3n1VoaK z1rep217lZq!dy%dRkCIM+{MCr%W`RP24&h^c!70E9#5*`~cm1ecP)3aO$5`;DbSN;LDetjtRJ8($ z(Tx;a&MQf7`ma2|ybojpgUXpA=8nPr|np}A|XkCe&FK^)MS2z}+!(o$K2krhbXZ0e%b zc<|M%_7eMADK|iRqaUx7A^`X|rLg~_QvTWy)y$mCZ2o&c%+PhzzVn#epU2C9puZ$g zK{F3Kjx=Hinq8|09>rY&lWxtB>FERC)_;VY!_g0Kh=mr=6yvIMB^P-;c$g$O+hkFIj@oKa z=MlE_d9!5&oJkfoCYFPDd0F)SxdQYNar5w=AMnP0pO|q3l(Z*=y*Y|0FnyAh56oLF zO*k^@thy)3I})SUOO%Rr{I3Xw_fm3*Dd24Agr@{h3>z$YZSM;l}L| zsRrXvrc}-!Hn(v;rdt`#Q@~|CeB~KD2UGZ&893-7NANmu`b7L)uO8 zTcZ`{_u2{XeVwmKy*O6DReG)pQqA_O`;)Hwxx8$eaP#-Im%&Y~k}Vm1P}t&Y1P{EC zaMBINtR7x(m|Y^-tV?|UeT$7)8v7ujxd@EiETPWGda#r-@nVUv8fBpg2eC?yrnid| z+w|_Zmq+c@%dR@?rPS4=3IwWP)A?wExOoAF)fi>ogqfsnarWVK1&9ZM)5eg zG#+?lQ@|PbrVpnl{LI#ZBDI#wgw~stpdh-vP!(Leh@Q8S93yC)+T&pIllrK$1-J5q z4?uOa%jeTG5z!Iic%t?s(5F0lo*KQ{q)W3z-)MD0f?U#zMM>nK_7gtA zwNEGH3-Y59>8F=Xw>U5pv=afLZzw40qg%}Yqao*g*eIHQ+J~R{$7Yf}gAy?u(1y2L z_zI%#Q=AOM1TK$pQg!ameF_2*(iCuzoSi6ednnI5Tl7&V5NPdD8n(a3o|{MbkePq> zj5Dqo%z}3+-!Dc=Oz|8#;#$c|MSMv9yn%2`G0vp)Ji)gv;@R%p42AB6+N|~J%mm68 zK+(AL`Ud884xZx=^Xet6hqI3BYkPn#YADMh?h>*%Sii+DI2zeN++1I*FV?L(^(^DL z=p%~L7P(WWF&99NaJqti(8x0#P(jygn!yisT`1f>_k~7;VZa?U!-ynn?&TBnn`SI0 zv>SS{nNR8cgM6GR)H-FufnL+{R&*y?GJ4EIA^&!ed@n|d9lm+qO;zffvLh~w2#L#-%II~b$IZu zwCFeK2a=4&;x;D$b7vU4{zaT|HIN0jQPiE<1E-&u#}M3ag7$@D{JxAcRES=-c9Re} zun)})aW&)Bu2C+>4J6{s^sa7cwap;{rPunhHx02vO+F4aGkS!1cm{t*rf*HRhsjpg z?G(#8Or+Jsg_(yU%WR*%Xj8ufsHL*~{MGwnyoI+_E0kq4g09aw2?=1qt6g!NO6B4m z(!Zb(Um|_Xu|tvXs(V^{N)lQ5WS-}CKrbOr2o!eE0tSXaxCmJ&tPLd&rxF1&b74F% z+7Ay#_R+X(-W6Fi)9{u4w!Gc4W>QAjW4%bvmm`5hK5+&pncd8eE1HD)ujx%4%v4Gl#VkK0q8 zRm*mJ_w}NejCLL7A72gx<+?qrkoF)_^g40V@vbCG^|5ErCfRwZ70O&oXv7|7-wr z_MtQPWHPtT^8Fp{?Z>LVD8a|IUi;}3!DsIcr+Qsl%J8+nn&s6vsW!u2b@)sDNd3NL zTnJr%Gq#;5>*H*ET(~B-JVdx&lEvj|)oPnjquV@4I{d;#=|N4{E^ib;z=!gC4!7S& zR|{`=yw8w75XzddZOA@{CtgrE>`-dNYy==yizupP=4|MeJID(N%Lbwd0S!QDgs>+UztQe7uoSH=nYlt(QuSGy18=>pDa+cWCt4gCw z4coL-&z!`9b#kh3X?a7RO?Da5W8%@?podEf9$`wZeTfvuPFp)TCDAcr6{o&O(a@I` zROZEuwQy)2jZTtG)6287_0hpP`hBy9XU()qc9QM9cp_>69fhOP@aW^{Am*2vO6%0` z7`FVv%3_UYUyuThfKk|+MtQ5F#mH!jOFlS6x{*B*lxF1>e5Uk;zh}n+h_s9I>qxbmxi8mYY)FsWqit~$^&Y3wR{Sn7=oIgjI zaC!sRhg!QPo7E?@_cPyY0qp&>l_EZi5JuDwHNTBKIcRvpMFl$2%dbSI$`VGJ^;>?e!T#MV zBDgAzd7imAKee)exy7`TbTE)A3?Fi)&U1V3$=az#B1P{U;E;+Cs}T*#(>^q{t*m65 zx3;$N!s0eHPK$b>M{R6*=9`qC9TNL!3Vc|fRTo-nd2?%2h++0-sqA}6Q|n&D)A<`E z5$?9r`<~4Z0akw|)hW1pL|pW)nG^<~)-vb{DQh}lXhNcP?Tz|L6{6ZD@JEa1<>&uQ zA__A37OUachPO>AHVMj}{uq}~upCMnehM@C;;RG4QPb<4@gan<+Xc{cq0cCkM2t$A?Z>vWNcWpmvC_fT`G z4a>ehQfTjt=Gs<(oOyt13-K2t+;RmM8I!Jk>KOiSI9lS3aYLdn`cg$0Hid!`VkZt+ zZm#4WpC&&(u!K^)+|LxmtSduD>XF0>dq+t6L@s5O@~NuR59ZLmAfvl;^gt8AX|Mor zr8sp`ROTGtjK_ucB(;toW?i-aX2bM)4J slI*AAe|_s(BESAP*An>|!FPTY3`7O*s^P}MBDgwquiEc0^6R_*0-if4X8-^I literal 0 HcmV?d00001 diff --git a/src/network/packets/swg/ErrorMessage.java b/src/network/packets/swg/ErrorMessage.java new file mode 100644 index 000000000..b3eb12a4f --- /dev/null +++ b/src/network/packets/swg/ErrorMessage.java @@ -0,0 +1,40 @@ +package network.packets.swg; + +import java.nio.ByteBuffer; + + +public class ErrorMessage extends SWGPacket { + public static final int CRC = 0xB5ABF91A; + private String type; + private String message; + private boolean fatal; + + public ErrorMessage() { + + } + + public ErrorMessage(String type, String message, boolean fatal) { + this.type = type; + this.message = message; + this.fatal = fatal; + } + + public void decode(ByteBuffer data) { + if (!super.decode(data, CRC)) + return; + type = getAscii(data); + message = getAscii(data); + fatal = getBoolean(data); + } + + public ByteBuffer encode() { + int length = 11 + type.length() + message.length(); + ByteBuffer data = ByteBuffer.allocate(length); + addShort(data, 3); + addInt( data, CRC); + addAscii(data, type); + addAscii(data, message); + addBoolean(data, fatal); + return data; + } +} diff --git a/src/network/packets/swg/ServerUnixEpochTime.java b/src/network/packets/swg/ServerUnixEpochTime.java new file mode 100644 index 000000000..c451f8c9b --- /dev/null +++ b/src/network/packets/swg/ServerUnixEpochTime.java @@ -0,0 +1,36 @@ +package network.packets.swg; + +import java.nio.ByteBuffer; + + +public class ServerUnixEpochTime extends SWGPacket { + + public static final int CRC = 0x24B73893; + private int time = 0; + + public ServerUnixEpochTime() { + + } + + public ServerUnixEpochTime(int time) { + this.time = time; + } + + public void decode(ByteBuffer data) { + if (!super.decode(data, CRC)) + return; + time = getInt(data); + } + + public ByteBuffer encode() { + ByteBuffer data = ByteBuffer.allocate(10); + addShort(data, 2); + addInt( data, CRC); + addInt( data, time); + return data; + } + + public int getTime() { + return time; + } +} diff --git a/src/network/packets/swg/login/AccountFeatureBits.java b/src/network/packets/swg/login/AccountFeatureBits.java new file mode 100644 index 000000000..9909879a3 --- /dev/null +++ b/src/network/packets/swg/login/AccountFeatureBits.java @@ -0,0 +1,33 @@ +package network.packets.swg.login; + +import java.nio.ByteBuffer; + +import network.packets.swg.SWGPacket; + + +public class AccountFeatureBits extends SWGPacket { + + public static final int CRC = 0x979F0279; + + public AccountFeatureBits() { + + } + + public void decode(ByteBuffer data) { + if (!super.decode(data, CRC)) + return; + // Not sure how to decode this.. still a mystery + } + + public ByteBuffer encode() { + ByteBuffer data = ByteBuffer.allocate(22); + addShort(data, 2); + addInt( data, CRC); + addInt( data, 0x025C8231); + addInt( data, 1); + addInt( data, 6); + addInt( data, 0x4EEAC08A); + return data; + } + +} diff --git a/src/network/packets/swg/login/CharacterCreationDisabled.java b/src/network/packets/swg/login/CharacterCreationDisabled.java new file mode 100644 index 000000000..fad971a1b --- /dev/null +++ b/src/network/packets/swg/login/CharacterCreationDisabled.java @@ -0,0 +1,50 @@ +package network.packets.swg.login; + +import java.nio.ByteBuffer; + +import network.packets.swg.SWGPacket; + + +public class CharacterCreationDisabled extends SWGPacket { + + public static final int CRC = 0xF4A15265; + + private String [] serverNames = new String[0]; + + public CharacterCreationDisabled() { + + } + + public CharacterCreationDisabled(String [] serverNames) { + + } + + public void decode(ByteBuffer data) { + if (!super.decode(data, CRC)) + return; + int listSize = getInt(data); + serverNames = new String[listSize]; + for (int i = 0; i < listSize; i++) { + serverNames[i] = getAscii(data); + } + } + + public ByteBuffer encode() { + int length = 10; + for (int i = 0; i < serverNames.length; i++) + length += 2 + serverNames[i].length(); + ByteBuffer data = ByteBuffer.allocate(length); + addShort(data, 2); + addInt( data, CRC); + addInt( data, serverNames.length); + for (int i = 0; i < serverNames.length; i++) { + addAscii(data, serverNames[i]); + } + return data; + } + + public String [] getServerNames() { + return serverNames; + } + +} diff --git a/src/network/packets/swg/login/ClientIdMsg.java b/src/network/packets/swg/login/ClientIdMsg.java new file mode 100644 index 000000000..6cab241ce --- /dev/null +++ b/src/network/packets/swg/login/ClientIdMsg.java @@ -0,0 +1,45 @@ +package network.packets.swg.login; + +import java.nio.ByteBuffer; + +import network.packets.swg.SWGPacket; + + +public class ClientIdMsg extends SWGPacket { + + public static final int CRC = 0xD5899226; + private byte [] sessionKey; + private String version; + + public ClientIdMsg() { + this(new byte[0], ""); + } + + public ClientIdMsg(ByteBuffer data) { + decode(data); + } + + public ClientIdMsg(byte [] sessionKey, String version) { + this.sessionKey = sessionKey; + this.version = version; + } + + public void decode(ByteBuffer data) { + if (!super.decode(data, CRC)) + return; + int sessionKeyLength = getInt(data); + sessionKey = new byte[sessionKeyLength]; + data.get(sessionKey); + version = getAscii(data); + } + + public ByteBuffer encode() { + ByteBuffer data = ByteBuffer.allocate(10 + sessionKey.length + version.length()); + addShort(data, 4); + addInt( data, CRC); + addInt( data, sessionKey.length); + data.put(sessionKey); + addAscii(data, version); + return data; + } +} diff --git a/src/network/packets/swg/login/ClientPermissionsMessage.java b/src/network/packets/swg/login/ClientPermissionsMessage.java new file mode 100644 index 000000000..3bbe22a92 --- /dev/null +++ b/src/network/packets/swg/login/ClientPermissionsMessage.java @@ -0,0 +1,35 @@ +package network.packets.swg.login; + +import java.nio.ByteBuffer; + +import network.packets.swg.SWGPacket; + + +public class ClientPermissionsMessage extends SWGPacket { + + public static final int CRC = 0xE00730E5; + + public ClientPermissionsMessage() { + + } + + public void decode(ByteBuffer data) { + if (!super.decode(data, CRC)) + return; + getByte(data); // 1 + getByte(data); // 1 + getByte(data); // 0 + getByte(data); // 1 + } + + public ByteBuffer encode() { + ByteBuffer data = ByteBuffer.allocate(10); + addShort(data, 5); + addInt( data, CRC); + addByte( data, 1); + addByte( data, 1); + addByte( data, 0); + addByte( data, 1); + return data; + } +} diff --git a/src/network/packets/swg/login/EnumerateCharacterId.java b/src/network/packets/swg/login/EnumerateCharacterId.java new file mode 100644 index 000000000..e826cce4f --- /dev/null +++ b/src/network/packets/swg/login/EnumerateCharacterId.java @@ -0,0 +1,103 @@ +package network.packets.swg.login; + +import java.nio.ByteBuffer; +import java.util.Vector; + +import network.packets.swg.SWGPacket; + + +public class EnumerateCharacterId extends SWGPacket { + + public static final int CRC = 0x65EA4574; + + private SWGCharacter [] characters; + + public EnumerateCharacterId() { + characters = new SWGCharacter[0]; + } + + public EnumerateCharacterId(SWGCharacter [] characters) { + this.characters = characters; + } + + public void decode(ByteBuffer data) { + if (!super.decode(data, CRC)) + return; + int characterLength = getInt(data); + Vector _characters = new Vector(); + for (int i = 0; i < characterLength; i++) { + SWGCharacter c = new SWGCharacter(); + c.decode(data); + _characters.add(c); + } + characters = _characters.toArray(new SWGCharacter[0]); + } + + public ByteBuffer encode() { + int length = 10; + for (int i = 0; i < characters.length; i++) { + length += characters[i].getLength(); + } + ByteBuffer data = ByteBuffer.allocate(length); + addShort(data, 2); + addInt( data, CRC); + addInt( data, characters.length); + for (SWGCharacter c : characters) { + data.put(c.encode().array()); + } + return data; + } + + public SWGCharacter [] getCharacters () { + return characters; + } + + public static class SWGCharacter extends EnumerateCharacterId { + private String name; + private int raceCrc; + private long id; + private int galaxyId; + private int status; + + public SWGCharacter() { + + } + + public SWGCharacter(String name, int raceCrc, long id, int galaxyId, int status) { + this.name = name; + this.raceCrc = raceCrc; + this.id = id; + this.galaxyId = galaxyId; + this.status = status; + } + + public int getLength() { + return 24 + name.length() * 2; + } + + public void decode(ByteBuffer data) { + name = getUnicode(data); + raceCrc = getInt(data); + id = getLong(data); + galaxyId = getInt(data); + status = getInt(data); + } + + public ByteBuffer encode() { + ByteBuffer data = ByteBuffer.allocate(getLength()); + addUnicode(data, name); + addInt( data, raceCrc); + addLong( data, id); + addInt( data, galaxyId); + addInt( data, status); + return data; + } + + public long getId() { return id; } + public String getName() { return name; } + public int getRaceCrc() { return raceCrc; } + public int getGalaxyId() { return galaxyId; } + public int getStatus() { return status; } + + } +} diff --git a/src/network/packets/swg/login/LoginClientId.java b/src/network/packets/swg/login/LoginClientId.java new file mode 100644 index 000000000..2197ccdfa --- /dev/null +++ b/src/network/packets/swg/login/LoginClientId.java @@ -0,0 +1,51 @@ +package network.packets.swg.login; + +import java.nio.ByteBuffer; + +import network.packets.swg.SWGPacket; + + +public class LoginClientId extends SWGPacket { + + public static final int CRC = 0x41131F96; + private String username; + private String password; + private String version; + + public LoginClientId() { + this("", "", ""); + } + + public LoginClientId(ByteBuffer data) { + decode(data); + } + + public LoginClientId(String username, String password, String version) { + this.username = username; + this.password = password; + this.version = version; + } + + public void decode(ByteBuffer data) { + if (!super.decode(data, CRC)) + return; + username = getAscii(data); + password = getAscii(data); + version = getAscii(data); + } + + public ByteBuffer encode() { + int length = 6 + 6 + username.length() * 2 + password.length() * 2 + version.length() * 2; + ByteBuffer data = ByteBuffer.allocate(length); + addShort(data, 4); + addInt( data, CRC); + addAscii(data, username); + addAscii(data, password); + addAscii(data, version); + return data; + } + + public String getUsername() { return username; } + public String getPassword() { return password; } + public String getVersion() { return version; } +} diff --git a/src/network/packets/swg/login/LoginClientToken.java b/src/network/packets/swg/login/LoginClientToken.java new file mode 100644 index 000000000..3a8811797 --- /dev/null +++ b/src/network/packets/swg/login/LoginClientToken.java @@ -0,0 +1,65 @@ +package network.packets.swg.login; + +import java.nio.ByteBuffer; + +import network.packets.swg.SWGPacket; + + +public class LoginClientToken extends SWGPacket { + + public static final int CRC = 0xAAB296C6; + private byte [] sessionKey; + private int userId; + private String username; + + public LoginClientToken() { + + } + + public LoginClientToken(ByteBuffer data) { + decode(data); + } + + public LoginClientToken(byte [] sessionKey, int userId, String username) { + this.sessionKey = sessionKey; + this.userId = userId; + this.username = username; + } + + public void decode(ByteBuffer data) { + if (!super.decode(data, CRC)) + return; + int sessionKeyLength = getInt(data); + if (sessionKeyLength > data.remaining()) + return; + sessionKey = new byte[sessionKeyLength]; + data.get(sessionKey); + userId = getInt(data); + username = getAscii(data); + } + + public ByteBuffer encode() { + int length = 16 + sessionKey.length + username.length(); + ByteBuffer data = ByteBuffer.allocate(length); + addShort(data, 4); + addInt( data, CRC); + addInt( data, sessionKey.length); + data.put(sessionKey); + addInt( data, userId); + addAscii(data, username); + return data; + } + + public byte [] getSessionKey() { + return sessionKey; + } + + public int getUserId() { + return userId; + } + + public String getUsername() { + return username; + } + +} diff --git a/src/network/packets/swg/login/LoginClusterStatus.java b/src/network/packets/swg/login/LoginClusterStatus.java new file mode 100644 index 000000000..70350c022 --- /dev/null +++ b/src/network/packets/swg/login/LoginClusterStatus.java @@ -0,0 +1,84 @@ +package network.packets.swg.login; + +import java.nio.ByteBuffer; +import java.util.List; +import java.util.Vector; + +import network.packets.swg.SWGPacket; +import resources.Galaxy; + + +public class LoginClusterStatus extends SWGPacket { + + public static final int CRC = 0x3436AEB6; + + private Vector galaxies; + + public LoginClusterStatus() { + galaxies = new Vector(); + } + + public void decode(ByteBuffer data) { + if (!super.decode(data, CRC)) + return; + int serverCount = getInt(data); + for (int i = 0; i < serverCount; i++) { + Galaxy g = new Galaxy(); + g.setId(getInt(data)); + g.setAddress(getAscii(data)); + getInt(data); // Server Port and Ping Port (blah!) + getInt(data); // Spacer of some kind.. always 0xFFFFFFFF + g.setPopulation(getInt(data)); + g.setMaxCharacters(getInt(data)); + g.setDistance(getInt(data)); + g.setStatus(getInt(data)); + g.setRecommended(getBoolean(data)); + getInt(data); + getInt(data); + galaxies.add(g); + } + } + + public ByteBuffer encode() { + int length = 10; + for (Galaxy g : galaxies) + length += 35 + g.getAddress().length() + 8; + ByteBuffer data = ByteBuffer.allocate(length); + addShort(data, 2); + addInt( data, CRC); + addInt( data, galaxies.size()); + for (Galaxy g : galaxies) { + addInt( data, g.getId()); + addAscii( data, g.getAddress()); + addShort( data, 44463); + addShort( data, 44462); + addInt( data, g.getPopulation()); + //addInt( data, 0xFFFFFFFF); + /* + * Very Light = 0 + * Light = 300 + * Medium = 600 + * Heavy = 900 + * Very Heavy = 1200 + * Extreamly Heavy = 1500 + * Full = 3000 + */ + addInt( data, 0); // Very Light + addInt( data, g.getMaxCharacters()); + addInt( data, g.getDistance()); + addInt( data, g.getStatus()); + addBoolean(data, g.isRecommended()); + data.put(new byte[] { (byte)0xC4, 0x09, 0, 0, (byte)0xFA, 0, 0, 0}); + } + return data; + } + + public void addGalaxy(Galaxy g) { + galaxies.add(g); + } + + public List getGalaxies() { + return galaxies; + } + +} diff --git a/src/network/packets/swg/login/LoginEnumCluster.java b/src/network/packets/swg/login/LoginEnumCluster.java new file mode 100644 index 000000000..b1f737646 --- /dev/null +++ b/src/network/packets/swg/login/LoginEnumCluster.java @@ -0,0 +1,70 @@ +package network.packets.swg.login; + +import java.nio.ByteBuffer; +import java.util.List; +import java.util.Vector; + +import network.packets.swg.SWGPacket; +import resources.Galaxy; + + +public class LoginEnumCluster extends SWGPacket { + + public static final int CRC = 0xC11C63B9; + + private Vector galaxies; + private int maxCharacters; + + public LoginEnumCluster() { + galaxies = new Vector(); + } + + public LoginEnumCluster(int maxCharacters) { + galaxies = new Vector(); + this.maxCharacters = maxCharacters; + } + + public void decode(ByteBuffer data) { + if (!super.decode(data, CRC)) + return; + int serverCount = getInt(data); + for (int i = 0; i < serverCount; i++) { + int id = getInt(data); + String name = getAscii(data); + int distance = getInt(data); // Distance - UNUSED + Galaxy g = new Galaxy(id, name, "127.0.0.1", 0, 0, distance, 2); + galaxies.add(g); + } + maxCharacters = getInt(data); + } + + public ByteBuffer encode() { + int length = 14; + for (Galaxy g : galaxies) + length += 10 + g.getName().length(); + ByteBuffer data = ByteBuffer.allocate(length); + addShort(data, 3); + addInt( data, CRC); + addInt( data, galaxies.size()); + for (Galaxy g : galaxies) { + addInt( data, g.getId()); + addAscii(data, g.getName()); + //addInt( data, g.getDistance()); + addInt( data, 0xFFFF8F80); + } + addInt(data, maxCharacters); + return data; + } + + public void addGalaxy(Galaxy g) { + galaxies.add(g); + } + + public int getMaxCharacters() { + return maxCharacters; + } + + public List getGalaxies() { + return galaxies; + } +} diff --git a/src/network/packets/swg/login/OfflineServersMessage.java b/src/network/packets/swg/login/OfflineServersMessage.java new file mode 100644 index 000000000..25a82439b --- /dev/null +++ b/src/network/packets/swg/login/OfflineServersMessage.java @@ -0,0 +1,60 @@ +package network.packets.swg.login; + +import java.nio.ByteBuffer; +import java.util.ArrayList; +import java.util.List; + +import network.packets.swg.SWGPacket; + +public class OfflineServersMessage extends SWGPacket { + + public static final int CRC = 0xF41A5265; + + private List offlineServers; + + public OfflineServersMessage() { + offlineServers = new ArrayList(); + } + + public OfflineServersMessage(List offline) { + this.offlineServers = offline; + } + + public OfflineServersMessage(ByteBuffer data) { + decode(data); + } + + public void decode(ByteBuffer data) { + if (!super.decode(data, CRC)) + return; + int listCount = getInt(data); + offlineServers = new ArrayList(listCount); + for (int i = 0 ; i < listCount; i++) + offlineServers.add(getAscii(data)); + } + + public ByteBuffer encode() { + int strLength = 0; + for (String str : offlineServers) + strLength += 2 + str.length(); + ByteBuffer data = ByteBuffer.allocate(10 + strLength); + addShort(data, 2); + addInt( data, CRC); + for (String str : offlineServers) + addAscii(data, str); + return data; + } + + public List getOfflineServers() { + return offlineServers; + } + + public void setOfflineServers(List offline) { + offlineServers = offline; + } + + public void addOflineServer(String offline) { + offlineServers.add(offline); + } + +} diff --git a/src/network/packets/swg/login/RequestExtendedClusters.java b/src/network/packets/swg/login/RequestExtendedClusters.java new file mode 100644 index 000000000..4655c05fc --- /dev/null +++ b/src/network/packets/swg/login/RequestExtendedClusters.java @@ -0,0 +1,28 @@ +package network.packets.swg.login; + +import java.nio.ByteBuffer; + +import network.packets.swg.SWGPacket; + + +public class RequestExtendedClusters extends SWGPacket { + + public static final int CRC = 0x8E33ED05; + + public RequestExtendedClusters() { + + } + + public void decode(ByteBuffer data) { + if (!super.decode(data, CRC)) + return; + } + + public ByteBuffer encode() { + ByteBuffer data = ByteBuffer.allocate(10); + addShort(data, 2); + addInt( data, CRC); + addInt( data, 0); + return data; + } +} diff --git a/src/network/packets/swg/login/ServerId.java b/src/network/packets/swg/login/ServerId.java new file mode 100644 index 000000000..7875cb4cf --- /dev/null +++ b/src/network/packets/swg/login/ServerId.java @@ -0,0 +1,39 @@ +package network.packets.swg.login; + +import java.nio.ByteBuffer; + +import network.packets.swg.SWGPacket; + + +public class ServerId extends SWGPacket { + + public static final int CRC = 0x58C07F21; + private int serverId = 0; + + public ServerId() { + + } + + public ServerId(int id) { + this.serverId = id; + } + + public void decode(ByteBuffer data) { + if (!super.decode(data, CRC)) + return; + serverId = getInt(data); + } + + public ByteBuffer encode() { + ByteBuffer data = ByteBuffer.allocate(10); + addShort(data, 2); + addInt( data, CRC); + addInt( data, serverId); + return data; + } + + public int getServerId() { + return serverId; + } + +} diff --git a/src/network/packets/swg/login/ServerString.java b/src/network/packets/swg/login/ServerString.java new file mode 100644 index 000000000..0f14cea44 --- /dev/null +++ b/src/network/packets/swg/login/ServerString.java @@ -0,0 +1,39 @@ +package network.packets.swg.login; + +import java.nio.ByteBuffer; + +import network.packets.swg.SWGPacket; + + +public class ServerString extends SWGPacket { + + public static final int CRC = 0x0E20D7E9; + private String serverName = ""; + + public ServerString() { + + } + + public ServerString(String name) { + this.serverName = name; + } + + public void decode(ByteBuffer data) { + if (!super.decode(data, CRC)) + return; + serverName = getAscii(data); + } + + public ByteBuffer encode() { + ByteBuffer data = ByteBuffer.allocate(8 + serverName.length()); + addShort(data, 2); + addInt( data, CRC); + addAscii(data, serverName); + return data; + } + + public String getServerString() { + return serverName; + } + +} diff --git a/src/network/packets/swg/login/StationIdHasJediSlot.java b/src/network/packets/swg/login/StationIdHasJediSlot.java new file mode 100644 index 000000000..3a0d5668d --- /dev/null +++ b/src/network/packets/swg/login/StationIdHasJediSlot.java @@ -0,0 +1,40 @@ +package network.packets.swg.login; + +import java.nio.ByteBuffer; + +import network.packets.swg.SWGPacket; + + +public class StationIdHasJediSlot extends SWGPacket { + + public static final int CRC = 0xCC9FCCF8; + + private int jedi; + + public StationIdHasJediSlot() { + this.jedi = 1; + } + + public StationIdHasJediSlot(int jedi) { + this.jedi = jedi; + } + + public void decode(ByteBuffer data) { + if (!super.decode(data, CRC)) + return; + jedi = getInt(data); + } + + public ByteBuffer encode() { + ByteBuffer data = ByteBuffer.allocate(10); + addShort(data, 2); + addInt( data, CRC); + addInt( data, jedi); + return data; + } + + public int getJediSlot() { + return jedi; + } + +} diff --git a/src/network/packets/swg/login/creation/ApproveNameRequest.java b/src/network/packets/swg/login/creation/ApproveNameRequest.java new file mode 100644 index 000000000..d94835b0b --- /dev/null +++ b/src/network/packets/swg/login/creation/ApproveNameRequest.java @@ -0,0 +1,41 @@ +package network.packets.swg.login.creation; + +import java.nio.ByteBuffer; + +import network.packets.swg.SWGPacket; + + +public class ApproveNameRequest extends SWGPacket { + + public static final int CRC = 0x9EB04B9F; + private String race = ""; + private String name = ""; + + public ApproveNameRequest() { + + } + + public ApproveNameRequest(String race, String name) { + this.race = race; + this.name = name; + } + + public void decode(ByteBuffer data) { + if (!super.decode(data, CRC)) + return; + race = getAscii(data); + name = getUnicode(data); + } + + public ByteBuffer encode() { + ByteBuffer data = ByteBuffer.allocate(10 + race.length() + name.length() * 2); + addShort( data, 4); + addInt( data, CRC); + addAscii( data, race); + addUnicode(data, name); + return data; + } + + public String getRace() { return race; } + public String getName() { return name; } +} diff --git a/src/network/packets/swg/login/creation/ApproveNameResponse.java b/src/network/packets/swg/login/creation/ApproveNameResponse.java new file mode 100644 index 000000000..708935615 --- /dev/null +++ b/src/network/packets/swg/login/creation/ApproveNameResponse.java @@ -0,0 +1,38 @@ +package network.packets.swg.login.creation; + +import java.nio.ByteBuffer; + +import network.packets.swg.SWGPacket; + + +public class ApproveNameResponse extends SWGPacket { + + public static final int CRC = 0x9B2C6BA7; + private String name = ""; + + public ApproveNameResponse() { + + } + + public ApproveNameResponse(String name) { + this.name = name; + } + + public void decode(ByteBuffer data) { + if (!super.decode(data, CRC)) + return; + name = getUnicode(data); + } + + public ByteBuffer encode() { + ByteBuffer data = ByteBuffer.allocate(33 + name.length() * 2); + addShort( data, 9); + addInt( data, CRC); + addUnicode(data, name); + addAscii( data, "ui"); + addInt( data, 0); + addAscii( data, "name_approved"); + return data; + } + +} diff --git a/src/network/packets/swg/login/creation/ClientCreateCharacter.java b/src/network/packets/swg/login/creation/ClientCreateCharacter.java new file mode 100644 index 000000000..fd8b852f8 --- /dev/null +++ b/src/network/packets/swg/login/creation/ClientCreateCharacter.java @@ -0,0 +1,96 @@ +package network.packets.swg.login.creation; + +import java.nio.ByteBuffer; + +import network.packets.swg.SWGPacket; + + +public class ClientCreateCharacter extends SWGPacket { + + public static final int CRC = 0xB97F3074; + private byte [] charCustomization = new byte[0]; + private String name = ""; + private String race = ""; + private String start = ""; + private String hair = ""; + private byte [] hairCustomization = new byte[0]; + private String clothes = ""; + private float height = 0; + private boolean tutorial = false; + private String profession = ""; + private String startingPhase = ""; + + public ClientCreateCharacter() { + + } + + public void decode(ByteBuffer data) { + if (!super.decode(data, CRC)) + return; + charCustomization = getArray(data); + name = getUnicode(data); + race = getAscii(data); + start = getAscii(data); + hair = getAscii(data); + hairCustomization = getArray(data); + clothes = getAscii(data); + byte b = getByte(data); + height = getFloat(data); + String str = getUnicode(data); + tutorial = getBoolean(data); + profession = getAscii(data); + startingPhase = getAscii(data); + } + + public ByteBuffer encode() { + int extraSize = charCustomization.length; + extraSize += name.length()*2; + extraSize += race.length() + start.length(); + extraSize += hair.length() + hairCustomization.length; + extraSize += clothes.length() + profession.length(); + extraSize += startingPhase.length(); + ByteBuffer data = ByteBuffer.allocate(36+extraSize); + addShort(data, 2); + addInt (data, CRC); + addArray(data, charCustomization); + addUnicode(data, name); + addAscii(data, race); + addAscii(data, start); + addAscii(data, hair); + addArray(data, hairCustomization); + addAscii(data, clothes); + addByte (data, 0); + addFloat(data, height); + addUnicode(data, ""); + addBoolean(data, tutorial); + addAscii (data, profession); + addAscii (data, startingPhase); + return data; + } + + public byte [] getCharCustomization() { return charCustomization; } + public String getName() { return name; } + public String getRace() { return race; } + public String getStartLocation() { return start; } + public String getHair() { return hair; } + public byte [] getHairCustomization() { return hairCustomization; } + public String getClothes() { return clothes; } + public float getHeight() { return height; } + public boolean isTutorial() { return tutorial; } + public String getProfession() { return profession; } + public String getStartingPhase() { return startingPhase; } + + public void setCharCustomization(byte [] data) { this.charCustomization = data; } + public void setName(String name) { this.name = name; } + public String getStart() { return start; } + public void setStart(String start) { this.start = start; } + public void setRace(String race) { this.race = race; } + public void setHair(String hair) { this.hair = hair; } + public void setHairCustomization(byte [] hairCustomization) { this.hairCustomization = hairCustomization; } + public void setClothes(String clothes) { this.clothes = clothes; } + public void setHeight(float height) { this.height = height; } + public void setTutorial(boolean tutorial) { this.tutorial = tutorial; } + public void setProfession(String profession) { this.profession = profession; } + public void setStartingPhase(String startingPhase) { this.startingPhase = startingPhase; } + +} diff --git a/src/network/packets/swg/login/creation/CreateCharacterFailure.java b/src/network/packets/swg/login/creation/CreateCharacterFailure.java new file mode 100644 index 000000000..add4a1ad3 --- /dev/null +++ b/src/network/packets/swg/login/creation/CreateCharacterFailure.java @@ -0,0 +1,60 @@ +package network.packets.swg.login.creation; + +import java.nio.ByteBuffer; + +import network.packets.swg.SWGPacket; + + +public class CreateCharacterFailure extends SWGPacket { + + public static final int CRC = 0xDF333C6E; + private NameFailureReason reason; + + public CreateCharacterFailure() { + reason = NameFailureReason.NAME_RETRY; + } + + public CreateCharacterFailure(NameFailureReason reason) { + this.reason = reason; + } + + public void decode(ByteBuffer data) { + + } + + public ByteBuffer encode() { + String errorString = nameFailureTranslation(reason); + ByteBuffer data = ByteBuffer.allocate(20 + errorString.length()); + addShort( data, 3); + addInt( data, CRC); + addUnicode(data, ""); + addAscii( data, "ui"); + addInt( data, 0); + addAscii( data, errorString); + return data; + } + + private String nameFailureTranslation(NameFailureReason reason) { + switch (reason) { + case NAME_DECLINED_EMPTY: + return "name_declined_empty"; + case NAME_IN_USE: + return "name_declined_in_use"; + case NAME_RETRY: + return "name_declined_retry"; + case NAME_SYNTAX: + return "name_declined_syntax"; + case NAME_TOO_FAST: + return "name_declined_too_fast"; + } + return "name_declined_retry"; + } + + public enum NameFailureReason { + NAME_DECLINED_EMPTY, + NAME_TOO_FAST, + NAME_RETRY, + NAME_SYNTAX, + NAME_IN_USE + } +} diff --git a/src/network/packets/swg/login/creation/CreateCharacterSuccess.java b/src/network/packets/swg/login/creation/CreateCharacterSuccess.java new file mode 100644 index 000000000..f46d878cd --- /dev/null +++ b/src/network/packets/swg/login/creation/CreateCharacterSuccess.java @@ -0,0 +1,37 @@ +package network.packets.swg.login.creation; + +import java.nio.ByteBuffer; + +import network.packets.swg.SWGPacket; + + +public class CreateCharacterSuccess extends SWGPacket { + + public static final int CRC = 0x1DB575CC; + private long id = 0; + + public CreateCharacterSuccess() { + + } + + public CreateCharacterSuccess(long charId) { + this.id = charId; + } + + public void decode(ByteBuffer data) { + if (!super.decode(data, CRC)) + return; + id = getLong(data); + } + + public ByteBuffer encode() { + ByteBuffer data = ByteBuffer.allocate(14); + addShort(data, 2); + addInt( data, CRC); + addLong( data, id); + return data; + } + + public long getId() { return id; } + public void setId(long id) { this.id = id; } +} diff --git a/src/network/packets/swg/login/creation/DeleteCharacterRequest.java b/src/network/packets/swg/login/creation/DeleteCharacterRequest.java new file mode 100644 index 000000000..336548dcd --- /dev/null +++ b/src/network/packets/swg/login/creation/DeleteCharacterRequest.java @@ -0,0 +1,41 @@ +package network.packets.swg.login.creation; + +import java.nio.ByteBuffer; + +import network.packets.swg.SWGPacket; + + +public class DeleteCharacterRequest extends SWGPacket { + + public static final int CRC = 0xE87AD031; + private int serverId = 0; + private long playerId = 0; + + public DeleteCharacterRequest() { + + } + + public DeleteCharacterRequest(int serverId, long playerId) { + this.serverId = serverId; + this.playerId = playerId; + } + + public void decode(ByteBuffer data) { + if (!super.decode(data, CRC)) + return; + serverId = getInt(data); + playerId = getLong(data); + } + + public ByteBuffer encode() { + ByteBuffer data = ByteBuffer.allocate(18); + addShort(data, 3); + addInt( data, CRC); + addInt( data, serverId); + addLong( data, playerId); + return data; + } + + public int getServerId() { return serverId; } + public long getPlayerId() { return playerId; } +} diff --git a/src/network/packets/swg/login/creation/DeleteCharacterResponse.java b/src/network/packets/swg/login/creation/DeleteCharacterResponse.java new file mode 100644 index 000000000..95d371aef --- /dev/null +++ b/src/network/packets/swg/login/creation/DeleteCharacterResponse.java @@ -0,0 +1,34 @@ +package network.packets.swg.login.creation; + +import java.nio.ByteBuffer; + +import network.packets.swg.SWGPacket; + + +public class DeleteCharacterResponse extends SWGPacket { + + public static final int CRC = 0x8268989B; + private boolean deleted = true; + + public DeleteCharacterResponse() { + + } + + public DeleteCharacterResponse(boolean deleted) { + this.deleted = deleted; + } + + public void decode(ByteBuffer data) { + if (!super.decode(data, CRC)) + return; + deleted = getInt(data) == 0; + } + + public ByteBuffer encode() { + ByteBuffer data = ByteBuffer.allocate(10); + addShort(data, 2); + addInt( data, CRC); + addInt( data, deleted ? 0 : 1); + return data; + } +} diff --git a/src/network/packets/swg/login/creation/RandomNameRequest.java b/src/network/packets/swg/login/creation/RandomNameRequest.java new file mode 100644 index 000000000..659ca5e1b --- /dev/null +++ b/src/network/packets/swg/login/creation/RandomNameRequest.java @@ -0,0 +1,32 @@ +package network.packets.swg.login.creation; + +import java.nio.ByteBuffer; + +import network.packets.swg.SWGPacket; + + +public class RandomNameRequest extends SWGPacket { + + public static final int CRC = 0xD6D1B6D1; + private String raceCrc = "object/creature/player/human_male.iff"; + + public RandomNameRequest() { + + } + + public void decode(ByteBuffer data) { + if (!super.decode(data, CRC)) + return; + raceCrc = getAscii(data); + } + + public ByteBuffer encode() { + ByteBuffer data = ByteBuffer.allocate(8 + raceCrc.length()); + addShort(data, 2); + addInt( data, CRC); + addAscii(data, raceCrc); + return data; + } + + public String getRace() { return raceCrc; } +} diff --git a/src/network/packets/swg/login/creation/RandomNameResponse.java b/src/network/packets/swg/login/creation/RandomNameResponse.java new file mode 100644 index 000000000..d7ef625ba --- /dev/null +++ b/src/network/packets/swg/login/creation/RandomNameResponse.java @@ -0,0 +1,47 @@ +package network.packets.swg.login.creation; + +import java.nio.ByteBuffer; + +import network.packets.swg.SWGPacket; + + +public class RandomNameResponse extends SWGPacket { + + public static final int CRC = 0xE85FB868; + + private String race; + private String randomName; + + public RandomNameResponse() { + this.race = "object/creature/player/human_male.iff"; + this.randomName = ""; + } + + public RandomNameResponse(String race, String randomName) { + this.race = race; + this.randomName = randomName; + } + + public void decode(ByteBuffer data) { + if (!super.decode(data, CRC)) + return; + race = getAscii(data); + randomName = getUnicode(data); + getAscii(data); + getInt(data); + getAscii(data); + } + + public ByteBuffer encode() { + int length = 35 + race.length() + randomName.length() * 2; + ByteBuffer data = ByteBuffer.allocate(length); + addShort( data, 4); + addInt( data, CRC); + addAscii( data, race); + addUnicode(data, randomName); + addAscii( data, "ui"); + addInt( data, 0); + addAscii( data, "name_approved"); + return data; + } +} diff --git a/src/network/packets/swg/zone/ChatRequestRoomList.java b/src/network/packets/swg/zone/ChatRequestRoomList.java new file mode 100644 index 000000000..e98f164d3 --- /dev/null +++ b/src/network/packets/swg/zone/ChatRequestRoomList.java @@ -0,0 +1,27 @@ +package network.packets.swg.zone; + +import java.nio.ByteBuffer; + +import network.packets.swg.SWGPacket; + +public class ChatRequestRoomList extends SWGPacket { + + public static final int CRC = 0x4C3D2CFA; + + public ChatRequestRoomList() { + + } + + public void decode(ByteBuffer data) { + if (!super.decode(data, CRC)) + return; + } + + public ByteBuffer encode() { + int length = 6; + ByteBuffer data = ByteBuffer.allocate(length); + addShort(data, 1); + addInt( data, CRC); + return data; + } +} diff --git a/src/network/packets/swg/zone/CmdSceneReady.java b/src/network/packets/swg/zone/CmdSceneReady.java new file mode 100644 index 000000000..232af3eca --- /dev/null +++ b/src/network/packets/swg/zone/CmdSceneReady.java @@ -0,0 +1,27 @@ +package network.packets.swg.zone; + +import java.nio.ByteBuffer; + +import network.packets.swg.SWGPacket; + +public class CmdSceneReady extends SWGPacket { + + public static final int CRC = 0x43FD1C22; + + public CmdSceneReady() { + + } + + public void decode(ByteBuffer data) { + if (!super.decode(data, CRC)) + return; + } + + public ByteBuffer encode() { + int length = 6; + ByteBuffer data = ByteBuffer.allocate(length); + addShort(data, 1); + addInt( data, CRC); + return data; + } +} diff --git a/src/network/packets/swg/zone/ConnectPlayerResponseMessage.java b/src/network/packets/swg/zone/ConnectPlayerResponseMessage.java new file mode 100644 index 000000000..9c6c61dbc --- /dev/null +++ b/src/network/packets/swg/zone/ConnectPlayerResponseMessage.java @@ -0,0 +1,33 @@ +package network.packets.swg.zone; + +import java.nio.ByteBuffer; + +import network.packets.swg.SWGPacket; + +public class ConnectPlayerResponseMessage extends SWGPacket { + + public static final int CRC = 0x6137556F; + + public ConnectPlayerResponseMessage() { + + } + + public ConnectPlayerResponseMessage(ByteBuffer data) { + decode(data); + } + + public void decode(ByteBuffer data) { + if (!super.decode(data, CRC)) + return; + getInt(data); + } + + public ByteBuffer encode() { + ByteBuffer data = ByteBuffer.allocate(10); + addShort(data, 2); + addInt (data, CRC); + addInt (data, 0); + return data; + } + +} diff --git a/src/network/packets/swg/zone/GalaxyLoopTimesRequest.java b/src/network/packets/swg/zone/GalaxyLoopTimesRequest.java new file mode 100644 index 000000000..bfaa2512a --- /dev/null +++ b/src/network/packets/swg/zone/GalaxyLoopTimesRequest.java @@ -0,0 +1,27 @@ +package network.packets.swg.zone; + +import java.nio.ByteBuffer; + +import network.packets.swg.SWGPacket; + +public class GalaxyLoopTimesRequest extends SWGPacket { + + public static final int CRC = 0x7D842D68; + + public GalaxyLoopTimesRequest() { + + } + + public void decode(ByteBuffer data) { + if (!super.decode(data, CRC)) + return; + } + + public ByteBuffer encode() { + int length = 6; + ByteBuffer data = ByteBuffer.allocate(length); + addShort(data, 1); + addInt( data, CRC); + return data; + } +} diff --git a/src/network/packets/swg/zone/GalaxyLoopTimesResponse.java b/src/network/packets/swg/zone/GalaxyLoopTimesResponse.java new file mode 100644 index 000000000..cd7f054c3 --- /dev/null +++ b/src/network/packets/swg/zone/GalaxyLoopTimesResponse.java @@ -0,0 +1,34 @@ +package network.packets.swg.zone; + +import java.nio.ByteBuffer; + +import network.packets.swg.SWGPacket; + +public class GalaxyLoopTimesResponse extends SWGPacket { + + public static final int CRC = 0x4E428088; + private long time = 0; + + public GalaxyLoopTimesResponse() { + + } + + public GalaxyLoopTimesResponse(long time) { + this.time = time; + } + + public void decode(ByteBuffer data) { + if (!super.decode(data, CRC)) + return; + time = getLong(data); + } + + public ByteBuffer encode() { + int length = 14; + ByteBuffer data = ByteBuffer.allocate(length); + addShort(data, 3); + addInt( data, CRC); + addLong( data, time); + return data; + } +} diff --git a/src/network/packets/swg/zone/HeartBeatMessage.java b/src/network/packets/swg/zone/HeartBeatMessage.java new file mode 100644 index 000000000..c91db59c7 --- /dev/null +++ b/src/network/packets/swg/zone/HeartBeatMessage.java @@ -0,0 +1,28 @@ +package network.packets.swg.zone; + +import java.nio.ByteBuffer; + +import network.packets.swg.SWGPacket; + +public class HeartBeatMessage extends SWGPacket { + + public static final int CRC = 0xA16CF9AF; + + public HeartBeatMessage() { + + } + + public void decode(ByteBuffer data) { + if (!super.decode(data, CRC)) + return; + } + + public ByteBuffer encode() { + int length = 10; + ByteBuffer data = ByteBuffer.allocate(length); + addShort(data, 1); + addInt( data, CRC); + addInt( data, 0); + return data; + } +} diff --git a/src/network/packets/swg/zone/OpenedContainerMessage.java b/src/network/packets/swg/zone/OpenedContainerMessage.java new file mode 100644 index 000000000..2e91fdadd --- /dev/null +++ b/src/network/packets/swg/zone/OpenedContainerMessage.java @@ -0,0 +1,43 @@ +package network.packets.swg.zone; + +import java.nio.ByteBuffer; + +import network.packets.swg.SWGPacket; + +public class OpenedContainerMessage extends SWGPacket { + + public static final int CRC = 0x2E11E4AB; + + private long containerId; + + public OpenedContainerMessage() { + this(0); + } + + public OpenedContainerMessage(long containerId) { + this.containerId = 0; + } + + public OpenedContainerMessage(ByteBuffer data) { + decode(data); + } + + public void decode(ByteBuffer data) { + if (!super.decode(data, CRC)) + return; + getInt(data); // 0? + containerId = getLong(data); + getShort(data); // 0? + } + + public ByteBuffer encode() { + ByteBuffer data = ByteBuffer.allocate(20); + addShort(data, 2); + addInt (data, CRC); + addInt (data, 0); + addLong (data, containerId); + addShort(data, 0); + return data; + } + +} diff --git a/src/network/packets/swg/zone/ParametersMessage.java b/src/network/packets/swg/zone/ParametersMessage.java new file mode 100644 index 000000000..93876f6a1 --- /dev/null +++ b/src/network/packets/swg/zone/ParametersMessage.java @@ -0,0 +1,29 @@ +package network.packets.swg.zone; + +import java.nio.ByteBuffer; + +import network.packets.swg.SWGPacket; + +public class ParametersMessage extends SWGPacket { + + public static final int CRC = 0x487652DA; + + public ParametersMessage() { + + } + + public void decode(ByteBuffer data) { + if (!super.decode(data, CRC)) + return; + getInt(data); + } + + public ByteBuffer encode() { + int length = 14; + ByteBuffer data = ByteBuffer.allocate(length); + addShort(data, 2); + addInt( data, CRC); + addInt( data, 900); + return data; + } +} diff --git a/src/network/packets/swg/zone/SceneCreateObjectByCrc.java b/src/network/packets/swg/zone/SceneCreateObjectByCrc.java new file mode 100644 index 000000000..8092efae6 --- /dev/null +++ b/src/network/packets/swg/zone/SceneCreateObjectByCrc.java @@ -0,0 +1,61 @@ +package network.packets.swg.zone; + +import java.nio.ByteBuffer; + +import network.packets.swg.SWGPacket; +import resources.Location; + +public class SceneCreateObjectByCrc extends SWGPacket { + + public static final int CRC = 0xFE89DDEA; + private long objId = 0; + private Location l = new Location(); + private int objCrc = 0; + + public SceneCreateObjectByCrc() { + + } + + public SceneCreateObjectByCrc(long objId, Location l, int objCrc) { + this.objId = objId; + this.l = l; + this.objCrc = objCrc; + } + + public void decode(ByteBuffer data) { + if (!super.decode(data, CRC)) + return; + objId = getLong(data); + l.setOrientationX(getFloat(data)); + l.setOrientationY(getFloat(data)); + l.setOrientationZ(getFloat(data)); + l.setOrientationW(getFloat(data)); + l.setX(getFloat(data)); + l.setZ(getFloat(data)); + l.setY(getFloat(data)); + objCrc = getInt(data); + getByte(data); // Unknown Byte + } + + public ByteBuffer encode() { + int length = 47; + ByteBuffer data = ByteBuffer.allocate(length); + addShort(data, 5); + addInt( data, CRC); + addLong( data, objId); + addFloat(data, l.getOrientationX()); + addFloat(data, l.getOrientationY()); + addFloat(data, l.getOrientationZ()); + addFloat(data, l.getOrientationW()); + addFloat(data, l.getX()); + addFloat(data, l.getY()); + addFloat(data, l.getZ()); + addInt( data, objCrc); + addByte( data, 0); // Unknown Byte + return data; + } + + public long getObjectId() { return objId; } + public Location getLocation() { return l; } + public int getObjectCrc() { return objCrc; } +} diff --git a/src/network/packets/swg/zone/SceneDestroyObject.java b/src/network/packets/swg/zone/SceneDestroyObject.java new file mode 100644 index 000000000..b09ffd4ce --- /dev/null +++ b/src/network/packets/swg/zone/SceneDestroyObject.java @@ -0,0 +1,44 @@ +package network.packets.swg.zone; + +import java.nio.ByteBuffer; + +import network.packets.swg.SWGPacket; + +public class SceneDestroyObject extends SWGPacket { + + public static final int CRC = 0x4D45D504; + + private long objId; + + public SceneDestroyObject() { + this(0); + } + + public SceneDestroyObject(long objId) { + + } + + public SceneDestroyObject(ByteBuffer data) { + decode(data); + } + + public void decode(ByteBuffer data) { + if (!super.decode(data, CRC)) + return; + objId = getLong(data); + getByte(data); + } + + public ByteBuffer encode() { + ByteBuffer data = ByteBuffer.allocate(14); + addShort(data, 3); + addInt (data, CRC); + addLong (data, objId); + addByte (data, 0); + return data; + } + + public long getObjectId() { return objId; } + public void setObjectId(long objId) { this.objId = objId; } + +} diff --git a/src/network/packets/swg/zone/SceneEndBaselines.java b/src/network/packets/swg/zone/SceneEndBaselines.java new file mode 100644 index 000000000..454b03761 --- /dev/null +++ b/src/network/packets/swg/zone/SceneEndBaselines.java @@ -0,0 +1,37 @@ +package network.packets.swg.zone; + +import java.nio.ByteBuffer; + +import network.packets.swg.SWGPacket; + +public class SceneEndBaselines extends SWGPacket { + + public static final int CRC = 0x2C436037; + private long objId = 0; + + public SceneEndBaselines() { + + } + + public SceneEndBaselines(long objId) { + this.objId = objId; + } + + public void decode(ByteBuffer data) { + if (!super.decode(data, CRC)) + return; + objId = getLong(data); + } + + public ByteBuffer encode() { + int length = 14; + ByteBuffer data = ByteBuffer.allocate(length); + addShort(data, 2); + addInt( data, CRC); + addLong( data, objId); + return data; + } + + public long getObjectId() { return objId; } + +} diff --git a/src/network/packets/swg/zone/ServerTimeMessage.java b/src/network/packets/swg/zone/ServerTimeMessage.java new file mode 100644 index 000000000..1b841b721 --- /dev/null +++ b/src/network/packets/swg/zone/ServerTimeMessage.java @@ -0,0 +1,38 @@ +package network.packets.swg.zone; + +import java.nio.ByteBuffer; + +import network.packets.swg.SWGPacket; + +public class ServerTimeMessage extends SWGPacket { + + public static final int CRC = 0x2EBC3BD9; + + private long time = 0; + + public ServerTimeMessage() { + + } + + public ServerTimeMessage(long time) { + this.time = time; + } + + public void decode(ByteBuffer data) { + if (!super.decode(data, CRC)) + return; + time = getLong(data); + } + + public ByteBuffer encode() { + ByteBuffer data = ByteBuffer.allocate(14); + addShort(data, 2); + addInt( data, CRC); + addLong( data, time); + return data; + } + + public long getTime() { + return time; + } +} diff --git a/src/network/packets/swg/zone/UpdateContainmentMessage.java b/src/network/packets/swg/zone/UpdateContainmentMessage.java new file mode 100644 index 000000000..0687feba4 --- /dev/null +++ b/src/network/packets/swg/zone/UpdateContainmentMessage.java @@ -0,0 +1,47 @@ +package network.packets.swg.zone; + +import java.nio.ByteBuffer; + +import network.packets.swg.SWGPacket; + +public class UpdateContainmentMessage extends SWGPacket { + + public static final int CRC = 0x56CBDE9E; + + private long containerId = 0; + private long objectId = 0; + private int slotIndex = 0; + + public UpdateContainmentMessage() { + + } + + public UpdateContainmentMessage(long objectId, long containerId, int slotIndex) { + this.objectId = objectId; + this.containerId = containerId; + this.slotIndex = slotIndex; + } + + public void decode(ByteBuffer data) { + if (!super.decode(data, CRC)) + return; + objectId = getLong(data); + containerId = getLong(data); + slotIndex = getInt(data); + } + + public ByteBuffer encode() { + int length = 26; + ByteBuffer data = ByteBuffer.allocate(length); + addShort(data, 4); + addInt( data, CRC); + addLong( data, objectId); + addLong( data, containerId); + addInt( data, slotIndex); + return data; + } + + public long getObjectId() { return objectId; } + public long getContainerId() { return containerId; } + public int getSlotIndex() { return slotIndex; } +} diff --git a/src/network/packets/swg/zone/UpdatePostureMessage.java b/src/network/packets/swg/zone/UpdatePostureMessage.java new file mode 100644 index 000000000..cf442b911 --- /dev/null +++ b/src/network/packets/swg/zone/UpdatePostureMessage.java @@ -0,0 +1,44 @@ +package network.packets.swg.zone; + +import java.nio.ByteBuffer; + +import network.packets.swg.SWGPacket; +import resources.Posture; + +public class UpdatePostureMessage extends SWGPacket { + + public static final int CRC = 0x00BDE6B41; + private int posture = 0; + private long objId = 0; + + public UpdatePostureMessage() { + + } + + public UpdatePostureMessage(Posture posture, long objId) { + this.posture = posture.getId(); + this.objId = objId; + } + + public UpdatePostureMessage(int posture, long objId) { + this.posture = posture; + this.objId = objId; + } + + public void decode(ByteBuffer data) { + if (!super.decode(data, CRC)) + return; + posture = getByte(data); + objId = getLong(data); + } + + public ByteBuffer encode() { + int length = 16; + ByteBuffer data = ByteBuffer.allocate(length); + addShort(data, 3); + addInt (data, CRC); + addByte (data, posture); + addLong (data, objId); + return data; + } +} diff --git a/src/network/packets/swg/zone/UpdatePvpStatusMessage.java b/src/network/packets/swg/zone/UpdatePvpStatusMessage.java new file mode 100644 index 000000000..13667bac3 --- /dev/null +++ b/src/network/packets/swg/zone/UpdatePvpStatusMessage.java @@ -0,0 +1,47 @@ +package network.packets.swg.zone; + +import java.nio.ByteBuffer; + +import network.packets.swg.SWGPacket; + +public class UpdatePvpStatusMessage extends SWGPacket { + + public static final int CRC = 0x08A1C126; + private int playerType = 16; + private int playerFaction = 0; + private long objId = 0; + + public UpdatePvpStatusMessage() { + + } + + public UpdatePvpStatusMessage(int playerType, int playerFaction, long objId) { + this.playerType = playerType; + this.playerFaction = playerFaction; + this.objId = objId; + } + + public void decode(ByteBuffer data) { + if (!super.decode(data, CRC)) + return; + playerType = getInt(data); + playerFaction = getInt(data); + objId = getLong(data); + } + + public ByteBuffer encode() { + int length = 22; + ByteBuffer data = ByteBuffer.allocate(length); + addShort(data, 4); + addInt( data, CRC); + addInt( data, playerType); + addInt( data, playerFaction); + addLong( data, objId); + return data; + } + + public long getObjectId() { return objId; } + public int getPlayerFaction() { return playerFaction; } + public int getPlayerType() { return playerType; } + +} diff --git a/src/network/packets/swg/zone/UpdateTransformsMessage.java b/src/network/packets/swg/zone/UpdateTransformsMessage.java new file mode 100644 index 000000000..f87466506 --- /dev/null +++ b/src/network/packets/swg/zone/UpdateTransformsMessage.java @@ -0,0 +1,64 @@ +package network.packets.swg.zone; + +import java.nio.ByteBuffer; + +import network.packets.swg.SWGPacket; + +public class UpdateTransformsMessage extends SWGPacket { + + public static final int CRC = 0x1B24F808; + private long objId; + private int posX; + private int posY; + private int posZ; + private int updateCounter; + private byte posture; + private byte direction; + + public UpdateTransformsMessage() { + this(0, 0, 0, 0, 0, (byte)0, (byte)0); + } + + public UpdateTransformsMessage(long objId, int posX, int posY, int posZ, int updateCounter, byte posture, byte direction) { + this.objId = objId; + this.posX = posX; + this.posY = posY; + this.posZ = posZ; + this.updateCounter = updateCounter; + this.posture = posture; + this.direction = direction; + } + + public UpdateTransformsMessage(ByteBuffer data) { + decode(data); + } + + public void decode(ByteBuffer data) { + if (!super.decode(data, CRC)) + return; + objId = getLong(data); + posX = getShort(data); + posY = getShort(data); + posZ = getShort(data); + updateCounter = getInt(data); + posture = getByte(data); + direction = getByte(data); + } + + public ByteBuffer encode() { + ByteBuffer data = ByteBuffer.allocate(26); + addShort(data, 2); + addInt( data, CRC); + addLong( data, objId); + addShort(data, posX); + addShort(data, posY); + addShort(data, posZ); + addInt (data, updateCounter); + addByte (data, posture); + addByte (data, direction); + return data; + } + + public long getObjectId() { return objId; } + +} diff --git a/src/network/packets/swg/zone/auction/AuctionQueryHeadersMessage.java b/src/network/packets/swg/zone/auction/AuctionQueryHeadersMessage.java new file mode 100644 index 000000000..c5a3e99b5 --- /dev/null +++ b/src/network/packets/swg/zone/auction/AuctionQueryHeadersMessage.java @@ -0,0 +1,35 @@ +package network.packets.swg.zone.auction; + +import java.nio.ByteBuffer; + +import network.packets.swg.SWGPacket; + +public class AuctionQueryHeadersMessage extends SWGPacket { + + public static final int CRC = 0x679E0D00; + + public AuctionQueryHeadersMessage() { + + } + + public AuctionQueryHeadersMessage(String command) { + + } + + public AuctionQueryHeadersMessage(ByteBuffer data) { + decode(data); + } + + public void decode(ByteBuffer data) { + if (!super.decode(data, CRC)) + return; + } + + public ByteBuffer encode() { + ByteBuffer data = ByteBuffer.allocate(6); + addShort(data, 2); + addInt (data, CRC); + return data; + } + +} diff --git a/src/network/packets/swg/zone/auction/AuctionQueryHeadersResponseMessage.java b/src/network/packets/swg/zone/auction/AuctionQueryHeadersResponseMessage.java new file mode 100644 index 000000000..d8b3bc703 --- /dev/null +++ b/src/network/packets/swg/zone/auction/AuctionQueryHeadersResponseMessage.java @@ -0,0 +1,222 @@ +package network.packets.swg.zone.auction; + +import java.nio.ByteBuffer; +import java.util.ArrayList; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Set; + +import network.packets.swg.SWGPacket; + +public class AuctionQueryHeadersResponseMessage extends SWGPacket { + + public static final int CRC = 0xFA500E52; + + private int counter; + private int screen; + private List items; + + public AuctionQueryHeadersResponseMessage() { + items = new ArrayList(); + } + + public AuctionQueryHeadersResponseMessage(ByteBuffer data) { + decode(data); + } + + public void decode(ByteBuffer data) { + if (!super.decode(data, CRC)) + return; + counter = getInt(data); + screen = getInt(data); + String [] locations = new String[getInt(data)]; + for (int i = 0; i < locations.length; i++) + locations[i] = getAscii(data); + int itemCount = getInt(data); + AuctionItem [] items = new AuctionItem[itemCount]; + for (int itemI = 0; itemI < itemCount; itemI++) { + AuctionItem item = new AuctionItem(); + item.setItemName(getUnicode(data)); + items[itemI] = item; + } + itemCount = getInt(data); + if (itemCount != items.length) + throw new IllegalStateException("I WAS LIED TO!"); + for (int itemI = 0; itemI < itemCount; itemI++) { + AuctionItem item = items[itemI]; + item.setObjectId(getLong(data)); + getByte(data); + item.setPrice(getInt(data)); + item.setExpireTime(getInt(data)*1000+System.currentTimeMillis()); + if (getInt(data) != item.getPrice()) + throw new IllegalStateException("I WAS LIED TO AT INDEX " + itemI); + item.setVuid(locations[getShort(data)]); + item.setOwnerId(getLong(data)); + item.setOwnerName(locations[getShort(data)]); + getLong(data); + getInt(data); + getInt(data); + getShort(data); + item.setItemType(getInt(data)); + getInt(data); + item.setAuctionOptions(getInt(data)); + getInt(data); + } + getShort(data); + getByte(data); + } + + public ByteBuffer encode() { + ByteBuffer data = ByteBuffer.allocate(6); + addShort(data, 8); + addInt (data, CRC); + addInt (data, counter); + addInt (data, screen); + + Set locations = new LinkedHashSet(); + for (AuctionItem item : items) { + locations.add(item.getVuid()); + locations.add(item.getOwnerName()); + } + addInt(data, items.size()); + for (String item : locations) { + addAscii(data, item); + } + + addInt (data, items.size()); + for (AuctionItem item : items) + addUnicode(data, item.getItemName()); + + addInt (data, items.size()); + + int i = 0; + for(AuctionItem item : items) { + addLong(data, item.getObjectId()); + addByte(data, i); + addInt(data, item.getPrice()); + addInt(data, (int) ((item.getExpireTime() - System.currentTimeMillis()) / 1000)); + addInt(data, item.getPrice()); // if != price then auction instead of instant sale + //addInt(data, 0); + addShort(data, getString(locations, item.getVuid())); + addLong(data, item.getOwnerId()); + addShort(data, getString(locations, item.getOwnerName())); + addLong(data, 0); + addInt(data, 0); // unk seen as 2 mostly, doesnt seem to have any effect + addInt(data, 0); + addShort(data, (short) 0); + addInt(data, item.getItemType()); // gameObjectType/category bitmask + + addInt(data, 0); + int options = 0; + + if (item.getStatus() == AuctionState.OFFERED || item.getStatus() == AuctionState.FORSALE) + options |= 0x800; + + addInt(data, item.getAuctionOptions() | options); + addInt(data, 0); + i++; + } + + addShort(data, 0); + + addByte(data, (byte) 0); + return data; + } + + private int getString(Set strings, String str) { + int index = 0; + for (String s : strings) { + if (s.equals(str)) + return index; + index++; + } + return index; + } + + public static enum AuctionState { + PREMIUM (0x400), + WITHDRAW (0x800), + FORSALE (1), + SOLD (2), + EXPIRED (4), + OFFERED (5), + RETRIEVED (6); + + private int id; + + AuctionState(int id) { + this.id = id; + } + + public int getId() { return id; } + } + + public static class AuctionItem { + private long objectId; + private long ownerId; + private long vendorId; + private long buyerId; + private long offerToId; + private int itemType; + private int itemTypeCRC; + private String ownerName; + private String bidderName; + private String itemName; + private String itemDescription; + private String planet; + private String location; + private int price; + private int proxyBid; + private boolean auction; + private String vuid; + private boolean onBazaar = false; + private long expireTime; + private int auctionOptions; + private AuctionState state; + + public long getObjectId() { return objectId; } + public long getOwnerId() { return ownerId; } + public long getVendorId() { return vendorId; } + public long getBuyerId() { return buyerId; } + public long getOfferToId() { return offerToId; } + public int getItemType() { return itemType; } + public String getOwnerName() { return ownerName; } + public String getBidderName() { return bidderName; } + public String getItemName() { return itemName; } + public String getLocation() { return location; } + public int getPrice() { return price; } + public int getProxyBid() { return proxyBid; } + public boolean isAuction() { return auction; } + public String getVuid() { return vuid; } + public AuctionState getStatus() { return state; } + public boolean isOnBazaar() { return onBazaar; } + public int getAuctionOptions() { return auctionOptions; } + public String getPlanet() { return planet; } + public int getItemTypeCRC() { return itemTypeCRC; } + + public String getItemDescription() { return itemDescription; } + public void setObjectId(long objectId) { this.objectId = objectId; } + public void setOwnerId(long ownerId) { this.ownerId = ownerId; } + public void setVendorId(long vendorId) { this.vendorId = vendorId; } + public void setBuyerId(long buyerId) { this.buyerId = buyerId; } + public void setOfferToId(long offerToId) { this.offerToId = offerToId; } + public void setItemType(int itemType) { this.itemType = itemType; } + public void setOwnerName(String ownerName) { this.ownerName = ownerName; } + public void setBidderName(String bidderName) { this.bidderName = bidderName; } + public void setItemName(String itemName) { this.itemName = itemName; } + public void setLocation(String location) { this.location = location; } + public void setItemDescription(String itemDescription) { this.itemDescription = itemDescription; } + public void setPrice(int price) { this.price = price; } + public void setProxyBid(int proxyBid) { this.proxyBid = proxyBid; } + public void setAuction(boolean auction) { this.auction = auction; } + public void setVuid(String vuid) { this.vuid = vuid; } + public void setStatus(AuctionState state) { this.state = state; } + public void setOnBazaar(boolean onBazaar) { this.onBazaar = onBazaar; } + public long getExpireTime() { return expireTime; } + public void setExpireTime(long expireTime) { this.expireTime = expireTime; } + public void setAuctionOptions(int auctionOptions) { this.auctionOptions = auctionOptions; } + public void setPlanet(String planet) { this.planet = planet; } + public void setItemTypeCRC(int itemTypeCRC) { this.itemTypeCRC = itemTypeCRC; } + } + +} diff --git a/src/network/packets/swg/zone/auction/CancelLiveAuctionMessage.java b/src/network/packets/swg/zone/auction/CancelLiveAuctionMessage.java new file mode 100644 index 000000000..be809ee43 --- /dev/null +++ b/src/network/packets/swg/zone/auction/CancelLiveAuctionMessage.java @@ -0,0 +1,35 @@ +package network.packets.swg.zone.auction; + +import java.nio.ByteBuffer; + +import network.packets.swg.SWGPacket; + +public class CancelLiveAuctionMessage extends SWGPacket { + + public static final int CRC = 0x3687A4D2; + + public CancelLiveAuctionMessage() { + + } + + public CancelLiveAuctionMessage(String command) { + + } + + public CancelLiveAuctionMessage(ByteBuffer data) { + decode(data); + } + + public void decode(ByteBuffer data) { + if (!super.decode(data, CRC)) + return; + } + + public ByteBuffer encode() { + ByteBuffer data = ByteBuffer.allocate(6); + addShort(data, 2); + addInt (data, CRC); + return data; + } + +} diff --git a/src/network/packets/swg/zone/auction/CancelLiveAuctionResponseMessage.java b/src/network/packets/swg/zone/auction/CancelLiveAuctionResponseMessage.java new file mode 100644 index 000000000..da40e1145 --- /dev/null +++ b/src/network/packets/swg/zone/auction/CancelLiveAuctionResponseMessage.java @@ -0,0 +1,35 @@ +package network.packets.swg.zone.auction; + +import java.nio.ByteBuffer; + +import network.packets.swg.SWGPacket; + +public class CancelLiveAuctionResponseMessage extends SWGPacket { + + public static final int CRC = 0x7DA2246C; + + public CancelLiveAuctionResponseMessage() { + + } + + public CancelLiveAuctionResponseMessage(String command) { + + } + + public CancelLiveAuctionResponseMessage(ByteBuffer data) { + decode(data); + } + + public void decode(ByteBuffer data) { + if (!super.decode(data, CRC)) + return; + } + + public ByteBuffer encode() { + ByteBuffer data = ByteBuffer.allocate(6); + addShort(data, 2); + addInt (data, CRC); + return data; + } + +} diff --git a/src/network/packets/swg/zone/auction/GetAuctionDetails.java b/src/network/packets/swg/zone/auction/GetAuctionDetails.java new file mode 100644 index 000000000..0e5ce3ad2 --- /dev/null +++ b/src/network/packets/swg/zone/auction/GetAuctionDetails.java @@ -0,0 +1,39 @@ +package network.packets.swg.zone.auction; + +import java.nio.ByteBuffer; + +import network.packets.swg.SWGPacket; + +public class GetAuctionDetails extends SWGPacket { + + public static final int CRC = 0xD36EFAE4; + + private long auctionId; + + public GetAuctionDetails() { + this(0); + } + + public GetAuctionDetails(long auctionId) { + this.auctionId = auctionId; + } + + public GetAuctionDetails(ByteBuffer data) { + decode(data); + } + + public void decode(ByteBuffer data) { + if (!super.decode(data, CRC)) + return; + auctionId = getLong(data); + } + + public ByteBuffer encode() { + ByteBuffer data = ByteBuffer.allocate(14); + addShort(data, 2); + addInt (data, CRC); + addLong (data, auctionId); + return data; + } + +} diff --git a/src/network/packets/swg/zone/auction/GetAuctionDetailsResponse.java b/src/network/packets/swg/zone/auction/GetAuctionDetailsResponse.java new file mode 100644 index 000000000..231bc8203 --- /dev/null +++ b/src/network/packets/swg/zone/auction/GetAuctionDetailsResponse.java @@ -0,0 +1,65 @@ +package network.packets.swg.zone.auction; + +import java.nio.ByteBuffer; +import java.util.HashMap; +import java.util.Map; +import java.util.Map.Entry; + +import network.packets.swg.SWGPacket; + +public class GetAuctionDetailsResponse extends SWGPacket { + + public static final int CRC = 0xFE0E644B; + + private long itemId; + private Map properties; + private String itemName; + + public GetAuctionDetailsResponse() { + this(0, new HashMap(), ""); + } + + public GetAuctionDetailsResponse(long itemId, Map properties, String itemName) { + this.itemId = itemId; + this.properties = properties; + this.itemName = itemName; + } + + public GetAuctionDetailsResponse(ByteBuffer data) { + decode(data); + } + + public void decode(ByteBuffer data) { + if (!super.decode(data, CRC)) + return; + itemId = getLong(data); + getInt(data); + int count = getInt(data); + for (int i = 0; i < count; i++) { + String key = getAscii(data); + String val = getUnicode(data); + properties.put(key, val); + } + itemName = getAscii(data); + getShort(data); // 0 + } + + public ByteBuffer encode() { + int strSize = 0; + for (Entry e : properties.entrySet()) + strSize += 6 + e.getKey().length() + e.getValue().length()*2; + ByteBuffer data = ByteBuffer.allocate(18 + strSize); + addShort(data, 9); + addInt (data, CRC); + addLong (data, itemId); + addInt (data, properties.size()); + for (Entry e : properties.entrySet()) { + addAscii(data, e.getKey()); + addUnicode(data, e.getValue()); + } + addAscii(data, itemName); + addShort(data, 0); + return data; + } + +} diff --git a/src/network/packets/swg/zone/auction/IsVendorOwnerResponseMessage.java b/src/network/packets/swg/zone/auction/IsVendorOwnerResponseMessage.java new file mode 100644 index 000000000..622ff0e58 --- /dev/null +++ b/src/network/packets/swg/zone/auction/IsVendorOwnerResponseMessage.java @@ -0,0 +1,35 @@ +package network.packets.swg.zone.auction; + +import java.nio.ByteBuffer; + +import network.packets.swg.SWGPacket; + +public class IsVendorOwnerResponseMessage extends SWGPacket { + + public static final int CRC = 0xCE04173E; + + public IsVendorOwnerResponseMessage() { + + } + + public IsVendorOwnerResponseMessage(String command) { + + } + + public IsVendorOwnerResponseMessage(ByteBuffer data) { + decode(data); + } + + public void decode(ByteBuffer data) { + if (!super.decode(data, CRC)) + return; + } + + public ByteBuffer encode() { + ByteBuffer data = ByteBuffer.allocate(6); + addShort(data, 2); + addInt (data, CRC); + return data; + } + +} diff --git a/src/network/packets/swg/zone/auction/RetrieveAuctionItemMessage.java b/src/network/packets/swg/zone/auction/RetrieveAuctionItemMessage.java new file mode 100644 index 000000000..8e600d36d --- /dev/null +++ b/src/network/packets/swg/zone/auction/RetrieveAuctionItemMessage.java @@ -0,0 +1,35 @@ +package network.packets.swg.zone.auction; + +import java.nio.ByteBuffer; + +import network.packets.swg.SWGPacket; + +public class RetrieveAuctionItemMessage extends SWGPacket { + + public static final int CRC = 0x12B0D449; + + public RetrieveAuctionItemMessage() { + + } + + public RetrieveAuctionItemMessage(String command) { + + } + + public RetrieveAuctionItemMessage(ByteBuffer data) { + decode(data); + } + + public void decode(ByteBuffer data) { + if (!super.decode(data, CRC)) + return; + } + + public ByteBuffer encode() { + ByteBuffer data = ByteBuffer.allocate(6); + addShort(data, 2); + addInt (data, CRC); + return data; + } + +} diff --git a/src/network/packets/swg/zone/auction/RetrieveAuctionItemResponseMessage.java b/src/network/packets/swg/zone/auction/RetrieveAuctionItemResponseMessage.java new file mode 100644 index 000000000..f9e4930fe --- /dev/null +++ b/src/network/packets/swg/zone/auction/RetrieveAuctionItemResponseMessage.java @@ -0,0 +1,35 @@ +package network.packets.swg.zone.auction; + +import java.nio.ByteBuffer; + +import network.packets.swg.SWGPacket; + +public class RetrieveAuctionItemResponseMessage extends SWGPacket { + + public static final int CRC = 0x9499EF8C; + + public RetrieveAuctionItemResponseMessage() { + + } + + public RetrieveAuctionItemResponseMessage(String command) { + + } + + public RetrieveAuctionItemResponseMessage(ByteBuffer data) { + decode(data); + } + + public void decode(ByteBuffer data) { + if (!super.decode(data, CRC)) + return; + } + + public ByteBuffer encode() { + ByteBuffer data = ByteBuffer.allocate(6); + addShort(data, 2); + addInt (data, CRC); + return data; + } + +} diff --git a/src/network/packets/swg/zone/baselines/Baseline.java b/src/network/packets/swg/zone/baselines/Baseline.java new file mode 100644 index 000000000..dce95adbe --- /dev/null +++ b/src/network/packets/swg/zone/baselines/Baseline.java @@ -0,0 +1,74 @@ +package network.packets.swg.zone.baselines; + +import java.nio.ByteBuffer; + +import network.packets.swg.SWGPacket; + + +public class Baseline extends SWGPacket { + + public static final int CRC = 0x68A75F0C; + private BaselineType type; + private int num; + private long objId; + private ByteBuffer baseData; + + public Baseline() { + + } + + public Baseline(long objId, Baseline subData) { + this.objId = objId; + type = subData.getType(); + num = subData.getNum(); + baseData = subData.encodeBaseline(); + } + + public void decode(ByteBuffer data) { + if (!super.decode(data, CRC)) + return; + objId = getLong(data); + byte [] str = new byte[4]; data.get(str); + String strType = new StringBuffer(new String(str, ascii)).reverse().toString(); + for (BaselineType baseType : BaselineType.values()) + if (baseType.toString().equals(strType)) + type = baseType; + num = getByte(data); + byte [] objData = new byte[getInt(data)]; + data.get(objData); + baseData = ByteBuffer.wrap(objData); + } + + public ByteBuffer encode() { + ByteBuffer data = ByteBuffer.allocate(23 + baseData.array().length); + addShort(data, 5); + addInt( data, CRC); + addLong( data, objId); + data.put(new StringBuffer(type.toString()).reverse().toString().getBytes(ascii)); + addByte( data, num); + addInt( data, baseData.array().length); + data.put(baseData.array()); + return data; + } + + public ByteBuffer encodeBaseline() { return ByteBuffer.allocate(0); } + + public long getObjectId() { return objId; } + + public void setType(BaselineType type) { this.type = type; } + public void setNum(int num) { this.num = num; } + public void setId(long id) { this.objId = id; } + + public BaselineType getType() { return type; } + public int getNum() { return num; } + public long getId() { return objId; } + public ByteBuffer getBaselineData() { return baseData; } + + public enum BaselineType { + BMRK, BUIO, CREO, FCYT, + GILD, GRUP, HINO, INSO, + ITNO, MINO, MISO, MSCO, + PLAY, RCNO, SCLT, STAO, + SHIP, TANO, WAYP, WEAO + } +} diff --git a/src/network/packets/swg/zone/baselines/CREO3.java b/src/network/packets/swg/zone/baselines/CREO3.java new file mode 100644 index 000000000..aa098f26c --- /dev/null +++ b/src/network/packets/swg/zone/baselines/CREO3.java @@ -0,0 +1,81 @@ +package network.packets.swg.zone.baselines; + +import java.nio.ByteBuffer; + +public class CREO3 extends Baseline { + + private String dName = ""; + private String cName = ""; + private byte [] customization = new byte[0]; + private int posture = 1; + private float height = 0; + private int fatigue = 0; + + public CREO3() { + + } + + public CREO3(String dName, String cName, byte [] customization, int posture, float height, int fatigue) { + this.dName = dName; + this.cName = cName; + this.customization = customization; + this.posture = posture; + this.height = height; + this.fatigue = fatigue; + } + + public void decodeBaseline(ByteBuffer data) { + getInt(data); + getShort(data); + getAscii(data); + getInt(data); + dName = getAscii(data); + cName = getUnicode(data); + getInt(data); + getLong(data); + customization = getArray(data); + getInt(data); + getInt(data); + getInt(data); + getInt(data); + getInt(data); + getInt(data); + getInt(data); + posture = getShort(data); + getByte(data); + getLong(data); + height = getFloat(data); + fatigue = getInt(data); + } + + public ByteBuffer encodeBaseline() { + int length = 91 + "species".length() + dName.length() + cName.length() * 2 + customization.length; + ByteBuffer data = ByteBuffer.allocate(length); + addInt( data, 0x13); // Object Count? + addShort( data, 0x3F80); // Scale? + addAscii( data, "species"); // Unknown.. + addInt( data, 0); // Spacer + addAscii( data, dName); // Default Name + addUnicode(data, cName); // Custom Name + addInt( data, 0x000F4240); // Unknown + addLong( data, 0); // Unknown + addArray( data, customization); // Object Customization Data + addInt( data, 1); // Unknown + addInt( data, 0); // Unknown + addInt( data, 0); // Unknown + addInt( data, 0x80); // Unknown + addInt( data, 0); // Unknown + addInt( data, 0); // Unknown + addInt( data, 0x00003A98); // Unknown + addShort( data, posture); // Posture for Object + addByte( data, 1); // Unknown + addLong( data, 0); // Target Object Id + addFloat( data, height); // Height of Object + addInt( data, fatigue); // Battle Fatigue + addLong( data, 0); // State? + return data; + } + + public String getDefaultName() { return dName; } + public String getCustomName() { return cName; } +} diff --git a/src/network/packets/swg/zone/baselines/CREO6.java b/src/network/packets/swg/zone/baselines/CREO6.java new file mode 100644 index 000000000..b68f795c0 --- /dev/null +++ b/src/network/packets/swg/zone/baselines/CREO6.java @@ -0,0 +1,98 @@ +package network.packets.swg.zone.baselines; + +import java.nio.ByteBuffer; + + +public class CREO6 extends Baseline { + + private long objectId = 0; + + public CREO6(long objectId) { + this.objectId = objectId; + } + + public void decodeBaseline(ByteBuffer data) { + + } + + public ByteBuffer encodeBaseline() { + // ByteBuffer data = ByteBuffer.allocate(260); + // addShort(data, 0x23); + // addFloat(data, 0); + // addInt(data, 0); + // addInt(data, 0); + // + // addLong(data, 0); + // addLong(data, 0); + // addLong(data, 0); + // addLong(data, 0); + // addInt(data, 0); + // + // addByte(data, 0); + // addShort(data, 90); + // addInt(data, (byte) 0xD007); + // addShort(data, 0); + // addAscii(data, "neutral"); + // //addLong(data, objectId + 5); // WEAO ID + // addLong(data, 0); + // + // addLong(data, 0); + // addInt(data, 0); + // addLong(data, 0); + // addLong(data, 0); + // addLong(data, 0); + // addByte(data, 0); + // addInt(data, 0); + // addInt(data, 0); + // addInt(data, 0); + // addShort(data, 0); + // + // addInt(data, 6); + // addInt(data, 6); // Current Combat stats list + // + // addInt(data, 350); + // addInt(data, 350); + // addInt(data, 350); + // addInt(data, 350); + // addInt(data, 350); + // addInt(data, 350); + // + // + // addInt(data, 6); + // addInt(data, 6); // Maximum Combat stats list + // + // addInt(data, 350); + // addInt(data, 350); + // addInt(data, 350); + // addInt(data, 350); + // addInt(data, 350); + // addInt(data, 350); + // + // + // addInt(data, 1); + // addInt(data, 1); + // + // addShort(data, 0); + // addInt(data, 4); + // addLong(data, objectId + 3); + // addInt(data, 0x73ba5001); + // addByte(data, 0); + // + // addNetInt(data, 1); + // + // addLong(data, 0); + // + // addShort(data, 0); + // + // return data; + byte [] data1 = { + (byte) 0x23, (byte) 0x00, (byte) 0x4E, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x5A, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x0C, (byte) 0x00, (byte) 0x63, (byte) 0x6F, (byte) 0x6E, (byte) 0x76, (byte) 0x65, (byte) 0x72, (byte) 0x73, (byte) 0x61, (byte) 0x74, (byte) 0x69, (byte) 0x6F, (byte) 0x6E, (byte) 0x00, (byte) 0xAE, (byte) 0x5E, (byte) 0xA9, (byte) 0x45, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x06, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x05, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x3B, (byte) 0x09, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0xEA, (byte) 0x0B, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0xE8, (byte) 0x03, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x06, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x05, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x3B, (byte) 0x09, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0xEA, (byte) 0x0B, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0xE8, (byte) 0x03, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x02, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x02, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x04, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0xFC, (byte) 0xAD, (byte) 0x5E, (byte) 0xA9, (byte) 0x45, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x1C, (byte) 0x79, (byte) 0x10, (byte) 0x21, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x04, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0xAE, (byte) 0x5E, (byte) 0xA9, (byte) 0x45, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x42, (byte) 0xE7, (byte) 0xD0, (byte) 0x7D, (byte) 0x01, (byte) 0x05, (byte) 0x00, (byte) 0x0C, (byte) 0x5F, (byte) 0xA7, (byte) 0x68, (byte) 0x00, (byte) 0xAE, (byte) 0x5E, (byte) 0xA9, (byte) 0x45, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x4F, (byte) 0x41, (byte) 0x45, (byte) 0x57, (byte) 0x03, (byte) 0x6E, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x14, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x0B, (byte) 0x00, (byte) 0x77, (byte) 0x65, (byte) 0x61, (byte) 0x70, (byte) 0x6F, (byte) 0x6E, (byte) 0x5F, (byte) 0x6E, (byte) 0x61, (byte) 0x6D, (byte) 0x65, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x0E, (byte) 0x00, (byte) 0x64, (byte) 0x65, (byte) 0x66, (byte) 0x61, (byte) 0x75, (byte) 0x6C, (byte) 0x74, (byte) 0x5F, (byte) 0x77, (byte) 0x65, (byte) 0x61, (byte) 0x70, (byte) 0x6F, (byte) 0x6E, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x01, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x01, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0xE8, (byte) 0x03, (byte) 0x00, (byte) 0x00, (byte) 0x01, (byte) 0x00, (byte) 0x00, (byte) 0x80, (byte) 0x3F, (byte) 0x0A, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0xA0, (byte) 0x40, (byte) 0x01, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x05, (byte) 0x00, (byte) 0x0C, (byte) 0x5F, (byte) 0xA7, (byte) 0x68, (byte) 0x00, (byte) 0xAE, (byte) 0x5E, (byte) 0xA9, (byte) 0x45, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x4F, (byte) 0x41, (byte) 0x45, (byte) 0x57, (byte) 0x06, (byte) 0x50, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x09, (byte) 0x00, (byte) 0x4E, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x0B, (byte) 0x00, (byte) 0x77, (byte) 0x65, (byte) 0x61, (byte) 0x70, (byte) 0x6F, (byte) 0x6E, (byte) 0x5F, (byte) 0x6E, (byte) 0x61, (byte) 0x6D, (byte) 0x65, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x0E, (byte) 0x00, (byte) 0x64, (byte) 0x65, (byte) 0x66, (byte) 0x61, (byte) 0x75, (byte) 0x6C, (byte) 0x74, (byte) 0x5F, (byte) 0x77, (byte) 0x65, (byte) 0x61, (byte) 0x70, (byte) 0x6F, (byte) 0x6E, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, + + }; + byte[] data2 = new byte[] { + + (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x06, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x01, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0x01, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, + }; + return ByteBuffer.allocate(data1.length + data2.length).put(data1).put(data2); + } +} diff --git a/src/network/packets/swg/zone/baselines/CREO8.java b/src/network/packets/swg/zone/baselines/CREO8.java new file mode 100644 index 000000000..ef1cd084c --- /dev/null +++ b/src/network/packets/swg/zone/baselines/CREO8.java @@ -0,0 +1,22 @@ +package network.packets.swg.zone.baselines; + +import java.nio.ByteBuffer; + + +public class CREO8 extends Baseline { + + public CREO8() { + + } + + public void decodeBaseline(ByteBuffer data) { + + } + + public ByteBuffer encodeBaseline() { + int length = 2; + ByteBuffer data = ByteBuffer.allocate(length); + addShort(data, 0); + return data; + } +} diff --git a/src/network/packets/swg/zone/baselines/CREO9.java b/src/network/packets/swg/zone/baselines/CREO9.java new file mode 100644 index 000000000..eb336a1db --- /dev/null +++ b/src/network/packets/swg/zone/baselines/CREO9.java @@ -0,0 +1,22 @@ +package network.packets.swg.zone.baselines; + +import java.nio.ByteBuffer; + + +public class CREO9 extends Baseline { + + public CREO9() { + + } + + public void decodeBaseline(ByteBuffer data) { + + } + + public ByteBuffer encodeBaseline() { + int length = 2; + ByteBuffer data = ByteBuffer.allocate(length); + addShort(data, 0); + return data; + } +} diff --git a/src/network/packets/swg/zone/baselines/PLAY6.java b/src/network/packets/swg/zone/baselines/PLAY6.java new file mode 100644 index 000000000..36846aeda --- /dev/null +++ b/src/network/packets/swg/zone/baselines/PLAY6.java @@ -0,0 +1,28 @@ +package network.packets.swg.zone.baselines; + +import java.nio.ByteBuffer; + + +public class PLAY6 extends Baseline { + + public void decodeBaseline(ByteBuffer data) { + + } + + public ByteBuffer encodeBaseline() { + int length = 81; + ByteBuffer data = ByteBuffer.allocate(length); + addShort(data, 17); + addInt( data, 0x4C); + addAscii(data, "string_id_table"); + addLong( data, 0); + addLong( data, 0); + addLong( data, 0); + addLong( data, 0); + addLong( data, 0); + addLong( data, 0); + addLong( data, 0); + addShort(data, 0); + return data; + } +} diff --git a/src/network/packets/swg/zone/baselines/PLAY9.java b/src/network/packets/swg/zone/baselines/PLAY9.java new file mode 100644 index 000000000..d7abcc954 --- /dev/null +++ b/src/network/packets/swg/zone/baselines/PLAY9.java @@ -0,0 +1,86 @@ +package network.packets.swg.zone.baselines; + +import java.nio.ByteBuffer; + + +public class PLAY9 extends Baseline { + + public void decodeBaseline(ByteBuffer data) { + + } + + public ByteBuffer encodeBaseline() { + int length = 0x0143; + ByteBuffer data = ByteBuffer.allocate(length); + addInt( data, 0x1F); + addInt( data, 0); + addInt( data, 0); + addShort(data, 0); + addInt( data, 0); + addInt( data, 3); + addInt( data, 3); + addByte( data, 0); + addInt( data, 0x30254293); + addInt( data, 0xD805AB60); + addInt( data, 1); + addByte( data, 0); + addInt( data, 0x4BB23CAE); + addInt( data, 0x6C750908); + addInt( data, 1); + addByte( data, 0); + addInt( data, 0x83AADF10); + addInt( data, 0x757A3F17); + addInt( data, 1); + addByte( data, 0); + addByte( data, 0); + addShort(data, 0); + addInt( data, 0); + addInt( data, 8); + addInt( data, 0); + addInt( data, 10); + addInt( data, 0x21); + addAscii(data, "atima"); + addAscii(data, "brokovo"); + addAscii(data, "daymian"); + addAscii(data, "dow-jones"); + addAscii(data, "eclipse.pandoren"); + addAscii(data, "eclipse.rabivesk"); + addAscii(data, "kenpachie"); + addAscii(data, "melony"); + addAscii(data, "omatchi'"); + addAscii(data, "sobli"); + addInt( data, 0); + addInt( data, 3); + addInt( data, 1); + addInt( data, 0); + addInt( data, 100); + addInt( data, 0); + addInt( data, 100); + addInt( data, 0); + addInt( data, 100); + addInt( data, 0); + addInt( data, 0); + addInt( data, 0); + addInt( data, 3); + addInt( data, 0); + addInt( data, 0); + addInt( data, 0); + addInt( data, 0); + addInt( data, 0); + addInt( data, 0); + addInt( data, 0); + addInt( data, 0); + addInt( data, 2); + addInt( data, 0); + addInt( data, 0); + addInt( data, 0); + addInt( data, 0); + addInt( data, 0); + addInt( data, 0); + addInt( data, 0); + addInt( data, 0); + addInt( data, 0); + addShort( data, 0); + return data; + } +} diff --git a/src/network/packets/swg/zone/building/UpdateCellPermissionMessage.java b/src/network/packets/swg/zone/building/UpdateCellPermissionMessage.java new file mode 100644 index 000000000..fa1186da9 --- /dev/null +++ b/src/network/packets/swg/zone/building/UpdateCellPermissionMessage.java @@ -0,0 +1,47 @@ +package network.packets.swg.zone.building; + +import java.nio.ByteBuffer; + +import network.packets.swg.SWGPacket; + +public class UpdateCellPermissionMessage extends SWGPacket { + + public static final int CRC = 0xF612499C; + + private byte permissionFlag; + private long cellId; + + public UpdateCellPermissionMessage() { + permissionFlag = 0; + cellId = 0; + } + + public UpdateCellPermissionMessage(byte permissionFlag, long cellId) { + this.permissionFlag = permissionFlag; + this.cellId = cellId; + } + + public UpdateCellPermissionMessage(ByteBuffer data) { + decode(data); + } + + public void decode(ByteBuffer data) { + if (!super.decode(data, CRC)) + return; + permissionFlag = getByte(data); + cellId = getLong(data); + } + + public ByteBuffer encode() { + ByteBuffer data = ByteBuffer.allocate(15); + addShort(data, 2); + addInt( data, CRC); + addByte( data, permissionFlag); + addLong( data, cellId); + return data; + } + + public long getCellId() { return cellId; } + public byte getPermissions() { return permissionFlag; } + +} diff --git a/src/network/packets/swg/zone/chat/ChatFriendsListUpdate.java b/src/network/packets/swg/zone/chat/ChatFriendsListUpdate.java new file mode 100644 index 000000000..5bb9d386f --- /dev/null +++ b/src/network/packets/swg/zone/chat/ChatFriendsListUpdate.java @@ -0,0 +1,47 @@ +package network.packets.swg.zone.chat; + +import java.nio.ByteBuffer; + +import network.packets.swg.SWGPacket; + +public class ChatFriendsListUpdate extends SWGPacket { + + public static final int CRC = 0x6CD2FCD8; + + private String galaxy; + private String friendName; + private boolean online; + + public ChatFriendsListUpdate() { + + } + + public ChatFriendsListUpdate(String command) { + + } + + public ChatFriendsListUpdate(ByteBuffer data) { + decode(data); + } + + public void decode(ByteBuffer data) { + if (!super.decode(data, CRC)) + return; + getAscii(data); // SWG + galaxy = getAscii(data); + friendName = getAscii(data); + online = getBoolean(data); + } + + public ByteBuffer encode() { + ByteBuffer data = ByteBuffer.allocate(6); + addShort (data, 3); + addInt (data, CRC); + addAscii (data, "SWG"); + addAscii (data, galaxy); + addAscii (data, friendName); + addBoolean(data, online); + return data; + } + +} diff --git a/src/network/packets/swg/zone/chat/ChatIgnoreList.java b/src/network/packets/swg/zone/chat/ChatIgnoreList.java new file mode 100644 index 000000000..d836123b5 --- /dev/null +++ b/src/network/packets/swg/zone/chat/ChatIgnoreList.java @@ -0,0 +1,86 @@ +package network.packets.swg.zone.chat; + +import java.nio.ByteBuffer; +import java.util.ArrayList; +import java.util.List; + +import network.packets.swg.SWGPacket; + +public class ChatIgnoreList extends SWGPacket { + + public static final int CRC = 0xF8C275B0; + + private long objectId; + private List ignoreList; + + public ChatIgnoreList() { + objectId = 0; + ignoreList = new ArrayList(); + } + + public ChatIgnoreList(ByteBuffer data) { + decode(data); + } + + public void addName(String game, String galaxy, String name) { + addName(new IgnoreListItem(game, galaxy, name)); + } + + public void addName(IgnoreListItem name) { + ignoreList.add(name); + } + + public void decode(ByteBuffer data) { + if (!super.decode(data, CRC)) + return; + objectId = getLong(data); + int listCount = getInt(data); + for (int i = 0; i < listCount; i++) { + String game = getAscii(data); + String galaxy = getAscii(data); + String name = getAscii(data); + addName(game, galaxy, name); + } + } + + public ByteBuffer encode() { + int extraSize = 0; + for (IgnoreListItem item : ignoreList) + extraSize += 6 + item.getGame().length() + item.getGalaxy().length() + item.getName().length(); + ByteBuffer data = ByteBuffer.allocate(18 + extraSize); + addShort (data, 3); + addInt (data, CRC); + addLong (data, objectId); + addInt (data, ignoreList.size()); + for (IgnoreListItem item : ignoreList) { + addAscii(data, item.getGame()); + addAscii(data, item.getGalaxy()); + addAscii(data, item.getName()); + } + return data; + } + + public static class IgnoreListItem { + private String game; + private String galaxy; + private String name; + + public IgnoreListItem() { + this("SWG", "", ""); + } + + public IgnoreListItem(String game, String galaxy, String name) { + this.game = game; + this.galaxy = galaxy; + this.name = name; + } + + public String getGame() { return game; } + public String getGalaxy() { return galaxy; } + public String getName() { return name; } + public void setGame(String game) { this.game = game; } + public void setGalaxy(String galaxy) { this.galaxy = galaxy; } + public void setName(String name) { this.name = name; } + } + +} diff --git a/src/network/packets/swg/zone/chat/ChatInstantMessageToCharacter.java b/src/network/packets/swg/zone/chat/ChatInstantMessageToCharacter.java new file mode 100644 index 000000000..7633c8a61 --- /dev/null +++ b/src/network/packets/swg/zone/chat/ChatInstantMessageToCharacter.java @@ -0,0 +1,65 @@ +package network.packets.swg.zone.chat; + +import java.nio.ByteBuffer; + +import network.packets.swg.SWGPacket; + +public class ChatInstantMessageToCharacter extends SWGPacket { + + public static final int CRC = 0x84BB21F7; + + private String galaxy; + private String character; + private String message; + private int sequence; + + public ChatInstantMessageToCharacter() { + this("", "", "", 0); + } + + public ChatInstantMessageToCharacter(String galaxy, String character, String message, int sequence) { + this.galaxy = galaxy; + this.character = character; + this.message = message; + this.sequence = sequence; + } + + public ChatInstantMessageToCharacter(ByteBuffer data) { + decode(data); + } + + public void decode(ByteBuffer data) { + if (!super.decode(data, CRC)) + return; + getAscii(data); + galaxy = getAscii(data); + character = getAscii(data); + message = getAscii(data); + getInt(data); + sequence = getInt(data); + } + + public ByteBuffer encode() { + ByteBuffer data = ByteBuffer.allocate(19 + character.length() + message.length()); + addShort(data, 2); + addInt( data, CRC); + addAscii(data, "SWG"); + addAscii(data, galaxy); + addAscii(data, character); + addAscii(data, message); + addInt (data, 0); + addInt (data, sequence); + return data; + } + + public String getGalaxy() { return galaxy; } + public String getCharacter() { return character; } + public String getMessage() { return message; } + public int getSequence() { return sequence; } + + public void setGalaxy(String galaxy) { this.galaxy = galaxy; } + public void setCharacter(String character) { this.character = character; } + public void setMessage(String message) { this.message = message; } + public void setSequence(int sequence) { this.sequence = sequence; } + +} diff --git a/src/network/packets/swg/zone/chat/ChatInstantMessageToClient.java b/src/network/packets/swg/zone/chat/ChatInstantMessageToClient.java new file mode 100644 index 000000000..341e5075f --- /dev/null +++ b/src/network/packets/swg/zone/chat/ChatInstantMessageToClient.java @@ -0,0 +1,59 @@ +package network.packets.swg.zone.chat; + +import java.nio.ByteBuffer; + +import network.packets.swg.SWGPacket; + +public class ChatInstantMessageToClient extends SWGPacket { + + public static final int CRC = 0x3C565CED; + + private String galaxy; + private String character; + private String message; + + public ChatInstantMessageToClient() { + this("", "", ""); + } + + public ChatInstantMessageToClient(String galaxy, String character, String message) { + this.galaxy = galaxy; + this.character = character; + this.message = message; + } + + public ChatInstantMessageToClient(ByteBuffer data) { + decode(data); + } + + public void decode(ByteBuffer data) { + if (!super.decode(data, CRC)) + return; + getAscii(data); + galaxy = getAscii(data); + character = getAscii(data); + message = getAscii(data); + getInt(data); + } + + public ByteBuffer encode() { + ByteBuffer data = ByteBuffer.allocate(19 + character.length() + message.length()); + addShort(data, 2); + addInt( data, CRC); + addAscii(data, "SWG"); + addAscii(data, galaxy); + addAscii(data, character); + addAscii(data, message); + addInt (data, 0); + return data; + } + + public String getGalaxy() { return galaxy; } + public String getCharacter() { return character; } + public String getMessage() { return message; } + + public void setGalaxy(String galaxy) { this.galaxy = galaxy; } + public void setCharacter(String character) { this.character = character; } + public void setMessage(String message) { this.message = message; } + +} diff --git a/src/network/packets/swg/zone/chat/ChatOnConnectAvatar.java b/src/network/packets/swg/zone/chat/ChatOnConnectAvatar.java new file mode 100644 index 000000000..c9de91d01 --- /dev/null +++ b/src/network/packets/swg/zone/chat/ChatOnConnectAvatar.java @@ -0,0 +1,35 @@ +package network.packets.swg.zone.chat; + +import java.nio.ByteBuffer; + +import network.packets.swg.SWGPacket; + +public class ChatOnConnectAvatar extends SWGPacket { + + public static final int CRC = 0xD72FE9BE; + + public ChatOnConnectAvatar() { + + } + + public ChatOnConnectAvatar(String command) { + + } + + public ChatOnConnectAvatar(ByteBuffer data) { + decode(data); + } + + public void decode(ByteBuffer data) { + if (!super.decode(data, CRC)) + return; + } + + public ByteBuffer encode() { + ByteBuffer data = ByteBuffer.allocate(6); + addShort(data, 2); + addInt (data, CRC); + return data; + } + +} diff --git a/src/network/packets/swg/zone/chat/ChatOnDestroyRoom.java b/src/network/packets/swg/zone/chat/ChatOnDestroyRoom.java new file mode 100644 index 000000000..2368746f1 --- /dev/null +++ b/src/network/packets/swg/zone/chat/ChatOnDestroyRoom.java @@ -0,0 +1,58 @@ +package network.packets.swg.zone.chat; + +import java.nio.ByteBuffer; + +import network.packets.swg.SWGPacket; + +public class ChatOnDestroyRoom extends SWGPacket { + + public static final int CRC = 0xE8EC5877; + + private String galaxy; + private String owner; + private boolean success; + private int roomId; + private int requestId; + + public ChatOnDestroyRoom() { + this("", "", true, 0, 0); + } + + public ChatOnDestroyRoom(String galaxy, String owner, boolean success, int roomId, int requestId) { + this.galaxy = galaxy; + this.owner = owner; + this.success = success; + this.roomId = roomId; + this.requestId = requestId; + } + + public ChatOnDestroyRoom(ByteBuffer data) { + decode(data); + } + + public void decode(ByteBuffer data) { + if (!super.decode(data, CRC)) + return; + getAscii(data); // SWG + galaxy = getAscii(data); + owner = getAscii(data); + success = getInt(data) == 0; + roomId = getInt(data); + requestId = getInt(data); + } + + public ByteBuffer encode() { + ByteBuffer data = ByteBuffer.allocate(27 + galaxy.length() + owner.length()); + addShort(data, 5); + addInt (data, CRC); + addAscii(data, "SWG"); + addAscii(data, galaxy); + addAscii(data, owner); + addInt (data, success ? 0 : 1); + addInt (data, roomId); + addInt (data, requestId); + return data; + } + +} + diff --git a/src/network/packets/swg/zone/chat/ChatOnEnteredRoom.java b/src/network/packets/swg/zone/chat/ChatOnEnteredRoom.java new file mode 100644 index 000000000..9e4247b9e --- /dev/null +++ b/src/network/packets/swg/zone/chat/ChatOnEnteredRoom.java @@ -0,0 +1,78 @@ +package network.packets.swg.zone.chat; + +import java.nio.ByteBuffer; + +import network.packets.swg.SWGPacket; + +public class ChatOnEnteredRoom extends SWGPacket { + + public static final int CRC = 0xE69BDC0A; + + private String galaxy; + private String character; + private ChannelStatus status; + private int chatRoomId; + + public ChatOnEnteredRoom() { + this("", "", ChannelStatus.SUCCESS, 0); + } + + public ChatOnEnteredRoom(String galaxy, String character, ChannelStatus status, int chatRoomId) { + this.galaxy = galaxy; + this.character = character; + this.status = status; + this.chatRoomId = chatRoomId; + } + + public ChatOnEnteredRoom(ByteBuffer data) { + decode(data); + } + + public void decode(ByteBuffer data) { + if (!super.decode(data, CRC)) + return; + getAscii(data); + galaxy = getAscii(data); + character = getAscii(data); + status = ChannelStatus.fromInteger(getInt(data)); + chatRoomId = getInt(data); + getInt(data); + } + + public ByteBuffer encode() { + ByteBuffer data = ByteBuffer.allocate(27 + galaxy.length() + character.length()); + addShort(data, 5); + addInt (data, CRC); + addAscii(data, "SWG"); + addAscii(data, galaxy); + addAscii(data, character); + addInt (data, status.getBitmask()); + addInt (data, chatRoomId); + addInt (data, 0); + return data; + } + + public enum ChannelStatus { + SUCCESS(0), // "You have joined the channel." + NOT_INVITED(0x10), // "You cannot join '%TU (room name)' because you are not invted to the room." + UNKNOWN(0x20); // "Chatroom '%TU (room name)' join failed for an unknown reason." + + private int bitmask; + + ChannelStatus(int bitmask) { + this.bitmask = bitmask; + } + public int getBitmask() { + return bitmask; + } + public static final ChannelStatus fromInteger(int i) { + if (i == 0) + return SUCCESS; + if (i == 0x10) + return NOT_INVITED; + return UNKNOWN; + } + }; + +} + diff --git a/src/network/packets/swg/zone/chat/ChatOnLeaveRoom.java b/src/network/packets/swg/zone/chat/ChatOnLeaveRoom.java new file mode 100644 index 000000000..08d9d7e70 --- /dev/null +++ b/src/network/packets/swg/zone/chat/ChatOnLeaveRoom.java @@ -0,0 +1,57 @@ +package network.packets.swg.zone.chat; + +import java.nio.ByteBuffer; + +import network.packets.swg.SWGPacket; + +public class ChatOnLeaveRoom extends SWGPacket { + + public static final int CRC = 0x60B5098B; + + private String galaxyName; + private String characterName; + private int errorCode; + private int chatRoomId; + private int requestId; + + public ChatOnLeaveRoom() { + this("", "", 0, 0, 0); + } + + public ChatOnLeaveRoom(String galaxy, String character, int errorCode, int chatRoomId, int requestId) { + this.galaxyName = galaxy; + this.characterName = character; + this.errorCode = errorCode; + this.chatRoomId = chatRoomId; + this.requestId = requestId; + } + + public ChatOnLeaveRoom(ByteBuffer data) { + decode(data); + } + + public void decode(ByteBuffer data) { + if (!super.decode(data, CRC)) + return; + getAscii(data); + galaxyName = getAscii(data); + characterName = getAscii(data); + errorCode = getInt(data); + chatRoomId = getInt(data); + requestId = getInt(data); + } + + public ByteBuffer encode() { + ByteBuffer data = ByteBuffer.allocate(27+galaxyName.length()+characterName.length()); + addShort(data, 2); + addInt( data, CRC); + addAscii(data, "SWG"); + addAscii(data, galaxyName); + addAscii(data, characterName); + addInt (data, errorCode); + addInt (data, chatRoomId); + addInt (data, requestId); + return data; + } + +} diff --git a/src/network/packets/swg/zone/chat/ChatOnReceiveRoomInvitation.java b/src/network/packets/swg/zone/chat/ChatOnReceiveRoomInvitation.java new file mode 100644 index 000000000..6b9b52ff6 --- /dev/null +++ b/src/network/packets/swg/zone/chat/ChatOnReceiveRoomInvitation.java @@ -0,0 +1,35 @@ +package network.packets.swg.zone.chat; + +import java.nio.ByteBuffer; + +import network.packets.swg.SWGPacket; + +public class ChatOnReceiveRoomInvitation extends SWGPacket { + + public static final int CRC = 0xC17EB06D; + + public ChatOnReceiveRoomInvitation() { + + } + + public ChatOnReceiveRoomInvitation(String command) { + + } + + public ChatOnReceiveRoomInvitation(ByteBuffer data) { + decode(data); + } + + public void decode(ByteBuffer data) { + if (!super.decode(data, CRC)) + return; + } + + public ByteBuffer encode() { + ByteBuffer data = ByteBuffer.allocate(6); + addShort(data, 2); + addInt (data, CRC); + return data; + } + +} diff --git a/src/network/packets/swg/zone/chat/ChatOnSendInstantMessage.java b/src/network/packets/swg/zone/chat/ChatOnSendInstantMessage.java new file mode 100644 index 000000000..91cfabe37 --- /dev/null +++ b/src/network/packets/swg/zone/chat/ChatOnSendInstantMessage.java @@ -0,0 +1,43 @@ +package network.packets.swg.zone.chat; + +import java.nio.ByteBuffer; + +import network.packets.swg.SWGPacket; + +public class ChatOnSendInstantMessage extends SWGPacket { + + public static final int CRC = 0x88DBB381; + + private int errorCode; + private int count; + + public ChatOnSendInstantMessage() { + this(0, 0); + } + + public ChatOnSendInstantMessage(int errorCode, int count) { + this.errorCode = errorCode; + this.count = count; + } + + public ChatOnSendInstantMessage(ByteBuffer data) { + decode(data); + } + + public void decode(ByteBuffer data) { + if (!super.decode(data, CRC)) + return; + errorCode = getInt(data); + count = getInt(data); + } + + public ByteBuffer encode() { + ByteBuffer data = ByteBuffer.allocate(14); + addShort(data, 2); + addInt (data, CRC); + addInt (data, errorCode); + addInt (data, count); + return data; + } + +} diff --git a/src/network/packets/swg/zone/chat/ChatOnSendRoomMessage.java b/src/network/packets/swg/zone/chat/ChatOnSendRoomMessage.java new file mode 100644 index 000000000..0a15dd1ca --- /dev/null +++ b/src/network/packets/swg/zone/chat/ChatOnSendRoomMessage.java @@ -0,0 +1,38 @@ +package network.packets.swg.zone.chat; + +import java.nio.ByteBuffer; + +import network.packets.swg.SWGPacket; + +public class ChatOnSendRoomMessage extends SWGPacket { + + public static final int CRC = 0xE7B61633; + private int error = 0; + private int messageId = 0; + + public ChatOnSendRoomMessage() { + + } + + public ChatOnSendRoomMessage(int error, int messageId) { + this.error = error; + this.messageId = messageId; + } + + public void decode(ByteBuffer data) { + if (!super.decode(data, CRC)) + return; + error = getInt(data); + messageId = getInt(data); + } + + public ByteBuffer encode() { + int length = 14; + ByteBuffer data = ByteBuffer.allocate(length); + addShort(data, 3); + addInt( data, CRC); + addInt( data, error); + addInt( data, messageId); + return data; + } +} diff --git a/src/network/packets/swg/zone/chat/ChatPersistentMessageToClient.java b/src/network/packets/swg/zone/chat/ChatPersistentMessageToClient.java new file mode 100644 index 000000000..87958a040 --- /dev/null +++ b/src/network/packets/swg/zone/chat/ChatPersistentMessageToClient.java @@ -0,0 +1,330 @@ +package network.packets.swg.zone.chat; + +import java.nio.ByteBuffer; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +import resources.Planet; +import network.packets.swg.SWGPacket; + +public class ChatPersistentMessageToClient extends SWGPacket { + + public static final int CRC = 0x08485E17; + + private String senderName; + private String galaxy; + private int mailId; + private byte type; + private String subject; + private String message; + private List waypointAttachments; + private List proseAttachments; + private byte status; + private int timestamp; + + public ChatPersistentMessageToClient() { + senderName = ""; + galaxy = ""; + mailId = 0; + type = 0; + subject = ""; + message = ""; + waypointAttachments = new ArrayList(); + proseAttachments = new ArrayList(); + status = 0; + timestamp = 0; + } + + public ChatPersistentMessageToClient(ByteBuffer data) { + decode(data); + } + + public void decode(ByteBuffer data) { + if (!super.decode(data, CRC)) + return; + senderName = getAscii(data); + getAscii(data); // SWG + galaxy = getAscii(data); + mailId = getInt(data); + type = getByte(data); + + if (type == 1) { + getInt(data); // 0? + subject = getUnicode(data); + getInt(data); + } else { + message = getUnicode(data); + subject = getUnicode(data); + int size = getInt(data) * 2; + int start = data.position(); + do { + getShort(data); // 0? + byte type = getByte(data); + getInt(data); // Integer version of the type, it seems + if (type == 4) + waypointAttachments.add(WaypointAttachment.deserialize(data)); + else if (type == 1) + proseAttachments.add(ProseAttachment.deserialize(data)); + else { + System.err.println("Invalid type supplied in ChatPersistentMessageToClient.decode"); + break; + } + } while (data.position() - start < size); + } + status = getByte(data); + timestamp = getInt(data); + } + + public ByteBuffer encode() { + int extraSize = 0; + if (type == 1) { + extraSize += 12 + subject.length()*2; + } else { + extraSize += 12 + message.length()*2 + subject.length()*2; + for (WaypointAttachment waypoint : waypointAttachments) + extraSize += 7 + waypoint.getSerializableSize(); + for (ProseAttachment prose : proseAttachments) + extraSize += 7 + prose.getSerializableSize(); + } + ByteBuffer data = ByteBuffer.allocate(25 + extraSize); + addShort(data, 2); + addInt( data, CRC); + addAscii(data, senderName); + addAscii(data, "SWG"); + addAscii(data, galaxy); + addInt(data, mailId); + addByte(data, type); + + if (type == 1) { + addInt(data, 0); + addUnicode(data, subject); + addInt(data, 0); + } else { + addUnicode(data, message); + addUnicode(data, subject); + addInt(data, extraSize / 2); + for (WaypointAttachment waypoint : waypointAttachments) { + addShort(data, 0); + addByte(data, 4); + addInt(data, 0xFFFFFFFD); + waypoint.serialize(data); + } + for (ProseAttachment prose : proseAttachments) { + addShort(data, 0); + addByte(data, 1); + addInt(data, 0xFFFFFFFF); + prose.serialize(data); + } + } + addByte(data, status); + addInt(data, timestamp); + return data; + } + + public void setSenderName(String senderName) { + this.senderName = senderName; + } + + public void setGalaxy(String galaxy) { + this.galaxy = galaxy; + } + + public void setMailId(int mailId) { + this.mailId = mailId; + } + + public void setType(byte type) { + this.type = type; + } + + public void setSubject(String subject) { + this.subject = subject; + } + + public void setMessage(String message) { + this.message = message; + } + + public void addWaypoint(WaypointAttachment waypoint) { + waypointAttachments.add(waypoint); + } + + public void addAllWaypoints(Collection waypoints) { + waypointAttachments.addAll(waypoints); + } + + public void addProse(ProseAttachment prose) { + proseAttachments.add(prose); + } + + public void addAllProses(Collection proses) { + proseAttachments.addAll(proses); + } + + public void setStatus(byte status) { + this.status = status; + } + + public void setTimestamp(int timestamp) { + this.timestamp = timestamp; + } + + public static class WaypointAttachment { + private float x; + private float y; + private float z; + private Planet planet; + private String attachmentName; + private long cellId; + private byte color; + private boolean active; + + public float getX() { return x; } + public float getY() { return y; } + public float getZ() { return z; } + public Planet getPlanet() { return planet; } + public String getAttachmentName() { return attachmentName; } + public long getCellId() { return cellId; } + public byte getColor() { return color; } + public boolean isActive() { return active; } + + public void setX(float x) { this.x = x; } + public void setY(float y) { this.y = y; } + public void setZ(float z) { this.z = z; } + public void setPlanet(Planet p) { this.planet = p; } + public void setAttachmentName(String name) { this.attachmentName = name; } + public void setCellId(long id) { this.cellId = id; } + public void setColor(byte c) { this.color = c; } + public void setActive(boolean active) { this.active = active; } + + private final int getSerializableSize() { + return 43 + attachmentName.length()*2; + } + + private static final WaypointAttachment deserialize(ByteBuffer data) { + WaypointAttachment waypoint = new WaypointAttachment(); + getInt(data); // 0? + waypoint.setX(getFloat(data)); + waypoint.setY(getFloat(data)); + waypoint.setZ(getFloat(data)); + getLong(data); // 0? + waypoint.setPlanet(Planet.getPlanetFromCrc(getInt(data))); + waypoint.setAttachmentName(getUnicode(data)); + waypoint.setCellId(getLong(data)); + waypoint.setColor(getByte(data)); + waypoint.setActive(getBoolean(data)); + getByte(data); // 0? + return waypoint; + } + + private final void serialize(ByteBuffer data) { + addInt (data, 0); + addFloat (data, getX()); + addFloat (data, getY()); + addFloat (data, getZ()); + addLong (data, 0); + addInt (data, planet.getCrc()); + addUnicode(data, attachmentName); + addLong (data, cellId); + addByte (data, color); + addBoolean(data, active); + addByte (data, 0); + } + } + + public static class ProseAttachment { + private String stf; + private ProseSegment tu; + private ProseSegment tt; + private ProseSegment to; + private int diInt; + private float dfFloat; + + public String getSTF() { return stf; } + public ProseSegment getTu() { return tu; } + public ProseSegment getTt() { return tt; } + public ProseSegment getTo() { return to; } + public int getDiInteger() { return diInt; } + public float getDfFloat() { return dfFloat; } + + public void setSTF(String stf) { this.stf = stf; } + public void setTu(ProseSegment tu) { this.tu = tu; } + public void setTt(ProseSegment tt) { this.tt = tt; } + public void setTo(ProseSegment to) { this.to = to; } + public void setDiInteger(int di) { this.diInt = di; } + public void setDfFloat(float df) { this.dfFloat = df; } + + private final int getSerializableSize() { + return 10 + stf.length() + tu.getSerializableSize() + tt.getSerializableSize() + to.getSerializableSize(); + } + + private static final ProseAttachment deserialize(ByteBuffer data) { + ProseAttachment prose = new ProseAttachment(); + prose.setSTF(getAscii(data)); + prose.setTu(ProseSegment.deserialize(data)); + prose.setTt(ProseSegment.deserialize(data)); + prose.setTo(ProseSegment.deserialize(data)); + prose.setDiInteger(getInt(data)); + prose.setDfFloat(getFloat(data)); + return prose; + } + + private final void serialize(ByteBuffer data) { + addAscii(data, stf); + tu.serialize(data); + tt.serialize(data); + to.serialize(data); + addInt(data, diInt); + addFloat(data, dfFloat); + } + + public static class ProseSegment { + private long objectId; + private String stf; + private String customString; + + public long getObjectId() { return objectId; } + public String getSTF() { return stf; } + public String getCustomString() { return customString; } + + public void setObjectId(long id) { this.objectId = id; } + public void setSTF(String stf) { this.stf = stf; } + public void setCustomString(String custom) { this.customString = custom; } + + private final int getSerializableSize() { + return 14 + stf.length() + customString.length()*2; + } + + private static final ProseSegment deserialize(ByteBuffer data) { + ProseSegment segment = new ProseSegment(); + segment.setObjectId(getLong(data)); + segment.setSTF(getAscii(data)); + segment.setCustomString(getUnicode(data)); + return segment; + } + + private final void serialize(ByteBuffer data) { + addLong(data, objectId); + addAscii(data, stf); + addUnicode(data, customString); + } + } + } + /* + * ASCII Stf + * LONG TuObjectId + * ASCII TuStf + * UNICODE TuCustomString + * LONG TtObjectId + * ASCII TtStf + * UNICODE TtCustomString + * LONG ToObjectId + * ASCII ToStf + * UNICODE ToCustomString + * INT DiInteger + * FLOAT DfFloat + * BYTE 0 + */ + +} diff --git a/src/network/packets/swg/zone/chat/ChatRoomMessage.java b/src/network/packets/swg/zone/chat/ChatRoomMessage.java new file mode 100644 index 000000000..d74def7ae --- /dev/null +++ b/src/network/packets/swg/zone/chat/ChatRoomMessage.java @@ -0,0 +1,51 @@ +package network.packets.swg.zone.chat; + +import java.nio.ByteBuffer; + +import network.packets.swg.SWGPacket; +import network.packets.swg.zone.insertion.ChatRoomList.ChatRoom.User; + +public class ChatRoomMessage extends SWGPacket { + + public static final int CRC = 0xCD4CE444; + private User user = new User(); + private int roomId = 0; + private String message = ""; + + public ChatRoomMessage() { + + } + + public ChatRoomMessage(String game, String server, String name, int roomId, String message) { + this.user.game = game; + this.user.server = server; + this.user.name = name; + this.roomId = roomId; + this.message = message; + } + + public void decode(ByteBuffer data) { + if (!super.decode(data, CRC)) + return; + user.game = getAscii(data); + user.server = getAscii(data); + user.name = getAscii(data); + roomId = getInt(data); + message = getUnicode(data); + getUnicode(data); + } + + public ByteBuffer encode() { + int length = 24 + user.game.length() + user.server.length() + user.name.length() + message.length() * 2; + ByteBuffer data = ByteBuffer.allocate(length); + addShort( data, 5); + addInt( data, CRC); + addAscii( data, user.game); + addAscii( data, user.server); + addAscii( data, user.name); + addInt( data, roomId); + addUnicode(data, message); + addUnicode(data, ""); + return data; + } +} diff --git a/src/network/packets/swg/zone/chat/ChatSystemMessage.java b/src/network/packets/swg/zone/chat/ChatSystemMessage.java new file mode 100644 index 000000000..610edfd38 --- /dev/null +++ b/src/network/packets/swg/zone/chat/ChatSystemMessage.java @@ -0,0 +1,58 @@ +package network.packets.swg.zone.chat; + +import java.nio.ByteBuffer; + +import network.packets.swg.SWGPacket; + +public class ChatSystemMessage extends SWGPacket { + + public static final int CRC = 0x6D2A6413; + private int type = 0; + private String message = ""; + + public ChatSystemMessage() { + + } + + public ChatSystemMessage(int type, String message) { + this.type = type; + this.message = message; + } + + public ChatSystemMessage(SystemChatType type, String message) { + this(type.ordinal(), message); + } + + public void decode(ByteBuffer data) { + if (!super.decode(data, CRC)) + return; + type = getByte(data); + message = getUnicode(data); + getUnicode(data); + } + + public ByteBuffer encode() { + int length = 15 + message.length() * 2; + ByteBuffer data = ByteBuffer.allocate(length); + addShort( data, 4); + addInt( data, CRC); + addByte( data, type); + addUnicode(data, message); + addUnicode(data, ""); + return data; + } + + public SystemChatType getType() { + for (SystemChatType t : SystemChatType.values()) { + if (type == t.ordinal()) return t; + } + return SystemChatType.SCREEN_AND_CHAT; + } + public String getMessage() { return message; } + + public enum SystemChatType { + SCREEN_AND_CHAT, + SCREEN, + CHAT + } +} diff --git a/src/network/packets/swg/zone/chat/ConGenericMessage.java b/src/network/packets/swg/zone/chat/ConGenericMessage.java new file mode 100644 index 000000000..dbd0024c9 --- /dev/null +++ b/src/network/packets/swg/zone/chat/ConGenericMessage.java @@ -0,0 +1,41 @@ +package network.packets.swg.zone.chat; + +import java.nio.ByteBuffer; + +import network.packets.swg.SWGPacket; + +public class ConGenericMessage extends SWGPacket { + + public static final int CRC = 0x08C5FC76; + + private String message; + + public ConGenericMessage() { + this(""); + } + + public ConGenericMessage(String message) { + this.message = message; + } + + public ConGenericMessage(ByteBuffer data) { + decode(data); + } + + public void decode(ByteBuffer data) { + if (!super.decode(data, CRC)) + return; + message = getAscii(data); + getInt(data); + } + + public ByteBuffer encode() { + ByteBuffer data = ByteBuffer.allocate(8 + message.length()); + addShort(data, 3); + addInt (data, CRC); + addAscii(data, message); + addInt (data, 0); + return data; + } + +} diff --git a/src/network/packets/swg/zone/chat/VoiceChatStatus.java b/src/network/packets/swg/zone/chat/VoiceChatStatus.java new file mode 100644 index 000000000..1854db46a --- /dev/null +++ b/src/network/packets/swg/zone/chat/VoiceChatStatus.java @@ -0,0 +1,33 @@ +package network.packets.swg.zone.chat; + +import java.nio.ByteBuffer; + +import network.packets.swg.SWGPacket; + +public class VoiceChatStatus extends SWGPacket { + + public static final int CRC = 0x9E601905; + + public VoiceChatStatus() { + + } + + public VoiceChatStatus(ByteBuffer data) { + decode(data); + } + + public void decode(ByteBuffer data) { + if (!super.decode(data, CRC)) + return; + getInt(data); + } + + public ByteBuffer encode() { + ByteBuffer data = ByteBuffer.allocate(6); + addShort(data, 2); + addInt (data, CRC); + addInt (data, 1); + return data; + } + +} diff --git a/src/network/packets/swg/zone/combat/GrantCommandMessage.java b/src/network/packets/swg/zone/combat/GrantCommandMessage.java new file mode 100644 index 000000000..4e16271cb --- /dev/null +++ b/src/network/packets/swg/zone/combat/GrantCommandMessage.java @@ -0,0 +1,47 @@ +package network.packets.swg.zone.combat; + +import java.nio.ByteBuffer; + +import network.packets.swg.SWGPacket; + +public class GrantCommandMessage extends SWGPacket { + + public static final int CRC = 0xE67E3875; + + private String command; + + public GrantCommandMessage() { + command = ""; + } + + public GrantCommandMessage(String command) { + this.command = command; + } + + public GrantCommandMessage(ByteBuffer data) { + decode(data); + } + + public void decode(ByteBuffer data) { + if (!super.decode(data, CRC)) + return; + this.command = getAscii(data); + } + + public ByteBuffer encode() { + ByteBuffer data = ByteBuffer.allocate(8 + command.length()); + addShort(data, 2); + addInt( data, CRC); + addAscii(data, command); + return data; + } + + public String getCommand() { + return command; + } + + public void setCommand(String command) { + this.command = command; + } + +} diff --git a/src/network/packets/swg/zone/deltas/DeltasMessage.java b/src/network/packets/swg/zone/deltas/DeltasMessage.java new file mode 100644 index 000000000..02d1c2166 --- /dev/null +++ b/src/network/packets/swg/zone/deltas/DeltasMessage.java @@ -0,0 +1,63 @@ +package network.packets.swg.zone.deltas; + +import java.nio.ByteBuffer; + +import network.packets.swg.SWGPacket; +import network.packets.swg.zone.baselines.Baseline.BaselineType; + +public class DeltasMessage extends SWGPacket { + + public static final int CRC = 0x12862153; + + private long objId; + private BaselineType type; + private int num; + private byte [] data; + + public DeltasMessage() { + this(0, 0, (byte)0, new byte[0]); + } + + public DeltasMessage(long objId, int type, byte typeNumber, byte [] data) { + + } + + public DeltasMessage(ByteBuffer data) { + decode(data); + } + + public void decode(ByteBuffer data) { + if (!super.decode(data, CRC)) + return; + objId = getLong(data); + byte [] str = new byte[4]; data.get(str); + String strType = new StringBuffer(new String(str, ascii)).reverse().toString(); + for (BaselineType baseType : BaselineType.values()) + if (baseType.toString().equals(strType)) + type = baseType; + num = getByte(data); + int length = getInt(data); + this.data = getArray(data, length); + } + + public ByteBuffer encode() { + ByteBuffer data = ByteBuffer.allocate(23 + this.data.length); + addShort(data, 2); + addInt( data, CRC); + addLong(data, objId); + data.put(new StringBuffer(type.toString()).reverse().toString().getBytes(ascii)); + addByte(data, num); + addInt(data, this.data.length); + data.put(data); + return data; + } + + public long getObjectId() { return objId; } + public BaselineType getType() { return type; } + public int getNum() { return num; } + + public void setType(BaselineType type) { this.type = type; } + public void setNum(int num) { this.num = num; } + public void setId(long id) { this.objId = id; } + +} diff --git a/src/network/packets/swg/zone/insertion/ChatRoomList.java b/src/network/packets/swg/zone/insertion/ChatRoomList.java new file mode 100644 index 000000000..6a06628b4 --- /dev/null +++ b/src/network/packets/swg/zone/insertion/ChatRoomList.java @@ -0,0 +1,209 @@ +package network.packets.swg.zone.insertion; + +import java.nio.ByteBuffer; +import java.util.ArrayList; +import java.util.List; +import java.util.Vector; + +import network.packets.swg.SWGPacket; +import network.packets.swg.zone.insertion.ChatRoomList.ChatRoom.User; + +public class ChatRoomList extends SWGPacket { + + public static final int CRC = 0x70DEB197; + private List chatrooms = new ArrayList(); + + public ChatRoomList() { + + } + + public ChatRoomList(ChatRoom room) { + chatrooms.add(room); + } + + public ChatRoomList(ChatRoom [] rooms) { + for (ChatRoom r : rooms) { + chatrooms.add(r); + } + } + + public void addChatRoom(ChatRoom r) { + chatrooms.add(r); + } + + public void decode(ByteBuffer data) { + if (!super.decode(data, CRC)) + return; + int chatroomCount = getInt(data); + for (int i = 0; i < chatroomCount; i++) { + ChatRoom room = new ChatRoom(); + room.setRoomId(getInt(data)); + room.setPrivateFlag(getInt(data)); + room.setModeratedFlag(getByte(data)); + room.setRoomPathName(getAscii(data)); + room.setGame(getAscii(data)); + room.setServer(getAscii(data)); + room.setOwner(getAscii(data)); + getAscii(data); // SWG + getAscii(data); // galaxy + room.setCreator(getAscii(data)); + room.setTitle(getUnicode(data)); + int moderatorCount = getInt(data); + for (int m = 0; m < moderatorCount; m++) { + User user = new User(); + user.setGame(getAscii(data)); + user.setServer(getAscii(data)); + user.setName(getAscii(data)); + room.addModerator(user); + } + int userCount = getInt(data); + for (int u = 0; u < userCount; u++) { + User user = new User(); + user.setGame(getAscii(data)); + user.setServer(getAscii(data)); + user.setName(getAscii(data)); + room.addUser(user); + } + } + } + + public ByteBuffer encode() { + int length = 10; + for (ChatRoom r : chatrooms) { + length += r.getSize(); + } + ByteBuffer data = ByteBuffer.allocate(length); + addShort(data, 2); + addInt( data, CRC); + addInt( data, chatrooms.size()); + for (ChatRoom r : chatrooms) { + addInt(data, r.getRoomId()); + addInt(data, r.getPrivateFlag()); + addByte(data, r.getModeratedFlag()); + addAscii(data, r.getRoomPathName()); + addAscii(data, r.getGame()); + addAscii(data, r.getServer()); + addAscii(data, r.getOwner()); + addAscii(data, r.getCreator()); + addUnicode(data, r.getTitle()); + addInt(data, r.getModerators().size()); + for (User u : r.getModerators()) { + addAscii(data, u.game); + addAscii(data, u.server); + addAscii(data, u.name); + } + addInt(data, r.getUsers().size()); + for (User u : r.getUsers()) { + addAscii(data, u.game); + addAscii(data, u.server); + addAscii(data, u.name); + } + } + return data; + } + + public static class ChatRoom { + private int roomId = 0; + private int privateFlag = 0; + private int moderatedFlag = 0; + private String roomPathName = ""; + private String game = ""; + private String server = ""; + private String owner = ""; + private String creator = ""; + private String title = ""; + private Vector moderators = new Vector(); + private Vector users = new Vector(); + + public ChatRoom() { + + } + + public ChatRoom(int roomId, int privateFlag, int moderatedFlag, String roomPathName, String game, String server, String owner, String creator, String title) { + this.roomId = roomId; + this.privateFlag = privateFlag; + this.moderatedFlag = moderatedFlag; + this.roomPathName = roomPathName; + this.game = game; + this.server = server; + this.owner = owner; + this.creator = creator; + this.title = title; + } + + public void addModerator(String game, String server, String name) { + moderators.add(new User(game, server, name)); + } + + public void addUser(String game, String server, String name) { + users.add(new User(game, server, name)); + } + + public int getSize() { + int length = 31; + length += roomPathName.length(); + length += game.length(); + length += server.length(); + length += owner.length(); + length += creator.length(); + length += title.length() * 2; + for (User u : moderators) length += u.getSize(); + for (User u : users) length += u.getSize(); + return length; + } + + public int getRoomId() { return roomId; } + public int getPrivateFlag() { return privateFlag; } + public int getModeratedFlag() { return moderatedFlag; } + public String getRoomPathName() { return roomPathName; } + public String getGame() { return game; } + public String getServer() { return server; } + public String getOwner() { return owner; } + public String getCreator() { return creator; } + public String getTitle() { return title; } + public List getUsers() { return users; } + public List getModerators() { return moderators; } + + public void setRoomId(int id) { this.roomId = id; } + public void setPrivateFlag(int flag) { this.privateFlag = flag; } + public void setModeratedFlag(int flag) { this.moderatedFlag = flag; } + public void setRoomPathName(String path) { this.roomPathName = path; } + public void setGame(String game) { this.game = game; } + public void setServer(String server) { this.server = server; } + public void setOwner(String owner) { this.owner = owner; } + public void setCreator(String creator) { this.creator = creator; } + public void setTitle(String title) { this.title = title; } + public void setUsers(Vector users) { this.users = users; } + public void setModerators(Vector moderators) { this.moderators = moderators; } + public void addUser(User user) { this.users.add(user); } + public void addModerator(User moderator) { this.moderators.add(moderator); } + + public static class User { + public String game = ""; + public String server = ""; + public String name = ""; + + public User() { + + } + + public User(String game, String server, String name) { + this.game = game; + this.server = server; + this.name = name; + } + + public int getSize() { + return 6 + game.length() + server.length() + name.length(); + } + + public String getGame() { return game; } + public String getServer() { return server; } + public String getName() { return name; } + + public void setGame(String game) { this.game = game; } + public void setServer(String server) { this.server = server; } + public void setName(String name) { this.name = name; } + } + } +} diff --git a/src/network/packets/swg/zone/insertion/ChatServerStatus.java b/src/network/packets/swg/zone/insertion/ChatServerStatus.java new file mode 100644 index 000000000..2de5520aa --- /dev/null +++ b/src/network/packets/swg/zone/insertion/ChatServerStatus.java @@ -0,0 +1,34 @@ +package network.packets.swg.zone.insertion; + +import java.nio.ByteBuffer; + +import network.packets.swg.SWGPacket; + +public class ChatServerStatus extends SWGPacket { + + public static final int CRC = 0x7102B15F; + private boolean online = false; + + public ChatServerStatus() { + + } + + public ChatServerStatus(boolean online) { + this.online = online; + } + + public void decode(ByteBuffer data) { + if (!super.decode(data, CRC)) + return; + online = getBoolean(data); + } + + public ByteBuffer encode() { + int length = 7; + ByteBuffer data = ByteBuffer.allocate(length); + addShort( data, 2); + addInt( data, CRC); + addBoolean(data, online); + return data; + } +} diff --git a/src/network/packets/swg/zone/insertion/CmdStartScene.java b/src/network/packets/swg/zone/insertion/CmdStartScene.java new file mode 100644 index 000000000..027eb1429 --- /dev/null +++ b/src/network/packets/swg/zone/insertion/CmdStartScene.java @@ -0,0 +1,76 @@ +package network.packets.swg.zone.insertion; + +import java.nio.ByteBuffer; + +import resources.Location; +import resources.Race; +import network.packets.swg.SWGPacket; + +public class CmdStartScene extends SWGPacket { + + public static final int CRC = 0x3AE6DFAE; + + private boolean ignoreLayoutFiles; + private long charId; + private String terrain; + private Race race; + private Location l; + private long galacticTime; + + public CmdStartScene() { + ignoreLayoutFiles = false; + charId = 0; + terrain = ""; + race = Race.HUMAN; + l = new Location(); + galacticTime = 0; + } + + public CmdStartScene(boolean ignoreLayoutFiles, long charId, String terrain, String race, Location l, long galacticTime) { + this.ignoreLayoutFiles = ignoreLayoutFiles; + this.charId = charId; + this.terrain = terrain; + this.race = Race.HUMAN; + this.l = l; + this.galacticTime = galacticTime; + } + + public void decode(ByteBuffer data) { + if (!super.decode(data, CRC)) + return; + ignoreLayoutFiles = getBoolean(data); + charId = getLong(data); + terrain = getAscii(data); + l.setX(getFloat(data)); + l.setY(getFloat(data)); + l.setZ(getFloat(data)); + getFloat(data); + race = Race.getRace(getAscii(data)); + galacticTime = getLong(data); + getInt(data); // 0x8EB5EA4E + } + + public ByteBuffer encode() { + int length = 47 + terrain.length() + race.getIFF().length(); + ByteBuffer data = ByteBuffer.allocate(length); + addShort( data, 2); + addInt( data, CRC); + addBoolean(data, ignoreLayoutFiles); + addLong( data, charId); + addAscii( data, terrain); + addFloat( data, l.getX()); + addFloat( data, l.getY()); + addFloat( data, l.getZ()); + addFloat( data, 0); + addAscii( data, race.getIFF()); + addLong( data, galacticTime); + addInt (data, 0x8EB5EA4E); + return data; + } + + public long getCharacterId() { return charId; } + public String getTerrain() { return terrain; } + public Location getLocation() { return l; } + public Race getRace() { return race; } + public long getGalacticTime() { return galacticTime; } +} diff --git a/src/network/packets/swg/zone/insertion/ConnectPlayerMessage.java b/src/network/packets/swg/zone/insertion/ConnectPlayerMessage.java new file mode 100644 index 000000000..e95efcdaa --- /dev/null +++ b/src/network/packets/swg/zone/insertion/ConnectPlayerMessage.java @@ -0,0 +1,28 @@ +package network.packets.swg.zone.insertion; + +import java.nio.ByteBuffer; + +import network.packets.swg.SWGPacket; + +public class ConnectPlayerMessage extends SWGPacket { + + public static final int CRC = 0x2E365218; + + public ConnectPlayerMessage() { + + } + + public void decode(ByteBuffer data) { + if (!super.decode(data, CRC)) + return; + } + + public ByteBuffer encode() { + int length = 10; + ByteBuffer data = ByteBuffer.allocate(length); + addShort(data, 2); + addInt( data, CRC); + addInt( data, 0); + return data; + } +} diff --git a/src/network/packets/swg/zone/insertion/SelectCharacter.java b/src/network/packets/swg/zone/insertion/SelectCharacter.java new file mode 100644 index 000000000..42f0cfa0d --- /dev/null +++ b/src/network/packets/swg/zone/insertion/SelectCharacter.java @@ -0,0 +1,36 @@ +package network.packets.swg.zone.insertion; + +import java.nio.ByteBuffer; + +import network.packets.swg.SWGPacket; + +public class SelectCharacter extends SWGPacket { + + public static final int CRC = 0xB5098D76; + + private long charId = 0; + + public SelectCharacter() { + + } + + public SelectCharacter(long id) { + this.charId = id; + } + + public void decode(ByteBuffer data) { + if (!super.decode(data, CRC)) + return; + charId = getLong(data); + } + + public ByteBuffer encode() { + ByteBuffer data = ByteBuffer.allocate(14); + addShort(data, 2); + addInt( data, CRC); + addLong( data, charId); + return data; + } + + public long getCharacterId() { return charId; } +} diff --git a/src/network/packets/swg/zone/object_controller/CommandQueueDequeue.java b/src/network/packets/swg/zone/object_controller/CommandQueueDequeue.java new file mode 100644 index 000000000..f325f6049 --- /dev/null +++ b/src/network/packets/swg/zone/object_controller/CommandQueueDequeue.java @@ -0,0 +1,54 @@ +package network.packets.swg.zone.object_controller; + +import java.nio.ByteBuffer; + + +public class CommandQueueDequeue extends ObjectController { + + public static final int CRC = 0x0117; + private int counter; + private float timer; + private int error; + private int action; + + public CommandQueueDequeue() { + + } + + public CommandQueueDequeue(ByteBuffer data) { + decodeAsObjectController(data); + } + + public void decodeAsObjectController(ByteBuffer data) { + counter = getInt(data); + timer = getFloat(data); + error = getInt(data); + action = getInt(data); + } + + public ByteBuffer encodeAsObjectController() { + ByteBuffer data = ByteBuffer.allocate(16); + addInt(data, counter); + addFloat(data, timer); + addInt(data, error); + addInt(data, action); + return data; + } + + public int getCounter() { + return counter; + } + + public float getTimer() { + return timer; + } + + public int getError() { + return error; + } + + public int getAction() { + return action; + } + +} diff --git a/src/network/packets/swg/zone/object_controller/CommandQueueEnqueue.java b/src/network/packets/swg/zone/object_controller/CommandQueueEnqueue.java new file mode 100644 index 000000000..7a9590dd3 --- /dev/null +++ b/src/network/packets/swg/zone/object_controller/CommandQueueEnqueue.java @@ -0,0 +1,39 @@ +package network.packets.swg.zone.object_controller; + +import java.nio.ByteBuffer; + + +public class CommandQueueEnqueue extends ObjectController { + + public static final int CRC = 0x0116; + private int counter = 0; + private int crc = 0; + private long targetId = 0; + private String arguments = ""; + + public CommandQueueEnqueue() { + + } + + public CommandQueueEnqueue(ByteBuffer data) { + decodeAsObjectController(data); + } + + public void decodeAsObjectController(ByteBuffer data) { + counter = getInt(data); + crc = getInt(data); + targetId = getLong(data); + arguments = getUnicode(data); + } + + public ByteBuffer encodeAsObjectController() { + int length = 20 + arguments.length() * 2; + ByteBuffer data = ByteBuffer.allocate(length); + addInt(data, counter); + addInt(data, crc); + addLong(data, targetId); + addUnicode(data, arguments); + return data; + } + +} diff --git a/src/network/packets/swg/zone/object_controller/DataTransform.java b/src/network/packets/swg/zone/object_controller/DataTransform.java new file mode 100644 index 000000000..112e718db --- /dev/null +++ b/src/network/packets/swg/zone/object_controller/DataTransform.java @@ -0,0 +1,47 @@ +package network.packets.swg.zone.object_controller; + +import java.nio.ByteBuffer; + +import resources.Location; + + +public class DataTransform extends ObjectController{ + + public static final int CRC = 0x0071; + private int updateCounter = 0; + private Location l; + private float speed = 0; + + public DataTransform() { + l = new Location(); + } + + public DataTransform(Location l) { + this.l = l; + } + + public DataTransform(ByteBuffer data) { + decodeAsObjectController(data); + } + + public void decodeAsObjectController(ByteBuffer data) { + getInt(data); + getInt(data); + updateCounter = getInt(data); + l = getLocation(data); + speed = getFloat(data); + } + + public ByteBuffer encodeAsObjectController() { + int length = 36; + ByteBuffer data = ByteBuffer.allocate(length); + addInt(data, updateCounter); + addLocation(data, l); + addFloat(data, speed); + return data; + } + + public int getUpdateCounter() { return updateCounter; } + public Location getLocation() { return l; } + public float getSpeed() { return speed; } +} diff --git a/src/network/packets/swg/zone/object_controller/ObjectController.java b/src/network/packets/swg/zone/object_controller/ObjectController.java new file mode 100644 index 000000000..706d8c0b6 --- /dev/null +++ b/src/network/packets/swg/zone/object_controller/ObjectController.java @@ -0,0 +1,68 @@ +package network.packets.swg.zone.object_controller; + +import java.nio.ByteBuffer; + +import network.packets.swg.SWGPacket; + +public class ObjectController extends SWGPacket { + + public static final int CRC = 0x80CE5E46; + + private int header2 = 0; + private int update = 0; + private long objId = 0; + private ObjectController obj; + + public ObjectController() { + + } + + public ObjectController(int header, long objId, ObjectController obj) { + this.header2 = header; + this.objId = objId; + this.obj = obj; + } + + public void decode(ByteBuffer data) { + if (!super.decode(data, CRC)) + return; + update = getInt(data); + header2 = getInt(data); + objId = getLong(data); + getInt(data); + byte [] rData = new byte[data.remaining()]; + data.get(rData); + getDecodingObject(objId, header2, ByteBuffer.wrap(rData)); + } + + public ByteBuffer encode() { + byte [] objData = obj.encodeAsObjectController().array(); + int length = 26 + objData.length; + ByteBuffer data = ByteBuffer.allocate(length); + addShort(data, 2); + addInt( data, CRC); + addInt (data, update); + addInt( data, header2); + addLong( data, objId); + addInt( data, 0); + data.put(objData); + return data; + } + + private void getDecodingObject(long id, int header, ByteBuffer data) { + String hex = new String(Integer.toHexString(header)).toUpperCase(); + obj = null; + switch (header) { + case 0x00000071: obj = new DataTransform(data); break; + case 0x00000116: obj = new CommandQueueEnqueue(data); break; + case 0x00000117: obj = new CommandQueueDequeue(data); break; + case 0x00000131: obj = new PostureUpdate(data); break; +// default: System.out.println("Unprocessed Object Controller: " + header + "[0x" + hex + "]"); break; + } + } + + public ByteBuffer encodeAsObjectController() { return ByteBuffer.allocate(0); } + public void decodeAsObjectController(ByteBuffer data) { } + + public long getObjectId() { return objId; } +} diff --git a/src/network/packets/swg/zone/object_controller/PostureUpdate.java b/src/network/packets/swg/zone/object_controller/PostureUpdate.java new file mode 100644 index 000000000..22c28d639 --- /dev/null +++ b/src/network/packets/swg/zone/object_controller/PostureUpdate.java @@ -0,0 +1,45 @@ +package network.packets.swg.zone.object_controller; + +import java.nio.ByteBuffer; + +import resources.Posture; + +public class PostureUpdate extends ObjectController { + + public static final int CRC = 0x00000131; + + private Posture posture; + + public PostureUpdate() { + this((byte)0); + } + + public PostureUpdate(Posture posture) { + this.posture = posture; + } + + public PostureUpdate(byte posture) { + this.posture = Posture.getFromId(posture); + } + + public PostureUpdate(ByteBuffer data) { + decodeAsObjectController(data); + } + + public void decodeAsObjectController(ByteBuffer data) { + posture = Posture.getFromId(data.get()); + data.get(); + } + + public ByteBuffer encodeAsObjectController() { + ByteBuffer data = ByteBuffer.allocate(2); + data.put(posture.getId()); + data.put((byte)1); + return data; + } + + + public Posture getPosture() { return posture; } + public void setPosture(byte posture) { this.posture = Posture.getFromId(posture); } + public void setPosture(Posture posture) { this.posture = posture; } +} diff --git a/src/network/packets/swg/zone/object_controller/SpatialChat.java b/src/network/packets/swg/zone/object_controller/SpatialChat.java new file mode 100644 index 000000000..e6c47d474 --- /dev/null +++ b/src/network/packets/swg/zone/object_controller/SpatialChat.java @@ -0,0 +1,55 @@ +package network.packets.swg.zone.object_controller; + +import java.nio.ByteBuffer; + + +public class SpatialChat extends ObjectController { + + public static final int CRC = 0x00F4; + private long sourceId = 0; + private long targetId = 0; + private String text = ""; + private int balloonSize = 5; + private int balloonType = 0; + + public SpatialChat() { + + } + + public SpatialChat(long sourceId, long targetId, String text, int balloonType) { + this.sourceId = sourceId; + this.targetId = targetId; + this.text = text; + this.balloonType = balloonType; + } + + public SpatialChat(ByteBuffer data) { + decodeAsObjectController(data); + } + + public void decodeAsObjectController(ByteBuffer data) { + sourceId = getLong(data); + targetId = getLong(data); + text = getUnicode(data); + getInt(data); + balloonSize = getShort(data); + balloonType = getShort(data); + } + + public ByteBuffer encodeAsObjectController() { + int length = 44 + text.length() * 2; + ByteBuffer data = ByteBuffer.allocate(length); + addLong(data, sourceId); + addLong(data, targetId); + addUnicode(data, text); + addInt(data, 0); + addShort(data, balloonSize); + addShort(data, balloonType); + addInt(data, 0); + addInt(data, 0); + addInt(data, 0); + addInt(data, 0); + return data; + } + +} diff --git a/src/network/packets/swg/zone/server_ui/SuiCreatePageMessage.java b/src/network/packets/swg/zone/server_ui/SuiCreatePageMessage.java new file mode 100644 index 000000000..89d6e9571 --- /dev/null +++ b/src/network/packets/swg/zone/server_ui/SuiCreatePageMessage.java @@ -0,0 +1,123 @@ +package network.packets.swg.zone.server_ui; + +import java.nio.ByteBuffer; +import java.util.ArrayList; +import java.util.List; + +import network.packets.swg.SWGPacket; + +public class SuiCreatePageMessage extends SWGPacket { + + public static final int CRC = 0xD44B7259; + + private int windowId; + private String scriptName; + private List components; + private long objectId; + private float maxDistance; + + public SuiCreatePageMessage() { + this(0, "", new ArrayList(), 0, 0); + } + + public SuiCreatePageMessage(int windowId, String scriptName, List components, long objectId, float maxDistance) { + this.windowId = windowId; + this.scriptName = scriptName; + this.components = components; + this.objectId = objectId; + this.maxDistance = maxDistance; + } + + public SuiCreatePageMessage(ByteBuffer data) { + decode(data); + } + + public void decode(ByteBuffer data) { + if (!super.decode(data, CRC)) + return; + windowId = getInt(data); + scriptName = getAscii(data); + int compSize = getInt(data); + components.clear(); + for (int compI = 0; compI < compSize; compI++) { + SuiWindowComponent comp = new SuiWindowComponent(); + comp.setType(getByte(data)); + int wideSize = getInt(data); + for (int wideI = 0; wideI < wideSize; wideI++) + comp.getWideParams().add(getUnicode(data)); + int narrowSize = getInt(data); + for (int narrowI = 0; narrowI < narrowSize; narrowI++) + comp.getNarrowParams().add(getAscii(data)); + components.add(comp); + } + objectId = getLong(data); + maxDistance = getFloat(data); + getLong(data); + getInt(data); + } + + public ByteBuffer encode() { + int extraSize = 0; + for (SuiWindowComponent comp : components) { + extraSize += 9; + for (String s : comp.getWideParams()) + extraSize += 4 + s.length()*2; + for (String s : comp.getNarrowParams()) + extraSize += 2 + s.length(); + } + ByteBuffer data = ByteBuffer.allocate(40+scriptName.length()+extraSize); + addShort(data, 2); + addInt( data, CRC); + addInt (data, windowId); + addAscii(data, scriptName); + addInt (data, components.size()); + for (SuiWindowComponent comp : components) { + addByte(data, comp.getType()); + addInt (data, comp.getWideParams().size()); + for (String wide : comp.getWideParams()) + addUnicode(data, wide); + addInt (data, comp.getNarrowParams().size()); + for (String narrow : comp.getNarrowParams()) + addAscii(data, narrow); + } + addLong (data, objectId); + addFloat(data, maxDistance); + addLong (data, 0); + addInt (data, 0); + return data; + } + + public static class SuiWindowComponent { + + private byte type; + private List narrowParams = new ArrayList(); + private List wideParams = new ArrayList(); + + public byte getType() { + return type; + } + public void setType(byte type) { + this.type = type; + } + public List getNarrowParams() { + return narrowParams; + } + public void setNarrowParams(List narrowParams) { + this.narrowParams = narrowParams; + } + public List getWideParams() { + return wideParams; + } + public void setWideParams(List wideParams) { + this.wideParams = wideParams; + } + public void addNarrowParam(String param) { + narrowParams.add(param); + } + public void addWideParam(String param) { + wideParams.add(param); + } + + } + +} diff --git a/src/network/packets/swg/zone/server_ui/SuiEventNotification.java b/src/network/packets/swg/zone/server_ui/SuiEventNotification.java new file mode 100644 index 000000000..fb2540197 --- /dev/null +++ b/src/network/packets/swg/zone/server_ui/SuiEventNotification.java @@ -0,0 +1,64 @@ +package network.packets.swg.zone.server_ui; + +import java.nio.ByteBuffer; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import network.packets.swg.SWGPacket; + +public class SuiEventNotification extends SWGPacket { + + public static final int CRC = 0x092D3564; + + private int windowId; + private boolean action; + private List dataStrings; + + public SuiEventNotification() { + this(0, false, new String[0]); + } + + public SuiEventNotification(int windowId, boolean action, String [] strings) { + this(windowId, action, new ArrayList(Arrays.asList(strings))); + } + + public SuiEventNotification(int windowId, boolean action, List strings) { + this.windowId = windowId; + this.action = action; + this.dataStrings = strings; + } + + public SuiEventNotification(ByteBuffer data) { + decode(data); + } + + public void decode(ByteBuffer data) { + if (!super.decode(data, CRC)) + return; + windowId = getInt(data); + action = getInt(data) != 0; + int size = getInt(data); + size = getInt(data); // loljk, the size is this + for (int i = 0; i < size; i++) { + dataStrings.add(getUnicode(data)); + } + } + + public ByteBuffer encode() { + int extraSize = 0; + for (String s : dataStrings) + extraSize += 4 + s.length()*2; + ByteBuffer data = ByteBuffer.allocate(22+extraSize); + addShort(data, 2); + addInt (data, CRC); + addInt (data, windowId); + addInt (data, action?0xFFFFFFFF : 0); + addInt (data, dataStrings.size()); + addInt (data, dataStrings.size()); + for (String s : dataStrings) + addUnicode(data, s); + return data; + } + +} diff --git a/src/network/packets/swg/zone/spatial/AttributeListMessage.java b/src/network/packets/swg/zone/spatial/AttributeListMessage.java new file mode 100644 index 000000000..15af0d5a5 --- /dev/null +++ b/src/network/packets/swg/zone/spatial/AttributeListMessage.java @@ -0,0 +1,64 @@ +package network.packets.swg.zone.spatial; + +import java.nio.ByteBuffer; +import java.util.HashMap; +import java.util.Map; +import java.util.Map.Entry; + +import network.packets.swg.SWGPacket; + +public class AttributeListMessage extends SWGPacket { + + public static final int CRC = 0xF3F12F2A; + + private long objectId; + private Map attributes; + + public AttributeListMessage() { + this(0, new HashMap()); + } + + public AttributeListMessage(long objectId, Map attributes) { + this.objectId = objectId; + this.attributes = attributes; + } + + public AttributeListMessage(ByteBuffer data) { + decode(data); + } + + public void decode(ByteBuffer data) { + if (!super.decode(data, CRC)) + return; + objectId = getLong(data); + getShort(data); + int count = getInt(data); + for (int i = 0; i < count; i++) { + String name = getAscii(data); + String attr = getUnicode(data); + attributes.put(name, attr); + } + getInt(data); + } + + public ByteBuffer encode() { + int size = 0; + for (Entry e : attributes.entrySet()) { + size += 6 + e.getKey().length() + e.getValue().length(); + } + ByteBuffer data = ByteBuffer.allocate(18 + size); + addShort(data, 3); + addInt (data, CRC); + addLong (data, objectId); + addShort(data, 0); + addInt (data, attributes.size()); + for (Entry e : attributes.entrySet()) { + addAscii(data, e.getKey()); + addUnicode(data, e.getValue()); + } + addInt (data, 0); + return data; + } + +} + diff --git a/src/network/packets/swg/zone/spatial/GetMapLocationsMessage.java b/src/network/packets/swg/zone/spatial/GetMapLocationsMessage.java new file mode 100644 index 000000000..332d81f89 --- /dev/null +++ b/src/network/packets/swg/zone/spatial/GetMapLocationsMessage.java @@ -0,0 +1,59 @@ +package network.packets.swg.zone.spatial; + +import java.nio.ByteBuffer; +import network.packets.swg.SWGPacket; + +public class GetMapLocationsMessage extends SWGPacket { + + public static final int CRC = 0x1A7AB839; + + private String planet; + private float x; + private float y; + private boolean category; + private boolean subcategory; + private boolean icon; + + public GetMapLocationsMessage() { + this("", 0, 0, false, false, false); + } + + public GetMapLocationsMessage(String planet, float x, float y, boolean category, boolean subcategory, boolean icon) { + this.planet = planet; + this.x = x; + this.y = y; + this.category = category; + this.subcategory = subcategory; + this.icon = icon; + } + + public GetMapLocationsMessage(ByteBuffer data) { + decode(data); + } + + public void decode(ByteBuffer data) { + if (!super.decode(data, CRC)) + return; + planet = getAscii(data); + x = getFloat(data); + y = getFloat(data); + category = getByte(data) != 0; + subcategory = getByte(data) != 0; + icon = getByte(data) != 0; + } + + public ByteBuffer encode() { + ByteBuffer data = ByteBuffer.allocate(19 + planet.length()); + addShort(data, 28); + addInt (data, CRC); + addAscii(data, planet); + addFloat(data, x); + addFloat(data, y); + addByte (data, category ? 1 : 0); + addByte (data, subcategory ? 1 : 0); + addByte (data, icon ? 1 : 0); + return data; + } + +} + diff --git a/src/network/packets/swg/zone/spatial/NewTicketActivityResponseMessage.java b/src/network/packets/swg/zone/spatial/NewTicketActivityResponseMessage.java new file mode 100644 index 000000000..89098a7e3 --- /dev/null +++ b/src/network/packets/swg/zone/spatial/NewTicketActivityResponseMessage.java @@ -0,0 +1,35 @@ +package network.packets.swg.zone.spatial; + +import java.nio.ByteBuffer; + +import network.packets.swg.SWGPacket; + +public class NewTicketActivityResponseMessage extends SWGPacket { + + public static final int CRC = 0x6EA42D80; + + public NewTicketActivityResponseMessage() { + + } + + public NewTicketActivityResponseMessage(ByteBuffer data) { + decode(data); + } + + public void decode(ByteBuffer data) { + if (!super.decode(data, CRC)) + return; + getByte(data); + getInt(data); + } + + public ByteBuffer encode() { + ByteBuffer data = ByteBuffer.allocate(11); + addShort(data, 2); + addInt (data, CRC); + addByte (data, 0); + addInt (data, 1); + return data; + } + +} diff --git a/src/network/packets/swg/zone/spatial/StopClientEffectObjectByLabelMessage.java b/src/network/packets/swg/zone/spatial/StopClientEffectObjectByLabelMessage.java new file mode 100644 index 000000000..5d6e986d1 --- /dev/null +++ b/src/network/packets/swg/zone/spatial/StopClientEffectObjectByLabelMessage.java @@ -0,0 +1,45 @@ +package network.packets.swg.zone.spatial; + +import java.nio.ByteBuffer; + +import network.packets.swg.SWGPacket; + +public class StopClientEffectObjectByLabelMessage extends SWGPacket { + + public static final int CRC = 0xAD6F6B26; + + private long objectId; + private String effect; + + public StopClientEffectObjectByLabelMessage() { + + } + + public StopClientEffectObjectByLabelMessage(long objectId, String effect) { + this.objectId = objectId; + this.effect = effect; + } + + public StopClientEffectObjectByLabelMessage(ByteBuffer data) { + decode(data); + } + + public void decode(ByteBuffer data) { + if (!super.decode(data, CRC)) + return; + objectId = getLong(data); + effect = getAscii(data); + getByte(data); + } + + public ByteBuffer encode() { + ByteBuffer data = ByteBuffer.allocate(6); + addShort(data, 4); + addInt (data, CRC); + addLong (data, objectId); + addAscii(data, effect); + addByte (data, 1); + return data; + } + +}