| 110 | } |
| 111 | |
| 112 | bool 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 | |
| 151 | bool OpenMaps(IStorage *pStorage, const char aaMapNames[3][64], CDataFileReader aInputMaps[2], CDataFileWriter &OutputMap) |
| 152 | { |
no test coverage detected