void TerrainRenderer::PrepareWaysPoint(GameWorldView *gwv, unsigned short tx, unsigned short ty, int xo, int yo) { float xpos = GetTerrainX(tx,ty)-gwv->GetXOffset()+xo; float ypos = GetTerrainY(tx,ty)-gwv->GetYOffset()+yo; // Wegtypen für die drei Richtungen unsigned char type; Visibility visibility = gwv->GetGameWorldViewer()->GetVisibility(tx,ty); for(unsigned char dir = 0;dir<3;++dir) { if ((type = gwv->GetGameWorldViewer()->GetVisibleRoad(tx,ty, dir+3, visibility))) { float xpos2 = GetTerrainX(gwv->GetGameWorldViewer()->GetXA(tx,ty,3+dir),gwv->GetGameWorldViewer()->GetYA(tx,ty,3+dir))-gwv->GetXOffset()+xo; float ypos2 = GetTerrainY(gwv->GetGameWorldViewer()->GetXA(tx,ty,3+dir),gwv->GetGameWorldViewer()->GetYA(tx,ty,3+dir))-gwv->GetYOffset()+yo; // Gehen wir über einen Kartenrand (horizontale Richung?) if(abs(xpos-xpos2) >= gwv->GetGameWorldViewer()->GetWidth() * TR_W / 2) { if(abs(xpos2-int(gwv->GetGameWorldViewer()->GetWidth())*TR_W-xpos) < abs(xpos-xpos2)) xpos2 -= gwv->GetGameWorldViewer()->GetWidth()*TR_W; else xpos2 += gwv->GetGameWorldViewer()->GetWidth()*TR_W; } // Und dasselbe für vertikale Richtung if(abs(ypos-ypos2) >= gwv->GetGameWorldViewer()->GetHeight() * TR_H / 2) { if(abs(ypos2-int(gwv->GetGameWorldViewer()->GetHeight())*TR_H-ypos) < abs(ypos-ypos2)) ypos2 -= gwv->GetGameWorldViewer()->GetHeight()*TR_H; else ypos2 += gwv->GetGameWorldViewer()->GetHeight()*TR_H; } --type; // Wegtypen "konvertieren" switch(type) { case RoadSegment::RT_DONKEY: case RoadSegment::RT_NORMAL: { unsigned t1 = gwv->GetGameWorldViewer()->GetTerrainAround(tx,ty, dir + 2); unsigned t2 = gwv->GetGameWorldViewer()->GetTerrainAround(tx,ty, dir + 3); // Prüfen, ob Bergwerge gezeichnet werden müssen, indem man guckt, ob der Weg einen // Berg "streift" oder auch eine Bergwiese if(( (t1 >= TT_MOUNTAIN1 && t1 <= TT_MOUNTAIN4) || t1 == TT_MOUNTAINMEADOW) || ( (t2 >= TT_MOUNTAIN1 && t2 <= TT_MOUNTAIN4) || t2 == TT_MOUNTAINMEADOW)) type = 3; } break; case RoadSegment::RT_BOAT: { type = 2; } break; } gwv->sorted_roads[type].push_back( PreparedRoad(type, xpos, ypos, xpos2, ypos2, GetColor(tx, ty), GetColor(gwv->GetGameWorldViewer()->GetXA(tx,ty,3+dir),gwv->GetGameWorldViewer()->GetYA(tx,ty,3+dir)), dir ) ); } } }
void TerrainRenderer::PrepareWaysPoint(PreparedRoads& sorted_roads, const GameWorldView& gwv, MapPoint t, const PointI& offset) { PointI startPos = PointI(GetTerrain(t)) - gwv.GetOffset() + offset; GameWorldViewer& gwViewer = gwv.GetGameWorldViewer(); Visibility visibility = gwViewer.GetVisibility(t); int totalWidth = gwViewer.GetWidth() * TR_W; int totalHeight = gwViewer.GetHeight() * TR_H; // Wegtypen für die drei Richtungen for(unsigned dir = 0; dir < 3; ++dir) { unsigned char type = gwViewer.GetVisibleRoad(t, dir, visibility); if (!type) continue; MapPoint ta = gwViewer.GetNeighbour(t, 3 + dir); PointI endPos = PointI(GetTerrain(ta)) - gwv.GetOffset() + offset; PointI diff = startPos - endPos; // Gehen wir über einen Kartenrand (horizontale Richung?) if(std::abs(diff.x) >= totalWidth / 2) { if(std::abs(endPos.x - totalWidth - startPos.x) < std::abs(diff.x)) endPos.x -= totalWidth; else endPos.x += totalWidth; } // Und dasselbe für vertikale Richtung if(std::abs(diff.y) >= totalHeight / 2) { if(std::abs(endPos.y - totalHeight - startPos.y) < std::abs(diff.y)) endPos.y -= totalHeight; else endPos.y += totalHeight; } --type; // Wegtypen "konvertieren" switch(type) { case RoadSegment::RT_DONKEY: case RoadSegment::RT_NORMAL: { TerrainType t1 = gwViewer.GetTerrainAround(t, dir + 2); TerrainType t2 = gwViewer.GetTerrainAround(t, dir + 3); // Prüfen, ob Bergwege gezeichnet werden müssen, indem man guckt, ob der Weg einen // Berg "streift" oder auch eine Bergwiese if(TerrainData::IsMountain(t1) || TerrainData::IsMountain(t2)) type = 3; break; } case RoadSegment::RT_BOAT: type = 2; break; } sorted_roads[type].push_back( PreparedRoad(type, startPos, endPos, GetColor(t), GetColor(ta), dir) ); } }