当前位置: 首页>>代码示例>>C++>>正文


C++ Map::GetHeight方法代码示例

本文整理汇总了C++中Map::GetHeight方法的典型用法代码示例。如果您正苦于以下问题:C++ Map::GetHeight方法的具体用法?C++ Map::GetHeight怎么用?C++ Map::GetHeight使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Map的用法示例。


在下文中一共展示了Map::GetHeight方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: render_ortho

void render_ortho(SDL_Renderer* renderer)
{
	const int offset = input_offset;
	const float scale = input_scale;

	const int tileSizeX = 128;
	const int tileSizeY = 64;

	//draw draw space
	if (input_draw_space) {
		SDL_SetRenderDrawColor(renderer, 255, 0, 0, 255);
		int w = worldMap.GetWidth()*tileSizeX*scale + (worldMap.GetWidth() - 1)*offset;
		int h = worldMap.GetHeight()*tileSizeY*scale + (worldMap.GetHeight() - 1)*offset;
		DRect rect(-camX, -camY, w, h);
		SDL_RenderFillRect(renderer, rect.get());
		SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255);
	}

	//draw map
	for (int y = 0; y < worldMap.GetHeight(); y++) {
		for (int x = 0; x < worldMap.GetWidth(); x++) {
			const int tileId = 0;
			SDL_Rect tileRect; //in tileset coords
			tileRect.x = tileId*tileSizeX;
			tileRect.y = tileId*tileSizeY;
			tileRect.w = tileSizeX;
			tileRect.h = tileSizeY;

			SDL_Rect rect; //in world coords
			rect.x = x*tileSizeX*scale + x*offset - camX;
			rect.y = y*tileSizeY*scale + y*offset - camY;
			rect.w = tileSizeX*scale;
			rect.h = tileSizeY*scale;

			SDL_RenderCopy(renderer, tileset, &tileRect, &rect);
		}
	}

	//draw debug rect
	if (input_show_debug_rect) {
		SDL_SetRenderDrawColor(renderer, 0, 255, 0, 255);
		for (int y = 0; y < worldMap.GetHeight(); y++) {
			for (int x = 0; x < worldMap.GetWidth(); x++) {
				SDL_Rect rect; //in world coords
				rect.x = x*tileSizeX*scale + x*offset - camX;
				rect.y = y*tileSizeY*scale + y*offset - camY;
				rect.w = tileSizeX*scale;
				rect.h = tileSizeY*scale;

				SDL_RenderDrawRect(renderer, &rect);
			}
		}
		SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255);
	}
}
开发者ID:Bong1236,项目名称:europa,代码行数:55,代码来源:main.cpp

示例2: cos

void
RandomMovementGenerator<Creature>::Initialize(Creature &creature)
{
    float x,y,z,z2, wander_distance;
    creature.GetRespawnCoord(x, y, z);
    creature.GetRespawnDist(wander_distance);
    uint32 mapid=creature.GetMapId();

    Map* map = MapManager::Instance().GetMap(mapid, &creature);
    // Initialization is done in bulk. Don’t use vamps for that (4. parameter = false). It is too costly when entering a new map grid
    z2 = map->GetHeight(x,y,z, false);
    if( fabs( z2 - z ) < 5 )
        z = z2;

    i_nextMove = 1;
    i_waypoints[0][0] = x;
    i_waypoints[0][1] = y;
    i_waypoints[0][2] = z;

    bool is_water_ok = creature.isCanSwimOrFly();
    bool is_land_ok  = creature.isCanWalkOrFly();

    for(unsigned int idx=1; idx < MAX_RAND_WAYPOINTS+1; ++idx)
    {
        const float angle = 2*M_PI*rand_norm();
        const float range = wander_distance*rand_norm();

        i_waypoints[idx][0] = x+ range * cos(angle);
        i_waypoints[idx][1] = y+ range * sin(angle);

        // prevent invalid coordinates generation
        MaNGOS::NormalizeMapCoord(i_waypoints[idx][0]);
        MaNGOS::NormalizeMapCoord(i_waypoints[idx][1]);

        bool is_water = map->IsInWater(i_waypoints[idx][0],i_waypoints[idx][1],z);
        // if generated wrong path just ignore
        if( is_water && !is_water_ok || !is_water && !is_land_ok )
        {
            i_waypoints[idx][0] = i_waypoints[idx-1][0];
            i_waypoints[idx][1] = i_waypoints[idx-1][1];
            i_waypoints[idx][2] = i_waypoints[idx-1][2];
            continue;
        }

        // Initialization is done in bulk. Don’t use vamps for that (4. parameter = false). It is too costly when entering a new map grid
        z2 = map->GetHeight(i_waypoints[idx][0],i_waypoints[idx][1],z, false);
        if( fabs( z2 - z ) < 5 )
            z = z2;
        i_waypoints[idx][2] =  z;
    }
    i_nextMoveTime.Reset(urand(0, 10000-1));                // TODO: check the lower bound (it is probably too small)
    creature.StopMoving();
}
开发者ID:Artea,项目名称:mangos-svn,代码行数:53,代码来源:RandomMovementGenerator.cpp

示例3: cos

void
RandomMovementGenerator::Initialize(Creature &creature)
{
    float x,y,z,z2, wander_distance;
    creature.GetRespawnCoord(x, y, z);
    creature.GetRespawnDist(wander_distance);
    uint32 mapid=creature.GetMapId();

    Map* map = MapManager::Instance().GetMap(mapid);
    z2 = map->GetHeight(x,y);
    if( abs( z2 - z ) < 5 )
        z = z2;

    i_nextMove = 1;
    i_waypoints[0][0] = x;
    i_waypoints[0][1] = y;
    i_waypoints[0][2] = z;

    bool is_water_ok = creature.isCanSwimOrFly();
    bool is_land_ok  = creature.isCanWalkOrFly();

    for(unsigned int idx=1; idx < MAX_RAND_WAYPOINTS+1; ++idx)
    {
        const float angle = (2*M_PI*rand())/RAND_MAX;
        const float range = (wander_distance*rand())/RAND_MAX;

        i_waypoints[idx][0] = x+ range * cos(angle);
        i_waypoints[idx][1] = y+ range * sin(angle);

        // prevent invalid coordinates generation
        MaNGOS::NormalizeMapCoord(i_waypoints[idx][0]);
        MaNGOS::NormalizeMapCoord(i_waypoints[idx][1]);

        bool is_water = map->IsInWater(i_waypoints[idx][0],i_waypoints[idx][1]);

        // if generated wrong path just ignore
        if( is_water && !is_water_ok || !is_water && !is_land_ok )
        {
            i_waypoints[idx][0] = i_waypoints[idx-1][0];
            i_waypoints[idx][1] = i_waypoints[idx-1][1];
            i_waypoints[idx][2] = i_waypoints[idx-1][2];
            continue;
        }

        z2 = map->GetHeight(i_waypoints[idx][0],i_waypoints[idx][1]);
        if( abs( z2 - z ) < 5 )
            z = z2;
        i_waypoints[idx][2] =  z;
    }
    i_nextMoveTime.Reset((rand() % 10000));
    creature.StopMoving();
}
开发者ID:Artea,项目名称:mangos-svn,代码行数:52,代码来源:RandomMovementGenerator.cpp

示例4: mouseClick

void mouseClick(MOUSE_EVENT event) {
	if (event == MOUSE_LEFT) {
		if (inEditorBar()) {
			std::cout << "editor!\n";
			int editorTileIndex = getTileEditor(mouse_x, mouse_y);
			
			if(editorTileIndex >= 0 && editorTileIndex < NB_TILES_EDITOR) {
				std::cout << "id= " << editorTileIndex << "\n";
				selectedTileEditor = editorTileIndex;
			}
		}
		else {
			//write tile to map
			int mapX; int mapY;
			getSelectedTileXY(mouse_x, mouse_y, mapX, mapY);

			if (mapX >= 0 && mapX < worldMap.GetWidth() && 
				mapY >= 0 && mapY < worldMap.GetHeight()) {
				int tileId = TILES_EDITOR[selectedTileEditor];
				Terrain& terrain = worldMap.Get(mapX, mapY);
				if (EDITOR_SELECTED_LAYER == 0) {
					terrain.terrainId = tileId;
				}
				else if (EDITOR_SELECTED_LAYER == 1) {
					terrain.objectId = tileId;
				}
				std::cout << "set tile " << tileId << " at " << mapX << "," << mapY << "\n";
			}
		}
	}
	else if (event == MOUSE_RIGHT) {
		//erase tile from map
		int mapX; int mapY;
		getSelectedTileXY(mouse_x, mouse_y, mapX, mapY);

		if (mapX >= 0 && mapX <= worldMap.GetWidth() &&
			mapY >= 0 && mapY < worldMap.GetHeight()) {
			int tileId = TILES_EDITOR[0];
			Terrain& terrain = worldMap.Get(mapX, mapY);
			if (EDITOR_SELECTED_LAYER == 0) {
				terrain.terrainId = -1;
			}
			else if (EDITOR_SELECTED_LAYER == 1) {
				terrain.objectId = -1;
			}
			std::cout << "set tile " << tileId << " at " << mapX << "," << mapY << "\n";
		}
	}
}
开发者ID:Bong1236,项目名称:europa,代码行数:49,代码来源:main.cpp

示例5:

void
ConfusedMovementGenerator::Initialize(Creature &creature)
{
    const float wander_distance=11;
    float x,y,z,z2;
    x = creature.GetPositionX();
    y = creature.GetPositionY();
    z = creature.GetPositionZ();
    uint32 mapid=creature.GetMapId();

    Map* map = MapManager::Instance().GetMap(mapid);
    z2 = map->GetHeight(x,y);
    if( abs( z2 - z ) < 5 )
        z = z2;

    i_nextMove = 1;

    bool is_water_ok = creature.isCanSwimOrFly();
    bool is_land_ok  = creature.isCanWalkOrFly();

    for(unsigned int idx=0; idx < MAX_CONF_WAYPOINTS+1; ++idx)
    {
        const float wanderX=((wander_distance*rand())/RAND_MAX)-wander_distance/2;
        const float wanderY=((wander_distance*rand())/RAND_MAX)-wander_distance/2;
            
        i_waypoints[idx][0] = x + wanderX;
        i_waypoints[idx][1] = y + wanderY;

        // prevent invalid coordinates generation
        MaNGOS::NormalizeMapCoord(i_waypoints[idx][0]);
        MaNGOS::NormalizeMapCoord(i_waypoints[idx][1]);

        bool is_water = map->IsInWater(i_waypoints[idx][0],i_waypoints[idx][1]);

        // if generated wrong path just ignore
        if( is_water && !is_water_ok || !is_water && !is_land_ok )
        {
            i_waypoints[idx][0] = idx > 0 ? i_waypoints[idx-1][0] : x;
            i_waypoints[idx][1] = idx > 0 ? i_waypoints[idx-1][1] : y;
        }

        z2 = map->GetHeight(i_waypoints[idx][0],i_waypoints[idx][1]);
        if( abs( z2 - z ) < 5 )
            z = z2;
        i_waypoints[idx][2] =  z;
    }
    creature.StopMoving();
}
开发者ID:Artea,项目名称:mangos-svn,代码行数:48,代码来源:ConfusedMovementGenerator.cpp

示例6: reset_view

void reset_view()
{
	camX = -(tileSizeX / 2) * (worldMap.GetHeight() - 1);
	camY = 0;
	input_offset = 0;
	input_scale = 1;
}
开发者ID:Bong1236,项目名称:europa,代码行数:7,代码来源:main.cpp

示例7: RandomTeleport

void RandomPlayerbotMgr::RandomTeleport(Player* bot, vector<WorldLocation> &locs)
{
    if (bot->IsBeingTeleported())
        return;

    if (locs.empty())
    {
        sLog->outMessage("playerbot", LOG_LEVEL_ERROR, "Cannot teleport bot %s - no locations available", bot->GetName().c_str());
        return;
    }

    for (int attemtps = 0; attemtps < 10; ++attemtps)
    {
        int index = urand(0, locs.size() - 1);
        WorldLocation loc = locs[index];
        float x = loc.m_positionX + urand(0, sPlayerbotAIConfig.grindDistance) - sPlayerbotAIConfig.grindDistance / 2;
        float y = loc.m_positionY + urand(0, sPlayerbotAIConfig.grindDistance) - sPlayerbotAIConfig.grindDistance / 2;
        float z = loc.m_positionZ;

        Map* map = sMapMgr->FindMap(loc.GetMapId(), 0);
        if (!map)
            continue;

        if (!map->IsOutdoors(x, y, z) ||
                map->IsInWater(x, y, z))
            continue;

        uint32 areaId = map->GetAreaId(x, y, z);
        if (!areaId)
            continue;

        AreaTableEntry const* area = sAreaStore.LookupEntry(areaId);
        if (!area)
            continue;

        float ground = map->GetHeight(x, y, z + 0.5f);
        if (ground <= INVALID_HEIGHT)
            continue;

        z = 0.05f + ground;
        sLog->outMessage("playerbot", LOG_LEVEL_INFO, "Random teleporting bot %s to %s %f,%f,%f", bot->GetName().c_str(), area->area_name[0], x, y, z);

        bot->GetMotionMaster()->Clear();
        bot->TeleportTo(loc.GetMapId(), x, y, z, 0);
        return;
    }

    sLog->outMessage("playerbot", LOG_LEVEL_ERROR, "Cannot teleport bot %s - no locations available", bot->GetName().c_str());
}
开发者ID:krlloyd,项目名称:gbcraft,代码行数:49,代码来源:RandomPlayerbotMgr.cpp

示例8: LayerToImage

/** layerToImage
  *
  * Converts a layer into an ImageMagick Image
  */
int HandlerUtils::LayerToImage(const Map& map, const Layer& layer, std::vector<Magick::Image>& tiles,
                               Magick::Image& image)
{
    for (unsigned int i = 0; i < map.GetHeight(); i++)
    {
        for (unsigned int j = 0; j < map.GetWidth(); j++)
        {
            int index = i * map.GetWidth() + j;
            int tile = layer[index];
            if (tile == -1)
                continue;
            image.composite(tiles[tile], j * map.GetTileWidth(), i * map.GetTileHeight(), Magick::AtopCompositeOp);
        }
    }

    return 0;
}
开发者ID:TricksterGuy,项目名称:TileMapEditor,代码行数:21,代码来源:HandlerUtils.cpp

示例9: main

int main()
{
	// Read the configuration file
	ConfigManager::ReadParameters();

	// Read and inflate map
	const char* mapurl = ConfigManager::GetMapUrl().erase(ConfigManager::GetMapUrl().size() - 1).c_str();
	Map* currMap = LoadMap(mapurl);

	int robotSize = MAX(ConfigManager::GetRobotHeight(),ConfigManager::GetRobotWidth());
	double mapResulotion = ConfigManager::GetMapResolution();
	int InflateAddition = ceil((robotSize / 2) / mapResulotion);
	Map* inflateMap = currMap->Inflate(InflateAddition);

	Map* Maparticle = currMap->Inflate(5);

	// Calculate the ratio between the grid resolution and map resolution
	int res = ConfigManager::GetGridResolution() / ConfigManager::GetMapResolution();
	Grid* grid = new Grid(inflateMap->GetMatrix(),inflateMap->GetWidth(),inflateMap->GetHeight(), res);

	// A*
	PathPlanner* p = new PathPlanner();
	Point* start = ConfigManager::GetStartLocationMapResolution();
	Point* end = ConfigManager::GetGoalMapResolution();
	int startGridPointX,startGridPointY, endGridPointX, endGridPointY;
	startGridPointX = start->GetRow() / res;
	startGridPointY = start->GetCol() / res;
	endGridPointX = end->GetRow() / res;
	endGridPointY = end->GetCol() / res;

	std::string route = p->pathFind(startGridPointX ,startGridPointY,endGridPointX,endGridPointY,grid);


	// WayPoint calculation
	Point* startWithRes = new Point(start->GetRow() / 4, start->GetCol() / 4);
	vector<Point *> waypointsArr = WayPoints::CalculateByDirectionalPath(route, startWithRes);


	Robot robot("localhost",6665);
	PlnObstacleAvoid plnOA(&robot);
	Manager manager(&robot, &plnOA, waypointsArr, Maparticle);
	manager.run();
}
开发者ID:nisan270390,项目名称:BehaviorsProj,代码行数:43,代码来源:main.cpp

示例10: MapToImage

/** MapToImage
  *
  * Converts a map into an ImageMagick Image
  */
int HandlerUtils::MapToImage(const Map& map, Magick::Image& image)
{
    std::vector<Magick::Image> tiles;

    if (HandlerUtils::GetTiles(map, tiles))
        return -1;

    Magick::Color color = Magick::ColorRGB(0, 0, 0);
    color.alpha(0);

    const Tileset& tileset = map.GetTileset();
    uint32_t tile_width, tile_height;
    tileset.GetTileDimensions(tile_width, tile_height);

    int width = map.GetWidth() * tile_width;
    int height = map.GetHeight() * tile_height;

    image.matte(true);
    image.resize(Magick::Geometry(width, height));
    image.backgroundColor(color);
    image.erase();

    try
    {
        for (const auto& layer : map.GetLayers())
        {
            if (HandlerUtils::LayerToImage(map, layer, tiles, image))
                return -1;
        }
    }
    catch (Magick::Exception& error_)
    {
        return -1;
    }

    return 0;
}
开发者ID:TricksterGuy,项目名称:TileMapEditor,代码行数:41,代码来源:HandlerUtils.cpp

示例11: HandleMovementOpcodes


//.........这里部分代码省略.........
            static const float MaxDeltaXYT = sWorld.GetMvAnticheatMaxXYT();

            if (delta_xyt > MaxDeltaXYT && delta<=100.0f && GetPlayer()->GetZoneId() != 2257)
            {
                if (sWorld.GetMvAnticheatSpeedCheck())
                    Anti__CheatOccurred(CurTime,"Speed hack",delta_xyt,LookupOpcodeName(opcode),
                    (float)(GetPlayer()->GetMotionMaster()->GetCurrentMovementGeneratorType()),
                    (float)(getMSTimeDiff(OldNextLenCheck-500,CurTime)));
            }
        }

        if (delta > 100.0f && GetPlayer()->GetZoneId() != 2257)
        {
            if (sWorld.GetMvAnticheatTeleportCheck())
                Anti__ReportCheat("Tele hack",delta,LookupOpcodeName(opcode));
        }

        // Check for waterwalking . Fix new way of checking for waterwalking by Darky88
        if (movementInfo.HasMovementFlag(MOVEFLAG_WATERWALKING) &&
            !(GetPlayer()->HasAuraType(SPELL_AURA_WATER_WALK) || GetPlayer()->HasAuraType(SPELL_AURA_GHOST)))
        {
            if (sWorld.GetMvAnticheatWaterCheck())
                Anti__CheatOccurred(CurTime,"Water walking",0.0f,NULL,0.0f,(uint32)(movementInfo.GetMovementFlags()));
        }

        // Check for walking upwards a mountain while not beeing able to do that, New check by Darky88 
        if ((delta_z < -2.3f) && (tg_z > 2.37f))
        {
            if (sWorld.GetMvAnticheatMountainCheck())
                Anti__CheatOccurred(CurTime,"Mountain hack",tg_z,NULL,delta,delta_z);
        }

        static const float DIFF_OVERGROUND = 10.0f;
        float Anti__GroundZ = GetPlayer()->GetMap()->GetHeight(GetPlayer()->GetPositionX(),GetPlayer()->GetPositionY(),MAX_HEIGHT);
        float Anti__FloorZ  = GetPlayer()->GetMap()->GetHeight(GetPlayer()->GetPositionX(),GetPlayer()->GetPositionY(),GetPlayer()->GetPositionZ());
        float Anti__MapZ = ((Anti__FloorZ <= (INVALID_HEIGHT+5.0f)) ? Anti__GroundZ : Anti__FloorZ) + DIFF_OVERGROUND;
         
        if (!GetPlayer()->CanFly() &&
            !GetPlayer()->GetBaseMap()->IsUnderWater(movementInfo.GetPos()->x, movementInfo.GetPos()->y, movementInfo.GetPos()->z-7.0f) &&
            Anti__MapZ < GetPlayer()->GetPositionZ() && Anti__MapZ > (INVALID_HEIGHT+DIFF_OVERGROUND + 5.0f))
        {
            static const float DIFF_AIRJUMP=25.0f; // 25 is realy high, but to many false positives...

            // Air-Jump-Detection definitively needs a better way to be detected...
            if ((movementInfo.GetMovementFlags() & (MOVEFLAG_CAN_FLY | MOVEFLAG_FLYING | MOVEFLAG_ROOT)) != 0) // Fly Hack
            {
                // Fix Aura 55164
                if (!GetPlayer()->HasAura(55164) || !GetPlayer()->HasAuraType(SPELL_AURA_FEATHER_FALL))
                    if (sWorld.GetMvAnticheatFlyCheck())
                        Anti__CheatOccurred(CurTime,"Fly hack",
                            ((uint8)(GetPlayer()->HasAuraType(SPELL_AURA_FLY))) +
                            ((uint8)(GetPlayer()->HasAuraType(SPELL_AURA_MOD_FLIGHT_SPEED_MOUNTED))*2),
                            NULL,GetPlayer()->GetPositionZ()-Anti__MapZ);
            }

            // Need a better way to do that - currently a lot of fake alarms
            else if ((Anti__MapZ+DIFF_AIRJUMP < GetPlayer()->GetPositionZ() &&
                    (movementInfo.GetMovementFlags() & (MOVEFLAG_FALLINGFAR | MOVEFLAG_PENDINGSTOP))==0) ||
                    (Anti__MapZ < GetPlayer()->GetPositionZ() && opcode==MSG_MOVE_JUMP) &&
                    !GetPlayer()->HasAuraType(SPELL_AURA_FEATHER_FALL))
            {
                if (sWorld.GetMvAnticheatJumpCheck())
                    Anti__CheatOccurred(CurTime,"Possible Air Jump Hack",0.0f,LookupOpcodeName(opcode),0.0f,movementInfo.GetMovementFlags());
            }
        }
