Extract struct
Move struct to new file
Use ResourcePool struct
Remove goto
Code style
Merge conditions
Code style
Replace flag with bool
Code style
Replace USE_PORTALS global with assert
Indentation
Code style
Merge conditions
Use clamp
Extract struct
Extract struct
Use struct
Use struct
Use struct
Use struct