MCPcopy Create free account
hub / github.com/OpenLoco/OpenLoco / allocate

Function allocate

src/OpenLoco/src/ViewportManager.cpp:32–50  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

30 }
31
32 static Viewport* allocate()
33 {
34 // Find a free viewport, it is considered unused when width is set to 0.
35 auto itFree = std::ranges::find(_viewports, 0, &Viewport::width);
36 if (itFree != std::ranges::end(_viewports))
37 {
38 return &(*itFree);
39 }
40
41 // Allocate a new viewport.
42 if (_viewports.size() < _viewports.capacity())
43 {
44 _viewports.emplace_back();
45 return &_viewports.back();
46 }
47
48 Logging::warn("No free viewports are available, reached max of {}", kMaxViewports);
49 return nullptr;
50 }
51
52 void destroy(Viewport* vp)
53 {

Callers 1

initViewportFunction · 0.85

Calls 5

findFunction · 0.85
endFunction · 0.85
warnFunction · 0.85
sizeMethod · 0.45
capacityMethod · 0.45

Tested by

no test coverage detected