开发者ID:Subv,项目名称:diamondcore,代码行数:66,代码来源:MovementHandler.cpp

示例12: HandleMovementOpcodes


//.........这里部分代码省略.........
            //Fly hack checks
            if (((movementInfo.flags & (MOVEMENTFLAG_CAN_FLY | MOVEMENTFLAG_FLYING | MOVEMENTFLAG_FLYING2)) != 0)
                  && !plMover->isGameMaster()
                  && !(plMover->HasAuraType(SPELL_AURA_FLY) || plMover->HasAuraType(SPELL_AURA_MOD_INCREASE_FLIGHT_SPEED)))
            {
                #ifdef MOVEMENT_ANTICHEAT_DEBUG
                sLog.outError("MA-%s, flight exception. {SPELL_AURA_FLY=[%X]} {SPELL_AURA_MOD_INCREASE_FLIGHT_SPEED=[%X]} {SPELL_AURA_MOD_SPEED_FLIGHT=[%X]} {SPELL_AURA_MOD_FLIGHT_SPEED_ALWAYS=[%X]} {SPELL_AURA_MOD_FLIGHT_SPEED_NOT_STACK=[%X]}",
                   plMover->GetName(),
                   plMover->HasAuraType(SPELL_AURA_FLY), plMover->HasAuraType(SPELL_AURA_MOD_INCREASE_FLIGHT_SPEED),
                   plMover->HasAuraType(SPELL_AURA_MOD_SPEED_FLIGHT), plMover->HasAuraType(SPELL_AURA_MOD_FLIGHT_SPEED_ALWAYS),
                   plMover->HasAuraType(SPELL_AURA_MOD_FLIGHT_SPEED_NOT_STACK));
                #endif
                check_passed = false;
            }
            //Water-Walk checks
            if (((movementInfo.flags & MOVEMENTFLAG_WATERWALKING) != 0)
                  && !plMover->isGameMaster()
                  && !(plMover->HasAuraType(SPELL_AURA_WATER_WALK) | plMover->HasAuraType(SPELL_AURA_GHOST)))
            {
                #ifdef MOVEMENT_ANTICHEAT_DEBUG
                sLog.outError("MA-%s, water-walk exception. [%X]{SPELL_AURA_WATER_WALK=[%X]}",
                                plMover->GetName(), movementInfo.flags, plMover->HasAuraType(SPELL_AURA_WATER_WALK));
                #endif
                check_passed = false;
            }
            //Teleport To Plane checks
            if (movementInfo.z < 0.0001f && movementInfo.z > -0.0001f
                && ((movementInfo.flags & (MOVEMENTFLAG_SWIMMING | MOVEMENTFLAG_CAN_FLY | MOVEMENTFLAG_FLYING | MOVEMENTFLAG_FLYING2)) == 0)
                && !plMover->isGameMaster())
            {
                // Prevent using TeleportToPlan.
                Map *map = plMover->GetMap();
                if (map){
                    float plane_z = map->GetHeight(movementInfo.x, movementInfo.y, MAX_HEIGHT) - movementInfo.z;
                    plane_z = (plane_z < -500.0f) ? 0 : plane_z; //check holes in heigth map
                    if(plane_z > 0.1f || plane_z < -0.1f)
                    {
                        plMover->m_anti_TeleToPlane_Count++;
                        check_passed = false;
                        #ifdef MOVEMENT_ANTICHEAT_DEBUG
                        sLog.outDebug("MA-%s, teleport to plan exception. plane_z: %f ",
                                        plMover->GetName(), plane_z);
                        #endif
                        if (plMover->m_anti_TeleToPlane_Count > World::GetTeleportToPlaneAlarms())
                        {
                            sLog.outError("MA-%s, teleport to plan exception. Exception count: %d ",
                                            plMover->GetName(), plMover->m_anti_TeleToPlane_Count);
                            plMover->GetSession()->KickPlayer();
                            return;
                        }
                    }
                }
            } else {
                if (plMover->m_anti_TeleToPlane_Count != 0)
                    plMover->m_anti_TeleToPlane_Count = 0;
            }
        } else if (movementInfo.flags & MOVEMENTFLAG_ONTRANSPORT) {
            //antiwrap checks
            if (plMover->m_transport)
            {
                float trans_rad = movementInfo.t_x*movementInfo.t_x + movementInfo.t_y*movementInfo.t_y + movementInfo.t_z*movementInfo.t_z;
                if (trans_rad > 3600.0f){
                    check_passed = false;
                    #ifdef MOVEMENT_ANTICHEAT_DEBUG
                    sLog.outError("MA-%s, leave transport.", plMover->GetName());
                    #endif
开发者ID:m1ke-dormant,项目名称:mangos,代码行数:67,代码来源:MovementHandler.cpp

示例13: render

void render(SDL_Renderer* renderer)
{
	//draw draw space
// 	if (input_draw_space) {
// 		SDL_SetRenderDrawColor(renderer, 255, 0, 0, 255);
// 		
// 		SDL_Rect rect;
// 		rect.x = 0;
// 		rect.y = 0;
// 		mapToOrtho(worldMap.GetWidth(), worldMap.GetHeight(), rect.w, rect.h);
// 		zoom(rect);
// 		worldToScreen(rect.x, rect.y);
// 
// 		SDL_RenderFillRect(renderer, &rect);
// 		SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255);
// 	}

	//draw map
	for (int y = 0; y < worldMap.GetHeight(); y++) {
		for (int x = 0; x < worldMap.GetWidth(); x++) {
			SDL_Rect rect; //in world coords
			rect.w = tileSizeX;
			rect.h = tileSizeY;
			mapToIso(x, y, rect.x, rect.y);
			zoom(rect);

			rect.y -= (tileSizeY*input_scale - tileWidth*input_scale);

			worldToScreen(rect.x, rect.y);

			SDL_Rect tileRect; //in tileset coords
			tileRect.w = tileSizeX;
			tileRect.h = tileSizeY;

			//layer terrain
			const int tileId = worldMap.Get(x,y).terrainId;
			if (tileId != -1) {
				int tileX; int tileY; getTileXY(tileId, &tileX, &tileY, TILESET_WIDTH);
				tileRect.x = tileX * tileSizeX;
				tileRect.y = tileY * tileSizeY;

				SDL_RenderCopy(renderer, tileset, &tileRect, &rect);
			}
			//layer object
			const int tileId2 = worldMap.Get(x, y).objectId;
			if (tileId2 != -1) {
				int tileObjX; int tileObjY; getTileXY(tileId2, &tileObjX, &tileObjY, TILESET_WIDTH);
				tileRect.x = tileObjX * tileSizeX;
				tileRect.y = tileObjY * tileSizeY;

				SDL_RenderCopy(renderer, tileset, &tileRect, &rect);
			}
		}
	}

// 	//draw debug rect
// 	if (input_show_debug_rect) {
// 		SDL_SetRenderDrawColor(renderer, 0, 255, 0, 255);
// 		for (int y = 0; y < worldMap.GetHeight(); y++) {
// 			for (int x = 0; x < worldMap.GetWidth(); x++) {
// 				SDL_Rect rect;
// 				rect.w = tileSizeX;
// 				rect.h = tileWidth;
// 
// 				mapToOrtho(x,y,rect.x, rect.y);
// 				zoom(rect);
// 				worldToScreen(rect.x, rect.y);
// 
// 				SDL_RenderDrawRect(renderer, &rect);
// 			}
// 		}
// 		SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255);
// 	}

	//show editor bar
	for (int i = 0; i < NB_TILES_EDITOR; i++) {
		SDL_Rect tileRect; //in tileset coords
		tileRect.w = tileSizeX;
		tileRect.h = tileSizeY;
		const int tileId = TILES_EDITOR[i];
		int tileX; int tileY; getTileXY(tileId, &tileX, &tileY, TILESET_WIDTH);
		tileRect.x = tileX * tileSizeX;
		tileRect.y = tileY * tileSizeY;

		SDL_Rect rect; //in world coords
		rect.w = tileSizeX;
		rect.h = tileSizeY;
		rect.x = i * tileSizeX;
		rect.y = WIN_HEIGHT - tileSizeY;
		
		SDL_RenderCopy(renderer, tileset, &tileRect, &rect);
	}

	if (input_show_debug_rect) {
		SDL_SetRenderDrawColor(renderer, 255, 0, 0, 255);
		for (int x = 0; x < worldMap.GetWidth() + 1; x++) {
			int x1 = x;
			int y1 = 0;
			int x2 = x;
			int y2 = worldMap.GetHeight();
//.........这里部分代码省略.........
开发者ID:Bong1236,项目名称:europa,代码行数:101,代码来源:main.cpp


注:本文中的Map::GetHeight方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。