MCPcopy Create free account
hub / github.com/ddnet/ddnet / LoadBackground

Method LoadBackground

src/game/client/components/background.cpp:41–84  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

39}
40
41void CBackground::LoadBackground()
42{
43 if(m_Loaded && m_pMap == m_pBackgroundMap.get())
44 m_pMap->Unload();
45
46 m_Loaded = false;
47 m_pMap = m_pBackgroundMap.get();
48 m_pLayers = m_pBackgroundLayers;
49 m_pImages = m_pBackgroundImages;
50
51 str_copy(m_aMapName, g_Config.m_ClBackgroundEntities);
52 if(g_Config.m_ClBackgroundEntities[0] != '\0')
53 {
54 bool NeedImageLoading = false;
55
56 char aBuf[IO_MAX_PATH_LENGTH];
57 str_format(aBuf, sizeof(aBuf), "maps/%s%s", g_Config.m_ClBackgroundEntities, str_endswith(g_Config.m_ClBackgroundEntities, ".map") ? "" : ".map");
58 if(str_comp(g_Config.m_ClBackgroundEntities, CURRENT_MAP) == 0)
59 {
60 m_pMap = GameClient()->Map();
61 if(m_pMap->IsLoaded())
62 {
63 m_pLayers = GameClient()->Layers();
64 m_pImages = &GameClient()->m_MapImages;
65 m_Loaded = true;
66 }
67 }
68 else if(m_pMap->Load(g_Config.m_ClBackgroundEntities, Storage(), aBuf, IStorage::TYPE_ALL))
69 {
70 m_pLayers->Init(m_pMap, true);
71 NeedImageLoading = true;
72 m_Loaded = true;
73 }
74
75 if(m_Loaded)
76 {
77 if(NeedImageLoading)
78 {
79 m_pImages->LoadBackground(m_pLayers, m_pMap);
80 }
81 CMapLayers::OnMapLoad();
82 }
83 }
84}
85
86void CBackground::OnMapLoad()
87{

Callers

nothing calls this directly

Calls 12

str_formatFunction · 0.85
str_endswithFunction · 0.85
str_compFunction · 0.85
StorageFunction · 0.85
getMethod · 0.80
str_copyFunction · 0.50
UnloadMethod · 0.45
MapMethod · 0.45
IsLoadedMethod · 0.45
LayersMethod · 0.45
LoadMethod · 0.45
InitMethod · 0.45

Tested by

no test coverage detected