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

Method Init

src/game/layers.cpp:14–119  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

12}
13
14void CLayers::Init(IMap *pMap, bool GameOnly)
15{
16 Unload();
17
18 m_pMap = pMap;
19 m_pMap->GetType(MAPITEMTYPE_GROUP, &m_GroupsStart, &m_GroupsNum);
20 m_pMap->GetType(MAPITEMTYPE_LAYER, &m_LayersStart, &m_LayersNum);
21
22 for(int GroupIndex = 0; GroupIndex < NumGroups(); GroupIndex++)
23 {
24 CMapItemGroup *pGroup = GetGroup(GroupIndex);
25 for(int LayerIndex = 0; LayerIndex < pGroup->m_NumLayers; LayerIndex++)
26 {
27 CMapItemLayer *pLayer = GetLayer(pGroup->m_StartLayer + LayerIndex);
28 if(pLayer->m_Type != LAYERTYPE_TILES)
29 continue;
30
31 CMapItemLayerTilemap *pTilemap = reinterpret_cast<CMapItemLayerTilemap *>(pLayer);
32 bool IsEntities = false;
33
34 if(pTilemap->m_Flags & TILESLAYERFLAG_GAME)
35 {
36 m_pGameLayer = pTilemap;
37 m_pGameGroup = pGroup;
38
39 // make sure the game group has standard settings
40 m_pGameGroup->m_OffsetX = 0;
41 m_pGameGroup->m_OffsetY = 0;
42 m_pGameGroup->m_ParallaxX = 100;
43 m_pGameGroup->m_ParallaxY = 100;
44
45 if(m_pGameGroup->m_Version >= 2)
46 {
47 m_pGameGroup->m_UseClipping = 0;
48 m_pGameGroup->m_ClipX = 0;
49 m_pGameGroup->m_ClipY = 0;
50 m_pGameGroup->m_ClipW = 0;
51 m_pGameGroup->m_ClipH = 0;
52 }
53
54 IsEntities = true;
55 }
56
57 if(!GameOnly)
58 {
59 if(pTilemap->m_Flags & TILESLAYERFLAG_TELE)
60 {
61 if(pTilemap->m_Version <= 2)
62 {
63 pTilemap->m_Tele = *((int *)(pTilemap) + 15);
64 }
65 m_pTeleLayer = pTilemap;
66 IsEntities = true;
67 }
68
69 if(pTilemap->m_Flags & TILESLAYERFLAG_SPEEDUP)
70 {
71 if(pTilemap->m_Version <= 2)

Callers 5

TESTFunction · 0.45
TESTFunction · 0.45
SetUpMethod · 0.45
CTestGameWorldMethod · 0.45

Calls 1

GetTypeMethod · 0.45

Tested by 4

TESTFunction · 0.36
TESTFunction · 0.36
SetUpMethod · 0.36
CTestGameWorldMethod · 0.36