mirror of
https://github.com/4jcraft/4jcraft.git
synced 2026-08-20 09:57:10 +00:00
Merge pull request #306 from Merc6/refactor/remove-int-cache
refactor: remove integer caching
This commit is contained in:
commit
4a2b05f4e0
|
|
@ -61,7 +61,6 @@
|
||||||
#include "../Minecraft.World/Headers/net.minecraft.world.entity.animal.h"
|
#include "../Minecraft.World/Headers/net.minecraft.world.entity.animal.h"
|
||||||
#include "../Minecraft.World/Headers/net.minecraft.world.entity.monster.h"
|
#include "../Minecraft.World/Headers/net.minecraft.world.entity.monster.h"
|
||||||
#include "../Minecraft.World/WorldGen/Features/StrongholdFeature.h"
|
#include "../Minecraft.World/WorldGen/Features/StrongholdFeature.h"
|
||||||
#include "../Minecraft.World/Util/IntCache.h"
|
|
||||||
#include "../Minecraft.World/Entities/Mobs/Villager.h"
|
#include "../Minecraft.World/Entities/Mobs/Villager.h"
|
||||||
#include "../Minecraft.World/Level/Storage/SparseLightStorage.h"
|
#include "../Minecraft.World/Level/Storage/SparseLightStorage.h"
|
||||||
#include "../Minecraft.World/Level/Storage/SparseDataStorage.h"
|
#include "../Minecraft.World/Level/Storage/SparseDataStorage.h"
|
||||||
|
|
@ -2078,9 +2077,11 @@ void Minecraft::run_middle() {
|
||||||
// If there's an unoccupied quadrant, then clear that to black
|
// If there's an unoccupied quadrant, then clear that to black
|
||||||
if (unoccupiedQuadrant > -1) {
|
if (unoccupiedQuadrant > -1) {
|
||||||
// render a logo
|
// render a logo
|
||||||
RenderManager.StateSetViewport((C4JRender::eViewportType)(
|
RenderManager.StateSetViewport((
|
||||||
C4JRender::VIEWPORT_TYPE_QUADRANT_TOP_LEFT +
|
C4JRender::
|
||||||
unoccupiedQuadrant));
|
eViewportType)(C4JRender::
|
||||||
|
VIEWPORT_TYPE_QUADRANT_TOP_LEFT +
|
||||||
|
unoccupiedQuadrant));
|
||||||
glClearColor(0, 0, 0, 0);
|
glClearColor(0, 0, 0, 0);
|
||||||
glClear(GL_COLOR_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
|
|
||||||
|
|
@ -2400,7 +2401,6 @@ void Minecraft::levelTickUpdateFunc(void* pParam) {
|
||||||
void Minecraft::levelTickThreadInitFunc() {
|
void Minecraft::levelTickThreadInitFunc() {
|
||||||
AABB::CreateNewThreadStorage();
|
AABB::CreateNewThreadStorage();
|
||||||
Vec3::CreateNewThreadStorage();
|
Vec3::CreateNewThreadStorage();
|
||||||
IntCache::CreateNewThreadStorage();
|
|
||||||
Compression::UseDefaultThreadStorage();
|
Compression::UseDefaultThreadStorage();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2596,8 +2596,8 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) {
|
||||||
if (player->isRiding()) {
|
if (player->isRiding()) {
|
||||||
std::shared_ptr<Entity> mount = player->riding;
|
std::shared_ptr<Entity> mount = player->riding;
|
||||||
|
|
||||||
if (mount->instanceof (eTYPE_MINECART) || mount->instanceof
|
if (mount->instanceof(eTYPE_MINECART) ||
|
||||||
(eTYPE_BOAT)) {
|
mount->instanceof(eTYPE_BOAT)) {
|
||||||
*piAlt = IDS_TOOLTIPS_EXIT;
|
*piAlt = IDS_TOOLTIPS_EXIT;
|
||||||
} else {
|
} else {
|
||||||
*piAlt = IDS_TOOLTIPS_DISMOUNT;
|
*piAlt = IDS_TOOLTIPS_DISMOUNT;
|
||||||
|
|
@ -3623,7 +3623,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if (hitResult->entity->instanceof (eTYPE_MOB)) {
|
if (hitResult->entity->instanceof(eTYPE_MOB)) {
|
||||||
std::shared_ptr<Mob> mob =
|
std::shared_ptr<Mob> mob =
|
||||||
std::dynamic_pointer_cast<Mob>(
|
std::dynamic_pointer_cast<Mob>(
|
||||||
hitResult->entity);
|
hitResult->entity);
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,6 @@
|
||||||
#include "Player/ServerPlayer.h"
|
#include "Player/ServerPlayer.h"
|
||||||
#include "Rendering/GameRenderer.h"
|
#include "Rendering/GameRenderer.h"
|
||||||
#include "../Minecraft.World/Util/ThreadName.h"
|
#include "../Minecraft.World/Util/ThreadName.h"
|
||||||
#include "../Minecraft.World/Util/IntCache.h"
|
|
||||||
#include "../Minecraft.World/Level/Storage/CompressedTileStorage.h"
|
#include "../Minecraft.World/Level/Storage/CompressedTileStorage.h"
|
||||||
#include "../Minecraft.World/Level/Storage/SparseLightStorage.h"
|
#include "../Minecraft.World/Level/Storage/SparseLightStorage.h"
|
||||||
#include "../Minecraft.World/Level/Storage/SparseDataStorage.h"
|
#include "../Minecraft.World/Level/Storage/SparseDataStorage.h"
|
||||||
|
|
@ -315,7 +314,6 @@ int MinecraftServer::runPostUpdate(void* lpParam) {
|
||||||
MinecraftServer* server = (MinecraftServer*)lpParam;
|
MinecraftServer* server = (MinecraftServer*)lpParam;
|
||||||
Entity::useSmallIds(); // This thread can end up spawning entities as
|
Entity::useSmallIds(); // This thread can end up spawning entities as
|
||||||
// resources
|
// resources
|
||||||
IntCache::CreateNewThreadStorage();
|
|
||||||
AABB::CreateNewThreadStorage();
|
AABB::CreateNewThreadStorage();
|
||||||
Vec3::CreateNewThreadStorage();
|
Vec3::CreateNewThreadStorage();
|
||||||
Compression::UseDefaultThreadStorage();
|
Compression::UseDefaultThreadStorage();
|
||||||
|
|
@ -366,7 +364,6 @@ int MinecraftServer::runPostUpdate(void* lpParam) {
|
||||||
LeaveCriticalSection(&server->m_postProcessCS);
|
LeaveCriticalSection(&server->m_postProcessCS);
|
||||||
// #endif //__PS3__
|
// #endif //__PS3__
|
||||||
Tile::ReleaseThreadStorage();
|
Tile::ReleaseThreadStorage();
|
||||||
IntCache::ReleaseThreadStorage();
|
|
||||||
AABB::ReleaseThreadStorage();
|
AABB::ReleaseThreadStorage();
|
||||||
Vec3::ReleaseThreadStorage();
|
Vec3::ReleaseThreadStorage();
|
||||||
Level::destroyLightingCache();
|
Level::destroyLightingCache();
|
||||||
|
|
@ -889,8 +886,7 @@ void MinecraftServer::overwriteHellBordersForNewWorldSize(ServerLevel* level,
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void MinecraftServer::setProgress(const std::wstring& status,
|
void MinecraftServer::setProgress(const std::wstring& status, int progress) {
|
||||||
int progress) {
|
|
||||||
progressStatus = status;
|
progressStatus = status;
|
||||||
this->progress = progress;
|
this->progress = progress;
|
||||||
// logger.info(status + ": " + progress + "%");
|
// logger.info(status + ": " + progress + "%");
|
||||||
|
|
@ -1817,9 +1813,7 @@ void MinecraftServer::info(const std::wstring& string) {}
|
||||||
|
|
||||||
void MinecraftServer::warn(const std::wstring& string) {}
|
void MinecraftServer::warn(const std::wstring& string) {}
|
||||||
|
|
||||||
std::wstring MinecraftServer::getConsoleName() {
|
std::wstring MinecraftServer::getConsoleName() { return L"CONSOLE"; }
|
||||||
return L"CONSOLE";
|
|
||||||
}
|
|
||||||
|
|
||||||
ServerLevel* MinecraftServer::getLevel(int dimension) {
|
ServerLevel* MinecraftServer::getLevel(int dimension) {
|
||||||
if (dimension == -1)
|
if (dimension == -1)
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,6 @@
|
||||||
|
|
||||||
#include "../../Minecraft.Client/UI/Gui.h"
|
#include "../../Minecraft.Client/UI/Gui.h"
|
||||||
#include "../../Minecraft.Client/Rendering/LevelRenderer.h"
|
#include "../../Minecraft.Client/Rendering/LevelRenderer.h"
|
||||||
#include "../../Minecraft.World/Util/IntCache.h"
|
|
||||||
#include "../GameRules/ConsoleGameRules.h"
|
#include "../GameRules/ConsoleGameRules.h"
|
||||||
#include "GameNetworkManager.h"
|
#include "GameNetworkManager.h"
|
||||||
|
|
||||||
|
|
@ -952,7 +951,6 @@ int CGameNetworkManager::RunNetworkGameThreadProc(void* lpParameter) {
|
||||||
Vec3::UseDefaultThreadStorage();
|
Vec3::UseDefaultThreadStorage();
|
||||||
Compression::UseDefaultThreadStorage();
|
Compression::UseDefaultThreadStorage();
|
||||||
Tile::CreateNewThreadStorage();
|
Tile::CreateNewThreadStorage();
|
||||||
IntCache::CreateNewThreadStorage();
|
|
||||||
|
|
||||||
g_NetworkManager.m_bNetworkThreadRunning = true;
|
g_NetworkManager.m_bNetworkThreadRunning = true;
|
||||||
bool success = g_NetworkManager._RunNetworkGame(lpParameter);
|
bool success = g_NetworkManager._RunNetworkGame(lpParameter);
|
||||||
|
|
@ -984,7 +982,6 @@ int CGameNetworkManager::RunNetworkGameThreadProc(void* lpParameter) {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Tile::ReleaseThreadStorage();
|
Tile::ReleaseThreadStorage();
|
||||||
IntCache::ReleaseThreadStorage();
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1012,7 +1009,6 @@ int CGameNetworkManager::ServerThreadProc(void* lpParameter) {
|
||||||
SetThreadName(-1, "Minecraft Server thread");
|
SetThreadName(-1, "Minecraft Server thread");
|
||||||
AABB::CreateNewThreadStorage();
|
AABB::CreateNewThreadStorage();
|
||||||
Vec3::CreateNewThreadStorage();
|
Vec3::CreateNewThreadStorage();
|
||||||
IntCache::CreateNewThreadStorage();
|
|
||||||
Compression::UseDefaultThreadStorage();
|
Compression::UseDefaultThreadStorage();
|
||||||
OldChunkStorage::UseDefaultThreadStorage();
|
OldChunkStorage::UseDefaultThreadStorage();
|
||||||
Entity::useSmallIds();
|
Entity::useSmallIds();
|
||||||
|
|
@ -1027,7 +1023,6 @@ int CGameNetworkManager::ServerThreadProc(void* lpParameter) {
|
||||||
Tile::ReleaseThreadStorage();
|
Tile::ReleaseThreadStorage();
|
||||||
AABB::ReleaseThreadStorage();
|
AABB::ReleaseThreadStorage();
|
||||||
Vec3::ReleaseThreadStorage();
|
Vec3::ReleaseThreadStorage();
|
||||||
IntCache::ReleaseThreadStorage();
|
|
||||||
Level::destroyLightingCache();
|
Level::destroyLightingCache();
|
||||||
|
|
||||||
if (lpParameter != NULL) delete (NetworkGameInitData*)lpParameter;
|
if (lpParameter != NULL) delete (NetworkGameInitData*)lpParameter;
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,6 @@
|
||||||
#include "../../Minecraft.World/Level/Storage/LevelSettings.h"
|
#include "../../Minecraft.World/Level/Storage/LevelSettings.h"
|
||||||
#include "../../Minecraft.World/Util/StringHelpers.h"
|
#include "../../Minecraft.World/Util/StringHelpers.h"
|
||||||
#include "../../Minecraft.World/WorldGen/Biomes/BiomeSource.h"
|
#include "../../Minecraft.World/WorldGen/Biomes/BiomeSource.h"
|
||||||
#include "../../Minecraft.World/Util/IntCache.h"
|
|
||||||
#include "../../Minecraft.World/Level/Storage/LevelType.h"
|
#include "../../Minecraft.World/Level/Storage/LevelType.h"
|
||||||
#include "../../Minecraft.Client/Textures/Packs/DLCTexturePack.h"
|
#include "../../Minecraft.Client/Textures/Packs/DLCTexturePack.h"
|
||||||
|
|
||||||
|
|
@ -1373,7 +1372,6 @@ int UIScene_CreateWorldMenu::StartGame_SignInReturned(void* pParam,
|
||||||
} else {
|
} else {
|
||||||
// This is NOT called from a storage manager thread, and is in
|
// This is NOT called from a storage manager thread, and is in
|
||||||
// fact called from the main thread in the Profile library tick.
|
// fact called from the main thread in the Profile library tick.
|
||||||
// Therefore we use the main threads IntCache.
|
|
||||||
CreateGame(pClass, localUsersMask);
|
CreateGame(pClass, localUsersMask);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1873,7 +1873,6 @@ int UIScene_LoadMenu::StartGame_SignInReturned(void* pParam, bool bContinue,
|
||||||
#endif
|
#endif
|
||||||
// This is NOT called from a storage manager thread, and is in
|
// This is NOT called from a storage manager thread, and is in
|
||||||
// fact called from the main thread in the Profile library tick.
|
// fact called from the main thread in the Profile library tick.
|
||||||
// Therefore we use the main threads IntCache.
|
|
||||||
StartGameFromSave(pClass, localUsersMask);
|
StartGameFromSave(pClass, localUsersMask);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,6 @@
|
||||||
#include "../../Minecraft.World/Level/Storage/LevelSettings.h"
|
#include "../../Minecraft.World/Level/Storage/LevelSettings.h"
|
||||||
#include "XUI_MultiGameLaunchMoreOptions.h"
|
#include "XUI_MultiGameLaunchMoreOptions.h"
|
||||||
#include "../../Minecraft.World/WorldGen/Biomes/BiomeSource.h"
|
#include "../../Minecraft.World/WorldGen/Biomes/BiomeSource.h"
|
||||||
#include "../../Minecraft.World/Util/IntCache.h"
|
|
||||||
#include "../../Minecraft.World/Level/Storage/LevelType.h"
|
#include "../../Minecraft.World/Level/Storage/LevelType.h"
|
||||||
#include "../../Minecraft.Client/Textures/Packs/TexturePackRepository.h"
|
#include "../../Minecraft.Client/Textures/Packs/TexturePackRepository.h"
|
||||||
#include "../../Minecraft.Client/Textures/Packs/TexturePack.h"
|
#include "../../Minecraft.Client/Textures/Packs/TexturePack.h"
|
||||||
|
|
@ -614,12 +613,14 @@ int CScene_MultiGameCreate::WarningTrialTexturePackReturned(
|
||||||
ProfileManager.GetPrimaryPad(), NULL, NULL,
|
ProfileManager.GetPrimaryPad(), NULL, NULL,
|
||||||
app.GetStringTable());
|
app.GetStringTable());
|
||||||
} else {
|
} else {
|
||||||
// This is called from a storage manager thread... need to set up
|
// 4J - This is called from a storage manager thread... need to set
|
||||||
// thread storage for IntCache as CreateGame requires this to search
|
// up thread storage for IntCache as CreateGame requires this to
|
||||||
// for a suitable seed if we haven't set a seed.
|
// search for a suitable seed if we haven't set a seed.
|
||||||
IntCache::CreateNewThreadStorage();
|
//
|
||||||
|
// 4jcraft - removed reliance on int caching, old 4J comment is
|
||||||
|
// moot, and we can search for suitable seeds without said cache
|
||||||
|
// initialization.
|
||||||
CreateGame(pScene, 0);
|
CreateGame(pScene, 0);
|
||||||
IntCache::ReleaseThreadStorage();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -825,9 +826,11 @@ int CScene_MultiGameCreate::ConfirmCreateReturned(
|
||||||
// This is called from a storage manager thread... need to set
|
// This is called from a storage manager thread... need to set
|
||||||
// up thread storage for IntCache as CreateGame requires this to
|
// up thread storage for IntCache as CreateGame requires this to
|
||||||
// search for a suitable seed if we haven't set a seed.
|
// search for a suitable seed if we haven't set a seed.
|
||||||
IntCache::CreateNewThreadStorage();
|
//
|
||||||
|
// 4jcraft - removed reliance on int caching, old 4J comment is
|
||||||
|
// moot, and we can search for suitable seeds without said cache
|
||||||
|
// initialization.
|
||||||
CreateGame(pClass, 0);
|
CreateGame(pClass, 0);
|
||||||
IntCache::ReleaseThreadStorage();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -895,7 +898,6 @@ int CScene_MultiGameCreate::StartGame_SignInReturned(void* pParam,
|
||||||
} else {
|
} else {
|
||||||
// This is NOT called from a storage manager thread, and is in
|
// This is NOT called from a storage manager thread, and is in
|
||||||
// fact called from the main thread in the Profile library tick.
|
// fact called from the main thread in the Profile library tick.
|
||||||
// Therefore we use the main threads IntCache.
|
|
||||||
CreateGame(pClass, dwLocalUsersMask);
|
CreateGame(pClass, dwLocalUsersMask);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -65,7 +65,6 @@ static void sigsegv_handler(int sig) {
|
||||||
#include "../../Rendering/Tesselator.h"
|
#include "../../Rendering/Tesselator.h"
|
||||||
#include "../../GameState/Options.h"
|
#include "../../GameState/Options.h"
|
||||||
#include "../Linux/Sentient/SentientManager.h"
|
#include "../Linux/Sentient/SentientManager.h"
|
||||||
#include "../../../Minecraft.World/Util/IntCache.h"
|
|
||||||
#include "../../Textures/Textures.h"
|
#include "../../Textures/Textures.h"
|
||||||
#include "../../../Minecraft.World/IO/Streams/Compression.h"
|
#include "../../../Minecraft.World/IO/Streams/Compression.h"
|
||||||
#include "../../../Minecraft.World/Level/Storage/OldChunkStorage.h"
|
#include "../../../Minecraft.World/Level/Storage/OldChunkStorage.h"
|
||||||
|
|
@ -870,7 +869,6 @@ return -1;
|
||||||
// Initialise TLS for AABB and Vec3 pools, for this main thread
|
// Initialise TLS for AABB and Vec3 pools, for this main thread
|
||||||
AABB::CreateNewThreadStorage();
|
AABB::CreateNewThreadStorage();
|
||||||
Vec3::CreateNewThreadStorage();
|
Vec3::CreateNewThreadStorage();
|
||||||
IntCache::CreateNewThreadStorage();
|
|
||||||
Compression::CreateNewThreadStorage();
|
Compression::CreateNewThreadStorage();
|
||||||
OldChunkStorage::CreateNewThreadStorage();
|
OldChunkStorage::CreateNewThreadStorage();
|
||||||
Level::enableLightingCache();
|
Level::enableLightingCache();
|
||||||
|
|
@ -940,7 +938,6 @@ return -1;
|
||||||
pMinecraft->soundEngine->tick(NULL, 0.0f);
|
pMinecraft->soundEngine->tick(NULL, 0.0f);
|
||||||
MemSect(0);
|
MemSect(0);
|
||||||
pMinecraft->textures->tick(true, false);
|
pMinecraft->textures->tick(true, false);
|
||||||
IntCache::Reset();
|
|
||||||
if (app.GetReallyChangingSessionType()) {
|
if (app.GetReallyChangingSessionType()) {
|
||||||
pMinecraft
|
pMinecraft
|
||||||
->tickAllConnections(); // Added to stop timing out when we
|
->tickAllConnections(); // Added to stop timing out when we
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -26,30 +26,31 @@
|
||||||
#include "../../../Minecraft.World/Util/ThreadName.h"
|
#include "../../../Minecraft.World/Util/ThreadName.h"
|
||||||
#include "../../GameState/StatsCounter.h"
|
#include "../../GameState/StatsCounter.h"
|
||||||
#include "../../UI/Screens/ConnectScreen.h"
|
#include "../../UI/Screens/ConnectScreen.h"
|
||||||
//#include "Social/SocialManager.h"
|
// #include "Social/SocialManager.h"
|
||||||
//#include "../Common/Leaderboards/LeaderboardManager.h"
|
// #include "../Common/Leaderboards/LeaderboardManager.h"
|
||||||
//#include "../Common/XUI/XUI_Scene_Container.h"
|
// #include "../Common/XUI/XUI_Scene_Container.h"
|
||||||
//#include "QNetManager.h"
|
// #include "QNetManager.h"
|
||||||
#include "../../Rendering/Tesselator.h"
|
#include "../../Rendering/Tesselator.h"
|
||||||
#include "Xbox_Awards_enum.h"
|
#include "Xbox_Awards_enum.h"
|
||||||
#include "../../GameState/Options.h"
|
#include "../../GameState/Options.h"
|
||||||
#include "Sentient/SentientManager.h"
|
#include "Sentient/SentientManager.h"
|
||||||
#include "../../../Minecraft.World/Util/IntCache.h"
|
|
||||||
#include "../../Textures/Textures.h"
|
#include "../../Textures/Textures.h"
|
||||||
#include "Resource.h"
|
#include "Resource.h"
|
||||||
|
|
||||||
|
#define THEME_NAME "584111F70AAAAAAA"
|
||||||
|
#define THEME_FILESIZE 2797568
|
||||||
|
|
||||||
#define THEME_NAME "584111F70AAAAAAA"
|
// #define THREE_MB 3145728 // minimum save size (checking for this on a
|
||||||
#define THEME_FILESIZE 2797568
|
// selected device) #define FIVE_MB 5242880 // minimum save size (checking for
|
||||||
|
// this on a selected device) #define FIFTY_TWO_MB (1024*1024*52) // Maximum TCR
|
||||||
//#define THREE_MB 3145728 // minimum save size (checking for this on a selected device)
|
// space required for a save (checking for this on a selected device)
|
||||||
//#define FIVE_MB 5242880 // minimum save size (checking for this on a selected device)
|
#define FIFTY_ONE_MB \
|
||||||
//#define FIFTY_TWO_MB (1024*1024*52) // Maximum TCR space required for a save (checking for this on a selected device)
|
(1000000 * 51) // Maximum TCR space required for a save is 52MB (checking
|
||||||
#define FIFTY_ONE_MB (1000000*51) // Maximum TCR space required for a save is 52MB (checking for this on a selected device)
|
// for this on a selected device)
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
//#define PROFILE_VERSION 3 // new version for the interim bug fix 166 TU
|
//#define PROFILE_VERSION 3 // new version for the interim bug fix 166 TU
|
||||||
#define NUM_PROFILE_VALUES 5
|
#define NUM_PROFILE_VALUES 5
|
||||||
#define NUM_PROFILE_SETTINGS 4
|
#define NUM_PROFILE_SETTINGS 4
|
||||||
DWORD dwProfileSettingsA[NUM_PROFILE_VALUES]=
|
DWORD dwProfileSettingsA[NUM_PROFILE_VALUES]=
|
||||||
{
|
{
|
||||||
|
|
@ -62,17 +63,15 @@ DWORD dwProfileSettingsA[NUM_PROFILE_VALUES]=
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------------
|
||||||
// Time Since fAppTime is a float, we need to keep the quadword app time
|
// Time Since fAppTime is a float, we need to keep the quadword app
|
||||||
// as a LARGE_INTEGER so that we don't lose precision after running
|
// time
|
||||||
// for a long time.
|
// as a LARGE_INTEGER so that we don't lose precision after
|
||||||
|
// running for a long time.
|
||||||
//-------------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
BOOL g_bWidescreen = TRUE;
|
BOOL g_bWidescreen = TRUE;
|
||||||
|
|
||||||
|
void DefineActions(void) {
|
||||||
void DefineActions(void)
|
|
||||||
{
|
|
||||||
#if 0
|
#if 0
|
||||||
// The app needs to define the actions required, and the possible mappings for these
|
// The app needs to define the actions required, and the possible mappings for these
|
||||||
|
|
||||||
|
|
@ -236,25 +235,23 @@ HRESULT InitD3D( IDirect3DDevice9 **ppDevice,
|
||||||
ppDevice );
|
ppDevice );
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
//#define MEMORY_TRACKING
|
// #define MEMORY_TRACKING
|
||||||
|
|
||||||
#ifdef MEMORY_TRACKING
|
#ifdef MEMORY_TRACKING
|
||||||
void ResetMem();
|
void ResetMem();
|
||||||
void DumpMem();
|
void DumpMem();
|
||||||
void MemPixStuff();
|
void MemPixStuff();
|
||||||
#else
|
#else
|
||||||
void MemSect(int sect)
|
void MemSect(int sect) {}
|
||||||
{
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
HINSTANCE g_hInst = NULL;
|
HINSTANCE g_hInst = NULL;
|
||||||
HWND g_hWnd = NULL;
|
HWND g_hWnd = NULL;
|
||||||
D3D_DRIVER_TYPE g_driverType = D3D_DRIVER_TYPE_NULL;
|
D3D_DRIVER_TYPE g_driverType = D3D_DRIVER_TYPE_NULL;
|
||||||
D3D_FEATURE_LEVEL g_featureLevel = D3D_FEATURE_LEVEL_11_0;
|
D3D_FEATURE_LEVEL g_featureLevel = D3D_FEATURE_LEVEL_11_0;
|
||||||
ID3D11Device* g_pd3dDevice = NULL;
|
ID3D11Device* g_pd3dDevice = NULL;
|
||||||
ID3D11DeviceContext* g_pImmediateContext = NULL;
|
ID3D11DeviceContext* g_pImmediateContext = NULL;
|
||||||
IDXGISwapChain* g_pSwapChain = NULL;
|
IDXGISwapChain* g_pSwapChain = NULL;
|
||||||
ID3D11RenderTargetView* g_pRenderTargetView = NULL;
|
ID3D11RenderTargetView* g_pRenderTargetView = NULL;
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
@ -267,66 +264,62 @@ ID3D11RenderTargetView* g_pRenderTargetView = NULL;
|
||||||
// WM_DESTROY - post a quit message and return
|
// WM_DESTROY - post a quit message and return
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam,
|
||||||
{
|
LPARAM lParam) {
|
||||||
int wmId, wmEvent;
|
int wmId, wmEvent;
|
||||||
PAINTSTRUCT ps;
|
PAINTSTRUCT ps;
|
||||||
HDC hdc;
|
HDC hdc;
|
||||||
|
|
||||||
switch (message)
|
switch (message) {
|
||||||
{
|
case WM_COMMAND:
|
||||||
case WM_COMMAND:
|
wmId = LOWORD(wParam);
|
||||||
wmId = LOWORD(wParam);
|
wmEvent = HIWORD(wParam);
|
||||||
wmEvent = HIWORD(wParam);
|
// Parse the menu selections:
|
||||||
// Parse the menu selections:
|
switch (wmId) {
|
||||||
switch (wmId)
|
case IDM_EXIT:
|
||||||
{
|
DestroyWindow(hWnd);
|
||||||
case IDM_EXIT:
|
break;
|
||||||
DestroyWindow(hWnd);
|
default:
|
||||||
break;
|
return DefWindowProc(hWnd, message, wParam, lParam);
|
||||||
default:
|
}
|
||||||
return DefWindowProc(hWnd, message, wParam, lParam);
|
break;
|
||||||
}
|
case WM_PAINT:
|
||||||
break;
|
hdc = BeginPaint(hWnd, &ps);
|
||||||
case WM_PAINT:
|
// TODO: Add any drawing code here...
|
||||||
hdc = BeginPaint(hWnd, &ps);
|
EndPaint(hWnd, &ps);
|
||||||
// TODO: Add any drawing code here...
|
break;
|
||||||
EndPaint(hWnd, &ps);
|
case WM_DESTROY:
|
||||||
break;
|
PostQuitMessage(0);
|
||||||
case WM_DESTROY:
|
break;
|
||||||
PostQuitMessage(0);
|
default:
|
||||||
break;
|
return DefWindowProc(hWnd, message, wParam, lParam);
|
||||||
default:
|
}
|
||||||
return DefWindowProc(hWnd, message, wParam, lParam);
|
return 0;
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// FUNCTION: MyRegisterClass()
|
// FUNCTION: MyRegisterClass()
|
||||||
//
|
//
|
||||||
// PURPOSE: Registers the window class.
|
// PURPOSE: Registers the window class.
|
||||||
//
|
//
|
||||||
ATOM MyRegisterClass(HINSTANCE hInstance)
|
ATOM MyRegisterClass(HINSTANCE hInstance) {
|
||||||
{
|
WNDCLASSEX wcex;
|
||||||
WNDCLASSEX wcex;
|
|
||||||
|
|
||||||
wcex.cbSize = sizeof(WNDCLASSEX);
|
wcex.cbSize = sizeof(WNDCLASSEX);
|
||||||
|
|
||||||
wcex.style = CS_HREDRAW | CS_VREDRAW;
|
wcex.style = CS_HREDRAW | CS_VREDRAW;
|
||||||
wcex.lpfnWndProc = WndProc;
|
wcex.lpfnWndProc = WndProc;
|
||||||
wcex.cbClsExtra = 0;
|
wcex.cbClsExtra = 0;
|
||||||
wcex.cbWndExtra = 0;
|
wcex.cbWndExtra = 0;
|
||||||
wcex.hInstance = hInstance;
|
wcex.hInstance = hInstance;
|
||||||
wcex.hIcon = LoadIcon(hInstance, "Minecraft");
|
wcex.hIcon = LoadIcon(hInstance, "Minecraft");
|
||||||
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
|
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
|
||||||
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
|
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
|
||||||
wcex.lpszMenuName = "Minecraft";
|
wcex.lpszMenuName = "Minecraft";
|
||||||
wcex.lpszClassName = "MinecraftClass";
|
wcex.lpszClassName = "MinecraftClass";
|
||||||
wcex.hIconSm = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_SMALL));
|
wcex.hIconSm = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_SMALL));
|
||||||
|
|
||||||
return RegisterClassEx(&wcex);
|
return RegisterClassEx(&wcex);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
@ -339,34 +332,31 @@ ATOM MyRegisterClass(HINSTANCE hInstance)
|
||||||
// In this function, we save the instance handle in a global variable and
|
// In this function, we save the instance handle in a global variable and
|
||||||
// create and display the main program window.
|
// create and display the main program window.
|
||||||
//
|
//
|
||||||
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
|
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) {
|
||||||
{
|
g_hInst = hInstance; // Store instance handle in our global variable
|
||||||
g_hInst = hInstance; // Store instance handle in our global variable
|
|
||||||
|
|
||||||
g_hWnd = CreateWindow("MinecraftClass", "Minecraft", WS_OVERLAPPEDWINDOW,
|
g_hWnd = CreateWindow("MinecraftClass", "Minecraft", WS_OVERLAPPEDWINDOW,
|
||||||
CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);
|
CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL,
|
||||||
|
hInstance, NULL);
|
||||||
|
|
||||||
if (!g_hWnd)
|
if (!g_hWnd) {
|
||||||
{
|
return FALSE;
|
||||||
return FALSE;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
ShowWindow(g_hWnd, nCmdShow);
|
ShowWindow(g_hWnd, nCmdShow);
|
||||||
UpdateWindow(g_hWnd);
|
UpdateWindow(g_hWnd);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
// Create Direct3D device and swap chain
|
// Create Direct3D device and swap chain
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
HRESULT InitDevice()
|
HRESULT InitDevice() {
|
||||||
{
|
|
||||||
HRESULT hr = S_OK;
|
HRESULT hr = S_OK;
|
||||||
|
|
||||||
RECT rc;
|
RECT rc;
|
||||||
GetClientRect( g_hWnd, &rc );
|
GetClientRect(g_hWnd, &rc);
|
||||||
UINT width = rc.right - rc.left;
|
UINT width = rc.right - rc.left;
|
||||||
UINT height = rc.bottom - rc.top;
|
UINT height = rc.bottom - rc.top;
|
||||||
|
|
||||||
|
|
@ -375,24 +365,22 @@ HRESULT InitDevice()
|
||||||
createDeviceFlags |= D3D11_CREATE_DEVICE_DEBUG;
|
createDeviceFlags |= D3D11_CREATE_DEVICE_DEBUG;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
D3D_DRIVER_TYPE driverTypes[] =
|
D3D_DRIVER_TYPE driverTypes[] = {
|
||||||
{
|
|
||||||
D3D_DRIVER_TYPE_HARDWARE,
|
D3D_DRIVER_TYPE_HARDWARE,
|
||||||
D3D_DRIVER_TYPE_WARP,
|
D3D_DRIVER_TYPE_WARP,
|
||||||
D3D_DRIVER_TYPE_REFERENCE,
|
D3D_DRIVER_TYPE_REFERENCE,
|
||||||
};
|
};
|
||||||
UINT numDriverTypes = ARRAYSIZE( driverTypes );
|
UINT numDriverTypes = ARRAYSIZE(driverTypes);
|
||||||
|
|
||||||
D3D_FEATURE_LEVEL featureLevels[] =
|
D3D_FEATURE_LEVEL featureLevels[] = {
|
||||||
{
|
|
||||||
D3D_FEATURE_LEVEL_11_0,
|
D3D_FEATURE_LEVEL_11_0,
|
||||||
D3D_FEATURE_LEVEL_10_1,
|
D3D_FEATURE_LEVEL_10_1,
|
||||||
D3D_FEATURE_LEVEL_10_0,
|
D3D_FEATURE_LEVEL_10_0,
|
||||||
};
|
};
|
||||||
UINT numFeatureLevels = ARRAYSIZE( featureLevels );
|
UINT numFeatureLevels = ARRAYSIZE(featureLevels);
|
||||||
|
|
||||||
DXGI_SWAP_CHAIN_DESC sd;
|
DXGI_SWAP_CHAIN_DESC sd;
|
||||||
ZeroMemory( &sd, sizeof( sd ) );
|
ZeroMemory(&sd, sizeof(sd));
|
||||||
sd.BufferCount = 1;
|
sd.BufferCount = 1;
|
||||||
sd.BufferDesc.Width = width;
|
sd.BufferDesc.Width = width;
|
||||||
sd.BufferDesc.Height = height;
|
sd.BufferDesc.Height = height;
|
||||||
|
|
@ -405,29 +393,29 @@ HRESULT InitDevice()
|
||||||
sd.SampleDesc.Quality = 0;
|
sd.SampleDesc.Quality = 0;
|
||||||
sd.Windowed = TRUE;
|
sd.Windowed = TRUE;
|
||||||
|
|
||||||
for( UINT driverTypeIndex = 0; driverTypeIndex < numDriverTypes; driverTypeIndex++ )
|
for (UINT driverTypeIndex = 0; driverTypeIndex < numDriverTypes;
|
||||||
{
|
driverTypeIndex++) {
|
||||||
g_driverType = driverTypes[driverTypeIndex];
|
g_driverType = driverTypes[driverTypeIndex];
|
||||||
hr = D3D11CreateDeviceAndSwapChain( NULL, g_driverType, NULL, createDeviceFlags, featureLevels, numFeatureLevels,
|
hr = D3D11CreateDeviceAndSwapChain(
|
||||||
D3D11_SDK_VERSION, &sd, &g_pSwapChain, &g_pd3dDevice, &g_featureLevel, &g_pImmediateContext );
|
NULL, g_driverType, NULL, createDeviceFlags, featureLevels,
|
||||||
if( SUCCEEDED( hr ) )
|
numFeatureLevels, D3D11_SDK_VERSION, &sd, &g_pSwapChain,
|
||||||
break;
|
&g_pd3dDevice, &g_featureLevel, &g_pImmediateContext);
|
||||||
|
if (SUCCEEDED(hr)) break;
|
||||||
}
|
}
|
||||||
if( FAILED( hr ) )
|
if (FAILED(hr)) return hr;
|
||||||
return hr;
|
|
||||||
|
|
||||||
// Create a render target view
|
// Create a render target view
|
||||||
ID3D11Texture2D* pBackBuffer = NULL;
|
ID3D11Texture2D* pBackBuffer = NULL;
|
||||||
hr = g_pSwapChain->GetBuffer( 0, __uuidof( ID3D11Texture2D ), ( LPVOID* )&pBackBuffer );
|
hr = g_pSwapChain->GetBuffer(0, __uuidof(ID3D11Texture2D),
|
||||||
if( FAILED( hr ) )
|
(LPVOID*)&pBackBuffer);
|
||||||
return hr;
|
if (FAILED(hr)) return hr;
|
||||||
|
|
||||||
hr = g_pd3dDevice->CreateRenderTargetView( pBackBuffer, NULL, &g_pRenderTargetView );
|
hr = g_pd3dDevice->CreateRenderTargetView(pBackBuffer, NULL,
|
||||||
|
&g_pRenderTargetView);
|
||||||
pBackBuffer->Release();
|
pBackBuffer->Release();
|
||||||
if( FAILED( hr ) )
|
if (FAILED(hr)) return hr;
|
||||||
return hr;
|
|
||||||
|
|
||||||
g_pImmediateContext->OMSetRenderTargets( 1, &g_pRenderTargetView, NULL );
|
g_pImmediateContext->OMSetRenderTargets(1, &g_pRenderTargetView, NULL);
|
||||||
|
|
||||||
// Setup the viewport
|
// Setup the viewport
|
||||||
D3D11_VIEWPORT vp;
|
D3D11_VIEWPORT vp;
|
||||||
|
|
@ -437,59 +425,51 @@ HRESULT InitDevice()
|
||||||
vp.MaxDepth = 1.0f;
|
vp.MaxDepth = 1.0f;
|
||||||
vp.TopLeftX = 0;
|
vp.TopLeftX = 0;
|
||||||
vp.TopLeftY = 0;
|
vp.TopLeftY = 0;
|
||||||
g_pImmediateContext->RSSetViewports( 1, &vp );
|
g_pImmediateContext->RSSetViewports(1, &vp);
|
||||||
|
|
||||||
RenderManager.Initialise(g_pd3dDevice, g_pSwapChain);
|
RenderManager.Initialise(g_pd3dDevice, g_pSwapChain);
|
||||||
|
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
// Render the frame
|
// Render the frame
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
void Render()
|
void Render() {
|
||||||
{
|
|
||||||
// Just clear the backbuffer
|
// Just clear the backbuffer
|
||||||
float ClearColor[4] = { 0.0f, 0.125f, 0.3f, 1.0f }; //red,green,blue,alpha
|
float ClearColor[4] = {0.0f, 0.125f, 0.3f, 1.0f}; // red,green,blue,alpha
|
||||||
|
|
||||||
g_pImmediateContext->ClearRenderTargetView( g_pRenderTargetView, ClearColor );
|
g_pImmediateContext->ClearRenderTargetView(g_pRenderTargetView, ClearColor);
|
||||||
g_pSwapChain->Present( 0, 0 );
|
g_pSwapChain->Present(0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
// Clean up the objects we've created
|
// Clean up the objects we've created
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
void CleanupDevice()
|
void CleanupDevice() {
|
||||||
{
|
if (g_pImmediateContext) g_pImmediateContext->ClearState();
|
||||||
if( g_pImmediateContext ) g_pImmediateContext->ClearState();
|
|
||||||
|
|
||||||
if( g_pRenderTargetView ) g_pRenderTargetView->Release();
|
if (g_pRenderTargetView) g_pRenderTargetView->Release();
|
||||||
if( g_pSwapChain ) g_pSwapChain->Release();
|
if (g_pSwapChain) g_pSwapChain->Release();
|
||||||
if( g_pImmediateContext ) g_pImmediateContext->Release();
|
if (g_pImmediateContext) g_pImmediateContext->Release();
|
||||||
if( g_pd3dDevice ) g_pd3dDevice->Release();
|
if (g_pd3dDevice) g_pd3dDevice->Release();
|
||||||
}
|
}
|
||||||
|
|
||||||
int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
|
int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
|
||||||
_In_opt_ HINSTANCE hPrevInstance,
|
_In_opt_ HINSTANCE hPrevInstance, _In_ LPTSTR lpCmdLine,
|
||||||
_In_ LPTSTR lpCmdLine,
|
_In_ int nCmdShow) {
|
||||||
_In_ int nCmdShow)
|
UNREFERENCED_PARAMETER(hPrevInstance);
|
||||||
{
|
UNREFERENCED_PARAMETER(lpCmdLine);
|
||||||
UNREFERENCED_PARAMETER(hPrevInstance);
|
|
||||||
UNREFERENCED_PARAMETER(lpCmdLine);
|
|
||||||
|
|
||||||
// Initialize global strings
|
// Initialize global strings
|
||||||
MyRegisterClass(hInstance);
|
MyRegisterClass(hInstance);
|
||||||
|
|
||||||
// Perform application initialization:
|
// Perform application initialization:
|
||||||
if (!InitInstance (hInstance, nCmdShow))
|
if (!InitInstance(hInstance, nCmdShow)) {
|
||||||
{
|
return FALSE;
|
||||||
return FALSE;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if( FAILED( InitDevice() ) )
|
if (FAILED(InitDevice())) {
|
||||||
{
|
|
||||||
CleanupDevice();
|
CleanupDevice();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -513,13 +493,14 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
|
||||||
return (int) msg.wParam;
|
return (int) msg.wParam;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static bool bTrialTimerDisplayed=true;
|
static bool bTrialTimerDisplayed = true;
|
||||||
|
|
||||||
#ifdef MEMORY_TRACKING
|
#ifdef MEMORY_TRACKING
|
||||||
ResetMem();
|
ResetMem();
|
||||||
MEMORYSTATUS memStat;
|
MEMORYSTATUS memStat;
|
||||||
GlobalMemoryStatus(&memStat);
|
GlobalMemoryStatus(&memStat);
|
||||||
printf("RESETMEM start: Avail. phys %d\n",memStat.dwAvailPhys/(1024*1024));
|
printf("RESETMEM start: Avail. phys %d\n",
|
||||||
|
memStat.dwAvailPhys / (1024 * 1024));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
|
|
@ -545,13 +526,12 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
RenderManager.Initialise(g_pd3dDevice, g_pSwapChain);
|
RenderManager.Initialise(g_pd3dDevice, g_pSwapChain);
|
||||||
|
|
||||||
////////////////
|
////////////////
|
||||||
// Initialise //
|
// Initialise //
|
||||||
////////////////
|
////////////////
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
// 4J Stu - XACT was creating these automatically, but we need them for QNet. The setup params
|
// 4J Stu - XACT was creating these automatically, but we need them for QNet. The setup params
|
||||||
|
|
@ -676,19 +656,16 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
|
||||||
// Sentient !
|
// Sentient !
|
||||||
hr = SentientManager.Init();
|
hr = SentientManager.Init();
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
// Initialise TLS for tesselator, for this main thread
|
// Initialise TLS for tesselator, for this main thread
|
||||||
Tesselator::CreateNewThreadStorage(1024*1024);
|
Tesselator::CreateNewThreadStorage(1024 * 1024);
|
||||||
// Initialise TLS for AABB and Vec3 pools, for this main thread
|
// Initialise TLS for AABB and Vec3 pools, for this main thread
|
||||||
AABB::CreateNewThreadStorage();
|
AABB::CreateNewThreadStorage();
|
||||||
Vec3::CreateNewThreadStorage();
|
Vec3::CreateNewThreadStorage();
|
||||||
IntCache::CreateNewThreadStorage();
|
Level::enableLightingCache();
|
||||||
Level::enableLightingCache();
|
|
||||||
|
|
||||||
|
Minecraft::main();
|
||||||
Minecraft::main();
|
Minecraft* pMinecraft = Minecraft::GetInstance();
|
||||||
Minecraft *pMinecraft=Minecraft::GetInstance();
|
|
||||||
#if 0
|
#if 0
|
||||||
//bool bDisplayPauseMenu=false;
|
//bool bDisplayPauseMenu=false;
|
||||||
|
|
||||||
|
|
@ -722,11 +699,9 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
|
||||||
|
|
||||||
DWORD initData=0;
|
DWORD initData=0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef _FINAL_BUILD
|
#ifndef _FINAL_BUILD
|
||||||
#ifndef _DEBUG
|
#ifndef _DEBUG
|
||||||
#pragma message(__LOC__"Need to define the _FINAL_BUILD before submission")
|
#pragma message(__LOC__ "Need to define the _FINAL_BUILD before submission")
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
@ -738,7 +713,7 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
|
||||||
app.NavigateToScene(XUSER_INDEX_ANY,CXboxMinecraftApp::e_xuiScene_Intro,&initData);
|
app.NavigateToScene(XUSER_INDEX_ANY,CXboxMinecraftApp::e_xuiScene_Intro,&initData);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//Sleep(10000);
|
// Sleep(10000);
|
||||||
#if 0
|
#if 0
|
||||||
// Intro loop ?
|
// Intro loop ?
|
||||||
while(app.IntroRunning())
|
while(app.IntroRunning())
|
||||||
|
|
@ -762,8 +737,7 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
while( TRUE )
|
while (TRUE) {
|
||||||
{
|
|
||||||
#if 0
|
#if 0
|
||||||
if(pMinecraft->soundEngine->isStreamingWavebankReady() &&
|
if(pMinecraft->soundEngine->isStreamingWavebankReady() &&
|
||||||
!pMinecraft->soundEngine->isPlayingStreamingGameMusic() &&
|
!pMinecraft->soundEngine->isPlayingStreamingGameMusic() &&
|
||||||
|
|
@ -773,81 +747,79 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
|
||||||
pMinecraft->soundEngine->playStreaming(L"", 0, 0, 0, 0, 0, false);
|
pMinecraft->soundEngine->playStreaming(L"", 0, 0, 0, 0, 0, false);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
app.UpdateTime();
|
app.UpdateTime();
|
||||||
PIXBeginNamedEvent(0,"Input manager tick");
|
PIXBeginNamedEvent(0, "Input manager tick");
|
||||||
// InputManager.Tick();
|
// InputManager.Tick();
|
||||||
PIXEndNamedEvent();
|
PIXEndNamedEvent();
|
||||||
PIXBeginNamedEvent(0,"Profile manager tick");
|
PIXBeginNamedEvent(0, "Profile manager tick");
|
||||||
// ProfileManager.Tick();
|
// ProfileManager.Tick();
|
||||||
PIXEndNamedEvent();
|
PIXEndNamedEvent();
|
||||||
PIXBeginNamedEvent(0,"Storage manager tick");
|
PIXBeginNamedEvent(0, "Storage manager tick");
|
||||||
// StorageManager.Tick();
|
// StorageManager.Tick();
|
||||||
PIXEndNamedEvent();
|
PIXEndNamedEvent();
|
||||||
PIXBeginNamedEvent(0,"Render manager tick");
|
PIXBeginNamedEvent(0, "Render manager tick");
|
||||||
RenderManager.Tick();
|
RenderManager.Tick();
|
||||||
PIXEndNamedEvent();
|
PIXEndNamedEvent();
|
||||||
|
|
||||||
// Tick the social networking manager.
|
// Tick the social networking manager.
|
||||||
PIXBeginNamedEvent(0,"Social network manager tick");
|
PIXBeginNamedEvent(0, "Social network manager tick");
|
||||||
// CSocialManager::Instance()->Tick();
|
// CSocialManager::Instance()->Tick();
|
||||||
PIXEndNamedEvent();
|
PIXEndNamedEvent();
|
||||||
|
|
||||||
// Tick sentient.
|
// Tick sentient.
|
||||||
PIXBeginNamedEvent(0,"Sentient tick");
|
PIXBeginNamedEvent(0, "Sentient tick");
|
||||||
MemSect(37);
|
MemSect(37);
|
||||||
// SentientManager.Tick();
|
// SentientManager.Tick();
|
||||||
MemSect(0);
|
MemSect(0);
|
||||||
PIXEndNamedEvent();
|
PIXEndNamedEvent();
|
||||||
|
|
||||||
PIXBeginNamedEvent(0,"Qnet do work #1");
|
PIXBeginNamedEvent(0, "Qnet do work #1");
|
||||||
// g_qNetManager.DoWork();
|
// g_qNetManager.DoWork();
|
||||||
PIXEndNamedEvent();
|
PIXEndNamedEvent();
|
||||||
|
|
||||||
// LeaderboardManager::Instance()->Tick();
|
// LeaderboardManager::Instance()->Tick();
|
||||||
// Render game graphics.
|
// Render game graphics.
|
||||||
if(app.GetGameStarted())
|
if (app.GetGameStarted()) {
|
||||||
{
|
pMinecraft->run_middle();
|
||||||
pMinecraft->run_middle();
|
app.SetAppPaused(
|
||||||
app.SetAppPaused( g_qNetManager.IsLocalGame() && g_qNetManager.GetPlayerCount() == 1 && app.IsPauseMenuDisplayed(ProfileManager.GetPrimaryPad()) );
|
g_qNetManager.IsLocalGame() &&
|
||||||
}
|
g_qNetManager.GetPlayerCount() == 1 &&
|
||||||
else
|
app.IsPauseMenuDisplayed(ProfileManager.GetPrimaryPad()));
|
||||||
{
|
} else {
|
||||||
MemSect(28);
|
MemSect(28);
|
||||||
pMinecraft->soundEngine->update(NULL, 0.0f);
|
pMinecraft->soundEngine->update(NULL, 0.0f);
|
||||||
MemSect(0);
|
MemSect(0);
|
||||||
pMinecraft->soundEngine->playMusicTick();
|
pMinecraft->soundEngine->playMusicTick();
|
||||||
pMinecraft->textures->tick(true,false);
|
pMinecraft->textures->tick(true, false);
|
||||||
IntCache::Reset();
|
app.SetGameStarted(true);
|
||||||
app.SetGameStarted(true);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
app.ToggleDimensionIfRequested();
|
|
||||||
|
|
||||||
|
app.ToggleDimensionIfRequested();
|
||||||
|
|
||||||
#ifdef MEMORY_TRACKING
|
#ifdef MEMORY_TRACKING
|
||||||
static bool bResetMemTrack = false;
|
static bool bResetMemTrack = false;
|
||||||
static bool bDumpMemTrack = false;
|
static bool bDumpMemTrack = false;
|
||||||
|
|
||||||
MemPixStuff();
|
MemPixStuff();
|
||||||
|
|
||||||
if( bResetMemTrack )
|
if (bResetMemTrack) {
|
||||||
{
|
ResetMem();
|
||||||
ResetMem();
|
MEMORYSTATUS memStat;
|
||||||
MEMORYSTATUS memStat;
|
GlobalMemoryStatus(&memStat);
|
||||||
GlobalMemoryStatus(&memStat);
|
printf("RESETMEM: Avail. phys %d\n",
|
||||||
printf("RESETMEM: Avail. phys %d\n",memStat.dwAvailPhys/(1024*1024));
|
memStat.dwAvailPhys / (1024 * 1024));
|
||||||
bResetMemTrack = false;
|
bResetMemTrack = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( bDumpMemTrack )
|
if (bDumpMemTrack) {
|
||||||
{
|
DumpMem();
|
||||||
DumpMem();
|
bDumpMemTrack = false;
|
||||||
bDumpMemTrack = false;
|
MEMORYSTATUS memStat;
|
||||||
MEMORYSTATUS memStat;
|
GlobalMemoryStatus(&memStat);
|
||||||
GlobalMemoryStatus(&memStat);
|
printf("DUMPMEM: Avail. phys %d\n",
|
||||||
printf("DUMPMEM: Avail. phys %d\n",memStat.dwAvailPhys/(1024*1024));
|
memStat.dwAvailPhys / (1024 * 1024));
|
||||||
printf("Renderer used: %d\n",RenderManager.CBuffSize(-1));
|
printf("Renderer used: %d\n", RenderManager.CBuffSize(-1));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#if 0
|
#if 0
|
||||||
static bool bDumpTextureUsage = false;
|
static bool bDumpTextureUsage = false;
|
||||||
|
|
@ -897,10 +869,10 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
|
||||||
|
|
||||||
RenderManager.Set_matrixDirty();
|
RenderManager.Set_matrixDirty();
|
||||||
#endif
|
#endif
|
||||||
// Present the frame.
|
// Present the frame.
|
||||||
PIXBeginNamedEvent(0,"Frame present");
|
PIXBeginNamedEvent(0, "Frame present");
|
||||||
RenderManager.Present();
|
RenderManager.Present();
|
||||||
PIXEndNamedEvent();
|
PIXEndNamedEvent();
|
||||||
#if 0
|
#if 0
|
||||||
app.CheckMenuDisplayed();
|
app.CheckMenuDisplayed();
|
||||||
PIXBeginNamedEvent(0,"Profile load check");
|
PIXBeginNamedEvent(0,"Profile load check");
|
||||||
|
|
@ -988,21 +960,21 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Fix for #7318 - Title crashes after short soak in the leaderboards menu
|
// Fix for #7318 - Title crashes after short soak in the leaderboards
|
||||||
// A memory leak was caused because the icon renderer kept creating new Vec3's because the pool wasn't reset
|
// menu A memory leak was caused because the icon renderer kept creating
|
||||||
Vec3::resetPool();
|
// new Vec3's because the pool wasn't reset
|
||||||
}
|
Vec3::resetPool();
|
||||||
|
}
|
||||||
|
|
||||||
// Free resources, unregister custom classes, and exit.
|
// Free resources, unregister custom classes, and exit.
|
||||||
// app.Uninit();
|
// app.Uninit();
|
||||||
g_pd3dDevice->Release();
|
g_pd3dDevice->Release();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef MEMORY_TRACKING
|
#ifdef MEMORY_TRACKING
|
||||||
|
|
||||||
int totalAllocGen = 0;
|
int totalAllocGen = 0;
|
||||||
std::unordered_map<int,int> allocCounts;
|
std::unordered_map<int, int> allocCounts;
|
||||||
bool trackEnable = false;
|
bool trackEnable = false;
|
||||||
bool trackStarted = false;
|
bool trackStarted = false;
|
||||||
volatile size_t sizeCheckMin = 1160;
|
volatile size_t sizeCheckMin = 1160;
|
||||||
|
|
@ -1011,181 +983,159 @@ volatile int sectCheck = 48;
|
||||||
CRITICAL_SECTION memCS;
|
CRITICAL_SECTION memCS;
|
||||||
DWORD tlsIdx;
|
DWORD tlsIdx;
|
||||||
|
|
||||||
LPVOID XMemAlloc(SIZE_T dwSize, DWORD dwAllocAttributes)
|
LPVOID XMemAlloc(SIZE_T dwSize, DWORD dwAllocAttributes) {
|
||||||
{
|
if (!trackStarted) {
|
||||||
if( !trackStarted )
|
void* p = XMemAllocDefault(dwSize, dwAllocAttributes);
|
||||||
{
|
size_t realSize = XMemSizeDefault(p, dwAllocAttributes);
|
||||||
void *p = XMemAllocDefault(dwSize,dwAllocAttributes);
|
totalAllocGen += realSize;
|
||||||
size_t realSize = XMemSizeDefault(p, dwAllocAttributes);
|
return p;
|
||||||
totalAllocGen += realSize;
|
}
|
||||||
return p;
|
|
||||||
}
|
|
||||||
|
|
||||||
EnterCriticalSection(&memCS);
|
EnterCriticalSection(&memCS);
|
||||||
|
|
||||||
void *p=XMemAllocDefault(dwSize + 16,dwAllocAttributes);
|
void* p = XMemAllocDefault(dwSize + 16, dwAllocAttributes);
|
||||||
size_t realSize = XMemSizeDefault(p,dwAllocAttributes) - 16;
|
size_t realSize = XMemSizeDefault(p, dwAllocAttributes) - 16;
|
||||||
|
|
||||||
if( trackEnable )
|
if (trackEnable) {
|
||||||
{
|
|
||||||
#if 1
|
#if 1
|
||||||
int sect = ((int) TlsGetValue(tlsIdx)) & 0x3f;
|
int sect = ((int)TlsGetValue(tlsIdx)) & 0x3f;
|
||||||
*(((unsigned char *)p)+realSize) = sect;
|
*(((unsigned char*)p) + realSize) = sect;
|
||||||
|
|
||||||
if( ( realSize >= sizeCheckMin ) && ( realSize <= sizeCheckMax ) && ( ( sect == sectCheck ) || ( sectCheck == -1 ) ) )
|
if ((realSize >= sizeCheckMin) && (realSize <= sizeCheckMax) &&
|
||||||
{
|
((sect == sectCheck) || (sectCheck == -1))) {
|
||||||
app.DebugPrintf("Found one\n");
|
app.DebugPrintf("Found one\n");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if( p )
|
if (p) {
|
||||||
{
|
totalAllocGen += realSize;
|
||||||
totalAllocGen += realSize;
|
trackEnable = false;
|
||||||
trackEnable = false;
|
int key = (sect << 26) | realSize;
|
||||||
int key = ( sect << 26 ) | realSize;
|
int oldCount = allocCounts[key];
|
||||||
int oldCount = allocCounts[key];
|
allocCounts[key] = oldCount + 1;
|
||||||
allocCounts[key] = oldCount + 1;
|
|
||||||
|
|
||||||
trackEnable = true;
|
trackEnable = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LeaveCriticalSection(&memCS);
|
LeaveCriticalSection(&memCS);
|
||||||
|
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
void* operator new (size_t size)
|
void* operator new(size_t size) {
|
||||||
{
|
return (unsigned char*)XMemAlloc(
|
||||||
return (unsigned char *)XMemAlloc(size,MAKE_XALLOC_ATTRIBUTES(0,FALSE,TRUE,FALSE,0,XALLOC_PHYSICAL_ALIGNMENT_DEFAULT,XALLOC_MEMPROTECT_READWRITE,FALSE,XALLOC_MEMTYPE_HEAP));
|
size, MAKE_XALLOC_ATTRIBUTES(
|
||||||
|
0, FALSE, TRUE, FALSE, 0, XALLOC_PHYSICAL_ALIGNMENT_DEFAULT,
|
||||||
|
XALLOC_MEMPROTECT_READWRITE, FALSE, XALLOC_MEMTYPE_HEAP));
|
||||||
}
|
}
|
||||||
|
|
||||||
void operator delete (void *p)
|
void operator delete(void* p) {
|
||||||
{
|
XMemFree(p, MAKE_XALLOC_ATTRIBUTES(
|
||||||
XMemFree(p,MAKE_XALLOC_ATTRIBUTES(0,FALSE,TRUE,FALSE,0,XALLOC_PHYSICAL_ALIGNMENT_DEFAULT,XALLOC_MEMPROTECT_READWRITE,FALSE,XALLOC_MEMTYPE_HEAP));
|
0, FALSE, TRUE, FALSE, 0, XALLOC_PHYSICAL_ALIGNMENT_DEFAULT,
|
||||||
|
XALLOC_MEMPROTECT_READWRITE, FALSE, XALLOC_MEMTYPE_HEAP));
|
||||||
}
|
}
|
||||||
|
|
||||||
void WINAPI XMemFree(PVOID pAddress, DWORD dwAllocAttributes)
|
void WINAPI XMemFree(PVOID pAddress, DWORD dwAllocAttributes) {
|
||||||
{
|
bool special = false;
|
||||||
bool special = false;
|
if (dwAllocAttributes == 0) {
|
||||||
if( dwAllocAttributes == 0 )
|
dwAllocAttributes = MAKE_XALLOC_ATTRIBUTES(
|
||||||
{
|
0, FALSE, TRUE, FALSE, 0, XALLOC_PHYSICAL_ALIGNMENT_DEFAULT,
|
||||||
dwAllocAttributes = MAKE_XALLOC_ATTRIBUTES(0,FALSE,TRUE,FALSE,0,XALLOC_PHYSICAL_ALIGNMENT_DEFAULT,XALLOC_MEMPROTECT_READWRITE,FALSE,XALLOC_MEMTYPE_HEAP);
|
XALLOC_MEMPROTECT_READWRITE, FALSE, XALLOC_MEMTYPE_HEAP);
|
||||||
special = true;
|
special = true;
|
||||||
}
|
}
|
||||||
if(!trackStarted )
|
if (!trackStarted) {
|
||||||
{
|
size_t realSize = XMemSizeDefault(pAddress, dwAllocAttributes);
|
||||||
size_t realSize = XMemSizeDefault(pAddress, dwAllocAttributes);
|
XMemFreeDefault(pAddress, dwAllocAttributes);
|
||||||
XMemFreeDefault(pAddress, dwAllocAttributes);
|
totalAllocGen -= realSize;
|
||||||
totalAllocGen -= realSize;
|
return;
|
||||||
return;
|
}
|
||||||
}
|
EnterCriticalSection(&memCS);
|
||||||
EnterCriticalSection(&memCS);
|
if (pAddress) {
|
||||||
if( pAddress )
|
size_t realSize = XMemSizeDefault(pAddress, dwAllocAttributes) - 16;
|
||||||
{
|
|
||||||
size_t realSize = XMemSizeDefault(pAddress, dwAllocAttributes) - 16;
|
|
||||||
|
|
||||||
if(trackEnable)
|
if (trackEnable) {
|
||||||
{
|
int sect = *(((unsigned char*)pAddress) + realSize);
|
||||||
int sect = *(((unsigned char *)pAddress)+realSize);
|
totalAllocGen -= realSize;
|
||||||
totalAllocGen -= realSize;
|
trackEnable = false;
|
||||||
trackEnable = false;
|
int key = (sect << 26) | realSize;
|
||||||
int key = ( sect << 26 ) | realSize;
|
int oldCount = allocCounts[key];
|
||||||
int oldCount = allocCounts[key];
|
allocCounts[key] = oldCount - 1;
|
||||||
allocCounts[key] = oldCount - 1;
|
trackEnable = true;
|
||||||
trackEnable = true;
|
}
|
||||||
|
XMemFreeDefault(pAddress, dwAllocAttributes);
|
||||||
}
|
}
|
||||||
XMemFreeDefault(pAddress, dwAllocAttributes);
|
LeaveCriticalSection(&memCS);
|
||||||
}
|
|
||||||
LeaveCriticalSection(&memCS);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SIZE_T WINAPI XMemSize(
|
SIZE_T WINAPI XMemSize(PVOID pAddress, DWORD dwAllocAttributes) {
|
||||||
PVOID pAddress,
|
if (trackStarted) {
|
||||||
DWORD dwAllocAttributes
|
return XMemSizeDefault(pAddress, dwAllocAttributes) - 16;
|
||||||
)
|
} else {
|
||||||
{
|
return XMemSizeDefault(pAddress, dwAllocAttributes);
|
||||||
if( trackStarted )
|
}
|
||||||
{
|
|
||||||
return XMemSizeDefault(pAddress, dwAllocAttributes) - 16;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return XMemSizeDefault(pAddress, dwAllocAttributes);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DumpMem() {
|
||||||
void DumpMem()
|
int totalLeak = 0;
|
||||||
{
|
for (AUTO_VAR(it, allocCounts.begin()); it != allocCounts.end(); it++) {
|
||||||
int totalLeak = 0;
|
if (it->second > 0) {
|
||||||
for(AUTO_VAR(it, allocCounts.begin()); it != allocCounts.end(); it++ )
|
app.DebugPrintf("%d %d %d %d\n", (it->first >> 26) & 0x3f,
|
||||||
{
|
it->first & 0x03ffffff, it->second,
|
||||||
if(it->second > 0 )
|
(it->first & 0x03ffffff) * it->second);
|
||||||
{
|
totalLeak += (it->first & 0x03ffffff) * it->second;
|
||||||
app.DebugPrintf("%d %d %d %d\n",( it->first >> 26 ) & 0x3f,it->first & 0x03ffffff, it->second, (it->first & 0x03ffffff) * it->second);
|
}
|
||||||
totalLeak += ( it->first & 0x03ffffff ) * it->second;
|
}
|
||||||
}
|
app.DebugPrintf("Total %d\n", totalLeak);
|
||||||
}
|
|
||||||
app.DebugPrintf("Total %d\n",totalLeak);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ResetMem()
|
void ResetMem() {
|
||||||
{
|
if (!trackStarted) {
|
||||||
if( !trackStarted )
|
trackEnable = true;
|
||||||
{
|
trackStarted = true;
|
||||||
trackEnable = true;
|
totalAllocGen = 0;
|
||||||
trackStarted = true;
|
InitializeCriticalSection(&memCS);
|
||||||
totalAllocGen = 0;
|
tlsIdx = TlsAlloc();
|
||||||
InitializeCriticalSection(&memCS);
|
}
|
||||||
tlsIdx = TlsAlloc();
|
EnterCriticalSection(&memCS);
|
||||||
}
|
trackEnable = false;
|
||||||
EnterCriticalSection(&memCS);
|
allocCounts.clear();
|
||||||
trackEnable = false;
|
trackEnable = true;
|
||||||
allocCounts.clear();
|
LeaveCriticalSection(&memCS);
|
||||||
trackEnable = true;
|
|
||||||
LeaveCriticalSection(&memCS);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MemSect(int section)
|
void MemSect(int section) {
|
||||||
{
|
unsigned int value = (unsigned int)TlsGetValue(tlsIdx);
|
||||||
unsigned int value = (unsigned int)TlsGetValue(tlsIdx);
|
if (section == 0) // pop
|
||||||
if( section == 0 ) // pop
|
{
|
||||||
{
|
value = (value >> 6) & 0x03ffffff;
|
||||||
value = (value >> 6) & 0x03ffffff;
|
} else {
|
||||||
}
|
value = (value << 6) | section;
|
||||||
else
|
}
|
||||||
{
|
TlsSetValue(tlsIdx, (LPVOID)value);
|
||||||
value = (value << 6) | section;
|
|
||||||
}
|
|
||||||
TlsSetValue(tlsIdx, (LPVOID)value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MemPixStuff()
|
void MemPixStuff() {
|
||||||
{
|
const int MAX_SECT = 46;
|
||||||
const int MAX_SECT = 46;
|
|
||||||
|
|
||||||
int totals[MAX_SECT] = {0};
|
int totals[MAX_SECT] = {0};
|
||||||
|
|
||||||
for(AUTO_VAR(it, allocCounts.begin()); it != allocCounts.end(); it++ )
|
for (AUTO_VAR(it, allocCounts.begin()); it != allocCounts.end(); it++) {
|
||||||
{
|
if (it->second > 0) {
|
||||||
if(it->second > 0 )
|
int sect = (it->first >> 26) & 0x3f;
|
||||||
{
|
int bytes = it->first & 0x03ffffff;
|
||||||
int sect = ( it->first >> 26 ) & 0x3f;
|
totals[sect] += bytes * it->second;
|
||||||
int bytes = it->first & 0x03ffffff;
|
}
|
||||||
totals[sect] += bytes * it->second;
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned int allSectsTotal = 0;
|
unsigned int allSectsTotal = 0;
|
||||||
for( int i = 0; i < MAX_SECT; i++ )
|
for (int i = 0; i < MAX_SECT; i++) {
|
||||||
{
|
allSectsTotal += totals[i];
|
||||||
allSectsTotal += totals[i];
|
PIXAddNamedCounter(((float)totals[i]) / 1024.0f, "MemSect%d", i);
|
||||||
PIXAddNamedCounter(((float)totals[i])/1024.0f,"MemSect%d",i);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
PIXAddNamedCounter(((float)allSectsTotal)/(4096.0f),"MemSect total pages");
|
PIXAddNamedCounter(((float)allSectsTotal) / (4096.0f),
|
||||||
|
"MemSect total pages");
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -36,7 +36,6 @@
|
||||||
#include "../../Minecraft.World/Util/JavaMath.h"
|
#include "../../Minecraft.World/Util/JavaMath.h"
|
||||||
#include "../../Minecraft.World/Util/Facing.h"
|
#include "../../Minecraft.World/Util/Facing.h"
|
||||||
#include "../../Minecraft.World/Entities/MobEffect.h"
|
#include "../../Minecraft.World/Entities/MobEffect.h"
|
||||||
#include "../../Minecraft.World/Util/IntCache.h"
|
|
||||||
#include "../../Minecraft.World/Util/SmoothFloat.h"
|
#include "../../Minecraft.World/Util/SmoothFloat.h"
|
||||||
#include "../../Minecraft.World/Entities/MobEffectInstance.h"
|
#include "../../Minecraft.World/Entities/MobEffectInstance.h"
|
||||||
#include "../../Minecraft.World/Items/Item.h"
|
#include "../../Minecraft.World/Items/Item.h"
|
||||||
|
|
@ -351,7 +350,7 @@ void GameRenderer::pick(float a) {
|
||||||
if (nearest < dist || (mc->hitResult == NULL)) {
|
if (nearest < dist || (mc->hitResult == NULL)) {
|
||||||
if (mc->hitResult != NULL) delete mc->hitResult;
|
if (mc->hitResult != NULL) delete mc->hitResult;
|
||||||
mc->hitResult = new HitResult(hovered);
|
mc->hitResult = new HitResult(hovered);
|
||||||
if (hovered->instanceof (eTYPE_LIVINGENTITY)) {
|
if (hovered->instanceof(eTYPE_LIVINGENTITY)) {
|
||||||
mc->crosshairPickMob =
|
mc->crosshairPickMob =
|
||||||
std::dynamic_pointer_cast<LivingEntity>(hovered);
|
std::dynamic_pointer_cast<LivingEntity>(hovered);
|
||||||
}
|
}
|
||||||
|
|
@ -424,7 +423,7 @@ void GameRenderer::bobHurt(float a) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameRenderer::bobView(float a) {
|
void GameRenderer::bobView(float a) {
|
||||||
if (!mc->cameraTargetPlayer->instanceof (eTYPE_LIVINGENTITY)) return;
|
if (!mc->cameraTargetPlayer->instanceof(eTYPE_LIVINGENTITY)) return;
|
||||||
|
|
||||||
std::shared_ptr<Player> player =
|
std::shared_ptr<Player> player =
|
||||||
std::dynamic_pointer_cast<Player>(mc->cameraTargetPlayer);
|
std::dynamic_pointer_cast<Player>(mc->cameraTargetPlayer);
|
||||||
|
|
@ -673,8 +672,7 @@ void GameRenderer::renderItemInHand(float a, int eye) {
|
||||||
// 4J-JEV: I'm fairly confident this method would crash if the cameratarget
|
// 4J-JEV: I'm fairly confident this method would crash if the cameratarget
|
||||||
// isnt a local player anyway, but oh well.
|
// isnt a local player anyway, but oh well.
|
||||||
std::shared_ptr<LocalPlayer> localplayer =
|
std::shared_ptr<LocalPlayer> localplayer =
|
||||||
mc->cameraTargetPlayer->instanceof
|
mc->cameraTargetPlayer->instanceof(eTYPE_LOCALPLAYER)
|
||||||
(eTYPE_LOCALPLAYER)
|
|
||||||
? std::dynamic_pointer_cast<LocalPlayer>(mc->cameraTargetPlayer)
|
? std::dynamic_pointer_cast<LocalPlayer>(mc->cameraTargetPlayer)
|
||||||
: nullptr;
|
: nullptr;
|
||||||
|
|
||||||
|
|
@ -807,9 +805,8 @@ void GameRenderer::turnOnLightLayer(
|
||||||
static int logCount = 0;
|
static int logCount = 0;
|
||||||
if (logCount < 16) {
|
if (logCount < 16) {
|
||||||
++logCount;
|
++logCount;
|
||||||
app.DebugPrintf(
|
app.DebugPrintf("[linux-lightmap] turnOnLightLayer tex=%d scale=%d\n",
|
||||||
"[linux-lightmap] turnOnLightLayer tex=%d scale=%d\n", textureId,
|
textureId, scaleLight ? 1 : 0);
|
||||||
scaleLight ? 1 : 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RenderManager.TextureBindVertex(textureId, scaleLight);
|
RenderManager.TextureBindVertex(textureId, scaleLight);
|
||||||
|
|
@ -1118,7 +1115,6 @@ int GameRenderer::runUpdate(void* lpParam) {
|
||||||
Minecraft* minecraft = Minecraft::GetInstance();
|
Minecraft* minecraft = Minecraft::GetInstance();
|
||||||
Vec3::CreateNewThreadStorage();
|
Vec3::CreateNewThreadStorage();
|
||||||
AABB::CreateNewThreadStorage();
|
AABB::CreateNewThreadStorage();
|
||||||
IntCache::CreateNewThreadStorage();
|
|
||||||
Tesselator::CreateNewThreadStorage(1024 * 1024);
|
Tesselator::CreateNewThreadStorage(1024 * 1024);
|
||||||
Compression::UseDefaultThreadStorage();
|
Compression::UseDefaultThreadStorage();
|
||||||
RenderManager.InitialiseContext();
|
RenderManager.InitialiseContext();
|
||||||
|
|
@ -1199,7 +1195,6 @@ int GameRenderer::runUpdate(void* lpParam) {
|
||||||
|
|
||||||
AABB::resetPool();
|
AABB::resetPool();
|
||||||
Vec3::resetPool();
|
Vec3::resetPool();
|
||||||
IntCache::Reset();
|
|
||||||
m_updateEvents->Set(eUpdateEventIsFinished);
|
m_updateEvents->Set(eUpdateEventIsFinished);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1254,7 +1249,9 @@ void GameRenderer::renderLevel(float a, int64_t until) {
|
||||||
|
|
||||||
// if (mc->cameraTargetPlayer == NULL) // 4J - removed condition as we
|
// if (mc->cameraTargetPlayer == NULL) // 4J - removed condition as we
|
||||||
// want to update this is mc->player changes for different local players
|
// want to update this is mc->player changes for different local players
|
||||||
{ mc->cameraTargetPlayer = mc->player; }
|
{
|
||||||
|
mc->cameraTargetPlayer = mc->player;
|
||||||
|
}
|
||||||
pick(a);
|
pick(a);
|
||||||
|
|
||||||
std::shared_ptr<LivingEntity> cameraEntity = mc->cameraTargetPlayer;
|
std::shared_ptr<LivingEntity> cameraEntity = mc->cameraTargetPlayer;
|
||||||
|
|
@ -1394,9 +1391,9 @@ void GameRenderer::renderLevel(float a, int64_t until) {
|
||||||
turnOffLightLayer(a); // 4J - brought forward from 1.8.2
|
turnOffLightLayer(a); // 4J - brought forward from 1.8.2
|
||||||
|
|
||||||
if ((mc->hitResult != NULL) &&
|
if ((mc->hitResult != NULL) &&
|
||||||
cameraEntity->isUnderLiquid(Material::water) &&
|
cameraEntity->isUnderLiquid(Material::water) &&
|
||||||
cameraEntity->instanceof
|
cameraEntity->instanceof(
|
||||||
(eTYPE_PLAYER)) //&& !mc->options.hideGui)
|
eTYPE_PLAYER)) //&& !mc->options.hideGui)
|
||||||
{
|
{
|
||||||
std::shared_ptr<Player> player =
|
std::shared_ptr<Player> player =
|
||||||
std::dynamic_pointer_cast<Player>(cameraEntity);
|
std::dynamic_pointer_cast<Player>(cameraEntity);
|
||||||
|
|
@ -1472,8 +1469,8 @@ void GameRenderer::renderLevel(float a, int64_t until) {
|
||||||
glEnable(GL_CULL_FACE);
|
glEnable(GL_CULL_FACE);
|
||||||
glDisable(GL_BLEND);
|
glDisable(GL_BLEND);
|
||||||
|
|
||||||
if ((zoom == 1) && cameraEntity->instanceof
|
if ((zoom == 1) &&
|
||||||
(eTYPE_PLAYER)) //&& !mc->options.hideGui)
|
cameraEntity->instanceof(eTYPE_PLAYER)) //&& !mc->options.hideGui)
|
||||||
{
|
{
|
||||||
if (mc->hitResult != NULL &&
|
if (mc->hitResult != NULL &&
|
||||||
!cameraEntity->isUnderLiquid(Material::water)) {
|
!cameraEntity->isUnderLiquid(Material::water)) {
|
||||||
|
|
@ -2008,7 +2005,7 @@ void GameRenderer::setupFog(int i, float alpha) {
|
||||||
|
|
||||||
// 4J - check for creative mode brought forward from 1.2.3
|
// 4J - check for creative mode brought forward from 1.2.3
|
||||||
bool creative = false;
|
bool creative = false;
|
||||||
if (player->instanceof (eTYPE_PLAYER)) {
|
if (player->instanceof(eTYPE_PLAYER)) {
|
||||||
creative =
|
creative =
|
||||||
(std::dynamic_pointer_cast<Player>(player))->abilities.instabuild;
|
(std::dynamic_pointer_cast<Player>(player))->abilities.instabuild;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,6 @@
|
||||||
#include "../GameState/Options.h"
|
#include "../GameState/Options.h"
|
||||||
#include "../Network/MultiPlayerChunkCache.h"
|
#include "../Network/MultiPlayerChunkCache.h"
|
||||||
#include "../../Minecraft.World/Util/ParticleTypes.h"
|
#include "../../Minecraft.World/Util/ParticleTypes.h"
|
||||||
#include "../../Minecraft.World/Util/IntCache.h"
|
|
||||||
#include "../../Minecraft.World/IO/Streams/IntBuffer.h"
|
#include "../../Minecraft.World/IO/Streams/IntBuffer.h"
|
||||||
#include "../../Minecraft.World/Util/JavaMath.h"
|
#include "../../Minecraft.World/Util/JavaMath.h"
|
||||||
#include "../../Minecraft.World/Headers/net.minecraft.world.level.h"
|
#include "../../Minecraft.World/Headers/net.minecraft.world.level.h"
|
||||||
|
|
@ -586,7 +585,7 @@ void LevelRenderer::renderEntities(Vec3* cam, Culler* culler, float a) {
|
||||||
(entity->noCulling || culler->isVisible(entity->bb)));
|
(entity->noCulling || culler->isVisible(entity->bb)));
|
||||||
|
|
||||||
// Render the mob if the mob's leash holder is within the culler
|
// Render the mob if the mob's leash holder is within the culler
|
||||||
if (!shouldRender && entity->instanceof (eTYPE_MOB)) {
|
if (!shouldRender && entity->instanceof(eTYPE_MOB)) {
|
||||||
std::shared_ptr<Mob> mob = std::dynamic_pointer_cast<Mob>(entity);
|
std::shared_ptr<Mob> mob = std::dynamic_pointer_cast<Mob>(entity);
|
||||||
if (mob->isLeashed() && (mob->getLeashHolder() != NULL)) {
|
if (mob->isLeashed() && (mob->getLeashHolder() != NULL)) {
|
||||||
std::shared_ptr<Entity> leashHolder = mob->getLeashHolder();
|
std::shared_ptr<Entity> leashHolder = mob->getLeashHolder();
|
||||||
|
|
@ -600,10 +599,10 @@ void LevelRenderer::renderEntities(Vec3* cam, Culler* culler, float a) {
|
||||||
// !mc->options->thirdPersonView &&
|
// !mc->options->thirdPersonView &&
|
||||||
// !mc->cameraTargetPlayer->isSleeping()) continue;
|
// !mc->cameraTargetPlayer->isSleeping()) continue;
|
||||||
std::shared_ptr<LocalPlayer> localplayer =
|
std::shared_ptr<LocalPlayer> localplayer =
|
||||||
mc->cameraTargetPlayer->instanceof
|
mc->cameraTargetPlayer->instanceof(eTYPE_LOCALPLAYER)
|
||||||
(eTYPE_LOCALPLAYER) ? std::dynamic_pointer_cast<LocalPlayer>(
|
? std::dynamic_pointer_cast<LocalPlayer>(
|
||||||
mc->cameraTargetPlayer)
|
mc->cameraTargetPlayer)
|
||||||
: nullptr;
|
: nullptr;
|
||||||
|
|
||||||
if (localplayer && entity == mc->cameraTargetPlayer &&
|
if (localplayer && entity == mc->cameraTargetPlayer &&
|
||||||
!localplayer->ThirdPersonView() &&
|
!localplayer->ThirdPersonView() &&
|
||||||
|
|
@ -2748,7 +2747,9 @@ void LevelRenderer::cull_SPU(int playerIndex, Culler* culler, float a) {
|
||||||
m_jobPort_CullSPU->submitSync();
|
m_jobPort_CullSPU->submitSync();
|
||||||
// static int doSort = false;
|
// static int doSort = false;
|
||||||
// if(doSort)
|
// if(doSort)
|
||||||
{ m_jobPort_CullSPU->submitJob(&sortJob); }
|
{
|
||||||
|
m_jobPort_CullSPU->submitJob(&sortJob);
|
||||||
|
}
|
||||||
// doSort ^= 1;
|
// doSort ^= 1;
|
||||||
m_bSPUCullStarted[playerIndex] = true;
|
m_bSPUCullStarted[playerIndex] = true;
|
||||||
}
|
}
|
||||||
|
|
@ -3221,7 +3222,7 @@ std::shared_ptr<Particle> LevelRenderer::addParticleInternal(
|
||||||
}
|
}
|
||||||
|
|
||||||
void LevelRenderer::entityAdded(std::shared_ptr<Entity> entity) {
|
void LevelRenderer::entityAdded(std::shared_ptr<Entity> entity) {
|
||||||
if (entity->instanceof (eTYPE_PLAYER)) {
|
if (entity->instanceof(eTYPE_PLAYER)) {
|
||||||
std::shared_ptr<Player> player =
|
std::shared_ptr<Player> player =
|
||||||
std::dynamic_pointer_cast<Player>(entity);
|
std::dynamic_pointer_cast<Player>(entity);
|
||||||
player->prepareCustomTextures();
|
player->prepareCustomTextures();
|
||||||
|
|
@ -3239,7 +3240,7 @@ void LevelRenderer::entityAdded(std::shared_ptr<Entity> entity) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void LevelRenderer::entityRemoved(std::shared_ptr<Entity> entity) {
|
void LevelRenderer::entityRemoved(std::shared_ptr<Entity> entity) {
|
||||||
if (entity->instanceof (eTYPE_PLAYER)) {
|
if (entity->instanceof(eTYPE_PLAYER)) {
|
||||||
std::shared_ptr<Player> player =
|
std::shared_ptr<Player> player =
|
||||||
std::dynamic_pointer_cast<Player>(entity);
|
std::dynamic_pointer_cast<Player>(entity);
|
||||||
if (player->customTextureUrl != L"") {
|
if (player->customTextureUrl != L"") {
|
||||||
|
|
@ -4040,7 +4041,6 @@ void LevelRenderer::staticCtor() {
|
||||||
int LevelRenderer::rebuildChunkThreadProc(void* lpParam) {
|
int LevelRenderer::rebuildChunkThreadProc(void* lpParam) {
|
||||||
Vec3::CreateNewThreadStorage();
|
Vec3::CreateNewThreadStorage();
|
||||||
AABB::CreateNewThreadStorage();
|
AABB::CreateNewThreadStorage();
|
||||||
IntCache::CreateNewThreadStorage();
|
|
||||||
Tesselator::CreateNewThreadStorage(1024 * 1024);
|
Tesselator::CreateNewThreadStorage(1024 * 1024);
|
||||||
RenderManager.InitialiseContext();
|
RenderManager.InitialiseContext();
|
||||||
Chunk::CreateNewThreadStorage();
|
Chunk::CreateNewThreadStorage();
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,6 @@
|
||||||
#include "../WorldGen/Layers/DownfallMixerLayer.h"
|
#include "../WorldGen/Layers/DownfallMixerLayer.h"
|
||||||
#include "../WorldGen/Layers/FlatLayer.h"
|
#include "../WorldGen/Layers/FlatLayer.h"
|
||||||
#include "../WorldGen/Layers/FuzzyZoomLayer.h"
|
#include "../WorldGen/Layers/FuzzyZoomLayer.h"
|
||||||
#include "../Util/IntCache.h"
|
|
||||||
#include "../WorldGen/Layers/IslandLayer.h"
|
#include "../WorldGen/Layers/IslandLayer.h"
|
||||||
#include "../WorldGen/Layers/Layer.h"
|
#include "../WorldGen/Layers/Layer.h"
|
||||||
#include "../WorldGen/Layers/RiverInitLayer.h"
|
#include "../WorldGen/Layers/RiverInitLayer.h"
|
||||||
|
|
|
||||||
|
|
@ -1,140 +0,0 @@
|
||||||
#include "../Platform/stdafx.h"
|
|
||||||
#include "IntCache.h"
|
|
||||||
|
|
||||||
unsigned int IntCache::tlsIdx = TlsAlloc();
|
|
||||||
|
|
||||||
void IntCache::CreateNewThreadStorage() {
|
|
||||||
ThreadStorage* tls = new ThreadStorage();
|
|
||||||
TlsSetValue(tlsIdx, (void*)tls);
|
|
||||||
tls->maxSize = TINY_CUTOFF;
|
|
||||||
}
|
|
||||||
|
|
||||||
IntCache::ThreadStorage::~ThreadStorage() {
|
|
||||||
for (unsigned int i = 0; i < tcache.size(); i++) {
|
|
||||||
delete[] tcache[i].data;
|
|
||||||
}
|
|
||||||
for (unsigned int i = 0; i < tallocated.size(); i++) {
|
|
||||||
delete[] tallocated[i].data;
|
|
||||||
}
|
|
||||||
for (unsigned int i = 0; i < cache.size(); i++) {
|
|
||||||
delete[] cache[i].data;
|
|
||||||
}
|
|
||||||
for (unsigned int i = 0; i < allocated.size(); i++) {
|
|
||||||
delete[] allocated[i].data;
|
|
||||||
}
|
|
||||||
for (int i = 0; i < toosmall.size(); i++) {
|
|
||||||
delete[] toosmall[i].data;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void IntCache::ReleaseThreadStorage() {
|
|
||||||
ThreadStorage* tls = (ThreadStorage*)TlsGetValue(tlsIdx);
|
|
||||||
|
|
||||||
delete tls;
|
|
||||||
}
|
|
||||||
|
|
||||||
intArray IntCache::allocate(int size) {
|
|
||||||
ThreadStorage* tls = (ThreadStorage*)TlsGetValue(tlsIdx);
|
|
||||||
|
|
||||||
if (size <= TINY_CUTOFF) {
|
|
||||||
if (tls->tcache.empty()) {
|
|
||||||
intArray result = intArray(TINY_CUTOFF, true);
|
|
||||||
tls->tallocated.push_back(result);
|
|
||||||
return result;
|
|
||||||
} else {
|
|
||||||
intArray result = tls->tcache.back();
|
|
||||||
tls->tcache.pop_back();
|
|
||||||
tls->tallocated.push_back(result);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (size > tls->maxSize) {
|
|
||||||
// app.DebugPrintf("IntCache: New max size: %d\n" , size);
|
|
||||||
tls->maxSize = size;
|
|
||||||
|
|
||||||
// 4J - added - all the vectors in cache & allocated are smaller than
|
|
||||||
// maxSize so should be discarded. However, we can't delete them until
|
|
||||||
// the next releaseAll so copy into another vector until then
|
|
||||||
tls->toosmall.insert(tls->toosmall.end(), tls->cache.begin(),
|
|
||||||
tls->cache.end());
|
|
||||||
tls->toosmall.insert(tls->toosmall.end(), tls->allocated.begin(),
|
|
||||||
tls->allocated.end());
|
|
||||||
|
|
||||||
tls->cache.clear();
|
|
||||||
tls->allocated.clear();
|
|
||||||
|
|
||||||
intArray result = intArray(tls->maxSize, true);
|
|
||||||
tls->allocated.push_back(result);
|
|
||||||
return result;
|
|
||||||
} else {
|
|
||||||
if (tls->cache.empty()) {
|
|
||||||
intArray result = intArray(tls->maxSize, true);
|
|
||||||
tls->allocated.push_back(result);
|
|
||||||
return result;
|
|
||||||
} else {
|
|
||||||
intArray result = tls->cache.back();
|
|
||||||
tls->cache.pop_back();
|
|
||||||
tls->allocated.push_back(result);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void IntCache::releaseAll() {
|
|
||||||
ThreadStorage* tls = (ThreadStorage*)TlsGetValue(tlsIdx);
|
|
||||||
|
|
||||||
// 4J - added - we can now remove the vectors that were deemed as too small
|
|
||||||
// (see comment in IntCache::allocate)
|
|
||||||
for (int i = 0; i < tls->toosmall.size(); i++) {
|
|
||||||
delete[] tls->toosmall[i].data;
|
|
||||||
}
|
|
||||||
tls->toosmall.clear();
|
|
||||||
|
|
||||||
if (!tls->cache.empty()) {
|
|
||||||
delete[] tls->cache.back().data;
|
|
||||||
tls->cache.pop_back();
|
|
||||||
}
|
|
||||||
if (!tls->tcache.empty()) {
|
|
||||||
delete[] tls->tcache.back().data;
|
|
||||||
tls->tcache.pop_back();
|
|
||||||
}
|
|
||||||
|
|
||||||
tls->cache.insert(tls->cache.end(), tls->allocated.begin(),
|
|
||||||
tls->allocated.end());
|
|
||||||
tls->tcache.insert(tls->tcache.end(), tls->tallocated.begin(),
|
|
||||||
tls->tallocated.end());
|
|
||||||
|
|
||||||
tls->allocated.clear();
|
|
||||||
tls->tallocated.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
// 4J added so that we can fully reset between levels
|
|
||||||
void IntCache::Reset() {
|
|
||||||
ThreadStorage* tls = (ThreadStorage*)TlsGetValue(tlsIdx);
|
|
||||||
tls->maxSize = TINY_CUTOFF;
|
|
||||||
for (int i = 0; i < tls->allocated.size(); i++) {
|
|
||||||
delete[] tls->allocated[i].data;
|
|
||||||
}
|
|
||||||
tls->allocated.clear();
|
|
||||||
|
|
||||||
for (int i = 0; i < tls->cache.size(); i++) {
|
|
||||||
delete[] tls->cache[i].data;
|
|
||||||
}
|
|
||||||
tls->cache.clear();
|
|
||||||
|
|
||||||
for (int i = 0; i < tls->tallocated.size(); i++) {
|
|
||||||
delete[] tls->tallocated[i].data;
|
|
||||||
}
|
|
||||||
tls->tallocated.clear();
|
|
||||||
|
|
||||||
for (int i = 0; i < tls->tcache.size(); i++) {
|
|
||||||
delete[] tls->tcache[i].data;
|
|
||||||
}
|
|
||||||
tls->tcache.clear();
|
|
||||||
|
|
||||||
for (int i = 0; i < tls->toosmall.size(); i++) {
|
|
||||||
delete[] tls->toosmall[i].data;
|
|
||||||
}
|
|
||||||
tls->toosmall.clear();
|
|
||||||
}
|
|
||||||
|
|
@ -1,30 +0,0 @@
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "ArrayWithLength.h"
|
|
||||||
|
|
||||||
class IntCache {
|
|
||||||
private:
|
|
||||||
class ThreadStorage {
|
|
||||||
public:
|
|
||||||
int maxSize;
|
|
||||||
|
|
||||||
std::vector<intArray> tcache;
|
|
||||||
std::vector<intArray> tallocated;
|
|
||||||
|
|
||||||
std::vector<intArray> cache;
|
|
||||||
std::vector<intArray> allocated;
|
|
||||||
std::vector<intArray> toosmall; // 4J added
|
|
||||||
~ThreadStorage();
|
|
||||||
};
|
|
||||||
static unsigned int tlsIdx;
|
|
||||||
|
|
||||||
static const int TINY_CUTOFF = 256;
|
|
||||||
|
|
||||||
public:
|
|
||||||
static intArray allocate(int size);
|
|
||||||
static void releaseAll();
|
|
||||||
|
|
||||||
static void CreateNewThreadStorage();
|
|
||||||
static void ReleaseThreadStorage();
|
|
||||||
static void Reset(); // 4J added
|
|
||||||
};
|
|
||||||
|
|
@ -75,7 +75,6 @@ floatArray BiomeSource::getDownfallBlock(int x, int z, int w, int h) const {
|
||||||
// downfall layers brought forward from 1.2.3
|
// downfall layers brought forward from 1.2.3
|
||||||
void BiomeSource::getDownfallBlock(floatArray& downfalls, int x, int z, int w,
|
void BiomeSource::getDownfallBlock(floatArray& downfalls, int x, int z, int w,
|
||||||
int h) const {
|
int h) const {
|
||||||
IntCache::releaseAll();
|
|
||||||
// if (downfalls == NULL || downfalls->length < w * h)
|
// if (downfalls == NULL || downfalls->length < w * h)
|
||||||
if (downfalls.data == NULL || downfalls.length < w * h) {
|
if (downfalls.data == NULL || downfalls.length < w * h) {
|
||||||
if (downfalls.data != NULL) delete[] downfalls.data;
|
if (downfalls.data != NULL) delete[] downfalls.data;
|
||||||
|
|
@ -112,7 +111,6 @@ floatArray BiomeSource::getTemperatureBlock(int x, int z, int w, int h) const {
|
||||||
// downfall layers brought forward from 1.2.3
|
// downfall layers brought forward from 1.2.3
|
||||||
void BiomeSource::getTemperatureBlock(floatArray& temperatures, int x, int z,
|
void BiomeSource::getTemperatureBlock(floatArray& temperatures, int x, int z,
|
||||||
int w, int h) const {
|
int w, int h) const {
|
||||||
IntCache::releaseAll();
|
|
||||||
// if (temperatures == null || temperatures.length < w * h) {
|
// if (temperatures == null || temperatures.length < w * h) {
|
||||||
if (temperatures.data == NULL || temperatures.length < w * h) {
|
if (temperatures.data == NULL || temperatures.length < w * h) {
|
||||||
if (temperatures.data != NULL) delete[] temperatures.data;
|
if (temperatures.data != NULL) delete[] temperatures.data;
|
||||||
|
|
@ -137,7 +135,6 @@ BiomeArray BiomeSource::getRawBiomeBlock(int x, int z, int w, int h) const {
|
||||||
// 4J added
|
// 4J added
|
||||||
void BiomeSource::getRawBiomeIndices(intArray& biomes, int x, int z, int w,
|
void BiomeSource::getRawBiomeIndices(intArray& biomes, int x, int z, int w,
|
||||||
int h) const {
|
int h) const {
|
||||||
IntCache::releaseAll();
|
|
||||||
|
|
||||||
intArray result = layer->getArea(x, z, w, h);
|
intArray result = layer->getArea(x, z, w, h);
|
||||||
for (int i = 0; i < w * h; i++) {
|
for (int i = 0; i < w * h; i++) {
|
||||||
|
|
@ -147,7 +144,6 @@ void BiomeSource::getRawBiomeIndices(intArray& biomes, int x, int z, int w,
|
||||||
|
|
||||||
void BiomeSource::getRawBiomeBlock(BiomeArray& biomes, int x, int z, int w,
|
void BiomeSource::getRawBiomeBlock(BiomeArray& biomes, int x, int z, int w,
|
||||||
int h) const {
|
int h) const {
|
||||||
IntCache::releaseAll();
|
|
||||||
// if (biomes == null || biomes.length < w * h)
|
// if (biomes == null || biomes.length < w * h)
|
||||||
if (biomes.data == NULL || biomes.length < w * h) {
|
if (biomes.data == NULL || biomes.length < w * h) {
|
||||||
if (biomes.data != NULL) delete[] biomes.data;
|
if (biomes.data != NULL) delete[] biomes.data;
|
||||||
|
|
@ -178,7 +174,6 @@ BiomeArray BiomeSource::getBiomeBlock(int x, int z, int w, int h) const {
|
||||||
// 4J - caller is responsible for deleting biomes array
|
// 4J - caller is responsible for deleting biomes array
|
||||||
void BiomeSource::getBiomeBlock(BiomeArray& biomes, int x, int z, int w, int h,
|
void BiomeSource::getBiomeBlock(BiomeArray& biomes, int x, int z, int w, int h,
|
||||||
bool useCache) const {
|
bool useCache) const {
|
||||||
IntCache::releaseAll();
|
|
||||||
// if (biomes == null || biomes.length < w * h)
|
// if (biomes == null || biomes.length < w * h)
|
||||||
if (biomes.data == NULL || biomes.length < w * h) {
|
if (biomes.data == NULL || biomes.length < w * h) {
|
||||||
if (biomes.data != NULL) delete[] biomes.data;
|
if (biomes.data != NULL) delete[] biomes.data;
|
||||||
|
|
@ -211,7 +206,6 @@ byteArray BiomeSource::getBiomeIndexBlock(int x, int z, int w, int h) const {
|
||||||
// 4J - caller is responsible for deleting biomes array
|
// 4J - caller is responsible for deleting biomes array
|
||||||
void BiomeSource::getBiomeIndexBlock(byteArray& biomeIndices, int x, int z,
|
void BiomeSource::getBiomeIndexBlock(byteArray& biomeIndices, int x, int z,
|
||||||
int w, int h, bool useCache) const {
|
int w, int h, bool useCache) const {
|
||||||
IntCache::releaseAll();
|
|
||||||
// if (biomes == null || biomes.length < w * h)
|
// if (biomes == null || biomes.length < w * h)
|
||||||
if (biomeIndices.data == NULL || biomeIndices.length < w * h) {
|
if (biomeIndices.data == NULL || biomeIndices.length < w * h) {
|
||||||
if (biomeIndices.data != NULL) delete[] biomeIndices.data;
|
if (biomeIndices.data != NULL) delete[] biomeIndices.data;
|
||||||
|
|
@ -239,7 +233,6 @@ void BiomeSource::getBiomeIndexBlock(byteArray& biomeIndices, int x, int z,
|
||||||
*/
|
*/
|
||||||
bool BiomeSource::containsOnly(int x, int z, int r,
|
bool BiomeSource::containsOnly(int x, int z, int r,
|
||||||
std::vector<Biome*> allowed) {
|
std::vector<Biome*> allowed) {
|
||||||
IntCache::releaseAll();
|
|
||||||
int x0 = ((x - r) >> 2);
|
int x0 = ((x - r) >> 2);
|
||||||
int z0 = ((z - r) >> 2);
|
int z0 = ((z - r) >> 2);
|
||||||
int x1 = ((x + r) >> 2);
|
int x1 = ((x + r) >> 2);
|
||||||
|
|
@ -266,7 +259,6 @@ bool BiomeSource::containsOnly(int x, int z, int r,
|
||||||
* NO other biomes, add a margin of at least four blocks to the radius
|
* NO other biomes, add a margin of at least four blocks to the radius
|
||||||
*/
|
*/
|
||||||
bool BiomeSource::containsOnly(int x, int z, int r, Biome* allowed) {
|
bool BiomeSource::containsOnly(int x, int z, int r, Biome* allowed) {
|
||||||
IntCache::releaseAll();
|
|
||||||
int x0 = ((x - r) >> 2);
|
int x0 = ((x - r) >> 2);
|
||||||
int z0 = ((z - r) >> 2);
|
int z0 = ((z - r) >> 2);
|
||||||
int x1 = ((x + r) >> 2);
|
int x1 = ((x + r) >> 2);
|
||||||
|
|
@ -292,7 +284,6 @@ bool BiomeSource::containsOnly(int x, int z, int r, Biome* allowed) {
|
||||||
*/
|
*/
|
||||||
TilePos* BiomeSource::findBiome(int x, int z, int r, Biome* toFind,
|
TilePos* BiomeSource::findBiome(int x, int z, int r, Biome* toFind,
|
||||||
Random* random) {
|
Random* random) {
|
||||||
IntCache::releaseAll();
|
|
||||||
int x0 = ((x - r) >> 2);
|
int x0 = ((x - r) >> 2);
|
||||||
int z0 = ((z - r) >> 2);
|
int z0 = ((z - r) >> 2);
|
||||||
int x1 = ((x + r) >> 2);
|
int x1 = ((x + r) >> 2);
|
||||||
|
|
@ -327,7 +318,6 @@ TilePos* BiomeSource::findBiome(int x, int z, int r, Biome* toFind,
|
||||||
*/
|
*/
|
||||||
TilePos* BiomeSource::findBiome(int x, int z, int r,
|
TilePos* BiomeSource::findBiome(int x, int z, int r,
|
||||||
std::vector<Biome*> allowed, Random* random) {
|
std::vector<Biome*> allowed, Random* random) {
|
||||||
IntCache::releaseAll();
|
|
||||||
int x0 = ((x - r) >> 2);
|
int x0 = ((x - r) >> 2);
|
||||||
int z0 = ((z - r) >> 2);
|
int z0 = ((z - r) >> 2);
|
||||||
int x1 = ((x + r) >> 2);
|
int x1 = ((x + r) >> 2);
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ intArray AddIslandLayer::getArea(int xo, int yo, int w, int h) {
|
||||||
int ph = h + 2;
|
int ph = h + 2;
|
||||||
intArray p = parent->getArea(px, py, pw, ph);
|
intArray p = parent->getArea(px, py, pw, ph);
|
||||||
|
|
||||||
intArray result = IntCache::allocate(w * h);
|
intArray result{static_cast<unsigned int>(w * h)};
|
||||||
for (int y = 0; y < h; y++) {
|
for (int y = 0; y < h; y++) {
|
||||||
for (int x = 0; x < w; x++) {
|
for (int x = 0; x < w; x++) {
|
||||||
int n1 = p[(x + 0) + (y + 0) * pw];
|
int n1 = p[(x + 0) + (y + 0) * pw];
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ intArray AddMushroomIslandLayer::getArea(int xo, int yo, int w, int h) {
|
||||||
int ph = h + 2;
|
int ph = h + 2;
|
||||||
intArray p = parent->getArea(px, py, pw, ph);
|
intArray p = parent->getArea(px, py, pw, ph);
|
||||||
|
|
||||||
intArray result = IntCache::allocate(w * h);
|
intArray result{static_cast<unsigned int>(w * h)};
|
||||||
for (int y = 0; y < h; y++) {
|
for (int y = 0; y < h; y++) {
|
||||||
for (int x = 0; x < w; x++) {
|
for (int x = 0; x < w; x++) {
|
||||||
int n1 = p[(x + 0) + (y + 0) * pw];
|
int n1 = p[(x + 0) + (y + 0) * pw];
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ intArray AddSnowLayer::getArea(int xo, int yo, int w, int h) {
|
||||||
int ph = h + 2;
|
int ph = h + 2;
|
||||||
intArray p = parent->getArea(px, py, pw, ph);
|
intArray p = parent->getArea(px, py, pw, ph);
|
||||||
|
|
||||||
intArray result = IntCache::allocate(w * h);
|
intArray result{static_cast<unsigned int>(w * h)};
|
||||||
for (int y = 0; y < h; y++) {
|
for (int y = 0; y < h; y++) {
|
||||||
for (int x = 0; x < w; x++) {
|
for (int x = 0; x < w; x++) {
|
||||||
int c = p[(x + 1) + (y + 1) * pw];
|
int c = p[(x + 1) + (y + 1) * pw];
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ BiomeInitLayer::~BiomeInitLayer() { delete[] startBiomes.data; }
|
||||||
intArray BiomeInitLayer::getArea(int xo, int yo, int w, int h) {
|
intArray BiomeInitLayer::getArea(int xo, int yo, int w, int h) {
|
||||||
intArray b = parent->getArea(xo, yo, w, h);
|
intArray b = parent->getArea(xo, yo, w, h);
|
||||||
|
|
||||||
intArray result = IntCache::allocate(w * h);
|
intArray result{static_cast<unsigned int>(w * h)};
|
||||||
for (int y = 0; y < h; y++) {
|
for (int y = 0; y < h; y++) {
|
||||||
for (int x = 0; x < w; x++) {
|
for (int x = 0; x < w; x++) {
|
||||||
initRandom(x + xo, y + yo);
|
initRandom(x + xo, y + yo);
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@ BiomeOverrideLayer::BiomeOverrideLayer(int seedMixup) : Layer(seedMixup) {
|
||||||
}
|
}
|
||||||
|
|
||||||
intArray BiomeOverrideLayer::getArea(int xo, int yo, int w, int h) {
|
intArray BiomeOverrideLayer::getArea(int xo, int yo, int w, int h) {
|
||||||
intArray result = IntCache::allocate(w * h);
|
intArray result{static_cast<unsigned int>(w * h)};
|
||||||
|
|
||||||
int xOrigin = xo + width / 2;
|
int xOrigin = xo + width / 2;
|
||||||
int yOrigin = yo + height / 2;
|
int yOrigin = yo + height / 2;
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ DownfallLayer::DownfallLayer(std::shared_ptr<Layer> parent) : Layer(0) {
|
||||||
intArray DownfallLayer::getArea(int xo, int yo, int w, int h) {
|
intArray DownfallLayer::getArea(int xo, int yo, int w, int h) {
|
||||||
intArray b = parent->getArea(xo, yo, w, h);
|
intArray b = parent->getArea(xo, yo, w, h);
|
||||||
|
|
||||||
intArray result = IntCache::allocate(w * h);
|
intArray result{static_cast<unsigned int>(w * h)};
|
||||||
for (int i = 0; i < w * h; i++) {
|
for (int i = 0; i < w * h; i++) {
|
||||||
result[i] = Biome::biomes[b[i]]->getDownfallInt();
|
result[i] = Biome::biomes[b[i]]->getDownfallInt();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ intArray DownfallMixerLayer::getArea(int xo, int yo, int w, int h) {
|
||||||
intArray b = parent->getArea(xo, yo, w, h);
|
intArray b = parent->getArea(xo, yo, w, h);
|
||||||
intArray d = downfall->getArea(xo, yo, w, h);
|
intArray d = downfall->getArea(xo, yo, w, h);
|
||||||
|
|
||||||
intArray result = IntCache::allocate(w * h);
|
intArray result{static_cast<unsigned int>(w * h)};
|
||||||
for (int i = 0; i < w * h; i++) {
|
for (int i = 0; i < w * h; i++) {
|
||||||
result[i] =
|
result[i] =
|
||||||
d[i] + (Biome::biomes[b[i]]->getDownfallInt() - d[i]) / (layer + 1);
|
d[i] + (Biome::biomes[b[i]]->getDownfallInt() - d[i]) / (layer + 1);
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
FlatLayer::FlatLayer(int val) : Layer(0) { this->val = val; }
|
FlatLayer::FlatLayer(int val) : Layer(0) { this->val = val; }
|
||||||
|
|
||||||
intArray FlatLayer::getArea(int xo, int yo, int w, int h) {
|
intArray FlatLayer::getArea(int xo, int yo, int w, int h) {
|
||||||
intArray result = IntCache::allocate(w * h);
|
intArray result{static_cast<unsigned int>(w * h)};
|
||||||
for (int y = 0; y < h; y++) {
|
for (int y = 0; y < h; y++) {
|
||||||
for (int x = 0; x < w; x++) {
|
for (int x = 0; x < w; x++) {
|
||||||
result[x + y * w] = val;
|
result[x + y * w] = val;
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ intArray FuzzyZoomLayer::getArea(int xo, int yo, int w, int h) {
|
||||||
intArray p = parent->getArea(px, py, pw, ph);
|
intArray p = parent->getArea(px, py, pw, ph);
|
||||||
|
|
||||||
// 4jcraft added casts to unsigned to prevent shift of neg value
|
// 4jcraft added casts to unsigned to prevent shift of neg value
|
||||||
intArray tmp = IntCache::allocate((pw * 2) * (ph * 2));
|
intArray tmp{static_cast<unsigned int>(pw * ph * 4)};
|
||||||
int ww = ((unsigned int)pw << 1);
|
int ww = ((unsigned int)pw << 1);
|
||||||
for (int y = 0; y < ph - 1; y++) {
|
for (int y = 0; y < ph - 1; y++) {
|
||||||
int ry = (unsigned int)y << 1;
|
int ry = (unsigned int)y << 1;
|
||||||
|
|
@ -37,7 +37,7 @@ intArray FuzzyZoomLayer::getArea(int xo, int yo, int w, int h) {
|
||||||
dl = dr;
|
dl = dr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
intArray result = IntCache::allocate(w * h);
|
intArray result{static_cast<unsigned int>(w * h)};
|
||||||
for (int y = 0; y < h; y++) {
|
for (int y = 0; y < h; y++) {
|
||||||
System::arraycopy(tmp,
|
System::arraycopy(tmp,
|
||||||
(y + (yo & 1)) * ((unsigned int)pw << 1) + (xo & 1),
|
(y + (yo & 1)) * ((unsigned int)pw << 1) + (xo & 1),
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ intArray GrowMushroomIslandLayer::getArea(int xo, int yo, int w, int h) {
|
||||||
int ph = h + 2;
|
int ph = h + 2;
|
||||||
intArray p = parent->getArea(px, py, pw, ph);
|
intArray p = parent->getArea(px, py, pw, ph);
|
||||||
|
|
||||||
intArray result = IntCache::allocate(w * h);
|
intArray result{static_cast<unsigned int>(w * h)};
|
||||||
for (int y = 0; y < h; y++) {
|
for (int y = 0; y < h; y++) {
|
||||||
for (int x = 0; x < w; x++) {
|
for (int x = 0; x < w; x++) {
|
||||||
int n1 = p[(x + 0) + (y + 0) * pw];
|
int n1 = p[(x + 0) + (y + 0) * pw];
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
IslandLayer::IslandLayer(int64_t seedMixup) : Layer(seedMixup) {}
|
IslandLayer::IslandLayer(int64_t seedMixup) : Layer(seedMixup) {}
|
||||||
|
|
||||||
intArray IslandLayer::getArea(int xo, int yo, int w, int h) {
|
intArray IslandLayer::getArea(int xo, int yo, int w, int h) {
|
||||||
intArray result = IntCache::allocate(w * h);
|
intArray result{static_cast<unsigned int>(w * h)};
|
||||||
for (int y = 0; y < h; y++) {
|
for (int y = 0; y < h; y++) {
|
||||||
for (int x = 0; x < w; x++) {
|
for (int x = 0; x < w; x++) {
|
||||||
initRandom(xo + x, yo + y);
|
initRandom(xo + x, yo + y);
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
#include "../../Platform/stdafx.h"
|
#include "../../Platform/stdafx.h"
|
||||||
#include "../../Headers/net.minecraft.world.level.biome.h"
|
#include "../../Headers/net.minecraft.world.level.biome.h"
|
||||||
#include "../../Util/IntCache.h"
|
|
||||||
#include "RegionHillsLayer.h"
|
#include "RegionHillsLayer.h"
|
||||||
|
|
||||||
RegionHillsLayer::RegionHillsLayer(int64_t seed, std::shared_ptr<Layer> parent)
|
RegionHillsLayer::RegionHillsLayer(int64_t seed, std::shared_ptr<Layer> parent)
|
||||||
|
|
@ -11,7 +10,7 @@ RegionHillsLayer::RegionHillsLayer(int64_t seed, std::shared_ptr<Layer> parent)
|
||||||
intArray RegionHillsLayer::getArea(int xo, int yo, int w, int h) {
|
intArray RegionHillsLayer::getArea(int xo, int yo, int w, int h) {
|
||||||
intArray b = parent->getArea(xo - 1, yo - 1, w + 2, h + 2);
|
intArray b = parent->getArea(xo - 1, yo - 1, w + 2, h + 2);
|
||||||
|
|
||||||
intArray result = IntCache::allocate(w * h);
|
intArray result{static_cast<unsigned int>(w * h)};
|
||||||
for (int y = 0; y < h; y++) {
|
for (int y = 0; y < h; y++) {
|
||||||
for (int x = 0; x < w; x++) {
|
for (int x = 0; x < w; x++) {
|
||||||
initRandom(x + xo, y + yo);
|
initRandom(x + xo, y + yo);
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ RiverInitLayer::RiverInitLayer(int64_t seed, std::shared_ptr<Layer> parent)
|
||||||
intArray RiverInitLayer::getArea(int xo, int yo, int w, int h) {
|
intArray RiverInitLayer::getArea(int xo, int yo, int w, int h) {
|
||||||
intArray b = parent->getArea(xo, yo, w, h);
|
intArray b = parent->getArea(xo, yo, w, h);
|
||||||
|
|
||||||
intArray result = IntCache::allocate(w * h);
|
intArray result{static_cast<unsigned int>(w * h)};
|
||||||
for (int y = 0; y < h; y++) {
|
for (int y = 0; y < h; y++) {
|
||||||
for (int x = 0; x < w; x++) {
|
for (int x = 0; x < w; x++) {
|
||||||
initRandom(x + xo, y + yo);
|
initRandom(x + xo, y + yo);
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ intArray RiverLayer::getArea(int xo, int yo, int w, int h) {
|
||||||
int ph = h + 2;
|
int ph = h + 2;
|
||||||
intArray p = parent->getArea(px, py, pw, ph);
|
intArray p = parent->getArea(px, py, pw, ph);
|
||||||
|
|
||||||
intArray result = IntCache::allocate(w * h);
|
intArray result{static_cast<unsigned int>(w * h)};
|
||||||
for (int y = 0; y < h; y++) {
|
for (int y = 0; y < h; y++) {
|
||||||
for (int x = 0; x < w; x++) {
|
for (int x = 0; x < w; x++) {
|
||||||
int l = p[(x + 0) + (y + 1) * pw];
|
int l = p[(x + 0) + (y + 1) * pw];
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ intArray RiverMixerLayer::getArea(int xo, int yo, int w, int h) {
|
||||||
intArray b = biomes->getArea(xo, yo, w, h);
|
intArray b = biomes->getArea(xo, yo, w, h);
|
||||||
intArray r = rivers->getArea(xo, yo, w, h);
|
intArray r = rivers->getArea(xo, yo, w, h);
|
||||||
|
|
||||||
intArray result = IntCache::allocate(w * h);
|
intArray result{static_cast<unsigned int>(w * h)};
|
||||||
for (int i = 0; i < w * h; i++) {
|
for (int i = 0; i < w * h; i++) {
|
||||||
if (b[i] == Biome::ocean->id) {
|
if (b[i] == Biome::ocean->id) {
|
||||||
result[i] = b[i];
|
result[i] = b[i];
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ ShoreLayer::ShoreLayer(int64_t seed, std::shared_ptr<Layer> parent)
|
||||||
intArray ShoreLayer::getArea(int xo, int yo, int w, int h) {
|
intArray ShoreLayer::getArea(int xo, int yo, int w, int h) {
|
||||||
intArray b = parent->getArea(xo - 1, yo - 1, w + 2, h + 2);
|
intArray b = parent->getArea(xo - 1, yo - 1, w + 2, h + 2);
|
||||||
|
|
||||||
intArray result = IntCache::allocate(w * h);
|
intArray result{static_cast<unsigned int>(w * h)};
|
||||||
for (int y = 0; y < h; y++) {
|
for (int y = 0; y < h; y++) {
|
||||||
for (int x = 0; x < w; x++) {
|
for (int x = 0; x < w; x++) {
|
||||||
initRandom(x + xo, y + yo);
|
initRandom(x + xo, y + yo);
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ intArray SmoothLayer::getArea(int xo, int yo, int w, int h) {
|
||||||
int ph = h + 2;
|
int ph = h + 2;
|
||||||
intArray p = parent->getArea(px, py, pw, ph);
|
intArray p = parent->getArea(px, py, pw, ph);
|
||||||
|
|
||||||
intArray result = IntCache::allocate(w * h);
|
intArray result{static_cast<unsigned int>(w * h)};
|
||||||
for (int y = 0; y < h; y++) {
|
for (int y = 0; y < h; y++) {
|
||||||
for (int x = 0; x < w; x++) {
|
for (int x = 0; x < w; x++) {
|
||||||
int l = p[(x + 0) + (y + 1) * pw];
|
int l = p[(x + 0) + (y + 1) * pw];
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ intArray SmoothZoomLayer::getArea(int xo, int yo, int w, int h) {
|
||||||
int ph = (h >> 1) + 3;
|
int ph = (h >> 1) + 3;
|
||||||
intArray p = parent->getArea(px, py, pw, ph);
|
intArray p = parent->getArea(px, py, pw, ph);
|
||||||
|
|
||||||
intArray tmp = IntCache::allocate((pw * 2) * (ph * 2));
|
intArray tmp{static_cast<unsigned int>(pw * ph * 4)};
|
||||||
int ww = (pw << 1);
|
int ww = (pw << 1);
|
||||||
for (int y = 0; y < ph - 1; y++) {
|
for (int y = 0; y < ph - 1; y++) {
|
||||||
int ry = y << 1;
|
int ry = y << 1;
|
||||||
|
|
@ -40,7 +40,7 @@ intArray SmoothZoomLayer::getArea(int xo, int yo, int w, int h) {
|
||||||
dl = dr;
|
dl = dr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
intArray result = IntCache::allocate(w * h);
|
intArray result{static_cast<unsigned int>(w * h)};
|
||||||
for (int y = 0; y < h; y++) {
|
for (int y = 0; y < h; y++) {
|
||||||
System::arraycopy(tmp, (y + (yo & 1)) * (pw << 1) + (xo & 1), &result,
|
System::arraycopy(tmp, (y + (yo & 1)) * (pw << 1) + (xo & 1), &result,
|
||||||
y * w, w);
|
y * w, w);
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
#include "../../Platform/stdafx.h"
|
#include "../../Platform/stdafx.h"
|
||||||
#include "../../Headers/net.minecraft.world.level.biome.h"
|
#include "../../Headers/net.minecraft.world.level.biome.h"
|
||||||
#include "../../Util/IntCache.h"
|
|
||||||
#include "SwampRiversLayer.h"
|
#include "SwampRiversLayer.h"
|
||||||
|
|
||||||
SwampRiversLayer::SwampRiversLayer(int64_t seed, std::shared_ptr<Layer> parent)
|
SwampRiversLayer::SwampRiversLayer(int64_t seed, std::shared_ptr<Layer> parent)
|
||||||
|
|
@ -11,7 +10,7 @@ SwampRiversLayer::SwampRiversLayer(int64_t seed, std::shared_ptr<Layer> parent)
|
||||||
intArray SwampRiversLayer::getArea(int xo, int yo, int w, int h) {
|
intArray SwampRiversLayer::getArea(int xo, int yo, int w, int h) {
|
||||||
intArray b = parent->getArea(xo - 1, yo - 1, w + 2, h + 2);
|
intArray b = parent->getArea(xo - 1, yo - 1, w + 2, h + 2);
|
||||||
|
|
||||||
intArray result = IntCache::allocate(w * h);
|
intArray result{static_cast<unsigned int>(w * h)};
|
||||||
for (int y = 0; y < h; y++) {
|
for (int y = 0; y < h; y++) {
|
||||||
for (int x = 0; x < w; x++) {
|
for (int x = 0; x < w; x++) {
|
||||||
initRandom(x + xo, y + yo);
|
initRandom(x + xo, y + yo);
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ TemperatureLayer::TemperatureLayer(std::shared_ptr<Layer> parent) : Layer(0) {
|
||||||
intArray TemperatureLayer::getArea(int xo, int yo, int w, int h) {
|
intArray TemperatureLayer::getArea(int xo, int yo, int w, int h) {
|
||||||
intArray b = parent->getArea(xo, yo, w, h);
|
intArray b = parent->getArea(xo, yo, w, h);
|
||||||
|
|
||||||
intArray result = IntCache::allocate(w * h);
|
intArray result{static_cast<unsigned int>(w * h)};
|
||||||
for (int i = 0; i < w * h; i++) {
|
for (int i = 0; i < w * h; i++) {
|
||||||
result[i] = Biome::biomes[b[i]]->getTemperatureInt();
|
result[i] = Biome::biomes[b[i]]->getTemperatureInt();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ intArray TemperatureMixerLayer::getArea(int xo, int yo, int w, int h) {
|
||||||
intArray b = parent->getArea(xo, yo, w, h);
|
intArray b = parent->getArea(xo, yo, w, h);
|
||||||
intArray t = temp->getArea(xo, yo, w, h);
|
intArray t = temp->getArea(xo, yo, w, h);
|
||||||
|
|
||||||
intArray result = IntCache::allocate(w * h);
|
intArray result{static_cast<unsigned int>(w * h)};
|
||||||
for (int i = 0; i < w * h; i++) {
|
for (int i = 0; i < w * h; i++) {
|
||||||
result[i] = t[i] + (Biome::biomes[b[i]]->getTemperatureInt() - t[i]) /
|
result[i] = t[i] + (Biome::biomes[b[i]]->getTemperatureInt() - t[i]) /
|
||||||
(layer * 2 + 1);
|
(layer * 2 + 1);
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ intArray VoronoiZoom::getArea(int xo, int yo, int w, int h) {
|
||||||
// 4jcraft added all those casts to unsigned
|
// 4jcraft added all those casts to unsigned
|
||||||
int ww = (unsigned)pw << bits;
|
int ww = (unsigned)pw << bits;
|
||||||
int hh = (unsigned)ph << bits;
|
int hh = (unsigned)ph << bits;
|
||||||
intArray tmp = IntCache::allocate(ww * hh);
|
intArray tmp{static_cast<unsigned int>(ww * hh)};
|
||||||
for (int y = 0; y < ph - 1; y++) {
|
for (int y = 0; y < ph - 1; y++) {
|
||||||
int ul = p[(0 + 0) + (y + 0) * pw];
|
int ul = p[(0 + 0) + (y + 0) * pw];
|
||||||
int dl = p[(0 + 0) + (y + 1) * pw];
|
int dl = p[(0 + 0) + (y + 1) * pw];
|
||||||
|
|
@ -71,7 +71,7 @@ intArray VoronoiZoom::getArea(int xo, int yo, int w, int h) {
|
||||||
dl = dr;
|
dl = dr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
intArray result = IntCache::allocate(w * h);
|
intArray result{static_cast<unsigned int>(w * h)};
|
||||||
for (int y = 0; y < h; y++) {
|
for (int y = 0; y < h; y++) {
|
||||||
System::arraycopy(
|
System::arraycopy(
|
||||||
tmp,
|
tmp,
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ intArray ZoomLayer::getArea(int xo, int yo, int w, int h) {
|
||||||
int ph = (h >> 1) + 3;
|
int ph = (h >> 1) + 3;
|
||||||
intArray p = parent->getArea(px, py, pw, ph);
|
intArray p = parent->getArea(px, py, pw, ph);
|
||||||
|
|
||||||
intArray tmp = IntCache::allocate((pw * 2) * (ph * 2));
|
intArray tmp{static_cast<unsigned int>(pw * ph * 4)};
|
||||||
// 4jcraft added casts to unsigned
|
// 4jcraft added casts to unsigned
|
||||||
int ww = ((unsigned int)pw << 1);
|
int ww = ((unsigned int)pw << 1);
|
||||||
for (int y = 0; y < ph - 1; y++) {
|
for (int y = 0; y < ph - 1; y++) {
|
||||||
|
|
@ -37,7 +37,7 @@ intArray ZoomLayer::getArea(int xo, int yo, int w, int h) {
|
||||||
dl = dr;
|
dl = dr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
intArray result = IntCache::allocate(w * h);
|
intArray result{static_cast<unsigned int>(w * h)};
|
||||||
for (int y = 0; y < h; y++) {
|
for (int y = 0; y < h; y++) {
|
||||||
System::arraycopy(tmp,
|
System::arraycopy(tmp,
|
||||||
(y + (yo & 1)) * (unsigned int)(pw << 1) + (xo & 1),
|
(y + (yo & 1)) * (unsigned int)(pw << 1) + (xo & 1),
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue