MCPcopy Create free account
hub / github.com/GoMudEngine/GoMud / GetLimitedMap

Method GetLimitedMap

internal/mapper/mapper.go:574–796  ·  view source on GitHub ↗

BFS Crawls from the center position as though the players POV So it won't follow locked rooms, secrets, etc.

(centerRoomId int, c Config)

Source from the content-addressed store, hash-verified

572// BFS Crawls from the center position as though the players POV
573// So it won't follow locked rooms, secrets, etc.
574func (r *mapper) GetLimitedMap(centerRoomId int, c Config) mapRender {
575
576 if c.ZoomLevel < 0 {
577 c.ZoomLevel = 0
578 }
579 c.ZoomLevel++
580 // Minimum effective zoom of 2 ensures that rooms 1 coordinate unit apart
581 // always have at least 1 connector cell between them, making rooms that are
582 // N units apart visually distinguishable from rooms that are 1 unit apart.
583 if c.ZoomLevel < 2 {
584 c.ZoomLevel = 2
585 }
586
587 out := newMapRender(c.Width, c.Height)
588
589 centerX, centerY := c.Width>>1, c.Height>>1
590
591 // Start drawing from the center of the output canvas
592 dstPos := positionDelta{
593 x: centerX,
594 y: centerY,
595 z: 0,
596 }
597
598 node := r.crawledRooms[centerRoomId]
599 if node == nil {
600 return out
601 }
602
603 r.crawlQueue = make([]crawlRoom, 0, 20) // pre-allocate 20 capacity
604
605 drawX, drawY := 0, 0
606
607 // Special additional crawl tracker.
608 // This is because we're doing a unique crawl right now, independent of the "global crawl"
609 tmpCrawledTracker := map[int]struct{}{}
610
611 //var lastNode *mapNode = nil
612 r.crawlQueue = append(r.crawlQueue, crawlRoom{RoomId: node.RoomId, Pos: dstPos})
613
614 var symbol rune
615 var legend string
616
617 for len(r.crawlQueue) > 0 {
618
619 roomNow := r.crawlQueue[0]
620 r.crawlQueue = r.crawlQueue[1:]
621
622 if _, ok := tmpCrawledTracker[roomNow.RoomId]; ok {
623 continue
624 }
625
626 dstPos = roomNow.Pos
627
628 node := r.getMapNode(roomNow.RoomId)
629 if node == nil {
630 continue
631 }

Callers 3

GetMapFunction · 0.80
MapFunction · 0.80
lookRoomFunction · 0.80

Calls 9

getMapNodeMethod · 0.95
GetByUserIdFunction · 0.92
LoadRoomFunction · 0.92
newMapRenderFunction · 0.85
resolveNodeColorsFunction · 0.85
HasKeyMethod · 0.80
HasVisitedRoomMethod · 0.80
CombineMethod · 0.80
HasVisitedMethod · 0.45

Tested by

no test coverage detected