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

Function ReplaceArea

src/tools/map_replace_area.cpp:112–149  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

110}
111
112bool ReplaceArea(IStorage *pStorage, const char aaMapNames[3][64], const float aaaGameAreas[][2][2])
113{
114 CDataFileReader aInputMaps[2];
115 CDataFileWriter OutputMap;
116
117 if(!OpenMaps(pStorage, aaMapNames, aInputMaps, OutputMap))
118 return false;
119 if(!CompareLayers(aaMapNames, aInputMaps))
120 return false;
121 CompareGroups(aaMapNames, aInputMaps);
122
123 int aLayersStart[2], LayersCount;
124 for(int i = 0; i < 2; i++)
125 aInputMaps[i].GetType(MAPITEMTYPE_LAYER, &aLayersStart[i], &LayersCount);
126
127 for(int i = 0; i < LayersCount; i++)
128 {
129 const CMapItemGroup *apLayerGroups[2];
130 CMapItemLayer *apItem[2];
131 for(int j = 0; j < 2; j++)
132 {
133 apLayerGroups[j] = GetLayerGroup(aInputMaps[j], i + 1);
134 apItem[j] = (CMapItemLayer *)aInputMaps[j].GetItem(aLayersStart[j] + i);
135 }
136
137 if(!apLayerGroups[0] || !apLayerGroups[1])
138 continue;
139
140 if(apItem[0]->m_Type == LAYERTYPE_TILES)
141 ReplaceAreaTiles(aInputMaps, aaaGameAreas, apLayerGroups, apItem);
142 else if(apItem[0]->m_Type == LAYERTYPE_QUADS)
143 ReplaceAreaQuads(aInputMaps, aaaGameAreas, apLayerGroups, apItem, aLayersStart[1] + i);
144 }
145
146 SaveOutputMap(aInputMaps[1], OutputMap);
147
148 return true;
149}
150
151bool OpenMaps(IStorage *pStorage, const char aaMapNames[3][64], CDataFileReader aInputMaps[2], CDataFileWriter &OutputMap)
152{

Callers 1

mainFunction · 0.85

Calls 9

OpenMapsFunction · 0.85
CompareLayersFunction · 0.85
CompareGroupsFunction · 0.85
GetLayerGroupFunction · 0.85
ReplaceAreaTilesFunction · 0.85
ReplaceAreaQuadsFunction · 0.85
SaveOutputMapFunction · 0.85
GetTypeMethod · 0.45
GetItemMethod · 0.45

Tested by

no test coverage detected