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

Method getMapNode

internal/mapper/mapper.go:1005–1086  ·  view source on GitHub ↗
(roomId int)

Source from the content-addressed store, hash-verified

1003}
1004
1005func (r *mapper) getMapNode(roomId int) *mapNode {
1006
1007 if r, ok := r.crawledRooms[roomId]; ok {
1008 return r
1009 }
1010
1011 room := rooms.LoadRoom(roomId)
1012 if room == nil {
1013 return nil
1014 }
1015
1016 useStoredCoords := room.HasCoordinates && room.Zone == r.rootZone
1017
1018 mNode := &mapNode{
1019 RoomId: room.RoomId,
1020 Exits: make(map[string]nodeExit, 2), // assume there will be on average 2 exits per room
1021 SecretExits: make(map[string]struct{}),
1022 HasStoredCoords: useStoredCoords,
1023 }
1024
1025 if useStoredCoords {
1026 mNode.Pos = positionDelta{x: room.MapX, y: room.MapY, z: room.MapZ}
1027 }
1028
1029 b := room.GetBiome()
1030 if room.MapSymbol != `` {
1031 mNode.Symbol = []rune(room.MapSymbol)[0]
1032 if room.MapLegend != `` {
1033 mNode.Legend = room.MapLegend
1034 }
1035 } else {
1036 if b != nil && b.GetSymbol() != 0 {
1037 mNode.Symbol = b.GetSymbol()
1038 mNode.Legend = b.Name
1039 } else {
1040 mNode.Symbol = defaultMapSymbol
1041 }
1042 }
1043 if b != nil {
1044 mNode.Color = b.Color
1045 mNode.SymbolOverrides = b.SymbolOverrides
1046 }
1047
1048 for exitName, exitInfo := range room.Exits {
1049 exitNode := nodeExit{
1050 RoomId: exitInfo.RoomId,
1051 Secret: exitInfo.Secret,
1052 LockDifficulty: int(exitInfo.Lock.Difficulty),
1053 }
1054
1055 if exitNode.LockDifficulty > 0 {
1056 exitNode.LockId = fmt.Sprintf(`%d-%s`, room.RoomId, exitName)
1057 }
1058
1059 // Derive the connector direction from the actual coordinate delta when
1060 // both rooms have stored coordinates in the same zone. This is always
1061 // authoritative and eliminates any dependency on mapdirection magnitude.
1062 dirSet := false

Callers 2

StartMethod · 0.95
GetLimitedMapMethod · 0.95

Calls 4

LoadRoomFunction · 0.92
arrowForDeltaFunction · 0.85
GetBiomeMethod · 0.80
GetSymbolMethod · 0.80

Tested by

no test coverage detected