예제 #1
0
/**
 *
 *  @author OLiver
 */
unsigned PreviewMinimap::CalcPixelColor(const void * param, const MapCoord x, const MapCoord y, const unsigned t)
{
	const glArchivItem_Map& s2map = *static_cast<const glArchivItem_Map*>(param); 
	unsigned color = 0;
	// Baum an dieser Stelle?
	unsigned char landscape_obj = s2map.GetMapDataAt(MAP_TYPE, x, y);
	if(landscape_obj >= 0xC4 && landscape_obj <= 0xC6)
		color = VaryBrightness(TREE_COLOR,VARY_TREE_COLOR);
	// Granit an dieser Stelle?
	else if(landscape_obj == 0xCC || landscape_obj == 0xCD)
		color = VaryBrightness(GRANITE_COLOR,VARY_GRANITE_COLOR);
	// Ansonsten die jeweilige Terrainfarbe nehmen
	else
	{
		color = TERRAIN_COLORS[s2map.getHeader().getGfxSet()]
		[TERRAIN_INDIZES[s2map.GetMapDataAt(MapLayer(MAP_TERRAIN1+t),x,y)]];

		// Schattierung
		int r = GetRed(color)+s2map.GetMapDataAt(MAP_SHADOWS, x, y)-0x40;
		int g = GetGreen(color)+s2map.GetMapDataAt(MAP_SHADOWS, x, y)-0x40;
		int b = GetBlue(color)+s2map.GetMapDataAt(MAP_SHADOWS, x, y)-0x40;

		if(r < 0) r = 0;
		if(r > 255) r = 255;
		if(g < 0) g = 0;
		if(g > 255) g = 255;
		if(b < 0) b = 0;
		if(b > 255) b = 255;

		color = MakeColor(0xFF,unsigned(r),unsigned(g),unsigned(b));
	}

	return color;
}
/**
*
*  @author OLiver
*/
unsigned PreviewMinimap::CalcPixelColor(const MapPoint pt, const unsigned t)
{
    unsigned color = 0;
    // Baum an dieser Stelle?
    unsigned char landscape_obj = objects[GetMMIdx(pt)];
    if(landscape_obj >= 0xC4 && landscape_obj <= 0xC6)
        color = VaryBrightness(TREE_COLOR, VARY_TREE_COLOR);
    // Granit an dieser Stelle?
    else if(landscape_obj == 0xCC || landscape_obj == 0xCD)
        color = VaryBrightness(GRANITE_COLOR, VARY_GRANITE_COLOR);
    // Ansonsten die jeweilige Terrainfarbe nehmen
    else
    {
        color = TerrainData::GetColor(lt, TerrainData::MapIdx2Terrain(t == 0 ? terrain1[GetMMIdx(pt)] : terrain2[GetMMIdx(pt)]));

        // Schattierung
        const int shading = shadows[GetMMIdx(pt)] - 0x40;
        int r = GetRed(color) + shading;
        int g = GetGreen(color) + shading;
        int b = GetBlue(color) + shading;

        if(r < 0) r = 0;
        if(r > 255) r = 255;
        if(g < 0) g = 0;
        if(g > 255) g = 255;
        if(b < 0) b = 0;
        if(b > 255) b = 255;

        color = MakeColor(0xFF, unsigned(r), unsigned(g), unsigned(b));
    }

    return color;
}
예제 #3
0
/**
 *
 *  @author OLiver
 */
unsigned IngameMinimap::CalcPixelColor(const void * param, const MapCoord x, const MapCoord y, const unsigned t)
{
	const GameWorldViewer& gwv = *static_cast<const GameWorldViewer*>(param);

	unsigned color = 0;

	// Beobeachtender Spieler
	unsigned char viewing_player = GameClient::inst().GetPlayerID();

	Visibility visibility = gwv.GetVisibility(x,y);

	if(visibility == VIS_INVISIBLE)
	{
		dos[y*map_width+x] = DO_INVISIBLE;
		// Man sieht nichts --> schwarz
		return 0xFF000000;
	}
	else
	{
		DrawnObject drawn_object = DO_INVALID;

		bool fow = (visibility == VIS_FOW);

		unsigned char owner;
		if(!fow)
			owner = gwv.GetNode(x,y).owner;
		else
			owner = gwv.GetNode(x,y).fow[GameClient::inst().GetPlayerID()].owner;

		// Baum an dieser Stelle?
		if((!fow && gwv.GetNO(x,y)->GetGOT() == GOT_TREE) || (fow && gwv.GetFOWObject(x,y,viewing_player)->GetType() == FOW_TREE))
		{
			color = VaryBrightness(TREE_COLOR,VARY_TREE_COLOR);
			drawn_object = DO_TERRAIN;
			// Ggf. mit Spielerfarbe
			if(owner)
			{
				drawn_object = DO_PLAYER;
				if(territory)
					color = CombineWithPlayerColor(color,owner);
			}
		}
		// Granit an dieser Stelle?
		else if((!fow && gwv.GetNO(x,y)->GetGOT() == GOT_GRANITE) || (fow && gwv.GetFOWObject(x,y,viewing_player)->GetType() == FOW_GRANITE))
		{
			color = VaryBrightness(GRANITE_COLOR,VARY_GRANITE_COLOR);
			drawn_object = DO_TERRAIN;
			// Ggf. mit Spielerfarbe
			if(owner)
			{
				drawn_object = DO_PLAYER;
				if(territory)
					color = CombineWithPlayerColor(color,owner);
			}
		}
		// Ansonsten die jeweilige Terrainfarbe nehmen
		else
		{
			// Ggf. Spielerfarbe mit einberechnen, falls das von einem Spieler ein Territorium ist
			if(owner)
			{
				// Gebäude?
				GO_Type got = gwv.GetNO(x,y)->GetGOT();
				FOW_Type fot = gwv.GetFOWObject(x,y,viewing_player)->GetType();

				if(((!fow && (got == GOT_NOB_USUAL || got == GOT_NOB_MILITARY || 
				   got == GOT_NOB_STOREHOUSE || got == GOT_NOB_USUAL ||
				   got == GOT_NOB_HQ || got == GOT_BUILDINGSITE)) || (fow && (fot == FOW_BUILDING || fot == FOW_BUILDINGSITE))))
				   drawn_object = DO_BUILDING;
				/// Straßen?
				else if(IsRoad(x,y,visibility))
					drawn_object = DO_ROAD;
				// ansonsten normales Territorium?
				else
					drawn_object = DO_PLAYER;

				if(drawn_object == DO_BUILDING && houses)
				   color = BUILDING_COLOR;
				/// Straßen?
				else if(drawn_object == DO_ROAD && roads)
					color = ROAD_COLOR;
				// ansonsten normales Territorium?
				else if(territory)
					// Normales Terrain und Spielerfarbe berechnen
					color = CombineWithPlayerColor(CalcTerrainColor(x,y,t),owner);
				else
					// Normales Terrain berechnen
					color = CalcTerrainColor(x,y,t);
			}
			else
			{
				// Normales Terrain berechnen
				color = CalcTerrainColor(x,y,t);
				drawn_object = DO_TERRAIN;
			}
		}

		// Bei FOW die Farben abdunkeln
		if(fow)
			color = MakeColor(0xFF,GetRed(color)/2,GetGreen(color)/2,GetBlue(color)/2);

		dos[y*map_width+x] = drawn_object;
	}

	return color;
}
예제 #4
0
unsigned IngameMinimap::CalcPixelColor(const MapPoint pt, const unsigned t)
{
    unsigned color = 0;

    Visibility visibility = gwv.GetVisibility(pt);

    if(visibility == VIS_INVISIBLE)
    {
        dos[GetMMIdx(pt)] = DO_INVISIBLE;
        // Man sieht nichts --> schwarz
        return 0xFF000000;
    } else
    {
        DrawnObject drawn_object = DO_INVALID;

        const bool fow = (visibility == VIS_FOW);

        unsigned char owner;
        NodalObjectType noType = NOP_NOTHING;
        FOW_Type fot = FOW_NOTHING;
        if(!fow)
        {
            const MapNode& node = gwv.GetNode(pt);
            owner = node.owner;
            if(node.obj)
                noType = node.obj->GetType();
        } else
        {
            const FoWNode& node = gwv.GetYoungestFOWNode(pt);
            owner = node.owner;
            if(node.object)
                fot = node.object->GetType();
        }

       // Baum an dieser Stelle?
        if((!fow && noType == NOP_TREE) || (fow && fot == FOW_TREE)) //-V807
        {
            color = VaryBrightness(TREE_COLOR, VARY_TREE_COLOR);
            drawn_object = DO_TERRAIN;
            // Ggf. mit Spielerfarbe
            if(owner)
            {
                drawn_object = DO_PLAYER;
                if(territory)
                    color = CombineWithPlayerColor(color, owner);
            }
        }
        // Granit an dieser Stelle?
        else if((!fow && noType == NOP_GRANITE) || (fow && fot == FOW_GRANITE))
        {
            color = VaryBrightness(GRANITE_COLOR, VARY_GRANITE_COLOR);
            drawn_object = DO_TERRAIN;
            // Ggf. mit Spielerfarbe
            if(owner)
            {
                drawn_object = DO_PLAYER;
                if(territory)
                    color = CombineWithPlayerColor(color, owner);
            }
        }
        // Ansonsten die jeweilige Terrainfarbe nehmen
        else
        {
            // Ggf. Spielerfarbe mit einberechnen, falls das von einem Spieler ein Territorium ist
            if(owner)
            {
                // Building?
                if(((!fow && (noType == NOP_BUILDING || noType == NOP_BUILDINGSITE)) || (fow && (fot == FOW_BUILDING || fot == FOW_BUILDINGSITE))))
                    drawn_object = DO_BUILDING;
                /// Roads?
                else if(IsRoad(pt, visibility))
                    drawn_object = DO_ROAD;
                // ansonsten normales Territorium?
                else
                    drawn_object = DO_PLAYER;

                if(drawn_object == DO_BUILDING && houses)
                    color = BUILDING_COLOR;
                /// Roads?
                else if(drawn_object == DO_ROAD && roads)
                    color = ROAD_COLOR;
                // ansonsten normales Territorium?
                else if(territory)
                    // Normales Terrain und Spielerfarbe berechnen
                    color = CombineWithPlayerColor(CalcTerrainColor(pt, t), owner);
                else
                    // Normales Terrain berechnen
                    color = CalcTerrainColor(pt, t);
            } else
            {
                // Normales Terrain berechnen
                color = CalcTerrainColor(pt, t);
                drawn_object = DO_TERRAIN;
            }
        }

        // Bei FOW die Farben abdunkeln
        if(fow)
            color = MakeColor(0xFF, GetRed(color) / 2, GetGreen(color) / 2, GetBlue(color) / 2);

        dos[GetMMIdx(pt)] = drawn_object;
    }

    return color;
}