aorecomp

Anarchy Online classic in the browser

git clone https://aorecomp.ubeagle.com/code/aorecomp.git


server/shop_geometry.go (1873B)


      1 package main
      2 
      3 import "fmt"
      4 
      5 func (geometry *sceneGeometry) dungeon(identity uint32) *missionScene {
      6 	// Public interiors are immutable; generated scenes have a separate lifecycle.
      7 	if scene := geometry.interiors[identity]; scene != nil {
      8 		return scene
      9 	}
     10 	return geometry.mission(identity)
     11 }
     12 
     13 func (geometry *sceneGeometry) staticDungeon(identity uint32) (*missionScene, error) {
     14 	library, err := geometry.dungeonLibrary(identity)
     15 	if err != nil {
     16 		return nil, err
     17 	}
     18 	scene := &missionScene{ground: library.ground, rooms: make([]placedRoom, len(library.rooms))}
     19 	for index := range scene.rooms {
     20 		room := &library.rooms[index]
     21 		if room.water {
     22 			return nil, fmt.Errorf("public interior %d room %d requires liquid physics", identity, index)
     23 		}
     24 		// client/game/llr.dll/lifted-0017.c::sub_380291D0 keeps the authored pose.
     25 		scene.rooms[index] = placedRoom{template: room, position: room.position, rotation: room.rotation,
     26 			surface: geometry.surface(identity<<16 | uint32(index))}
     27 		if scene.rooms[index].surface == nil {
     28 			return nil, fmt.Errorf("missing public interior %d room %d surface", identity, index)
     29 		}
     30 	}
     31 
     32 	// client/game/llr.dll/lifted-0018.c::sub_3802C270 reads authored adjacency.
     33 	// Static GetSafePos (client/game/kkr.dll/lifted-0096.c::sub_3614DAD0) uses room 0.
     34 	scene.entrance = &scene.rooms[0]
     35 	for index := range scene.rooms {
     36 		room := &scene.rooms[index]
     37 		for _, door := range room.template.doors {
     38 			position, direction := scene.portal(room, uint16(door[1]))
     39 			if door[0] == -1 {
     40 				continue
     41 			}
     42 			if door[0] < 0 || int(door[0]) >= len(scene.rooms) {
     43 				return nil, fmt.Errorf("invalid public interior %d room link %d", identity, door[0])
     44 			}
     45 			if int(door[0]) <= index {
     46 				continue
     47 			}
     48 			scene.links = append(scene.links, roomLink{[2]*placedRoom{room, &scene.rooms[door[0]]}, position, direction})
     49 		}
     50 	}
     51 	return scene, nil
     52 }