diff --git a/Minecraft.Client/GameState/Options.cpp b/Minecraft.Client/GameState/Options.cpp index 63ae52ba8..0723f7690 100644 --- a/Minecraft.Client/GameState/Options.cpp +++ b/Minecraft.Client/GameState/Options.cpp @@ -108,7 +108,7 @@ void Options::init() { advancedOpengl = false; // 4JCRAFT V-Sync / VSync -#ifdef ENABLE_VSYNC +#if defined(ENABLE_VSYNC) framerateLimit = 2; #else framerateLimit = 3; @@ -198,19 +198,11 @@ void Options::setKey(int i, int key) { void Options::set(const Options::Option* item, float fVal) { if (item == Option::MUSIC) { music = fVal; -#if 0 - minecraft->soundEngine->updateMusicVolume(fVal * 2.0f); -#else minecraft->soundEngine->updateMusicVolume(fVal); -#endif } if (item == Option::SOUND) { sound = fVal; -#if 0 - minecraft->soundEngine->updateSoundEffectVolume(fVal * 2.0f); -#else minecraft->soundEngine->updateSoundEffectVolume(fVal); -#endif } if (item == Option::SENSITIVITY) { sensitivity = fVal; diff --git a/Minecraft.Client/GameState/StatsCounter.cpp b/Minecraft.Client/GameState/StatsCounter.cpp index e646d480a..5a39b30a9 100644 --- a/Minecraft.Client/GameState/StatsCounter.cpp +++ b/Minecraft.Client/GameState/StatsCounter.cpp @@ -28,7 +28,6 @@ StatsCounter::StatsCounter() { void StatsCounter::award(Stat* stat, unsigned int difficulty, unsigned int count) { -#if 1 if (stat->isAchievement()) difficulty = 0; StatsMap::iterator val = stats.find(stat); @@ -64,7 +63,6 @@ void StatsCounter::award(Stat* stat, unsigned int difficulty, modifiedBoards |= (leaderboardEntry->second << difficulty); if (flushCounter == 0) flushCounter = FLUSH_DELAY; } -#endif } bool StatsCounter::hasTaken(Achievement* ach) { @@ -112,7 +110,6 @@ void StatsCounter::clear() { } void StatsCounter::parse(void* data) { -#if 1 // 4J-PB - If this is the trial game, let's just make sure all the stats are // empty 4J-PB - removing - someone can have the full game, and then remove // it and go back to the trial @@ -177,11 +174,9 @@ void StatsCounter::parse(void* data) { } dumpStatsToTTY(); -#endif } void StatsCounter::save(int player, bool force) { -#if 1 // 4J-PB - If this is the trial game, don't save any stats if (!ProfileManager.IsFullVersion()) { return; @@ -198,14 +193,8 @@ void StatsCounter::save(int player, bool force) { sizeof(GAME_SETTINGS))); // Retrieve the data pointer from the profile -#if (0 || 0 || 0 || \ - 0) - std::uint8_t* pbData = reinterpret_cast( - StorageManager.GetGameDefinedProfileData(player)); -#else std::uint8_t* pbData = reinterpret_cast( ProfileManager.GetGameDefinedProfileData(player)); -#endif pbData += sizeof(GAME_SETTINGS); // Pointer to current position in stat array @@ -260,38 +249,13 @@ void StatsCounter::save(int player, bool force) { } } -#if (0 || 0 || 0 || \ - 0) - StorageManager.WriteToProfile(player, true, force); -#else ProfileManager.WriteToProfile(player, true, force); -#endif saveCounter = SAVE_DELAY; -#endif } -#if 0 -void StatsCounter::setLeaderboardProperty(XUSER_PROPERTY* prop, - std::uint32_t id, - unsigned int value) { - app.DebugPrintf("Setting property id: %d to value %d\n", id, value); - prop->dwPropertyId = id; - prop->value.type = XUSER_DATA_TYPE_INT32; - prop->value.nData = - (int)(value & 0x7FFFFFFF); // Just making sure we clamp the unsigned - // int to the max val for a signed int -} - -void StatsCounter::setLeaderboardRating(XUSER_PROPERTY* prop, LONGLONG value) { - prop->dwPropertyId = PROPERTY_RATING; - prop->value.type = XUSER_DATA_TYPE_INT64; - prop->value.i64Data = value; -} -#endif void StatsCounter::flushLeaderboards() { -#if 1 if (LeaderboardManager::Instance()->OpenSession()) { writeStats(); LeaderboardManager::Instance()->FlushStats(); @@ -305,11 +269,9 @@ void StatsCounter::flushLeaderboards() { } modifiedBoards = 0; -#endif } void StatsCounter::saveLeaderboards() { -#if 1 // 4J-PB - If this is the trial game, no writing leaderboards if (!ProfileManager.IsFullVersion()) { return; @@ -328,11 +290,9 @@ void StatsCounter::saveLeaderboards() { } modifiedBoards = 0; -#endif } void StatsCounter::writeStats() { -#if 1 // 4J-PB - If this is the trial game, no writing if (!ProfileManager.IsFullVersion()) { return; @@ -342,1451 +302,9 @@ void StatsCounter::writeStats() { int viewCount = 0; int iPad = ProfileManager.GetLockedProfile(); -#if 0 || 0 || 0 - LeaderboardManager::RegisterScore* scores = - new LeaderboardManager::RegisterScore[24]; - - if (modifiedBoards & LEADERBOARD_KILLS_EASY) { - scores[viewCount].m_iPad = iPad; - - app.DebugPrintf("Updating leaderboard view LEADERBOARD_KILLS_EASY\n"); - scores[viewCount].m_difficulty = 1; - - scores[viewCount].m_commentData.m_statsType = - LeaderboardManager::eStatsType_Kills; - - scores[viewCount].m_commentData.m_kills.m_zombie = - getValue(Stats::killsZombie, eDifficulty_Easy); - scores[viewCount].m_commentData.m_kills.m_skeleton = - getValue(Stats::killsSkeleton, eDifficulty_Easy); - scores[viewCount].m_commentData.m_kills.m_creeper = - getValue(Stats::killsCreeper, eDifficulty_Easy); - scores[viewCount].m_commentData.m_kills.m_spider = - getValue(Stats::killsSpider, eDifficulty_Easy); - scores[viewCount].m_commentData.m_kills.m_spiderJockey = - getValue(Stats::killsSpiderJockey, eDifficulty_Easy); - // scores[viewCount].m_commentData.m_kills.m_zombiePigman = - // getValue(Stats::killsZombiePigman, eDifficulty_Easy); - scores[viewCount].m_commentData.m_kills.m_zombiePigman = - getValue(Stats::killsNetherZombiePigman, eDifficulty_Easy); - scores[viewCount].m_commentData.m_kills.m_slime = - getValue(Stats::killsSlime, eDifficulty_Easy); - - scores[viewCount].m_score = - scores[viewCount].m_commentData.m_kills.m_zombie + - scores[viewCount].m_commentData.m_kills.m_skeleton + - scores[viewCount].m_commentData.m_kills.m_creeper + - scores[viewCount].m_commentData.m_kills.m_spider + - scores[viewCount].m_commentData.m_kills.m_spiderJockey - // + getValue(Stats::killsZombiePigman, - // eDifficulty_Easy); - + scores[viewCount].m_commentData.m_kills.m_zombiePigman + - scores[viewCount].m_commentData.m_kills.m_slime; - - viewCount++; - } - - if (modifiedBoards & LEADERBOARD_KILLS_NORMAL) { - scores[viewCount].m_iPad = iPad; - - app.DebugPrintf("Updating leaderboard view LEADERBOARD_KILLS_NORMAL\n"); - scores[viewCount].m_difficulty = 2; - - scores[viewCount].m_commentData.m_statsType = - LeaderboardManager::eStatsType_Kills; - - scores[viewCount].m_commentData.m_kills.m_zombie = - getValue(Stats::killsZombie, eDifficulty_Normal); - scores[viewCount].m_commentData.m_kills.m_skeleton = - getValue(Stats::killsSkeleton, eDifficulty_Normal); - scores[viewCount].m_commentData.m_kills.m_creeper = - getValue(Stats::killsCreeper, eDifficulty_Normal); - scores[viewCount].m_commentData.m_kills.m_spider = - getValue(Stats::killsSpider, eDifficulty_Normal); - scores[viewCount].m_commentData.m_kills.m_spiderJockey = - getValue(Stats::killsSpiderJockey, eDifficulty_Normal); - // scores[viewCount].m_commentData.m_kills.m_zombiePigman = - // getValue(Stats::killsZombiePigman, eDifficulty_Normal); - scores[viewCount].m_commentData.m_kills.m_zombiePigman = - getValue(Stats::killsNetherZombiePigman, eDifficulty_Normal); - scores[viewCount].m_commentData.m_kills.m_slime = - getValue(Stats::killsSlime, eDifficulty_Normal); - - scores[viewCount].m_score = - scores[viewCount].m_commentData.m_kills.m_zombie + - scores[viewCount].m_commentData.m_kills.m_skeleton + - scores[viewCount].m_commentData.m_kills.m_creeper + - scores[viewCount].m_commentData.m_kills.m_spider + - scores[viewCount].m_commentData.m_kills.m_spiderJockey - // + getValue(Stats::killsZombiePigman, - // eDifficulty_Normal); - + scores[viewCount].m_commentData.m_kills.m_zombiePigman + - scores[viewCount].m_commentData.m_kills.m_slime; - - viewCount++; - } - - if (modifiedBoards & LEADERBOARD_KILLS_HARD) { - scores[viewCount].m_iPad = iPad; - - app.DebugPrintf("Updating leaderboard view LEADERBOARD_KILLS_HARD\n"); - scores[viewCount].m_difficulty = 3; - - scores[viewCount].m_commentData.m_statsType = - LeaderboardManager::eStatsType_Kills; - - scores[viewCount].m_commentData.m_kills.m_zombie = - getValue(Stats::killsZombie, eDifficulty_Hard); - scores[viewCount].m_commentData.m_kills.m_skeleton = - getValue(Stats::killsSkeleton, eDifficulty_Hard); - scores[viewCount].m_commentData.m_kills.m_creeper = - getValue(Stats::killsCreeper, eDifficulty_Hard); - scores[viewCount].m_commentData.m_kills.m_spider = - getValue(Stats::killsSpider, eDifficulty_Hard); - scores[viewCount].m_commentData.m_kills.m_spiderJockey = - getValue(Stats::killsSpiderJockey, eDifficulty_Hard); - // scores[viewCount].m_commentData.m_kills.m_zombiePigman = - // getValue(Stats::killsZombiePigman, eDifficulty_Hard); - scores[viewCount].m_commentData.m_kills.m_zombiePigman = - getValue(Stats::killsNetherZombiePigman, eDifficulty_Hard); - scores[viewCount].m_commentData.m_kills.m_slime = - getValue(Stats::killsSlime, eDifficulty_Hard); - - scores[viewCount].m_score = - scores[viewCount].m_commentData.m_kills.m_zombie + - scores[viewCount].m_commentData.m_kills.m_skeleton + - scores[viewCount].m_commentData.m_kills.m_creeper + - scores[viewCount].m_commentData.m_kills.m_spider + - scores[viewCount].m_commentData.m_kills.m_spiderJockey - // + getValue(Stats::killsZombiePigman, - // eDifficulty_Hard); - + scores[viewCount].m_commentData.m_kills.m_zombiePigman + - scores[viewCount].m_commentData.m_kills.m_slime; - - viewCount++; - } - - if (modifiedBoards & LEADERBOARD_MININGBLOCKS_PEACEFUL) { - scores[viewCount].m_iPad = iPad; - - app.DebugPrintf( - "Updating leaderboard view LEADERBOARD_MININGBLOCKS_PEACEFUL\n"); - scores[viewCount].m_difficulty = 0; - - scores[viewCount].m_commentData.m_statsType = - LeaderboardManager::eStatsType_Mining; - - scores[viewCount].m_commentData.m_mining.m_dirt = - getValue(Stats::blocksMined[Tile::dirt->id], eDifficulty_Peaceful); - scores[viewCount].m_commentData.m_mining.m_cobblestone = getValue( - Stats::blocksMined[Tile::cobblestone->id], eDifficulty_Peaceful); - scores[viewCount].m_commentData.m_mining.m_sand = - getValue(Stats::blocksMined[Tile::sand->id], eDifficulty_Peaceful); - scores[viewCount].m_commentData.m_mining.m_stone = - getValue(Stats::blocksMined[Tile::stone->id], eDifficulty_Peaceful); - scores[viewCount].m_commentData.m_mining.m_gravel = getValue( - Stats::blocksMined[Tile::gravel->id], eDifficulty_Peaceful); - scores[viewCount].m_commentData.m_mining.m_clay = - getValue(Stats::blocksMined[Tile::clay->id], eDifficulty_Peaceful); - scores[viewCount].m_commentData.m_mining.m_obsidian = getValue( - Stats::blocksMined[Tile::obsidian->id], eDifficulty_Peaceful); - - scores[viewCount].m_score = - scores[viewCount].m_commentData.m_mining.m_dirt + - scores[viewCount].m_commentData.m_mining.m_cobblestone + - scores[viewCount].m_commentData.m_mining.m_sand + - scores[viewCount].m_commentData.m_mining.m_stone + - scores[viewCount].m_commentData.m_mining.m_gravel + - scores[viewCount].m_commentData.m_mining.m_clay + - scores[viewCount].m_commentData.m_mining.m_obsidian; - - viewCount++; - } - - if (modifiedBoards & LEADERBOARD_MININGBLOCKS_EASY) { - scores[viewCount].m_iPad = iPad; - - app.DebugPrintf( - "Updating leaderboard view LEADERBOARD_MININGBLOCKS_EASY\n"); - scores[viewCount].m_difficulty = 1; - - scores[viewCount].m_commentData.m_statsType = - LeaderboardManager::eStatsType_Mining; - - scores[viewCount].m_commentData.m_mining.m_dirt = - getValue(Stats::blocksMined[Tile::dirt->id], eDifficulty_Easy); - scores[viewCount].m_commentData.m_mining.m_cobblestone = getValue( - Stats::blocksMined[Tile::cobblestone->id], eDifficulty_Easy); - scores[viewCount].m_commentData.m_mining.m_sand = - getValue(Stats::blocksMined[Tile::sand->id], eDifficulty_Easy); - scores[viewCount].m_commentData.m_mining.m_stone = - getValue(Stats::blocksMined[Tile::stone->id], eDifficulty_Easy); - scores[viewCount].m_commentData.m_mining.m_gravel = - getValue(Stats::blocksMined[Tile::gravel->id], eDifficulty_Easy); - scores[viewCount].m_commentData.m_mining.m_clay = - getValue(Stats::blocksMined[Tile::clay->id], eDifficulty_Easy); - scores[viewCount].m_commentData.m_mining.m_obsidian = - getValue(Stats::blocksMined[Tile::obsidian->id], eDifficulty_Easy); - - scores[viewCount].m_score = - scores[viewCount].m_commentData.m_mining.m_dirt + - scores[viewCount].m_commentData.m_mining.m_cobblestone + - scores[viewCount].m_commentData.m_mining.m_sand + - scores[viewCount].m_commentData.m_mining.m_stone + - scores[viewCount].m_commentData.m_mining.m_gravel + - scores[viewCount].m_commentData.m_mining.m_clay + - scores[viewCount].m_commentData.m_mining.m_obsidian; - - viewCount++; - } - - if (modifiedBoards & LEADERBOARD_MININGBLOCKS_NORMAL) { - scores[viewCount].m_iPad = iPad; - - app.DebugPrintf( - "Updating leaderboard view LEADERBOARD_MININGBLOCKS_NORMAL\n"); - scores[viewCount].m_difficulty = 2; - - scores[viewCount].m_commentData.m_statsType = - LeaderboardManager::eStatsType_Mining; - - scores[viewCount].m_commentData.m_mining.m_dirt = - getValue(Stats::blocksMined[Tile::dirt->id], eDifficulty_Normal); - scores[viewCount].m_commentData.m_mining.m_cobblestone = getValue( - Stats::blocksMined[Tile::cobblestone->id], eDifficulty_Normal); - scores[viewCount].m_commentData.m_mining.m_sand = - getValue(Stats::blocksMined[Tile::sand->id], eDifficulty_Normal); - scores[viewCount].m_commentData.m_mining.m_stone = - getValue(Stats::blocksMined[Tile::stone->id], eDifficulty_Normal); - scores[viewCount].m_commentData.m_mining.m_gravel = - getValue(Stats::blocksMined[Tile::gravel->id], eDifficulty_Normal); - scores[viewCount].m_commentData.m_mining.m_clay = - getValue(Stats::blocksMined[Tile::clay->id], eDifficulty_Normal); - scores[viewCount].m_commentData.m_mining.m_obsidian = getValue( - Stats::blocksMined[Tile::obsidian->id], eDifficulty_Normal); - - scores[viewCount].m_score = - scores[viewCount].m_commentData.m_mining.m_dirt + - scores[viewCount].m_commentData.m_mining.m_cobblestone + - scores[viewCount].m_commentData.m_mining.m_sand + - scores[viewCount].m_commentData.m_mining.m_stone + - scores[viewCount].m_commentData.m_mining.m_gravel + - scores[viewCount].m_commentData.m_mining.m_clay + - scores[viewCount].m_commentData.m_mining.m_obsidian; - - viewCount++; - } - - if (modifiedBoards & LEADERBOARD_MININGBLOCKS_HARD) { - scores[viewCount].m_iPad = iPad; - - app.DebugPrintf( - "Updating leaderboard view LEADERBOARD_MININGBLOCKS_HARD\n"); - scores[viewCount].m_difficulty = 3; - - scores[viewCount].m_commentData.m_statsType = - LeaderboardManager::eStatsType_Mining; - - scores[viewCount].m_commentData.m_mining.m_dirt = - getValue(Stats::blocksMined[Tile::dirt->id], eDifficulty_Hard); - scores[viewCount].m_commentData.m_mining.m_cobblestone = getValue( - Stats::blocksMined[Tile::cobblestone->id], eDifficulty_Hard); - scores[viewCount].m_commentData.m_mining.m_sand = - getValue(Stats::blocksMined[Tile::sand->id], eDifficulty_Hard); - scores[viewCount].m_commentData.m_mining.m_stone = - getValue(Stats::blocksMined[Tile::stone->id], eDifficulty_Hard); - scores[viewCount].m_commentData.m_mining.m_gravel = - getValue(Stats::blocksMined[Tile::gravel->id], eDifficulty_Hard); - scores[viewCount].m_commentData.m_mining.m_clay = - getValue(Stats::blocksMined[Tile::clay->id], eDifficulty_Hard); - scores[viewCount].m_commentData.m_mining.m_obsidian = - getValue(Stats::blocksMined[Tile::obsidian->id], eDifficulty_Hard); - - scores[viewCount].m_score = - scores[viewCount].m_commentData.m_mining.m_dirt + - scores[viewCount].m_commentData.m_mining.m_cobblestone + - scores[viewCount].m_commentData.m_mining.m_sand + - scores[viewCount].m_commentData.m_mining.m_stone + - scores[viewCount].m_commentData.m_mining.m_gravel + - scores[viewCount].m_commentData.m_mining.m_clay + - scores[viewCount].m_commentData.m_mining.m_obsidian; - - viewCount++; - } - - if (modifiedBoards & LEADERBOARD_FARMING_PEACEFUL) { - scores[viewCount].m_iPad = iPad; - - app.DebugPrintf( - "Updating leaderboard view LEADERBOARD_FARMING_PEACEFUL\n"); - scores[viewCount].m_difficulty = 0; - - scores[viewCount].m_commentData.m_statsType = - LeaderboardManager::eStatsType_Farming; - - scores[viewCount].m_commentData.m_farming.m_eggs = getValue( - Stats::itemsCollected[Item::egg->id], eDifficulty_Peaceful); - scores[viewCount].m_commentData.m_farming.m_wheat = - getValue(Stats::blocksMined[Tile::wheat_Id], eDifficulty_Peaceful); - scores[viewCount].m_commentData.m_farming.m_mushroom = getValue( - Stats::blocksMined[Tile::mushroom_brown_Id], eDifficulty_Peaceful); - scores[viewCount].m_commentData.m_farming.m_sugarcane = - getValue(Stats::blocksMined[Tile::reeds_Id], eDifficulty_Peaceful); - scores[viewCount].m_commentData.m_farming.m_milk = - getValue(Stats::cowsMilked, eDifficulty_Peaceful); - scores[viewCount].m_commentData.m_farming.m_pumpkin = getValue( - Stats::itemsCollected[Tile::pumpkin->id], eDifficulty_Peaceful); - - scores[viewCount].m_score = - scores[viewCount].m_commentData.m_farming.m_eggs + - scores[viewCount].m_commentData.m_farming.m_wheat + - scores[viewCount].m_commentData.m_farming.m_mushroom + - scores[viewCount].m_commentData.m_farming.m_sugarcane + - scores[viewCount].m_commentData.m_farming.m_milk + - scores[viewCount].m_commentData.m_farming.m_pumpkin; - - viewCount++; - } - - if (modifiedBoards & LEADERBOARD_FARMING_EASY) { - scores[viewCount].m_iPad = iPad; - - app.DebugPrintf("Updating leaderboard view LEADERBOARD_FARMING_EASY\n"); - scores[viewCount].m_difficulty = 1; - - scores[viewCount].m_commentData.m_statsType = - LeaderboardManager::eStatsType_Farming; - - scores[viewCount].m_commentData.m_farming.m_eggs = - getValue(Stats::itemsCollected[Item::egg->id], eDifficulty_Easy); - scores[viewCount].m_commentData.m_farming.m_wheat = - getValue(Stats::blocksMined[Tile::wheat_Id], eDifficulty_Easy); - scores[viewCount].m_commentData.m_farming.m_mushroom = getValue( - Stats::blocksMined[Tile::mushroom_brown_Id], eDifficulty_Easy); - scores[viewCount].m_commentData.m_farming.m_sugarcane = - getValue(Stats::blocksMined[Tile::reeds_Id], eDifficulty_Easy); - scores[viewCount].m_commentData.m_farming.m_milk = - getValue(Stats::cowsMilked, eDifficulty_Easy); - scores[viewCount].m_commentData.m_farming.m_pumpkin = getValue( - Stats::itemsCollected[Tile::pumpkin->id], eDifficulty_Easy); - - scores[viewCount].m_score = - scores[viewCount].m_commentData.m_farming.m_eggs + - scores[viewCount].m_commentData.m_farming.m_wheat + - scores[viewCount].m_commentData.m_farming.m_mushroom + - scores[viewCount].m_commentData.m_farming.m_sugarcane + - scores[viewCount].m_commentData.m_farming.m_milk + - scores[viewCount].m_commentData.m_farming.m_pumpkin; - - viewCount++; - } - - if (modifiedBoards & LEADERBOARD_FARMING_NORMAL) { - scores[viewCount].m_iPad = iPad; - - app.DebugPrintf( - "Updating leaderboard view LEADERBOARD_FARMING_NORMAL\n"); - scores[viewCount].m_difficulty = 2; - - scores[viewCount].m_commentData.m_statsType = - LeaderboardManager::eStatsType_Farming; - - scores[viewCount].m_commentData.m_farming.m_eggs = - getValue(Stats::itemsCollected[Item::egg->id], eDifficulty_Normal); - scores[viewCount].m_commentData.m_farming.m_wheat = - getValue(Stats::blocksMined[Tile::wheat_Id], eDifficulty_Normal); - scores[viewCount].m_commentData.m_farming.m_mushroom = getValue( - Stats::blocksMined[Tile::mushroom_brown_Id], eDifficulty_Normal); - scores[viewCount].m_commentData.m_farming.m_sugarcane = - getValue(Stats::blocksMined[Tile::reeds_Id], eDifficulty_Normal); - scores[viewCount].m_commentData.m_farming.m_milk = - getValue(Stats::cowsMilked, eDifficulty_Normal); - scores[viewCount].m_commentData.m_farming.m_pumpkin = getValue( - Stats::itemsCollected[Tile::pumpkin->id], eDifficulty_Normal); - - scores[viewCount].m_score = - scores[viewCount].m_commentData.m_farming.m_eggs + - scores[viewCount].m_commentData.m_farming.m_wheat + - scores[viewCount].m_commentData.m_farming.m_mushroom + - scores[viewCount].m_commentData.m_farming.m_sugarcane + - scores[viewCount].m_commentData.m_farming.m_milk + - scores[viewCount].m_commentData.m_farming.m_pumpkin; - - viewCount++; - } - - if (modifiedBoards & LEADERBOARD_FARMING_HARD) { - scores[viewCount].m_iPad = iPad; - - app.DebugPrintf("Updating leaderboard view LEADERBOARD_FARMING_HARD\n"); - scores[viewCount].m_difficulty = 3; - - scores[viewCount].m_commentData.m_statsType = - LeaderboardManager::eStatsType_Farming; - - scores[viewCount].m_commentData.m_farming.m_eggs = - getValue(Stats::itemsCollected[Item::egg->id], eDifficulty_Hard); - scores[viewCount].m_commentData.m_farming.m_wheat = - getValue(Stats::blocksMined[Tile::wheat_Id], eDifficulty_Hard); - scores[viewCount].m_commentData.m_farming.m_mushroom = getValue( - Stats::blocksMined[Tile::mushroom_brown_Id], eDifficulty_Hard); - scores[viewCount].m_commentData.m_farming.m_sugarcane = - getValue(Stats::blocksMined[Tile::reeds_Id], eDifficulty_Hard); - scores[viewCount].m_commentData.m_farming.m_milk = - getValue(Stats::cowsMilked, eDifficulty_Hard); - scores[viewCount].m_commentData.m_farming.m_pumpkin = getValue( - Stats::itemsCollected[Tile::pumpkin->id], eDifficulty_Hard); - - scores[viewCount].m_score = - scores[viewCount].m_commentData.m_farming.m_eggs + - scores[viewCount].m_commentData.m_farming.m_wheat + - scores[viewCount].m_commentData.m_farming.m_mushroom + - scores[viewCount].m_commentData.m_farming.m_sugarcane + - scores[viewCount].m_commentData.m_farming.m_milk + - scores[viewCount].m_commentData.m_farming.m_pumpkin; - - viewCount++; - } - - if (modifiedBoards & LEADERBOARD_TRAVELLING_PEACEFUL) { - scores[viewCount].m_iPad = iPad; - - app.DebugPrintf( - "Updating leaderboard view LEADERBOARD_TRAVELLING_PEACEFUL\n"); - scores[viewCount].m_difficulty = 0; - - scores[viewCount].m_commentData.m_statsType = - LeaderboardManager::eStatsType_Travelling; - - scores[viewCount].m_commentData.m_travelling.m_walked = - getValue(Stats::walkOneM, eDifficulty_Peaceful); - scores[viewCount].m_commentData.m_travelling.m_fallen = - getValue(Stats::fallOneM, eDifficulty_Peaceful); - scores[viewCount].m_commentData.m_travelling.m_minecart = - getValue(Stats::minecartOneM, eDifficulty_Peaceful); - scores[viewCount].m_commentData.m_travelling.m_boat = - getValue(Stats::boatOneM, eDifficulty_Peaceful); - - scores[viewCount].m_score = - scores[viewCount].m_commentData.m_travelling.m_walked + - scores[viewCount].m_commentData.m_travelling.m_fallen + - scores[viewCount].m_commentData.m_travelling.m_minecart + - scores[viewCount].m_commentData.m_travelling.m_boat; - - viewCount++; - } - - if (modifiedBoards & LEADERBOARD_TRAVELLING_EASY) { - scores[viewCount].m_iPad = iPad; - - app.DebugPrintf( - "Updating leaderboard view LEADERBOARD_TRAVELLING_EASY\n"); - scores[viewCount].m_difficulty = 1; - - scores[viewCount].m_commentData.m_statsType = - LeaderboardManager::eStatsType_Travelling; - - scores[viewCount].m_commentData.m_travelling.m_walked = - getValue(Stats::walkOneM, eDifficulty_Easy); - scores[viewCount].m_commentData.m_travelling.m_fallen = - getValue(Stats::fallOneM, eDifficulty_Easy); - scores[viewCount].m_commentData.m_travelling.m_minecart = - getValue(Stats::minecartOneM, eDifficulty_Easy); - scores[viewCount].m_commentData.m_travelling.m_boat = - getValue(Stats::boatOneM, eDifficulty_Easy); - - scores[viewCount].m_score = - scores[viewCount].m_commentData.m_travelling.m_walked + - scores[viewCount].m_commentData.m_travelling.m_fallen + - scores[viewCount].m_commentData.m_travelling.m_minecart + - scores[viewCount].m_commentData.m_travelling.m_boat; - - viewCount++; - } - - if (modifiedBoards & LEADERBOARD_TRAVELLING_NORMAL) { - scores[viewCount].m_iPad = iPad; - - app.DebugPrintf( - "Updating leaderboard view LEADERBOARD_TRAVELLING_NORMAL\n"); - scores[viewCount].m_difficulty = 2; - - scores[viewCount].m_commentData.m_statsType = - LeaderboardManager::eStatsType_Travelling; - - scores[viewCount].m_commentData.m_travelling.m_walked = - getValue(Stats::walkOneM, eDifficulty_Normal); - scores[viewCount].m_commentData.m_travelling.m_fallen = - getValue(Stats::fallOneM, eDifficulty_Normal); - scores[viewCount].m_commentData.m_travelling.m_minecart = - getValue(Stats::minecartOneM, eDifficulty_Normal); - scores[viewCount].m_commentData.m_travelling.m_boat = - getValue(Stats::boatOneM, eDifficulty_Normal); - - scores[viewCount].m_score = - scores[viewCount].m_commentData.m_travelling.m_walked + - scores[viewCount].m_commentData.m_travelling.m_fallen + - scores[viewCount].m_commentData.m_travelling.m_minecart + - scores[viewCount].m_commentData.m_travelling.m_boat; - - viewCount++; - } - - if (modifiedBoards & LEADERBOARD_TRAVELLING_HARD) { - scores[viewCount].m_iPad = iPad; - - app.DebugPrintf( - "Updating leaderboard view LEADERBOARD_TRAVELLING_HARD\n"); - scores[viewCount].m_difficulty = 3; - - scores[viewCount].m_commentData.m_statsType = - LeaderboardManager::eStatsType_Travelling; - - scores[viewCount].m_commentData.m_travelling.m_walked = - getValue(Stats::walkOneM, eDifficulty_Hard); - scores[viewCount].m_commentData.m_travelling.m_fallen = - getValue(Stats::fallOneM, eDifficulty_Hard); - scores[viewCount].m_commentData.m_travelling.m_minecart = - getValue(Stats::minecartOneM, eDifficulty_Hard); - scores[viewCount].m_commentData.m_travelling.m_boat = - getValue(Stats::boatOneM, eDifficulty_Hard); - - scores[viewCount].m_score = - scores[viewCount].m_commentData.m_travelling.m_walked + - scores[viewCount].m_commentData.m_travelling.m_fallen + - scores[viewCount].m_commentData.m_travelling.m_minecart + - scores[viewCount].m_commentData.m_travelling.m_boat; - - viewCount++; - } - - if (modifiedBoards & - (LEADERBOARD_TRAVELLING_PEACEFUL | LEADERBOARD_TRAVELLING_EASY | - LEADERBOARD_TRAVELLING_NORMAL | LEADERBOARD_TRAVELLING_HARD)) { - app.DebugPrintf( - "Updating leaderboard view LEADERBOARD_TRAVELLING_PEACEFUL | " - "LEADERBOARD_TRAVELLING_EASY | LEADERBOARD_TRAVELLING_NORMAL | " - "LEADERBOARD_TRAVELLING_HARD\n"); - - // viewCount++; - } - - if (viewCount > 0) { - if (!LeaderboardManager::Instance()->WriteStats(viewCount, scores)) { - app.DebugPrintf("Failed to write to leaderboard\n"); - assert(false); // && "Failed to write to leaderboard"); - // printf("Failed to write to leaderboard"); - } else { - app.DebugPrintf("Successfully wrote %d leadeboard views\n", - viewCount); - } - } else { - delete[] scores; - } - -#elif 0 - - LONGLONG rating; - - XSESSION_VIEW_PROPERTIES views[24]; - - XUSER_PROPERTY killsEasyProperties[LeaderboardManager::eProperty_Kills_Max]; - XUSER_PROPERTY - killsNormalProperties[LeaderboardManager::eProperty_Kills_Max]; - XUSER_PROPERTY killsHardProperties[LeaderboardManager::eProperty_Kills_Max]; - XUSER_PROPERTY miningBlocksPeacefulProperties - [LeaderboardManager::eProperty_Mining_Max]; - XUSER_PROPERTY - miningBlocksEasyProperties[LeaderboardManager::eProperty_Mining_Max]; - XUSER_PROPERTY - miningBlocksNormalProperties[LeaderboardManager::eProperty_Mining_Max]; - XUSER_PROPERTY - miningBlocksHardProperties[LeaderboardManager::eProperty_Mining_Max]; - XUSER_PROPERTY - farmingPeacefulProperties[LeaderboardManager::eProperty_Farming_Max]; - XUSER_PROPERTY - farmingEasyProperties[LeaderboardManager::eProperty_Farming_Max]; - XUSER_PROPERTY - farmingNormalProperties[LeaderboardManager::eProperty_Farming_Max]; - XUSER_PROPERTY - farmingHardProperties[LeaderboardManager::eProperty_Farming_Max]; - XUSER_PROPERTY travellingPeacefulProperties - [LeaderboardManager::eProperty_Travelling_Max]; - XUSER_PROPERTY - travellingEasyProperties[LeaderboardManager::eProperty_Travelling_Max]; - XUSER_PROPERTY travellingNormalProperties - [LeaderboardManager::eProperty_Travelling_Max]; - XUSER_PROPERTY - travellingHardProperties[LeaderboardManager::eProperty_Travelling_Max]; - XUSER_PROPERTY travellingProperties[1]; // arcade leaderboard - - if (modifiedBoards & LEADERBOARD_KILLS_EASY) { - app.DebugPrintf("Updating leaderboard view LEADERBOARD_KILLS_EASY\n"); - views[viewCount].dwViewId = STATS_VIEW_KILLS_EASY; - views[viewCount].dwNumProperties = - LeaderboardManager::eProperty_Kills_Max; - views[viewCount].pProperties = killsEasyProperties; - - rating = getValue(Stats::killsZombie, eDifficulty_Easy) + - getValue(Stats::killsSkeleton, eDifficulty_Easy) + - getValue(Stats::killsCreeper, eDifficulty_Easy) + - getValue(Stats::killsSpider, eDifficulty_Easy) + - getValue(Stats::killsSpiderJockey, eDifficulty_Easy) + - getValue(Stats::killsZombiePigman, eDifficulty_Easy) + - getValue(Stats::killsNetherZombiePigman, eDifficulty_Easy) + - getValue(Stats::killsSlime, eDifficulty_Easy); - - setLeaderboardProperty( - &killsEasyProperties[LeaderboardManager::eProperty_Kills_Zombie], - PROPERTY_KILLS_ZOMBIE, - getValue(Stats::killsZombie, eDifficulty_Easy)); - setLeaderboardProperty( - &killsEasyProperties[LeaderboardManager::eProperty_Kills_Skeleton], - PROPERTY_KILLS_SKELETON, - getValue(Stats::killsSkeleton, eDifficulty_Easy)); - setLeaderboardProperty( - &killsEasyProperties[LeaderboardManager::eProperty_Kills_Creeper], - PROPERTY_KILLS_CREEPER, - getValue(Stats::killsCreeper, eDifficulty_Easy)); - setLeaderboardProperty( - &killsEasyProperties[LeaderboardManager::eProperty_Kills_Spider], - PROPERTY_KILLS_SPIDER, - getValue(Stats::killsSpider, eDifficulty_Easy)); - setLeaderboardProperty( - &killsEasyProperties - [LeaderboardManager::eProperty_Kills_SpiderJockey], - PROPERTY_KILLS_SPIDERJOCKEY, - getValue(Stats::killsSpiderJockey, eDifficulty_Easy)); - // 4J-PB - this could overflow - // setLeaderboardProperty( - // &killsEasyProperties[LeaderboardManager::eProperty_Kills_ZombiePigman - // ], PROPERTY_KILLS_ZOMBIEPIGMAN, - // getValue(Stats::killsZombiePigman, eDifficulty_Easy) + - // getValue(Stats::killsNetherZombiePigman, eDifficulty_Easy) ); - ULONGLONG ulTemp = - getValue(Stats::killsZombiePigman, eDifficulty_Easy) + - getValue(Stats::killsNetherZombiePigman, eDifficulty_Easy); - setLeaderboardProperty( - &killsEasyProperties - [LeaderboardManager::eProperty_Kills_ZombiePigman], - PROPERTY_KILLS_ZOMBIEPIGMAN, - (ulTemp > 0xFFFFFFFFLL) ? 0xFFFFFFFF : (unsigned int)ulTemp); - - setLeaderboardProperty( - &killsEasyProperties[LeaderboardManager::eProperty_Kills_Slime], - PROPERTY_KILLS_SLIME, - getValue(Stats::killsSlime, eDifficulty_Easy)); - setLeaderboardRating( - &killsEasyProperties[LeaderboardManager::eProperty_Kills_Rating], - rating); - - viewCount++; - } - - if (modifiedBoards & LEADERBOARD_KILLS_NORMAL) { - app.DebugPrintf("Updating leaderboard view LEADERBOARD_KILLS_NORMAL\n"); - views[viewCount].dwViewId = STATS_VIEW_KILLS_NORMAL; - views[viewCount].dwNumProperties = - LeaderboardManager::eProperty_Kills_Max; - views[viewCount].pProperties = killsNormalProperties; - - rating = getValue(Stats::killsZombie, eDifficulty_Normal) + - getValue(Stats::killsSkeleton, eDifficulty_Normal) + - getValue(Stats::killsCreeper, eDifficulty_Normal) + - getValue(Stats::killsSpider, eDifficulty_Normal) + - getValue(Stats::killsSpiderJockey, eDifficulty_Normal) + - getValue(Stats::killsZombiePigman, eDifficulty_Normal) + - getValue(Stats::killsNetherZombiePigman, eDifficulty_Normal) + - getValue(Stats::killsSlime, eDifficulty_Normal); - - setLeaderboardProperty( - &killsNormalProperties[LeaderboardManager::eProperty_Kills_Zombie], - PROPERTY_KILLS_ZOMBIE, - getValue(Stats::killsZombie, eDifficulty_Normal)); - setLeaderboardProperty( - &killsNormalProperties - [LeaderboardManager::eProperty_Kills_Skeleton], - PROPERTY_KILLS_SKELETON, - getValue(Stats::killsSkeleton, eDifficulty_Normal)); - setLeaderboardProperty( - &killsNormalProperties[LeaderboardManager::eProperty_Kills_Creeper], - PROPERTY_KILLS_CREEPER, - getValue(Stats::killsCreeper, eDifficulty_Normal)); - setLeaderboardProperty( - &killsNormalProperties[LeaderboardManager::eProperty_Kills_Spider], - PROPERTY_KILLS_SPIDER, - getValue(Stats::killsSpider, eDifficulty_Normal)); - setLeaderboardProperty( - &killsNormalProperties - [LeaderboardManager::eProperty_Kills_SpiderJockey], - PROPERTY_KILLS_SPIDERJOCKEY, - getValue(Stats::killsSpiderJockey, eDifficulty_Normal)); - // 4J-PB - this could overflow - ULONGLONG ulTemp = - getValue(Stats::killsZombiePigman, eDifficulty_Normal) + - getValue(Stats::killsNetherZombiePigman, eDifficulty_Normal); - // setLeaderboardProperty( - // &killsNormalProperties[LeaderboardManager::eProperty_Kills_ZombiePigman - // ], PROPERTY_KILLS_ZOMBIEPIGMAN, - // getValue(Stats::killsZombiePigman, eDifficulty_Normal) + - // getValue(Stats::killsNetherZombiePigman, eDifficulty_Normal) ); - setLeaderboardProperty( - &killsNormalProperties - [LeaderboardManager::eProperty_Kills_ZombiePigman], - PROPERTY_KILLS_ZOMBIEPIGMAN, - (ulTemp > 0xFFFFFFFFLL) ? 0xFFFFFFFF : (unsigned int)ulTemp); - - setLeaderboardProperty( - &killsNormalProperties[LeaderboardManager::eProperty_Kills_Slime], - PROPERTY_KILLS_SLIME, - getValue(Stats::killsSlime, eDifficulty_Normal)); - setLeaderboardRating( - &killsNormalProperties[LeaderboardManager::eProperty_Kills_Rating], - rating); - - viewCount++; - } - - if (modifiedBoards & LEADERBOARD_KILLS_HARD) { - app.DebugPrintf("Updating leaderboard view LEADERBOARD_KILLS_HARD\n"); - views[viewCount].dwViewId = STATS_VIEW_KILLS_HARD; - views[viewCount].dwNumProperties = - LeaderboardManager::eProperty_Kills_Max; - views[viewCount].pProperties = killsHardProperties; - - rating = getValue(Stats::killsZombie, eDifficulty_Hard) + - getValue(Stats::killsSkeleton, eDifficulty_Hard) + - getValue(Stats::killsCreeper, eDifficulty_Hard) + - getValue(Stats::killsSpider, eDifficulty_Hard) + - getValue(Stats::killsSpiderJockey, eDifficulty_Hard) + - getValue(Stats::killsZombiePigman, eDifficulty_Hard) + - getValue(Stats::killsNetherZombiePigman, eDifficulty_Hard) + - getValue(Stats::killsSlime, eDifficulty_Hard); - - setLeaderboardProperty( - &killsHardProperties[LeaderboardManager::eProperty_Kills_Zombie], - PROPERTY_KILLS_ZOMBIE, - getValue(Stats::killsZombie, eDifficulty_Hard)); - setLeaderboardProperty( - &killsHardProperties[LeaderboardManager::eProperty_Kills_Skeleton], - PROPERTY_KILLS_SKELETON, - getValue(Stats::killsSkeleton, eDifficulty_Hard)); - setLeaderboardProperty( - &killsHardProperties[LeaderboardManager::eProperty_Kills_Creeper], - PROPERTY_KILLS_CREEPER, - getValue(Stats::killsCreeper, eDifficulty_Hard)); - setLeaderboardProperty( - &killsHardProperties[LeaderboardManager::eProperty_Kills_Spider], - PROPERTY_KILLS_SPIDER, - getValue(Stats::killsSpider, eDifficulty_Hard)); - setLeaderboardProperty( - &killsHardProperties - [LeaderboardManager::eProperty_Kills_SpiderJockey], - PROPERTY_KILLS_SPIDERJOCKEY, - getValue(Stats::killsSpiderJockey, eDifficulty_Hard)); - // 4J-PB - this could overflow - ULONGLONG ulTemp = - getValue(Stats::killsZombiePigman, eDifficulty_Hard) + - getValue(Stats::killsNetherZombiePigman, eDifficulty_Hard); - // setLeaderboardProperty( - // &killsHardProperties[LeaderboardManager::eProperty_Kills_ZombiePigman - // ], PROPERTY_KILLS_ZOMBIEPIGMAN, - // getValue(Stats::killsZombiePigman, eDifficulty_Hard) + - // getValue(Stats::killsNetherZombiePigman, eDifficulty_Hard) ); - setLeaderboardProperty( - &killsHardProperties - [LeaderboardManager::eProperty_Kills_ZombiePigman], - PROPERTY_KILLS_ZOMBIEPIGMAN, - (ulTemp > 0xFFFFFFFFLL) ? 0xFFFFFFFF : (unsigned int)ulTemp); - - setLeaderboardProperty( - &killsHardProperties[LeaderboardManager::eProperty_Kills_Slime], - PROPERTY_KILLS_SLIME, - getValue(Stats::killsSlime, eDifficulty_Hard)); - setLeaderboardRating( - &killsHardProperties[LeaderboardManager::eProperty_Kills_Rating], - rating); - - viewCount++; - } - - if (modifiedBoards & LEADERBOARD_MININGBLOCKS_PEACEFUL) { - app.DebugPrintf( - "Updating leaderboard view LEADERBOARD_MININGBLOCKS_PEACEFUL\n"); - views[viewCount].dwViewId = STATS_VIEW_MINING_BLOCKS_PEACEFUL; - views[viewCount].dwNumProperties = - LeaderboardManager::eProperty_Mining_Max; - views[viewCount].pProperties = miningBlocksPeacefulProperties; - - rating = - getValue(Stats::blocksMined[Tile::dirt->id], eDifficulty_Peaceful) + - getValue(Stats::blocksMined[Tile::cobblestone->id], - eDifficulty_Peaceful) + - getValue(Stats::blocksMined[Tile::sand->id], eDifficulty_Peaceful) + - getValue(Stats::blocksMined[Tile::stone->id], - eDifficulty_Peaceful) + - getValue(Stats::blocksMined[Tile::gravel->id], - eDifficulty_Peaceful) + - getValue(Stats::blocksMined[Tile::clay->id], eDifficulty_Peaceful) + - getValue(Stats::blocksMined[Tile::obsidian->id], - eDifficulty_Peaceful); - - setLeaderboardProperty( - &miningBlocksPeacefulProperties - [LeaderboardManager::eProperty_Mining_Dirt], - PROPERTY_MINED_DIRT, - getValue(Stats::blocksMined[Tile::dirt->id], eDifficulty_Peaceful)); - setLeaderboardProperty( - &miningBlocksPeacefulProperties - [LeaderboardManager::eProperty_Mining_Stone], - PROPERTY_MINED_STONE, - getValue(Stats::blocksMined[Tile::cobblestone->id], - eDifficulty_Peaceful)); - setLeaderboardProperty( - &miningBlocksPeacefulProperties - [LeaderboardManager::eProperty_Mining_Sand], - PROPERTY_MINED_SAND, - getValue(Stats::blocksMined[Tile::sand->id], eDifficulty_Peaceful)); - setLeaderboardProperty( - &miningBlocksPeacefulProperties - [LeaderboardManager::eProperty_Mining_Cobblestone], - PROPERTY_MINED_COBBLESTONE, - getValue(Stats::blocksMined[Tile::stone->id], - eDifficulty_Peaceful)); - setLeaderboardProperty( - &miningBlocksPeacefulProperties - [LeaderboardManager::eProperty_Mining_Gravel], - PROPERTY_MINED_GRAVEL, - getValue(Stats::blocksMined[Tile::gravel->id], - eDifficulty_Peaceful)); - setLeaderboardProperty( - &miningBlocksPeacefulProperties - [LeaderboardManager::eProperty_Mining_Clay], - PROPERTY_MINED_CLAY, - getValue(Stats::blocksMined[Tile::clay->id], eDifficulty_Peaceful)); - setLeaderboardProperty( - &miningBlocksPeacefulProperties - [LeaderboardManager::eProperty_Mining_Obsidian], - PROPERTY_MINED_OBSIDIAN, - getValue(Stats::blocksMined[Tile::obsidian->id], - eDifficulty_Peaceful)); - setLeaderboardRating(&miningBlocksPeacefulProperties - [LeaderboardManager::eProperty_Mining_Rating], - rating); - - viewCount++; - } - - if (modifiedBoards & LEADERBOARD_MININGBLOCKS_EASY) { - app.DebugPrintf( - "Updating leaderboard view LEADERBOARD_MININGBLOCKS_EASY\n"); - views[viewCount].dwViewId = STATS_VIEW_MINING_BLOCKS_EASY; - views[viewCount].dwNumProperties = - LeaderboardManager::eProperty_Mining_Max; - views[viewCount].pProperties = miningBlocksEasyProperties; - - rating = - getValue(Stats::blocksMined[Tile::dirt->id], eDifficulty_Easy) + - getValue(Stats::blocksMined[Tile::cobblestone->id], - eDifficulty_Easy) + - getValue(Stats::blocksMined[Tile::sand->id], eDifficulty_Easy) + - getValue(Stats::blocksMined[Tile::stone->id], eDifficulty_Easy) + - getValue(Stats::blocksMined[Tile::gravel->id], eDifficulty_Easy) + - getValue(Stats::blocksMined[Tile::clay->id], eDifficulty_Easy) + - getValue(Stats::blocksMined[Tile::obsidian->id], eDifficulty_Easy); - - setLeaderboardProperty( - &miningBlocksEasyProperties - [LeaderboardManager::eProperty_Mining_Dirt], - PROPERTY_MINED_DIRT, - getValue(Stats::blocksMined[Tile::dirt->id], eDifficulty_Easy)); - setLeaderboardProperty( - &miningBlocksEasyProperties - [LeaderboardManager::eProperty_Mining_Stone], - PROPERTY_MINED_STONE, - getValue(Stats::blocksMined[Tile::cobblestone->id], - eDifficulty_Easy)); - setLeaderboardProperty( - &miningBlocksEasyProperties - [LeaderboardManager::eProperty_Mining_Sand], - PROPERTY_MINED_SAND, - getValue(Stats::blocksMined[Tile::sand->id], eDifficulty_Easy)); - setLeaderboardProperty( - &miningBlocksEasyProperties - [LeaderboardManager::eProperty_Mining_Cobblestone], - PROPERTY_MINED_COBBLESTONE, - getValue(Stats::blocksMined[Tile::stone->id], eDifficulty_Easy)); - setLeaderboardProperty( - &miningBlocksEasyProperties - [LeaderboardManager::eProperty_Mining_Gravel], - PROPERTY_MINED_GRAVEL, - getValue(Stats::blocksMined[Tile::gravel->id], eDifficulty_Easy)); - setLeaderboardProperty( - &miningBlocksEasyProperties - [LeaderboardManager::eProperty_Mining_Clay], - PROPERTY_MINED_CLAY, - getValue(Stats::blocksMined[Tile::clay->id], eDifficulty_Easy)); - setLeaderboardProperty( - &miningBlocksEasyProperties - [LeaderboardManager::eProperty_Mining_Obsidian], - PROPERTY_MINED_OBSIDIAN, - getValue(Stats::blocksMined[Tile::obsidian->id], eDifficulty_Easy)); - setLeaderboardRating(&miningBlocksEasyProperties - [LeaderboardManager::eProperty_Mining_Rating], - rating); - - viewCount++; - } - - if (modifiedBoards & LEADERBOARD_MININGBLOCKS_NORMAL) { - app.DebugPrintf( - "Updating leaderboard view LEADERBOARD_MININGBLOCKS_NORMAL\n"); - views[viewCount].dwViewId = STATS_VIEW_MINING_BLOCKS_NORMAL; - views[viewCount].dwNumProperties = - LeaderboardManager::eProperty_Mining_Max; - views[viewCount].pProperties = miningBlocksNormalProperties; - - rating = - getValue(Stats::blocksMined[Tile::dirt->id], eDifficulty_Normal) + - getValue(Stats::blocksMined[Tile::cobblestone->id], - eDifficulty_Normal) + - getValue(Stats::blocksMined[Tile::sand->id], eDifficulty_Normal) + - getValue(Stats::blocksMined[Tile::stone->id], eDifficulty_Normal) + - getValue(Stats::blocksMined[Tile::gravel->id], eDifficulty_Normal) + - getValue(Stats::blocksMined[Tile::clay->id], eDifficulty_Normal) + - getValue(Stats::blocksMined[Tile::obsidian->id], - eDifficulty_Normal); - - setLeaderboardProperty( - &miningBlocksNormalProperties - [LeaderboardManager::eProperty_Mining_Dirt], - PROPERTY_MINED_DIRT, - getValue(Stats::blocksMined[Tile::dirt->id], eDifficulty_Normal)); - setLeaderboardProperty( - &miningBlocksNormalProperties - [LeaderboardManager::eProperty_Mining_Stone], - PROPERTY_MINED_STONE, - getValue(Stats::blocksMined[Tile::cobblestone->id], - eDifficulty_Normal)); - setLeaderboardProperty( - &miningBlocksNormalProperties - [LeaderboardManager::eProperty_Mining_Sand], - PROPERTY_MINED_SAND, - getValue(Stats::blocksMined[Tile::sand->id], eDifficulty_Normal)); - setLeaderboardProperty( - &miningBlocksNormalProperties - [LeaderboardManager::eProperty_Mining_Cobblestone], - PROPERTY_MINED_COBBLESTONE, - getValue(Stats::blocksMined[Tile::stone->id], eDifficulty_Normal)); - setLeaderboardProperty( - &miningBlocksNormalProperties - [LeaderboardManager::eProperty_Mining_Gravel], - PROPERTY_MINED_GRAVEL, - getValue(Stats::blocksMined[Tile::gravel->id], eDifficulty_Normal)); - setLeaderboardProperty( - &miningBlocksNormalProperties - [LeaderboardManager::eProperty_Mining_Clay], - PROPERTY_MINED_CLAY, - getValue(Stats::blocksMined[Tile::clay->id], eDifficulty_Normal)); - setLeaderboardProperty( - &miningBlocksNormalProperties - [LeaderboardManager::eProperty_Mining_Obsidian], - PROPERTY_MINED_OBSIDIAN, - getValue(Stats::blocksMined[Tile::obsidian->id], - eDifficulty_Normal)); - setLeaderboardRating(&miningBlocksNormalProperties - [LeaderboardManager::eProperty_Mining_Rating], - rating); - - viewCount++; - } - - if (modifiedBoards & LEADERBOARD_MININGBLOCKS_HARD) { - app.DebugPrintf( - "Updating leaderboard view LEADERBOARD_MININGBLOCKS_HARD\n"); - views[viewCount].dwViewId = STATS_VIEW_MINING_BLOCKS_HARD; - views[viewCount].dwNumProperties = - LeaderboardManager::eProperty_Mining_Max; - views[viewCount].pProperties = miningBlocksHardProperties; - - rating = - getValue(Stats::blocksMined[Tile::dirt->id], eDifficulty_Hard) + - getValue(Stats::blocksMined[Tile::cobblestone->id], - eDifficulty_Hard) + - getValue(Stats::blocksMined[Tile::sand->id], eDifficulty_Hard) + - getValue(Stats::blocksMined[Tile::stone->id], eDifficulty_Hard) + - getValue(Stats::blocksMined[Tile::gravel->id], eDifficulty_Hard) + - getValue(Stats::blocksMined[Tile::clay->id], eDifficulty_Hard) + - getValue(Stats::blocksMined[Tile::obsidian->id], eDifficulty_Hard); - - setLeaderboardProperty( - &miningBlocksHardProperties - [LeaderboardManager::eProperty_Mining_Dirt], - PROPERTY_MINED_DIRT, - getValue(Stats::blocksMined[Tile::dirt->id], eDifficulty_Hard)); - setLeaderboardProperty( - &miningBlocksHardProperties - [LeaderboardManager::eProperty_Mining_Stone], - PROPERTY_MINED_STONE, - getValue(Stats::blocksMined[Tile::cobblestone->id], - eDifficulty_Hard)); - setLeaderboardProperty( - &miningBlocksHardProperties - [LeaderboardManager::eProperty_Mining_Sand], - PROPERTY_MINED_SAND, - getValue(Stats::blocksMined[Tile::sand->id], eDifficulty_Hard)); - setLeaderboardProperty( - &miningBlocksHardProperties - [LeaderboardManager::eProperty_Mining_Cobblestone], - PROPERTY_MINED_COBBLESTONE, - getValue(Stats::blocksMined[Tile::stone->id], eDifficulty_Hard)); - setLeaderboardProperty( - &miningBlocksHardProperties - [LeaderboardManager::eProperty_Mining_Gravel], - PROPERTY_MINED_GRAVEL, - getValue(Stats::blocksMined[Tile::gravel->id], eDifficulty_Hard)); - setLeaderboardProperty( - &miningBlocksHardProperties - [LeaderboardManager::eProperty_Mining_Clay], - PROPERTY_MINED_CLAY, - getValue(Stats::blocksMined[Tile::clay->id], eDifficulty_Hard)); - setLeaderboardProperty( - &miningBlocksHardProperties - [LeaderboardManager::eProperty_Mining_Obsidian], - PROPERTY_MINED_OBSIDIAN, - getValue(Stats::blocksMined[Tile::obsidian->id], eDifficulty_Hard)); - setLeaderboardRating(&miningBlocksHardProperties - [LeaderboardManager::eProperty_Mining_Rating], - rating); - - viewCount++; - } - - if (modifiedBoards & LEADERBOARD_FARMING_PEACEFUL) { - app.DebugPrintf( - "Updating leaderboard view LEADERBOARD_FARMING_PEACEFUL\n"); - views[viewCount].dwViewId = STATS_VIEW_FARMING_PEACEFUL; - views[viewCount].dwNumProperties = - LeaderboardManager::eProperty_Farming_Max; - views[viewCount].pProperties = farmingPeacefulProperties; - - rating = - getValue(Stats::itemsCollected[Item::egg->id], - eDifficulty_Peaceful) + - getValue(Stats::blocksMined[Tile::wheat_Id], eDifficulty_Peaceful) + - getValue(Stats::blocksMined[Tile::mushroom_brown_Id], - eDifficulty_Peaceful) + - getValue(Stats::blocksMined[Tile::reeds_Id], eDifficulty_Peaceful) + - getValue(Stats::cowsMilked, eDifficulty_Peaceful) + - getValue(Stats::itemsCollected[Tile::pumpkin->id], - eDifficulty_Peaceful); - - setLeaderboardProperty(&farmingPeacefulProperties - [LeaderboardManager::eProperty_Farming_Egg], - PROPERTY_COLLECTED_EGG, - getValue(Stats::itemsCollected[Item::egg->id], - eDifficulty_Peaceful)); - setLeaderboardProperty( - &farmingPeacefulProperties - [LeaderboardManager::eProperty_Farming_Wheat], - PROPERTY_COLLECTED_WHEAT, - getValue(Stats::blocksMined[Tile::wheat_Id], eDifficulty_Peaceful)); - setLeaderboardProperty( - &farmingPeacefulProperties - [LeaderboardManager::eProperty_Farming_Mushroom], - PROPERTY_COLLECTED_MUSHROOM, - getValue(Stats::blocksMined[Tile::mushroom_brown_Id], - eDifficulty_Peaceful)); - setLeaderboardProperty( - &farmingPeacefulProperties - [LeaderboardManager::eProperty_Farming_Sugarcane], - PROPERTY_COLLECTED_SUGARCANE, - getValue(Stats::blocksMined[Tile::reeds_Id], eDifficulty_Peaceful)); - setLeaderboardProperty( - &farmingPeacefulProperties - [LeaderboardManager::eProperty_Farming_Milk], - PROPERTY_COLLECTED_MILK, - getValue(Stats::cowsMilked, eDifficulty_Peaceful)); - setLeaderboardProperty( - &farmingPeacefulProperties - [LeaderboardManager::eProperty_Farming_Pumpkin], - PROPERTY_COLLECTED_PUMPKIN, - getValue(Stats::itemsCollected[Tile::pumpkin->id], - eDifficulty_Peaceful)); - setLeaderboardRating(&farmingPeacefulProperties - [LeaderboardManager::eProperty_Farming_Rating], - rating); - - viewCount++; - } - - if (modifiedBoards & LEADERBOARD_FARMING_EASY) { - app.DebugPrintf("Updating leaderboard view LEADERBOARD_FARMING_EASY\n"); - views[viewCount].dwViewId = STATS_VIEW_FARMING_EASY; - views[viewCount].dwNumProperties = - LeaderboardManager::eProperty_Farming_Max; - views[viewCount].pProperties = farmingEasyProperties; - - rating = - getValue(Stats::itemsCollected[Item::egg->id], eDifficulty_Easy) + - getValue(Stats::blocksMined[Tile::wheat_Id], eDifficulty_Easy) + - getValue(Stats::blocksMined[Tile::mushroom_brown_Id], - eDifficulty_Easy) + - getValue(Stats::blocksMined[Tile::reeds_Id], eDifficulty_Easy) + - getValue(Stats::cowsMilked, eDifficulty_Easy) + - getValue(Stats::itemsCollected[Tile::pumpkin->id], - eDifficulty_Easy); - - setLeaderboardProperty( - &farmingEasyProperties[LeaderboardManager::eProperty_Farming_Egg], - PROPERTY_COLLECTED_EGG, - getValue(Stats::itemsCollected[Item::egg->id], eDifficulty_Easy)); - setLeaderboardProperty( - &farmingEasyProperties[LeaderboardManager::eProperty_Farming_Wheat], - PROPERTY_COLLECTED_WHEAT, - getValue(Stats::blocksMined[Tile::wheat_Id], eDifficulty_Easy)); - setLeaderboardProperty( - &farmingEasyProperties - [LeaderboardManager::eProperty_Farming_Mushroom], - PROPERTY_COLLECTED_MUSHROOM, - getValue(Stats::blocksMined[Tile::mushroom_brown_Id], - eDifficulty_Easy)); - setLeaderboardProperty( - &farmingEasyProperties - [LeaderboardManager::eProperty_Farming_Sugarcane], - PROPERTY_COLLECTED_SUGARCANE, - getValue(Stats::blocksMined[Tile::reeds_Id], eDifficulty_Easy)); - setLeaderboardProperty( - &farmingEasyProperties[LeaderboardManager::eProperty_Farming_Milk], - PROPERTY_COLLECTED_MILK, - getValue(Stats::cowsMilked, eDifficulty_Easy)); - setLeaderboardProperty( - &farmingEasyProperties - [LeaderboardManager::eProperty_Farming_Pumpkin], - PROPERTY_COLLECTED_PUMPKIN, - getValue(Stats::itemsCollected[Tile::pumpkin->id], - eDifficulty_Easy)); - setLeaderboardRating(&farmingEasyProperties - [LeaderboardManager::eProperty_Farming_Rating], - rating); - - viewCount++; - } - - if (modifiedBoards & LEADERBOARD_FARMING_NORMAL) { - app.DebugPrintf( - "Updating leaderboard view LEADERBOARD_FARMING_NORMAL\n"); - views[viewCount].dwViewId = STATS_VIEW_FARMING_NORMAL; - views[viewCount].dwNumProperties = - LeaderboardManager::eProperty_Farming_Max; - views[viewCount].pProperties = farmingNormalProperties; - - rating = - getValue(Stats::itemsCollected[Item::egg->id], eDifficulty_Normal) + - getValue(Stats::blocksMined[Tile::wheat_Id], eDifficulty_Normal) + - getValue(Stats::blocksMined[Tile::mushroom_brown_Id], - eDifficulty_Normal) + - getValue(Stats::blocksMined[Tile::reeds_Id], eDifficulty_Normal) + - getValue(Stats::cowsMilked, eDifficulty_Normal) + - getValue(Stats::itemsCollected[Tile::pumpkin->id], - eDifficulty_Normal); - - setLeaderboardProperty( - &farmingNormalProperties[LeaderboardManager::eProperty_Farming_Egg], - PROPERTY_COLLECTED_EGG, - getValue(Stats::itemsCollected[Item::egg->id], eDifficulty_Normal)); - setLeaderboardProperty( - &farmingNormalProperties - [LeaderboardManager::eProperty_Farming_Wheat], - PROPERTY_COLLECTED_WHEAT, - getValue(Stats::blocksMined[Tile::wheat_Id], eDifficulty_Normal)); - setLeaderboardProperty( - &farmingNormalProperties - [LeaderboardManager::eProperty_Farming_Mushroom], - PROPERTY_COLLECTED_MUSHROOM, - getValue(Stats::blocksMined[Tile::mushroom_brown_Id], - eDifficulty_Normal)); - setLeaderboardProperty( - &farmingNormalProperties - [LeaderboardManager::eProperty_Farming_Sugarcane], - PROPERTY_COLLECTED_SUGARCANE, - getValue(Stats::blocksMined[Tile::reeds_Id], eDifficulty_Normal)); - setLeaderboardProperty(&farmingNormalProperties - [LeaderboardManager::eProperty_Farming_Milk], - PROPERTY_COLLECTED_MILK, - getValue(Stats::cowsMilked, eDifficulty_Normal)); - setLeaderboardProperty( - &farmingNormalProperties - [LeaderboardManager::eProperty_Farming_Pumpkin], - PROPERTY_COLLECTED_PUMPKIN, - getValue(Stats::itemsCollected[Tile::pumpkin->id], - eDifficulty_Normal)); - setLeaderboardRating(&farmingNormalProperties - [LeaderboardManager::eProperty_Farming_Rating], - rating); - - viewCount++; - } - - if (modifiedBoards & LEADERBOARD_FARMING_HARD) { - app.DebugPrintf("Updating leaderboard view LEADERBOARD_FARMING_HARD\n"); - views[viewCount].dwViewId = STATS_VIEW_FARMING_HARD; - views[viewCount].dwNumProperties = - LeaderboardManager::eProperty_Farming_Max; - views[viewCount].pProperties = farmingHardProperties; - - rating = - getValue(Stats::itemsCollected[Item::egg->id], eDifficulty_Hard) + - getValue(Stats::blocksMined[Tile::wheat_Id], eDifficulty_Hard) + - getValue(Stats::blocksMined[Tile::mushroom_brown_Id], - eDifficulty_Hard) + - getValue(Stats::blocksMined[Tile::reeds_Id], eDifficulty_Hard) + - getValue(Stats::cowsMilked, eDifficulty_Hard) + - getValue(Stats::itemsCollected[Tile::pumpkin->id], - eDifficulty_Hard); - - setLeaderboardProperty( - &farmingHardProperties[LeaderboardManager::eProperty_Farming_Egg], - PROPERTY_COLLECTED_EGG, - getValue(Stats::itemsCollected[Item::egg->id], eDifficulty_Hard)); - setLeaderboardProperty( - &farmingHardProperties[LeaderboardManager::eProperty_Farming_Wheat], - PROPERTY_COLLECTED_WHEAT, - getValue(Stats::blocksMined[Tile::wheat_Id], eDifficulty_Hard)); - setLeaderboardProperty( - &farmingHardProperties - [LeaderboardManager::eProperty_Farming_Mushroom], - PROPERTY_COLLECTED_MUSHROOM, - getValue(Stats::blocksMined[Tile::mushroom_brown_Id], - eDifficulty_Hard)); - setLeaderboardProperty( - &farmingHardProperties - [LeaderboardManager::eProperty_Farming_Sugarcane], - PROPERTY_COLLECTED_SUGARCANE, - getValue(Stats::blocksMined[Tile::reeds_Id], eDifficulty_Hard)); - setLeaderboardProperty( - &farmingHardProperties[LeaderboardManager::eProperty_Farming_Milk], - PROPERTY_COLLECTED_MILK, - getValue(Stats::cowsMilked, eDifficulty_Hard)); - setLeaderboardProperty( - &farmingHardProperties - [LeaderboardManager::eProperty_Farming_Pumpkin], - PROPERTY_COLLECTED_PUMPKIN, - getValue(Stats::itemsCollected[Tile::pumpkin->id], - eDifficulty_Hard)); - setLeaderboardRating(&farmingHardProperties - [LeaderboardManager::eProperty_Farming_Rating], - rating); - - viewCount++; - } - - if (modifiedBoards & LEADERBOARD_TRAVELLING_PEACEFUL) { - app.DebugPrintf( - "Updating leaderboard view LEADERBOARD_TRAVELLING_PEACEFUL\n"); - views[viewCount].dwViewId = STATS_VIEW_TRAVELLING_PEACEFUL; - views[viewCount].dwNumProperties = - LeaderboardManager::eProperty_Travelling_Max; - views[viewCount].pProperties = travellingPeacefulProperties; - - rating = getValue(Stats::walkOneM, eDifficulty_Peaceful) + - getValue(Stats::fallOneM, eDifficulty_Peaceful) + - getValue(Stats::minecartOneM, eDifficulty_Peaceful) + - getValue(Stats::boatOneM, eDifficulty_Peaceful); - - setLeaderboardProperty( - &travellingPeacefulProperties - [LeaderboardManager::eProperty_Travelling_Walked], - PROPERTY_TRAVEL_WALK, - getValue(Stats::walkOneM, eDifficulty_Peaceful)); - setLeaderboardProperty( - &travellingPeacefulProperties - [LeaderboardManager::eProperty_Travelling_Fallen], - PROPERTY_TRAVEL_FALL, - getValue(Stats::fallOneM, eDifficulty_Peaceful)); - setLeaderboardProperty( - &travellingPeacefulProperties - [LeaderboardManager::eProperty_Travelling_Minecart], - PROPERTY_TRAVEL_MINECART, - getValue(Stats::minecartOneM, eDifficulty_Peaceful)); - setLeaderboardProperty( - &travellingPeacefulProperties - [LeaderboardManager::eProperty_Travelling_Boat], - PROPERTY_TRAVEL_BOAT, - getValue(Stats::boatOneM, eDifficulty_Peaceful)); - setLeaderboardRating( - &travellingPeacefulProperties - [LeaderboardManager::eProperty_Travelling_Rating], - rating); - - viewCount++; - } - - if (modifiedBoards & LEADERBOARD_TRAVELLING_EASY) { - app.DebugPrintf( - "Updating leaderboard view LEADERBOARD_TRAVELLING_EASY\n"); - views[viewCount].dwViewId = STATS_VIEW_TRAVELLING_EASY; - views[viewCount].dwNumProperties = - LeaderboardManager::eProperty_Travelling_Max; - views[viewCount].pProperties = travellingEasyProperties; - - rating = getValue(Stats::walkOneM, eDifficulty_Easy) + - getValue(Stats::fallOneM, eDifficulty_Easy) + - getValue(Stats::minecartOneM, eDifficulty_Easy) + - getValue(Stats::boatOneM, eDifficulty_Easy); - - setLeaderboardProperty( - &travellingEasyProperties - [LeaderboardManager::eProperty_Travelling_Walked], - PROPERTY_TRAVEL_WALK, getValue(Stats::walkOneM, eDifficulty_Easy)); - setLeaderboardProperty( - &travellingEasyProperties - [LeaderboardManager::eProperty_Travelling_Fallen], - PROPERTY_TRAVEL_FALL, getValue(Stats::fallOneM, eDifficulty_Easy)); - setLeaderboardProperty( - &travellingEasyProperties - [LeaderboardManager::eProperty_Travelling_Minecart], - PROPERTY_TRAVEL_MINECART, - getValue(Stats::minecartOneM, eDifficulty_Easy)); - setLeaderboardProperty( - &travellingEasyProperties - [LeaderboardManager::eProperty_Travelling_Boat], - PROPERTY_TRAVEL_BOAT, getValue(Stats::boatOneM, eDifficulty_Easy)); - setLeaderboardRating( - &travellingEasyProperties - [LeaderboardManager::eProperty_Travelling_Rating], - rating); - - viewCount++; - } - - if (modifiedBoards & LEADERBOARD_TRAVELLING_NORMAL) { - app.DebugPrintf( - "Updating leaderboard view LEADERBOARD_TRAVELLING_NORMAL\n"); - views[viewCount].dwViewId = STATS_VIEW_TRAVELLING_NORMAL; - views[viewCount].dwNumProperties = - LeaderboardManager::eProperty_Travelling_Max; - views[viewCount].pProperties = travellingNormalProperties; - - rating = getValue(Stats::walkOneM, eDifficulty_Normal) + - getValue(Stats::fallOneM, eDifficulty_Normal) + - getValue(Stats::minecartOneM, eDifficulty_Normal) + - getValue(Stats::boatOneM, eDifficulty_Normal); - - setLeaderboardProperty( - &travellingNormalProperties - [LeaderboardManager::eProperty_Travelling_Walked], - PROPERTY_TRAVEL_WALK, - getValue(Stats::walkOneM, eDifficulty_Normal)); - setLeaderboardProperty( - &travellingNormalProperties - [LeaderboardManager::eProperty_Travelling_Fallen], - PROPERTY_TRAVEL_FALL, - getValue(Stats::fallOneM, eDifficulty_Normal)); - setLeaderboardProperty( - &travellingNormalProperties - [LeaderboardManager::eProperty_Travelling_Minecart], - PROPERTY_TRAVEL_MINECART, - getValue(Stats::minecartOneM, eDifficulty_Normal)); - setLeaderboardProperty( - &travellingNormalProperties - [LeaderboardManager::eProperty_Travelling_Boat], - PROPERTY_TRAVEL_BOAT, - getValue(Stats::boatOneM, eDifficulty_Normal)); - setLeaderboardRating( - &travellingNormalProperties - [LeaderboardManager::eProperty_Travelling_Rating], - rating); - - viewCount++; - } - - if (modifiedBoards & LEADERBOARD_TRAVELLING_HARD) { - app.DebugPrintf( - "Updating leaderboard view LEADERBOARD_TRAVELLING_HARD\n"); - views[viewCount].dwViewId = STATS_VIEW_TRAVELLING_HARD; - views[viewCount].dwNumProperties = - LeaderboardManager::eProperty_Travelling_Max; - views[viewCount].pProperties = travellingHardProperties; - - rating = getValue(Stats::walkOneM, eDifficulty_Hard) + - getValue(Stats::fallOneM, eDifficulty_Hard) + - getValue(Stats::minecartOneM, eDifficulty_Hard) + - getValue(Stats::boatOneM, eDifficulty_Hard); - - setLeaderboardProperty( - &travellingHardProperties - [LeaderboardManager::eProperty_Travelling_Walked], - PROPERTY_TRAVEL_WALK, getValue(Stats::walkOneM, eDifficulty_Hard)); - setLeaderboardProperty( - &travellingHardProperties - [LeaderboardManager::eProperty_Travelling_Fallen], - PROPERTY_TRAVEL_FALL, getValue(Stats::fallOneM, eDifficulty_Hard)); - setLeaderboardProperty( - &travellingHardProperties - [LeaderboardManager::eProperty_Travelling_Minecart], - PROPERTY_TRAVEL_MINECART, - getValue(Stats::minecartOneM, eDifficulty_Hard)); - setLeaderboardProperty( - &travellingHardProperties - [LeaderboardManager::eProperty_Travelling_Boat], - PROPERTY_TRAVEL_BOAT, getValue(Stats::boatOneM, eDifficulty_Hard)); - setLeaderboardRating( - &travellingHardProperties - [LeaderboardManager::eProperty_Travelling_Rating], - rating); - - viewCount++; - } - - if (modifiedBoards & - (LEADERBOARD_TRAVELLING_PEACEFUL | LEADERBOARD_TRAVELLING_EASY | - LEADERBOARD_TRAVELLING_NORMAL | LEADERBOARD_TRAVELLING_HARD)) { - app.DebugPrintf( - "Updating leaderboard view LEADERBOARD_TRAVELLING_PEACEFUL | " - "LEADERBOARD_TRAVELLING_EASY | LEADERBOARD_TRAVELLING_NORMAL | " - "LEADERBOARD_TRAVELLING_HARD\n"); - views[viewCount].dwViewId = STATS_VIEW_TRAVELLING_TOTAL; - views[viewCount].dwNumProperties = 1; - views[viewCount].pProperties = travellingProperties; - - rating = getValue(Stats::walkOneM, eDifficulty_Peaceful) + - getValue(Stats::fallOneM, eDifficulty_Peaceful) + - getValue(Stats::boatOneM, eDifficulty_Peaceful) + - getValue(Stats::minecartOneM, eDifficulty_Peaceful) + - getValue(Stats::walkOneM, eDifficulty_Easy) + - getValue(Stats::fallOneM, eDifficulty_Easy) + - getValue(Stats::boatOneM, eDifficulty_Easy) + - getValue(Stats::minecartOneM, eDifficulty_Easy) + - getValue(Stats::walkOneM, eDifficulty_Normal) + - getValue(Stats::fallOneM, eDifficulty_Normal) + - getValue(Stats::boatOneM, eDifficulty_Normal) + - getValue(Stats::minecartOneM, eDifficulty_Normal) + - getValue(Stats::walkOneM, eDifficulty_Hard) + - getValue(Stats::fallOneM, eDifficulty_Hard) + - getValue(Stats::boatOneM, eDifficulty_Hard) + - getValue(Stats::minecartOneM, eDifficulty_Hard); - - setLeaderboardRating(&travellingProperties[0], rating); - - viewCount++; - } - - if (viewCount > 0) { - if (!LeaderboardManager::Instance()->WriteStats(viewCount, views)) { - assert(false && "Failed to write to leaderboard"); - // printf("Failed to write to leaderboard"); - } else { - app.DebugPrintf("Successfully wrote %d leadeboard views\n", - viewCount); - } - } -#endif // Xbox -#endif // ndef 0 } void StatsCounter::setupStatBoards() { -#if 1 statBoards.insert( std::make_pair(Stats::killsZombie, LEADERBOARD_KILLS_PEACEFUL)); statBoards.insert( @@ -1841,15 +359,12 @@ void StatsCounter::setupStatBoards() { std::make_pair(Stats::minecartOneM, LEADERBOARD_TRAVELLING_PEACEFUL)); statBoards.insert( std::make_pair(Stats::boatOneM, LEADERBOARD_TRAVELLING_PEACEFUL)); -#endif } bool StatsCounter::isLargeStat(Stat* stat) { -#if 1 Stat*** end = &LARGE_STATS[LARGE_STATS_COUNT]; for (Stat*** iter = LARGE_STATS; iter != end; ++iter) if ((*(*iter))->id == stat->id) return true; -#endif return false; } @@ -1863,7 +378,7 @@ void StatsCounter::dumpStatsToTTY() { } } -#ifdef _DEBUG +#if defined(_DEBUG) // To clear leaderboards set DEBUG_ENABLE_CLEAR_LEADERBOARDS to 1 and set // DEBUG_CLEAR_LEADERBOARDS to be the bitmask of what you want to clear @@ -1876,60 +391,5 @@ void StatsCounter::dumpStatsToTTY() { #define DEBUG_ENABLE_CLEAR_LEADERBOARDS void StatsCounter::WipeLeaderboards() { -#if defined DEBUG_ENABLE_CLEAR_LEADERBOARDS && 0 - - if (DEBUG_CLEAR_LEADERBOARDS & LEADERBOARD_KILLS_EASY) - XUserResetStatsViewAllUsers(STATS_VIEW_KILLS_EASY, NULL); - if (DEBUG_CLEAR_LEADERBOARDS & LEADERBOARD_KILLS_NORMAL) - XUserResetStatsViewAllUsers(STATS_VIEW_KILLS_NORMAL, NULL); - if (DEBUG_CLEAR_LEADERBOARDS & LEADERBOARD_KILLS_HARD) - XUserResetStatsViewAllUsers(STATS_VIEW_KILLS_HARD, NULL); - if (DEBUG_CLEAR_LEADERBOARDS & LEADERBOARD_MININGBLOCKS_PEACEFUL) - XUserResetStatsViewAllUsers(STATS_VIEW_MINING_BLOCKS_PEACEFUL, NULL); - if (DEBUG_CLEAR_LEADERBOARDS & LEADERBOARD_MININGBLOCKS_EASY) - XUserResetStatsViewAllUsers(STATS_VIEW_MINING_BLOCKS_EASY, NULL); - if (DEBUG_CLEAR_LEADERBOARDS & LEADERBOARD_MININGBLOCKS_NORMAL) - XUserResetStatsViewAllUsers(STATS_VIEW_MINING_BLOCKS_NORMAL, NULL); - if (DEBUG_CLEAR_LEADERBOARDS & LEADERBOARD_MININGBLOCKS_HARD) - XUserResetStatsViewAllUsers(STATS_VIEW_MINING_BLOCKS_HARD, NULL); - // if( DEBUG_CLEAR_LEADERBOARDS & LEADERBOARD_MININGORE_PEACEFUL ) - // XUserResetStatsViewAllUsers(STATS_VIEW_MINING_ORE_PEACEFUL, NULL); - // if( DEBUG_CLEAR_LEADERBOARDS & LEADERBOARD_MININGORE_EASY ) - // XUserResetStatsViewAllUsers(STATS_VIEW_MINING_ORE_EASY, NULL); if( - // DEBUG_CLEAR_LEADERBOARDS & LEADERBOARD_MININGORE_NORMAL ) - // XUserResetStatsViewAllUsers(STATS_VIEW_MINING_ORE_NORMAL, NULL); - // if( DEBUG_CLEAR_LEADERBOARDS & LEADERBOARD_MININGORE_HARD ) - // XUserResetStatsViewAllUsers(STATS_VIEW_MINING_ORE_HARD, NULL); - if (DEBUG_CLEAR_LEADERBOARDS & LEADERBOARD_FARMING_PEACEFUL) - XUserResetStatsViewAllUsers(STATS_VIEW_FARMING_PEACEFUL, NULL); - if (DEBUG_CLEAR_LEADERBOARDS & LEADERBOARD_FARMING_EASY) - XUserResetStatsViewAllUsers(STATS_VIEW_FARMING_EASY, NULL); - if (DEBUG_CLEAR_LEADERBOARDS & LEADERBOARD_FARMING_NORMAL) - XUserResetStatsViewAllUsers(STATS_VIEW_FARMING_NORMAL, NULL); - if (DEBUG_CLEAR_LEADERBOARDS & LEADERBOARD_FARMING_HARD) - XUserResetStatsViewAllUsers(STATS_VIEW_FARMING_HARD, NULL); - if (DEBUG_CLEAR_LEADERBOARDS & LEADERBOARD_TRAVELLING_PEACEFUL) - XUserResetStatsViewAllUsers(STATS_VIEW_TRAVELLING_PEACEFUL, NULL); - if (DEBUG_CLEAR_LEADERBOARDS & LEADERBOARD_TRAVELLING_EASY) - XUserResetStatsViewAllUsers(STATS_VIEW_TRAVELLING_EASY, NULL); - if (DEBUG_CLEAR_LEADERBOARDS & LEADERBOARD_TRAVELLING_NORMAL) - XUserResetStatsViewAllUsers(STATS_VIEW_TRAVELLING_NORMAL, NULL); - if (DEBUG_CLEAR_LEADERBOARDS & LEADERBOARD_TRAVELLING_HARD) - XUserResetStatsViewAllUsers(STATS_VIEW_TRAVELLING_HARD, NULL); - // if( DEBUG_CLEAR_LEADERBOARDS & LEADERBOARD_NETHER_PEACEFUL ) - // XUserResetStatsViewAllUsers(STATS_VIEW_NETHER_PEACEFUL, NULL); if( - // DEBUG_CLEAR_LEADERBOARDS & LEADERBOARD_NETHER_EASY ) - // XUserResetStatsViewAllUsers(STATS_VIEW_NETHER_EASY, NULL); if( - // DEBUG_CLEAR_LEADERBOARDS & LEADERBOARD_NETHER_NORMAL ) - // XUserResetStatsViewAllUsers(STATS_VIEW_NETHER_NORMAL, NULL); if( - // DEBUG_CLEAR_LEADERBOARDS & LEADERBOARD_NETHER_HARD ) - // XUserResetStatsViewAllUsers(STATS_VIEW_NETHER_HARD, NULL); - if (DEBUG_CLEAR_LEADERBOARDS & LEADERBOARD_TRAVELLING_TOTAL) - XUserResetStatsViewAllUsers(STATS_VIEW_TRAVELLING_TOTAL, NULL); - if (LeaderboardManager::Instance()->OpenSession()) { - writeStats(); - LeaderboardManager::Instance()->CloseSession(); - } -#endif } #endif diff --git a/Minecraft.Client/GameState/StatsCounter.h b/Minecraft.Client/GameState/StatsCounter.h index e76fb0d12..bc34d7980 100644 --- a/Minecraft.Client/GameState/StatsCounter.h +++ b/Minecraft.Client/GameState/StatsCounter.h @@ -82,7 +82,7 @@ public: void flushLeaderboards(); void saveLeaderboards(); static void setupStatBoards(); -#ifdef _DEBUG +#if defined(_DEBUG) void WipeLeaderboards(); #endif @@ -90,11 +90,6 @@ private: bool isLargeStat(Stat* stat); void dumpStatsToTTY(); -#if 0 - static void setLeaderboardProperty(XUSER_PROPERTY* prop, std::uint32_t id, - unsigned int value); - static void setLeaderboardRating(XUSER_PROPERTY* prop, LONGLONG value); -#endif void writeStats(); }; diff --git a/Minecraft.Client/Level/MultiPlayerLevel.cpp b/Minecraft.Client/Level/MultiPlayerLevel.cpp index cddae1c89..071f81fa2 100644 --- a/Minecraft.Client/Level/MultiPlayerLevel.cpp +++ b/Minecraft.Client/Level/MultiPlayerLevel.cpp @@ -93,7 +93,7 @@ void MultiPlayerLevel::tick() { setGameTime(getGameTime() + 1); if (getGameRules()->getBoolean(GameRules::RULE_DAYLIGHT)) { // 4J: Debug setting added to keep it at day time -#ifndef _FINAL_BUILD +#if !defined(_FINAL_BUILD) bool freezeTime = app.DebugSettingsOn() && app.GetGameSettingsDebugMask(ProfileManager.GetPrimaryPad()) & @@ -221,7 +221,7 @@ void MultiPlayerLevel::tick() { } } -#ifdef LIGHT_COMPRESSION_STATS +#if defined(LIGHT_COMPRESSION_STATS) static int updateTick = 0; if ((updateTick % 60) == 0) { @@ -262,7 +262,7 @@ void MultiPlayerLevel::tick() { #endif -#ifdef DATA_COMPRESSION_STATS +#if defined(DATA_COMPRESSION_STATS) static int updateTick = 0; if ((updateTick % 60) == 0) { @@ -294,7 +294,7 @@ void MultiPlayerLevel::tick() { #endif -#ifdef BLOCK_COMPRESSION_STATS +#if defined(BLOCK_COMPRESSION_STATS) static int updateTick = 0; if ((updateTick % 60) == 0) { @@ -391,15 +391,9 @@ void MultiPlayerLevel::tickTiles() { PIXEndNamedEvent(); PIXBeginNamedEvent(0, "Ticking client side tiles"); -#if 0 - // AP - see CustomSet.h for and explanation - for (int i = 0; i < chunksToPoll.end(); i += 1) { - ChunkPos cp = chunksToPoll.get(i); -#else AUTO_VAR(itEndCtp, chunksToPoll.end()); for (AUTO_VAR(it, chunksToPoll.begin()); it != itEndCtp; it++) { ChunkPos cp = *it; -#endif int xo = cp.x * 16; int zo = cp.z * 16; diff --git a/Minecraft.Client/Level/ServerLevel.cpp b/Minecraft.Client/Level/ServerLevel.cpp index 8e45766d0..7ca06e9b1 100644 --- a/Minecraft.Client/Level/ServerLevel.cpp +++ b/Minecraft.Client/Level/ServerLevel.cpp @@ -62,14 +62,6 @@ void ServerLevel::staticCtor() { m_updateThread = new C4JThread(runUpdate, NULL, "Tile update"); m_updateThread->SetProcessor(CPU_CORE_TILE_UPDATE); -#if 0 - m_updateThread->SetPriority( - THREAD_PRIORITY_BELOW_NORMAL); // On Orbis, this core is also used for - // Matching 2, and that priority of that - // seems to be always at default no - // matter what we set it to. Prioritise - // this below Matching 2. -#endif m_updateThread->Run(); RANDOM_BONUS_ITEMS = WeighedTreasureArray(20); @@ -182,7 +174,7 @@ ServerLevel::ServerLevel(MinecraftServer* server, emptyTime = 0; activeTileEventsList = 0; -#ifdef _LARGE_WORLDS +#if defined(_LARGE_WORLDS) saveInterval = 3; #else saveInterval = 20 * 2; @@ -288,7 +280,7 @@ void ServerLevel::tick() { int64_t time = levelData->getGameTime() + 1; // 4J Stu - Putting this back in, but I have reduced the number of chunks // that save when not forced -#ifdef _LARGE_WORLDS +#if defined(_LARGE_WORLDS) if (time % (saveInterval) == (dimension->id + 1)) #else if (time % (saveInterval) == @@ -307,7 +299,7 @@ void ServerLevel::tick() { setGameTime(levelData->getGameTime() + 1); if (getGameRules()->getBoolean(GameRules::RULE_DAYLIGHT)) { // 4J: Debug setting added to keep it at day time -#ifndef _FINAL_BUILD +#if !defined(_FINAL_BUILD) bool freezeTime = app.DebugSettingsOn() && app.GetGameSettingsDebugMask(ProfileManager.GetPrimaryPad()) & @@ -488,15 +480,9 @@ void ServerLevel::tickTiles() { if (app.GetGameSettingsDebugMask() & (1L << eDebugSetting_RegularLightning)) prob = 100; -#if 0 - // AP - see CustomSet.h for and explanation - for (int i = 0; i < chunksToPoll.end(); i += 1) { - ChunkPos cp = chunksToPoll.get(i); -#else AUTO_VAR(itEndCtp, chunksToPoll.end()); for (AUTO_VAR(it, chunksToPoll.begin()); it != itEndCtp; it++) { ChunkPos cp = *it; -#endif int xo = cp.x * 16; int zo = cp.z * 16; @@ -955,17 +941,10 @@ void ServerLevel::save(bool force, ProgressListener* progressListener, if (progressListener != NULL) progressListener->progressStage(IDS_PROGRESS_SAVING_CHUNKS); -#if 0 || 0 - // Our autosave is a minimal save. All the chunks are saves by the constant - // save process - if (bAutosave) { - chunkSource->saveAllEntities(); - } else -#endif { chunkSource->save(force, progressListener); -#ifdef _LARGE_WORLDS +#if defined(_LARGE_WORLDS) // 4J Stu - Only do this if there are players in the level if (chunkMap->players.size() > 0) { // 4J Stu - This will come in a later change anyway @@ -1569,9 +1548,6 @@ int ServerLevel::runUpdate(void* lpParam) { LeaveCriticalSection(&m_updateCS[iLev]); } PIXEndNamedEvent(); -#if 0 - Sleep(10); -#endif //0 } ShutdownManager::HasFinished(ShutdownManager::eRunUpdateThread); diff --git a/Minecraft.Client/Network/ClientConnection.cpp b/Minecraft.Client/Network/ClientConnection.cpp index 9f8316c40..f2a6662cc 100644 --- a/Minecraft.Client/Network/ClientConnection.cpp +++ b/Minecraft.Client/Network/ClientConnection.cpp @@ -46,49 +46,14 @@ #include "../ClientConstants.h" #include "../../Minecraft.World/Util/SoundTypes.h" #include "../Textures/Packs/TexturePackRepository.h" -#if 1 #include "../Platform/Common/UI/UI.h" -#endif #include "../Textures/Packs/DLCTexturePack.h" -#if 0 -#include "../../Minecraft.World/Stats/DurangoStats.h" -#include "../../Minecraft.World/Stats/GenericStats.h" -#endif ClientConnection::ClientConnection(Minecraft* minecraft, const std::wstring& ip, int port) { // 4J Stu - No longer used as we use the socket version below. assert(FALSE); -#if 0 - // 4J - added initiliasers - random = new Random(); - done = false; - level = false; - started = false; - - this->minecraft = minecraft; - - Socket *socket; - if( gNetworkManager.IsHost() ) - { - socket = new Socket(); // 4J - Local connection - } - else - { - socket = new Socket(ip); // 4J - Connection over xrnm - hardcoded IP at present - } - createdOk = socket->createdOk; - if( createdOk ) - { - connection = new Connection(socket, L"Client", this); - } - else - { - connection = NULL; - delete socket; - } -#endif } ClientConnection::ClientConnection(Minecraft* minecraft, Socket* socket, @@ -197,15 +162,6 @@ void ClientConnection::handleLogin(std::shared_ptr packet) { // check the file is not already in bRes = app.IsFileInMemoryTextures(wstr); if (!bRes) { -#if 0 - C4JStorage::ETMSStatus eTMSStatus; - eTMSStatus = StorageManager.ReadTMSFile( - iUserID, C4JStorage::eGlobalStorage_Title, - C4JStorage::eTMS_FileType_Graphic, pMojangData->wchSkin, - &pBuffer, &dwSize); - - bRes = (eTMSStatus == C4JStorage::ETMSStatus_Idle); -#endif } if (bRes) { @@ -219,14 +175,6 @@ void ClientConnection::handleLogin(std::shared_ptr packet) { // check the file is not already in bRes = app.IsFileInMemoryTextures(wstr); if (!bRes) { -#if 0 - C4JStorage::ETMSStatus eTMSStatus; - eTMSStatus = StorageManager.ReadTMSFile( - iUserID, C4JStorage::eGlobalStorage_Title, - C4JStorage::eTMS_FileType_Graphic, pMojangData->wchCape, - &pBuffer, &dwSize); - bRes = (eTMSStatus == C4JStorage::ETMSStatus_Idle); -#endif } if (bRes) { @@ -543,7 +491,7 @@ void ClientConnection::handleAddEntity( new LeashFenceKnotEntity(level, (int)x, (int)y, (int)z)); packet->data = 0; break; -#ifndef _FINAL_BUILD +#if !defined(_FINAL_BUILD) default: // Not a known entity (?) assert(0); @@ -805,17 +753,9 @@ void ClientConnection::handleAddPlayer( player->yHeadRot = packet->yHeadRot * 360 / 256.0f; player->setXuid(packet->xuid); -#if 0 - // On Durango request player display name from network manager - INetworkPlayer* networkPlayer = - g_NetworkManager.GetPlayerByXuid(player->getXuid()); - if (networkPlayer != NULL) - player->m_displayName = networkPlayer->GetDisplayName(); -#else // On all other platforms display name is just gamertag so don't check with // the network manager player->m_displayName = player->name; -#endif // printf("\t\t\t\t%d: Add player\n",packet->id,packet->yRot); @@ -1267,7 +1207,7 @@ void ClientConnection::handleTileUpdate( void ClientConnection::handleDisconnect( std::shared_ptr packet) { -#ifdef __linux__ +#if defined(__linux__) // Linux fix: On local host connections, ignore DisconnectPacket. The // singleplayer internal server should never disconnect itself. If we see // this, it's likely stream desync reading garbage data as a @@ -1872,7 +1812,6 @@ void ClientConnection::handlePreLogin(std::shared_ptr packet) { fprintf(stderr, "[LOGIN-CLI] handlePreLogin entered, isHost=%d, userIdx=%d\n", (int)g_NetworkManager.IsHost(), m_userIndex); -#if 1 // 4J - Check that we can play with all the players already in the game who // have Friends-Only UGC set bool canPlay = true; @@ -1893,338 +1832,19 @@ void ClientConnection::handlePreLogin(std::shared_ptr packet) { } } -#if 0 - if (!g_NetworkManager.IsHost() && - !app.GetGameHostOption(eGameHostOption_FriendsOfFriends)) { - if (m_userIndex == ProfileManager.GetPrimaryPad()) { - for (std::uint8_t idx = 0; idx < XUSER_MAX_COUNT; ++idx) { - if (ProfileManager.IsSignedIn(m_userIndex) && - ProfileManager.IsGuest(idx)) { - canPlay = false; - isFriendsWithHost = false; - } else { - PlayerUID playerXuid = INVALID_XUID; - if (ProfileManager.IsSignedInLive(idx)) { - ProfileManager.GetXUID(idx, &playerXuid, true); - } - if (playerXuid != INVALID_XUID) { - // Is this user friends with the host player? - int result = 0; - const unsigned int error = XUserAreUsersFriends( - idx, &packet->m_playerXuids[packet->m_hostIndex], 1, - &result, NULL); - if (error == ERROR_SUCCESS && result == 0) { - canPlay = false; - isFriendsWithHost = false; - } - } - } - if (!canPlay) break; - } - } else { - if (ProfileManager.IsSignedIn(m_userIndex) && - ProfileManager.IsGuest(m_userIndex)) { - canPlay = false; - isFriendsWithHost = false; - } else { - PlayerUID playerXuid = INVALID_XUID; - if (ProfileManager.IsSignedInLive(m_userIndex)) { - ProfileManager.GetXUID(m_userIndex, &playerXuid, true); - } - if (playerXuid != INVALID_XUID) { - // Is this user friends with the host player? - int result = 0; - const unsigned int error = XUserAreUsersFriends( - m_userIndex, - &packet->m_playerXuids[packet->m_hostIndex], 1, &result, - NULL); - if (error == ERROR_SUCCESS && result == 0) { - canPlay = false; - isFriendsWithHost = false; - } - } - } - } - } - - if (canPlay) { - for (std::uint8_t i = 0; i < packet->m_dwPlayerCount; ++i) { - bool localPlayer = false; - for (std::uint8_t idx = 0; idx < XUSER_MAX_COUNT; ++idx) { - if (ProfileManager.IsSignedInLive(idx)) { - // need to use the XUID here - PlayerUID playerXUID = INVALID_XUID; - if (!ProfileManager.IsGuest(idx)) { - // Guest don't have an offline XUID as they cannot play - // offline, so use their online one - ProfileManager.GetXUID(idx, &playerXUID, true); - } - if (ProfileManager.AreXUIDSEqual(playerXUID, - packet->m_playerXuids[i])) - localPlayer = true; - } else if (ProfileManager.IsSignedIn(idx)) { - // If we aren't signed into live then they have to be a - // local player - localPlayer = true; - } - } - if (!localPlayer) { - // First check our own permissions to see if we can play with - // this player - if (m_userIndex == ProfileManager.GetPrimaryPad()) { - canPlayLocal = ProfileManager.CanViewPlayerCreatedContent( - m_userIndex, false, &packet->m_playerXuids[i], 1); - - // 4J Stu - Everyone joining needs to have at least one - // friend in the game Local players are implied friends - if (!isAtLeastOneFriend) { - int result = 0; - for (std::uint8_t idx = 0; idx < XUSER_MAX_COUNT; - ++idx) { - if (ProfileManager.IsSignedIn(idx) && - !ProfileManager.IsGuest(idx)) { - const unsigned int error = XUserAreUsersFriends( - idx, &packet->m_playerXuids[i], 1, &result, - NULL); - if (error == ERROR_SUCCESS && result != 0) - isAtLeastOneFriend = true; - } - } - } - } else { - // Friends with the primary player on this system - isAtLeastOneFriend = true; - - canPlayLocal = ProfileManager.CanViewPlayerCreatedContent( - m_userIndex, true, &packet->m_playerXuids[i], 1); - } - - // If we can play with them, then check if they can play with us - if (canPlayLocal && (packet->m_friendsOnlyBits & (1 << i))) { - // If this is the primary pad then check all local players - // against the list in the packet (this happens when joining - // the game for the first time) If not the primary pad, then - // just check against this index. It happens on joining at - // the start, but more importantly players trying to join - // during the game - bool thisQuadrantOnly = true; - if (m_userIndex == ProfileManager.GetPrimaryPad()) - thisQuadrantOnly = false; - - int result = 0; - for (std::uint8_t idx = 0; idx < XUSER_MAX_COUNT; ++idx) { - if ((!thisQuadrantOnly || m_userIndex == idx) && - ProfileManager.IsSignedIn(idx) && - !ProfileManager.IsGuest(idx)) { - const unsigned int error = XUserAreUsersFriends( - idx, &packet->m_playerXuids[i], 1, &result, - NULL); - if (error == ERROR_SUCCESS) - canPlay &= (result != 0); - } - if (!canPlay) break; - } - } - if (!canPlay || !canPlayLocal) break; - } - } - } -#else // TODO - handle this kind of things for non-360 platforms canPlay = true; canPlayLocal = true; isAtLeastOneFriend = true; cantPlayContentRestricted = false; -#if (0 || 0 || 0) - if (!g_NetworkManager.IsHost() && - !app.GetGameHostOption(eGameHostOption_FriendsOfFriends)) { - bool bChatRestricted = false; - ProfileManager.GetChatAndContentRestrictions( - m_userIndex, true, &bChatRestricted, NULL, NULL); - - // Chat restricted orbis players can still play online -#if 1 - canPlay = !bChatRestricted; -#endif - - if (m_userIndex == ProfileManager.GetPrimaryPad()) { - // Is this user friends with the host player? - bool isFriend = true; - unsigned int friendCount = 0; -#if 0 - int ret = sceNpBasicGetFriendListEntryCount(&friendCount); -#elif 0 - sce::Toolkit::NP::Utilities::Future - friendList; - int ret = -1; - if (!CGameNetworkManager::usingAdhocMode()) // we don't need to be - // friends in PSN for - // adhoc mode - { - int ret = sce::Toolkit::NP::Friends::Interface::getFriendslist( - &friendList, false); - if (ret == SCE_TOOLKIT_NP_SUCCESS) { - if (friendList.hasResult()) { - friendCount = friendList.get()->size(); - } - } - } -#else // 0 - - sce::Toolkit::NP::Utilities::Future - friendList; - - sce::Toolkit::NP::FriendInfoRequest requestParam; - memset(&requestParam, 0, sizeof(requestParam)); - requestParam.flag = SCE_TOOLKIT_NP_FRIENDS_LIST_ALL; - requestParam.limit = 0; - requestParam.offset = 0; - requestParam.userInfo.userId = - ProfileManager.getUserID(ProfileManager.GetPrimaryPad()); - - int ret = sce::Toolkit::NP::Friends::Interface::getFriendslist( - &friendList, &requestParam, false); - if (ret == 0) { - if (friendList.hasResult()) { - friendCount = friendList.get()->size(); - } - } -#endif - if (ret == 0) { - isFriend = false; - SceNpId npid; - for (unsigned int i = 0; i < friendCount; i++) { -#if 0 - ret = sceNpBasicGetFriendListEntry(i, &npid); -#else - npid = friendList.get()->at(i).npid; -#endif - if (ret == 0) { - if (strcmp(npid.handle.data, - packet->m_playerXuids[packet->m_hostIndex] - .getOnlineID()) == 0) { - isFriend = true; - break; - } - } - } - } - - if (!isFriend) { - canPlay = FALSE; - isFriendsWithHost = FALSE; - } - } - } - // is it an online game, and a player has chat restricted? - else if (!g_NetworkManager.IsLocalGame()) { - // if the player is chat restricted, then they can't play an online game - bool bChatRestricted = false; - bool bContentRestricted = false; - - // If this is a pre-login packet for the first player on the machine, - // then accumulate up these flags for everyone signed in. We can handle - // exiting the game much more cleanly at this point by exiting the - // level, rather than waiting for a prelogin packet for the other - // players, when we have to exit the player which seems to be very - // unstable at the point of starting up the game - if (m_userIndex == ProfileManager.GetPrimaryPad()) { - ProfileManager.GetChatAndContentRestrictions( - m_userIndex, false, &bChatRestricted, &bContentRestricted, - NULL); - } else { - ProfileManager.GetChatAndContentRestrictions( - m_userIndex, true, &bChatRestricted, &bContentRestricted, NULL); - } - - // Chat restricted orbis players can still play online -#if 1 - canPlayLocal = !bChatRestricted; -#endif - - cantPlayContentRestricted = bContentRestricted ? 1 : 0; - } - -#endif - -#if 0 - if (!g_NetworkManager.IsHost() && - m_userIndex == ProfileManager.GetPrimaryPad()) { - long long startTime = System::currentTimeMillis(); - - auto friendsXuids = DQRNetworkManager::GetFriends(); - - if (app.GetGameHostOption(eGameHostOption_FriendsOfFriends)) { - // Check that the user has at least one friend in the game - isAtLeastOneFriend = false; - - for (int i = 0; i < friendsXuids->Size; i++) { - auto friendsXuid = friendsXuids->GetAt(i); - - // Check this friend against each player, if we find them we - // have at least one friend - for (int j = 0; j < g_NetworkManager.GetPlayerCount(); j++) { - Platform::String ^ xboxUserId = ref new Platform::String( - g_NetworkManager.GetPlayerByIndex(j) - ->GetUID() - .toString() - .data()); - if (friendsXuid == xboxUserId) { - isAtLeastOneFriend = true; - break; - } - } - } - - app.DebugPrintf( - "ClientConnection::handlePreLogin: User has at least one " - "friend? %s\n", - isAtLeastOneFriend ? "Yes" : "No"); - } else { - // Check that the user is friends with the host - bool isFriend = false; - - Platform::String ^ hostXboxUserId = ref new Platform::String( - g_NetworkManager.GetHostPlayer()->GetUID().toString().data()); - - for (int i = 0; i < friendsXuids->Size; i++) { - if (friendsXuids->GetAt(i) == hostXboxUserId) { - isFriend = true; - break; - } - } - - if (!isFriend) { - canPlay = FALSE; - isFriendsWithHost = FALSE; - } - - app.DebugPrintf( - "ClientConnection::handlePreLogin: User is friends with the " - "host? %s\n", - isFriendsWithHost ? "Yes" : "No"); - } - - app.DebugPrintf( - "ClientConnection::handlePreLogin: Friendship checks took %i ms\n", - System::currentTimeMillis() - startTime); - } -#endif - -#endif // 0 if (!canPlay || !canPlayLocal || !isAtLeastOneFriend || cantPlayContentRestricted) { -#if 1 DisconnectPacket::eDisconnectReason reason = DisconnectPacket::eDisconnect_NoUGC_Remote; -#else - DisconnectPacket::eDisconnectReason reason = - DisconnectPacket::eDisconnect_None; -#endif if (m_userIndex == ProfileManager.GetPrimaryPad()) { if (!isFriendsWithHost) reason = DisconnectPacket::eDisconnect_NotFriendsWithHost; @@ -2302,9 +1922,6 @@ void ClientConnection::handlePreLogin(std::shared_ptr packet) { packet->m_texturePackId); // 4J-PB - we need to upsell the texture pack to the player -#if 0 || 0 || 0 - app.SetAction(m_userIndex, eAppAction_TexturePackRequired); -#endif // Let the player go into the game, and we'll check that they // are using the right texture pack when in } @@ -2322,19 +1939,10 @@ void ClientConnection::handlePreLogin(std::shared_ptr packet) { // use their online one ProfileManager.GetXUID(m_userIndex, &onlineXUID, true); } -#if 0 - if (CGameNetworkManager::usingAdhocMode() && - onlineXUID.getOnlineID()[0] == 0) { - // player doesn't have an online UID, set it from the player name - onlineXUID.setForAdhoc(); - } -#endif // On PS3, all non-signed in players (even guests) can get a useful // offlineXUID -#if !(0 || 0) if (!ProfileManager.IsGuest(m_userIndex)) -#endif { // All other players we use their offline XUID so that they can play // the game offline @@ -2363,36 +1971,6 @@ void ClientConnection::handlePreLogin(std::shared_ptr packet) { (eCCLoginSent * 100) / (eCCConnected)); } } -#else - // 4J - removed - if (packet->loginKey.equals("-")) { - send(new LoginPacket(minecraft->user.name, - SharedConstants.NETWORK_PROTOCOL_VERSION)); - } else { - try { - URL url = - new URL("http://www.minecraft->net/game/joinserver.jsp?user=" + - minecraft->user.name + - "&sessionId=" + minecraft->user.sessionId + - "&serverId=" + packet->loginKey); - BufferedReader br = - new BufferedReader(new InputStreamReader(url.openStream())); - String msg = br.readLine(); - br.close(); - - if (msg.equalsIgnoreCase("ok")) { - send(new LoginPacket(minecraft->user.name, - SharedConstants.NETWORK_PROTOCOL_VERSION)); - } else { - connection.close("disconnect.loginFailedInfo", msg); - } - } catch (Exception e) { - e.printStackTrace(); - connection.close("disconnect.genericReason", - "Internal client error: " + e.toString()); - } - } -#endif } void ClientConnection::close() { @@ -2579,7 +2157,7 @@ void ClientConnection::handleTexture(std::shared_ptr packet) { if (packet->dataBytes == 0) { // Request for texture -#ifndef _CONTENT_PACKAGE +#if !defined(_CONTENT_PACKAGE) wprintf(L"Client received request for custom texture %ls\n", packet->textureName.c_str()); #endif @@ -2593,7 +2171,7 @@ void ClientConnection::handleTexture(std::shared_ptr packet) { } } else { // Response with texture data -#ifndef _CONTENT_PACKAGE +#if !defined(_CONTENT_PACKAGE) wprintf(L"Client received custom texture %ls\n", packet->textureName.c_str()); #endif @@ -2613,7 +2191,7 @@ void ClientConnection::handleTextureAndGeometry( if (packet->dwTextureBytes == 0) { // Request for texture -#ifndef _CONTENT_PACKAGE +#if !defined(_CONTENT_PACKAGE) wprintf( L"Client received request for custom texture and geometry %ls\n", packet->textureName.c_str()); @@ -2649,7 +2227,7 @@ void ClientConnection::handleTextureAndGeometry( } } else { // Response with texture data -#ifndef _CONTENT_PACKAGE +#if !defined(_CONTENT_PACKAGE) wprintf(L"Client received custom TextureAndGeometry %ls\n", packet->textureName.c_str()); #endif @@ -2691,7 +2269,7 @@ void ClientConnection::handleTextureChange( switch (packet->action) { case TextureChangePacket::e_TextureChange_Skin: player->setCustomSkin(app.getSkinIdFromPath(packet->path)); -#ifndef _CONTENT_PACKAGE +#if !defined(_CONTENT_PACKAGE) wprintf(L"Skin for remote player %ls has changed to %ls (%d)\n", player->name.c_str(), player->customTextureUrl.c_str(), player->getPlayerDefaultSkin()); @@ -2700,7 +2278,7 @@ void ClientConnection::handleTextureChange( case TextureChangePacket::e_TextureChange_Cape: player->setCustomCape(Player::getCapeIdFromPath(packet->path)); // player->customTextureUrl2 = packet->path; -#ifndef _CONTENT_PACKAGE +#if !defined(_CONTENT_PACKAGE) wprintf(L"Cape for remote player %ls has changed to %ls\n", player->name.c_str(), player->customTextureUrl2.c_str()); #endif @@ -2711,7 +2289,7 @@ void ClientConnection::handleTextureChange( packet->path.substr(0, 3).compare(L"def") != 0 && !app.IsFileInMemoryTextures(packet->path)) { if (minecraft->addPendingClientTextureRequest(packet->path)) { -#ifndef _CONTENT_PACKAGE +#if !defined(_CONTENT_PACKAGE) wprintf( L"handleTextureChange - Client sending texture packet to get " L"custom skin %ls for player %ls\n", @@ -2747,7 +2325,7 @@ void ClientConnection::handleTextureAndGeometryChange( player->setCustomSkin(app.getSkinIdFromPath(packet->path)); -#ifndef _CONTENT_PACKAGE +#if !defined(_CONTENT_PACKAGE) wprintf(L"Skin for remote player %ls has changed to %ls (%d)\n", player->name.c_str(), player->customTextureUrl.c_str(), player->getPlayerDefaultSkin()); @@ -2757,7 +2335,7 @@ void ClientConnection::handleTextureAndGeometryChange( packet->path.substr(0, 3).compare(L"def") != 0 && !app.IsFileInMemoryTextures(packet->path)) { if (minecraft->addPendingClientTextureRequest(packet->path)) { -#ifndef _CONTENT_PACKAGE +#if !defined(_CONTENT_PACKAGE) wprintf( L"handleTextureAndGeometryChange - Client sending " L"TextureAndGeometryPacket to get custom skin %ls for player " @@ -2837,13 +2415,6 @@ void ClientConnection::handleRespawn(std::shared_ptr packet) { minecraft->setScreen(new ReceivingLevelScreen(this)); // minecraft->addPendingLocalConnection(m_userIndex, this); -#if 0 - TelemetryManager->RecordLevelStart( - m_userIndex, eSen_FriendOrMatch_Playing_With_Invited_Friends, - eSen_CompeteOrCoop_Coop_and_Competitive, - Minecraft::GetInstance()->getLevel(packet->dimension)->difficulty, - app.GetLocalPlayerCount(), g_NetworkManager.GetOnlinePlayerCount()); -#endif if (minecraft->localgameModes[m_userIndex] != NULL) { TutorialMode* gameMode = @@ -3337,28 +2908,6 @@ void ClientConnection::handleGameEvent( } else if (event == GameEventPacket::WIN_GAME) { ui.SetWinUserIndex(static_cast(gameEventPacket->param)); -#if 0 - - // turn off the gamertags in splitscreen for the primary player, since - // they are about to be made fullscreen - ui.HideAllGameUIElements(); - - // Hide the other players scenes - ui.ShowOtherPlayersBaseScene(ProfileManager.GetPrimaryPad(), false); - - // This just allows it to be shown - if (minecraft->localgameModes[ProfileManager.GetPrimaryPad()] != NULL) - minecraft->localgameModes[ProfileManager.GetPrimaryPad()] - ->getTutorial() - ->showTutorialPopup(false); - // Temporarily make this scene fullscreen - CXuiSceneBase::SetPlayerBaseScenePosition( - ProfileManager.GetPrimaryPad(), - CXuiSceneBase::e_BaseScene_Fullscreen); - - app.CloseXuiScenesAndNavigateToScene(ProfileManager.GetPrimaryPad(), - eUIScene_EndPoem); -#else app.DebugPrintf("handleGameEvent packet for WIN_GAME - %d\n", m_userIndex); // This just allows it to be shown @@ -3368,7 +2917,6 @@ void ClientConnection::handleGameEvent( ->showTutorialPopup(false); ui.NavigateToScene(ProfileManager.GetPrimaryPad(), eUIScene_EndPoem, NULL, eUILayer_Scene, eUIGroup_Fullscreen); -#endif } else if (event == GameEventPacket::START_SAVING) { if (!g_NetworkManager.IsHost()) { // Move app started to here so that it happens immediately otherwise @@ -3501,21 +3049,6 @@ void ClientConnection::handlePlayerInfo( // 4J Stu - I don't think we care about this, so not converting it (came // from 1.8.2) -#if 0 - PlayerInfo pi = playerInfoMap.get(packet.name); - if (pi == null && packet.add) { - pi = new PlayerInfo(packet.name); - playerInfoMap.put(packet.name, pi); - playerInfos.add(pi); - } - if (pi != null && !packet.add) { - playerInfoMap.remove(packet.name); - playerInfos.remove(pi); - } - if (packet.add && pi != null) { - pi.latency = packet.latency; - } -#endif } void ClientConnection::displayPrivilegeChanges( @@ -3707,23 +3240,9 @@ void ClientConnection::handleCustomPayload( ->containerMenu->containerId) { std::shared_ptr trader = nullptr; -#if 0 - HXUIOBJ scene = app.GetCurrentScene(m_userIndex); - HXUICLASS thisClass = XuiFindClass(L"CXuiSceneTrading"); - HXUICLASS objClass = XuiGetObjectClass(scene); - - // Also returns TRUE if they are the same (which is what we want) - if (XuiClassDerivesFrom(objClass, thisClass)) { - CXuiSceneTrading* screen; - HRESULT hr = XuiObjectFromHandle(scene, (void**)&screen); - if (FAILED(hr)) return; - trader = screen->getMerchant(); - } -#else UIScene* scene = ui.GetTopScene(m_userIndex, eUILayer_Scene); UIScene_TradingMenu* screen = (UIScene_TradingMenu*)scene; trader = screen->getMerchant(); -#endif MerchantRecipeList* recipeList = MerchantRecipeList::createFromStream(&input); @@ -3817,23 +3336,6 @@ int ClientConnection::HostDisconnectReturned( } } -#if 0 || 0 - // Give the player the option to save their game - // does the save exist? - bool bSaveExists; - StorageManager.DoesSaveExist(&bSaveExists); - // 4J-PB - we check if the save exists inside the libs - // we need to ask if they are sure they want to overwrite the existing game - if (bSaveExists && StorageManager.GetSaveDisabled()) { - unsigned int uiIDA[2]; - uiIDA[0] = IDS_CONFIRM_CANCEL; - uiIDA[1] = IDS_CONFIRM_OK; - ui.RequestErrorMessage(IDS_TITLE_SAVE_GAME, IDS_CONFIRM_SAVE_GAME, - uiIDA, 2, ProfileManager.GetPrimaryPad(), - &ClientConnection::ExitGameAndSaveReturned, - NULL); - } else -#else // Give the player the option to save their game // does the save exist? bool bSaveExists; @@ -3849,11 +3351,7 @@ int ClientConnection::HostDisconnectReturned( &ClientConnection::ExitGameAndSaveReturned, NULL); } else -#endif { -#if 0 || 0 - StorageManager.SetSaveDisabled(false); -#endif MinecraftServer::getInstance()->setSaveOnExit(true); // flag a app action of exit game app.SetAction(iPad, eAppAction_ExitWorld); @@ -3871,9 +3369,6 @@ int ClientConnection::ExitGameAndSaveReturned( // StorageManager.GetSaveUniqueNumber(&saveOrCheckpointId); // SentientManager.RecordLevelSaveOrCheckpoint(ProfileManager.GetPrimaryPad(), // saveOrCheckpointId); -#if 0 || 0 - StorageManager.SetSaveDisabled(false); -#endif MinecraftServer::getInstance()->setSaveOnExit(true); } else { MinecraftServer::getInstance()->setSaveOnExit(false); @@ -3885,119 +3380,22 @@ int ClientConnection::ExitGameAndSaveReturned( // std::wstring ClientConnection::GetDisplayNameByGamertag(std::wstring gamertag) { -#if 0 - std::wstring displayName = - g_NetworkManager.GetDisplayNameByGamertag(gamertag); - return displayName; -#else return gamertag; -#endif } void ClientConnection::handleAddObjective( std::shared_ptr packet) { -#if 0 - Scoreboard scoreboard = level->getScoreboard(); - - if (packet->method == SetObjectivePacket::METHOD_ADD) - { - Objective objective = scoreboard->addObjective(packet->objectiveName, ObjectiveCriteria::DUMMY); - objective->setDisplayName(packet->displayName); - } - else - { - Objective objective = scoreboard->getObjective(packet->objectiveName); - - if (packet->method == SetObjectivePacket::METHOD_REMOVE) - { - scoreboard->removeObjective(objective); - } - else if (packet->method == SetObjectivePacket::METHOD_CHANGE) - { - objective->setDisplayName(packet->displayName); - } - } -#endif } void ClientConnection::handleSetScore(std::shared_ptr packet) { -#if 0 - Scoreboard scoreboard = level->getScoreboard(); - Objective objective = scoreboard->getObjective(packet->objectiveName); - - if (packet->method == SetScorePacket::METHOD_CHANGE) - { - Score score = scoreboard->getPlayerScore(packet->owner, objective); - score->setScore(packet->score); - } - else if (packet->method == SetScorePacket::METHOD_REMOVE) - { - scoreboard->resetPlayerScore(packet->owner); - } -#endif } void ClientConnection::handleSetDisplayObjective( std::shared_ptr packet) { -#if 0 - Scoreboard scoreboard = level->getScoreboard(); - - if (packet->objectiveName->length() == 0) - { - scoreboard->setDisplayObjective(packet->slot, null); - } - else - { - Objective objective = scoreboard->getObjective(packet->objectiveName); - scoreboard->setDisplayObjective(packet->slot, objective); - } -#endif } void ClientConnection::handleSetPlayerTeamPacket( std::shared_ptr packet) { -#if 0 - Scoreboard scoreboard = level->getScoreboard(); - PlayerTeam *team; - - if (packet->method == SetPlayerTeamPacket::METHOD_ADD) - { - team = scoreboard->addPlayerTeam(packet->name); - } - else - { - team = scoreboard->getPlayerTeam(packet->name); - } - - if (packet->method == SetPlayerTeamPacket::METHOD_ADD || packet->method == SetPlayerTeamPacket::METHOD_CHANGE) - { - team->setDisplayName(packet->displayName); - team->setPrefix(packet->prefix); - team->setSuffix(packet->suffix); - team->unpackOptions(packet->options); - } - - if (packet->method == SetPlayerTeamPacket::METHOD_ADD || packet->method == SetPlayerTeamPacket::METHOD_JOIN) - { - for (int i = 0; i < packet->players.size(); i++) - { - scoreboard->addPlayerToTeam(packet->players[i], team); - } - } - - if (packet->method == SetPlayerTeamPacket::METHOD_LEAVE) - { - for (int i = 0; i < packet->players.size(); i++) - { - scoreboard->removePlayerFromTeam(packet->players[i], team); - } - } - - if (packet->method == SetPlayerTeamPacket::METHOD_REMOVE) - { - scoreboard->removePlayerTeam(team); - } -#endif } void ClientConnection::handleParticleEvent( diff --git a/Minecraft.Client/Network/PendingConnection.cpp b/Minecraft.Client/Network/PendingConnection.cpp index 5658a5163..26889858b 100644 --- a/Minecraft.Client/Network/PendingConnection.cpp +++ b/Minecraft.Client/Network/PendingConnection.cpp @@ -122,14 +122,6 @@ void PendingConnection::sendPreLoginResponse() { } } -#if 0 - if (false)// server->onlineMode) // 4J - removed - { - loginKey = L"TOIMPLEMENT"; // 4J - todo Long.toHexString(random.nextLong()); - connection->send( std::shared_ptr( new PreLoginPacket(loginKey, ugcXuids, ugcXuidCount, ugcFriendsOnlyBits, server->m_ugcPlayersVersion, szUniqueMapName,app.GetGameHostOption(eGameHostOption_All),hostIndex) ) ); - } - else -#endif { connection->send(std::shared_ptr( new PreLoginPacket(L"-", ugcXuids, ugcXuidCount, ugcFriendsOnlyBits, @@ -168,27 +160,6 @@ void PendingConnection::handleLogin(std::shared_ptr packet) { // else { // 4J - removed -#if 0 - new Thread() { - public void run() { - try { - String key = loginKey; - URL url = new URL("http://www.minecraft.net/game/checkserver.jsp?user=" + URLEncoder.encode(packet.userName, "UTF-8") + "&serverId=" + URLEncoder.encode(key, "UTF-8")); - BufferedReader br = new BufferedReader(new InputStreamReader(url.openStream())); - String msg = br.readLine(); - br.close(); - if (msg.equals("YES")) { - acceptedLogin = packet; - } else { - disconnect("Failed to verify username!"); - } - } catch (Exception e) { - disconnect("Failed to verify username! [internal error " + e + "]"); - e.printStackTrace(); - } - } - }.start(); -#endif } } diff --git a/Minecraft.Client/Network/PlayerConnection.cpp b/Minecraft.Client/Network/PlayerConnection.cpp index 0e5038d86..e09bc00ef 100644 --- a/Minecraft.Client/Network/PlayerConnection.cpp +++ b/Minecraft.Client/Network/PlayerConnection.cpp @@ -315,7 +315,7 @@ void PlayerConnection::handleMovePlayer( // System.out.println("Got position " + xt + ", " + yt + // ", " + zt); System.out.println("Expected " + player->x // + ", " + player->y + ", " + player->z); -#ifndef _CONTENT_PACKAGE +#if !defined(_CONTENT_PACKAGE) wprintf(L"%ls moved wrongly!\n", player->name.c_str()); app.DebugPrintf("Got position %f, %f, %f\n", xt, yt, zt); app.DebugPrintf("Expected %f, %f, %f\n", player->x, player->y, @@ -340,7 +340,7 @@ void PlayerConnection::handleMovePlayer( if (aboveGroundTickCount > 80) { // logger.warning(player->name + " was // kicked for floating too long!"); -#ifndef _CONTENT_PACKAGE +#if !defined(_CONTENT_PACKAGE) wprintf(L"%ls was kicked for floating too long!\n", player->name.c_str()); #endif @@ -622,44 +622,10 @@ void PlayerConnection::handleSetCarriedItem( void PlayerConnection::handleChat(std::shared_ptr packet) { // 4J - TODO -#if 0 - std::wstring message = packet->message; - if (message.length() > SharedConstants::maxChatLength) - { - disconnect(L"Chat message too long"); - return; - } - message = message.trim(); - for (int i = 0; i < message.length(); i++) - { - if (SharedConstants.acceptableLetters.indexOf(message.charAt(i)) < 0 && (int) message.charAt(i) < 32) - { - disconnect(L"Illegal characters in chat"); - return; - } - } - - if (message.startsWith("/")) - { - handleCommand(message); - } else { - message = "<" + player.name + "> " + message; - logger.info(message); - server.players.broadcastAll(new ChatPacket(message)); - } - chatSpamTickCount += SharedConstants::TICKS_PER_SECOND; - if (chatSpamTickCount > SharedConstants::TICKS_PER_SECOND * 10) - { - disconnect("disconnect.spam"); - } -#endif } void PlayerConnection::handleCommand(const std::wstring& message) { // 4J - TODO -#if 0 - server.getCommandDispatcher().performCommand(player, message); -#endif } void PlayerConnection::handleAnimate(std::shared_ptr packet) { @@ -779,7 +745,7 @@ void PlayerConnection::handleTexture(std::shared_ptr packet) { if (packet->dataBytes == 0) { // Request for texture -#ifndef _CONTENT_PACKAGE +#if !defined(_CONTENT_PACKAGE) wprintf(L"Server received request for custom texture %ls\n", packet->textureName.c_str()); #endif @@ -795,7 +761,7 @@ void PlayerConnection::handleTexture(std::shared_ptr packet) { } } else { // Response with texture data -#ifndef _CONTENT_PACKAGE +#if !defined(_CONTENT_PACKAGE) wprintf(L"Server received custom texture %ls\n", packet->textureName.c_str()); #endif @@ -812,7 +778,7 @@ void PlayerConnection::handleTextureAndGeometry( if (packet->dwTextureBytes == 0) { // Request for texture and geometry -#ifndef _CONTENT_PACKAGE +#if !defined(_CONTENT_PACKAGE) wprintf(L"Server received request for custom texture %ls\n", packet->textureName.c_str()); #endif @@ -852,7 +818,7 @@ void PlayerConnection::handleTextureAndGeometry( } } else { // Response with texture and geometry data -#ifndef _CONTENT_PACKAGE +#if !defined(_CONTENT_PACKAGE) wprintf(L"Server received custom texture %ls and geometry\n", packet->textureName.c_str()); #endif @@ -861,7 +827,7 @@ void PlayerConnection::handleTextureAndGeometry( // add the geometry to the app list if (packet->dwBoxC != 0) { -#ifndef _CONTENT_PACKAGE +#if !defined(_CONTENT_PACKAGE) wprintf(L"Adding skin boxes for skin id %X, box count %d\n", packet->dwSkinID, packet->dwBoxC); #endif @@ -938,7 +904,7 @@ void PlayerConnection::handleTextureChange( switch (packet->action) { case TextureChangePacket::e_TextureChange_Skin: player->setCustomSkin(app.getSkinIdFromPath(packet->path)); -#ifndef _CONTENT_PACKAGE +#if !defined(_CONTENT_PACKAGE) wprintf(L"Skin for server player %ls has changed to %ls (%d)\n", player->name.c_str(), player->customTextureUrl.c_str(), player->getPlayerDefaultSkin()); @@ -947,7 +913,7 @@ void PlayerConnection::handleTextureChange( case TextureChangePacket::e_TextureChange_Cape: player->setCustomCape(Player::getCapeIdFromPath(packet->path)); // player->customTextureUrl2 = packet->path; -#ifndef _CONTENT_PACKAGE +#if !defined(_CONTENT_PACKAGE) wprintf(L"Cape for server player %ls has changed to %ls\n", player->name.c_str(), player->customTextureUrl2.c_str()); #endif @@ -957,7 +923,7 @@ void PlayerConnection::handleTextureChange( packet->path.substr(0, 3).compare(L"def") != 0 && !app.IsFileInMemoryTextures(packet->path)) { if (server->connection->addPendingTextureRequest(packet->path)) { -#ifndef _CONTENT_PACKAGE +#if !defined(_CONTENT_PACKAGE) wprintf( L"Sending texture packet to get custom skin %ls from player " L"%ls\n", @@ -980,7 +946,7 @@ void PlayerConnection::handleTextureChange( void PlayerConnection::handleTextureAndGeometryChange( std::shared_ptr packet) { player->setCustomSkin(app.getSkinIdFromPath(packet->path)); -#ifndef _CONTENT_PACKAGE +#if !defined(_CONTENT_PACKAGE) wprintf( L"PlayerConnection::handleTextureAndGeometryChange - Skin for server " L"player %ls has changed to %ls (%d)\n", @@ -992,7 +958,7 @@ void PlayerConnection::handleTextureAndGeometryChange( packet->path.substr(0, 3).compare(L"def") != 0 && !app.IsFileInMemoryTextures(packet->path)) { if (server->connection->addPendingTextureRequest(packet->path)) { -#ifndef _CONTENT_PACKAGE +#if !defined(_CONTENT_PACKAGE) wprintf( L"Sending texture packet to get custom skin %ls from player " L"%ls\n", @@ -1131,7 +1097,7 @@ void PlayerConnection::handleContainerClose( player->doCloseContainer(); } -#ifndef _CONTENT_PACKAGE +#if !defined(_CONTENT_PACKAGE) void PlayerConnection::handleContainerSetSlot( std::shared_ptr packet) { if (packet->containerId == AbstractContainerMenu::CONTAINER_ID_CARRIED) { @@ -1218,7 +1184,7 @@ void PlayerConnection::handleSetCreativeModeSlot( if (item != NULL && item->id == Item::map_Id) { int mapScale = 3; -#ifdef _LARGE_WORLDS +#if defined(_LARGE_WORLDS) int scale = MapItemSavedData::MAP_SIZE * 2 * (1 << mapScale); int centreXC = (int)(Math::round(player->x / scale) * scale); int centreZC = (int)(Math::round(player->z / scale) * scale); @@ -1394,7 +1360,7 @@ void PlayerConnection::handlePlayerInfo( gameType = LevelSettings::validateGameType(gameType->getId()); if (serverPlayer->gameMode->getGameModeForPlayer() != gameType) { -#ifndef _CONTENT_PACKAGE +#if !defined(_CONTENT_PACKAGE) wprintf(L"Setting %ls to game mode %d\n", serverPlayer->name.c_str(), gameType); #endif @@ -1409,7 +1375,7 @@ void PlayerConnection::handlePlayerInfo( GameEventPacket::CHANGE_GAME_MODE, gameType->getId()))); } else { -#ifndef _CONTENT_PACKAGE +#if !defined(_CONTENT_PACKAGE) wprintf(L"%ls already has game mode %d\n", serverPlayer->name.c_str(), gameType); #endif @@ -1566,47 +1532,6 @@ void PlayerConnection::handlePlayerAbilities( void PlayerConnection::handleCustomPayload( std::shared_ptr customPayloadPacket) { -#if 0 - if (CustomPayloadPacket.CUSTOM_BOOK_PACKET.equals(customPayloadPacket.identifier)) - { - ByteArrayInputStream bais(customPayloadPacket->data); - DataInputStream input(&bais); - std::shared_ptr sentItem = Packet::readItem(input); - - if (!WritingBookItem.makeSureTagIsValid(sentItem.getTag())) - { - throw new IOException("Invalid book tag!"); - } - - // make sure the sent item is the currently carried item - ItemInstance carried = player.inventory.getSelected(); - if (sentItem != null && sentItem.id == Item.writingBook.id && sentItem.id == carried.id) - { - carried.addTagElement(WrittenBookItem.TAG_PAGES, sentItem.getTag().getList(WrittenBookItem.TAG_PAGES)); - } - } - else if (CustomPayloadPacket.CUSTOM_BOOK_SIGN_PACKET.equals(customPayloadPacket.identifier)) - { - DataInputStream input = new DataInputStream(new ByteArrayInputStream(customPayloadPacket.data)); - ItemInstance sentItem = Packet.readItem(input); - - if (!WrittenBookItem.makeSureTagIsValid(sentItem.getTag())) - { - throw new IOException("Invalid book tag!"); - } - - // make sure the sent item is the currently carried item - ItemInstance carried = player.inventory.getSelected(); - if (sentItem != null && sentItem.id == Item.writtenBook.id && carried.id == Item.writingBook.id) - { - carried.addTagElement(WrittenBookItem.TAG_AUTHOR, new StringTag(WrittenBookItem.TAG_AUTHOR, player.getName())); - carried.addTagElement(WrittenBookItem.TAG_TITLE, new StringTag(WrittenBookItem.TAG_TITLE, sentItem.getTag().getString(WrittenBookItem.TAG_TITLE))); - carried.addTagElement(WrittenBookItem.TAG_PAGES, sentItem.getTag().getList(WrittenBookItem.TAG_PAGES)); - carried.id = Item.writtenBook.id; - } - } - else -#endif if (CustomPayloadPacket::TRADER_SELECTION_PACKET.compare( customPayloadPacket->identifier) == 0) { ByteArrayInputStream bais(customPayloadPacket->data); diff --git a/Minecraft.Client/Network/PlayerList.cpp b/Minecraft.Client/Network/PlayerList.cpp index ef32cc865..cce086cba 100644 --- a/Minecraft.Client/Network/PlayerList.cpp +++ b/Minecraft.Client/Network/PlayerList.cpp @@ -38,9 +38,7 @@ PlayerList::PlayerList(MinecraftServer* server) { overrideGameMode = NULL; allowCheatsForAllPlayers = false; -#if 0 - viewDistance = 3; -#elif defined _LARGE_WORLDS +#if defined(_LARGE_WORLDS) viewDistance = 16; #else viewDistance = 10; @@ -85,16 +83,6 @@ void PlayerList::placeNewPlayer(Connection* connection, player->setPlayerGamePrivilege(Player::ePlayerGamePrivilege_HOST, 1); } -#if 0 || 0 - // PS3 networking library doesn't automatically assign PlayerUIDs to the - // network players for anything remote, so need to tell it what to set from - // the data in this packet now - if (!g_NetworkManager.IsLocalGame()) { - if (networkPlayer != NULL) { - ((NetworkPlayerSony*)networkPlayer)->SetUID(packet->m_onlineXuid); - } - } -#endif // 4J Stu - TU-1 hotfix // Fix for #13150 - When a player loads/joins a game after saving/leaving in @@ -136,7 +124,7 @@ void PlayerList::placeNewPlayer(Connection* connection, if (newPlayer) { int mapScale = 3; -#ifdef _LARGE_WORLDS +#if defined(_LARGE_WORLDS) int scale = MapItemSavedData::MAP_SIZE * 2 * (1 << mapScale); int centreXC = (int)(Math::round(player->x / scale) * scale); int centreZC = (int)(Math::round(player->z / scale) * scale); @@ -162,7 +150,7 @@ void PlayerList::placeNewPlayer(Connection* connection, !app.IsFileInMemoryTextures(player->customTextureUrl)) { if (server->getConnection()->addPendingTextureRequest( player->customTextureUrl)) { -#ifndef _CONTENT_PACKAGE +#if !defined(_CONTENT_PACKAGE) wprintf( L"Sending texture packet to get custom skin %ls from player " L"%ls\n", @@ -183,7 +171,7 @@ void PlayerList::placeNewPlayer(Connection* connection, !app.IsFileInMemoryTextures(player->customTextureUrl2)) { if (server->getConnection()->addPendingTextureRequest( player->customTextureUrl2)) { -#ifndef _CONTENT_PACKAGE +#if !defined(_CONTENT_PACKAGE) wprintf( L"Sending texture packet to get custom skin %ls from player " L"%ls\n", @@ -1138,7 +1126,7 @@ bool PlayerList::isOp(const std::wstring& name) { return false; } bool PlayerList::isOp(std::shared_ptr player) { bool cheatsEnabled = app.GetGameHostOption(eGameHostOption_CheatsEnabled); -#ifdef _DEBUG_MENUS_ENABLED +#if defined(_DEBUG_MENUS_ENABLED) cheatsEnabled = cheatsEnabled || app.GetUseDPadForDebug(); #endif INetworkPlayer* networkPlayer = player->connection->getNetworkPlayer(); @@ -1347,17 +1335,6 @@ void PlayerList::broadcast(std::shared_ptr except, double x, double y, double yd = y - p->y; double zd = z - p->z; if (xd * xd + yd * yd + zd * zd < range * range) { -#if 0 // _DEBUG - std::shared_ptr SoundPacket= std::dynamic_pointer_cast(packet); - - if(SoundPacket) - { - - app.DebugPrintf("---broadcast - eSoundType_[%d] ",SoundPacket->getSound()); - OutputDebugStringW(ConsoleSoundEngine::wchSoundNames[SoundPacket->getSound()]); - app.DebugPrintf("\n"); - } -#endif p->connection->send(packet); sentTo.push_back(p); } @@ -1505,7 +1482,7 @@ void PlayerList::removePlayerFromReceiving(std::shared_ptr player, else if (dimIndex == 1) dimIndex = 2; -#ifndef _CONTENT_PACKAGE +#if !defined(_CONTENT_PACKAGE) app.DebugPrintf("Requesting remove player %ls as primary in dimension %d\n", player->name.c_str(), dimIndex); #endif @@ -1514,7 +1491,7 @@ void PlayerList::removePlayerFromReceiving(std::shared_ptr player, AUTO_VAR(it, find(receiveAllPlayers[dimIndex].begin(), receiveAllPlayers[dimIndex].end(), player)); if (it != receiveAllPlayers[dimIndex].end()) { -#ifndef _CONTENT_PACKAGE +#if !defined(_CONTENT_PACKAGE) app.DebugPrintf( "Remove: Removing player %ls as primary in dimension %d\n", player->name.c_str(), dimIndex); @@ -1533,7 +1510,7 @@ void PlayerList::removePlayerFromReceiving(std::shared_ptr player, if (newPlayer != player && newPlayer->dimension == playerDim && otherPlayer != NULL && otherPlayer->IsSameSystem(thisPlayer)) { -#ifndef _CONTENT_PACKAGE +#if !defined(_CONTENT_PACKAGE) app.DebugPrintf( "Remove: Adding player %ls as primary in dimension %d\n", newPlayer->name.c_str(), dimIndex); @@ -1543,7 +1520,7 @@ void PlayerList::removePlayerFromReceiving(std::shared_ptr player, } } } else if (thisPlayer == NULL) { -#ifndef _CONTENT_PACKAGE +#if !defined(_CONTENT_PACKAGE) app.DebugPrintf( "Remove: Qnet player for %ls was NULL so re-checking all players\n", player->name.c_str()); @@ -1575,7 +1552,7 @@ void PlayerList::removePlayerFromReceiving(std::shared_ptr player, } } if (!foundPrimary) { -#ifndef _CONTENT_PACKAGE +#if !defined(_CONTENT_PACKAGE) app.DebugPrintf( "Remove: Adding player %ls as primary in dimension " "%d\n", @@ -1595,7 +1572,7 @@ void PlayerList::addPlayerToReceiving(std::shared_ptr player) { else if (player->dimension == 1) playerDim = 2; -#ifndef _CONTENT_PACKAGE +#if !defined(_CONTENT_PACKAGE) app.DebugPrintf("Requesting add player %ls as primary in dimension %d\n", player->name.c_str(), playerDim); #endif @@ -1605,7 +1582,7 @@ void PlayerList::addPlayerToReceiving(std::shared_ptr player) { INetworkPlayer* thisPlayer = player->connection->getNetworkPlayer(); if (thisPlayer == NULL) { -#ifndef _CONTENT_PACKAGE +#if !defined(_CONTENT_PACKAGE) app.DebugPrintf( "Add: Qnet player for player %ls is NULL so not adding them\n", player->name.c_str()); @@ -1626,7 +1603,7 @@ void PlayerList::addPlayerToReceiving(std::shared_ptr player) { } if (shouldAddPlayer) { -#ifndef _CONTENT_PACKAGE +#if !defined(_CONTENT_PACKAGE) app.DebugPrintf("Add: Adding player %ls as primary in dimension %d\n", player->name.c_str(), playerDim); #endif diff --git a/Minecraft.Client/Network/ServerChunkCache.cpp b/Minecraft.Client/Network/ServerChunkCache.cpp index 79fdca861..5fda09389 100644 --- a/Minecraft.Client/Network/ServerChunkCache.cpp +++ b/Minecraft.Client/Network/ServerChunkCache.cpp @@ -31,7 +31,7 @@ ServerChunkCache::ServerChunkCache(ServerLevel* level, ChunkStorage* storage, this->cache = new LevelChunk*[XZSIZE * XZSIZE]; memset(this->cache, 0, XZSIZE * XZSIZE * sizeof(LevelChunk*)); -#ifdef _LARGE_WORLDS +#if defined(_LARGE_WORLDS) m_unloadedCache = new LevelChunk*[XZSIZE * XZSIZE]; memset(m_unloadedCache, 0, XZSIZE * XZSIZE * sizeof(LevelChunk*)); #endif @@ -46,7 +46,7 @@ ServerChunkCache::~ServerChunkCache() { delete[] cache; // 4jcraft changed to delete[] delete source; -#ifdef _LARGE_WORLDS +#if defined(_LARGE_WORLDS) for (unsigned int i = 0; i < XZSIZE * XZSIZE; ++i) { delete m_unloadedCache[i]; } @@ -81,7 +81,7 @@ std::vector* ServerChunkCache::getLoadedChunkList() { void ServerChunkCache::drop(int x, int z) { // 4J - we're not dropping things anymore now that we have a fixed sized // cache -#ifdef _LARGE_WORLDS +#if defined(_LARGE_WORLDS) bool canDrop = false; // if (level->dimension->mayRespawn()) @@ -117,7 +117,7 @@ void ServerChunkCache::drop(int x, int z) { } void ServerChunkCache::dropAll() { -#ifdef _LARGE_WORLDS +#if defined(_LARGE_WORLDS) for (LevelChunk* chunk : m_loadedChunkList) { drop(chunk->x, chunk->z); } @@ -158,7 +158,7 @@ LevelChunk* ServerChunkCache::create( LeaveCriticalSection(&m_csLoadCreate); -#if (defined _WIN64 || defined __LP64__) +#if defined(_WIN64) || defined(__LP64__) if (InterlockedCompareExchangeRelease64( (LONG64*)&cache[idx], (LONG64)chunk, (LONG64)lastChunk) == (LONG64)lastChunk) @@ -166,7 +166,7 @@ LevelChunk* ServerChunkCache::create( if (InterlockedCompareExchangeRelease((LONG*)&cache[idx], (LONG)chunk, (LONG)lastChunk) == (LONG)lastChunk) -#endif // 0 +#endif { // Successfully updated the cache EnterCriticalSection(&m_csLoadCreate); @@ -276,9 +276,6 @@ LevelChunk* ServerChunkCache::create( } } -#if 0 - Sleep(1); -#endif // 0 return chunk; } @@ -304,7 +301,7 @@ LevelChunk* ServerChunkCache::getChunk(int x, int z) { return emptyChunk; } -#ifdef _LARGE_WORLDS +#if defined(_LARGE_WORLDS) // 4J added - this special variation on getChunk also checks the unloaded chunk // cache. It is called on a host machine from the client-side level when: (1) // Trying to determine whether the client blocks and data are the same as those @@ -340,7 +337,7 @@ LevelChunk* ServerChunkCache::getChunkLoadedOrUnloaded(int x, int z) { // 4J MGH added, for expanding worlds, to kill any player changes and reset the // chunk -#ifdef _LARGE_WORLDS +#if defined(_LARGE_WORLDS) void ServerChunkCache::overwriteLevelChunkFromSource(int x, int z) { int ix = x + XZOFFSET; int iz = z + XZOFFSET; @@ -409,7 +406,7 @@ void ServerChunkCache::overwriteHellLevelChunkFromSource(int x, int z, #endif // 4J Added // -#ifdef _LARGE_WORLDS +#if defined(_LARGE_WORLDS) void ServerChunkCache::dontDrop(int x, int z) { LevelChunk* chunk = getChunk(x, z); m_toDrop.erase(std::remove(m_toDrop.begin(), m_toDrop.end(), chunk), @@ -422,7 +419,7 @@ LevelChunk* ServerChunkCache::load(int x, int z) { LevelChunk* levelChunk = NULL; -#ifdef _LARGE_WORLDS +#if defined(_LARGE_WORLDS) int ix = x + XZOFFSET; int iz = z + XZOFFSET; int idx = ix * XZSIZE + iz; @@ -694,7 +691,7 @@ bool ServerChunkCache::save(bool force, ProgressListener* progressListener) { // Single threaded implementation for small saves for (unsigned int i = 0; i < m_loadedChunkList.size(); i++) { LevelChunk* chunk = m_loadedChunkList[i]; -#ifndef SPLIT_SAVES +#if !defined(SPLIT_SAVES) if (force && !chunk->dontSave) saveEntities(chunk); #endif if (chunk->shouldSave(force)) { @@ -715,7 +712,6 @@ bool ServerChunkCache::save(bool force, ProgressListener* progressListener) { } } } else { -#if 1 //_LARGE_WORLDS // 4J Stu - We have multiple for threads for all saving as part of the // storage, so use that rather than new threads here @@ -773,211 +769,6 @@ bool ServerChunkCache::save(bool force, ProgressListener* progressListener) { // Wait for the storage threads to be complete storage->WaitForAll(); -#else - // Multithreaded implementation for larger saves - - C4JThread::Event* wakeEvent[3]; // This sets off the threads that are - // waiting to continue - C4JThread::Event* - notificationEvent[3]; // These are signalled by the threads to let - // us know they are complete - C4JThread* saveThreads[3]; - DWORD threadId[3]; - SaveThreadData threadData[3]; - ZeroMemory(&threadData[0], sizeof(SaveThreadData)); - ZeroMemory(&threadData[1], sizeof(SaveThreadData)); - ZeroMemory(&threadData[2], sizeof(SaveThreadData)); - - for (unsigned int i = 0; i < 3; ++i) { - saveThreads[i] = NULL; - - threadData[i].cache = this; - - wakeEvent[i] = - new C4JThread::Event(); // CreateEvent(NULL,FALSE,FALSE,NULL); - threadData[i].wakeEvent = wakeEvent[i]; - - notificationEvent[i] = - new C4JThread::Event(); // CreateEvent(NULL,FALSE,FALSE,NULL); - threadData[i].notificationEvent = notificationEvent[i]; - - if (i == 0) - threadData[i].useSharedThreadStorage = true; - else - threadData[i].useSharedThreadStorage = false; - } - - LevelChunk* chunk = NULL; - std::uint8_t workingThreads; - bool chunkSet = false; - - // Created a roughly sorted list to match the order that the files were - // created in McRegionChunkStorage::McRegionChunkStorage. This is to - // minimise the amount of data that needs to be moved round when - // creating a new level. - - std::vector sortedChunkList; - - for (int i = 0; i < m_loadedChunkList.size(); i++) { - if ((m_loadedChunkList[i]->x < 0) && (m_loadedChunkList[i]->z < 0)) - sortedChunkList.push_back(m_loadedChunkList[i]); - } - for (int i = 0; i < m_loadedChunkList.size(); i++) { - if ((m_loadedChunkList[i]->x >= 0) && (m_loadedChunkList[i]->z < 0)) - sortedChunkList.push_back(m_loadedChunkList[i]); - } - for (int i = 0; i < m_loadedChunkList.size(); i++) { - if ((m_loadedChunkList[i]->x >= 0) && - (m_loadedChunkList[i]->z >= 0)) - sortedChunkList.push_back(m_loadedChunkList[i]); - } - for (int i = 0; i < m_loadedChunkList.size(); i++) { - if ((m_loadedChunkList[i]->x < 0) && (m_loadedChunkList[i]->z >= 0)) - sortedChunkList.push_back(m_loadedChunkList[i]); - } - - for (unsigned int i = 0; i < sortedChunkList.size();) { - workingThreads = 0; - PIXBeginNamedEvent(0, "Setting tasks for save threads\n"); - for (unsigned int j = 0; j < 3; ++j) { - chunkSet = false; - - while (!chunkSet && i < sortedChunkList.size()) { - chunk = sortedChunkList[i]; - - threadData[j].saveEntities = (force && !chunk->dontSave); - - if (chunk->shouldSave(force) || - threadData[j].saveEntities) { - chunkSet = true; - ++workingThreads; - - threadData[j].chunkToSave = chunk; - - // app.DebugPrintf("Chunk to save set for thread %d\n", - // j); - - if (saveThreads[j] == NULL) { - char threadName[256]; - sprintf(threadName, "Save thread %d\n", j); - SetThreadName(threadId[j], threadName); - - // saveThreads[j] = - // CreateThread(NULL,0,runSaveThreadProc,&threadData[j],CREATE_SUSPENDED,&threadId[j]); - saveThreads[j] = new C4JThread( - runSaveThreadProc, (void*)&threadData[j], - threadName); - - // app.DebugPrintf("Created new thread: - // %s\n",threadName); - - // Threads 1,3 and 5 are generally idle so use them - // (this call waits on thread 2) - if (j == 0) - saveThreads[j]->SetProcessor( - CPU_CORE_SAVE_THREAD_A); // XSetThreadProcessor( - // saveThreads[j], - // 1); - else if (j == 1) - saveThreads[j]->SetProcessor( - CPU_CORE_SAVE_THREAD_B); // XSetThreadProcessor( - // saveThreads[j], - // 3); - else if (j == 2) - saveThreads[j]->SetProcessor( - CPU_CORE_SAVE_THREAD_C); // XSetThreadProcessor( - // saveThreads[j], - // 5); - - // ResumeThread( saveThreads[j] ); - saveThreads[j]->Run(); - } - - if (++saves == MAX_SAVES && !force) { - maxSavesReached = true; - break; - - // LeaveCriticalSection(&m_csLoadCreate); - // TODO Should we be returning from here? Probably - // not - // return false; - } - - // 4J - added this to support progressListener - if (progressListener != NULL) { - if (count > 0 && ++cc % 10 == 0) { - progressListener->progressStagePercentage( - cc * 100 / count); - } - } - } - - ++i; - } - - if (!chunkSet) { - threadData[j].chunkToSave = NULL; - // app.DebugPrintf("No chunk to save set for thread - // %d\n",j); - } - } - PIXEndNamedEvent(); - PIXBeginNamedEvent(0, "Waking save threads\n"); - // Start the worker threads going - for (unsigned int k = 0; k < 3; ++k) { - // app.DebugPrintf("Waking save thread %d\n",k); - threadData[k] - .wakeEvent->Set(); // SetEvent(threadData[k].wakeEvent); - } - PIXEndNamedEvent(); - PIXBeginNamedEvent(0, "Waiting for completion of save threads\n"); - // app.DebugPrintf("Waiting for %d save thread(s) to complete\n", - // workingThreads); - - // Wait for the worker threads to complete - // WaitForMultipleObjects(workingThreads,notificationEvent,TRUE,INFINITE); - // 4J Stu - TODO This isn't ideal as it's not a perfect - // re-implmentation of the Xbox behaviour - for (unsigned int k = 0; k < workingThreads; ++k) { - threadData[k].notificationEvent->WaitForSignal(INFINITE); - } - PIXEndNamedEvent(); - if (maxSavesReached) break; - } - - // app.DebugPrintf("Clearing up worker threads\n"); - // Stop all the worker threads by giving them nothing to process then - // telling them to start - unsigned char validThreads = 0; - for (unsigned int i = 0; i < 3; ++i) { - // app.DebugPrintf("Settings chunk to NULL for save thread %d\n", - // i); - threadData[i].chunkToSave = NULL; - - // app.DebugPrintf("Setting wake event for save thread %d\n",i); - threadData[i] - .wakeEvent->Set(); // SetEvent(threadData[i].wakeEvent); - - if (saveThreads[i] != NULL) ++validThreads; - } - - // WaitForMultipleObjects(validThreads,saveThreads,TRUE,INFINITE); - // 4J Stu - TODO This isn't ideal as it's not a perfect - // re-implmentation of the Xbox behaviour - for (unsigned int k = 0; k < validThreads; ++k) { - saveThreads[k]->WaitForCompletion(INFINITE); - ; - } - - for (unsigned int i = 0; i < 3; ++i) { - // app.DebugPrintf("Closing handles for save thread %d\n", i); - delete threadData[i] - .wakeEvent; // CloseHandle(threadData[i].wakeEvent); - delete threadData[i] - .notificationEvent; // CloseHandle(threadData[i].notificationEvent); - delete saveThreads[i]; // CloseHandle(saveThreads[i]); - } -#endif } if (force) { @@ -994,7 +785,7 @@ bool ServerChunkCache::save(bool force, ProgressListener* progressListener) { bool ServerChunkCache::tick() { if (!level->noSave) { -#ifdef _LARGE_WORLDS +#if defined(_LARGE_WORLDS) for (int i = 0; i < 100; i++) { if (!m_toDrop.empty()) { LevelChunk* chunk = m_toDrop.front(); diff --git a/Minecraft.Client/Player/LocalPlayer.cpp b/Minecraft.Client/Player/LocalPlayer.cpp index 9be2a1850..4efe76482 100644 --- a/Minecraft.Client/Player/LocalPlayer.cpp +++ b/Minecraft.Client/Player/LocalPlayer.cpp @@ -53,9 +53,7 @@ #include "../GameState/Options.h" #include "../../Minecraft.World/Level/Dimensions/Dimension.h" -#if 1 #include "../../Minecraft.World/Stats/CommonStats.h" -#endif LocalPlayer::LocalPlayer(Minecraft* minecraft, Level* level, User* user, int dimension) @@ -306,11 +304,11 @@ void LocalPlayer::aiStep() { } } else if ((!input->jumping) && (jumpTriggerTime > 0) && twoJumpsRegistered) { -#ifndef _CONTENT_PACKAGE +#if !defined(_CONTENT_PACKAGE) printf("flying was %s\n", abilities.flying ? "on" : "off"); #endif abilities.flying = !abilities.flying; -#ifndef _CONTENT_PACKAGE +#if !defined(_CONTENT_PACKAGE) printf("flying is %s\n", abilities.flying ? "on" : "off"); #endif jumpTriggerTime = 0; @@ -321,7 +319,7 @@ void LocalPlayer::aiStep() { // into flying mode whilst sneaking? } } else if (abilities.flying) { -#ifdef _DEBUG_MENUS_ENABLED +#if defined(_DEBUG_MENUS_ENABLED) if (!abilities.debugflying) #endif { @@ -393,7 +391,7 @@ void LocalPlayer::aiStep() { // 4J-PB - If we're in Creative Mode, allow flying on ground if (!abilities.mayfly && !isAllowedToFly()) { if (onGround && abilities.flying) { -#ifdef _DEBUG_MENUS_ENABLED +#if defined(_DEBUG_MENUS_ENABLED) if (!abilities.debugflying) #endif { @@ -409,7 +407,7 @@ void LocalPlayer::aiStep() { // 4J-PB - To let the player build easily while flying, we need to // change this -#ifdef _DEBUG_MENUS_ENABLED +#if defined(_DEBUG_MENUS_ENABLED) if (abilities.debugflying) { flyX = (float)viewVector->x * input->ya; flyY = (float)viewVector->y * input->ya; @@ -486,7 +484,7 @@ void LocalPlayer::changeDimension(int i) { if (dimension == 1 && i == 1) { awardStat(GenericStats::winGame(), GenericStats::param_noArgs()); // minecraft.setScreen(new WinScreen()); -#ifndef _CONTENT_PACKAGE +#if !defined(_CONTENT_PACKAGE) app.DebugPrintf( "LocalPlayer::changeDimension from 1 to 1 but WinScreen has " "not been implemented.\n"); @@ -548,7 +546,7 @@ void LocalPlayer::closeContainer() { } void LocalPlayer::openTextEdit(std::shared_ptr tileEntity) { -#ifdef ENABLE_JAVA_GUIS +#if defined(ENABLE_JAVA_GUIS) if (tileEntity->GetType() == eTYPE_SIGNTILEENTITY) { minecraft->setScreen(new TextEditScreen(std::dynamic_pointer_cast(tileEntity))); bool success = true; @@ -571,7 +569,7 @@ void LocalPlayer::openTextEdit(std::shared_ptr tileEntity) { } bool LocalPlayer::openContainer(std::shared_ptr container) { -#ifdef ENABLE_JAVA_GUIS +#if defined(ENABLE_JAVA_GUIS) minecraft->setScreen(new ContainerScreen(inventory, container)); bool success = true; #else @@ -606,7 +604,7 @@ bool LocalPlayer::openHorseInventory(std::shared_ptr horse, } bool LocalPlayer::startCrafting(int x, int y, int z) { -#ifdef ENABLE_JAVA_GUIS +#if defined(ENABLE_JAVA_GUIS) minecraft->setScreen(new CraftingScreen(inventory, level, x, y, z)); bool success = true; #else @@ -638,7 +636,7 @@ bool LocalPlayer::startEnchanting(int x, int y, int z, } bool LocalPlayer::startRepairing(int x, int y, int z) { -#ifdef ENABLE_JAVA_GUIS +#if defined(ENABLE_JAVA_GUIS) // minecraft.setScreen(new RepairScreen(inventory, level, x, y, z)); // FUCK YOU 4J FIRST AND FOREMOST bool success = true; @@ -651,7 +649,7 @@ bool LocalPlayer::startRepairing(int x, int y, int z) { } bool LocalPlayer::openFurnace(std::shared_ptr furnace) { -#ifdef ENABLE_JAVA_GUIS +#if defined(ENABLE_JAVA_GUIS) minecraft->setScreen(new FurnaceScreen(inventory, furnace)); bool success = true; #else @@ -761,15 +759,6 @@ void LocalPlayer::displayClientMessage(int messageId) { } void LocalPlayer::awardStat(Stat* stat, byteArray param) { -#if 0 - // 4J-JEV: Maybe we want to fine tune this later? #TODO - if (!ProfileManager.IsGuest(GetXboxPad()) && - app.CanRecordStatsAndAchievements() && ProfileManager.IsFullVersion()) { - stat->handleParamBlob( - std::dynamic_pointer_cast(shared_from_this()), param); - } - delete[] param.data; -#else int count = CommonStats::readParam(param); delete[] param.data; @@ -785,7 +774,7 @@ void LocalPlayer::awardStat(Stat* stat, byteArray param) { if (!minecraft->stats[m_iPad]->hasTaken(ach)) { // 4J-PB - Don't display the java popup -#ifdef ENABLE_JAVA_GUIS +#if defined(ENABLE_JAVA_GUIS) minecraft->achievementPopup->popup(ach); #endif @@ -908,27 +897,8 @@ void LocalPlayer::awardStat(Stat* stat, byteArray param) { } } -#if 0 - // AWARD: Have we killed 10 creepers? - if (pStats->getTotalValue(GenericStats::killsCreeper()) >= 10) { - awardStat(GenericStats::kill10Creepers(), - GenericStats::param_noArgs()); - } - // AWARD : Have we been playing for 100 game days? - if (pStats->getTotalValue(GenericStats::timePlayed()) >= - (Level::TICKS_PER_DAY * 100)) { - awardStat(GenericStats::play100Days(), - GenericStats::param_noArgs()); - } - // AWARD : Have we mined 100 blocks? - if (pStats->getTotalValue(GenericStats::totalBlocksMined()) >= 100) { - awardStat(GenericStats::mine100Blocks(), - GenericStats::param_noArgs()); - } -#endif - -#ifdef _EXTENDED_ACHIEVEMENTS +#if defined(_EXTENDED_ACHIEVEMENTS) // AWARD : Porkchop, cook and eat a porkchop. { @@ -1087,7 +1057,6 @@ void LocalPlayer::awardStat(Stat* stat, byteArray param) { } #endif } -#endif } bool LocalPlayer::isSolidBlock(int x, int y, int z) { diff --git a/Minecraft.Client/Player/MultiPlayerLocalPlayer.cpp b/Minecraft.Client/Player/MultiPlayerLocalPlayer.cpp index 4d287b9cc..63f91dca7 100644 --- a/Minecraft.Client/Player/MultiPlayerLocalPlayer.cpp +++ b/Minecraft.Client/Player/MultiPlayerLocalPlayer.cpp @@ -16,7 +16,7 @@ #include "../Rendering/LevelRenderer.h" // 4J added for testing -#ifdef STRESS_TEST_MOVE +#if defined(STRESS_TEST_MOVE) volatile bool stressTestEnabled = true; #endif @@ -68,7 +68,7 @@ void MultiplayerLocalPlayer::tick() { LocalPlayer::tick(); // 4J added for testing -#ifdef STRESS_TEST_MOVE +#if defined(STRESS_TEST_MOVE) if (stressTestEnabled) { StressTestMove(&tempX, &tempY, &tempZ); } @@ -385,7 +385,7 @@ void MultiplayerLocalPlayer::StopSleeping() { void MultiplayerLocalPlayer::setAndBroadcastCustomSkin(std::uint32_t skinId) { std::uint32_t oldSkinIndex = getCustomSkin(); LocalPlayer::setCustomSkin(skinId); -#ifndef _CONTENT_PACKAGE +#if !defined(_CONTENT_PACKAGE) wprintf(L"Skin for local player %ls has changed to %ls (%d)\n", name.c_str(), customTextureUrl.c_str(), getPlayerDefaultSkin()); #endif @@ -398,7 +398,7 @@ void MultiplayerLocalPlayer::setAndBroadcastCustomSkin(std::uint32_t skinId) { void MultiplayerLocalPlayer::setAndBroadcastCustomCape(std::uint32_t capeId) { std::uint32_t oldCapeIndex = getCustomCape(); LocalPlayer::setCustomCape(capeId); -#ifndef _CONTENT_PACKAGE +#if !defined(_CONTENT_PACKAGE) wprintf(L"Cape for local player %ls has changed to %ls\n", name.c_str(), customTextureUrl2.c_str()); #endif @@ -417,7 +417,7 @@ void MultiplayerLocalPlayer::setAndBroadcastCustomCape(std::uint32_t capeId) { // back to mode 0 Whilst carrying out this movement pattern, this calls // checkAllPresentChunks which checks the integrity of all currently // loaded/created chunks round the player. -#ifdef STRESS_TEST_MOVE +#if defined(STRESS_TEST_MOVE) void MultiplayerLocalPlayer::StressTestMove(double* tempX, double* tempY, double* tempZ) { static volatile int64_t lastChangeTime = 0; @@ -448,15 +448,6 @@ void MultiplayerLocalPlayer::StressTestMove(double* tempX, double* tempY, static float dx = cos(30.0); static float dz = sin(30.0); -#if 0 - if( ( stressTestCount % dirChangeTickCount) == 0 ) - { - int angledeg = rand() % 360; - angle = (((double)angledeg) / 360.0 ) * ( 2.0 * 3.141592654 ); - dx = cos(angle); - dz = sin(angle); - } -#endif float nx = x + (dx * 1.2); float nz = z + (dz * 1.2); diff --git a/Minecraft.Client/Player/ServerPlayer.cpp b/Minecraft.Client/Player/ServerPlayer.cpp index 5f9ceedfd..6780660a2 100644 --- a/Minecraft.Client/Player/ServerPlayer.cpp +++ b/Minecraft.Client/Player/ServerPlayer.cpp @@ -374,22 +374,9 @@ void ServerPlayer::doChunkSendingTick(bool dontDelayChunks) { if (dontDelayChunks || (canSendToPlayer && -#if 0 - // The network manager on xbox one doesn't currently split - // data into slow & fast queues - since we can only measure - // both together then bytes provides a better metric than - // count of data items to determine if we should avoid - // queueing too much up - (g_NetworkManager.GetHostPlayer()->GetSendQueueSizeBytes( - NULL, true) < 8192) && -#elif 0 - (g_NetworkManager.GetHostPlayer() - ->GetSendQueueSizeMessages(NULL, true) < 4) && -#else (connection->countDelayedPackets() < 4) && (g_NetworkManager.GetHostPlayer() ->GetSendQueueSizeMessages(NULL, true) < 4) && -#endif //(tickCount - lastBrupSendTickCount) > //(connection->getNetworkPlayer()->GetCurrentRtt()>>4) && !connection->done)) { @@ -521,7 +508,7 @@ void ServerPlayer::doChunkSendingTick(bool dontDelayChunks) { } void ServerPlayer::doTickB() { -#ifndef _CONTENT_PACKAGE +#if !defined(_CONTENT_PACKAGE) // check if there's a debug dimension change requested // if(app.GetGameSettingsDebugMask(ProfileManager.GetPrimaryPad())&(1L<awardLocallyOnly) { -#if 1 int count = *((int*)param.data); delete[] param.data; connection->send(std::shared_ptr( new AwardStatPacket(stat->id, count))); -#else - connection->send(std::shared_ptr( - new AwardStatPacket(stat->id, param))); - // byteArray deleted in AwardStatPacket destructor. -#endif } else delete[] param.data; } @@ -1824,7 +1805,7 @@ void ServerPlayer::handleCollectItem(std::shared_ptr item) { gameMode->getGameRules()->onCollectItem(item); } -#ifndef _CONTENT_PACKAGE +#if !defined(_CONTENT_PACKAGE) void ServerPlayer::debug_setPosition(double x, double y, double z, double nYRot, double nXRot) { connection->teleport(x, y, z, nYRot, nXRot); diff --git a/Minecraft.Client/Rendering/Camera.cpp b/Minecraft.Client/Rendering/Camera.cpp index c50b0bdb8..cc6bc9b41 100644 --- a/Minecraft.Client/Rendering/Camera.cpp +++ b/Minecraft.Client/Rendering/Camera.cpp @@ -48,23 +48,6 @@ zPlayerOffs = position->get(2); memcpy(&_modelview, modelview->_getDataPointer(), 64); memcpy(&_proj, projection->_getDataPointer(), 64); -#if (0) || (0) - _modelview = transpose(_modelview); - _proj = transpose(_proj); - _final = _modelview * _proj; - _invert = sce::Vectormath::Simd::Aos::inverse(_final); - xPlayerOffs = _invert.getElem(0, 3) / _invert.getElem(3, 3); - yPlayerOffs = _invert.getElem(1, 3) / _invert.getElem(3, 3); - zPlayerOffs = _invert.getElem(2, 3) / _invert.getElem(3, 3); -#elif 0 - _modelview = transpose(_modelview); - _proj = transpose(_proj); - _final = _modelview * _proj; - _invert = Vectormath::Aos::inverse(_final); - xPlayerOffs = _invert.getElem(0, 3) / _invert.getElem(3, 3); - yPlayerOffs = _invert.getElem(1, 3) / _invert.getElem(3, 3); - zPlayerOffs = _invert.getElem(2, 3) / _invert.getElem(3, 3); -#else _final = XMMatrixMultiply(_modelview, _proj); _det = XMMatrixDeterminant(_final); _invert = XMMatrixInverse(&_det, _final); @@ -74,7 +57,6 @@ zPlayerOffs = position->get(2); xPlayerOffs = trans.x / trans.w; yPlayerOffs = trans.y / trans.w; zPlayerOffs = trans.z / trans.w; -#endif int flipCamera = mirror ? 1 : 0; diff --git a/Minecraft.Client/Rendering/Chunk.cpp b/Minecraft.Client/Rendering/Chunk.cpp index 721efd4b2..0659ea722 100644 --- a/Minecraft.Client/Rendering/Chunk.cpp +++ b/Minecraft.Client/Rendering/Chunk.cpp @@ -8,12 +8,10 @@ #include "../../Minecraft.World/Headers/net.minecraft.world.level.tile.entity.h" #include "LevelRenderer.h" -#if 0 -#endif int Chunk::updates = 0; -#ifdef _LARGE_WORLDS +#if defined(_LARGE_WORLDS) thread_local uint8_t* Chunk::m_tlsTileIds = nullptr; void Chunk::CreateNewThreadStorage() { @@ -66,7 +64,6 @@ void Chunk::setPos(int x, int y, int z) { clipChunk->globalIdx = LevelRenderer::getGlobalIndexForChunk(x, y, z, level); -#if 1 // 4J - we're not using offsetted renderlists anymore, so just set the full // position of this chunk into x/y/zRenderOffs where it will be used // directly in the renderlist of this chunk @@ -76,14 +73,6 @@ void Chunk::setPos(int x, int y, int z) { xRender = 0; yRender = 0; zRender = 0; -#else - xRenderOffs = x & 1023; - yRenderOffs = y; - zRenderOffs = z & 1023; - xRender = x - xRenderOffs; - yRender = y - yRenderOffs; - zRender = z - zRenderOffs; -#endif float g = 6.0f; // 4J - changed to just set the value rather than make a new one, if we've @@ -125,11 +114,7 @@ void Chunk::setPos(int x, int y, int z) { // other than the ones in the stack itself have been made dirty. levelRenderer->setGlobalChunkFlag(x, y, z, level, LevelRenderer::CHUNK_FLAG_DIRTY); -#if 0 - PIXSetMarker(0, "Non-stack event pushed"); -#else PIXSetMarkerDeprecated(0, "Non-stack event pushed"); -#endif } LeaveCriticalSection(&levelRenderer->m_csDirtyChunks); @@ -165,15 +150,11 @@ void Chunk::makeCopyForRebuild(Chunk* source) { void Chunk::rebuild() { PIXBeginNamedEvent(0, "Rebuilding chunk %d, %d, %d", x, y, z); -#if 0 && !defined DISABLE_SPU_CODE - rebuild_SPU(); - return; -#endif // 0 // if (!dirty) return; PIXBeginNamedEvent(0, "Rebuild section A"); -#ifdef _LARGE_WORLDS +#if defined(_LARGE_WORLDS) Tesselator* t = Tesselator::getInstance(); #else Chunk::t = Tesselator::getInstance(); // 4J - added - static initialiser @@ -217,7 +198,7 @@ void Chunk::rebuild() { // it is ordered by x then z then y so just getting a small range of y out // of it would involve getting the whole thing into the cache anyway. -#ifdef _LARGE_WORLDS +#if defined(_LARGE_WORLDS) unsigned char* tileIds = GetTileIdsStorage(); #else static unsigned char tileIds[16 * 16 * Level::maxBuildHeight]; @@ -238,11 +219,6 @@ void Chunk::rebuild() { // that calls to Region::getTile can grab data more quickly from this array // rather than calling CompressedTileStorage. On the Vita the total thread // time spent in Region::getTile went from 20% to 4%. -#if 0 - int xc = x >> 4; - int zc = z >> 4; - ((Region*)region)->setCachedTiles(tileIds, xc, zc); -#endif // We now go through the vertical section of this level chunk that we are // interested in and try and establish (1) if it is completely empty (2) if @@ -420,11 +396,6 @@ void Chunk::rebuild() { // should need it, and have now optimised the vertex // shader so it doesn't do anything other than // translate with this matrix anyway -#if 0 - glTranslatef(-zs / 2.0f, -ys / 2.0f, -zs / 2.0f); - glScalef(ss, ss, ss); - glTranslatef(zs / 2.0f, ys / 2.0f, zs / 2.0f); -#endif t->begin(); t->offset((float)(-this->x), (float)(-this->y), (float)(-this->z)); @@ -452,24 +423,8 @@ void Chunk::rebuild() { } } -#if 0 - if (currentLayer == 0) { - levelRenderer->clearGlobalChunkFlag( - this->x, this->y, this->z, level, - LevelRenderer::CHUNK_FLAG_CUT_OUT); - } -#endif if (started) { -#if 0 - // AP - make sure we don't attempt to render chunks without cutout - // geometry - if (t->getCutOutFound()) { - levelRenderer->setGlobalChunkFlag( - this->x, this->y, this->z, level, - LevelRenderer::CHUNK_FLAG_CUT_OUT); - } -#endif t->end(); bounds.addBounds(t->bounds); // 4J MGH - added glPopMatrix(); @@ -519,7 +474,6 @@ void Chunk::rebuild() { // globally in the levelrenderer, in a hashmap with a special key made up // from the dimension and chunk position (using same index as is used for // global flags) -#if 1 int key = levelRenderer->getGlobalIndexForChunk(this->x, this->y, this->z, level); EnterCriticalSection(globalRenderableTileEntities_cs); @@ -573,62 +527,6 @@ void Chunk::rebuild() { } LeaveCriticalSection(globalRenderableTileEntities_cs); PIXEndNamedEvent(); -#else - // Find the removed ones: - - // 4J - original code for this section: - /* - Set newTileEntities = new HashSet(); - newTileEntities.addAll(renderableTileEntities); - newTileEntities.removeAll(oldTileEntities); - globalRenderableTileEntities.addAll(newTileEntities); - - oldTileEntities.removeAll(renderableTileEntities); - globalRenderableTileEntities.removeAll(oldTileEntities); - */ - - std::unordered_set > newTileEntities( - renderableTileEntities.begin(), renderableTileEntities.end()); - - AUTO_VAR(endIt, oldTileEntities.end()); - for (std::unordered_set >::iterator it = - oldTileEntities.begin(); - it != endIt; it++) { - newTileEntities.erase(*it); - } - - // 4J - newTileEntities is now renderableTileEntities with any old ones from - // oldTileEntitesRemoved (so just new things added) - - EnterCriticalSection(globalRenderableTileEntities_cs); - endIt = newTileEntities.end(); - for (std::unordered_set >::iterator it = - newTileEntities.begin(); - it != endIt; it++) { - globalRenderableTileEntities->push_back(*it); - } - - // 4J - All these new things added to globalRenderableTileEntities - - AUTO_VAR(endItRTE, renderableTileEntities.end()); - for (std::vector >::iterator it = - renderableTileEntities.begin(); - it != endItRTE; it++) { - oldTileEntities.erase(*it); - } - // 4J - oldTileEntities is now the removed items - std::vector >::iterator it = - globalRenderableTileEntities->begin(); - while (it != globalRenderableTileEntities->end()) { - if (oldTileEntities.find(*it) != oldTileEntities.end()) { - it = globalRenderableTileEntities->erase(it); - } else { - ++it; - } - } - - LeaveCriticalSection(globalRenderableTileEntities_cs); -#endif // 4J - These removed items are now also removed from // globalRenderableTileEntities @@ -646,328 +544,6 @@ void Chunk::rebuild() { return; } -#if 0 -ChunkRebuildData g_rebuildDataIn __attribute__((__aligned__(16))); -ChunkRebuildData g_rebuildDataOut __attribute__((__aligned__(16))); -TileCompressData_SPU g_tileCompressDataIn __attribute__((__aligned__(16))); -unsigned char* g_tileCompressDataOut = - (unsigned char*)&g_rebuildDataIn.m_tileIds; - -void RunSPURebuild() { - static C4JSpursJobQueue::Port p("C4JSpursJob_ChunkUpdate"); - C4JSpursJob_CompressedTile tileJob(&g_tileCompressDataIn, - g_tileCompressDataOut); - C4JSpursJob_ChunkUpdate chunkJob(&g_rebuildDataIn, &g_rebuildDataOut); - - if (g_rebuildDataIn.m_currentLayer == - 0) // only need to create the tiles on the first layer - { - p.submitJob(&tileJob); - p.submitSync(); - } - - p.submitJob(&chunkJob); - p.waitForCompletion(); - - assert(g_rebuildDataIn.m_x0 == g_rebuildDataOut.m_x0); -} - -void Chunk::rebuild_SPU() { - // if (!dirty) return; - Chunk::t = Tesselator::getInstance(); // 4J - added - static initialiser - // being set at the wrong time - updates++; - - int x0 = x; - int y0 = y; - int z0 = z; - int x1 = x + SIZE; - int y1 = y + SIZE; - int z1 = z + SIZE; - - LevelChunk::touchedSky = false; - - // unordered_set > - // oldTileEntities(renderableTileEntities.begin(),renderableTileEntities.end()); - //// 4J removed this & next line renderableTileEntities.clear(); - - std::vector > - renderableTileEntities; // 4J - added - - // List newTileEntities = new ArrayList(); - // newTileEntities.clear(); - // renderableTileEntities.clear(); - - int r = 1; - - Region region(level, x0 - r, y0 - r, z0 - r, x1 + r, y1 + r, z1 + r, r); - TileRenderer tileRenderer(®ion); - - int lists = levelRenderer->getGlobalIndexForChunk(this->x, this->y, this->z, - level) * - 2; - lists += levelRenderer->chunkLists; - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // 4J - optimisation begins. - - // Get the data for the level chunk that this render chunk is it (level - // chunk is 16 x 16 x 128, render chunk is 16 x 16 x 16. We wouldn't have to - // actually get all of it if the data was ordered differently, but currently - // it is ordered by x then z then y so just getting a small range of y out - // of it would involve getting the whole thing into the cache anyway. - ChunkRebuildData* pOutData = NULL; - g_rebuildDataIn.buildForChunk(®ion, level, x0, y0, z0); - - Tesselator::Bounds bounds; - { - // this was the old default clip bounds for the chunk, set in - // Chunk::setPos. - float g = 6.0f; - bounds.boundingBox[0] = -g; - bounds.boundingBox[1] = -g; - bounds.boundingBox[2] = -g; - bounds.boundingBox[3] = SIZE + g; - bounds.boundingBox[4] = SIZE + g; - bounds.boundingBox[5] = SIZE + g; - } - - for (int currentLayer = 0; currentLayer < 2; currentLayer++) { - bool rendered = false; - - { - glNewList(lists + currentLayer, GL_COMPILE); - MemSect(0); - glPushMatrix(); - glDepthMask(true); // 4J added - t->useCompactVertices(true); // 4J added - translateToPos(); - float ss = 1.000001f; - // 4J - have removed this scale as I don't think we should need it, - // and have now optimised the vertex shader so it doesn't do - // anything other than translate with this matrix anyway -#if 0 - glTranslatef(-zs / 2.0f, -ys / 2.0f, -zs / 2.0f); - glScalef(ss, ss, ss); - glTranslatef(zs / 2.0f, ys / 2.0f, zs / 2.0f); -#endif - t->begin(); - t->offset((float)(-this->x), (float)(-this->y), (float)(-this->z)); - } - - g_rebuildDataIn.copyFromTesselator(); - intArray_SPU tesselatorArray( - (unsigned int*)g_rebuildDataIn.m_tesselator.m_PPUArray); - g_rebuildDataIn.m_tesselator._array = &tesselatorArray; - g_rebuildDataIn.m_currentLayer = currentLayer; - g_tileCompressDataIn.setForChunk(®ion, x0, y0, z0); - RunSPURebuild(); - g_rebuildDataOut.storeInTesselator(); - pOutData = &g_rebuildDataOut; - - if (pOutData->m_flags & ChunkRebuildData::e_flag_Rendered) - rendered = true; - - // 4J - changed loop order here to leave y as the innermost loop for - // better cache performance - for (int z = z0; z < z1; z++) { - for (int x = x0; x < x1; x++) { - for (int y = y0; y < y1; y++) { - // 4J - get tile from those copied into our local array in - // earlier optimisation - unsigned char tileId = pOutData->getTile(x, y, z); - if (tileId > 0) { - if (currentLayer == 0 && - Tile::tiles[tileId]->isEntityTile()) { - std::shared_ptr et = - region.getTileEntity(x, y, z); - if (TileEntityRenderDispatcher::instance - ->hasRenderer(et)) { - renderableTileEntities.push_back(et); - } - } - int flags = pOutData->getFlags(x, y, z); - if (flags & - ChunkRebuildData::e_flag_SPURenderCodeMissing) { - Tile* tile = Tile::tiles[tileId]; - int renderLayer = tile->getRenderLayer(); - - if (renderLayer != currentLayer) { - // renderNextLayer - //= true; - } else if (renderLayer == currentLayer) { - // if(currentLayer == 0) - // numRenderedLayer0++; - rendered |= tileRenderer.tesselateInWorld( - tile, x, y, z); - } - } - } - } - } - } - - { - t->end(); - bounds.addBounds(t->bounds); - glPopMatrix(); - glEndList(); - t->useCompactVertices(false); // 4J added - t->offset(0, 0, 0); - } - if (rendered) { - levelRenderer->clearGlobalChunkFlag( - this->x, this->y, this->z, level, - LevelRenderer::CHUNK_FLAG_EMPTY0, currentLayer); - } else { - // 4J - added - clear any renderer data associated with this unused - // list - levelRenderer->setGlobalChunkFlag(this->x, this->y, this->z, level, - LevelRenderer::CHUNK_FLAG_EMPTY0, - currentLayer); - RenderManager.CBuffClear(lists + currentLayer); - } - } - - if (bb) { - bb->set(bounds.boundingBox[0], bounds.boundingBox[1], - bounds.boundingBox[2], bounds.boundingBox[3], - bounds.boundingBox[4], bounds.boundingBox[5]); - } - - if (pOutData->m_flags & ChunkRebuildData::e_flag_TouchedSky) - LevelChunk::touchedSky = true; - - // 4J - have rewritten the way that tile entities are stored globally to - // make it work more easily with split screen. Chunks are now stored - // globally in the levelrenderer, in a hashmap with a special key made up - // from the dimension and chunk position (using same index as is used for - // global flags) -#if 1 - int key = - levelRenderer->getGlobalIndexForChunk(this->x, this->y, this->z, level); - EnterCriticalSection(globalRenderableTileEntities_cs); - if (renderableTileEntities.size()) { - AUTO_VAR(it, globalRenderableTileEntities->find(key)); - if (it != globalRenderableTileEntities->end()) { - // We've got some renderable tile entities that we want associated - // with this chunk, and an existing list of things that used to be. - // We need to flag any that we don't need any more to be removed, - // keep those that we do, and add any new ones - - // First pass - flag everything already existing to be removed - for (AUTO_VAR(it2, it->second.begin()); it2 != it->second.end(); - it2++) { - (*it2)->setRenderRemoveStage( - TileEntity::e_RenderRemoveStageFlaggedAtChunk); - } - - // Now go through the current list. If these are already in the - // list, then unflag the remove flag. If they aren't, then add - for (int i = 0; i < renderableTileEntities.size(); i++) { - AUTO_VAR(it2, find(it->second.begin(), it->second.end(), - renderableTileEntities[i])); - if (it2 == it->second.end()) { - (*globalRenderableTileEntities)[key].push_back( - renderableTileEntities[i]); - } else { - (*it2)->setRenderRemoveStage( - TileEntity::e_RenderRemoveStageKeep); - } - } - } else { - // Easy case - nothing already existing for this chunk. Add them all - // in. - for (int i = 0; i < renderableTileEntities.size(); i++) { - (*globalRenderableTileEntities)[key].push_back( - renderableTileEntities[i]); - } - } - } else { - // Another easy case - we don't want any renderable tile entities - // associated with this chunk. Flag all to be removed. - AUTO_VAR(it, globalRenderableTileEntities->find(key)); - if (it != globalRenderableTileEntities->end()) { - for (AUTO_VAR(it2, it->second.begin()); it2 != it->second.end(); - it2++) { - (*it2)->setRenderRemoveStage( - TileEntity::e_RenderRemoveStageFlaggedAtChunk); - } - } - } - LeaveCriticalSection(globalRenderableTileEntities_cs); -#else - // Find the removed ones: - - // 4J - original code for this section: - /* - Set newTileEntities = new HashSet(); - newTileEntities.addAll(renderableTileEntities); - newTileEntities.removeAll(oldTileEntities); - globalRenderableTileEntities.addAll(newTileEntities); - - oldTileEntities.removeAll(renderableTileEntities); - globalRenderableTileEntities.removeAll(oldTileEntities); - */ - - std::unordered_set > newTileEntities( - renderableTileEntities.begin(), renderableTileEntities.end()); - - AUTO_VAR(endIt, oldTileEntities.end()); - for (std::unordered_set >::iterator it = - oldTileEntities.begin(); - it != endIt; it++) { - newTileEntities.erase(*it); - } - - // 4J - newTileEntities is now renderableTileEntities with any old ones from - // oldTileEntitesRemoved (so just new things added) - - EnterCriticalSection(globalRenderableTileEntities_cs); - endIt = newTileEntities.end(); - for (std::unordered_set >::iterator it = - newTileEntities.begin(); - it != endIt; it++) { - globalRenderableTileEntities.push_back(*it); - } - - // 4J - All these new things added to globalRenderableTileEntities - - AUTO_VAR(endItRTE, renderableTileEntities.end()); - for (std::vector >::iterator it = - renderableTileEntities.begin(); - it != endItRTE; it++) { - oldTileEntities.erase(*it); - } - // 4J - oldTileEntities is now the removed items - std::vector >::iterator it = - globalRenderableTileEntities->begin(); - while (it != globalRenderableTileEntities->end()) { - if (oldTileEntities.find(*it) != oldTileEntities.end()) { - it = globalRenderableTileEntities->erase(it); - } else { - ++it; - } - } - - LeaveCriticalSection(globalRenderableTileEntities_cs); -#endif - - // 4J - These removed items are now also removed from - // globalRenderableTileEntities - - if (LevelChunk::touchedSky) { - levelRenderer->clearGlobalChunkFlag( - x, y, z, level, LevelRenderer::CHUNK_FLAG_NOTSKYLIT); - } else { - levelRenderer->setGlobalChunkFlag(x, y, z, level, - LevelRenderer::CHUNK_FLAG_NOTSKYLIT); - } - levelRenderer->setGlobalChunkFlag(x, y, z, level, - LevelRenderer::CHUNK_FLAG_COMPILED); - return; -} -#endif // _PS3_ float Chunk::distanceToSqr(std::shared_ptr player) const { float xd = (float)(player->x - xm); @@ -1052,7 +628,7 @@ void Chunk::setDirty() { void Chunk::clearDirty() { levelRenderer->clearGlobalChunkFlag(x, y, z, level, LevelRenderer::CHUNK_FLAG_DIRTY); -#ifdef _CRITICAL_CHUNKS +#if defined(_CRITICAL_CHUNKS) levelRenderer->clearGlobalChunkFlag(x, y, z, level, LevelRenderer::CHUNK_FLAG_CRITICAL); #endif diff --git a/Minecraft.Client/Rendering/Chunk.h b/Minecraft.Client/Rendering/Chunk.h index 8e9a10209..2a1896ed3 100644 --- a/Minecraft.Client/Rendering/Chunk.h +++ b/Minecraft.Client/Rendering/Chunk.h @@ -27,7 +27,7 @@ public: static LevelRenderer* levelRenderer; private: -#ifndef _LARGE_WORLDS +#if !defined(_LARGE_WORLDS) static Tesselator* t; #else static thread_local uint8_t* m_tlsTileIds; @@ -73,9 +73,6 @@ private: public: void makeCopyForRebuild(Chunk* source); void rebuild(); -#if 0 - void rebuild_SPU(); -#endif // 0 float distanceToSqr(std::shared_ptr player) const; float squishedDistanceToSqr(std::shared_ptr player); void reset(); diff --git a/Minecraft.Client/Rendering/EntityRenderers/ChestRenderer.cpp b/Minecraft.Client/Rendering/EntityRenderers/ChestRenderer.cpp index cc6a181d8..80bac57e1 100644 --- a/Minecraft.Client/Rendering/EntityRenderers/ChestRenderer.cpp +++ b/Minecraft.Client/Rendering/EntityRenderers/ChestRenderer.cpp @@ -27,12 +27,6 @@ ChestRenderer::ChestRenderer() : TileEntityRenderer() { xmasTextures = false; // 4J Stu - Disable this -#if 0 - if (Calendar::GetMonth() + 1 == 12 && Calendar::GetDayOfMonth() >= 24 && Calendar::GetDayOfMonth() <= 26) - { - xmasTextures = true; - } -#endif } ChestRenderer::~ChestRenderer() { diff --git a/Minecraft.Client/Rendering/EntityRenderers/EnchantTableRenderer.cpp b/Minecraft.Client/Rendering/EntityRenderers/EnchantTableRenderer.cpp index 274f89ef3..a8541fd00 100644 --- a/Minecraft.Client/Rendering/EntityRenderers/EnchantTableRenderer.cpp +++ b/Minecraft.Client/Rendering/EntityRenderers/EnchantTableRenderer.cpp @@ -18,14 +18,6 @@ void EnchantTableRenderer::render(std::shared_ptr _table, double x, std::shared_ptr table = std::dynamic_pointer_cast(_table); -#if 0 - // AP - the book pages are made with 0 depth so the front and back polys are - // at the same location. This can cause z-fighting if culling is disabled - // which can sometimes happen depending on what object was last seen so make - // sure culling is always enabled. Should this be a problem for other - // platforms? - glEnable(GL_CULL_FACE); -#endif glPushMatrix(); glTranslatef((float)x + 0.5f, (float)y + 12 / 16.0f, (float)z + 0.5f); diff --git a/Minecraft.Client/Rendering/EntityRenderers/EnderDragonRenderer.cpp b/Minecraft.Client/Rendering/EntityRenderers/EnderDragonRenderer.cpp index 746790862..e96104861 100644 --- a/Minecraft.Client/Rendering/EntityRenderers/EnderDragonRenderer.cpp +++ b/Minecraft.Client/Rendering/EntityRenderers/EnderDragonRenderer.cpp @@ -86,16 +86,8 @@ void EnderDragonRenderer::renderModel(std::shared_ptr _mob, glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glColor4f(1, 0, 0, 0.5f); -#if 0 - // AP - not sure that the usecompiled flag is supposed to be false. This - // makes it really slow on vita. Making it true still seems to look the - // same - model->render(mob, wp, ws, bob, headRotMinusBodyRot, headRotx, scale, - true); -#else model->render(mob, wp, ws, bob, headRotMinusBodyRot, headRotx, scale, false); -#endif glEnable(GL_TEXTURE_2D); glDisable(GL_BLEND); glDepthFunc(GL_LEQUAL); @@ -268,9 +260,6 @@ int EnderDragonRenderer::prepareArmor(std::shared_ptr _mob, // back on the renderer) However we do want it off for other platforms that // don't force it on in the render lib CBuff handling Several texture packs // have fully transparent bits that break if this is off -#if 0 - glDisable(GL_ALPHA_TEST); -#endif glBlendFunc(GL_ONE, GL_ONE); glDisable(GL_LIGHTING); glDepthFunc(GL_EQUAL); diff --git a/Minecraft.Client/Rendering/EntityRenderers/EnderDragonRenderer.h b/Minecraft.Client/Rendering/EntityRenderers/EnderDragonRenderer.h index b2e597cc1..fb0bdc083 100644 --- a/Minecraft.Client/Rendering/EntityRenderers/EnderDragonRenderer.h +++ b/Minecraft.Client/Rendering/EntityRenderers/EnderDragonRenderer.h @@ -1,9 +1,6 @@ #pragma once #include "MobRenderer.h" -#if 0 -class EnderDragon; -#endif class DragonModel; class EnderDragonRenderer : public MobRenderer { diff --git a/Minecraft.Client/Rendering/EntityRenderers/EnderManRenderer.cpp b/Minecraft.Client/Rendering/EntityRenderers/EnderManRenderer.cpp index ca84cd398..4798c2754 100644 --- a/Minecraft.Client/Rendering/EntityRenderers/EnderManRenderer.cpp +++ b/Minecraft.Client/Rendering/EntityRenderers/EnderManRenderer.cpp @@ -93,9 +93,6 @@ int EndermanRenderer::prepareArmor(std::shared_ptr _mob, // back on the renderer) However we do want it off for other platforms that // don't force it on in the render lib CBuff handling Several texture packs // have fully transparent bits that break if this is off -#if 0 - glDisable(GL_ALPHA_TEST); -#endif glBlendFunc(GL_ONE, GL_ONE); glDisable(GL_LIGHTING); diff --git a/Minecraft.Client/Rendering/EntityRenderers/ItemInHandRenderer.cpp b/Minecraft.Client/Rendering/EntityRenderers/ItemInHandRenderer.cpp index a740abd8b..b17bffd3e 100644 --- a/Minecraft.Client/Rendering/EntityRenderers/ItemInHandRenderer.cpp +++ b/Minecraft.Client/Rendering/EntityRenderers/ItemInHandRenderer.cpp @@ -441,7 +441,7 @@ void ItemInHandRenderer::render(float a) { Mth::floor(player->z), 0); int u = col % 65536; int v = col / 65536; -#ifdef __linux__ +#if defined(__linux__) static int lightmapLogCount = 0; if (lightmapLogCount < 8) { ++lightmapLogCount; @@ -588,13 +588,9 @@ void ItemInHandRenderer::render(float a) { glPushMatrix(); float d = 0.8f; -#if 0 || 0 - static const float swingPowFactor = 1.0f; -#else static const float swingPowFactor = 4.0f; // 4J added, to slow the swing down when nearest the player // for avoiding luminance flash issues -#endif if (player->getUseItemDuration() > 0) { UseAnim anim = item->getUseAnimation(); if ((anim == UseAnim_eat) || (anim == UseAnim_drink)) { diff --git a/Minecraft.Client/Rendering/EntityRenderers/ItemRenderer.cpp b/Minecraft.Client/Rendering/EntityRenderers/ItemRenderer.cpp index fb0366bf5..ec95f67fa 100644 --- a/Minecraft.Client/Rendering/EntityRenderers/ItemRenderer.cpp +++ b/Minecraft.Client/Rendering/EntityRenderers/ItemRenderer.cpp @@ -12,9 +12,6 @@ #include "../../GameState/Options.h" #include "../../Textures/TextureAtlas.h" -#if 0 -extern IDirect3DDevice9* g_pD3DDevice; -#endif ItemRenderer::ItemRenderer() : EntityRenderer() { random = new Random(); @@ -41,12 +38,6 @@ ResourceLocation* ItemRenderer::getTextureLocation(int iconType) { if (iconType == Icon::TYPE_TERRAIN) { return &TextureAtlas::LOCATION_BLOCKS; // L"/terrain.png")); } else { -#if 0 - // 4J - make sure we've got linear sampling on minification here as - // non-mipmapped things like this currently default to having point - // sampling, which makes very small icons render rather badly - g_pD3DDevice->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR); -#endif return &TextureAtlas::LOCATION_ITEMS; // L"/gui/items.png")); } } @@ -360,7 +351,6 @@ void ItemRenderer::renderGuiItem(Font* font, Textures* textures, glPushMatrix(); // 4J - original code left here for reference // 4jcraft: original code reused for proper lighting -#if 1 glTranslatef((float)(x), (float)(y), 0.0f); glScalef(fScaleX, fScaleY, 1.0f); glTranslatef(-2.0f,3.0f, -3.0f + blitOffset); @@ -369,22 +359,6 @@ void ItemRenderer::renderGuiItem(Font* font, Textures* textures, glScalef(1.0f, 1.0f, -1.0f); glRotatef(180.0f + 30.0f, 1.0f, 0.0f, 0.0f); glRotatef(45.0f, 0.0f, 1.0f, 0.0f); -#else - glTranslatef(x, y, 0.0f); // Translate to screen coords - glScalef(16.0f * fScaleX, 16.0f * fScaleY, - 1.0f); // Scale to 0 to 16*scale range - glTranslatef(0.5f, 0.5f, 0.0f); // Translate to 0 to 1 range - glScalef( - 0.55f, 0.55f, - -1.0f); // Scale to occupy full -0.5 to 0.5 bounding region (just - // touching top & bottom) 0.55 comes from - // 1/(1+sqrt(2)/sqrt(3)) which is determined by the angles - // that the cube is rotated in an orthographic projection - glRotatef(180.0f + 30.0f, 1.0f, 0.0f, - 0.0f); // Rotate round x axis (centre at origin) - glRotatef(45.0f, 0.0f, 1.0f, - 0.0f); // Rotate round y axis (centre at origin) -#endif // 4J-PB - pass the alpha value in - the grass block // render has the top surface coloured differently to // the rest of the block @@ -430,16 +404,6 @@ void ItemRenderer::renderGuiItem(Font* font, Textures* textures, } else { textures->bindTexture( &TextureAtlas::LOCATION_ITEMS); // L"/gui/items.png")); -#if 0 - // 4J - make sure we've got - // linear sampling on - // minification here as - // non-mipmapped things like - // this currently - // default to having point sampling, which makes very small icons - // render rather badly - g_pD3DDevice->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR); -#endif } MemSect(0); diff --git a/Minecraft.Client/Rendering/EntityRenderers/LivingEntityRenderer.cpp b/Minecraft.Client/Rendering/EntityRenderers/LivingEntityRenderer.cpp index f5f4cbf3c..81f24cc87 100644 --- a/Minecraft.Client/Rendering/EntityRenderers/LivingEntityRenderer.cpp +++ b/Minecraft.Client/Rendering/EntityRenderers/LivingEntityRenderer.cpp @@ -511,32 +511,7 @@ void LivingEntityRenderer::renderNameTag(std::shared_ptr mob, if (app.isXuidDeadmau5(player->getXuid())) offs = -10; -#if 0 || 0 - // Check we have all the font characters for this player name - switch (player->GetPlayerNameValidState()) { - case Player::ePlayerNameValid_NotSet: - if (font->AllCharactersValid(name)) { - playerName = name; - player->SetPlayerNameValidState(true); - } else { - memset(wchName, 0, sizeof(WCHAR) * 2); - swprintf(wchName, 2, L"%d", player->getPlayerIndex() + 1); - playerName = wchName; - player->SetPlayerNameValidState(false); - } - break; - case Player::ePlayerNameValid_True: - playerName = name; - break; - case Player::ePlayerNameValid_False: - memset(wchName, 0, sizeof(WCHAR) * 2); - swprintf(wchName, 2, L"%d", player->getPlayerIndex() + 1); - playerName = wchName; - break; - } -#else playerName = name; -#endif } else { playerName = name; } diff --git a/Minecraft.Client/Rendering/EntityRenderers/PlayerRenderer.cpp b/Minecraft.Client/Rendering/EntityRenderers/PlayerRenderer.cpp index 358e2b7d9..804672296 100644 --- a/Minecraft.Client/Rendering/EntityRenderers/PlayerRenderer.cpp +++ b/Minecraft.Client/Rendering/EntityRenderers/PlayerRenderer.cpp @@ -21,12 +21,10 @@ const unsigned int PlayerRenderer::s_nametagColors[MINECRAFT_NET_MAX_PLAYERS] = 0xff33cc33, // GREEN 0xffcc3333, // RED 0xff3333cc, // BLUE -#if 1 // only 4 player on Vita 0xffcc33cc, // PINK 0xffcc6633, // ORANGE 0xffcccc33, // YELLOW 0xff33dccc, // TURQUOISE -#endif }; ResourceLocation PlayerRenderer::DEFAULT_LOCATION = @@ -440,29 +438,6 @@ void PlayerRenderer::renderNameTags(std::shared_ptr player, double x, double y, double z, std::wstring msg, float scale, double dist) { -#if 0 - if (dist < 10 * 10) - { - Scoreboard *scoreboard = player->getScoreboard(); - Objective *objective = scoreboard->getDisplayObjective(Scoreboard::DISPLAY_SLOT_BELOW_NAME); - - if (objective != NULL) - { - Score *score = scoreboard->getPlayerScore(player->getAName(), objective); - - if (player->isSleeping()) - { - renderNameTag(player, score->getScore() + " " + objective->getDisplayName(), x, y - 1.5f, z, 64); - } - else - { - renderNameTag(player, score->getScore() + " " + objective->getDisplayName(), x, y, z, 64); - } - - y += getFont()->lineHeight * 1.15f * scale; - } - } -#endif LivingEntityRenderer::renderNameTags(player, x, y, z, msg, scale, dist); } diff --git a/Minecraft.Client/Rendering/EntityRenderers/ProgressRenderer.cpp b/Minecraft.Client/Rendering/EntityRenderers/ProgressRenderer.cpp index 2552a16f1..e90405934 100644 --- a/Minecraft.Client/Rendering/EntityRenderers/ProgressRenderer.cpp +++ b/Minecraft.Client/Rendering/EntityRenderers/ProgressRenderer.cpp @@ -38,17 +38,6 @@ void ProgressRenderer::_progressStart(int title) { this->title = title; LeaveCriticalSection(&ProgressRenderer::s_progress); -#if 0 - ScreenSizeCalculator ssc(minecraft->options, minecraft->width, minecraft->height); - - glClear(GL_DEPTH_BUFFER_BIT); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - glOrtho(0, (float)ssc.rawWidth, (float)ssc.rawHeight, 0, 100, 300); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - glTranslatef(0, 0, -200); -#endif } void ProgressRenderer::progressStage(int status) { @@ -73,79 +62,6 @@ void ProgressRenderer::progressStagePercentage(int i) { lastPercent = i; LeaveCriticalSection(&ProgressRenderer::s_progress); -#if 0 - if (!minecraft->running) - { - if (noAbort) return; -// throw new StopGameException(); // 4J - removed - } - - - int64_t now = System::currentTimeMillis(); - if (now - lastTime < 20) return; - lastTime = now; - - ScreenSizeCalculator ssc(minecraft->options, minecraft->width, minecraft->height); - int screenWidth = ssc.getWidth(); - int screenHeight = ssc.getHeight(); - - glClear(GL_DEPTH_BUFFER_BIT); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - glOrtho(0, (float)ssc.rawWidth, (float)ssc.rawHeight, 0, 100, 300); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - glTranslatef(0, 0, -200); - - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - - Tesselator *t = Tesselator::getInstance(); - int id = minecraft->textures->loadTexture(L"/gui/background.png"); - glBindTexture(GL_TEXTURE_2D, id); - float s = 32; - t->begin(); - t->color(0x404040); - t->vertexUV((float)(0), (float)( screenHeight), (float)( 0), (float)( 0), (float)( screenHeight / s)); - t->vertexUV((float)(screenWidth), (float)( screenHeight), (float)( 0), (float)( screenWidth / s), (float)( screenHeight / s)); - t->vertexUV((float)(screenWidth), (float)( 0), (float)( 0), (float)( screenWidth / s), (float)( 0)); - t->vertexUV((float)(0), (float)( 0), (float)( 0), (float)( 0), (float)( 0)); - t->end(); - - if (i >= 0) - { - int w = 100; - int h = 2; - int x = screenWidth / 2 - w / 2; - int y = screenHeight / 2 + 16; - - glDisable(GL_TEXTURE_2D); - t->begin(); - t->color(0x808080); - t->vertex((float)(x), (float)( y), (float)( 0)); - t->vertex((float)(x), (float)( y + h), (float)( 0)); - t->vertex((float)(x + w), (float)( y + h), (float)( 0)); - t->vertex((float)(x + w), (float)( y), (float)( 0)); - - t->color(0x80ff80); - t->vertex((float)(x), (float)( y), (float)( 0)); - t->vertex((float)(x), (float)( y + h), (float)( 0)); - t->vertex((float)(x + i), (float)( y + h), (float)( 0)); - t->vertex((float)(x + i), (float)( y), (float)( 0)); - t->end(); - glEnable(GL_TEXTURE_2D); - } - - minecraft->font->drawShadow(title, (screenWidth - minecraft->font->width(title)) / 2, screenHeight / 2 - 4 - 16, 0xffffff); - minecraft->font->drawShadow(status, (screenWidth - minecraft->font->width(status)) / 2, screenHeight / 2 - 4 + 8, 0xffffff); - Display::update(); - - /* // 4J - removed - try { - Thread.yield(); - } catch (Exception e) { - } - */ -#endif } int ProgressRenderer::getCurrentPercent() { diff --git a/Minecraft.Client/Rendering/EntityRenderers/SpiderRenderer.cpp b/Minecraft.Client/Rendering/EntityRenderers/SpiderRenderer.cpp index a61231bdb..bc03ecb3b 100644 --- a/Minecraft.Client/Rendering/EntityRenderers/SpiderRenderer.cpp +++ b/Minecraft.Client/Rendering/EntityRenderers/SpiderRenderer.cpp @@ -33,9 +33,6 @@ int SpiderRenderer::prepareArmor(std::shared_ptr _spider, // back on the renderer) However we do want it off for other platforms that // don't force it on in the render lib CBuff handling Several texture packs // have fully transparent bits that break if this is off -#if 0 - glDisable(GL_ALPHA_TEST); -#endif // 4J - changes brought forward from 1.8.2 glBlendFunc(GL_ONE, GL_ONE); if (spider->isInvisible()) diff --git a/Minecraft.Client/Rendering/EntityRenderers/TileRenderer.cpp b/Minecraft.Client/Rendering/EntityRenderers/TileRenderer.cpp index a50aa3513..f7a2f2e2e 100644 --- a/Minecraft.Client/Rendering/EntityRenderers/TileRenderer.cpp +++ b/Minecraft.Client/Rendering/EntityRenderers/TileRenderer.cpp @@ -182,14 +182,6 @@ void TileRenderer::setFixedTexture(Icon* fixedTexture) { void TileRenderer::clearFixedTexture() { this->fixedTexture = NULL; } bool TileRenderer::hasFixedTexture() { -#if 0 - // AP - alpha cut out is expensive on vita. Pass on the Alpha Cut out flag - // to the tesselator - if (fixedTexture) { - Tesselator* t = Tesselator::getInstance(); - t->setAlphaCutOut(fixedTexture->getFlags() & Icon::IS_ALPHA_CUT_OUT); - } -#endif return fixedTexture != NULL; } @@ -7120,18 +7112,6 @@ void TileRenderer::renderFaceDown(Tile* tt, double x, double y, double z, double z1 = z + tileShapeZ1; if (applyAmbienceOcclusion) { -#if 0 - if (t->getCompactVertices()) { - t->tileQuad((float)(x0), (float)(y0), (float)(z1), (float)(u10), - (float)(v10), c1r, c1g, c1b, tc1, (float)(x0), - (float)(y0), (float)(z0), (float)(u00), (float)(v00), - c2r, c2g, c2b, tc2, (float)(x1), (float)(y0), - (float)(z0), (float)(u01), (float)(v01), c3r, c3g, c3b, - tc3, (float)(x1), (float)(y0), (float)(z1), - (float)(u11), (float)(v11), c4r, c4g, c4b, tc4); - return; - } -#endif t->color(c1r, c1g, c1b); if (SharedConstants::TEXTURE_LIGHTING) t->tex2(tc1); @@ -7239,18 +7219,6 @@ void TileRenderer::renderFaceUp(Tile* tt, double x, double y, double z, double z1 = z + tileShapeZ1; if (applyAmbienceOcclusion) { -#if 0 - if (t->getCompactVertices()) { - t->tileQuad((float)(x1), (float)(y1), (float)(z1), (float)(u11), - (float)(v11), c1r, c1g, c1b, tc1, (float)(x1), - (float)(y1), (float)(z0), (float)(u01), (float)(v01), - c2r, c2g, c2b, tc2, (float)(x0), (float)(y1), - (float)(z0), (float)(u00), (float)(v00), c3r, c3g, c3b, - tc3, (float)(x0), (float)(y1), (float)(z1), - (float)(u10), (float)(v10), c4r, c4g, c4b, tc4); - return; - } -#endif t->color(c1r, c1g, c1b); if (SharedConstants::TEXTURE_LIGHTING) t->tex2(tc1); @@ -7363,18 +7331,6 @@ void TileRenderer::renderNorth(Tile* tt, double x, double y, double z, double z0 = z + tileShapeZ0; if (applyAmbienceOcclusion) { -#if 0 - if (t->getCompactVertices()) { - t->tileQuad((float)(x0), (float)(y1), (float)(z0), (float)(u01), - (float)(v01), c1r, c1g, c1b, tc1, (float)(x1), - (float)(y1), (float)(z0), (float)(u00), (float)(v00), - c2r, c2g, c2b, tc2, (float)(x1), (float)(y0), - (float)(z0), (float)(u10), (float)(v10), c3r, c3g, c3b, - tc3, (float)(x0), (float)(y0), (float)(z0), - (float)(u11), (float)(v11), c4r, c4g, c4b, tc4); - return; - } -#endif t->color(c1r, c1g, c1b); if (SharedConstants::TEXTURE_LIGHTING) t->tex2(tc1); @@ -7487,18 +7443,6 @@ void TileRenderer::renderSouth(Tile* tt, double x, double y, double z, double z1 = z + tileShapeZ1; if (applyAmbienceOcclusion) { -#if 0 - if (t->getCompactVertices()) { - t->tileQuad((float)(x0), (float)(y1), (float)(z1), (float)(u00), - (float)(v00), c1r, c1g, c1b, tc1, (float)(x0), - (float)(y0), (float)(z1), (float)(u10), (float)(v10), - c2r, c2g, c2b, tc2, (float)(x1), (float)(y0), - (float)(z1), (float)(u11), (float)(v11), c3r, c3g, c3b, - tc3, (float)(x1), (float)(y1), (float)(z1), - (float)(u01), (float)(v01), c4r, c4g, c4b, tc4); - return; - } -#endif t->color(c1r, c1g, c1b); if (SharedConstants::TEXTURE_LIGHTING) t->tex2(tc1); @@ -7611,18 +7555,6 @@ void TileRenderer::renderWest(Tile* tt, double x, double y, double z, double z1 = z + tileShapeZ1; if (applyAmbienceOcclusion) { -#if 0 - if (t->getCompactVertices()) { - t->tileQuad((float)(x0), (float)(y1), (float)(z1), (float)(u01), - (float)(v01), c1r, c1g, c1b, tc1, (float)(x0), - (float)(y1), (float)(z0), (float)(u00), (float)(v00), - c2r, c2g, c2b, tc2, (float)(x0), (float)(y0), - (float)(z0), (float)(u10), (float)(v10), c3r, c3g, c3b, - tc3, (float)(x0), (float)(y0), (float)(z1), - (float)(u11), (float)(v11), c4r, c4g, c4b, tc4); - return; - } -#endif t->color(c1r, c1g, c1b); if (SharedConstants::TEXTURE_LIGHTING) t->tex2(tc1); @@ -7735,18 +7667,6 @@ void TileRenderer::renderEast(Tile* tt, double x, double y, double z, double z1 = z + tileShapeZ1; if (applyAmbienceOcclusion) { -#if 0 - if (t->getCompactVertices()) { - t->tileQuad((float)(x1), (float)(y0), (float)(z1), (float)(u10), - (float)(v10), c1r, c1g, c1b, tc1, (float)(x1), - (float)(y0), (float)(z0), (float)(u11), (float)(v11), - c2r, c2g, c2b, tc2, (float)(x1), (float)(y1), - (float)(z0), (float)(u01), (float)(v01), c3r, c3g, c3b, - tc3, (float)(x1), (float)(y1), (float)(z1), - (float)(u00), (float)(v00), c4r, c4g, c4b, tc4); - return; - } -#endif t->color(c1r, c1g, c1b); if (SharedConstants::TEXTURE_LIGHTING) t->tex2(tc1); @@ -8390,12 +8310,6 @@ Icon* TileRenderer::getTextureOrMissing(Icon* icon) { if (icon == NULL) return minecraft->textures->getMissingIcon(Icon::TYPE_TERRAIN); -#if 0 - // AP - alpha cut out is expensive on vita. Pass on the Alpha Cut out flag - // to the tesselator - Tesselator* t = Tesselator::getInstance(); - t->setAlphaCutOut(icon->getFlags() & Icon::IS_ALPHA_CUT_OUT); -#endif return icon; } diff --git a/Minecraft.Client/Rendering/GameRenderer.cpp b/Minecraft.Client/Rendering/GameRenderer.cpp index 7db01fb45..5eef3ccc8 100644 --- a/Minecraft.Client/Rendering/GameRenderer.cpp +++ b/Minecraft.Client/Rendering/GameRenderer.cpp @@ -54,7 +54,7 @@ bool GameRenderer::anaglyph3d = false; int GameRenderer::anaglyphPass = 0; -#ifdef MULTITHREAD_ENABLE +#if defined(MULTITHREAD_ENABLE) C4JThread* GameRenderer::m_updateThread; C4JThread::EventArray* GameRenderer::m_updateEvents; bool GameRenderer::nearThingsToDo = false; @@ -158,27 +158,16 @@ GameRenderer::GameRenderer(Minecraft* mc) { // per level to support split screen } delete img; -#if 0 - // we're using the RSX now to upload textures to vram, so we need the main - // ram textures allocated from io space - for (int i = 0; i < NUM_LIGHT_TEXTURES; i++) - lightPixels[i] = intArray( - (int*)RenderManager.allocIOMem(16 * 16 * sizeof(int)), 16 * 16); -#else for (int i = 0; i < NUM_LIGHT_TEXTURES; i++) lightPixels[i] = intArray(16 * 16); -#endif -#ifdef MULTITHREAD_ENABLE +#if defined(MULTITHREAD_ENABLE) m_updateEvents = new C4JThread::EventArray( eUpdateEventCount, C4JThread::EventArray::e_modeAutoClear); m_updateEvents->Set(eUpdateEventIsFinished); InitializeCriticalSection(&m_csDeleteStack); m_updateThread = new C4JThread(runUpdate, NULL, "Chunk update"); -#if 0 - m_updateThread->SetPriority(THREAD_PRIORITY_ABOVE_NORMAL); -#endif // 0 m_updateThread->SetProcessor(CPU_CORE_CHUNK_UPDATE); m_updateThread->Run(); #endif @@ -765,7 +754,7 @@ void GameRenderer::renderItemInHand(float a, int eye) { // 4J - change brought forward from 1.8.2 void GameRenderer::turnOffLightLayer(double alpha) { // 4J - TODO -#ifdef __linux__ +#if defined(__linux__) if (SharedConstants::TEXTURE_LIGHTING) { LinuxLogStubLightmapProbe(); RenderManager.TextureBindVertex(-1); @@ -774,7 +763,6 @@ void GameRenderer::turnOffLightLayer(double alpha) { // 4J - TODO #else // 4jcraft: manually handle this in order to ensure that the light layer is // turned off correctly -#if 1 if (SharedConstants::TEXTURE_LIGHTING) { glClientActiveTexture(GL_TEXTURE1); glActiveTexture(GL_TEXTURE1); @@ -786,9 +774,6 @@ void GameRenderer::turnOffLightLayer(double alpha) { // 4J - TODO glClientActiveTexture(GL_TEXTURE0); glActiveTexture(GL_TEXTURE0); } -#else - RenderManager.TextureBindVertex(-1); -#endif #endif } @@ -796,7 +781,7 @@ void GameRenderer::turnOffLightLayer(double alpha) { // 4J - TODO void GameRenderer::turnOnLightLayer( double alpha, bool scaleLight) { // 4jcraft: added scaleLight for entity lighting -#ifdef __linux__ +#if defined(__linux__) if (!SharedConstants::TEXTURE_LIGHTING) return; LinuxLogStubLightmapProbe(); @@ -812,43 +797,10 @@ void GameRenderer::turnOnLightLayer( RenderManager.TextureBindVertex(textureId, scaleLight); LinuxGLLogLightmapState("turnOnLightLayer", textureId, scaleLight); #else -#if 0 - if (SharedConstants::TEXTURE_LIGHTING) - { - glClientActiveTexture(GL_TEXTURE1); - glActiveTexture(GL_TEXTURE1); - glMatrixMode(GL_TEXTURE); - glLoadIdentity(); - // float s = 1 / 16f / 15.0f*16/14.0f; - float s = 1 / 16.0f / 15.0f * 15 / 16; - glScalef(s, s, s); - glTranslatef(8f, 8f, 8f); - glMatrixMode(GL_MODELVIEW); - - mc->textures->bind(lightTexture); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); - glColor4f(1, 1, 1, 1); - glEnable(GL_TEXTURE_2D); - glClientActiveTexture(GL_TEXTURE0); - glActiveTexture(GL_TEXTURE0); - } -#endif // 4jcraft: update light texture // todo: check implementation of getLightTexture. RenderManager.TextureBindVertex( getLightTexture(mc->player->GetXboxPad(), mc->level), scaleLight); -#if 0 - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); -#endif #endif } @@ -967,10 +919,8 @@ void GameRenderer::updateLightTexture(float a) { int g = (int)(_g * 255); int b = (int)(_b * 255); -#if (0 || defined _WIN64 || 0 || __linux__) +#if defined(_WIN64) || __linux__ lightPixels[j][i] = alpha << 24 | b << 16 | g << 8 | r; -#elif (0 || 0) - lightPixels[j][i] = alpha << 24 | r << 16 | g << 8 | b; #else lightPixels[j][i] = r << 24 | g << 16 | b << 8 | alpha; #endif @@ -1017,28 +967,6 @@ void GameRenderer::render(float a, bool bFirst) { } } -#if 0 // 4J - TODO - if (mc->mouseGrabbed && focused) { - mc->mouseHandler.poll(); - - float ss = mc->options->sensitivity * 0.6f + 0.2f; - float sens = (ss * ss * ss) * 8; - float xo = mc->mouseHandler.xd * sens; - float yo = mc->mouseHandler.yd * sens; - - int yAxis = 1; - if (mc->options->invertYMouse) yAxis = -1; - - if (mc->options->smoothCamera) { - - xo = smoothTurnX.getNewDeltaValue(xo, .05f * sens); - yo = smoothTurnY.getNewDeltaValue(yo, .05f * sens); - - } - - mc->player.turn(xo, yo * yAxis); - } -#endif if (mc->noRender) return; GameRenderer::anaglyph3d = mc->options->anaglyph3d; @@ -1085,7 +1013,7 @@ void GameRenderer::render(float a, bool bFirst) { void GameRenderer::renderLevel(float a) { renderLevel(a, 0); } -#ifdef MULTITHREAD_ENABLE +#if defined(MULTITHREAD_ENABLE) // Request that an item be deleted, when it is safe to do so void GameRenderer::AddForDelete(uint8_t* deleteThis) { EnterCriticalSection(&m_csDeleteStack); @@ -1118,7 +1046,7 @@ int GameRenderer::runUpdate(void* lpParam) { Tesselator::CreateNewThreadStorage(1024 * 1024); Compression::UseDefaultThreadStorage(); RenderManager.InitialiseContext(); -#ifdef _LARGE_WORLDS +#if defined(_LARGE_WORLDS) Chunk::CreateNewThreadStorage(); #endif Tile::CreateNewThreadStorage(); @@ -1207,7 +1135,7 @@ void GameRenderer::EnableUpdateThread() { // #if 0 // MGH - disable the update on PS3 for now // return; // #endif -#ifdef MULTITHREAD_ENABLE +#if defined(MULTITHREAD_ENABLE) if (updateRunning) return; app.DebugPrintf( "------------------EnableUpdateThread--------------------\n"); @@ -1221,7 +1149,7 @@ void GameRenderer::DisableUpdateThread() { // #if 0 // MGH - disable the update on PS3 for now // return; // #endif -#ifdef MULTITHREAD_ENABLE +#if defined(MULTITHREAD_ENABLE) if (!updateRunning) return; app.DebugPrintf( "------------------DisableUpdateThread--------------------\n"); @@ -1311,7 +1239,7 @@ void GameRenderer::renderLevel(float a, int64_t until) { mc->levelRenderer->cull(frustum, a); PIXEndNamedEvent(); -#ifndef MULTITHREAD_ENABLE +#if !defined(MULTITHREAD_ENABLE) if ((i == 0) && updateChunks) // 4J - added updateChunks condition { int PIXPass = 0; @@ -1374,10 +1302,6 @@ void GameRenderer::renderLevel(float a, int64_t until) { cameraPos->y = cameraPosTemp->y; cameraPos->z = cameraPosTemp->z; levelRenderer->renderEntities(cameraPos, frustum, a); -#if 0 - // AP - make sure we're using the Alpha cut out effect for particles - glEnable(GL_ALPHA_TEST); -#endif PIXEndNamedEvent(); PIXBeginNamedEvent(0, "Particle render"); turnOnLightLayer(a); // 4J - brought forward from 1.8.2 @@ -1740,20 +1664,6 @@ void GameRenderer::renderSnowAndRain(float a) { float br = 1; t->offset(-xo * 1, -yo * 1, -zo * 1); -#if 0 - // AP - this will set up the 4 vertices in half the time - float Alpha = ((1 - dd * dd) * 0.5f + 0.5f) * rainLevel; - int tex2 = - (level->getLightColor(x, yl, z, 0) * 3 + 0xf000f0) / 4; - t->tileRainQuad( - x - xa + 0.5, yy0, z - za + 0.5, 0 * s, - yy0 * s / 4.0f + ra * s, x + xa + 0.5, yy0, - z + za + 0.5, 1 * s, yy0 * s / 4.0f + ra * s, - x + xa + 0.5, yy1, z + za + 0.5, 1 * s, - yy1 * s / 4.0f + ra * s, x - xa + 0.5, yy1, - z - za + 0.5, 0 * s, yy1 * s / 4.0f + ra * s, br, br, - br, Alpha, br, br, br, 0, tex2); -#else t->tex2(level->getLightColor(x, yl, z, 0)); t->color(br, br, br, ((1 - dd * dd) * 0.5f + 0.5f) * rainLevel); @@ -1768,7 +1678,6 @@ void GameRenderer::renderSnowAndRain(float a) { yy1 * s / 4.0f + ra * s); t->vertexUV(x - xa + 0.5, yy1, z - za + 0.5, 0 * s, yy1 * s / 4.0f + ra * s); -#endif t->offset(0, 0, 0); t->end(); } else { @@ -1788,20 +1697,6 @@ void GameRenderer::renderSnowAndRain(float a) { float dd = (float)sqrt(xd * xd + zd * zd) / r; float br = 1; t->offset(-xo * 1, -yo * 1, -zo * 1); -#if 0 - // AP - this will set up the 4 vertices in half the time - float Alpha = ((1 - dd * dd) * 0.3f + 0.5f) * rainLevel; - int tex2 = - (level->getLightColor(x, yl, z, 0) * 3 + 0xf000f0) / 4; - t->tileRainQuad( - x - xa + 0.5, yy0, z - za + 0.5, 0 * s + uo, - yy0 * s / 4.0f + ra * s + vo, x + xa + 0.5, yy0, - z + za + 0.5, 1 * s + uo, yy0 * s / 4.0f + ra * s + vo, - x + xa + 0.5, yy1, z + za + 0.5, 1 * s + uo, - yy1 * s / 4.0f + ra * s + vo, x - xa + 0.5, yy1, - z - za + 0.5, 0 * s + uo, yy1 * s / 4.0f + ra * s + vo, - br, br, br, Alpha, br, br, br, Alpha, tex2); -#else t->tex2((level->getLightColor(x, yl, z, 0) * 3 + 0xf000f0) / 4); t->color(br, br, br, @@ -1814,7 +1709,6 @@ void GameRenderer::renderSnowAndRain(float a) { yy1 * s / 4.0f + ra * s + vo); t->vertexUV(x - xa + 0.5, yy1, z - za + 0.5, 0 * s + uo, yy1 * s / 4.0f + ra * s + vo); -#endif t->offset(0, 0, 0); } } diff --git a/Minecraft.Client/Rendering/LevelRenderer.cpp b/Minecraft.Client/Rendering/LevelRenderer.cpp index fea5954c0..937c33c33 100644 --- a/Minecraft.Client/Rendering/LevelRenderer.cpp +++ b/Minecraft.Client/Rendering/LevelRenderer.cpp @@ -63,12 +63,6 @@ // #define DISABLE_SPU_CODE -#if 0 -static LevelRenderer_cull_DataIn g_cullDataIn[4] - __attribute__((__aligned__(16))); -static LevelRenderer_FindNearestChunk_DataIn g_findNearestChunkDataIn - __attribute__((__aligned__(16))); -#endif ResourceLocation LevelRenderer::MOON_LOCATION = ResourceLocation(TN_TERRAIN_MOON); @@ -82,7 +76,7 @@ ResourceLocation LevelRenderer::END_SKY_LOCATION = const unsigned int HALO_RING_RADIUS = 100; -#ifdef _LARGE_WORLDS +#if defined(_LARGE_WORLDS) Chunk LevelRenderer::permaChunk[MAX_CONCURRENT_CHUNK_REBUILDS]; C4JThread* LevelRenderer::rebuildThreads[MAX_CHUNK_REBUILD_THREADS]; C4JThread::EventArray* LevelRenderer::s_rebuildCompleteEvents; @@ -163,7 +157,7 @@ LevelRenderer::LevelRenderer(Minecraft* mc, Textures* textures) { InitializeCriticalSection(&m_csDirtyChunks); InitializeCriticalSection(&m_csRenderableTileEntities); -#ifdef _LARGE_WORLDS +#if defined(_LARGE_WORLDS) InitializeCriticalSection(&m_csChunkFlags); #endif @@ -274,12 +268,6 @@ LevelRenderer::LevelRenderer(Minecraft* mc, Textures* textures) { destroyedTileManager = new DestroyedTileManager(); dirtyChunksLockFreeStack.Initialize(); -#if 0 - m_jobPort_CullSPU = - new C4JSpursJobQueue::Port("C4JSpursJob_LevelRenderer_cull"); - m_jobPort_FindNearestChunk = new C4JSpursJobQueue::Port( - "C4JSpursJob_LevelRenderer_FindNearestChunk"); -#endif // 0 } void LevelRenderer::renderStars() { @@ -439,9 +427,6 @@ void LevelRenderer::allChanged(int playerIndex) { int dist = (int)sqrtf((float)PLAYER_RENDER_AREA / (float)activePlayers()); // AP - poor little Vita just can't cope with such a big area -#if 0 - dist = 10; -#endif lastPlayerCount[playerIndex] = activePlayers(); @@ -775,25 +760,10 @@ int LevelRenderer::render(std::shared_ptr player, int layer, return count; } -#if 0 -#include - -// this is need to sort the chunks by depth -typedef struct { - int Index; - float Depth; -} SChunckSort; - -int compare(const void* a, const void* b) { - return (((SChunckSort*)a)->Depth - ((SChunckSort*)b)->Depth); -} - -#endif int LevelRenderer::renderChunks(int from, int to, int layer, double alpha) { int playerIndex = mc->player->GetXboxPad(); // 4J added -#if 1 // 4J - cut down version, we're not using offsetted render lists, or a // sorted chunk list, anymore mc->gameRenderer->turnOnLightLayer( @@ -806,34 +776,8 @@ int LevelRenderer::renderChunks(int from, int to, int layer, double alpha) { glPushMatrix(); glTranslatef((float)-xOff, (float)-yOff, (float)-zOff); -#if 0 - // AP - also set the camera position so we can work out if a chunk is fogged - // or not - RenderManager.SetCameraPosition((float)-xOff, (float)-yOff, (float)-zOff); -#endif -#if 0 && !defined DISABLE_SPU_CODE - // pre- calc'd on the SPU - int count = 0; - waitForCull_SPU(); - if (layer == 0) { - count = g_cullDataIn[playerIndex].numToRender_layer0; - RenderManager.CBuffCallMultiple( - g_cullDataIn[playerIndex].listArray_layer0, count); - } else // layer == 1 - { - count = g_cullDataIn[playerIndex].numToRender_layer1; - RenderManager.CBuffCallMultiple( - g_cullDataIn[playerIndex].listArray_layer1, count); - } -#else // 0 - -#if 0 - // AP - alpha cut out is expensive on vita. First render all the non-alpha - // cut outs - glDisable(GL_ALPHA_TEST); -#endif bool first = true; int count = 0; @@ -859,105 +803,12 @@ int LevelRenderer::renderChunks(int from, int to, int layer, double alpha) { count++; } -#if 0 - // AP - alpha cut out is expensive on vita. Now we render all the alpha cut - // outs - glEnable(GL_ALPHA_TEST); - RenderManager.StateSetForceLOD( - 0); // AP - force mipmapping off for cut outs - first = true; - pClipChunk = chunks[playerIndex].data; - emptyFlag = LevelRenderer::CHUNK_FLAG_EMPTY0 << layer; - for (int i = 0; i < chunks[playerIndex].length; i++, pClipChunk++) { - if (!pClipChunk->visible) - continue; // This will be set if the chunk isn't visible, or isn't - // compiled, or has both empty flags set - if (pClipChunk->globalIdx == -1) - continue; // Not sure if we should ever encounter this... TODO - // check - if ((globalChunkFlags[pClipChunk->globalIdx] & emptyFlag) == emptyFlag) - continue; // Check that this particular layer isn't empty - if (!(globalChunkFlags[pClipChunk->globalIdx] & - LevelRenderer::CHUNK_FLAG_CUT_OUT)) - continue; // Does this chunk contain any cut out geometry - // List can be calculated directly from the chunk's global idex - int list = pClipChunk->globalIdx * 2 + layer; - list += chunkLists; - - if (RenderManager.CBuffCallCutOut(list, first)) { - first = false; - } - } - RenderManager.StateSetForceLOD(-1); // AP - back to normal mipmapping -#endif - -#endif // 0 glPopMatrix(); mc->gameRenderer->turnOffLightLayer( alpha); // 4J - brought forward from 1.8.2 -#else - _renderChunks.clear(); - // int p = 0; - int count = 0; - for (int i = from; i < to; i++) { - if (layer == 0) { - totalChunks++; - if (sortedChunks[playerIndex]->at(i)->emptyFlagSet(layer)) - emptyChunks++; - else if (!sortedChunks[playerIndex]->at(i)->visible) - offscreenChunks++; - else - renderedChunks++; - } - - // if (!sortedChunks[i].empty[layer] && - // sortedChunks[i].visible && - // (sortedChunks[i].occlusion_visible)) { - if (!(sortedChunks[playerIndex]->at(i)->emptyFlagSet(layer) && - sortedChunks[playerIndex]->at(i)->visible)) { - int list = sortedChunks[playerIndex]->at(i)->getList(layer); - if (list >= 0) { - _renderChunks.push_back(sortedChunks[playerIndex]->at(i)); - count++; - } - } - } - - std::shared_ptr player = mc->cameraTargetPlayer; - double xOff = player->xOld + (player->x - player->xOld) * alpha; - double yOff = player->yOld + (player->y - player->yOld) * alpha; - double zOff = player->zOld + (player->z - player->zOld) * alpha; - - int lists = 0; - for (int l = 0; l < RENDERLISTS_LENGTH; l++) { - renderLists[l].clear(); - } - - AUTO_VAR(itEnd, _renderChunks.end()); - for (AUTO_VAR(it, _renderChunks.begin()); it != itEnd; it++) { - Chunk* chunk = *it; //_renderChunks[i]; - - int list = -1; - for (int l = 0; l < lists; l++) { - if (renderLists[l].isAt(chunk->xRender, chunk->yRender, - chunk->zRender)) { - list = l; - } - } - if (list < 0) { - list = lists++; - renderLists[list].init(chunk->xRender, chunk->yRender, - chunk->zRender, xOff, yOff, zOff); - } - - renderLists[list].add(chunk->getList(layer)); - } - - renderSameAsLast(layer, alpha); -#endif return count; } @@ -1052,10 +903,6 @@ void LevelRenderer::renderSky(float alpha) { glDepthMask(false); -#if 0 - // AP - alpha cut out is expensive on vita. - glDisable(GL_ALPHA_TEST); -#endif glEnable(GL_FOG); glColor3f(sr, sg, sb); @@ -1171,10 +1018,6 @@ void LevelRenderer::renderSky(float alpha) { glEnable(GL_ALPHA_TEST); glEnable(GL_FOG); -#if 0 - // AP - alpha cut out is expensive on vita. - glDisable(GL_ALPHA_TEST); -#endif glPopMatrix(); glDisable(GL_TEXTURE_2D); @@ -1193,41 +1036,6 @@ void LevelRenderer::renderSky(float alpha) { // 4J - can't work out what this big black box is for. Taking it out // until someone misses it... it causes a big black box to visible // appear in 3rd person mode whilst under the ground. -#if 0 - float ss = 1; - float yo = -(float) (yy + 65); - float y0 = -ss; - float y1 = yo; - - - t->begin(); - t->color(0x000000, 255); - t->vertex(-ss, y1, ss); - t->vertex(+ss, y1, ss); - t->vertex(+ss, y0, ss); - t->vertex(-ss, y0, ss); - - t->vertex(-ss, y0, -ss); - t->vertex(+ss, y0, -ss); - t->vertex(+ss, y1, -ss); - t->vertex(-ss, y1, -ss); - - t->vertex(+ss, y0, -ss); - t->vertex(+ss, y0, +ss); - t->vertex(+ss, y1, +ss); - t->vertex(+ss, y1, -ss); - - t->vertex(-ss, y1, -ss); - t->vertex(-ss, y1, +ss); - t->vertex(-ss, y0, +ss); - t->vertex(-ss, y0, -ss); - - t->vertex(-ss, y0, -ss); - t->vertex(-ss, y0, +ss); - t->vertex(+ss, y0, +ss); - t->vertex(+ss, y0, -ss); - t->end(); -#endif } if (level[playerIndex]->dimension->hasGround()) { @@ -1245,7 +1053,6 @@ void LevelRenderer::renderSky(float alpha) { } void LevelRenderer::renderHaloRing(float alpha) { -#if !0 && !0 && !0 if (!mc->level->dimension->isNaturalDimension()) return; glDisable(GL_ALPHA_TEST); @@ -1291,7 +1098,6 @@ void LevelRenderer::renderHaloRing(float alpha) { glEnable(GL_ALPHA_TEST); glDisable(GL_FOG); -#endif } void LevelRenderer::renderClouds(float alpha) { @@ -1686,78 +1492,6 @@ void LevelRenderer::renderAdvancedClouds(float alpha) { // geometry to get rid of seams. This is a huge amount more // quads to render, so now using command buffers to render each // section to cut CPU hit. -#if 0 - float xx = (float)(xPos * D); - float zz = (float)(zPos * D); - float xp = xx - xoffs; - float zp = zz - zoffs; - - if (!pFrustumData->cubeInFrustum(0 + xp, 0 + yy, 0 + zp, 8 + xp, - 4 + yy, 8 + zp)) - continue; - - glMatrixMode(GL_TEXTURE); - glLoadIdentity(); - glTranslatef(xx / 256.0f + uo, zz / 256.0f + vo, 0); - glMatrixMode(GL_MODELVIEW); - glPushMatrix(); - glTranslatef(xp, yy, zp); - - glColor4f(cr, cg, cb, 1.0f); - if (noBFCMode) { - // This is the more complex form of render the clouds, based - // on the way that the original code picked which sides to - // render, with backface culling disabled. This is to give a - // more solid version of the clouds for when the player - // might be inside them. - bool draw[6] = {false, false, false, false, false, false}; - - // These rules to decide which sides to draw are the same as - // the original code below - if (yy > -h - 1) draw[0] = true; - if (yy <= h + 1) draw[1] = true; - if (xPos > -1) draw[2] = true; - if (xPos <= 1) draw[3] = true; - if (zPos > -1) draw[4] = true; - if (zPos <= 1) draw[5] = true; - - // Top and bottom just render when required - if (draw[0]) glCallList(cloudList); - if (draw[1]) glCallList(cloudList + 1); - // For x facing sides, if we are actually in the clouds and - // about to draw both sides of the x sides too, then do a - // little offsetting here to avoid z fighting - if (draw[0] && draw[1] && draw[2] && draw[3]) { - glTranslatef(e, 0.0f, 0.0f); - glCallList(cloudList + 2); - glTranslatef(-e, 0.0f, 0.0f); - glCallList(cloudList + 3); - } else { - if (draw[2]) glCallList(cloudList + 2); - if (draw[3]) glCallList(cloudList + 3); - } - // For z facing sides, if we are actually in the clouds and - // about to draw both sides of the z sides too, then do a - // little offsetting here to avoid z fighting - if (draw[0] && draw[1] && draw[4] && draw[5]) { - glTranslatef(0.0f, 0.0f, e); - glCallList(cloudList + 4); - glTranslatef(0.0f, 0.0f, -e); - glCallList(cloudList + 5); - } else { - if (draw[4]) glCallList(cloudList + 4); - if (draw[5]) glCallList(cloudList + 5); - } - } else { - // Simpler form of rendering that we can do most of the - // time, when we aren't potentially inside a cloud - glCallList(cloudList + 6); - } - glPopMatrix(); - glMatrixMode(GL_TEXTURE); - glLoadIdentity(); - glMatrixMode(GL_MODELVIEW); -#else glDisable(GL_CULL_FACE); t->begin(); float xx = (float)(xPos * D); @@ -1889,7 +1623,6 @@ void LevelRenderer::renderAdvancedClouds(float alpha) { } } t->end(); -#endif } } } @@ -1908,7 +1641,7 @@ void LevelRenderer::renderAdvancedClouds(float alpha) { } bool LevelRenderer::updateDirtyChunks() { -#ifdef _LARGE_WORLDS +#if defined(_LARGE_WORLDS) std::list > nearestClipChunks; #endif @@ -1939,7 +1672,7 @@ bool LevelRenderer::updateDirtyChunks() { // See comment on dirtyChunksLockFreeStack.Push() regarding details of // this casting/subtracting -2. index = (size_t)dirtyChunksLockFreeStack.Pop(); -#ifdef _CRITICAL_CHUNKS +#if defined(_CRITICAL_CHUNKS) int oldIndex = index; index &= 0x0fffffff; // remove the top bit that marked the chunk as // non-critical @@ -1962,7 +1695,7 @@ bool LevelRenderer::updateDirtyChunks() { } setGlobalChunkFlag(index - 2, CHUNK_FLAG_DIRTY); -#ifdef _CRITICAL_CHUNKS +#if defined(_CRITICAL_CHUNKS) if (!(oldIndex & 0x10000000)) // was this chunk not marked as // non-critical. Ugh double negatives { @@ -1978,61 +1711,8 @@ bool LevelRenderer::updateDirtyChunks() { if (dirtyChunkPresent) { lastDirtyChunkFound = System::currentTimeMillis(); PIXBeginNamedEvent(0, "Finding nearest chunk\n"); -#if 0 && !defined DISABLE_SPU_CODE - // find the nearest chunk with a spu task, copy all the data over here - // for uploading to SPU - g_findNearestChunkDataIn.numGlobalChunks = getGlobalChunkCount(); - g_findNearestChunkDataIn.pGlobalChunkFlags = globalChunkFlags; - g_findNearestChunkDataIn.onlyRebuild = onlyRebuild; - g_findNearestChunkDataIn.lowerOffset = - (int)&((LevelChunk*)0) - ->lowerBlocks; // dodgy bit of class structure poking, as we - // don't want to try and get the whole of - // LevelChunk copmpiling on SPU - g_findNearestChunkDataIn.upperOffset = - (int)&((LevelChunk*)0)->upperBlocks; - g_findNearestChunkDataIn.xChunks = xChunks; - g_findNearestChunkDataIn.yChunks = yChunks; - g_findNearestChunkDataIn.zChunks = zChunks; - for (int i = 0; i < 4; i++) { - g_findNearestChunkDataIn.chunks[i] = - (LevelRenderer_FindNearestChunk_DataIn::ClipChunk*)chunks[i] - .data; - g_findNearestChunkDataIn.chunkLengths[i] = chunks[i].length; - g_findNearestChunkDataIn.level[i] = level[i]; - g_findNearestChunkDataIn.playerData[i].bValid = - mc->localplayers[i] != NULL; - if (mc->localplayers[i] != NULL) { - g_findNearestChunkDataIn.playerData[i].x = - mc->localplayers[i]->x; - g_findNearestChunkDataIn.playerData[i].y = - mc->localplayers[i]->y; - g_findNearestChunkDataIn.playerData[i].z = - mc->localplayers[i]->z; - } - if (level[i] != NULL) { - g_findNearestChunkDataIn.multiplayerChunkCache[i].XZOFFSET = - ((MultiPlayerChunkCache*)(level[i]->chunkSource))->XZOFFSET; - g_findNearestChunkDataIn.multiplayerChunkCache[i].XZSIZE = - ((MultiPlayerChunkCache*)(level[i]->chunkSource))->XZSIZE; - g_findNearestChunkDataIn.multiplayerChunkCache[i].cache = - (void**)((MultiPlayerChunkCache*)(level[i]->chunkSource)) - ->cache; - } - } - - // assert(sizeof(LevelRenderer_FindNearestChunk_DataIn::Chunk) - // == sizeof(Chunk)); - C4JSpursJob_LevelRenderer_FindNearestChunk findJob( - &g_findNearestChunkDataIn); - m_jobPort_FindNearestChunk->submitJob(&findJob); - m_jobPort_FindNearestChunk->waitForCompletion(); - nearChunk = (ClipChunk*)g_findNearestChunkDataIn.nearChunk; - veryNearCount = g_findNearestChunkDataIn.veryNearCount; -#else // 0 - -#ifdef _LARGE_WORLDS +#if defined(_LARGE_WORLDS) int maxNearestChunks = MAX_CONCURRENT_CHUNK_REBUILDS; // 4J Stu - On XboxOne we should cut this down if in a constrained state // so the saving threads get more time @@ -2091,7 +1771,7 @@ bool LevelRenderer::updateDirtyChunks() { { considered++; // Is this chunk nearer than our nearest? -#ifdef _LARGE_WORLDS +#if defined(_LARGE_WORLDS) bool isNearer = nearestClipChunks.empty(); AUTO_VAR(itNearest, nearestClipChunks.begin()); for (; itNearest != nearestClipChunks.end(); @@ -2107,7 +1787,7 @@ bool LevelRenderer::updateDirtyChunks() { bool isNearer = distSqWeighted < minDistSq; #endif -#ifdef _CRITICAL_CHUNKS +#if defined(_CRITICAL_CHUNKS) // AP - this will make sure that if a deferred // grouping has started, only critical chunks go // into that grouping, even if a non-critical @@ -2143,7 +1823,7 @@ bool LevelRenderer::updateDirtyChunks() { if (!lc->isRenderChunkEmpty(y * 16)) { nearChunk = pClipChunk; minDistSq = distSqWeighted; -#ifdef _LARGE_WORLDS +#if defined(_LARGE_WORLDS) nearestClipChunks.insert( itNearest, std::pair( @@ -2162,7 +1842,7 @@ bool LevelRenderer::updateDirtyChunks() { } } -#ifdef _CRITICAL_CHUNKS +#if defined(_CRITICAL_CHUNKS) // AP - is the chunk near and also critical if (distSq < 20 * 20 && ((globalChunkFlags[pClipChunk->globalIdx] & @@ -2180,12 +1860,11 @@ bool LevelRenderer::updateDirtyChunks() { } // app.DebugPrintf("[%d,%d,%d]\n",nearestClipChunks.empty(),considered,wouldBeNearButEmpty); } -#endif // 0 PIXEndNamedEvent(); } Chunk* chunk = NULL; -#ifdef _LARGE_WORLDS +#if defined(_LARGE_WORLDS) if (!nearestClipChunks.empty()) { int index = 0; for (AUTO_VAR(it, nearestClipChunks.begin()); @@ -2316,9 +1995,6 @@ bool LevelRenderer::updateDirtyChunks() { dirtyChunkPresent = false; } LeaveCriticalSection(&m_csDirtyChunks); -#if 0 - Sleep(5); -#endif // 0 return false; } @@ -2398,15 +2074,7 @@ void LevelRenderer::renderDestroyAnimation(Tesselator* t, glEnable(GL_ALPHA_TEST); t->begin(); -#if 0 - // AP : fix for bug 4952. No amount of polygon offset will push this - // close enough to be seen above the second tile layer when looking - // straight down so just add on a little bit of y to fix this. hacky - // hacky - t->offset((float)-xo, (float)-yo + 0.01f, (float)-zo); -#else t->offset((float)-xo, (float)-yo, (float)-zo); -#endif t->noColor(); AUTO_VAR(it, destroyingBlocks.begin()); @@ -2552,7 +2220,7 @@ void LevelRenderer::setDirty(int x0, int y0, int z0, int x1, int y1, int z1, // Therefore adding 2 to our index value here to move our valid // range from 1 to something quite big + 2 if (index > -1) { -#ifdef _CRITICAL_CHUNKS +#if defined(_CRITICAL_CHUNKS) index += 2; // AP - by the time we reach this function the area passed @@ -2603,13 +2271,8 @@ void LevelRenderer::setDirty(int x0, int y0, int z0, int x1, int y1, int z1, (int*)(intptr_t)(uintptr_t)(index + 2)); #endif -#if 0 - PIXSetMarker(0, "Setting chunk %d %d %d dirty", x * 16, - y * 16, z * 16); -#else PIXSetMarkerDeprecated(0, "Setting chunk %d %d %d dirty", x * 16, y * 16, z * 16); -#endif } // setGlobalChunkFlag(x * 16, y * // 16, z * 16, level, CHUNK_FLAG_DIRTY); @@ -2675,94 +2338,10 @@ bool inline clip(float* bb, float* frustum) { return true; } -#if 0 -int g_listArray_layer0[4][LevelRenderer_cull_DataIn::sc_listSize] - __attribute__((__aligned__(16))); // 8000 -int g_listArray_layer1[4][LevelRenderer_cull_DataIn::sc_listSize] - __attribute__((__aligned__(16))); -float g_zDepth_layer0[4][LevelRenderer_cull_DataIn::sc_listSize] - __attribute__((__aligned__(16))); // 8000 -float g_zDepth_layer1[4][LevelRenderer_cull_DataIn::sc_listSize] - __attribute__((__aligned__(16))); - -volatile bool g_useIdent = false; -volatile float g_maxDepthRender = 1000; -volatile float g_maxHeightRender = -1000; -volatile float g_offMulVal = 1; - -void LevelRenderer::cull_SPU(int playerIndex, Culler* culler, float a) { - if (m_bSPUCullStarted[playerIndex]) { - return; // running already - } - - FrustumCuller* fc = (FrustumCuller*)culler; - FrustumData* fd = fc->frustum; - float fdraw[6 * 4]; - for (int i = 0; i < 6; i++) { - double fx = fd->m_Frustum[i][0]; - double fy = fd->m_Frustum[i][1]; - double fz = fd->m_Frustum[i][2]; - fdraw[i * 4 + 0] = (float)fx; - fdraw[i * 4 + 1] = (float)fy; - fdraw[i * 4 + 2] = (float)fz; - fdraw[i * 4 + 3] = (float)(fd->m_Frustum[i][3] + (fx * -fc->xOff) + - (fy * -fc->yOff) + (fz * -fc->zOff)); - } - - memcpy(&g_cullDataIn[playerIndex].fdraw, fdraw, sizeof(fdraw)); - g_cullDataIn[playerIndex].numClipChunks = chunks[playerIndex].length; - g_cullDataIn[playerIndex].pClipChunks = - (ClipChunk_SPU*)chunks[playerIndex].data; - g_cullDataIn[playerIndex].numGlobalChunks = getGlobalChunkCount(); - g_cullDataIn[playerIndex].pGlobalChunkFlags = globalChunkFlags; - g_cullDataIn[playerIndex].chunkLists = chunkLists; - g_cullDataIn[playerIndex].listArray_layer0 = - g_listArray_layer0[playerIndex]; - g_cullDataIn[playerIndex].listArray_layer1 = - g_listArray_layer1[playerIndex]; - g_cullDataIn[playerIndex].zDepth_layer0 = g_zDepth_layer0[playerIndex]; - g_cullDataIn[playerIndex].zDepth_layer1 = g_zDepth_layer1[playerIndex]; - g_cullDataIn[playerIndex].maxDepthRender = g_maxDepthRender; - g_cullDataIn[playerIndex].maxHeightRender = g_maxHeightRender; - - if (g_useIdent) - g_cullDataIn[playerIndex].clipMat = - Vectormath::Aos::Matrix4::identity(); - else { - memcpy(&g_cullDataIn[playerIndex].clipMat, &fc->frustum->modl[0], - sizeof(float) * 16); - g_cullDataIn[playerIndex].clipMat[3][0] = -fc->xOff; - g_cullDataIn[playerIndex].clipMat[3][1] = -fc->yOff; - g_cullDataIn[playerIndex].clipMat[3][2] = -fc->zOff; - } - - C4JSpursJob_LevelRenderer_cull cullJob(&g_cullDataIn[playerIndex]); - C4JSpursJob_LevelRenderer_zSort sortJob(&g_cullDataIn[playerIndex]); - - m_jobPort_CullSPU->submitJob(&cullJob); - m_jobPort_CullSPU->submitSync(); - // static int doSort = false; - // if(doSort) - { - m_jobPort_CullSPU->submitJob(&sortJob); - } - // doSort ^= 1; - m_bSPUCullStarted[playerIndex] = true; -} -void LevelRenderer::waitForCull_SPU() { - m_jobPort_CullSPU->waitForCompletion(); - int playerIndex = mc->player->GetXboxPad(); // 4J added - m_bSPUCullStarted[playerIndex] = false; -} -#endif // 0 void LevelRenderer::cull(Culler* culler, float a) { int playerIndex = mc->player->GetXboxPad(); // 4J added -#if 0 && !defined DISABLE_SPU_CODE - cull_SPU(playerIndex, culler, a); - return; -#endif // 0 FrustumCuller* fc = (FrustumCuller*)culler; FrustumData* fd = fc->frustum; @@ -3250,17 +2829,6 @@ void LevelRenderer::entityRemoved(std::shared_ptr entity) { void LevelRenderer::skyColorChanged() { // 4J - no longer used -#if 0 - EnterCriticalSection(&m_csDirtyChunks); - for( int i = 0; i < getGlobalChunkCountForOverworld(); i++ ) - { - if( ( globalChunkFlags[i] & CHUNK_FLAG_NOTSKYLIT ) == 0 ) - { - globalChunkFlags[i] |= CHUNK_FLAG_DIRTY; - } - } - LeaveCriticalSection(&m_csDirtyChunks); -#endif } void LevelRenderer::clear() { MemoryTracker::releaseLists(chunkLists); } @@ -3727,11 +3295,11 @@ void LevelRenderer::setGlobalChunkFlags(int x, int y, int z, Level* level, unsigned char flags) { int index = getGlobalIndexForChunk(x, y, z, level); if (index != -1) { -#ifdef _LARGE_WORLDS +#if defined(_LARGE_WORLDS) EnterCriticalSection(&m_csChunkFlags); #endif globalChunkFlags[index] = flags; -#ifdef _LARGE_WORLDS +#if defined(_LARGE_WORLDS) LeaveCriticalSection(&m_csChunkFlags); #endif } @@ -3742,11 +3310,11 @@ void LevelRenderer::setGlobalChunkFlag(int index, unsigned char flag, unsigned char sflag = flag << shift; if (index != -1) { -#ifdef _LARGE_WORLDS +#if defined(_LARGE_WORLDS) EnterCriticalSection(&m_csChunkFlags); #endif globalChunkFlags[index] |= sflag; -#ifdef _LARGE_WORLDS +#if defined(_LARGE_WORLDS) LeaveCriticalSection(&m_csChunkFlags); #endif } @@ -3758,11 +3326,11 @@ void LevelRenderer::setGlobalChunkFlag(int x, int y, int z, Level* level, unsigned char sflag = flag << shift; int index = getGlobalIndexForChunk(x, y, z, level); if (index != -1) { -#ifdef _LARGE_WORLDS +#if defined(_LARGE_WORLDS) EnterCriticalSection(&m_csChunkFlags); #endif globalChunkFlags[index] |= sflag; -#ifdef _LARGE_WORLDS +#if defined(_LARGE_WORLDS) LeaveCriticalSection(&m_csChunkFlags); #endif } @@ -3774,11 +3342,11 @@ void LevelRenderer::clearGlobalChunkFlag(int x, int y, int z, Level* level, unsigned char sflag = flag << shift; int index = getGlobalIndexForChunk(x, y, z, level); if (index != -1) { -#ifdef _LARGE_WORLDS +#if defined(_LARGE_WORLDS) EnterCriticalSection(&m_csChunkFlags); #endif globalChunkFlags[index] &= ~sflag; -#ifdef _LARGE_WORLDS +#if defined(_LARGE_WORLDS) LeaveCriticalSection(&m_csChunkFlags); #endif } @@ -4000,7 +3568,7 @@ void LevelRenderer::DestroyedTileManager::tick() { LeaveCriticalSection(&m_csDestroyedTiles); } -#ifdef _LARGE_WORLDS +#if defined(_LARGE_WORLDS) void LevelRenderer::staticCtor() { s_rebuildCompleteEvents = new C4JThread::EventArray(MAX_CHUNK_REBUILD_THREADS); @@ -4017,15 +3585,6 @@ void LevelRenderer::staticCtor() { rebuildThreads[i]->SetProcessor(CPU_CORE_CHUNK_REBUILD_A); else if ((i % 3) == 1) { rebuildThreads[i]->SetProcessor(CPU_CORE_CHUNK_REBUILD_B); -#if 0 - rebuildThreads[i]->SetPriority( - THREAD_PRIORITY_BELOW_NORMAL); // On Orbis, this core is also - // used for Matching 2, and that - // priority of that seems to be - // always at default no matter - // what we set it to. Prioritise - // this below Matching 2. -#endif } else if ((i % 3) == 2) rebuildThreads[i]->SetProcessor(CPU_CORE_CHUNK_REBUILD_C); diff --git a/Minecraft.Client/Rendering/LevelRenderer.h b/Minecraft.Client/Rendering/LevelRenderer.h index 4740cd039..fbd13451d 100644 --- a/Minecraft.Client/Rendering/LevelRenderer.h +++ b/Minecraft.Client/Rendering/LevelRenderer.h @@ -4,9 +4,9 @@ #include "OffsettedRenderList.h" #include "../../Minecraft.World/Util/JavaIntHash.h" #include "../../Minecraft.World/Level/Level.h" -#ifndef __linux__ +#if !defined(__linux__) #include -#endif // __linux__ +#endif class MultiPlayerLevel; class Textures; class Chunk; @@ -29,9 +29,6 @@ class Tesselator; // I've added another chunk flag to mark a chunk critical so it swipes a bit // from the reference count value (goes to 3 bits to 2). This works on Vita // because it doesn't have split screen reference counting. -#if 0 -#define _CRITICAL_CHUNKS -#endif class LevelRenderer : public LevelListener { friend class Chunk; @@ -45,24 +42,15 @@ private: public: static const int CHUNK_XZSIZE = 16; -#ifdef _LARGE_WORLDS +#if defined(_LARGE_WORLDS) static const int CHUNK_SIZE = 16; #else static const int CHUNK_SIZE = 16; #endif static const int CHUNK_Y_COUNT = Level::maxBuildHeight / CHUNK_SIZE; -#if (0 || defined _WINDOWS64) +#if defined(_WINDOWS64) static const int MAX_COMMANDBUFFER_ALLOCATIONS = 512 * 1024 * 1024; // 4J - added -#elif 0 - static const int MAX_COMMANDBUFFER_ALLOCATIONS = - 448 * 1024 * - 1024; // 4J - added - hard limit is 512 so giving a lot of headroom - // here for fragmentation (have seen 16MB lost to fragmentation - // in multiplayer crash dump before) -#elif 0 - static const int MAX_COMMANDBUFFER_ALLOCATIONS = - 110 * 1024 * 1024; // 4J - added #else static const int MAX_COMMANDBUFFER_ALLOCATIONS = 55 * 1024 * 1024; // 4J - added @@ -123,13 +111,6 @@ public: void setTilesDirty(int x0, int y0, int z0, int x1, int y1, int z1, Level* level); // 4J - added level param -#if 0 - void cull_SPU(int playerIndex, Culler* culler, float a); - void waitForCull_SPU(); - C4JSpursJobQueue::Port* m_jobPort_CullSPU; - C4JSpursJobQueue::Port* m_jobPort_FindNearestChunk; - bool m_bSPUCullStarted[4]; -#endif // 0 void cull(Culler* culler, float a); void playStreamingMusic(const std::wstring& name, int x, int y, int z); void playSound(int iSound, double x, double y, double z, float volume, @@ -267,7 +248,7 @@ public: // This is the TOTAL area of columns of chunks to be allocated for render // round the players. So for one player, it would be a region of // sqrt(PLAYER_RENDER_AREA) x sqrt(PLAYER_RENDER_AREA) -#ifdef _LARGE_WORLDS +#if defined(_LARGE_WORLDS) static const int PLAYER_VIEW_DISTANCE = 18; // Straight line distance from centre to extent of visible world static const int PLAYER_RENDER_AREA = @@ -312,7 +293,7 @@ public: static const int CHUNK_FLAG_EMPTY1 = 0x08; static const int CHUNK_FLAG_EMPTYBOTH = 0x0c; static const int CHUNK_FLAG_NOTSKYLIT = 0x10; -#ifdef _CRITICAL_CHUNKS +#if defined(_CRITICAL_CHUNKS) static const int CHUNK_FLAG_CRITICAL = 0x20; static const int CHUNK_FLAG_CUT_OUT = 0x40; static const int CHUNK_FLAG_REF_MASK = 0x01; @@ -328,7 +309,7 @@ public: int64_t lastDirtyChunkFound; static const int FORCE_DIRTY_CHUNK_CHECK_PERIOD_MS = 250; -#ifdef _LARGE_WORLDS +#if defined(_LARGE_WORLDS) static const int MAX_CONCURRENT_CHUNK_REBUILDS = 4; static const int MAX_CHUNK_REBUILD_THREADS = MAX_CONCURRENT_CHUNK_REBUILDS - 1; diff --git a/Minecraft.Client/Rendering/Minimap.cpp b/Minecraft.Client/Rendering/Minimap.cpp index 3d1ff5657..3b8170557 100644 --- a/Minecraft.Client/Rendering/Minimap.cpp +++ b/Minecraft.Client/Rendering/Minimap.cpp @@ -8,40 +8,19 @@ #include "../../Minecraft.World/Headers/net.minecraft.world.level.saveddata.h" #include "../../Minecraft.World/Headers/net.minecraft.world.level.material.h" -#if 0 -short Minimap::LUT[256]; // 4J added -#else int Minimap::LUT[256]; // 4J added -#endif bool Minimap::genLUT = true; // 4J added Minimap::Minimap(Font* font, Options* options, Textures* textures, bool optimised) { -#if 0 - // we're using the RSX now to upload textures to vram, so we need the main - // ram textures allocated from io space - this->pixels = - intArray((int*)RenderManager.allocIOMem(w * h * sizeof(int)), 16 * 16); - -#elif 0 - this->pixels = shortArray(w * h); -#else this->pixels = intArray(w * h); -#endif this->options = options; this->font = font; BufferedImage* img = new BufferedImage(w, h, BufferedImage::TYPE_INT_ARGB); -#if 0 - mapTexture = - textures->getTexture(img, C4JRender::TEXTURE_FORMAT_RxGyBzAw5551, - false); // 4J - make sure we aren't mipmapping as - // we never set the data for mipmaps -#else mapTexture = textures->getTexture(img, C4JRender::TEXTURE_FORMAT_RxGyBzAw, false); // 4J - make sure we aren't mipmapping as // we never set the data for mipmaps -#endif delete img; for (int i = 0; i < w * h; i++) { pixels[i] = 0x00000000; @@ -65,11 +44,7 @@ void Minimap::reloadColours() { { if (i / 4 == 0) { // 4J - changed byte order to save having to reorder later -#if 0 - LUT[i] = 0; -#else LUT[i] = (((i + i / w) & 1) * 8 + 16); -#endif // pixels[i] = (((i + i / w) & 1) * 8 + 16) << 24; } else { int color = @@ -85,15 +60,8 @@ void Minimap::reloadColours() { int b = ((color) & 0xff) * br / 255; // 4J - changed byte order to save having to reorder later -#if (0 || defined _WIN64 || 0 || __linux__) +#if defined(_WIN64) || __linux__ LUT[i] = 255 << 24 | b << 16 | g << 8 | r; -#elif 0 - LUT[i] = 255 << 24 | r << 16 | g << 8 | b; -#elif 0 - r >>= 3; - g >>= 3; - b >>= 3; - LUT[i] = 1 << 15 | (r << 10) | (g << 5) | b; #else LUT[i] = r << 24 | g << 16 | b << 8 | 255; #endif @@ -139,9 +107,6 @@ void Minimap::render(std::shared_ptr player, Textures* textures, // 4J - moved to -0.02 to stop z fighting ( was -0.01) // AP - Vita still has issues so push it a bit more float Offset = -0.02f; -#if 0 - Offset = -0.03f; -#endif t->vertexUV((float)(x + 0 + vo), (float)(y + h - vo), (float)(Offset), (float)(0), (float)(1)); t->vertexUV((float)(x + w - vo), (float)(y + h - vo), (float)(Offset), @@ -159,7 +124,7 @@ void Minimap::render(std::shared_ptr player, Textures* textures, AUTO_VAR(itEnd, data->decorations.end()); -#ifdef _LARGE_WORLDS +#if defined(_LARGE_WORLDS) std::vector m_edgeIcons; #endif @@ -175,7 +140,7 @@ void Minimap::render(std::shared_ptr player, Textures* textures, char imgIndex = dec->img; -#ifdef _LARGE_WORLDS +#if defined(_LARGE_WORLDS) // For edge icons, use a different texture if (imgIndex >= 16) { m_edgeIcons.push_back(dec); @@ -218,7 +183,7 @@ void Minimap::render(std::shared_ptr player, Textures* textures, fIconZ -= 0.01f; } -#ifdef _LARGE_WORLDS +#if defined(_LARGE_WORLDS) // For players on the edge of the world textures->bind(textures->loadTexture(TN_MISC_ADDITIONALMAPICONS)); diff --git a/Minecraft.Client/Rendering/Minimap.h b/Minecraft.Client/Rendering/Minimap.h index 27893363f..9bb7efbec 100644 --- a/Minecraft.Client/Rendering/Minimap.h +++ b/Minecraft.Client/Rendering/Minimap.h @@ -10,19 +10,11 @@ class Minimap { private: static const int w = MapItem::IMAGE_WIDTH; static const int h = MapItem::IMAGE_HEIGHT; -#if 0 - static short LUT[256]; // 4J added -#else static int LUT[256]; // 4J added -#endif static bool genLUT; // 4J added int renderCount; // 4J added bool m_optimised; // 4J Added -#if 0 - shortArray pixels; -#else intArray pixels; -#endif int mapTexture; Options* options; Font* font; diff --git a/Minecraft.Client/Rendering/Particles/FireworksParticles.cpp b/Minecraft.Client/Rendering/Particles/FireworksParticles.cpp index c1426980c..d891865ab 100644 --- a/Minecraft.Client/Rendering/Particles/FireworksParticles.cpp +++ b/Minecraft.Client/Rendering/Particles/FireworksParticles.cpp @@ -309,12 +309,7 @@ FireworksParticles::FireworksSparkParticle::FireworksSparkParticle( size *= 0.75f; lifetime = 48 + random->nextInt(12); -#if 0 - noPhysics = true; // 4J - optimisation, these are just too slow on Vita to - // be running with physics on -#else noPhysics = false; -#endif trail = false; flicker = false; diff --git a/Minecraft.Client/Rendering/Particles/GuiParticles.cpp b/Minecraft.Client/Rendering/Particles/GuiParticles.cpp index c60ffcd81..5a7002682 100644 --- a/Minecraft.Client/Rendering/Particles/GuiParticles.cpp +++ b/Minecraft.Client/Rendering/Particles/GuiParticles.cpp @@ -26,23 +26,4 @@ void GuiParticles::add(GuiParticle* guiParticle) { void GuiParticles::render(float a) { // 4J Stu - Never used -#if 0 - mc->textures->bindTexture(L"/gui/particles.png"); - - AUTO_VAR(itEnd, particles.end()); - for (AUTO_VAR(it, particles.begin()); it != itEnd; it++) - { - GuiParticle *gp = *it; //particles[i]; - int xx = (int) (gp->xo + (gp->x - gp->xo) * a - 4); - int yy = (int) (gp->yo + (gp->y - gp->yo) * a - 4); - - float alpha = ((float) (gp->oA + (gp->a - gp->oA) * a)); - float r = ((float) (gp->oR + (gp->r - gp->oR) * a)); - float g = ((float) (gp->oG + (gp->g - gp->oG) * a)); - float b = ((float) (gp->oB + (gp->b - gp->oB) * a)); - - glColor4f(r, g, b, alpha); - blit(xx, yy, 8 * 5, 0, 8, 8); - } -#endif } diff --git a/Minecraft.Client/Rendering/Particles/Particle.cpp b/Minecraft.Client/Rendering/Particles/Particle.cpp index 19e7def16..3fa94b9d3 100644 --- a/Minecraft.Client/Rendering/Particles/Particle.cpp +++ b/Minecraft.Client/Rendering/Particles/Particle.cpp @@ -148,18 +148,6 @@ void Particle::render(Tesselator* t, float a, float xa, float ya, float za, br = getBrightness(a); } -#if 0 - // AP - this will set up the 4 vertices in half the time. - t->tileParticleQuad((float)(x - xa * r - xa2 * r), (float)(y - ya * r), - (float)(z - za * r - za2 * r), (float)(u1), (float)(v1), - (float)(x - xa * r + xa2 * r), (float)(y + ya * r), - (float)(z - za * r + za2 * r), (float)(u1), (float)(v0), - (float)(x + xa * r + xa2 * r), (float)(y + ya * r), - (float)(z + za * r + za2 * r), (float)(u0), (float)(v0), - (float)(x + xa * r - xa2 * r), (float)(y - ya * r), - (float)(z + za * r - za2 * r), (float)(u0), (float)(v1), - rCol * br, gCol * br, bCol * br, alpha); -#else t->color(rCol * br, gCol * br, bCol * br, alpha); t->vertexUV((float)(x - xa * r - xa2 * r), (float)(y - ya * r), @@ -170,7 +158,6 @@ void Particle::render(Tesselator* t, float a, float xa, float ya, float za, (float)(z + za * r + za2 * r), (float)(u0), (float)(v0)); t->vertexUV((float)(x + xa * r - xa2 * r), (float)(y - ya * r), (float)(z + za * r - za2 * r), (float)(u0), (float)(v1)); -#endif } int Particle::getParticleTexture() { return ParticleEngine::MISC_TEXTURE; } @@ -185,7 +172,7 @@ void Particle::setTex(Textures* textures, Icon* icon) { } else if (getParticleTexture() == ParticleEngine::ITEM_TEXTURE) { tex = icon; } else { -#ifndef _CONTENT_PACKAGE +#if !defined(_CONTENT_PACKAGE) printf("Invalid call to Particle.setTex, use coordinate methods\n"); __debugbreak(); #endif @@ -197,7 +184,7 @@ void Particle::setTex(Textures* textures, Icon* icon) { void Particle::setMiscTex(int slotIndex) { if (getParticleTexture() != ParticleEngine::MISC_TEXTURE && getParticleTexture() != ParticleEngine::DRAGON_BREATH_TEXTURE) { -#ifndef _CONTENT_PACKAGE +#if !defined(_CONTENT_PACKAGE) printf("Invalid call to Particle.setMixTex\n"); __debugbreak(); // throw new RuntimeException("Invalid call to Particle.setMiscTex"); diff --git a/Minecraft.Client/Rendering/Tesselator.cpp b/Minecraft.Client/Rendering/Tesselator.cpp index a8e153562..05a6fa05d 100644 --- a/Minecraft.Client/Rendering/Tesselator.cpp +++ b/Minecraft.Client/Rendering/Tesselator.cpp @@ -73,16 +73,6 @@ Tesselator::Tesselator(int size) { ARBVertexBufferObject::glGenBuffersARB(vboIds); } -#if 0 - // AP - alpha cut out is expensive on vita. Use this to defer primitives - // that use icons with alpha - alphaCutOutEnabled = false; - - // this is the cut out enabled vertex array - _array2 = new intArray(size); - vertices2 = 0; - p2 = 0; -#endif } Tesselator* Tesselator::getUniqueInstance(int size) { @@ -93,13 +83,7 @@ void Tesselator::end() { // if (!tesselating) throw new IllegalStateException("Not tesselating!"); // // 4J - removed tesselating = false; -#if 0 - // AP - alpha cut out is expensive on vita. Check both counts for valid - // vertices - if (vertices > 0 || vertices2 > 0) -#else if (vertices > 0) -#endif { // 4J - a lot of stuff taken out here for fiddling round with enable // client states etc. that don't matter for our renderer @@ -115,29 +99,9 @@ void Tesselator::end() { *pColData = 0x00000000; pColData += 8; } -#if 0 - // AP - alpha cut out is expensive on vita. Check both counts for - // valid vertices - pColData = (unsigned int*)_array2->data; - pColData += 5; - for (int i = 0; i < vertices2; i++) { - *pColData = 0xffffffff; - pColData += 8; - } -#endif } if (mode == GL_QUADS && TRIANGLE_MODE) { // glDrawArrays(GL_TRIANGLES, 0, vertices); // 4J - changed for xbox -#if 0 - RenderManager.DrawVertices( - D3DPT_TRIANGLELIST, vertices, _array->data, - useCompactFormat360 - ? C4JRender::VERTEX_TYPE_PS3_TS2_CS1 - : C4JRender::VERTEX_TYPE_PF3_TF2_CB4_NB4_XW1, - useProjectedTexturePixelShader - ? C4JRender::PIXEL_SHADER_TYPE_PROJECTION - : C4JRender::PIXEL_SHADER_TYPE_STANDARD); -#else RenderManager.DrawVertices( C4JRender::PRIMITIVE_TYPE_TRIANGLE_LIST, vertices, _array->data, useCompactFormat360 @@ -146,58 +110,18 @@ void Tesselator::end() { useProjectedTexturePixelShader ? C4JRender::PIXEL_SHADER_TYPE_PROJECTION : C4JRender::PIXEL_SHADER_TYPE_STANDARD); -#endif } else { // glDrawArrays(mode, 0, vertices); // 4J - changed for xbox // For compact vertices, the vertexCount has to be calculated from the amount of // data written, as we insert extra fake vertices to encode supplementary data // for more awkward quads that have non axis aligned UVs (eg flowing lava/water) -#if 0 int vertexCount = vertices; if (useCompactFormat360) { - vertexCount = p / 2; - RenderManager.DrawVertices( - (D3DPRIMITIVETYPE)mode, vertexCount, _array->data, - C4JRender::VERTEX_TYPE_PS3_TS2_CS1, - C4JRender::PIXEL_SHADER_TYPE_STANDARD); - } else { - if (useProjectedTexturePixelShader) { - RenderManager.DrawVertices( - (D3DPRIMITIVETYPE)mode, vertexCount, _array->data, - C4JRender::VERTEX_TYPE_PF3_TF2_CB4_NB4_XW1_TEXGEN, - C4JRender::PIXEL_SHADER_TYPE_PROJECTION); - } else { - RenderManager.DrawVertices( - (D3DPRIMITIVETYPE)mode, vertexCount, _array->data, - C4JRender::VERTEX_TYPE_PF3_TF2_CB4_NB4_XW1, - C4JRender::PIXEL_SHADER_TYPE_STANDARD); - } - } -#else - int vertexCount = vertices; - if (useCompactFormat360) { -#if 0 - // AP - alpha cut out is expensive on vita. Render non-cut out - // stuff first then send the cut out stuff - if (vertexCount) { - RenderManager.DrawVertices( - (C4JRender::ePrimitiveType)mode, vertexCount, - _array->data, C4JRender::VERTEX_TYPE_COMPRESSED, - C4JRender::PIXEL_SHADER_TYPE_STANDARD); - } - if (vertices2) { - RenderManager.DrawVerticesCutOut( - (C4JRender::ePrimitiveType)mode, vertices2, - _array2->data, C4JRender::VERTEX_TYPE_COMPRESSED, - C4JRender::PIXEL_SHADER_TYPE_STANDARD); - } -#else RenderManager.DrawVertices( (C4JRender::ePrimitiveType)mode, vertexCount, _array->data, C4JRender::VERTEX_TYPE_COMPRESSED, C4JRender::PIXEL_SHADER_TYPE_STANDARD); -#endif } else { if (useProjectedTexturePixelShader) { RenderManager.DrawVertices( @@ -213,7 +137,6 @@ void Tesselator::end() { C4JRender::PIXEL_SHADER_TYPE_STANDARD); } } -#endif } glDisableClientState(GL_VERTEX_ARRAY); if (hasTexture) glDisableClientState(GL_TEXTURE_COORD_ARRAY); @@ -230,11 +153,6 @@ void Tesselator::clear() { p = 0; count = 0; -#if 0 - // AP - alpha cut out is expensive on vita. Clear the cut out variables - vertices2 = 0; - p2 = 0; -#endif } void Tesselator::begin() { @@ -258,18 +176,6 @@ bool Tesselator::setMipmapEnable(bool enable) { return prev; } -#if 0 -// AP - alpha cut out is expensive on vita. Use this to defer primitives that -// use icons with alpha -void Tesselator::setAlphaCutOut(bool enable) { alphaCutOutEnabled = enable; } - -// AP - was any cut out geometry added since the last call to Clear -bool Tesselator::getCutOutFound() { - if (vertices2) return true; - - return false; -} -#endif void Tesselator::begin(int mode) { /* // 4J - removed @@ -495,251 +401,12 @@ void Tesselator::packCompactQuad() { } } -#if 0 -void Tesselator::tileQuad(float x1, float y1, float z1, float u1, float v1, - float r1, float g1, float b1, int tex1, float x2, - float y2, float z2, float u2, float v2, float r2, - float g2, float b2, int tex2, float x3, float y3, - float z3, float u3, float v3, float r3, float g3, - float b3, int tex3, float x4, float y4, float z4, - float u4, float v4, float r4, float g4, float b4, - int tex4) { - hasTexture = true; - hasTexture2 = true; - hasColor = true; - - count += 4; - - // AP - alpha cut out is expensive on vita. This will choose the correct - // data buffer depending on cut out enabled - std::int16_t* pShortData; - if (!alphaCutOutEnabled) { - pShortData = (std::int16_t*)&_array->data[p]; - p += 16; - vertices += 4; - } else { - pShortData = (std::int16_t*)&_array2->data[p2]; - p2 += 16; - vertices2 += 4; - } - - int r = ((int)(r1 * 31)) << 11; - int g = ((int)(g1 * 63)) << 5; - int b = ((int)(b1 * 31)); - int ipackedcol = r | g | b; - ipackedcol -= 32768; // -32768 to 32767 range - ipackedcol &= 0xffff; - - bounds.addVert(x1 + xo, y1 + yo, z1 + zo); // 4J MGH - added - pShortData[0] = (((int)((x1 + xo) * 1024.0f)) & 0xffff); - pShortData[1] = (((int)((y1 + yo) * 1024.0f)) & 0xffff); - pShortData[2] = (((int)((z1 + zo) * 1024.0f)) & 0xffff); - pShortData[3] = ipackedcol; - pShortData[4] = (((int)(u1 * 8192.0f)) & 0xffff); - pShortData[5] = (((int)(v1 * 8192.0f)) & 0xffff); - ((int*)pShortData)[3] = tex1; - pShortData += 8; - - r = ((int)(r2 * 31)) << 11; - g = ((int)(g2 * 63)) << 5; - b = ((int)(b2 * 31)); - ipackedcol = r | g | b; - ipackedcol -= 32768; // -32768 to 32767 range - ipackedcol &= 0xffff; - - bounds.addVert(x2 + xo, y2 + yo, z2 + zo); // 4J MGH - added - pShortData[0] = (((int)((x2 + xo) * 1024.0f)) & 0xffff); - pShortData[1] = (((int)((y2 + yo) * 1024.0f)) & 0xffff); - pShortData[2] = (((int)((z2 + zo) * 1024.0f)) & 0xffff); - pShortData[3] = ipackedcol; - pShortData[4] = (((int)(u2 * 8192.0f)) & 0xffff); - pShortData[5] = (((int)(v2 * 8192.0f)) & 0xffff); - ((int*)pShortData)[3] = tex2; - pShortData += 8; - - r = ((int)(r3 * 31)) << 11; - g = ((int)(g3 * 63)) << 5; - b = ((int)(b3 * 31)); - ipackedcol = r | g | b; - ipackedcol -= 32768; // -32768 to 32767 range - ipackedcol &= 0xffff; - - bounds.addVert(x3 + xo, y3 + yo, z3 + zo); // 4J MGH - added - pShortData[0] = (((int)((x3 + xo) * 1024.0f)) & 0xffff); - pShortData[1] = (((int)((y3 + yo) * 1024.0f)) & 0xffff); - pShortData[2] = (((int)((z3 + zo) * 1024.0f)) & 0xffff); - pShortData[3] = ipackedcol; - pShortData[4] = (((int)(u3 * 8192.0f)) & 0xffff); - pShortData[5] = (((int)(v3 * 8192.0f)) & 0xffff); - ((int*)pShortData)[3] = tex3; - pShortData += 8; - - r = ((int)(r4 * 31)) << 11; - g = ((int)(g4 * 63)) << 5; - b = ((int)(b4 * 31)); - ipackedcol = r | g | b; - ipackedcol -= 32768; // -32768 to 32767 range - ipackedcol &= 0xffff; - - bounds.addVert(x4 + xo, y4 + yo, z4 + zo); // 4J MGH - added - pShortData[0] = (((int)((x4 + xo) * 1024.0f)) & 0xffff); - pShortData[1] = (((int)((y4 + yo) * 1024.0f)) & 0xffff); - pShortData[2] = (((int)((z4 + zo) * 1024.0f)) & 0xffff); - pShortData[3] = ipackedcol; - pShortData[4] = (((int)(u4 * 8192.0f)) & 0xffff); - pShortData[5] = (((int)(v4 * 8192.0f)) & 0xffff); - ((int*)pShortData)[3] = tex4; - - // Max 65535 verts in D3D, so 65532 is the last point at the end of a quad - // to catch it - if ((!alphaCutOutEnabled && vertices % 4 == 0 && - ((p >= size - 4 * 4) || ((p / 4) >= 65532))) || - (alphaCutOutEnabled && vertices2 % 4 == 0 && - ((p2 >= size - 4 * 4) || ((p2 / 4) >= 65532)))) { - end(); - tesselating = true; - } -} - -void Tesselator::tileRainQuad(float x1, float y1, float z1, float u1, float v1, - float x2, float y2, float z2, float u2, float v2, - float x3, float y3, float z3, float u3, float v3, - float x4, float y4, float z4, float u4, float v4, - float r1, float g1, float b1, float a1, float r2, - float g2, float b2, float a2, int tex1) { - hasTexture = true; - hasTexture2 = true; - hasColor = true; - - float* pfData = (float*)&_array->data[p]; - - count += 4; - p += 4 * 8; - vertices += 4; - - unsigned int col1 = ((int)(r1 * 255) << 24) | ((int)(g1 * 255) << 16) | - ((int)(b1 * 255) << 8) | (int)(a1 * 255); - - bounds.addVert(x1 + xo, y1 + yo, z1 + zo); - pfData[0] = (x1 + xo); - pfData[1] = (y1 + yo); - pfData[2] = (z1 + zo); - pfData[3] = u1; - pfData[4] = v1; - ((int*)pfData)[5] = col1; - ((int*)pfData)[7] = tex1; - pfData += 8; - - bounds.addVert(x2 + xo, y2 + yo, z2 + zo); - pfData[0] = (x2 + xo); - pfData[1] = (y2 + yo); - pfData[2] = (z2 + zo); - pfData[3] = u2; - pfData[4] = v2; - ((int*)pfData)[5] = col1; - ((int*)pfData)[7] = tex1; - pfData += 8; - - col1 = ((int)(r2 * 255) << 24) | ((int)(g2 * 255) << 16) | - ((int)(b2 * 255) << 8) | (int)(a2 * 255); - - bounds.addVert(x3 + xo, y3 + yo, z3 + zo); - pfData[0] = (x3 + xo); - pfData[1] = (y3 + yo); - pfData[2] = (z3 + zo); - pfData[3] = u3; - pfData[4] = v3; - ((int*)pfData)[5] = col1; - ((int*)pfData)[7] = tex1; - pfData += 8; - - bounds.addVert(x4 + xo, y4 + yo, z4 + zo); - pfData[0] = (x4 + xo); - pfData[1] = (y4 + yo); - pfData[2] = (z4 + zo); - pfData[3] = u4; - pfData[4] = v4; - ((int*)pfData)[5] = col1; - ((int*)pfData)[7] = tex1; - pfData += 8; - - if (vertices % 4 == 0 && p >= size - 8 * 4) { - end(); - tesselating = true; - } -} - -void Tesselator::tileParticleQuad(float x1, float y1, float z1, float u1, - float v1, float x2, float y2, float z2, - float u2, float v2, float x3, float y3, - float z3, float u3, float v3, float x4, - float y4, float z4, float u4, float v4, - float r1, float g1, float b1, float a1) { - hasTexture = true; - hasTexture2 = true; - hasColor = true; - - float* pfData = (float*)&_array->data[p]; - - count += 4; - p += 4 * 8; - vertices += 4; - - unsigned int col1 = ((int)(r1 * 255) << 24) | ((int)(g1 * 255) << 16) | - ((int)(b1 * 255) << 8) | (int)(a1 * 255); - - bounds.addVert(x1 + xo, y1 + yo, z1 + zo); - pfData[0] = (x1 + xo); - pfData[1] = (y1 + yo); - pfData[2] = (z1 + zo); - pfData[3] = u1; - pfData[4] = v1; - ((int*)pfData)[5] = col1; - ((int*)pfData)[7] = _tex2; - pfData += 8; - - bounds.addVert(x2 + xo, y2 + yo, z2 + zo); - pfData[0] = (x2 + xo); - pfData[1] = (y2 + yo); - pfData[2] = (z2 + zo); - pfData[3] = u2; - pfData[4] = v2; - ((int*)pfData)[5] = col1; - ((int*)pfData)[7] = _tex2; - pfData += 8; - - bounds.addVert(x3 + xo, y3 + yo, z3 + zo); - pfData[0] = (x3 + xo); - pfData[1] = (y3 + yo); - pfData[2] = (z3 + zo); - pfData[3] = u3; - pfData[4] = v3; - ((int*)pfData)[5] = col1; - ((int*)pfData)[7] = _tex2; - pfData += 8; - - bounds.addVert(x4 + xo, y4 + yo, z4 + zo); - pfData[0] = (x4 + xo); - pfData[1] = (y4 + yo); - pfData[2] = (z4 + zo); - pfData[3] = u4; - pfData[4] = v4; - ((int*)pfData)[5] = col1; - ((int*)pfData)[7] = _tex2; - pfData += 8; - - if (vertices % 4 == 0 && p >= size - 8 * 4) { - end(); - tesselating = true; - } -} -#endif typedef unsigned short hfloat; extern hfloat convertFloatToHFloat(float f); extern float convertHFloatToFloat(hfloat hf); -#ifdef __linux__ +#if defined(__linux__) namespace { void packLinuxLightmapCoords(int tex2, std::int16_t& u, std::int16_t& v) { u = static_cast(tex2 & 0xffff); @@ -778,25 +445,6 @@ void Tesselator::vertex(float x, float y, float z) { if (useCompactFormat360) { unsigned int ucol = (unsigned int)col; -#if 0 - // Pack as 4:4:4 RGB_ - unsigned short packedcol = - (((col & 0xf0000000) >> 16) | ((col & 0x00f00000) >> 12) | - ((col & 0x0000f000) >> 8)); - int ipackedcol = ((int)packedcol) & 0xffff; // 0 to 65535 range - - int quadIdx = vertices % 4; - m_ix[quadIdx] = (unsigned int)((x + xo) * 128.0f); - m_iy[quadIdx] = (unsigned int)((y + yo) * 128.0f); - m_iz[quadIdx] = (unsigned int)((z + zo) * 128.0f); - m_clr[quadIdx] = (unsigned int)ipackedcol; - m_u[quadIdx] = (int)(uu * 4096.0f); - m_v[quadIdx] = (int)(v * 4096.0f); - m_t2[quadIdx] = ((_tex2 & 0x00f00000) >> 20) | (_tex2 & 0x000000f0); - if (quadIdx == 3) { - packCompactQuad(); - } -#else unsigned short packedcol = ((col & 0xf8000000) >> 16) | ((col & 0x00fc0000) >> 13) | ((col & 0x0000f800) >> 11); @@ -805,47 +453,9 @@ void Tesselator::vertex(float x, float y, float z) { ipackedcol -= 32768; // -32768 to 32767 range ipackedcol &= 0xffff; -#if 0 - // AP - alpha cut out is expensive on vita. This will choose the correct - // data buffer depending on cut out enabled - std::int16_t* pShortData; - if (!alphaCutOutEnabled) { - pShortData = (std::int16_t*)&_array->data[p]; - } else { - pShortData = (std::int16_t*)&_array2->data[p2]; - } -#else std::int16_t* pShortData = (std::int16_t*)&_array->data[p]; -#endif -#if 0 - float tex2U = ((std::int16_t*)&_tex2)[1] + 8; - float tex2V = ((std::int16_t*)&_tex2)[0] + 8; - float colVal1 = ((col & 0xff000000) >> 24) / 256.0f; - float colVal2 = ((col & 0x00ff0000) >> 16) / 256.0f; - float colVal3 = ((col & 0x0000ff00) >> 8) / 256.0f; - - // pShortData[0] = convertFloatToHFloat(x + xo); - // pShortData[1] = convertFloatToHFloat(y + yo); - // pShortData[2] = convertFloatToHFloat(z + zo); - // pShortData[3] = convertFloatToHFloat(uu); - // pShortData[4] = convertFloatToHFloat(tex2U + colVal1); - // pShortData[5] = convertFloatToHFloat(tex2V + colVal2); - // pShortData[6] = convertFloatToHFloat(colVal3); - // pShortData[7] = convertFloatToHFloat(v); - - pShortData[0] = (((int)((x + xo) * 1024.0f)) & 0xffff); - pShortData[1] = (((int)((y + yo) * 1024.0f)) & 0xffff); - pShortData[2] = (((int)((z + zo) * 1024.0f)) & 0xffff); - pShortData[3] = ipackedcol; - pShortData[4] = (((int)(uu * 8192.0f)) & 0xffff); - pShortData[5] = (((int)(v * 8192.0f)) & 0xffff); - pShortData[6] = (((int)(tex2U * (8192.0f / 256.0f))) & 0xffff); - pShortData[7] = (((int)(tex2V * (8192.0f / 256.0f))) & 0xffff); - - p += 4; -#else pShortData[0] = (((int)((x + xo) * 1024.0f)) & 0xffff); pShortData[1] = (((int)((y + yo) * 1024.0f)) & 0xffff); pShortData[2] = (((int)((z + zo) * 1024.0f)) & 0xffff); @@ -854,77 +464,28 @@ void Tesselator::vertex(float x, float y, float z) { pShortData[5] = (((int)(v * 8192.0f)) & 0xffff); std::int16_t u2 = static_cast(_tex2 & 0xffff); std::int16_t v2 = static_cast((_tex2 >> 16) & 0xffff); -#ifdef __linux__ +#if defined(__linux__) packLinuxLightmapCoords(_tex2, u2, v2); logLinuxPackedLightmapCoords("compact", _tex2, u2, v2); #endif -#if 0 || 0 - // Optimisation - pack the second UVs into a single short (they could - // actually go in a byte), which frees up a short to store the x offset - // for this chunk in the vertex itself. This means that when rendering - // chunks, we don't need to update the vertex constants that specify the - // location for a chunk, when only the x offset has changed. - pShortData[6] = (u2 << 8) | v2; - pShortData[7] = -xoo; -#else pShortData[6] = u2; pShortData[7] = v2; -#endif -#if 0 - // AP - alpha cut out is expensive on vita. This will choose the correct - // data buffer depending on cut out enabled - if (!alphaCutOutEnabled) { - p += 4; - } else { - p2 += 4; - } -#else p += 4; -#endif -#endif -#endif -#if 0 - // AP - alpha cut out is expensive on vita. Increase the correct - // vertices depending on cut out enabled - if (!alphaCutOutEnabled) { - vertices++; - } else { - vertices2++; - } -#else vertices++; -#endif -#if 0 - if (vertices % 4 == 0 && - ((p >= size - 8 * 2) || - ((p / 2) >= - 65532))) // Max 65535 verts in D3D, so 65532 is the last point at - // the end of a quad to catch it -#else -#if 0 - // Max 65535 verts in D3D, so 65532 is the last point at the end of a - // quad to catch it - if ((!alphaCutOutEnabled && vertices % 4 == 0 && - ((p >= size - 4 * 4) || ((p / 4) >= 65532))) || - (alphaCutOutEnabled && vertices2 % 4 == 0 && - ((p2 >= size - 4 * 4) || ((p2 / 4) >= 65532)))) -#else if (vertices % 4 == 0 && ((p >= size - 4 * 4) || ((p / 4) >= 65532))) // Max 65535 verts in D3D, so 65532 is the last point at // the end of a quad to catch it -#endif -#endif { end(); tesselating = true; @@ -962,26 +523,17 @@ void Tesselator::vertex(float x, float y, float z) { _array->data[p + 6] = _normal; } if (hasTexture2) { -#if 0 - _array->data[p + 7] = ((_tex2 >> 16) & 0xffff) | (_tex2 << 16); -#else // 4jcraft: we will be lighting the blocks right in here -#if 0 || defined(__linux__) -#if 0 - std::int16_t tex2U = ((std::int16_t*)&_tex2)[1] + 8; - std::int16_t tex2V = ((std::int16_t*)&_tex2)[0] + 8; -#else +#if defined(__linux__) std::int16_t tex2U; std::int16_t tex2V; packLinuxLightmapCoords(_tex2, tex2U, tex2V); logLinuxPackedLightmapCoords("standard", _tex2, tex2U, tex2V); -#endif std::int16_t* pShortArray = (std::int16_t*)&_array->data[p + 7]; pShortArray[0] = tex2U; pShortArray[1] = tex2V; #else _array->data[p + 7] = _tex2; -#endif #endif } else { // -512 each for u/v will mean that the renderer will use global @@ -1020,85 +572,15 @@ void Tesselator::color(int c, int alpha) { void Tesselator::noColor() { _noColor = true; } -#if 0 -std::uint32_t _ConvertF32toX11Y11Z10N(float x, float y, float z) { - // 11111111111 X 0x000007FF - // 1111111111100000000000 Y 0x003FF800 - // 11111111110000000000000000000000 Z 0xFFC00000 - // ZZZZZZZZZZYYYYYYYYYYYXXXXXXXXXXX - // #defines for X11Y11Z10N format -#define X11Y11Z10N_X_MASK 0x000007FF -#define X11Y11Z10N_X_BITS 11 -#define X11Y11Z10N_X_SHIFT 0 - -#define X11Y11Z10N_Y_MASK 0x003FF800 -#define X11Y11Z10N_Y_BITS 11 -#define X11Y11Z10N_Y_SHIFT 11 - -#define X11Y11Z10N_Z_MASK 0xFFC00000 -#define X11Y11Z10N_Z_BITS 10 -#define X11Y11Z10N_Z_SHIFT 22 - -#ifndef _CONTENT_PACKAGE - if (x < -1.0f || x > 1.0f) { - printf( - "Value (%5.3f) should be in range [-1..1]. Conversion will clamp " - "to X11Y11Z10N.\n", - x); - } - if (y < -1.0f || y > 1.0f) { - printf( - "Value (%5.3f) should be in range [-1..1]. Conversion will clamp " - "to X11Y11Z10N.\n", - y); - } - if (z < -1.0f || z > 1.0f) { - printf( - "Value (%5.3f) should be in range [-1..1]. Conversion will clamp " - "to X11Y11Z10N.\n", - z); - } -#endif - - const std::uint32_t uX = - ((std::int32_t(std::max(std::min(((x) * 2047.f - 1.f) * 0.5f, 1023.f), - -1024.f)) & - (X11Y11Z10N_X_MASK >> X11Y11Z10N_X_SHIFT)) - << X11Y11Z10N_X_SHIFT); - const std::uint32_t uY = - ((std::int32_t(std::max(std::min(((y) * 2047.f - 1.f) * 0.5f, 1023.f), - -1024.f)) & - (X11Y11Z10N_Y_MASK >> X11Y11Z10N_Y_SHIFT)) - << X11Y11Z10N_Y_SHIFT); - const std::uint32_t uZ = - ((std::int32_t( - std::max(std::min(((z) * 1023.f - 1.f) * 0.5f, 511.f), -512.f)) & - (X11Y11Z10N_Z_MASK >> X11Y11Z10N_Z_SHIFT)) - << X11Y11Z10N_Z_SHIFT); - const std::uint32_t xyz = uX | uY | uZ; - return xyz; -} -#endif // 0 void Tesselator::normal(float x, float y, float z) { hasNormal = true; -#if 0 - _normal = _ConvertF32toX11Y11Z10N(x, y, z); -#elif 0 - // AP - casting a negative value to 'byte' on Vita results in zero. changed - // to a signed 8 value - std::int8_t xx = (std::int8_t)(x * 127); - std::int8_t yy = (std::int8_t)(y * 127); - std::int8_t zz = (std::int8_t)(z * 127); - _normal = (xx & 0xff) | ((yy & 0xff) << 8) | ((zz & 0xff) << 16); -#else // 4jcraft copied the PSVITA branch, read comment above std::int8_t xx = (std::int8_t)(x * 127); std::int8_t yy = (std::int8_t)(y * 127); std::int8_t zz = (std::int8_t)(z * 127); _normal = (xx & 0xff) | ((yy & 0xff) << 8) | ((zz & 0xff) << 16); -#endif } void Tesselator::offset(float xo, float yo, float zo) { @@ -1119,14 +601,5 @@ void Tesselator::addOffset(float x, float y, float z) { } bool Tesselator::hasMaxVertices() { -#if 0 - // On PS4, the way we push data to the command buffer has a maximum size of - // a single command packet of 2^16 bytes, and the effective maximum size - // will be slightly less than that due to packet headers and padding. - int bytes = vertices * (useCompactFormat360 ? 16 : 32); - - return bytes > 60 * 1024; -#else return false; -#endif } \ No newline at end of file diff --git a/Minecraft.Client/Rendering/Tesselator.h b/Minecraft.Client/Rendering/Tesselator.h index 78b291db3..7fc2c5556 100644 --- a/Minecraft.Client/Rendering/Tesselator.h +++ b/Minecraft.Client/Rendering/Tesselator.h @@ -73,16 +73,6 @@ private: unsigned int m_t2[4]; void packCompactQuad(); -#if 0 - // AP - alpha cut out is expensive on vita. Use this to defer primitives - // that use icons with alpha - bool alphaCutOutEnabled; - - // this is the cut out enabled vertex array - intArray* _array2; - int vertices2; - int p2; -#endif public: // 4J MGH - added, to calculate tight bounds @@ -147,31 +137,4 @@ public: bool setMipmapEnable(bool enable); // 4J added bool hasMaxVertices(); // 4J Added -#if 0 - // AP - alpha cut out is expensive on vita. Use this to defer primitives - // that use icons with alpha - void setAlphaCutOut(bool enable); - bool getCutOutFound(); - - // AP - a faster way of creating a compressed tile quad - void tileQuad(float x1, float y1, float z1, float u1, float v1, float r1, - float g1, float b1, int tex1, float x2, float y2, float z2, - float u2, float v2, float r2, float g2, float b2, int tex2, - float x3, float y3, float z3, float u3, float v3, float r3, - float g3, float b3, int tex3, float x4, float y4, float z4, - float u4, float v4, float r4, float g4, float b4, int tex4); - // AP - a faster way of creating rain quads - void tileRainQuad(float x1, float y1, float z1, float u1, float v1, - float x2, float y2, float z2, float u2, float v2, - float x3, float y3, float z3, float u3, float v3, - float x4, float y4, float z4, float u4, float v4, - float r1, float g1, float b1, float a1, float r2, - float g2, float b2, float a2, int tex1); - // AP - a faster way of creating particles - void tileParticleQuad(float x1, float y1, float z1, float u1, float v1, - float x2, float y2, float z2, float u2, float v2, - float x3, float y3, float z3, float u3, float v3, - float x4, float y4, float z4, float u4, float v4, - float r1, float g1, float b1, float a1); -#endif }; \ No newline at end of file diff --git a/Minecraft.Client/Rendering/glWrapper.cpp b/Minecraft.Client/Rendering/glWrapper.cpp index 19eb96d5e..b58a250d8 100644 --- a/Minecraft.Client/Rendering/glWrapper.cpp +++ b/Minecraft.Client/Rendering/glWrapper.cpp @@ -1,6 +1,6 @@ #include "../Platform/stdafx.h" -#ifndef __linux__ +#if !defined(__linux__) #include "../../Minecraft.World/IO/Streams/FloatBuffer.h" #include "../../Minecraft.World/IO/Streams/IntBuffer.h" @@ -57,11 +57,7 @@ int glGenLists(int count) { return RenderManager.CBuffCreate(count); } void glNewList(int index, int mode) { RenderManager.CBuffStart(index); } void glEndList(int vertexCount) { -#if 0 - RenderManager.CBuffEnd(vertexCount); -#else RenderManager.CBuffEnd(); -#endif } void glCallList(int index) { RenderManager.CBuffCall(index); } @@ -75,25 +71,8 @@ void glCallLists(IntBuffer* ib) { void glClear(int flags) { RenderManager.Clear(flags); } void glClearColor(float r, float g, float b, float a) { -#if 0 - int ir = (int)(r * 255.0f); - if (ir < 0) ir = 0; - if (ir > 255) ir = 255; - int ig = (int)(g * 255.0f); - if (ig < 0) ig = 0; - if (ig > 255) ig = 255; - int ib = (int)(b * 255.0f); - if (ib < 0) ib = 0; - if (ib > 255) ib = 255; - int ia = (int)(a * 255.0f); - if (ia < 0) ia = 0; - if (ia > 255) ia = 255; - - RenderManager.SetClearColour(D3DCOLOR_RGBA(ir, ig, ib, ia)); -#else float rgba[4] = {r, g, b, a}; RenderManager.SetClearColour(rgba); -#endif } void Display::update() {} @@ -208,11 +187,7 @@ void glAlphaFunc(int func, float param) { } void glDepthFunc(int func) { -#if 0 RenderManager.StateSetDepthFunc(func); -#else - RenderManager.StateSetDepthFunc(func); -#endif } void glTexParameteri(int target, int param, int value) { @@ -220,16 +195,12 @@ void glTexParameteri(int target, int param, int value) { } void glPolygonOffset(float factor, float units) { -#if 0 - RenderManager.StateSetDepthSlopeAndBias(factor, units); -#else // DirectX specifies these offsets in z buffer 0 to 1 sort of range, whereas // opengl seems to be in a 0 -> depth buffer size sort of range. The slope // factor is quite possibly different too. Magic factor for now anyway. const float magicFactor = 65536.0f; RenderManager.StateSetDepthSlopeAndBias(factor / magicFactor, units / magicFactor); -#endif } void glFogi(int param, int value) { diff --git a/Minecraft.Client/Textures/BufferedImage.cpp b/Minecraft.Client/Textures/BufferedImage.cpp index d6eafaac9..37a77ba3f 100644 --- a/Minecraft.Client/Textures/BufferedImage.cpp +++ b/Minecraft.Client/Textures/BufferedImage.cpp @@ -4,25 +4,6 @@ #include "../../Minecraft.World/Util/ArrayWithLength.h" #include "BufferedImage.h" -#if 0 -typedef struct { - unsigned int filesz; - unsigned short creator1; - unsigned short creator2; - unsigned int bmp_offset; - unsigned int header_sz; - unsigned int width; - unsigned int height; - unsigned short nplanes; - unsigned short bitspp; - unsigned int compress_type; - unsigned int bmp_bytesz; - int hres; - int vres; - unsigned int ncolors; - unsigned int nimpcolors; -} BITMAPINFOHEADER; -#endif BufferedImage::BufferedImage(int width, int height, int type) { data[0] = new int[width * height]; @@ -54,53 +35,6 @@ BufferedImage::BufferedImage(const std::wstring& File, wDrive = drive; if (wDrive.empty()) { -#if 0 - if (bTitleUpdateTexture) { - // Make the content package point to to the UPDATE: drive is needed -#ifdef _TU_BUILD - wDrive = L"UPDATE:\\"; -#else - - wDrive = L"GAME:\\res\\TitleUpdate\\"; -#endif - } else { - wDrive = L"GAME:\\"; - } -#else - -#if 0 - - char* pchUsrDir; - if (app.GetBootedFromDiscPatch()) { - const char* pchTextureName = wstringtofilename(File); - pchUsrDir = app.GetBDUsrDirPath(pchTextureName); - } else { - pchUsrDir = getUsrDirPath(); - } - - std::wstring wstr(pchUsrDir, pchUsrDir + strlen(pchUsrDir)); - - if (bTitleUpdateTexture) { - // Make the content package point to to the UPDATE: drive is needed - wDrive = wstr + L"\\Common\\res\\TitleUpdate\\"; - } else { - wDrive = wstr + L"/Common/"; - } -#elif 0 - - /*char *pchUsrDir=getUsrDirPath(); - - wstring wstr (pchUsrDir, pchUsrDir+strlen(pchUsrDir)); - - if(bTitleUpdateTexture) - { - // Make the content package point to to the UPDATE: drive is - needed wDrive= wstr + L"\\Common\\res\\TitleUpdate\\"; - } - else - { - wDrive= wstr + L"/Common/"; - }*/ if (bTitleUpdateTexture) { // Make the content package point to to the UPDATE: drive is needed @@ -108,16 +42,7 @@ BufferedImage::BufferedImage(const std::wstring& File, } else { wDrive = L"Common/"; } -#else - if (bTitleUpdateTexture) { - // Make the content package point to to the UPDATE: drive is needed - wDrive = L"Common\\res\\TitleUpdate\\"; - } else { - wDrive = L"Common/"; - } -#endif -#endif } for (int l = 0; l < 10; l++) { @@ -139,7 +64,7 @@ BufferedImage::BufferedImage(const std::wstring& File, const char* pchTextureName = wstringtofilename(name); -#ifndef _CONTENT_PACKAGE +#if !defined(_CONTENT_PACKAGE) app.DebugPrintf("\n--- Loading TEXTURE - %s\n\n", pchTextureName); #endif diff --git a/Minecraft.Client/Textures/Packs/AbstractTexturePack.cpp b/Minecraft.Client/Textures/Packs/AbstractTexturePack.cpp index abd49c931..a77888b66 100644 --- a/Minecraft.Client/Textures/Packs/AbstractTexturePack.cpp +++ b/Minecraft.Client/Textures/Packs/AbstractTexturePack.cpp @@ -36,69 +36,13 @@ std::wstring AbstractTexturePack::trim(std::wstring line) { } void AbstractTexturePack::loadIcon() { -#if 0 - // 4J Stu - Temporary only - constexpr int LOCATOR_SIZE = - 256; // Use this to allocate space to hold a ResourceLocator string - WCHAR szResourceLocator[LOCATOR_SIZE]; - - const ULONG_PTR c_ModuleHandle = (ULONG_PTR)GetModuleHandle(NULL); - swprintf(szResourceLocator, LOCATOR_SIZE, L"section://%X,%ls#%ls", - c_ModuleHandle, L"media", L"media/Graphics/TexturePackIcon.png"); - - unsigned int size = 0; - HRESULT hr = XuiResourceLoadAllNoLoc(szResourceLocator, &m_iconData, &size); - m_iconSize = static_cast(size); -#endif } void AbstractTexturePack::loadComparison() { -#if 0 - // 4J Stu - Temporary only - constexpr int LOCATOR_SIZE = - 256; // Use this to allocate space to hold a ResourceLocator string - WCHAR szResourceLocator[LOCATOR_SIZE]; - - const ULONG_PTR c_ModuleHandle = (ULONG_PTR)GetModuleHandle(NULL); - swprintf(szResourceLocator, LOCATOR_SIZE, L"section://%X,%ls#%ls", - c_ModuleHandle, L"media", - L"media/Graphics/DefaultPack_Comparison.png"); - - unsigned int size = 0; - HRESULT hr = - XuiResourceLoadAllNoLoc(szResourceLocator, &m_comparisonData, &size); - m_comparisonSize = static_cast(size); -#endif } void AbstractTexturePack::loadDescription() { // 4J Unused currently -#if 0 - InputStream *inputStream = NULL; - BufferedReader *br = NULL; - //try { - inputStream = getResourceImplementation(L"/pack.txt"); - br = new BufferedReader(new InputStreamReader(inputStream)); - desc1 = trim(br->readLine()); - desc2 = trim(br->readLine()); - //} catch (IOException ignored) { - //} finally { - // TODO [EB]: use IOUtils.closeSilently() - // try { - if (br != NULL) - { - br->close(); - delete br; - } - if (inputStream != NULL) - { - inputStream->close(); - delete inputStream; - } - // } catch (IOException ignored) { - // } - //} -#endif } void AbstractTexturePack::loadName() {} @@ -180,7 +124,7 @@ std::wstring AbstractTexturePack::getAnimationString( if (fileStream) { // Minecraft::getInstance()->getLogger().info("Found animation info for: // " + animationDefinitionFile); -#ifndef _CONTENT_PACKAGE +#if !defined(_CONTENT_PACKAGE) app.DebugPrintf("Found animation info for: %ls\n", animationDefinitionFile.c_str()); #endif @@ -214,26 +158,7 @@ BufferedImage* AbstractTexturePack::getImageResource( } void AbstractTexturePack::loadDefaultUI() { -#if 0 - // load from the .xzp file - const ULONG_PTR c_ModuleHandle = (ULONG_PTR)GetModuleHandle(NULL); - - // Load new skin - constexpr int LOCATOR_SIZE = - 256; // Use this to allocate space to hold a ResourceLocator string - WCHAR szResourceLocator[LOCATOR_SIZE]; - - swprintf(szResourceLocator, LOCATOR_SIZE, L"section://%X,%ls#%ls", - c_ModuleHandle, L"media", L"media/skin_Minecraft.xur"); - - XuiFreeVisuals(L""); - app.LoadSkin(szResourceLocator, NULL); // L"TexturePack"); - // CXuiSceneBase::GetInstance()->SetVisualPrefix(L"TexturePack"); - CXuiSceneBase::GetInstance()->SkinChanged( - CXuiSceneBase::GetInstance()->m_hObj); -#else ui.ReloadSkin(); -#endif } void AbstractTexturePack::loadColourTable() { @@ -243,17 +168,8 @@ void AbstractTexturePack::loadColourTable() { void AbstractTexturePack::loadDefaultColourTable() { // Load the file -#if 0 - // need to check if it's a BD build, so pass in the name - File coloursFile( - AbstractTexturePack::getPath( - true, app.GetBootedFromDiscPatch() ? "colours.col" : NULL) - .append(L"res/colours.col")); - -#else File coloursFile( AbstractTexturePack::getPath(true).append(L"res/colours.col")); -#endif if (coloursFile.exists()) { DWORD dataLength = coloursFile.length(); @@ -273,36 +189,6 @@ void AbstractTexturePack::loadDefaultColourTable() { } void AbstractTexturePack::loadDefaultHTMLColourTable() { -#if 0 - // load from the .xzp file - const ULONG_PTR c_ModuleHandle = (ULONG_PTR)GetModuleHandle(NULL); - - constexpr int LOCATOR_SIZE = - 256; // Use this to allocate space to hold a ResourceLocator string - WCHAR szResourceLocator[LOCATOR_SIZE]; - - // Try and load the HTMLColours.col based off the common XML first, before - // the deprecated xuiscene_colourtable - wsprintfW(szResourceLocator, L"section://%X,%s#%s", c_ModuleHandle, - L"media", L"media/HTMLColours.col"); - std::uint8_t* data; - unsigned int dataLength; - if (XuiResourceLoadAll(szResourceLocator, &data, &dataLength) == S_OK) { - m_colourTable->loadColoursFromData(data, dataLength); - - XuiFree(data); - } else { - wsprintfW(szResourceLocator, L"section://%X,%s#%s", c_ModuleHandle, - L"media", L"media/"); - HXUIOBJ hScene; - HRESULT hr = XuiSceneCreate(szResourceLocator, - L"xuiscene_colourtable.xur", NULL, &hScene); - - if (HRESULT_SUCCEEDED(hr)) { - loadHTMLColourTableFromXuiScene(hScene); - } - } -#else if (app.hasArchiveFile(L"HTMLColours.col")) { byteArray textColours = app.getArchiveFile(L"HTMLColours.col"); m_colourTable->loadColoursFromData(textColours.data, @@ -310,45 +196,12 @@ void AbstractTexturePack::loadDefaultHTMLColourTable() { delete[] textColours.data; } -#endif } -#if 0 -void AbstractTexturePack::loadHTMLColourTableFromXuiScene(HXUIOBJ hObj) { - HXUIOBJ child; - HRESULT hr = XuiElementGetFirstChild(hObj, &child); - - while (HRESULT_SUCCEEDED(hr) && child != NULL) { - LPCWSTR childName; - XuiElementGetId(child, &childName); - m_colourTable->setColour(childName, XuiTextElementGetText(child)); - - // eMinecraftTextColours colourIndex = eTextColor_NONE; - // for(int i = 0; i < (int)eTextColor_MAX; i++) - //{ - // if(wcscmp(HTMLColourTableElements[i],childName)==0) - // { - // colourIndex = (eMinecraftTextColours)i; - // break; - // } - // } - - // LPCWSTR stringValue = XuiTextElementGetText(child); - - // m_htmlColourTable[colourIndex] = XuiTextElementGetText(child); - - hr = XuiElementGetNext(child, &child); - } -} -#endif void AbstractTexturePack::loadUI() { loadColourTable(); -#if 0 - CXuiSceneBase::GetInstance()->SkinChanged( - CXuiSceneBase::GetInstance()->m_hObj); -#endif } void AbstractTexturePack::unloadUI() { diff --git a/Minecraft.Client/Textures/Packs/AbstractTexturePack.h b/Minecraft.Client/Textures/Packs/AbstractTexturePack.h index 072a1123a..a4f1939b1 100644 --- a/Minecraft.Client/Textures/Packs/AbstractTexturePack.h +++ b/Minecraft.Client/Textures/Packs/AbstractTexturePack.h @@ -78,9 +78,6 @@ protected: void loadDefaultUI(); void loadDefaultColourTable(); void loadDefaultHTMLColourTable(); -#if 0 - void loadHTMLColourTableFromXuiScene(HXUIOBJ hObj); -#endif public: virtual BufferedImage* getImageResource(const std::wstring& File, diff --git a/Minecraft.Client/Textures/Packs/DLCTexturePack.cpp b/Minecraft.Client/Textures/Packs/DLCTexturePack.cpp index 8750a5f57..b3286e0da 100644 --- a/Minecraft.Client/Textures/Packs/DLCTexturePack.cpp +++ b/Minecraft.Client/Textures/Packs/DLCTexturePack.cpp @@ -15,7 +15,7 @@ #include #include -#if 0 || defined _WINDOWS64 +#if defined(_WINDOWS64) #include "../../Platform/Common/XML/ATGXmlParser.h" #include "../../Platform/Common/XML/xmlFilesCallback.h" #endif @@ -65,10 +65,6 @@ DLCTexturePack::DLCTexturePack(std::uint32_t id, DLCPack* pack, m_stringTable = NULL; -#if 0 - m_pStreamedWaveBank = NULL; - m_pSoundBank = NULL; -#endif if (m_dlcInfoPack->doesPackContainFile( DLCManager::e_DLCType_LocalisationData, L"languages.loc")) { @@ -134,7 +130,7 @@ void DLCTexturePack::loadDescription() { std::wstring DLCTexturePack::getResource(const std::wstring& name) { // 4J Stu - We should never call this function -#ifndef __CONTENT_PACKAGE +#if !defined(__CONTENT_PACKAGE) __debugbreak(); #endif return L""; @@ -144,7 +140,7 @@ InputStream* DLCTexturePack::getResourceImplementation( const std::wstring& name) // throws IOException { // 4J Stu - We should never call this function -#ifndef _CONTENT_PACKAGE +#if !defined(_CONTENT_PACKAGE) __debugbreak(); if (hasFile(name)) return NULL; #endif @@ -211,48 +207,6 @@ void DLCTexturePack::loadColourTable() { } // Load the text colours -#if 0 - if (m_dlcDataPack != NULL && - m_dlcDataPack->doesPackContainFile(DLCManager::e_DLCType_UIData, - L"TexturePack.xzp")) { - DLCUIDataFile* dataFile = (DLCUIDataFile*)m_dlcDataPack->getFile( - DLCManager::e_DLCType_UIData, L"TexturePack.xzp"); - - std::uint32_t dwSize = 0; - std::uint8_t* pbData = dataFile->getData(dwSize); - - constexpr int LOCATOR_SIZE = - 256; // Use this to allocate space to hold a ResourceLocator string - WCHAR szResourceLocator[LOCATOR_SIZE]; - - // Try and load the HTMLColours.col based off the common XML first, - // before the deprecated xuiscene_colourtable - swprintf(szResourceLocator, LOCATOR_SIZE, - L"memory://%08X,%04X#HTMLColours.col", pbData, dwSize); - std::uint8_t* data; - unsigned int dataLength; - if (XuiResourceLoadAll(szResourceLocator, &data, &dataLength) == S_OK) { - m_colourTable->loadColoursFromData(data, dataLength); - - XuiFree(data); - } else { - swprintf(szResourceLocator, LOCATOR_SIZE, - L"memory://%08X,%04X#xuiscene_colourtable.xur", pbData, - dwSize); - HXUIOBJ hScene; - HRESULT hr = XuiSceneCreate(szResourceLocator, szResourceLocator, - NULL, &hScene); - - if (HRESULT_SUCCEEDED(hr)) { - loadHTMLColourTableFromXuiScene(hScene); - } else { - loadDefaultHTMLColourTable(); - } - } - } else { - loadDefaultHTMLColourTable(); - } -#else if (app.hasArchiveFile(L"HTMLColours.col")) { byteArray textColours = app.getArchiveFile(L"HTMLColours.col"); m_colourTable->loadColoursFromData(textColours.data, @@ -260,24 +214,16 @@ void DLCTexturePack::loadColourTable() { delete[] textColours.data; } -#endif } void DLCTexturePack::loadData() { int mountIndex = m_dlcInfoPack->GetDLCMountIndex(); if (mountIndex > -1) { -#if 0 - if (StorageManager.MountInstalledDLC(ProfileManager.GetPrimaryPad(), - mountIndex, - &DLCTexturePack::packMounted, this, - L"TPACK") != ERROR_IO_PENDING) -#else if (StorageManager.MountInstalledDLC(ProfileManager.GetPrimaryPad(), mountIndex, &DLCTexturePack::packMounted, this, "TPACK") != ERROR_IO_PENDING) -#endif { // corrupt DLC m_bHasLoadedData = true; @@ -334,29 +280,11 @@ int DLCTexturePack::packMounted(void* pParam, int iPad, std::uint32_t dwErr, // Load the UI data if (texturePack->m_dlcDataPack != NULL) { -#if 0 - File xzpPath( - getFilePath(texturePack->m_dlcInfoPack->GetPackID(), - std::wstring(L"TexturePack.xzp"))); - - if (xzpPath.exists()) { - std::uint8_t* pbData = NULL; - unsigned int bytesRead = 0; - if (ReadPortableBinaryFile(xzpPath, pbData, bytesRead)) { - DLCUIDataFile* uiDLCFile = - (DLCUIDataFile*)texturePack->m_dlcDataPack->addFile( - DLCManager::e_DLCType_UIData, - L"TexturePack.xzp"); - uiDLCFile->addData(pbData, bytesRead, true); - } - } -#else File archivePath( getFilePath(texturePack->m_dlcInfoPack->GetPackID(), std::wstring(L"media.arc"))); if (archivePath.exists()) texturePack->m_archiveFile = new ArchiveFile(archivePath); -#endif /** 4J-JEV: @@ -419,27 +347,6 @@ int DLCTexturePack::packMounted(void* pParam, int iPad, std::uint32_t dwErr, } // any audio data? -#if 0 - File audioXSBPath( - getFilePath(texturePack->m_dlcInfoPack->GetPackID(), - std::wstring(L"MashUp.xsb"))); - File audioXWBPath( - getFilePath(texturePack->m_dlcInfoPack->GetPackID(), - std::wstring(L"MashUp.xwb"))); - - if (audioXSBPath.exists() && audioXWBPath.exists()) { - texturePack->setHasAudio(true); - const char* pchXWBFilename = - wstringtofilename(audioXWBPath.getPath()); - Minecraft::GetInstance() - ->soundEngine->CreateStreamingWavebank( - pchXWBFilename, &texturePack->m_pStreamedWaveBank); - const char* pchXSBFilename = - wstringtofilename(audioXSBPath.getPath()); - Minecraft::GetInstance()->soundEngine->CreateSoundbank( - pchXSBFilename, &texturePack->m_pSoundBank); - } -#else // DLCPack *pack = texturePack->m_dlcInfoPack->GetParentPack(); if (pack->getDLCItemsCount(DLCManager::e_DLCType_Audio) > 0) { DLCAudioFile* dlcFile = (DLCAudioFile*)pack->getFile( @@ -465,7 +372,6 @@ int DLCTexturePack::packMounted(void* pParam, int iPad, std::uint32_t dwErr, iEndStart + iEndC, iEndStart + iEndC); // push the CD start to after } -#endif } texturePack->loadColourTable(); } @@ -473,9 +379,6 @@ int DLCTexturePack::packMounted(void* pParam, int iPad, std::uint32_t dwErr, // 4J-PB - we need to leave the texture pack mounted if it contained // streaming audio if (texturePack->hasAudio() == false) { -#if 0 - StorageManager.UnmountInstalledDLC("TPACK"); -#endif } } @@ -488,68 +391,24 @@ int DLCTexturePack::packMounted(void* pParam, int iPad, std::uint32_t dwErr, } void DLCTexturePack::loadUI() { -#if 0 - // Syntax: "memory://" + Address + "," + Size + "#" + File - // L"memory://0123ABCD,21A3#skin_default.xur" - - // Load new skin - if (m_dlcDataPack != NULL && - m_dlcDataPack->doesPackContainFile(DLCManager::e_DLCType_UIData, - L"TexturePack.xzp")) { - DLCUIDataFile* dataFile = (DLCUIDataFile*)m_dlcDataPack->getFile( - DLCManager::e_DLCType_UIData, L"TexturePack.xzp"); - - std::uint32_t dwSize = 0; - std::uint8_t* pbData = dataFile->getData(dwSize); - - constexpr int LOCATOR_SIZE = - 256; // Use this to allocate space to hold a ResourceLocator string - WCHAR szResourceLocator[LOCATOR_SIZE]; - swprintf(szResourceLocator, LOCATOR_SIZE, - L"memory://%08X,%04X#skin_Minecraft.xur", pbData, dwSize); - - XuiFreeVisuals(L""); - - HRESULT hr = app.LoadSkin(szResourceLocator, NULL); // L"TexturePack"); - if (HRESULT_SUCCEEDED(hr)) { - bUILoaded = true; - // CXuiSceneBase::GetInstance()->SetVisualPrefix(L"TexturePack"); - // CXuiSceneBase::GetInstance()->SkinChanged(CXuiSceneBase::GetInstance()->m_hObj); - } - } -#else if (m_archiveFile && m_archiveFile->hasFile(L"skin.swf")) { ui.ReloadSkin(); bUILoaded = true; } -#endif else { loadDefaultUI(); bUILoaded = true; } AbstractTexturePack::loadUI(); -#if 1 if (hasAudio() == false && !ui.IsReloadingSkin()) { -#if 0 - StorageManager.UnmountInstalledDLC(L"TPACK"); -#else StorageManager.UnmountInstalledDLC("TPACK"); -#endif } -#endif } void DLCTexturePack::unloadUI() { // Unload skin if (bUILoaded) { -#if 0 - XuiFreeVisuals(L"TexturePack"); - XuiFreeVisuals(L""); - CXuiSceneBase::GetInstance()->SetVisualPrefix(L""); - CXuiSceneBase::GetInstance()->SkinChanged( - CXuiSceneBase::GetInstance()->m_hObj); -#endif setHasAudio(false); } AbstractTexturePack::unloadUI(); diff --git a/Minecraft.Client/Textures/Packs/DLCTexturePack.h b/Minecraft.Client/Textures/Packs/DLCTexturePack.h index bcdd0b9d3..2d7db8443 100644 --- a/Minecraft.Client/Textures/Packs/DLCTexturePack.h +++ b/Minecraft.Client/Textures/Packs/DLCTexturePack.h @@ -35,10 +35,6 @@ public: } // Added for sound banks with MashUp packs -#if 0 - IXACT3WaveBank* m_pStreamedWaveBank; - IXACT3SoundBank* m_pSoundBank; -#endif protected: //@Override void loadIcon(); diff --git a/Minecraft.Client/Textures/Packs/DefaultTexturePack.cpp b/Minecraft.Client/Textures/Packs/DefaultTexturePack.cpp index 7c67804ee..413fcd9e1 100644 --- a/Minecraft.Client/Textures/Packs/DefaultTexturePack.cpp +++ b/Minecraft.Client/Textures/Packs/DefaultTexturePack.cpp @@ -13,26 +13,11 @@ DefaultTexturePack::DefaultTexturePack() } void DefaultTexturePack::loadIcon() { -#if 0 - // 4J Stu - Temporary only - constexpr int LOCATOR_SIZE = - 256; // Use this to allocate space to hold a ResourceLocator string - WCHAR szResourceLocator[LOCATOR_SIZE]; - - const ULONG_PTR c_ModuleHandle = (ULONG_PTR)GetModuleHandle(NULL); - swprintf(szResourceLocator, LOCATOR_SIZE, L"section://%X,%ls#%ls", - c_ModuleHandle, L"media", L"media/Graphics/TexturePackIcon.png"); - - unsigned int size = 0; - HRESULT hr = XuiResourceLoadAllNoLoc(szResourceLocator, &m_iconData, &size); - m_iconSize = size; -#else if (app.hasArchiveFile(L"Graphics\\TexturePackIcon.png")) { byteArray ba = app.getArchiveFile(L"Graphics\\TexturePackIcon.png"); m_iconData = ba.data; m_iconSize = static_cast(ba.length); } -#endif } void DefaultTexturePack::loadDescription() { @@ -52,48 +37,8 @@ InputStream* DefaultTexturePack::getResourceImplementation( { std::wstring wDrive = L""; // Make the content package point to to the UPDATE: drive is needed -#if 0 -#ifdef _TU_BUILD - wDrive = L"UPDATE:\\res"; -#else - - wDrive = L"GAME:\\res\\TitleUpdate\\res"; -#endif -#elif 0 - - char* pchUsrDir; - if (app.GetBootedFromDiscPatch()) { - const char* pchTextureName = wstringtofilename(name); - pchUsrDir = app.GetBDUsrDirPath(pchTextureName); - app.DebugPrintf( - "DefaultTexturePack::getResourceImplementation - texture %s - " - "Drive - %s\n", - pchTextureName, pchUsrDir); - } else { - const char* pchTextureName = wstringtofilename(name); - pchUsrDir = getUsrDirPath(); - app.DebugPrintf( - "DefaultTexturePack::getResourceImplementation - texture %s - " - "Drive - %s\n", - pchTextureName, pchUsrDir); - } - - std::wstring wstr(pchUsrDir, pchUsrDir + strlen(pchUsrDir)); - - wDrive = wstr + L"\\Common\\res\\TitleUpdate\\res"; -#elif 0 - - /* - char *pchUsrDir=getUsrDirPath(); - std::wstring wstr (pchUsrDir, pchUsrDir+strlen(pchUsrDir)); - - wDrive = wstr + L"Common\\res\\TitleUpdate\\res"; - */ - wDrive = L"Common\\res\\TitleUpdate\\res"; -#else wDrive = L"Common\\res\\TitleUpdate\\res"; -#endif InputStream* resource = InputStream::getResourceAsStream(wDrive + name); // InputStream *stream = // DefaultTexturePack::class->getResourceAsStream(name); if (stream == NULL) @@ -112,13 +57,5 @@ void DefaultTexturePack::loadUI() { } void DefaultTexturePack::unloadUI() { -#if 0 - // Unload skin - XuiFreeVisuals(L"TexturePack"); - XuiFreeVisuals(L""); - CXuiSceneBase::GetInstance()->SetVisualPrefix(L""); - CXuiSceneBase::GetInstance()->SkinChanged( - CXuiSceneBase::GetInstance()->m_hObj); -#endif AbstractTexturePack::unloadUI(); } diff --git a/Minecraft.Client/Textures/Packs/FileTexturePack.cpp b/Minecraft.Client/Textures/Packs/FileTexturePack.cpp index 5d0dee1b8..a7fa5f268 100644 --- a/Minecraft.Client/Textures/Packs/FileTexturePack.cpp +++ b/Minecraft.Client/Textures/Packs/FileTexturePack.cpp @@ -11,75 +11,22 @@ FileTexturePack::FileTexturePack(std::uint32_t id, File* file, } void FileTexturePack::unload(Textures* textures) { -#if 0 - super.unload(textures); - - try { - if (zipFile != null) zipFile.close(); - } - catch (IOException ignored) - { - } - zipFile = null; -#endif } InputStream* FileTexturePack::getResourceImplementation( const std::wstring& name) // throws IOException { -#if 0 - loadZipFile(); - - ZipEntry entry = zipFile.getEntry(name.substring(1)); - if (entry == null) { - throw new FileNotFoundException(name); - } - - return zipFile.getInputStream(entry); -#endif return NULL; } bool FileTexturePack::hasFile(const std::wstring& name) { -#if 0 - try { - loadZipFile(); - - return zipFile.getEntry(name.substring(1)) != null; - } catch (Exception e) { - return false; - } -#endif return false; } void FileTexturePack::loadZipFile() // throws IOException { -#if 0 - if (zipFile != null) { - return; - } - - zipFile = new ZipFile(file); -#endif } bool FileTexturePack::isTerrainUpdateCompatible() { -#if 0 - try { - loadZipFile(); - - Enumeration entries = zipFile.entries(); - while (entries.hasMoreElements()) { - ZipEntry entry = entries.nextElement(); - if (entry.getName().startsWith("textures/")) { - return true; - } - } - } catch (Exception ignored) { - } - boolean hasOldFiles = hasFile("terrain.png") || hasFile("gui/items.png"); - return !hasOldFiles; -#endif return false; } diff --git a/Minecraft.Client/Textures/Packs/FolderTexturePack.cpp b/Minecraft.Client/Textures/Packs/FolderTexturePack.cpp index a2c92685c..ba449e746 100644 --- a/Minecraft.Client/Textures/Packs/FolderTexturePack.cpp +++ b/Minecraft.Client/Textures/Packs/FolderTexturePack.cpp @@ -15,22 +15,10 @@ FolderTexturePack::FolderTexturePack(std::uint32_t id, const std::wstring& name, InputStream* FolderTexturePack::getResourceImplementation( const std::wstring& name) // throws IOException { -#if 0 - final File file = new File(this.file, name.substring(1)); - if (!file.exists()) { - throw new FileNotFoundException(name); - } - - return new BufferedInputStream(new FileInputStream(file)); -#endif std::wstring wDrive = L""; // Make the content package point to to the UPDATE: drive is needed -#if 0 - wDrive = L"GAME:\\DummyTexturePack\\res"; -#else wDrive = L"Common\\DummyTexturePack\\res"; -#endif InputStream* resource = InputStream::getResourceAsStream(wDrive + name); // InputStream *stream = // DefaultTexturePack::class->getResourceAsStream(name); if (stream == NULL) @@ -49,62 +37,18 @@ bool FolderTexturePack::hasFile(const std::wstring& name) { } bool FolderTexturePack::isTerrainUpdateCompatible() { -#if 0 - final File dir = new File(this.file, "textures/"); - final boolean hasTexturesFolder = dir.exists() && dir.isDirectory(); - final boolean hasOldFiles = hasFile("terrain.png") || hasFile("gui/items.png"); - return hasTexturesFolder || !hasOldFiles; -#endif return true; } std::wstring FolderTexturePack::getPath(bool bTitleUpdateTexture /*= false*/, const char* pchBDPatchFilename) { std::wstring wDrive; -#if 0 - wDrive = L"GAME:\\" + file->getPath() + L"\\"; -#else wDrive = L"Common\\" + file->getPath() + L"\\"; -#endif return wDrive; } void FolderTexturePack::loadUI() { -#if 0 - //"file://" + Drive + PathToXZP + "#" + PathInsideXZP - - // L"file://game:/ui.xzp#skin_default.xur" - - // Load new skin - if (hasFile(L"TexturePack.xzp")) { - constexpr int LOCATOR_SIZE = - 256; // Use this to allocate space to hold a ResourceLocator string - WCHAR szResourceLocator[LOCATOR_SIZE]; - - swprintf(szResourceLocator, LOCATOR_SIZE, - L"file://%lsTexturePack.xzp#skin_Minecraft.xur", - getPath().c_str()); - - XuiFreeVisuals(L""); - app.LoadSkin(szResourceLocator, NULL); // L"TexturePack"); - bUILoaded = true; - // CXuiSceneBase::GetInstance()->SetVisualPrefix(L"TexturePack"); - } - - AbstractTexturePack::loadUI(); -#endif } void FolderTexturePack::unloadUI() { -#if 0 - // Unload skin - if (bUILoaded) { - XuiFreeVisuals(L"TexturePack"); - XuiFreeVisuals(L""); - CXuiSceneBase::GetInstance()->SetVisualPrefix(L""); - CXuiSceneBase::GetInstance()->SkinChanged( - CXuiSceneBase::GetInstance()->m_hObj); - } - AbstractTexturePack::unloadUI(); -#endif } \ No newline at end of file diff --git a/Minecraft.Client/Textures/Packs/TexturePack.cpp b/Minecraft.Client/Textures/Packs/TexturePack.cpp index a9b3fe690..3501dea30 100644 --- a/Minecraft.Client/Textures/Packs/TexturePack.cpp +++ b/Minecraft.Client/Textures/Packs/TexturePack.cpp @@ -4,67 +4,13 @@ std::wstring TexturePack::getPath(bool bTitleUpdateTexture /*= false*/, const char* pchBDPatchFileName /*= NULL*/) { std::wstring wDrive; -#if 0 - if (bTitleUpdateTexture) { - // Make the content package point to to the UPDATE: drive is needed -#ifdef _TU_BUILD - wDrive = L"UPDATE:\\"; -#else - wDrive = L"GAME:\\res\\TitleUpdate\\"; -#endif - } else { - wDrive = L"GAME:\\"; - } -#else - -#if 0 - - // 4J-PB - we need to check for a BD patch - this is going to be an issue - // for full DLC texture packs (Halloween) - char* pchUsrDir = NULL; - if (app.GetBootedFromDiscPatch() && pchBDPatchFileName != NULL) { - pchUsrDir = app.GetBDUsrDirPath(pchBDPatchFileName); - std::wstring wstr(pchUsrDir, pchUsrDir + strlen(pchUsrDir)); - - if (bTitleUpdateTexture) { - wDrive = wstr + L"\\Common\\res\\TitleUpdate\\"; - - } else { - wDrive = wstr + L"/Common/"; - } - } else { - pchUsrDir = getUsrDirPath(); - - std::wstring wstr(pchUsrDir, pchUsrDir + strlen(pchUsrDir)); - - if (bTitleUpdateTexture) { - // Make the content package point to to the UPDATE: drive is needed - wDrive = wstr + L"\\Common\\res\\TitleUpdate\\"; - } else { - wDrive = wstr + L"/Common/"; - } - } - -#elif 0 - char* pchUsrDir = ""; // getUsrDirPath(); - std::wstring wstr(pchUsrDir, pchUsrDir + strlen(pchUsrDir)); - - if (bTitleUpdateTexture) { - // Make the content package point to to the UPDATE: drive is needed - wDrive = wstr + L"Common\\res\\TitleUpdate\\"; - } else { - wDrive = wstr + L"Common\\"; - } -#else if (bTitleUpdateTexture) { // Make the content package point to to the UPDATE: drive is needed wDrive = L"Common\\res\\TitleUpdate\\"; } else { wDrive = L"Common/"; } -#endif -#endif return wDrive; } diff --git a/Minecraft.Client/Textures/Packs/TexturePackRepository.cpp b/Minecraft.Client/Textures/Packs/TexturePackRepository.cpp index 5636dfe78..dc4e4decb 100644 --- a/Minecraft.Client/Textures/Packs/TexturePackRepository.cpp +++ b/Minecraft.Client/Textures/Packs/TexturePackRepository.cpp @@ -36,60 +36,18 @@ TexturePackRepository::TexturePackRepository(File workingDirectory, } void TexturePackRepository::addDebugPacks() { -#ifndef _CONTENT_PACKAGE +#if !defined(_CONTENT_PACKAGE) // File *file = new File(L"DummyTexturePack"); // Path to the test texture // pack m_dummyTexturePack = new // FolderTexturePack(FOLDER_TEST_TEXTURE_PACK_ID, L"FolderTestPack", file, // DEFAULT_TEXTURE_PACK); texturePacks->push_back(m_dummyTexturePack); // cacheById[m_dummyTexturePack->getId()] = m_dummyTexturePack; -#if 0 - File packedTestFile(L"GAME:\\DummyTexturePack\\TexturePack.pck"); - if (packedTestFile.exists()) { - DLCPack* pack = app.m_dlcManager.getPack(L"DLCTestPack"); - - if (pack != NULL && pack->IsCorrupt()) { - app.m_dlcManager.removePack(pack); - pack = NULL; - } - - if (pack == NULL) { - wprintf(L"Pack \"%ls\" is not installed, so adding it\n", - L"DLCTestPack"); - pack = new DLCPack(L"DLCTestPack", 0xffffffff); - unsigned int dwFilesProcessed = 0; - if (app.m_dlcManager.readDLCDataFile( - dwFilesProcessed, - "GAME:\\DummyTexturePack\\TexturePack.pck", pack)) { - // 4J Stu - Don't need to do this, as the readDLCDataFile now - // adds texture packs - // m_dummyDLCTexturePack = addTexturePackFromDLC(pack, - // DLC_TEST_TEXTURE_PACK_ID); //new DLCTexturePack(0xFFFFFFFE, - // L"DLCTestPack", pack, DEFAULT_TEXTURE_PACK); - app.m_dlcManager.addPack(pack); - } else { - delete pack; - } - } - } - -#endif // 0 -#endif // _CONTENT_PACKAGE +#endif } void TexturePackRepository::createWorkingDirecoryUnlessExists() { // 4J Unused -#if 0 - if (!workDir.isDirectory()) { - workDir.delete(); - workDir.mkdirs(); - } - - if (!multiplayerDir.isDirectory()) { - multiplayerDir.delete(); - multiplayerDir.mkdirs(); - } -#endif } bool TexturePackRepository::selectSkin(TexturePack* skin) { @@ -106,38 +64,12 @@ bool TexturePackRepository::selectSkin(TexturePack* skin) { void TexturePackRepository::selectWebSkin(const std::wstring& url) { app.DebugPrintf( "TexturePackRepository::selectWebSkin is not implemented\n"); -#if 0 - String filename = url.substring(url.lastIndexOf("/") + 1); - if (filename.contains("?")) filename = filename.substring(0, filename.indexOf("?")); - if (!filename.endsWith(".zip")) return; - File file = new File(multiplayerDir, filename); - downloadWebSkin(url, file); -#endif } void TexturePackRepository::downloadWebSkin(const std::wstring& url, File file) { app.DebugPrintf( "TexturePackRepository::selectWebSkin is not implemented\n"); -#if 0 - Map headers = new HashMap(); - final ProgressScreen listener = new ProgressScreen(); - headers.put("X-Minecraft-Username", minecraft.user.name); - headers.put("X-Minecraft-Version", SharedConstants.VERSION_STRING); - headers.put("X-Minecraft-Supported-Resolutions", "16"); - usingWeb = true; - - minecraft.setScreen(listener); - - HttpUtil.downloadTo(file, url, new HttpUtil.DownloadSuccessRunnable() { - public void onDownloadSuccess(File file) { - if (!usingWeb) return; - - selected = new FileTexturePack(getIdOrNull(file), file, DEFAULT_TEXTURE_PACK); - minecraft.delayTextureReload(); - } - }, headers, MAX_WEB_FILESIZE, listener); -#endif } bool TexturePackRepository::isUsingWebSkin() { return usingWeb; } @@ -151,93 +83,16 @@ void TexturePackRepository::resetWebSkin() { void TexturePackRepository::updateList() { // 4J Stu - We don't ever want to completely refresh the lists, we keep them // up-to-date as we go -#if 0 - std::vector *currentPacks = new std::vector; - currentPacks->push_back(DEFAULT_TEXTURE_PACK); - cacheById[DEFAULT_TEXTURE_PACK->getId()] = DEFAULT_TEXTURE_PACK; -#ifndef _CONTENT_PACKAGE - currentPacks->push_back(m_dummyTexturePack); - cacheById[m_dummyTexturePack->getId()] = m_dummyTexturePack; - - if(m_dummyDLCTexturePack != NULL) - { - currentPacks->push_back(m_dummyDLCTexturePack); - cacheById[m_dummyDLCTexturePack->getId()] = m_dummyDLCTexturePack; - } - - //selected = m_dummyTexturePack; -#endif - selected = DEFAULT_TEXTURE_PACK; - - - // 4J Unused - for (File file : getWorkDirContents()) - { - final String id = getIdOrNull(file); - if (id == null) continue; - - TexturePack pack = cacheById.get(id); - if (pack == null) { - pack = file.isDirectory() ? new FolderTexturePack(id, file, DEFAULT_TEXTURE_PACK) : new FileTexturePack(id, file, DEFAULT_TEXTURE_PACK); - cacheById.put(id, pack); - } - - if (pack.getName().equals(minecraft.options.skin)) { - selected = pack; - } - currentPacks.add(pack); - } - - // 4J - was texturePacks.removeAll(currentPacks); - AUTO_VAR(itEnd, currentPacks->end()); - for( std::vector::iterator it1 = currentPacks->begin(); it1 != itEnd; it1++ ) - { - for( std::vector::iterator it2 = texturePacks->begin(); it2 != texturePacks->end(); it2++ ) - { - if( *it1 == *it2 ) - { - it2 = texturePacks->erase(it2); - } - } - } - - itEnd = texturePacks->end(); - for( std::vector::iterator it = texturePacks->begin(); it != itEnd; it++ ) - { - TexturePack *pack = *it; - pack->unload(minecraft->textures); - cacheById.erase(pack->getId()); - } - - delete texturePacks; - texturePacks = currentPacks; -#endif } std::wstring TexturePackRepository::getIdOrNull(File file) { app.DebugPrintf("TexturePackRepository::getIdOrNull is not implemented\n"); -#if 0 - if (file.isFile() && file.getName().toLowerCase().endsWith(".zip")) { - return file.getName() + ":" + file.length() + ":" + file.lastModified(); - } else if (file.isDirectory() && new File(file, "pack.txt").exists()) { - return file.getName() + ":folder:" + file.lastModified(); - } - - return NULL; -#endif return L""; } std::vector TexturePackRepository::getWorkDirContents() { app.DebugPrintf( "TexturePackRepository::getWorkDirContents is not implemented\n"); -#if 0 - if (workDir.exists() && workDir.isDirectory()) { - return Arrays.asList(workDir.listFiles()); - } - - return Collections.emptyList(); -#endif return std::vector(); } @@ -256,32 +111,12 @@ TexturePack* TexturePackRepository::getSelected() { bool TexturePackRepository::shouldPromptForWebSkin() { app.DebugPrintf( "TexturePackRepository::shouldPromptForWebSkin is not implemented\n"); -#if 0 - if (!minecraft.options.serverTextures) return false; - ServerData data = minecraft.getCurrentServer(); - - if (data == null) { - return true; - } else { - return data.promptOnTextures(); - } -#endif return false; } bool TexturePackRepository::canUseWebSkin() { app.DebugPrintf( "TexturePackRepository::canUseWebSkin is not implemented\n"); -#if 0 - if (!minecraft.options.serverTextures) return false; - ServerData data = minecraft.getCurrentServer(); - - if (data == null) { - return false; - } else { - return data.allowTextures(); - } -#endif return false; } @@ -328,7 +163,7 @@ bool TexturePackRepository::selectTexturePackById(std::uint32_t id) { } else { app.DebugPrintf( "Failed to select texture pack %d as it is not in the list\n", id); -#ifndef _CONTENT_PACKAGE +#if !defined(_CONTENT_PACKAGE) // TODO - 4J Stu: We should report this to the player in some way //__debugbreak(); #endif @@ -364,7 +199,7 @@ TexturePack* TexturePackRepository::addTexturePackFromDLC(DLCPack* dlcPack, texturePacks->push_back(newPack); cacheById[parentId] = newPack; -#ifndef _CONTENT_PACKAGE +#if !defined(_CONTENT_PACKAGE) if (dlcPack->hasPurchasedFile(DLCManager::e_DLCType_TexturePack, L"")) { wprintf(L"Added new FULL DLCTexturePack: %ls - id=%u\n", dlcPack->getName().c_str(), parentId); diff --git a/Minecraft.Client/Textures/Stitching/PreStitchedTextureMap.cpp b/Minecraft.Client/Textures/Stitching/PreStitchedTextureMap.cpp index f4be6d313..574a3c733 100644 --- a/Minecraft.Client/Textures/Stitching/PreStitchedTextureMap.cpp +++ b/Minecraft.Client/Textures/Stitching/PreStitchedTextureMap.cpp @@ -92,18 +92,6 @@ void PreStitchedTextureMap::stitch() { std::wstring drive = L""; // 4J-PB - need to check for BD patched files -#if 0 - const char* pchName = wstringtofilename(filename); - if (app.GetBootedFromDiscPatch() && app.IsFileInPatchList(pchName)) { - if (texturePack->hasFile(L"res/" + filename, false)) { - drive = texturePack->getPath(true, pchName); - } else { - drive = Minecraft::GetInstance()->skins->getDefault()->getPath( - true, pchName); - texturePack = Minecraft::GetInstance()->skins->getDefault(); - } - } else -#endif if (texturePack->hasFile(L"res/" + filename, false)) { drive = texturePack->getPath(true); } else { @@ -157,42 +145,6 @@ void PreStitchedTextureMap::stitch() { stitchResult->writeAsPNG(L"debug.stitched_" + name + L".png"); stitchResult->updateOnGPU(); -#if 0 - // AP - alpha cut out is expensive on vita so we mark which icons actually - // require it - DWORD* data = (DWORD*)this->getStitchedTexture()->getData()->getBuffer(); - int Width = this->getStitchedTexture()->getWidth(); - int Height = this->getStitchedTexture()->getHeight(); - for (AUTO_VAR(it, texturesByName.begin()); it != texturesByName.end(); - ++it) { - StitchedTexture* preStitched = (StitchedTexture*)it->second; - - bool Found = false; - int u0 = preStitched->getU0() * Width; - int u1 = preStitched->getU1() * Width; - int v0 = preStitched->getV0() * Height; - int v1 = preStitched->getV1() * Height; - - // check all the texels for this icon. If ANY are transparent we mark it - // as 'cut out' - for (int v = v0; v < v1; v += 1) { - for (int u = u0; u < u1; u += 1) { - // is this texel alpha value < 0.1 - if ((data[v * Width + u] & 0xff000000) < 0x20000000) { - // this texel is transparent. Mark the icon as such and bail - preStitched->setFlags(Icon::IS_ALPHA_CUT_OUT); - Found = true; - break; - } - } - - if (Found) { - // move onto the next icon - break; - } - } - } -#endif } void PreStitchedTextureMap::makeTextureAnimated(TexturePack* texturePack, @@ -220,7 +172,7 @@ void PreStitchedTextureMap::makeTextureAnimated(TexturePack* texturePack, Texture* first = frames->at(0); -#ifndef _CONTENT_PACKAGE +#if !defined(_CONTENT_PACKAGE) if (first->getWidth() != tex->getWidth() || first->getHeight() != tex->getHeight()) { app.DebugPrintf("%ls - first w - %d, h - %d, tex w - %d, h - %d\n", @@ -243,16 +195,11 @@ void PreStitchedTextureMap::makeTextureAnimated(TexturePack* texturePack, } StitchedTexture* PreStitchedTextureMap::getTexture(const std::wstring& name) { -#ifndef _CONTENT_PACKAGE +#if !defined(_CONTENT_PACKAGE) app.DebugPrintf("Not implemented!\n"); __debugbreak(); #endif return NULL; -#if 0 - StitchedTexture *result = texturesByName.find(name)->second; - if (result == NULL) result = missingPosition; - return result; -#endif } void PreStitchedTextureMap::cycleAnimationFrames() { @@ -271,7 +218,7 @@ Icon* PreStitchedTextureMap::registerIcon(const std::wstring& name) { Icon* result = NULL; if (name.empty()) { app.DebugPrintf("Don't register NULL\n"); -#ifndef _CONTENT_PACKAGE +#if !defined(_CONTENT_PACKAGE) __debugbreak(); #endif result = missingPosition; @@ -282,7 +229,7 @@ Icon* PreStitchedTextureMap::registerIcon(const std::wstring& name) { if (it != texturesByName.end()) result = it->second; if (result == NULL) { -#ifndef _CONTENT_PACKAGE +#if !defined(_CONTENT_PACKAGE) app.DebugPrintf("Could not find uv data for icon %ls\n", name.c_str()); __debugbreak(); #endif diff --git a/Minecraft.Client/Textures/Texture.cpp b/Minecraft.Client/Textures/Texture.cpp index fc078dc56..165990201 100644 --- a/Minecraft.Client/Textures/Texture.cpp +++ b/Minecraft.Client/Textures/Texture.cpp @@ -4,16 +4,6 @@ #include "TextureManager.h" #include "Texture.h" -#if 0 -#include "PS3/SPU_Tasks/Texture_blit/Texture_blit.h" -#include "C4JSpursJob.h" -static const int sc_maxTextureBlits = 256; -static Texture_blit_DataIn g_textureBlitDataIn[sc_maxTextureBlits] - __attribute__((__aligned__(16))); -static int g_currentTexBlit = 0; -C4JSpursJobQueue::Port* g_texBlitJobQueuePort; -// #define DISABLE_SPU_CODE -#endif //0 #define MAX_MIP_LEVELS 5 @@ -27,11 +17,6 @@ Texture::Texture(const std::wstring& name, int mode, int width, int height, void Texture::_init(const std::wstring& name, int mode, int width, int height, int depth, int wrapMode, int format, int minFilter, int magFilter, bool mipMap) { -#if 0 - if (g_texBlitJobQueuePort == NULL) - g_texBlitJobQueuePort = - new C4JSpursJobQueue::Port("C4JSpursJob_Texture_blit"); -#endif this->name = name; this->mode = mode; this->width = width; @@ -80,13 +65,6 @@ void Texture::_init(const std::wstring& name, int mode, int width, int height, if (m_iMipLevels > MAX_MIP_LEVELS) m_iMipLevels = MAX_MIP_LEVELS; } -#if 0 - // vita doesn't have a mipmap conditional shader because it's too slow so - // make sure this texture don't look awful at the lower mips - if (name == L"terrain") { - m_iMipLevels = 3; - } -#endif if (mode != TM_CONTAINER) { glId = glGenTextures(); @@ -116,11 +94,7 @@ void Texture::_init(const std::wstring& name, int mode, int width, int height, for (int index = 0; index < tempBytes.length; index++) { tempBytes[index] = 0; } -#if 0 - data[0] = new ByteBuffer_IO(tempBytes.length); -#else data[0] = ByteBuffer::allocateDirect(tempBytes.length); -#endif // __{S3__ data[0]->clear(); data[0]->put(tempBytes); data[0]->position(0)->limit(tempBytes.length); @@ -137,11 +111,7 @@ void Texture::_init(const std::wstring& name, int mode, int width, int height, tempBytes[index] = 0; } -#if 0 - data[level] = new ByteBuffer_IO(tempBytes.length); -#else data[level] = ByteBuffer::allocateDirect(tempBytes.length); -#endif // 0 data[level]->clear(); data[level]->put(tempBytes); data[level]->position(0)->limit(tempBytes.length); @@ -232,124 +202,10 @@ void Texture::fill(const Rect2i* rect, int color) { void Texture::writeAsBMP(const std::wstring& name) { // 4J Don't need -#if 0 - if (type == GL_TEXTURE_3D) - { - return; - } - - File *outFile = new File(name); - if (outFile.exists()) - { - outFile.delete(); - } - - DataOutputStream *outStream = NULL; - //try { - outStream = new DataOutputStream(new FileOutputStream(outFile)); - //} catch (IOException e) { - // Unable to open file for writing for some reason - // return; - //} - - //try { - // Write the header - outStream->writeShort((short)0x424d); // 0x0000: ID - 'BM' - int byteSize = width * height * 4 + 54; - outStream->writeByte((uint8_t)(byteSize >> 0)); // 0x0002: Raw file size - outStream->writeByte((uint8_t)(byteSize >> 8)); - outStream->writeByte((uint8_t)(byteSize >> 16)); - outStream->writeByte((uint8_t)(byteSize >> 24)); - outStream->writeInt(0); // 0x0006: Reserved - outStream->writeByte(54); // 0x000A: Start of pixel data - outStream->writeByte(0); - outStream->writeByte(0); - outStream->writeByte(0); - outStream->writeByte(40); // 0x000E: Size of secondary header - outStream->writeByte(0); - outStream->writeByte(0); - outStream->writeByte(0); - outStream->writeByte((uint8_t)(width >> 0)); // 0x0012: Image width, in pixels - outStream->writeByte((uint8_t)(width >> 8)); - outStream->writeByte((uint8_t)(width >> 16)); - outStream->writeByte((uint8_t)(width >> 24)); - outStream->writeByte((uint8_t)(height >> 0)); // 0x0016: Image height, in pixels - outStream->writeByte((uint8_t)(height >> 8)); - outStream->writeByte((uint8_t)(height >> 16)); - outStream->writeByte((uint8_t)(height >> 24)); - outStream->writeByte(1); // 0x001A: Number of color planes, must be 1 - outStream->writeByte(0); - outStream->writeByte(32); // 0x001C: Bit depth (32bpp) - outStream->writeByte(0); - outStream->writeInt(0); // 0x001E: Compression mode (BI_RGB, uncompressed) - int bufSize = width * height * 4; - outStream->writeInt((uint8_t)(bufSize >> 0)); // 0x0022: Raw size of bitmap data - outStream->writeInt((uint8_t)(bufSize >> 8)); - outStream->writeInt((uint8_t)(bufSize >> 16)); - outStream->writeInt((uint8_t)(bufSize >> 24)); - outStream->writeInt(0); // 0x0026: Horizontal resolution in ppm - outStream->writeInt(0); // 0x002A: Vertical resolution in ppm - outStream->writeInt(0); // 0x002E: Palette size (0 to match bit depth) - outStream->writeInt(0); // 0x0032: Number of important colors, 0 for all - - // Pixels follow in inverted Y order - uint8_t[] bytes = new uint8_t[width * height * 4]; - data.position(0); - data.get(bytes); - for (int y = height - 1; y >= 0; y--) - { - int line = y * width * 4; - for (int x = 0; x < width; x++) - { - outStream->writeByte(bytes[line + x * 4 + 2]); - outStream->writeByte(bytes[line + x * 4 + 1]); - outStream->writeByte(bytes[line + x * 4 + 0]); - outStream->writeByte(bytes[line + x * 4 + 3]); - } - } - - outStream->close(); - //} catch (IOException e) { - // Unable to write to the file for some reason - // return; - //} -#endif } void Texture::writeAsPNG(const std::wstring& filename) { // 4J Don't need -#if 0 - BufferedImage *image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); - ByteBuffer *buffer = this->getData(); - uint8_t[] bytes = new uint8_t[width * height * 4]; - - buffer.position(0); - buffer.get(bytes); - - for (int x = 0; x < width; x++) - { - for (int y = 0; y < height; y++) - { - int pos = (y * width * 4) + x * 4; - int col = 0; - - col |= (bytes[pos + 2] & 0xFF) << 0; - col |= (bytes[pos + 1] & 0xFF) << 8; - col |= (bytes[pos + 0] & 0xFF) << 16; - col |= (bytes[pos + 3] & 0xFF) << 24; - - image.setRGB(x, y, col); - } - } - - data.position(width * height * 4); - - //try { - ImageIO::write(image, L"png", new File(Minecraft.getWorkingDirectory(), filename)); - //} catch (IOException e) { - // e.printStackTrace(); - //} -#endif } void Texture::blit(int x, int y, Texture* source) { blit(x, y, source, false); } @@ -376,63 +232,6 @@ void Texture::blit(int x, int y, Texture* source, bool rotated) { data[level]->position(0); srcBuffer->position(0); -#if 0 && !defined DISABLE_SPU_CODE - if (g_texBlitJobQueuePort->hasCompleted()) { - // all outstanding blits have completed, so reset to the start of - // the blit list - g_currentTexBlit = 0; - } - Texture_blit_DataIn& dataIn = g_textureBlitDataIn[g_currentTexBlit]; - g_currentTexBlit++; - if (g_currentTexBlit >= sc_maxTextureBlits) { - app.DebugPrintf( - "ran out of tex blit slots, stalling for completion\n"); - g_texBlitJobQueuePort->waitForCompletion(); - g_currentTexBlit = 0; - } - dataIn.pSrcData = srcBuffer->getBuffer(); - dataIn.pDstData = data[level]->getBuffer(); - dataIn.yy = yy; - dataIn.xx = xx; - dataIn.hh = hh; - dataIn.ww = ww; - dataIn.shh = shh; - dataIn.sww = sww; - dataIn.rotated = rotated; - - C4JSpursJob_Texture_blit blitJob(&dataIn); - g_texBlitJobQueuePort->submitJob(&blitJob); - // p.waitForCompletion(); - -#elif 0 - unsigned int* src = (unsigned int*)srcBuffer->getBuffer(); - unsigned int* dst = (unsigned int*)data[level]->getBuffer(); - - for (int srcY = 0; srcY < shh; srcY++) { - int dstY = yy + srcY; - int srcLine = srcY * sww; - int dstLine = dstY * ww; - - if (rotated) { - dstY = yy + (shh - srcY); - } - - if (!rotated) { - memcpy(dst + dstLine + xx, src + srcLine, sww * 4); - } else { - for (int srcX = 0; srcX < sww; srcX++) { - int dstPos = dstLine + (srcX + xx); - int srcPos = srcLine + srcX; - - if (rotated) { - dstPos = (xx + srcX * ww) + dstY; - } - - dst[dstPos] = src[srcPos]; - } - } - } -#else for (int srcY = 0; srcY < shh; srcY++) { int dstY = yy + srcY; @@ -459,7 +258,6 @@ void Texture::blit(int x, int y, Texture* source, bool rotated) { } // Don't delete this, as it belongs to the source texture // delete srcBuffer; -#endif data[level]->position(ww * hh * 4); } @@ -553,11 +351,7 @@ void Texture::transferFromImage(BufferedImage* image) { // int byteRemapRGBA[] = { 0, 1, 2, 3 }; // int byteRemapBGRA[] = { 2, 1, 0, 3 }; // #else -#if 0 - int byteRemapRGBA[] = {0, 1, 2, 3}; -#else int byteRemapRGBA[] = {3, 0, 1, 2}; -#endif int byteRemapBGRA[] = {3, 2, 1, 0}; // #endif int* byteRemap = ((format == TFMT_BGRA) ? byteRemapBGRA : byteRemapRGBA); @@ -593,11 +387,7 @@ void Texture::transferFromImage(BufferedImage* image) { } MemSect(51); -#if 0 - data[0] = new ByteBuffer_IO(tempBytes.length); -#else data[0] = ByteBuffer::allocateDirect(tempBytes.length); -#endif // __{S3__ MemSect(0); data[0]->clear(); data[0]->put(tempBytes); @@ -647,7 +437,6 @@ void Texture::transferFromImage(BufferedImage* image) { ((x * 2 + 1) + (y * 2 + 1) * ow) * 4); int c3 = data[level - 1]->getInt( ((x * 2 + 0) + (y * 2 + 1) * ow) * 4); -#if 1 // 4J - convert our RGBA texels to ARGB that crispBlend // is expecting 4jcraft, added uint cast to pervent // shift of neg int @@ -659,7 +448,6 @@ void Texture::transferFromImage(BufferedImage* image) { ((c2 >> 8) & 0x00ffffff) | ((unsigned int)c2 << 24); c3 = ((c3 >> 8) & 0x00ffffff) | ((unsigned int)c3 << 24); -#endif int col = crispBlend(crispBlend(c0, c1), crispBlend(c2, c3)); // 4J - and back from ARGB -> RGBA @@ -684,11 +472,7 @@ void Texture::transferFromImage(BufferedImage* image) { } MemSect(51); -#if 0 - data[level] = new ByteBuffer_IO(tempBytes.length); -#else data[level] = ByteBuffer::allocateDirect(tempBytes.length); -#endif // __{S3__ MemSect(0); data[level]->clear(); data[level]->put(tempBytes); @@ -795,57 +579,24 @@ void Texture::updateOnGPU() { if (!m_bInitialised) { RenderManager.TextureSetTextureLevels(m_iMipLevels); // 4J added -#if 0 - // AP - replace the dynamic ram buffer to one that points to a newly - // allocated video ram texture buffer. This means we don't have to - // memcpy the ram based buffer to it any more inside - // RenderManager.TextureDataUpdate - unsigned char* newData = - RenderManager.TextureData(width, height, data[0]->getBuffer(), 0, - C4JRender::TEXTURE_FORMAT_RxGyBzAw); - ByteBuffer* oldBuffer = data[0]; - data[0] = new ByteBuffer(data[0]->getSize(), (uint8_t*)newData); - delete oldBuffer; - newData += width * height * 4; -#else RenderManager.TextureData(width, height, data[0]->getBuffer(), 0, C4JRender::TEXTURE_FORMAT_RxGyBzAw); -#endif if (mipmapped) { for (int level = 1; level < m_iMipLevels; level++) { int levelWidth = width >> level; int levelHeight = height >> level; -#if 0 - // AP - replace the dynamic ram buffer to one that points to a - // newly allocated video ram texture buffer. This means we don't - // have to memcpy the ram based buffer to it any more inside - // RenderManager.TextureDataUpdate - RenderManager.TextureDataUpdate(0, 0, levelWidth, levelHeight, - data[level]->getBuffer(), - level); - ByteBuffer* oldBuffer = data[level]; - data[level] = - new ByteBuffer(data[level]->getSize(), (uint8_t*)newData); - delete oldBuffer; - newData += levelWidth * levelHeight * 4; -#else RenderManager.TextureData(levelWidth, levelHeight, data[level]->getBuffer(), level, C4JRender::TEXTURE_FORMAT_RxGyBzAw); -#endif } } m_bInitialised = true; } else { -#if 0 - RenderManager.TextureDataUpdate(data[0]->getBuffer(), 0); -#else RenderManager.TextureDataUpdate(0, 0, width, height, data[0]->getBuffer(), 0); -#endif if (mipmapped) { if (RenderManager.TextureGetTextureLevels() > 1) { @@ -853,14 +604,9 @@ void Texture::updateOnGPU() { int levelWidth = width >> level; int levelHeight = height >> level; -#if 0 - RenderManager.TextureDataUpdate(data[level]->getBuffer(), - level); -#else RenderManager.TextureDataUpdate( 0, 0, levelWidth, levelHeight, data[level]->getBuffer(), level); -#endif } } } diff --git a/Minecraft.Client/Textures/Texture.h b/Minecraft.Client/Textures/Texture.h index b626cbe86..ce43a4862 100644 --- a/Minecraft.Client/Textures/Texture.h +++ b/Minecraft.Client/Textures/Texture.h @@ -4,9 +4,6 @@ class Rect2i; class ByteBuffer; class BufferedImage; -#if 0 -class ByteBuffer_IO; -#endif class Texture { public: @@ -58,11 +55,7 @@ private: bool immediateUpdate; bool updated; int m_iMipLevels; -#if 0 - ByteBuffer_IO* data[10]; -#else ByteBuffer* data[10]; // Arrays for mipmaps - NULL if not used -#endif public: bool m_bInitialised; // 4J Added diff --git a/Minecraft.Client/Textures/TextureManager.cpp b/Minecraft.Client/Textures/TextureManager.cpp index 49521079c..77195f4df 100644 --- a/Minecraft.Client/Textures/TextureManager.cpp +++ b/Minecraft.Client/Textures/TextureManager.cpp @@ -88,14 +88,6 @@ std::vector* TextureManager::createTextures( if (texturePack->hasFile(L"res/" + filename, false)) { drive = texturePack->getPath(true); } else { -#if 0 - if (app.GetBootedFromDiscPatch()) { - const char* pchTextureName = wstringtofilename(filename); - char* pchUsrDir = app.GetBDUsrDirPath(pchTextureName); - std::wstring wstr(pchUsrDir, pchUsrDir + strlen(pchUsrDir)); - drive = wstr + L"\\Common\\res\\TitleUpdate\\"; - } else -#endif { drive = Minecraft::GetInstance()->skins->getDefault()->getPath(true); @@ -142,7 +134,7 @@ std::vector* TextureManager::createTextures( // Minecraft.getInstance().getLogger().warning("TextureManager.createTexture: // Skipping " + filename + " because of broken aspect ratio and not // animation"); -#ifndef _CONTENT_PACKAGE +#if !defined(_CONTENT_PACKAGE) wprintf( L"TextureManager.createTexture: Skipping %ls because of broken " L"aspect ratio and not animation\n", diff --git a/Minecraft.Client/Textures/Textures.cpp b/Minecraft.Client/Textures/Textures.cpp index ce5e4145c..8f2e0c117 100644 --- a/Minecraft.Client/Textures/Textures.cpp +++ b/Minecraft.Client/Textures/Textures.cpp @@ -177,7 +177,7 @@ const wchar_t* Textures::preLoaded[TN_COUNT] = { // L"item/christmas", // L"item/christmas_double", -#ifdef _LARGE_WORLDS +#if defined(_LARGE_WORLDS) L"misc/additionalmapicons", #endif @@ -384,19 +384,6 @@ int Textures::loadTexture(int idx) { // renderer that map the single 8-bit channel to RGBA differently. void Textures::setTextureFormat(const std::wstring& resourceName) { // 4J Stu - These texture formats are not currently in the render header -#if 0 - if (resourceName == L"/environment/clouds.png") { - TEXTURE_FORMAT = C4JRender::TEXTURE_FORMAT_R1G1B1Ax; - } else if (resourceName == L"%blur%/misc/pumpkinblur.png") { - TEXTURE_FORMAT = C4JRender::TEXTURE_FORMAT_R0G0B0Ax; - } else if (resourceName == L"%clamp%/misc/shadow.png") { - TEXTURE_FORMAT = C4JRender::TEXTURE_FORMAT_R0G0B0Ax; - } else if (resourceName == L"/environment/snow.png") { - TEXTURE_FORMAT = C4JRender::TEXTURE_FORMAT_RxGxBxAx; - } else if (resourceName == L"/1_2_2/misc/explosion.png") { - TEXTURE_FORMAT = C4JRender::TEXTURE_FORMAT_RxGxBxAx; - } else -#endif { TEXTURE_FORMAT = C4JRender::TEXTURE_FORMAT_RxGyBzAw; } @@ -701,17 +688,10 @@ void Textures::loadTexture(BufferedImage* img, int id, bool blur, bool clamp) { int g = (rawPixels[i] >> 8) & 0xff; int b = (rawPixels[i]) & 0xff; -#if 0 - newPixels[i * 4 + 0] = (uint8_t)a; - newPixels[i * 4 + 1] = (uint8_t)r; - newPixels[i * 4 + 2] = (uint8_t)g; - newPixels[i * 4 + 3] = (uint8_t)b; -#else newPixels[i * 4 + 0] = (uint8_t)r; newPixels[i * 4 + 1] = (uint8_t)g; newPixels[i * 4 + 2] = (uint8_t)b; newPixels[i * 4 + 3] = (uint8_t)a; -#endif } // 4J - now creating a buffer of the size we require dynamically ByteBuffer* pixels = MemoryTracker::createByteBuffer(w * h * 4); @@ -753,12 +733,10 @@ void Textures::loadTexture(BufferedImage* img, int id, bool blur, bool clamp) { // rather than generating if possible if (img->getData(level)) { memcpy(tempData, img->getData(level), ww * hh * 4); -#if 1 // Swap ARGB to RGBA for (int i = 0; i < ww * hh; i++) { tempData[i] = (tempData[i] >> 24) | (tempData[i] << 8); } -#endif } else { for (int x = 0; x < ww; x++) for (int y = 0; y < hh; y++) { @@ -770,7 +748,6 @@ void Textures::loadTexture(BufferedImage* img, int id, bool blur, bool clamp) { ((x * 2 + 1) + (y * 2 + 1) * ow) * 4); int c3 = pixels->getInt( ((x * 2 + 0) + (y * 2 + 1) * ow) * 4); -#if 1 // 4J - convert our RGBA texels to ARGB that crispBlend // is expecting 4jcraft, added uint cast to pervent // shift of neg int @@ -782,14 +759,11 @@ void Textures::loadTexture(BufferedImage* img, int id, bool blur, bool clamp) { ((c2 >> 8) & 0x00ffffff) | ((unsigned int)c2 << 24); c3 = ((c3 >> 8) & 0x00ffffff) | ((unsigned int)c3 << 24); -#endif int col = Texture::crispBlend(Texture::crispBlend(c0, c1), Texture::crispBlend(c2, c3)); -#if 1 // 4J - and back from ARGB -> RGBA col = ((unsigned int)col << 8) | ((col >> 24) & 0xff); -#endif tempData[x + y * ww] = col; } } @@ -835,20 +809,6 @@ void Textures::replaceTexture(intArray rawPixels, int w, int h, int id) { bind(id); // Removed in Java -#if 0 - if (MIPMAP) - { - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - /* - * glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_LOD, 0); - * glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LOD, 4); - * glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0); - * glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 4); - */ - } - else -#endif { glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); @@ -892,11 +852,7 @@ void Textures::replaceTexture(intArray rawPixels, int w, int h, int id) { // New // glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, w, h, GL12.GL_BGRA, // GL12.GL_UNSIGNED_INT_8_8_8_8_REV, pixels); -#if 0 - RenderManager.TextureDataUpdate(pixels->getBuffer(), 0); -#else RenderManager.TextureDataUpdate(0, 0, w, h, pixels->getBuffer(), 0); -#endif // Old // glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, w, h, GL_RGBA, GL_UNSIGNED_BYTE, // pixels); @@ -910,20 +866,6 @@ void Textures::replaceTextureDirect(intArray rawPixels, int w, int h, int id) { glBindTexture(GL_TEXTURE_2D, id); // Remove in Java -#if 0 - if (MIPMAP) - { - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - /* - * glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_LOD, 0); - * glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LOD, 4); - * glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0); - * glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 4); - */ - } - else -#endif { glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); @@ -932,11 +874,7 @@ void Textures::replaceTextureDirect(intArray rawPixels, int w, int h, int id) { glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); -#if 0 - RenderManager.TextureDataUpdate(rawPixels.data, 0); -#else RenderManager.TextureDataUpdate(0, 0, w, h, rawPixels.data, 0); -#endif } // 4J - added. This is a more minimal version of replaceTexture that assumes the @@ -947,20 +885,6 @@ void Textures::replaceTextureDirect(shortArray rawPixels, int w, int h, glBindTexture(GL_TEXTURE_2D, id); // Remove in Java -#if 0 - if (MIPMAP) - { - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - /* - * glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_LOD, 0); - * glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LOD, 4); - * glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0); - * glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 4); - */ - } - else -#endif { glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); @@ -969,11 +893,7 @@ void Textures::replaceTextureDirect(shortArray rawPixels, int w, int h, glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); -#if 0 - RenderManager.TextureDataUpdate(rawPixels.data, 0); -#else RenderManager.TextureDataUpdate(0, 0, w, h, rawPixels.data, 0); -#endif } void Textures::releaseTexture(int id) { @@ -1246,58 +1166,6 @@ void Textures::reloadAll() { skins->clearInvalidTexturePacks(); -#if 0 - AUTO_VAR(itEndLI, loadedImages.end() ); - for(std::unordered_map::iterator it = loadedImages.begin(); it != itEndLI; it++ ) - { - BufferedImage *image = it->second; - loadTexture(image, it->first); - } - - AUTO_VAR(itEndHT, httpTextures.end()); - for(std::unordered_map::iterator it = httpTextures.begin(); it != itEndHT; it++ ) - { - it->second->isLoaded = false; - } - - AUTO_VAR(itEndMT, memTextures.end()); - for(std::unordered_map::iterator it = memTextures.begin(); it != itEndMT; it++ ) - { - it->second->isLoaded = false; - } - - - AUTO_VAR(itEndIM, idMap.end()); - for( std::unordered_map::iterator it = idMap.begin(); it != itEndIM; it++ ) - { - std::wstring name = it->first; - - int id = idMap[name]; - BufferedImage *image; - - std::wstring prefix = L"%blur%"; - bool blur = name.substr(0, prefix.size()).compare(prefix) == 0; //name.startsWith("%blur%"); - if (blur) name = name.substr(6); - - prefix = L"%clamp%"; - bool clamp = name.substr(0, prefix.size()).compare(prefix) == 0; //name.startsWith("%clamp%"); - if (clamp) name = name.substr(7); - - image = readImage(skin->getResource(name)); - - loadTexture(image, id, blur, clamp); - delete image; - } - AUTO_VAR(itEndPM, pixelsMap.end()); - for( std::unordered_map::iterator it = pixelsMap.begin(); it != itEndPM; it++ ) - { - std::wstring name = it->first; - BufferedImage *image = readImage(skin->getResource(name)); - - loadTexturePixels(image, pixelsMap[name]); - delete image; - } -#endif // Recalculate fonts // Minecraft::GetInstance()->font->loadCharacterWidths(); @@ -1336,19 +1204,6 @@ BufferedImage* Textures::readImage( drive); // new BufferedImage(name,false,isTu,drive); } else { const char* pchName = wstringtofilename(name); -#if 0 - if (app.GetBootedFromDiscPatch() && app.IsFileInPatchList(pchName)) { - char* pchUsrDir = app.GetBDUsrDirPath(pchName); - std::wstring wstr(pchUsrDir, pchUsrDir + strlen(pchUsrDir)); - - if (isTu) { - drive = wstr + L"\\Common\\res\\TitleUpdate\\"; - - } else { - drive = wstr + L"\\Common\\"; - } - } else -#endif { drive = skins->getDefault()->getPath(isTu); } @@ -1413,7 +1268,7 @@ TEXTURE_NAME TUImages[] = { // TN_TILE_XMAS_CHEST, // TN_TILE_LARGE_XMAS_CHEST, -#ifdef _LARGE_WORLDS +#if defined(_LARGE_WORLDS) TN_MISC_ADDITIONALMAPICONS, #endif diff --git a/Minecraft.Client/UI/Font.cpp b/Minecraft.Client/UI/Font.cpp index 68dd58c1d..daaa769bb 100644 --- a/Minecraft.Client/UI/Font.cpp +++ b/Minecraft.Client/UI/Font.cpp @@ -113,11 +113,9 @@ Font::Font(Options* options, const std::wstring& name, Textures* textures, } } -#if 1 // 4J Stu - This dtor clashes with one in xui! We never delete these anyway so // take it out for now. Can go back when we have got rid of XUI Font::~Font() { delete[] charWidths; } -#endif void Font::renderCharacter(wchar_t c) { float xOff = c % m_cols * m_charWidth; @@ -131,7 +129,6 @@ void Font::renderCharacter(wchar_t c) { Tesselator* t = Tesselator::getInstance(); // 4J Stu - Changed to a quad so that we can use within a command buffer -#if 1 t->begin(); t->tex(xOff / fontWidth, (yOff + 7.99f) / fontHeight); t->vertex(xPos, yPos + height, 0.0f); @@ -146,18 +143,6 @@ void Font::renderCharacter(wchar_t c) { t->vertex(xPos, yPos, 0.0f); t->end(); -#else - t->begin(GL_TRIANGLE_STRIP); - t->tex(xOff / 128.0F, yOff / 128.0F); - t->vertex(xPos, yPos, 0.0f); - t->tex(xOff / 128.0F, (yOff + 7.99f) / 128.0F); - t->vertex(xPos, yPos + 7.99f, 0.0f); - t->tex((xOff + width) / 128.0F, yOff / 128.0F); - t->vertex(xPos + width, yPos, 0.0f); - t->tex((xOff + width) / 128.0F, (yOff + 7.99f) / 128.0F); - t->vertex(xPos + width, yPos + 7.99f, 0.0f); - t->end(); -#endif xPos += (float)charWidths[c]; } diff --git a/Minecraft.Client/UI/Font.h b/Minecraft.Client/UI/Font.h index c8e53ec7f..b37693fdb 100644 --- a/Minecraft.Client/UI/Font.h +++ b/Minecraft.Client/UI/Font.h @@ -36,11 +36,9 @@ public: bool enforceUnicode, ResourceLocation* textureLocation, int cols, int rows, int charWidth, int charHeight, unsigned short charMap[] = NULL); -#if 1 // 4J Stu - This dtor clashes with one in xui! We never delete these anyway // so take it out for now. Can go back when we have got rid of XUI ~Font(); -#endif void renderFakeCB(IntBuffer* cb); // 4J added private: diff --git a/Minecraft.Client/UI/Gui.cpp b/Minecraft.Client/UI/Gui.cpp index 5004a892a..3dee33ba4 100644 --- a/Minecraft.Client/UI/Gui.cpp +++ b/Minecraft.Client/UI/Gui.cpp @@ -36,7 +36,7 @@ ResourceLocation Gui::PUMPKIN_BLUR_LOCATION = ResourceLocation Gui::GUI_GUI_LOCATION = ResourceLocation(TN_GUI_GUI); ResourceLocation Gui::GUI_ICONS_LOCATION = ResourceLocation(TN_GUI_ICONS); -#ifdef ENABLE_JAVA_GUIS +#if defined(ENABLE_JAVA_GUIS) #define RENDER_HUD 1 #else #define RENDER_HUD 0 @@ -414,7 +414,7 @@ void Gui::render(float a, bool mouseFree, int xMouse, int yMouse) { // if (false) //(true) // { -#ifdef ENABLE_JAVA_GUIS +#if defined(ENABLE_JAVA_GUIS) renderBossHealth(); #endif // } @@ -693,7 +693,7 @@ void Gui::render(float a, bool mouseFree, int xMouse, int yMouse) { Lighting::turnOff(); glDisable(GL_RESCALE_NORMAL); } -#endif // RENDER_HUD +#endif // 4J - do render of crouched player. This code is largely taken from // the inventory render of the player, with some special hard-coded @@ -739,11 +739,6 @@ void Gui::render(float a, bool mouseFree, int xMouse, int yMouse) { int xo = iSafezoneXHalf + 10; int yo = iSafezoneTopYHalf + 10; -#if 0 - // align directly with corners, there are no safe zones on vita - xo = 10; - yo = 10; -#endif glPushMatrix(); glTranslatef((float)xo, (float)yo, 50); @@ -851,7 +846,7 @@ void Gui::render(float a, bool mouseFree, int xMouse, int yMouse) { font->draw(str, x, y, col); } } -#endif // RENDER_HUD +#endif // 4J - added to disable blends, which we have enabled previously to allow // gui fading @@ -899,7 +894,7 @@ void Gui::render(float a, bool mouseFree, int xMouse, int yMouse) { // 64; font.draw(str, x + 1, y, 0xffffff); // } -#ifndef _FINAL_BUILD +#if !defined(_FINAL_BUILD) MemSect(31); if (minecraft->options->renderDebug) { glPushMatrix(); @@ -1014,7 +1009,7 @@ max) + "% (" + (total / 1024 / 1024) + "MB)"; drawString(font, msg, screenWidth lastTickA = a; // 4J Stu - This is now displayed in a xui scene -#ifdef ENABLE_JAVA_GUIS +#if defined(ENABLE_JAVA_GUIS) // Jukebox CD message if (overlayMessageTime > 0) { float t = overlayMessageTime - a; @@ -1064,7 +1059,7 @@ max) + "% (" + (total / 1024 / 1024) + "MB)"; drawString(font, msg, screenWidth glDisable(GL_ALPHA_TEST); // 4J Stu - We have moved the chat text to a xui -#ifdef ENABLE_JAVA_GUIS +#if defined(ENABLE_JAVA_GUIS) glPushMatrix(); // 4J-PB we need to move this up a bit because we've moved the quick select // glTranslatef(0, ((float)screenHeight) - 48, 0); @@ -1114,62 +1109,6 @@ max) + "% (" + (total / 1024 / 1024) + "MB)"; drawString(font, msg, screenWidth #endif // 4J Stu - Copied over but not used -#if 0 - if (minecraft.player instanceof MultiplayerLocalPlayer && minecraft.options.keyPlayerList.isDown) - { - ClientConnection connection = ((MultiplayerLocalPlayer) minecraft.player).connection; - List playerInfos = connection.playerInfos; - int slots = connection.maxPlayers; - - int rows = slots; - int cols = 1; - while (rows > 20) { - cols++; - rows = (slots + cols - 1) / cols; - } - - /* - * int fakeCount = 39; while (playerInfos.size() > fakeCount) - * playerInfos.remove(playerInfos.size() - 1); while (playerInfos.size() < - * fakeCount) playerInfos.add(new PlayerInfo("fiddle")); - */ - - int slotWidth = 300 / cols; - if (slotWidth > 150) slotWidth = 150; - - int xxo = (screenWidth - cols * slotWidth) / 2; - int yyo = 10; - fill(xxo - 1, yyo - 1, xxo + slotWidth * cols, yyo + 9 * rows, 0x80000000); - for (int i = 0; i < slots; i++) { - int xo = xxo + i % cols * slotWidth; - int yo = yyo + i / cols * 9; - - fill(xo, yo, xo + slotWidth - 1, yo + 8, 0x20ffffff); - glColor4f(1, 1, 1, 1); - glEnable(GL_ALPHA_TEST); - - if (i < playerInfos.size()) { - PlayerInfo pl = playerInfos.get(i); - font.drawShadow(pl.name, xo, yo, 0xffffff); - minecraft.textures.bind(minecraft.textures.loadTexture("/gui/icons.png")); - int xt = 0; - int yt = 0; - xt = 0; - yt = 0; - if (pl.latency < 0) yt = 5; - else if (pl.latency < 150) yt = 0; - else if (pl.latency < 300) yt = 1; - else if (pl.latency < 600) yt = 2; - else if (pl.latency < 1000) yt = 3; - else yt = 4; - - blitOffset += 100; - blit(xo + slotWidth - 12, yo, 0 + xt * 10, 176 + yt * 8, 10, 8); - blitOffset -= 100; - } - } - } -#endif if (bDisplayGui && bTwoPlayerSplitscreen) { // pop the scaled matrix @@ -1246,8 +1185,9 @@ void Gui::renderVignette(float br, int w, int h) { if (br > 1) br = 1; tbr += (br - tbr) * 0.01f; -#ifdef ENABLE_JAVA_GUIS // 4J - removed - TODO put back when we have blend - // functions implemented + // 4J removed this path; keep it gated until the blend-function path is + // intentionally restored for the Java-style UI. +#if defined(ENABLE_JAVA_GUIS) glDisable(GL_DEPTH_TEST); glDepthMask(false); glBlendFunc(GL_ZERO, GL_ONE_MINUS_SRC_COLOR); @@ -1403,9 +1343,6 @@ void Gui::addMessage(const std::wstring& _string, int iPad, } else { maximumChars = 55; } -#if 0 - maximumChars = 90; -#endif switch (XGetLanguage()) { case XC_LANGUAGE_JAPANESE: case XC_LANGUAGE_TCHINESE: @@ -1415,9 +1352,6 @@ void Gui::addMessage(const std::wstring& _string, int iPad, } else { maximumChars = 35; } -#if 0 - maximumChars = 55; -#endif break; } break; diff --git a/Minecraft.Client/UI/Screens/AchievementScreen.cpp b/Minecraft.Client/UI/Screens/AchievementScreen.cpp index 1ef4a92bc..31c179622 100644 --- a/Minecraft.Client/UI/Screens/AchievementScreen.cpp +++ b/Minecraft.Client/UI/Screens/AchievementScreen.cpp @@ -137,266 +137,6 @@ void AchievementScreen::renderLabels() { void AchievementScreen::renderBg(int xm, int ym, float a) { // 4J Unused -#if 0 - int xScroll = Mth::floor(xScrollO + (xScrollP - xScrollO) * a); - int yScroll = Mth::floor(yScrollO + (yScrollP - yScrollO) * a); - - if (xScroll < xMin) xScroll = xMin; - if (yScroll < yMin) yScroll = yMin; - if (xScroll >= xMax) xScroll = xMax - 1; - if (yScroll >= yMax) yScroll = yMax - 1; - - - int terrainTex = minecraft->textures->loadTexture(L"/terrain.png"); - int tex = minecraft->textures->loadTexture(L"/achievement/bg.png"); - - int xo = (width - imageWidth) / 2; - int yo = (height - imageHeight) / 2; - - int xBigMap = xo + BIGMAP_X; - int yBigMap = yo + BIGMAP_Y; - - blitOffset = 0; -// glDisable(GL_DEPTH_TEST); - glDepthFunc(GL_GEQUAL); - glPushMatrix(); - glTranslatef(0, 0, -200); - - { - glEnable(GL_TEXTURE_2D); - glDisable(GL_LIGHTING); - glEnable(GL_RESCALE_NORMAL); - glEnable(GL_COLOR_MATERIAL); - - minecraft->textures->bind(terrainTex); - - int leftTile = (xScroll + EDGE_VALUE_X) >> 4; - int topTile = (yScroll + EDGE_VALUE_Y) >> 4; - int xMod = (xScroll + EDGE_VALUE_X) % 16; - int yMod = (yScroll + EDGE_VALUE_Y) % 16; - - const int rockLevel = (Achievements::ACHIEVEMENT_HEIGHT_POSITION * 4) / 10; - const int coalLevel = (Achievements::ACHIEVEMENT_HEIGHT_POSITION * 7) / 10; - const int ironLevel = (Achievements::ACHIEVEMENT_HEIGHT_POSITION * 9) / 10; - const int diamondLevel = (Achievements::ACHIEVEMENT_HEIGHT_POSITION * 19) / 10; - const int bedrockLevel = (Achievements::ACHIEVEMENT_HEIGHT_POSITION * 31) / 10; - - Random *random = new Random(); - - for (int tileY = 0; (tileY * 16) - yMod < BIGMAP_HEIGHT; tileY++) - { - - float amount = .6f - (float) (topTile + tileY) / (float) (Achievements::ACHIEVEMENT_HEIGHT_POSITION * 2 + 1) * .3f; - glColor4f(amount, amount, amount, 1); - - for (int tileX = 0; (tileX * 16) - xMod < BIGMAP_WIDTH; tileX++) - { - - random->setSeed(1234 + leftTile + tileX); - random->nextInt(); - int heightValue = random->nextInt(1 + topTile + tileY) + (topTile + tileY) / 2; - int tileType = Tile::sand->tex; - - if (heightValue > bedrockLevel || (topTile + tileY) == MAX_BG_TILE_Y) - { - tileType = Tile::unbreakable->tex; - } - else if (heightValue == diamondLevel) - { - if (random->nextInt(2) == 0) - { - tileType = Tile::diamondOre->tex; - } - else - { - tileType = Tile::redStoneOre->tex; - } - } - else if (heightValue == ironLevel) - { - tileType = Tile::ironOre->tex; - } - else if (heightValue == coalLevel) - { - tileType = Tile::coalOre->tex; - } - else if (heightValue > rockLevel) - { - tileType = Tile::rock->tex; - } - else if (heightValue > 0) - { - tileType = Tile::dirt->tex; - } - - this->blit(xBigMap + tileX * 16 - xMod, yBigMap + tileY * 16 - yMod, (tileType % 16) << 4, (tileType >> 4) << 4, 16, 16); - } - } - - } - glEnable(GL_DEPTH_TEST); - - - glDepthFunc(GL_LEQUAL); - - glDisable(GL_TEXTURE_2D); - - AUTO_VAR(itEnd, Achievements::achievements->end()); - for (AUTO_VAR(it, Achievements::achievements->begin()); it != itEnd; it++) - { - Achievement *ach = *it; //Achievements::achievements->at(i); - if (ach->requires == NULL) continue; - - int x1 = ach->x * ACHIEVEMENT_COORD_SCALE - (int) xScroll + 11 + xBigMap; - int y1 = ach->y * ACHIEVEMENT_COORD_SCALE - (int) yScroll + 11 + yBigMap; - - int x2 = ach->requires->x * ACHIEVEMENT_COORD_SCALE - (int) xScroll + 11 + xBigMap; - int y2 = ach->requires->y * ACHIEVEMENT_COORD_SCALE - (int) yScroll + 11 + yBigMap; - - int color = 0; - - bool taken = statsCounter->hasTaken(ach); - bool canTake = statsCounter->canTake(ach); - - int alph = (int) (sin(System::currentTimeMillis() % 600 / 600.0 * PI * 2) > 0.6 ? 255 : 130); - if (taken) color = 0xff707070; - else if (canTake) color = 0x00ff00 + (alph << 24); - else color = 0xff000000; - - hLine(x1, x2, y1, color); - vLine(x2, y1, y2, color); - } - - Achievement *hoveredAchievement = NULL; - ItemRenderer *ir = new ItemRenderer(); - - glPushMatrix(); - glRotatef(180, 1, 0, 0); - Lighting::turnOn(); - glPopMatrix(); - glDisable(GL_LIGHTING); - glEnable(GL_RESCALE_NORMAL); - glEnable(GL_COLOR_MATERIAL); - - itEnd = Achievements::achievements->end(); - for (AUTO_VAR(it, Achievements::achievements->begin()); it != itEnd; it++) - { - Achievement *ach = *it; //Achievements::achievements->at(i); - - int x = ach->x * ACHIEVEMENT_COORD_SCALE - (int) xScroll; - int y = ach->y * ACHIEVEMENT_COORD_SCALE - (int) yScroll; - - if (x >= -24 && y >= -24 && x <= BIGMAP_WIDTH && y <= BIGMAP_HEIGHT) - { - - if (statsCounter->hasTaken(ach)) - { - float br = 1.0f; - glColor4f(br, br, br, 1); - } - else if (statsCounter->canTake(ach)) - { - float br = (sin(System::currentTimeMillis() % 600 / 600.0 * PI * 2) < 0.6 ? 0.6f : 0.8f); - glColor4f(br, br, br, 1); - } - else - { - float br = 0.3f; - glColor4f(br, br, br, 1); - } - - minecraft->textures->bind(tex); - int xx = xBigMap + x; - int yy = yBigMap + y; - if (ach->isGolden()) - { - this->blit(xx - 2, yy - 2, 26, 202, 26, 26); - } - else - { - this->blit(xx - 2, yy - 2, 0, 202, 26, 26); - } - - if (!statsCounter->canTake(ach)) - { - float br = 0.1f; - glColor4f(br, br, br, 1); - ir->setColor = false; - } - glEnable(GL_LIGHTING); - glEnable(GL_CULL_FACE); - ir->renderGuiItem(minecraft->font, minecraft->textures, ach->icon, xx + 3, yy + 3); - glDisable(GL_LIGHTING); - if (!statsCounter->canTake(ach)) - { - ir->setColor = true; - } - glColor4f(1, 1, 1, 1); - - - if (xm >= xBigMap && ym >= yBigMap && xm < xBigMap + BIGMAP_WIDTH && ym < yBigMap + BIGMAP_HEIGHT && xm >= xx && xm <= xx + 22 && ym >= yy && ym <= yy + 22) { - hoveredAchievement = ach; - } - } - } - - glDisable(GL_DEPTH_TEST); - glEnable(GL_BLEND); - glColor4f(1, 1, 1, 1); - minecraft->textures->bind(tex); - blit(xo, yo, 0, 0, imageWidth, imageHeight); - - - glPopMatrix(); - - blitOffset = 0; - glDepthFunc(GL_LEQUAL); - - glDisable(GL_DEPTH_TEST); - glEnable(GL_TEXTURE_2D); - Screen::render(xm, ym, a); - - if (hoveredAchievement != NULL) - { - Achievement *ach = hoveredAchievement; - std::wstring name = ach->name; - std::wstring descr = ach->getDescription(); - - int x = xm + 12; - int y = ym - 4; - - if (statsCounter->canTake(ach)) - { - int width = Math::_max(font->width(name), 120); - int height = font->wordWrapHeight(descr, width); - if (statsCounter->hasTaken(ach)) - { - height += 12; - } - fillGradient(x - 3, y - 3, x + width + 3, y + height + 3 + 12, 0xc0000000, 0xc0000000); - - font->drawWordWrap(descr, x, y + 12, width, 0xffa0a0a0); - if (statsCounter->hasTaken(ach)) - { - font->drawShadow(I18n::get(L"achievement.taken"), x, y + height + 4, 0xff9090ff); - } - } - else - { - int width = Math::_max(font->width(name), 120); - std::wstring msg = I18n::get(L"achievement.requires", ach->requires->name); - int height = font->wordWrapHeight(msg, width); - fillGradient(x - 3, y - 3, x + width + 3, y + height + 12 + 3, 0xc0000000, 0xc0000000); - font->drawWordWrap(msg, x, y + 12, width, 0xff705050); - } - font->drawShadow(name, x, y, statsCounter->canTake(ach) ? ach->isGolden() ? 0xffffff80 : 0xffffffff : ach->isGolden() ? 0xff808040 : 0xff808080); - - - } - glEnable(GL_DEPTH_TEST); - glEnable(GL_LIGHTING); - Lighting::turnOff(); -#endif } bool AchievementScreen::isPauseScreen() { return true; } \ No newline at end of file diff --git a/Minecraft.Client/UI/Screens/ConnectScreen.cpp b/Minecraft.Client/UI/Screens/ConnectScreen.cpp index be444f509..e09dffb18 100644 --- a/Minecraft.Client/UI/Screens/ConnectScreen.cpp +++ b/Minecraft.Client/UI/Screens/ConnectScreen.cpp @@ -12,42 +12,12 @@ ConnectScreen::ConnectScreen(Minecraft* minecraft, const std::wstring& ip, aborted = false; // System.out.println("Connecting to " + ip + ", " + port); minecraft->setLevel(NULL); -#if 1 // 4J - removed from separate thread, but need to investigate what we // actually need here connection = new ClientConnection(minecraft, ip, port); if (aborted) return; connection->send(std::shared_ptr( new PreLoginPacket(minecraft->user->name))); -#else - - new Thread(){public void run(){ - - try {connection = new ClientConnection(minecraft, ip, port); - if (aborted) return; - connection.send(new PreLoginPacket(minecraft.user.name)); -} -catch (UnknownHostException e) { - if (aborted) return; - minecraft.setScreen(new DisconnectedScreen("connect.failed", - "disconnect.genericReason", - "Unknown host '" + ip + "'")); -} -catch (ConnectException e) { - if (aborted) return; - minecraft.setScreen(new DisconnectedScreen( - "connect.failed", "disconnect.genericReason", e.getMessage())); -} -catch (Exception e) { - if (aborted) return; - e.printStackTrace(); - minecraft.setScreen(new DisconnectedScreen( - "connect.failed", "disconnect.genericReason", e.toString())); -} -} -} -.start(); -#endif } void ConnectScreen::tick() { diff --git a/Minecraft.Client/UI/Screens/ContainerScreen.cpp b/Minecraft.Client/UI/Screens/ContainerScreen.cpp index 4f34f524e..3a461f9c0 100644 --- a/Minecraft.Client/UI/Screens/ContainerScreen.cpp +++ b/Minecraft.Client/UI/Screens/ContainerScreen.cpp @@ -18,15 +18,11 @@ ContainerScreen::ContainerScreen(std::shared_ptr inventory, } void ContainerScreen::renderLabels() { -#if 0 - font->draw(container->getName(), 8, 2 + 2 + 2, 0x404040); - font->draw(inventory->getName(), 8, imageHeight - 96 + 2, 0x404040); -#endif } void ContainerScreen::renderBg(float a) { // 4J Unused -#ifdef ENABLE_JAVA_GUIS +#if defined(ENABLE_JAVA_GUIS) int tex = minecraft->textures->loadTexture(TN_GUI_CONTAINER); glColor4f(1, 1, 1, 1); minecraft->textures->bind(tex); diff --git a/Minecraft.Client/UI/Screens/CreateWorldScreen.cpp b/Minecraft.Client/UI/Screens/CreateWorldScreen.cpp index d38f3d067..c3395ec25 100644 --- a/Minecraft.Client/UI/Screens/CreateWorldScreen.cpp +++ b/Minecraft.Client/UI/Screens/CreateWorldScreen.cpp @@ -140,12 +140,6 @@ std::wstring CreateWorldScreen::findAvailableFolderName( LevelStorageSource* levelSource, const std::wstring& folder) { std::wstring folder2 = folder; // 4J - copy input as it is const -#if 0 - while (levelSource->getDataTagFor(folder2) != NULL) - { - folder2 = folder2 + L"-"; - } -#endif return folder2; } @@ -300,11 +294,6 @@ void CreateWorldScreen::buttonClicked(Button* button) { new MessageScreen(language->getElement(L"menu.generatingLevel"))); // 4J Stu - This screen is not used, so removing this to stop the build // failing -#if 0 - minecraft->gameMode = new SurvivalMode(minecraft); - minecraft->selectLevel(resultFolder, nameEdit->getValue(), seedValue); - minecraft->setScreen(NULL); -#endif } else if (button->id == 2) { if (gameMode == L"survival") gameMode = L"creative"; diff --git a/Minecraft.Client/UI/Screens/RenameWorldScreen.cpp b/Minecraft.Client/UI/Screens/RenameWorldScreen.cpp index df2479392..7c6b7712b 100644 --- a/Minecraft.Client/UI/Screens/RenameWorldScreen.cpp +++ b/Minecraft.Client/UI/Screens/RenameWorldScreen.cpp @@ -18,22 +18,6 @@ void RenameWorldScreen::tick() { nameEdit->tick(); } void RenameWorldScreen::init() { // 4J Stu - Removed this as we don't need the screen. Changed to how we pass // save data around stopped this compiling -#if 0 - Language *language = Language::getInstance(); - - Keyboard::enableRepeatEvents(true); - buttons.clear(); - buttons.push_back(new Button(0, width / 2 - 100, height / 4 + 24 * 4 + 12, language->getElement(L"selectWorld.renameButton"))); - buttons.push_back(new Button(1, width / 2 - 100, height / 4 + 24 * 5 + 12, language->getElement(L"gui.cancel"))); - - LevelStorageSource *levelSource = minecraft->getLevelSource(); - LevelData *levelData = levelSource->getDataTagFor(levelId); - std::wstring currentName = levelData->getLevelName(); - - nameEdit = new EditBox(this, font, width / 2 - 100, 60, 200, 20, currentName); - nameEdit->inFocus = true; - nameEdit->setMaxLength(32); -#endif } void RenameWorldScreen::removed() { Keyboard::enableRepeatEvents(false); } diff --git a/Minecraft.Client/UI/Screens/SelectWorldScreen.cpp b/Minecraft.Client/UI/Screens/SelectWorldScreen.cpp index aa410280b..af51786a4 100644 --- a/Minecraft.Client/UI/Screens/SelectWorldScreen.cpp +++ b/Minecraft.Client/UI/Screens/SelectWorldScreen.cpp @@ -117,11 +117,6 @@ void SelectWorldScreen::buttonClicked(Button* button) { if (done) return; done = true; // 4J Stu - Not used, so commenting to stop the build failing -#if 0 - minecraft->gameMode = new DemoMode(minecraft); - minecraft->selectLevel(CreateWorldScreen::findAvailableFolderName(minecraft->getLevelSource(), L"Demo"), L"Demo World", 0L); - minecraft->setScreen(NULL); -#endif } } else if (button->id == BUTTON_RENAME_ID) { minecraft->setScreen( @@ -146,10 +141,6 @@ void SelectWorldScreen::worldSelected(int id) { worldFolderName = L"World" + _toString(id); } // 4J Stu - Not used, so commenting to stop the build failing -#if 0 - minecraft->selectLevel(worldFolderName, getWorldName(id), 0); - minecraft->setScreen(NULL); -#endif } void SelectWorldScreen::confirmResult(bool result, int id) { diff --git a/Minecraft.Client/UI/Screens/StatsScreen.cpp b/Minecraft.Client/UI/Screens/StatsScreen.cpp index 199c0fb16..9f310f029 100644 --- a/Minecraft.Client/UI/Screens/StatsScreen.cpp +++ b/Minecraft.Client/UI/Screens/StatsScreen.cpp @@ -127,44 +127,12 @@ void StatsScreen::GeneralStatisticsList::renderItem(int i, int x, int y, int h, void StatsScreen::blitSlot(int x, int y, int item) { // 4J Unused -#if 0 - blitSlotBg(x + SLOT_BG_X, y + SLOT_BG_Y); - - glEnable(GL_RESCALE_NORMAL); - - glPushMatrix(); - glRotatef(180, 1, 0, 0); - Lighting::turnOn(); - glPopMatrix(); - - itemRenderer->renderGuiItem(font, minecraft->textures, item, 0, Item::items[item]->getIcon(0), x + SLOT_FG_X, y + SLOT_FG_Y); - Lighting::turnOff(); - - glDisable(GL_RESCALE_NORMAL); -#endif } void StatsScreen::blitSlotBg(int x, int y) { blitSlotIcon(x, y, 0, 0); } void StatsScreen::blitSlotIcon(int x, int y, int sx, int sy) { // 4J Unused -#if 0 - int tex = minecraft->textures->loadTexture(L"/gui/slot.png"); - glColor4f(1, 1, 1, 1); - minecraft->textures->bind(tex); - - const float us = 1 / SLOT_TEX_SIZE; - const float vs = 1 / SLOT_TEX_SIZE; - const int w = SLOT_BG_SIZE; - const int h = SLOT_BG_SIZE; - Tesselator *t = Tesselator::getInstance(); - t->begin(); - t->vertexUV((float)(x + 0), (float)( y + h), (float)( blitOffset), (float)( (sx + 0) * us), (float)( (sy + h) * vs)); - t->vertexUV((float)(x + w), (float)( y + h), (float)( blitOffset), (float)( (sx + w) * us), (float)( (sy + h) * vs)); - t->vertexUV((float)(x + w), (float)( y + 0), (float)( blitOffset), (float)( (sx + w) * us), (float)( (sy + 0) * vs)); - t->vertexUV((float)(x + 0), (float)( y + 0), (float)( blitOffset), (float)( (sx + 0) * us), (float)( (sy + 0) * vs)); - t->end(); -#endif } // 4J - added parameter so we can access parent @@ -326,26 +294,6 @@ void StatsScreen::StatisticsList::renderDecorations(int mouseX, int mouseY) { void StatsScreen::StatisticsList::renderMousehoverTooltip(ItemStat* stat, int x, int y) { // 4J Stu - Unused -#if 0 - if (stat == NULL) - { - return; - } - - Item *item = Item::items[stat->getItemId()]; - - std::wstring elementName = trimString(L"" + Language::getInstance()->getElementName(item->getDescriptionId())); - - if (elementName.length() > 0) - { - int rx = x + 12; - int ry = y - 12; - int width = parent->font->width(elementName); - parent->fillGradient(rx - 3, ry - 3, rx + width + 3, ry + 8 + 3, 0xc0000000, 0xc0000000); - - parent->font->drawShadow(elementName, rx, ry, 0xffffffff); - } -#endif } void StatsScreen::StatisticsList::sortByColumn(int column) { diff --git a/Minecraft.Client/UI/Screens/TrapScreen.cpp b/Minecraft.Client/UI/Screens/TrapScreen.cpp index 80de6d7e9..b754f7447 100644 --- a/Minecraft.Client/UI/Screens/TrapScreen.cpp +++ b/Minecraft.Client/UI/Screens/TrapScreen.cpp @@ -17,12 +17,4 @@ void TrapScreen::renderLabels() { void TrapScreen::renderBg(float a) { // 4J Unused -#if 0 - int tex = minecraft->textures->loadTexture(L"/gui/trap.png"); - glColor4f(1, 1, 1, 1); - minecraft->textures->bind(tex); - int xo = (width - imageWidth) / 2; - int yo = (height - imageHeight) / 2; - this->blit(xo, yo, 0, 0, imageWidth, imageHeight); -#endif } \ No newline at end of file diff --git a/Minecraft.Client/UI/ScrolledSelectionList.cpp b/Minecraft.Client/UI/ScrolledSelectionList.cpp index 81cc76896..c91d92f64 100644 --- a/Minecraft.Client/UI/ScrolledSelectionList.cpp +++ b/Minecraft.Client/UI/ScrolledSelectionList.cpp @@ -100,244 +100,9 @@ void ScrolledSelectionList::buttonClicked(Button* button) { void ScrolledSelectionList::render(int xm, int ym, float a) { // 4J Unused -#if 0 - renderBackground(); - - int itemCount = getNumberOfItems(); - - int xx0 = width / 2 + 124; - int xx1 = xx0 + 6; - - if (Mouse::isButtonDown(0)) - { - if (yDrag == NO_DRAG) - { - bool doDrag = true; - if (ym >= y0 && ym <= y1) - { - int x0 = width / 2 - (92 + 16 + 2); - int x1 = width / 2 + (92 + 16 + 2); - - int clickSlotPos = (ym - y0 - headerHeight + (int) yo - 4); - int slot = clickSlotPos / itemHeight; - if (xm >= x0 && xm <= x1 && slot >= 0 && clickSlotPos >= 0 && slot < itemCount) - { - - bool doubleClick = slot == lastSelection && (System::currentTimeMillis() - lastSelectionTime) < 250; - - selectItem(slot, doubleClick); - lastSelection = slot; - lastSelectionTime = System::currentTimeMillis(); - } - else if (xm >= x0 && xm <= x1 && clickSlotPos < 0) - { - clickedHeader(xm - x0, ym - y0 + (int) yo - 4); - doDrag = false; - } - if (xm >= xx0 && xm <= xx1) - { - yDragScale = -1; - - int max = getMaxPosition() - (y1 - y0 - 4); - if (max < 1) max = 1; - int barHeight = (int) ((y1 - y0) * (y1 - y0) / (float) getMaxPosition()); - if (barHeight < 32) barHeight = 32; - if (barHeight > (y1 - y0 - 8)) barHeight = (y1 - y0 - 8); - -// int yp = yo * (y1 - y0 - barHeight) / max + y0; -// if (yp < y0) yp = y0; - - yDragScale /= (y1 - y0 - barHeight) / (float) max; - - } - else - { - yDragScale = 1; - } - if (doDrag) - { - yDrag = (float)ym; - } - else - { - yDrag = DRAG_OUTSIDE; - } - } - else - { - yDrag = DRAG_OUTSIDE; - } - } - else if (yDrag >= 0) - { - yo -= (ym - yDrag) * yDragScale; - yDrag = (float)ym; - } - - } - else - { - yDrag = NO_DRAG; - } - - capYPosition(); - - glDisable(GL_LIGHTING); - glDisable(GL_FOG); - Tesselator *t = Tesselator::getInstance(); - - glBindTexture(GL_TEXTURE_2D, minecraft->textures->loadTexture(L"/gui/background.png")); - glColor4f(1.0f, 1, 1, 1); - float s = 32; - t->begin(); - t->color(0x202020); - t->vertexUV((float)(x0), (float)( y1), (float)( 0), (float)( x0 / s), (float)( (y1 + (int) yo) / s)); - t->vertexUV((float)(x1), (float)( y1), (float)( 0), (float)( x1 / s), (float)( (y1 + (int) yo) / s)); - t->vertexUV((float)(x1), (float)( y0), (float)( 0), (float)( x1 / s), (float)( (y0 + (int) yo) / s)); - t->vertexUV((float)(x0), (float)( y0), (float)( 0), (float)( x0 / s), (float)( (y0 + (int) yo) / s)); - t->end(); - - int rowX = width / 2 - 92 - 16; - int rowBaseY = y0 + 4 - (int) yo; - - if (_renderHeader) - { - renderHeader(rowX, rowBaseY, t); - } - - for (int i = 0; i < itemCount; i++) - { - - int y = rowBaseY + (i) * itemHeight + headerHeight; - int h = itemHeight - 4; - - if (y > y1 || (y + h) < y0) - { - continue; - } - - if (renderSelection && isSelectedItem(i)) - { - int x0 = width / 2 - (92 + 16 + 2); - int x1 = width / 2 + (92 + 16 + 2); - glColor4f(1, 1, 1, 1); - glDisable(GL_TEXTURE_2D); - t->begin(); - t->color(0x808080); - t->vertexUV((float)(x0), (float)( y + h + 2), (float)( 0), (float)( 0), (float)( 1)); - t->vertexUV((float)(x1), (float)( y + h + 2), (float)( 0), (float)( 1), (float)( 1)); - t->vertexUV((float)(x1), (float)( y - 2), (float)( 0), (float)( 1), (float)( 0)); - t->vertexUV((float)(x0), (float)( y - 2), (float)( 0), (float)( 0), (float)( 0)); - - t->color(0x000000); - t->vertexUV((float)(x0 + 1), (float)( y + h + 1), (float)( 0), (float)( 0), (float)( 1)); - t->vertexUV((float)(x1 - 1), (float)( y + h + 1), (float)( 0), (float)( 1), (float)( 1)); - t->vertexUV((float)(x1 - 1), (float)( y - 1), (float)( 0), (float)( 1), (float)( 0)); - t->vertexUV((float)(x0 + 1), (float)( y - 1), (float)( 0), (float)( 0), (float)( 0)); - - t->end(); - glEnable(GL_TEXTURE_2D); - } - - renderItem(i, rowX, y, h, t); - - } - - glDisable(GL_DEPTH_TEST); - - - int d = 4; - - renderHoleBackground(0, y0, 255, 255); - renderHoleBackground(y1, height, 255, 255); - - glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glDisable(GL_ALPHA_TEST); - glShadeModel(GL_SMOOTH); - - glDisable(GL_TEXTURE_2D); - - t->begin(); - t->color(0x000000, 0); - t->vertexUV((float)(x0), (float)( y0 + d), (float)( 0), (float)( 0), (float)( 1)); - t->vertexUV((float)(x1), (float)( y0 + d), (float)( 0), (float)( 1), (float)( 1)); - t->color(0x000000, 255); - t->vertexUV((float)(x1), (float)( y0), (float)( 0), (float)( 1), (float)( 0)); - t->vertexUV((float)(x0), (float)( y0), (float)( 0), (float)( 0), (float)( 0)); - t->end(); - - t->begin(); - t->color(0x000000, 255); - t->vertexUV((float)(x0), (float)( y1), (float)( 0), (float)( 0), (float)( 1)); - t->vertexUV((float)(x1), (float)( y1), (float)( 0), (float)( 1), (float)( 1)); - t->color(0x000000, 0); - t->vertexUV((float)(x1), (float)( y1 - d), (float)( 0), (float)( 1), (float)( 0)); - t->vertexUV((float)(x0), (float)( y1 - d), (float)( 0), (float)( 0), (float)( 0)); - t->end(); - - { - int max = getMaxPosition() - (y1 - y0 - 4); - if (max > 0) - { - int barHeight = (int) (y1 - y0) * (y1 - y0) / (getMaxPosition()); - if (barHeight < 32) barHeight = 32; - if (barHeight > (y1 - y0 - 8)) barHeight = (y1 - y0 - 8); - - int yp = (int) yo * (y1 - y0 - barHeight) / max + y0; - if (yp < y0) yp = y0; - - t->begin(); - t->color(0x000000, 255); - t->vertexUV((float)(xx0), (float)( y1), (float)( 0), (float)( 0), (float)( 1)); - t->vertexUV((float)(xx1), (float)( y1), (float)( 0), (float)( 1), (float)( 1)); - t->vertexUV((float)(xx1), (float)( y0), (float)( 0), (float)( 1), (float)( 0)); - t->vertexUV((float)(xx0), (float)( y0), (float)( 0), (float)( 0), (float)( 0)); - t->end(); - - t->begin(); - t->color(0x808080, 255); - t->vertexUV((float)(xx0), (float)( yp + barHeight), (float)( 0), (float)( 0), (float)( 1)); - t->vertexUV((float)(xx1), (float)( yp + barHeight), (float)( 0), (float)( 1), (float)( 1)); - t->vertexUV((float)(xx1), (float)( yp), (float)( 0), (float)( 1), (float)( 0)); - t->vertexUV((float)(xx0), (float)( yp), (float)( 0), (float)( 0), (float)( 0)); - t->end(); - - t->begin(); - t->color(0xc0c0c0, 255); - t->vertexUV((float)(xx0), (float)( yp + barHeight - 1), (float)( 0), (float)( 0), (float)( 1)); - t->vertexUV((float)(xx1 - 1), (float)( yp + barHeight - 1), (float)( 0), (float)( 1), (float)( 1)); - t->vertexUV((float)(xx1 - 1), (float)( yp), (float)( 0), (float)( 1), (float)( 0)); - t->vertexUV((float)(xx0), (float)( yp), (float)( 0), (float)( 0), (float)( 0)); - t->end(); - } - } - - renderDecorations(xm, ym); - - glEnable(GL_TEXTURE_2D); - - glShadeModel(GL_FLAT); - glEnable(GL_ALPHA_TEST); - glDisable(GL_BLEND); -#endif } void ScrolledSelectionList::renderHoleBackground(int y0, int y1, int a0, int a1) { // 4J Unused -#if 0 - Tesselator *t = Tesselator::getInstance(); - glBindTexture(GL_TEXTURE_2D, minecraft->textures->loadTexture(L"/gui/background.png")); - glColor4f(1.0f, 1, 1, 1); - float s = 32; - t->begin(); - t->color(0x404040, a1); - t->vertexUV((float)(0), (float)( y1), (float)( 0), (float)( 0), (float)( y1 / s)); - t->vertexUV((float)(width), (float)( y1), (float)( 0), (float)( width / s), (float)( y1 / s)); - t->color(0x404040, a0); - t->vertexUV((float)(width), (float)( y0), (float)( 0), (float)( width / s), (float)( y0 / s)); - t->vertexUV((float)(0), (float)( y0), (float)( 0), (float)( 0), (float)( y0 / s)); - t->end(); -#endif } diff --git a/Minecraft.Client/Utils/ArchiveFile.cpp b/Minecraft.Client/Utils/ArchiveFile.cpp index 6064181f7..81a0b9def 100644 --- a/Minecraft.Client/Utils/ArchiveFile.cpp +++ b/Minecraft.Client/Utils/ArchiveFile.cpp @@ -31,7 +31,7 @@ ArchiveFile::ArchiveFile(File file) { m_cachedData = NULL; m_sourcefile = file; app.DebugPrintf("Loading archive file...\n"); -#ifndef _CONTENT_PACKAGE +#if !defined(_CONTENT_PACKAGE) char buf[256]; wcstombs(buf, file.getPath().c_str(), 256); app.DebugPrintf("archive file - %s\n", buf); @@ -44,7 +44,7 @@ ArchiveFile::ArchiveFile(File file) { FileInputStream fis(file); -#if 0 || 0 || defined _WINDOWS64 +#if defined(_WINDOWS64) byteArray readArray(file.length()); fis.read(readArray, 0, file.length()); @@ -60,7 +60,7 @@ ArchiveFile::ArchiveFile(File file) { dis.close(); fis.close(); -#if 0 || 0 || defined _WINDOWS64 +#if defined(_WINDOWS64) bais.reset(); #endif app.DebugPrintf("Finished loading archive file\n"); @@ -94,14 +94,14 @@ byteArray ArchiveFile::getFile(const std::wstring& filename) { app.DebugPrintf("Couldn't find file in archive\n"); app.DebugPrintf("Failed to find file '%ls' in archive\n", filename.c_str()); -#ifndef _CONTENT_PACKAGE +#if !defined(_CONTENT_PACKAGE) __debugbreak(); #endif app.FatalLoadError(); } else { PMetaData data = it->second; -#if 0 || 0 || defined _WINDOWS64 +#if defined(_WINDOWS64) out = byteArray(data->filesize); memcpy(out.data, m_cachedData + data->ptr, data->filesize); diff --git a/Minecraft.Client/Utils/StringTable.h b/Minecraft.Client/Utils/StringTable.h index 6eac0020e..3eb724e64 100644 --- a/Minecraft.Client/Utils/StringTable.h +++ b/Minecraft.Client/Utils/StringTable.h @@ -2,13 +2,7 @@ #include -#if 0 || 0 || 0 -#define LOCALE_COUNT 21 -#elif 0 -#define LOCALE_COUNT 19 -#else #define LOCALE_COUNT 11 -#endif class StringTable { private: