@@ -12,9 +12,9 @@ import { stringToLong } from '@engine/util/strings';
12
12
import { LandscapeObject } from '@runejs/filestore' ;
13
13
import { xteaRegions } from '@engine/config' ;
14
14
import { world } from '@engine/game-server' ;
15
- import { ConstructedMap } from '@engine/world/map/region' ;
16
- import { map } from 'rxjs/operators' ;
17
- import { Room } from '@plugins/skills/construction/con-house' ;
15
+ import { ConstructedChunk , ConstructedRegion } from '@engine/world/map/region' ;
16
+
17
+
18
18
19
19
/**
20
20
* A helper class for sending various network packets back to the game client.
@@ -567,7 +567,7 @@ export class OutboundPackets {
567
567
this . queue ( packet ) ;
568
568
}
569
569
570
- public constructMapRegion ( mapData : ConstructedMap ) : void {
570
+ public constructMapRegion ( mapData : ConstructedRegion ) : void {
571
571
const packet = new Packet ( 23 , PacketType . DYNAMIC_LARGE ) ;
572
572
573
573
packet . put ( this . player . position . chunkLocalY , 'short' ) ;
@@ -578,23 +578,23 @@ export class OutboundPackets {
578
578
579
579
packet . openBitBuffer ( ) ;
580
580
581
- const mapWorldX = mapData . position . x ;
582
- const mapWorldY = mapData . position . y ;
581
+ const mapWorldX = mapData . renderPosition . x ;
582
+ const mapWorldY = mapData . renderPosition . y ;
583
583
584
584
const topCornerMapChunk = world . chunkManager . getChunkForWorldPosition ( new Position ( mapWorldX , mapWorldY , this . player . position . level ) ) ;
585
585
const playerChunk = world . chunkManager . getChunkForWorldPosition ( this . player . position ) ;
586
586
587
587
const offsetX = playerChunk . position . x - ( topCornerMapChunk . position . x - 2 ) ;
588
588
const offsetY = playerChunk . position . y - ( topCornerMapChunk . position . y - 2 ) ;
589
589
590
- mapData . centerOffsetX = offsetX - 6 ; // 6 === center
591
- mapData . centerOffsetY = offsetY - 6 ; // 6 === center
590
+ mapData . drawOffsetX = offsetX - 6 ; // 6 === center
591
+ mapData . drawOffsetY = offsetY - 6 ; // 6 === center
592
592
593
593
for ( let level = 0 ; level < 4 ; level ++ ) {
594
594
for ( let x = 0 ; x < 13 ; x ++ ) {
595
595
for ( let y = 0 ; y < 13 ; y ++ ) {
596
- let mapTileOffsetX = x + mapData . centerOffsetX ;
597
- let mapTileOffsetY = y + mapData . centerOffsetY ;
596
+ let mapTileOffsetX = x + mapData . drawOffsetX ;
597
+ let mapTileOffsetY = y + mapData . drawOffsetY ;
598
598
if ( mapTileOffsetX < 0 ) {
599
599
mapTileOffsetX = 0 ;
600
600
}
@@ -608,14 +608,15 @@ export class OutboundPackets {
608
608
mapTileOffsetY = 12 ;
609
609
}
610
610
611
- const room : Room | null = mapData . rooms [ level ] [ x ] [ y ] ;
612
- packet . putBits ( 1 , room === null ? 0 : 1 )
613
- if ( room !== null ) {
614
- packet . putBits ( 2 , room . position . level & 0x3 )
615
- packet . putBits ( 10 , room . position . x / 8 )
616
- packet . putBits ( 11 , room . position . y / 8 )
617
- packet . putBits ( 2 , room . rotation )
618
- packet . putBits ( 1 , 0 ) //unused
611
+ const constructedChunk : ConstructedChunk | null = mapData . chunks [ level ] [ x ] [ y ] ;
612
+ packet . putBits ( 1 , constructedChunk === null ? 0 : 1 )
613
+ if ( constructedChunk !== null ) {
614
+ const { templatePosition, rotation } = constructedChunk ;
615
+ packet . putBits ( 2 , templatePosition ?. level & 0x3 ) ;
616
+ packet . putBits ( 10 , templatePosition ?. x / 8 ) ;
617
+ packet . putBits ( 11 , templatePosition ?. y / 8 ) ;
618
+ packet . putBits ( 2 , rotation || 0 ) ;
619
+ packet . putBits ( 1 , 0 ) ; // unused
619
620
}
620
621
}
621
622
}
0 commit comments