@@ -37,13 +37,13 @@ static void SendSectionsWhenJoin(this ServerContext server, int whoAmI) {
3737 List < Point > existingPos = new ( ( spawnSectionXEnd - spawnSectionXBegin ) * ( spawnSectionYEnd - spawnSectionYBegin ) ) ;
3838 for ( int x = spawnSectionXBegin ; x < spawnSectionXEnd ; x ++ ) {
3939 for ( int y = spawnSectionYBegin ; y < spawnSectionYEnd ; y ++ ) {
40- server . NetMessage . SendSection ( x , y , whoAmI ) ;
40+ server . NetMessage . SendSection ( whoAmI , x , y ) ;
4141 existingPos . Add ( new Point ( x , y ) ) ;
4242 }
4343 }
4444 server . PortalHelper . SyncPortalsOnPlayerJoin ( whoAmI , 1 , existingPos , out var portalSections ) ;
4545 foreach ( var section in portalSections ) {
46- server . NetMessage . SendSection ( section . X , section . Y , whoAmI ) ;
46+ server . NetMessage . SendSection ( whoAmI , section . X , section . Y ) ;
4747 }
4848 }
4949 static void SendWorldEntities ( this ServerContext server , int whoAmI ) {
@@ -79,7 +79,25 @@ static void SendWorldInfo(this ServerContext server, int whoAmI) {
7979 #endregion
8080
8181 #region Sync Server Offline To Player
82+ static void SendRawData ( ServerContext offlineServer , int plr , byte [ ] data , int offset , int count ) {
83+ var client = offlineServer . Netplay . Clients [ plr ] ;
84+ offlineServer . Hooks . NetMessage . InvokeSendBytes ( client . Socket , data , offset , count , delegate ( object state ) {
85+ client . ServerWriteCallBack ( offlineServer , state ) ;
86+ } ,
87+ null , plr ) ;
88+ }
8289 public static void SyncServerOfflineToPlayer ( ServerContext offlineServer , int plr ) {
90+ byte [ ] data = [ 6 , 0 , MessageID . ItemOwner , default , default , 255 ] ;
91+ for ( int i = 0 ; i < Terraria . Main . maxItems ; i ++ ) {
92+ var item = offlineServer . Main . item [ i ] ;
93+ if ( ! item . active || item . playerIndexTheItemIsReservedFor != plr ) {
94+ continue ;
95+ }
96+ short itemSlot = ( short ) i ;
97+ data [ 3 ] = ( byte ) ( itemSlot & 0xFF ) ;
98+ data [ 4 ] = ( byte ) ( itemSlot >> 8 ) ;
99+ SendRawData ( offlineServer , plr , data , 0 , 6 ) ;
100+ }
83101 for ( int i = 0 ; i < Terraria . Main . maxProjectiles ; i ++ ) {
84102 var proj = offlineServer . Main . projectile [ i ] ;
85103 if ( ! proj . active ) {
@@ -89,7 +107,7 @@ public static void SyncServerOfflineToPlayer(ServerContext offlineServer, int pl
89107 }
90108 for ( int i = 0 ; i < Terraria . Main . maxPlayers ; i ++ ) {
91109 var player = offlineServer . Main . player [ i ] ;
92- if ( ! player . active ) {
110+ if ( ! player . active ) {
93111 continue ;
94112 }
95113 offlineServer . NetMessage . TrySendData ( MessageID . PlayerActive , plr , i , null , i , 0 ) ;
@@ -102,7 +120,6 @@ public static void SyncPlayerJoinToOthers(ServerContext onlineServer, int whoAmI
102120 var player = onlineServer . Main . player [ whoAmI ] ;
103121 onlineServer . NetMessage . TrySendData ( MessageID . PlayerActive , - 1 , whoAmI , null , whoAmI ) ;
104122 onlineServer . NetMessage . TrySendData ( MessageID . SyncPlayer , - 1 , whoAmI , null , whoAmI ) ;
105- onlineServer . NetMessage . TrySendData ( 68 , - 1 , whoAmI , null , whoAmI ) ;
106123 onlineServer . NetMessage . TrySendData ( MessageID . PlayerLifeMana , - 1 , whoAmI , null , whoAmI ) ;
107124 onlineServer . NetMessage . TrySendData ( 42 , - 1 , whoAmI , null , whoAmI ) ;
108125 onlineServer . NetMessage . TrySendData ( MessageID . PlayerBuffs , - 1 , whoAmI , null , whoAmI ) ;
0 commit comments