20 Commits
Author SHA1 Message Date
pieeebot c677cc0065 chore: update README.md to include discord server. 2026-07-17 20:17:07 +01:00
pieeebot eb3ae69d3f chore: add Wii U and Switch to README.md 2026-07-17 12:41:07 +01:00
pieeebot 1580fdced7 Update README.md 2026-07-16 13:50:36 +01:00
pieeebot 7200598afa chore: change readme to update project name and description 2026-07-16 13:46:41 +01:00
qloakandpieeebot b08d478d73 fix(TU20): Piston and StemTile fixes (#6)
- fixed "Two pistons stacked facing up and the top piston is powered with a repeater will cause the top piston to lock in place."
- fixed "Fix for issue where destroying planted pumpkin and melon seeds drops an incorrect number of seeds."

---------

Co-authored-by: pieeebot <10+pieeebot@noreply.neolegacy.dev>
Reviewed-on: https://git.neolegacy.dev/pieeebot/mc_pieLCE/pulls/6
Co-authored-by: qloak <realminecart@gmail.com>
Co-committed-by: qloak <realminecart@gmail.com>
2026-07-15 20:33:38 +01:00
pieeebot b1189eb6c9 chore: update development status on xbox 360
qloak found a discovery that let us grab the xur files from the tu update files, .xui is compiled into .xur and its easy to convert it back to .xui.
2026-07-15 16:45:48 +01:00
str1k3r 4e2369f194 fix(Orbis): Leaderboard manager
Make the Orbis Leaderboard manager work with the new Sony Leaderboard manager
2026-07-15 09:00:52 -04:00
qloakandpieeebot e1508731d0 fix(TU20): more TU20 bug fixes
TU20:

Fixed issue where name tags do not appear to work correctly on the wither, iron golems, and wither skeletons.
Fix for issue where creepers hover off the floor.

---------

Co-authored-by: pieeebot <10+pieeebot@noreply.neolegacy.dev>
Reviewed-on: https://git.neolegacy.dev/pieeebot/mc_pieLCE/pulls/5
Co-authored-by: qloak <realminecart@gmail.com>
Co-committed-by: qloak <realminecart@gmail.com>
2026-07-15 13:15:45 +01:00
pieeebot d236b70546 fix(TU20): Noteblock fall-off distance so they can be heard further away. 2026-07-15 14:57:35 +03:00
pieeebot 636bf0b692 fix(TU20): TNT minecart exploding despite 'TNT Explodes' option being turned off. 2026-07-15 00:13:08 +03:00
qloakandpieeebot 22bcbde6a3 fix(TU20): fixed name tag Y-position for tall mobs (wither, iron golem, wither skeleton) (#4)
title

Reviewed-on: https://git.neolegacy.dev/pieeebot/mc_pieLCE/pulls/4
Co-authored-by: qloak <realminecart@gmail.com>
Co-committed-by: qloak <realminecart@gmail.com>
2026-07-14 21:42:19 +01:00
pieeebot 8b20122798 fix: horse rendering (#3)
Reviewed-on: https://git.neolegacy.dev/pieeebot/mc_pieLCE/pulls/3
2026-07-14 21:05:11 +01:00
qloak 0672a56786 merge upstream 2026-07-14 20:59:48 +01:00
qloak 8e77eb70de fix horse layered texture rendering for platforms without multitexture support 2026-07-14 12:58:42 -07:00
pieeebot d0cc8ce080 fix(Windows64): windows build, uncap fps, double buffer, remove Sleep(0) #1
Reviewed-on: https://git.neolegacy.dev/pieeebot/mc_pieLCE/pulls/1
2026-07-14 18:32:04 +01:00
qloak a0e81976e6 fix: windows build, uncap fps, double buffer, remove Sleep(0) 2026-07-14 10:13:55 -07:00
qloak dd19188d93 fix: windows build, uncap fps, double buffer, remove Sleep(0), 2026-07-14 09:51:14 -07:00
str1k3r 976f55c46d chore: update postbuild paths 2026-07-13 18:24:03 -04:00
pieeebot 2d3fb87a1a chore(PSVita): restrict OldSdk to PSVita 2026-07-13 20:03:43 +03:00
pieeebot 3b78903179 fix(PSVita): fix compile errors from missing sceNp functions 2026-07-13 15:13:47 +03:00
90 changed files with 636 additions and 1883 deletions
+6
View File
@@ -2,6 +2,8 @@
/ORBIS_Release /ORBIS_Release
/PS3_Debug /PS3_Debug
/PS3_Release /PS3_Release
/PSVita_Debug
/PSVita_Release
/X360_Debug /X360_Debug
/X360_Release /X360_Release
/Release /Release
@@ -14,6 +16,8 @@
/Minecraft.Client/ORBIS_Release /Minecraft.Client/ORBIS_Release
/Minecraft.Client/PS3_Debug /Minecraft.Client/PS3_Debug
/Minecraft.Client/PS3_Release /Minecraft.Client/PS3_Release
/Minecraft.Client/PSVita_Debug
/Minecraft.Client/PSVita_Release
/Minecraft.Client/X360_Debug /Minecraft.Client/X360_Debug
/Minecraft.Client/X360_Release /Minecraft.Client/X360_Release
/Minecraft.Client/Debug /Minecraft.Client/Debug
@@ -25,6 +29,8 @@
/Minecraft.World/ORBIS_Release /Minecraft.World/ORBIS_Release
/Minecraft.World/PS3_Debug /Minecraft.World/PS3_Debug
/Minecraft.World/PS3_Release /Minecraft.World/PS3_Release
/Minecraft.World/PSVita_Debug
/Minecraft.World/PSVita_Release
/Minecraft.World/X360_Debug /Minecraft.World/X360_Debug
/Minecraft.World/X360_Release /Minecraft.World/X360_Release
/Minecraft.World/Debug /Minecraft.World/Debug
@@ -9,7 +9,9 @@ const wstring LeaderboardManager::filterNames[eNumFilterModes] =
L"Friends", L"MyScore", L"TopRank" L"Friends", L"MyScore", L"TopRank"
}; };
#if !defined(_WINDOWS64) && !defined(_DURANGO) && !defined(__ORBIS__) && !defined(__PS3__) && !defined(__PSVITA__) && !defined(_XBOX)
LeaderboardManager *LeaderboardManager::m_instance = NULL; LeaderboardManager *LeaderboardManager::m_instance = NULL;
#endif
void LeaderboardManager::DeleteInstance() void LeaderboardManager::DeleteInstance()
{ {
@@ -59,7 +59,7 @@ $destPath = Join-Path $destDir $newName
if (Test-Path $builtFile) { if (Test-Path $builtFile) {
New-Item -ItemType Directory -Path $destDir -Force | Out-Null New-Item -ItemType Directory -Path $destDir -Force | Out-Null
Move-Item -Path $builtFile -Destination $destPath -Force Copy-Item -Path $builtFile -Destination $destPath -Force
} }
$deleteDirs = @( $deleteDirs = @(
@@ -84,8 +84,8 @@ foreach ($dir in $deleteDirs) {
} }
$delDirs = @( $delDirs = @(
"Common\Media", "PS4_GAME\Common\Media",
"Common\Media\font" "PS4_GAME\Common\Media\font"
) )
foreach ($dir in $delDirs) { foreach ($dir in $delDirs) {
@@ -91,8 +91,8 @@ foreach ($dir in $deleteDirs) {
} }
$delDirs = @( $delDirs = @(
"Common\Media", "PS3_GAME\USRDIR\Common\Media",
"Common\Media\font" "PS3_GAME\USRDIR\Common\Media\font"
) )
foreach ($dir in $delDirs) { foreach ($dir in $delDirs) {
@@ -57,7 +57,7 @@ $destPath = Join-Path $destDir $newName
if (Test-Path $builtFile) { if (Test-Path $builtFile) {
New-Item -ItemType Directory -Path $destDir -Force | Out-Null New-Item -ItemType Directory -Path $destDir -Force | Out-Null
Move-Item -Path $builtFile -Destination $destPath -Force Copy-Item -Path $builtFile -Destination $destPath -Force
} }
$deleteDirs = @( $deleteDirs = @(
@@ -82,8 +82,8 @@ foreach ($dir in $deleteDirs) {
} }
$delDirs = @( $delDirs = @(
"Common\Media", "PSVITA_GAME\Common\Media",
"Common\Media\font" "PSVITA_GAME\Common\Media\font"
) )
foreach ($dir in $delDirs) { foreach ($dir in $delDirs) {
+1 -1
View File
@@ -6,7 +6,7 @@
// 4J - added // 4J - added
void CreeperModel::_init(float g) void CreeperModel::_init(float g)
{ {
int yo = 4; int yo = 6;
head = new ModelPart(this, 0, 0); head = new ModelPart(this, 0, 0);
head->addBox(-4, - 8, -4, 8, 8, 8, g); // Head head->addBox(-4, - 8, -4, 8, 8, 8, g); // Head
+29 -3
View File
@@ -46,9 +46,35 @@ void HorseRenderer::renderModel(shared_ptr<LivingEntity> mob, float wp, float ws
} }
else else
{ {
EntityRenderer::bindTexture(mob); shared_ptr<EntityHorse> horse = dynamic_pointer_cast<EntityHorse>(mob);
model->render(mob, wp, ws, bob, headRotMinusBodyRot, headRotx, scale, true); ResourceLocation *location = getTextureLocation(mob);
// Ensure that any extra layers of texturing are disabled after rendering this horse
// Pass 1: Bind only the coat texture (first valid layer) and render opaque
int coatTex = location->getTexture(0);
if( coatTex != -1 )
{
RenderManager.TextureBind(entityRenderDispatcher->textures->loadTexture(coatTex));
}
model->render(mob, wp, ws, bob, headRotMinusBodyRot, headRotx, scale, true);
// Pass 2: If horse has armor, find the armor texture in the layers and render with blending
int armorType = horse->getArmorType();
if( armorType > 0 )
{
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
for( int i = 1; i < location->getTextureCount(); i++ )
{
int texId = location->getTexture(i);
if( texId != -1 )
{
RenderManager.TextureBind(entityRenderDispatcher->textures->loadTexture(texId));
model->render(mob, wp, ws, bob, headRotMinusBodyRot, headRotx, scale, true);
}
}
glDisable(GL_BLEND);
}
RenderManager.TextureBind(-1); RenderManager.TextureBind(-1);
} }
} }
+1 -1
View File
@@ -491,7 +491,7 @@ void LivingEntityRenderer::renderNameTag(shared_ptr<LivingEntity> mob, const wst
float s = 1 / 60.0f * size; float s = 1 / 60.0f * size;
glPushMatrix(); glPushMatrix();
glTranslatef((float) x, (float) y + 2.3f, (float) z); glTranslatef((float) x, (float) y + mob->bbHeight + 0.5f, (float) z);
glNormal3f(0, 1, 0); glNormal3f(0, 1, 0);
glRotatef(-this->entityRenderDispatcher->playerRotY, 0, 1, 0); glRotatef(-this->entityRenderDispatcher->playerRotY, 0, 1, 0);
+6 -42
View File
@@ -1435,7 +1435,7 @@ if not exist "$(TargetDir)\savedata" mkdir "$(TargetDir)\savedata"</Command>
<ExceptionHandling>Sync</ExceptionHandling> <ExceptionHandling>Sync</ExceptionHandling>
<BufferSecurityCheck>false</BufferSecurityCheck> <BufferSecurityCheck>false</BufferSecurityCheck>
<PrecompiledHeaderOutputFile>$(OutDir)$(ProjectName).pch</PrecompiledHeaderOutputFile> <PrecompiledHeaderOutputFile>$(OutDir)$(ProjectName).pch</PrecompiledHeaderOutputFile>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary> <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<PreprocessorDefinitions>_LARGE_WORLDS;_DEBUG_MENUS_ENABLED;_DEBUG;_CRT_NON_CONFORMING_SWPRINTFS;_CRT_SECURE_NO_WARNINGS;_WINDOWS64;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>_LARGE_WORLDS;_DEBUG_MENUS_ENABLED;_DEBUG;_CRT_NON_CONFORMING_SWPRINTFS;_CRT_SECURE_NO_WARNINGS;_WINDOWS64;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<CallAttributedProfiling>Disabled</CallAttributedProfiling> <CallAttributedProfiling>Disabled</CallAttributedProfiling>
<AdditionalIncludeDirectories>Windows64\Iggy\include;$(ProjectDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>Windows64\Iggy\include;$(ProjectDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
@@ -1472,46 +1472,6 @@ if not exist "$(TargetDir)\savedata" mkdir "$(TargetDir)\savedata"</Command>
<Message>Run Windows64 postbuild script</Message> <Message>Run Windows64 postbuild script</Message>
</PostBuildEvent> </PostBuildEvent>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<Optimization>Disabled</Optimization>
<ExceptionHandling>Sync</ExceptionHandling>
<BufferSecurityCheck>false</BufferSecurityCheck>
<PrecompiledHeaderOutputFile>$(OutDir)$(ProjectName).pch</PrecompiledHeaderOutputFile>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<PreprocessorDefinitions>_LARGE_WORLDS;_DEBUG_MENUS_ENABLED;_DEBUG;_CRT_NON_CONFORMING_SWPRINTFS;_CRT_SECURE_NO_WARNINGS;_WINDOWS64;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<CallAttributedProfiling>Disabled</CallAttributedProfiling>
<AdditionalIncludeDirectories>Windows64\Iggy\include;$(ProjectDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<RuntimeTypeInfo>true</RuntimeTypeInfo>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<BasicRuntimeChecks>Default</BasicRuntimeChecks>
<ShowIncludes>false</ShowIncludes>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<ProgramDatabaseFile>$(OutDir)$(ProjectName).pdb</ProgramDatabaseFile>
<AdditionalDependencies>d3d11.lib;..\Minecraft.World\x64_Debug\Minecraft.World.lib;%(AdditionalDependencies);XInput9_1_0.lib;..\Minecraft.Client\Windows64\Miles\Lib\mss64.lib;wsock32.lib</AdditionalDependencies>
<ShowProgress>NotSet</ShowProgress>
<SuppressStartupBanner>false</SuppressStartupBanner>
</Link>
<ImageXex>
<ConfigurationFile>$(ProjectDir)xbox\xex-dev.xml</ConfigurationFile>
</ImageXex>
<ImageXex>
<TitleID>1480659447</TitleID>
</ImageXex>
<ImageXex>
<AdditionalSections>584111F7=$(ProjectDir)xbox\GameConfig\Minecraft.spa,RO;media=$(ProjectDir)xbox\XZP\Minecraft.xzp,RO</AdditionalSections>
<Pal50Incompatible>true</Pal50Incompatible>
</ImageXex>
<Deploy>
<DeploymentType>CopyToHardDrive</DeploymentType>
<DeploymentFiles>$(RemoteRoot)=$(ImagePath);$(RemoteRoot)\res=Xbox\res;$(RemoteRoot)=Xbox\AvatarAwards;$(RemoteRoot)\Tutorial=Xbox\Tutorial\Tutorial;$(RemoteRoot)=Xbox\584111F70AAAAAAA;$(RemoteRoot)=Xbox\kinect\speech;$(RemoteRoot)=Xbox\XZP\TMSFiles.xzp</DeploymentFiles>
</Deploy>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Durango'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Durango'">
<ClCompile> <ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader> <PrecompiledHeader>Use</PrecompiledHeader>
@@ -17167,6 +17127,7 @@ xcopy /q /y /i /s /e $(ProjectDir)Durango\CU $(LayoutDir)Image\Loose\CU</Comman
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='ContentPackage_Vita|Xbox 360'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='ContentPackage_Vita|Xbox 360'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Xbox 360'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Xbox 360'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='CONTENTPACKAGE_SYMBOLS|Xbox 360'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='CONTENTPACKAGE_SYMBOLS|Xbox 360'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|PSVita'">true</ExcludedFromBuild>
</ClInclude> </ClInclude>
<ClInclude Include="PSVita\Network\PSVita_NPToolkit.h"> <ClInclude Include="PSVita\Network\PSVita_NPToolkit.h">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='ContentPackage|Durango'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='ContentPackage|Durango'">true</ExcludedFromBuild>
@@ -17485,6 +17446,7 @@ xcopy /q /y /i /s /e $(ProjectDir)Durango\CU $(LayoutDir)Image\Loose\CU</Comman
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Xbox 360'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Xbox 360'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='CONTENTPACKAGE_SYMBOLS|Xbox 360'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='CONTENTPACKAGE_SYMBOLS|Xbox 360'">true</ExcludedFromBuild>
</ClInclude> </ClInclude>
<ClInclude Include="PSVita\OldSdk.h" />
<ClInclude Include="PSVita\PSVitaExtras\Conf.h"> <ClInclude Include="PSVita\PSVitaExtras\Conf.h">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='ContentPackage|Durango'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='ContentPackage|Durango'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='ContentPackage_NO_TU|Durango'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='ContentPackage_NO_TU|Durango'">true</ExcludedFromBuild>
@@ -32817,6 +32779,7 @@ xcopy /q /y /i /s /e $(ProjectDir)Durango\CU $(LayoutDir)Image\Loose\CU</Comman
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='ContentPackage_Vita|Xbox 360'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='ContentPackage_Vita|Xbox 360'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Xbox 360'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Xbox 360'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='CONTENTPACKAGE_SYMBOLS|Xbox 360'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='CONTENTPACKAGE_SYMBOLS|Xbox 360'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|PSVita'">true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="PSVita\Network\PSVita_NPToolkit.cpp"> <ClCompile Include="PSVita\Network\PSVita_NPToolkit.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='ContentPackage|Durango'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='ContentPackage|Durango'">true</ExcludedFromBuild>
@@ -33133,6 +33096,7 @@ xcopy /q /y /i /s /e $(ProjectDir)Durango\CU $(LayoutDir)Image\Loose\CU</Comman
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Xbox 360'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Xbox 360'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='CONTENTPACKAGE_SYMBOLS|Xbox 360'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='CONTENTPACKAGE_SYMBOLS|Xbox 360'">true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="PSVita\OldSdk.cpp" />
<ClCompile Include="PSVita\PSVitaExtras\CustomMap.cpp"> <ClCompile Include="PSVita\PSVitaExtras\CustomMap.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='ContentPackage|Durango'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='ContentPackage|Durango'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='ContentPackage_Vita|Durango'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='ContentPackage_Vita|Durango'">true</ExcludedFromBuild>
@@ -34044,7 +34008,7 @@ xcopy /q /y /i /s /e $(ProjectDir)Durango\CU $(LayoutDir)Image\Loose\CU</Comman
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='ReleaseForArt|Win32'">false</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='ReleaseForArt|Win32'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='ContentPackage_NO_TU|x64'">false</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='ContentPackage_NO_TU|x64'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='ContentPackage_NO_TU|Win32'">false</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='ContentPackage_NO_TU|Win32'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='ContentPackage_Vita|x64'">false</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='ContentPackage_Vita|x64'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='ContentPackage_Vita|Win32'">false</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='ContentPackage_Vita|Win32'">false</ExcludedFromBuild>
@@ -3772,6 +3772,9 @@
<ClInclude Include="Common\Leaderboards\LeaderboardInterface.h"> <ClInclude Include="Common\Leaderboards\LeaderboardInterface.h">
<Filter>Common\Source Files\Leaderboards</Filter> <Filter>Common\Source Files\Leaderboards</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="PSVita\OldSdk.h">
<Filter>PSVita</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="stdafx.cpp"> <ClCompile Include="stdafx.cpp">
@@ -5913,6 +5916,9 @@
<ClCompile Include="Common\Leaderboards\LeaderboardInterface.cpp"> <ClCompile Include="Common\Leaderboards\LeaderboardInterface.cpp">
<Filter>Common\Source Files\Leaderboards</Filter> <Filter>Common\Source Files\Leaderboards</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="PSVita\OldSdk.cpp">
<Filter>PSVita</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Library Include="Xbox\4JLibs\libs\4J_Render_d.lib"> <Library Include="Xbox\4JLibs\libs\4J_Render_d.lib">
+1 -1
View File
@@ -1858,7 +1858,7 @@ void Minecraft::run_middle()
achievementPopup->render(); achievementPopup->render();
PIXBeginNamedEvent(0,"Sleeping"); PIXBeginNamedEvent(0,"Sleeping");
Sleep(0); // 4J - was Thread.yield() //Sleep(0); // 4J - was Thread.yield()
PIXEndNamedEvent(); PIXEndNamedEvent();
// if (Keyboard::isKeyDown(Keyboard::KEY_F7)) Display.update(); // 4J - removed condition // if (Keyboard::isKeyDown(Keyboard::KEY_F7)) Display.update(); // 4J - removed condition
+1 -1
View File
@@ -116,7 +116,7 @@ void Options::init()
bobView = true; bobView = true;
anaglyph3d = false; anaglyph3d = false;
advancedOpengl = false; advancedOpengl = false;
framerateLimit = 2; framerateLimit = 0;
fancyGraphics = true; fancyGraphics = true;
ambientOcclusion = true; ambientOcclusion = true;
renderClouds = true; renderClouds = true;
File diff suppressed because it is too large Load Diff
@@ -1,109 +1,32 @@
#pragma once #pragma once
#include "Common\Leaderboards\SonyLeaderboardManager.h"
#include "Common\Leaderboards\LeaderboardManager.h" #include "Common\Leaderboards\LeaderboardManager.h"
class OrbisLeaderboardManager : public LeaderboardManager #include <np.h>
{
protected:
enum EStatsState
{
eStatsState_Idle,
eStatsState_Getting,
eStatsState_Failed,
eStatsState_Ready,
eStatsState_Canceled,
//eStatsState_Writing,
eStatsState_Max
};
class OrbisLeaderboardManager : public SonyLeaderboardManager
{
public: public:
OrbisLeaderboardManager(); OrbisLeaderboardManager();
virtual ~OrbisLeaderboardManager();
private: protected:
unsigned short m_openSessions;
C4JThread *m_threadScoreboard; virtual HRESULT initialiseScoreUtility();
bool m_running;
int m_titleContext; virtual bool scoreUtilityAlreadyInitialised(HRESULT hr);
int32_t m_requestId;
//SceNpId m_myNpId; virtual HRESULT createTitleContext(const SceNpId &npId);
static int scoreboardThreadEntry(LPVOID lpParam); virtual HRESULT destroyTitleContext(int titleContext);
void scoreboardThreadInternal();
bool getScoreByIds(); virtual HRESULT createTransactionContext(int titleContext);
bool getScoreByRange();
bool setScore(); virtual HRESULT abortTransactionContext(int transactionContext);
queue<RegisterScore> m_views;
CRITICAL_SECTION m_csViewsLock; virtual HRESULT destroyTransactionContext(int transactionContext);
EStatsState m_eStatsState; //State of the stats read virtual HRESULT getFriendsList(sce::Toolkit::NP::Utilities::Future<sce::Toolkit::NP::FriendsList> &friendsList);
// EFilterMode m_eFilterMode;
ReadScore *m_scores; virtual char * getComment(SceNpScoreComment *comment);
unsigned int m_maxRank;
//SceNpScoreRankData *m_stats;
public:
virtual void Tick();// {}
//Open a session
virtual bool OpenSession();// { return true; }
//Close a session
virtual void CloseSession();// {}
//Delete a session
virtual void DeleteSession();// {}
//Write the given stats
//This is called synchronously and will not free any memory allocated for views when it is done
virtual bool WriteStats(unsigned int viewCount, ViewIn views);// { return false; }
virtual bool ReadStats_Friends(LeaderboardReadListener *callback, int difficulty, EStatsType type, PlayerUID myUID, unsigned int startIndex, unsigned int readCount);// { return false; }
virtual bool ReadStats_MyScore(LeaderboardReadListener *callback, int difficulty, EStatsType type, PlayerUID myUID, unsigned int readCount);// { return false; }
virtual bool ReadStats_TopRank(LeaderboardReadListener *callback, int difficulty, EStatsType type, unsigned int startIndex, unsigned int readCount);// { return false; }
//Perform a flush of the stats
virtual void FlushStats();// {}
//Cancel the current operation
virtual void CancelOperation();// {}
//Is the leaderboard manager idle.
virtual bool isIdle();// { return true; }
private:
int getBoardId(int difficulty, EStatsType);
//LeaderboardManager::ReadScore *filterJustScorers(unsigned int &num, LeaderboardManager::ReadScore *friendsData);
SceNpScorePlayerRankData *addPadding(unsigned int num, SceNpScoreRankData *rankData);
void convertToOutput(unsigned int &num, ReadScore *out, SceNpScorePlayerRankData *rankData, SceNpScoreComment *comm);
void toBinary(void *out, SceNpScoreComment *in);
void fromBinary(SceNpScoreComment **out, void *in);
void toBase32(SceNpScoreComment *out, void *in);
void fromBase32(void *out, SceNpScoreComment *in);
void toSymbols(char *);
void fromSymbols(char *);
bool test_string(string);
void initReadScoreStruct(ReadScore &out, SceNpScoreRankData &);
void fillReadScoreStruct(ReadScore &out, SceNpScoreComment &comment);
static bool SortByRank(const ReadScore &lhs, const ReadScore &rhs);
//void NotifyAsyncPlusFeature();
}; };
@@ -10,6 +10,8 @@
#include "..\..\Common\Network\Sony\SQRNetworkManager.h" #include "..\..\Common\Network\Sony\SQRNetworkManager.h"
#include "../OldSdk.h"
class SQRNetworkPlayer; class SQRNetworkPlayer;
class ISQRNetworkManagerListener; class ISQRNetworkManagerListener;
class SonyVoiceChat_Vita; class SonyVoiceChat_Vita;
+53
View File
@@ -0,0 +1,53 @@
#include "stdafx.h"
#include "OldSdk.h"
#ifdef __PSVITA__
int sceNpBasicGetFriendOnlineStatus(const SceNpId *friendId, SceNpBasicOnlineStatus *status) {
if (status) *status = SCE_NP_BASIC_ONLINE_STATUS_UNKNOWN;
return -1;
}
int sceNpBasicGetFriendContextState(const SceNpId *friendId, SceNpBasicFriendContextState *state) {
if (state) *state = SCE_NP_BASIC_FRIEND_CONTEXT_STATE_UNKNOWN;
return -1;
}
int sceNpBasicGetGamePresenceOfFriend(const SceNpId *friendId, SceNpBasicGamePresence *presence) {
if (presence) memset(presence, 0, sizeof(SceNpBasicGamePresence));
return -1;
}
int sceNpBasicGetFriendListEntryCount(SceSize *count) {
if (count) *count = 0;
return 0;
}
int sceNpBasicGetFriendListEntries(unsigned int startIndex, SceNpId *entries, SceSize numEntries, SceSize *retrieved) {
if (retrieved) *retrieved = 0;
return 0;
}
int sceNpBasicGetFriendRequestEntryCount(SceSize *count) {
if (count) *count = 0;
return 0;
}
int sceNpBasicGetFriendRequestEntries(unsigned int startIndex, SceNpId *entries, SceSize numEntries, SceSize *retrieved) {
if (retrieved) *retrieved = 0;
return 0;
}
int sceNpBasicGetRequestedFriendRequestEntryCount(SceSize *count) {
if (count) *count = 0;
return 0;
}
int sceNpBasicGetRequestedFriendRequestEntries(unsigned int startIndex, SceNpId *entries, SceSize numEntries, SceSize *retrieved) {
if (retrieved) *retrieved = 0;
return 0;
}
SceInt32 sceAppUtilAppEventParseNpBasicJoinablePresence(const SceAppUtilAppEventParam *eventParam, SceAppUtilNpBasicJoinablePresenceParam *param) {
return -1;
}
#endif
+55
View File
@@ -0,0 +1,55 @@
#pragma once
#ifdef __PSVITA__
#ifndef _OLD_SDK_H
#define _OLD_SDK_H 1
#include <np.h>
#include <np/np_basic.h>
#include <apputil.h>
#include <np_toolkit.h>
#include <np_toolkit\friends_interface.h>
typedef enum {
SCE_NP_BASIC_ONLINE_STATUS_UNKNOWN = 0,
SCE_NP_BASIC_ONLINE_STATUS_OFFLINE = 1,
SCE_NP_BASIC_ONLINE_STATUS_AFK = 2,
SCE_NP_BASIC_ONLINE_STATUS_ONLINE = 3
} SceNpBasicOnlineStatus;
typedef void(*SceNpBasicFriendOnlineStatusEventHandler)(
const SceNpId *friendId,
SceNpBasicOnlineStatus status,
void *userdata
);
typedef enum {
SCE_NP_BASIC_FRIEND_CONTEXT_STATE_UNKNOWN = 0,
SCE_NP_BASIC_FRIEND_CONTEXT_STATE_OUT_OF_CONTEXT = 1,
SCE_NP_BASIC_FRIEND_CONTEXT_STATE_IN_CONTEXT = 2
} SceNpBasicFriendContextState;
typedef void(*SceNpBasicFriendContextEventHandler)(
const SceNpId *friendId,
SceNpBasicFriendContextState state,
void *userdata
);
typedef struct SceAppUtilNpBasicJoinablePresenceParam {
SceNpCommunicationId commId;
SceNpId npId;
} SceAppUtilNpBasicJoinablePresenceParam;
int sceNpBasicGetFriendOnlineStatus(const SceNpId *friendId, SceNpBasicOnlineStatus *status);
int sceNpBasicGetFriendContextState(const SceNpId *friendId, SceNpBasicFriendContextState *state);
int sceNpBasicGetGamePresenceOfFriend(const SceNpId *friendId, SceNpBasicGamePresence *presence);
int sceNpBasicGetFriendListEntryCount(SceSize *count);
int sceNpBasicGetFriendListEntries(unsigned int startIndex, SceNpId *entries, SceSize numEntries, SceSize *retrieved);
int sceNpBasicGetFriendRequestEntryCount(SceSize *count);
int sceNpBasicGetFriendRequestEntries(unsigned int startIndex, SceNpId *entries, SceSize numEntries, SceSize *retrieved);
int sceNpBasicGetRequestedFriendRequestEntryCount(SceSize *count);
int sceNpBasicGetRequestedFriendRequestEntries(unsigned int startIndex, SceNpId *entries, SceSize numEntries, SceSize *retrieved);
SceInt32 sceAppUtilAppEventParseNpBasicJoinablePresence(const SceAppUtilAppEventParam *eventParam, SceAppUtilNpBasicJoinablePresenceParam *param);
#define SCE_APPUTIL_APPEVENT_TYPE_NP_BASIC_JOINABLE_PRESENCE (3)
#endif
#endif
+5 -1
View File
@@ -434,7 +434,11 @@ void Textures::bindTextureLayers(ResourceLocation *resource)
for( int i = 0; i < layers; i++ ) for( int i = 0; i < layers; i++ )
{ {
RenderManager.TextureBind(loadTexture(resource->getTexture(i))); int texId = resource->getTexture(i);
if( texId != -1 )
{
RenderManager.TextureBind(loadTexture(texId));
}
} }
} }
@@ -498,7 +498,7 @@ app.DebugPrintf("width: %d, height: %d\n", width, height);
DXGI_SWAP_CHAIN_DESC sd; DXGI_SWAP_CHAIN_DESC sd;
ZeroMemory( &sd, sizeof( sd ) ); ZeroMemory( &sd, sizeof( sd ) );
sd.BufferCount = 1; sd.BufferCount = 2;
sd.BufferDesc.Width = width; sd.BufferDesc.Width = width;
sd.BufferDesc.Height = height; sd.BufferDesc.Height = height;
sd.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; sd.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
+1 -2
View File
@@ -552,13 +552,12 @@ bool AbstractContainerMenu::isPauseScreen()
void AbstractContainerMenu::setItem(unsigned int slot, shared_ptr<ItemInstance> item) void AbstractContainerMenu::setItem(unsigned int slot, shared_ptr<ItemInstance> item)
{ {
if (slot >= slots->size()) return;
getSlot(slot)->set(item); getSlot(slot)->set(item);
} }
void AbstractContainerMenu::setAll(ItemInstanceArray *items) void AbstractContainerMenu::setAll(ItemInstanceArray *items)
{ {
for (unsigned int i = 0; i < items->length && i < slots->size(); i++) for (unsigned int i = 0; i < items->length; i++)
{ {
getSlot(i)->set( (*items)[i] ); getSlot(i)->set( (*items)[i] );
} }
+18 -18
View File
@@ -1,19 +1,19 @@
#include "stdafx.h" #include "stdafx.h"
#include "AttackDamageMobEffect.h" #include "AttackDamageMobEffect.h"
AttackDamageMobEffect::AttackDamageMobEffect(int id, bool isHarmful, eMinecraftColour color) : MobEffect(id, isHarmful, color) AttackDamageMobEffect::AttackDamageMobEffect(int id, bool isHarmful, eMinecraftColour color) : MobEffect(id, isHarmful, color)
{ {
} }
double AttackDamageMobEffect::getAttributeModifierValue(int amplifier, AttributeModifier *original) double AttackDamageMobEffect::getAttributeModifierValue(int amplifier, AttributeModifier *original)
{ {
if (id == MobEffect::weakness->id) if (id == MobEffect::weakness->id)
{ {
return -0.5f * (amplifier + 1); return -0.5f * (amplifier + 1);
} }
else else
{ {
return 1.3 * (amplifier + 1); return 1.3 * (amplifier + 1);
} }
} }
+1 -1
View File
@@ -47,7 +47,7 @@ void AwardStatPacket::read(DataInputStream *dis) //throws IOException
// Read parameter blob. // Read parameter blob.
int length = dis->readInt(); int length = dis->readInt();
if(length > 0 && length <= 65536) if(length > 0)
{ {
m_paramData = byteArray(length); m_paramData = byteArray(length);
dis->readFully(m_paramData); dis->readFully(m_paramData);
+1 -10
View File
@@ -103,12 +103,6 @@ void BlockRegionUpdatePacket::read(DataInputStream *dis) //throws IOException
levelIdx = ( size >> 30 ) & 3; levelIdx = ( size >> 30 ) & 3;
size &= 0x3fffffff; size &= 0x3fffffff;
const int MAX_COMPRESSED_CHUNK_SIZE = 5 * 1024 * 1024;
if(size < 0 || size > MAX_COMPRESSED_CHUNK_SIZE)
{
size = 0;
}
if(size == 0) if(size == 0)
{ {
buffer = byteArray(); buffer = byteArray();
@@ -137,10 +131,7 @@ void BlockRegionUpdatePacket::read(DataInputStream *dis) //throws IOException
delete [] compressedBuffer.data; delete [] compressedBuffer.data;
if(buffer.length != outputSize) assert(buffer.length == outputSize);
{
app.DebugPrintf("BlockRegionUpdatePacket: decompressed size mismatch (expected %d, got %d)\n", buffer.length, outputSize);
}
} }
} }
+5 -10
View File
@@ -9,17 +9,12 @@
//buf - the input buffer. //buf - the input buffer.
//offset - the offset in the buffer of the first byte to read. //offset - the offset in the buffer of the first byte to read.
//length - the maximum number of bytes to read from the buffer. //length - the maximum number of bytes to read from the buffer.
ByteArrayInputStream::ByteArrayInputStream(byteArray buf, unsigned int offset, unsigned int length) ByteArrayInputStream::ByteArrayInputStream(byteArray buf, unsigned int offset, unsigned int length)
: pos( offset ), mark( offset ) : pos( offset ), count( min( offset+length, buf.length ) ), mark( offset )
{ {
if( offset > buf.length ) this->buf = buf;
count = buf.length;
else if( length > buf.length - offset )
count = buf.length;
else
count = offset + length;
this->buf = buf;
} }
//Creates a ByteArrayInputStream so that it uses buf as its buffer array. The buffer array is not copied. //Creates a ByteArrayInputStream so that it uses buf as its buffer array. The buffer array is not copied.
//The initial value of pos is 0 and the initial value of count is the length of buf. //The initial value of pos is 0 and the initial value of count is the length of buf.
//Parameters: //Parameters:
+12 -21
View File
@@ -49,27 +49,18 @@ void ByteArrayOutputStream::write(byteArray b)
//b - the data. //b - the data.
//off - the start offset in the data. //off - the start offset in the data.
//len - the number of bytes to write. //len - the number of bytes to write.
void ByteArrayOutputStream::write(byteArray b, unsigned int offset, unsigned int length) void ByteArrayOutputStream::write(byteArray b, unsigned int offset, unsigned int length)
{ {
assert( b.length >= offset + length );
if (offset > b.length || length > b.length - offset)
return; // If we will fill the buffer we need to make it bigger
if( count + length >= buf.length )
if (length > 0xFFFFFFFF - count) buf.resize( max( count + length + 1, buf.length * 2 ) );
return;
XMemCpy( &buf[count], &b[offset], length );
// If we will fill the buffer we need to make it bigger //std::copy( b->data+offset, b->data+offset+length, buf->data + count ); // Or this instead?
if( count + length >= buf.length )
{ count += length;
unsigned int newSize = (std::max)( count + length + 1, buf.length * 2 );
if( newSize <= buf.length )
return;
buf.resize( newSize );
}
XMemCpy( &buf[count], &b[offset], length );
count += length;
} }
//Closing a ByteArrayOutputStream has no effect. //Closing a ByteArrayOutputStream has no effect.
+7 -8
View File
@@ -18,14 +18,13 @@ public:
dos->write(data); dos->write(data);
} }
void load(DataInput *dis) void load(DataInput *dis, int tagDepth)
{ {
int length = dis->readInt(); int length = dis->readInt();
if (length < 0 || length > 2 * 1024 * 1024) length = 0;
if ( data.data ) delete[] data.data;
if ( data.data ) delete[] data.data; data = byteArray(length);
data = byteArray(length); dis->readFully(data);
dis->readFully(data);
} }
byte getId() { return TAG_Byte_Array; } byte getId() { return TAG_Byte_Array; }
+3 -4
View File
@@ -112,7 +112,6 @@ C4JThread::C4JThread( C4JThreadStartFunc* startFunc, void* param, const char* th
m_threadID = sceKernelCreateThread(m_threadName, entryPoint, g_DefaultPriority, m_stackSize, 0, CPU, NULL); m_threadID = sceKernelCreateThread(m_threadName, entryPoint, g_DefaultPriority, m_stackSize, 0, CPU, NULL);
app.DebugPrintf("***************************** start thread %s **************************\n", m_threadName); app.DebugPrintf("***************************** start thread %s **************************\n", m_threadName);
#else #else
m_completionFlag = new Event(Event::e_modeManualClear);
m_threadID = 0; m_threadID = 0;
m_threadHandle = 0; m_threadHandle = 0;
m_threadHandle = CreateThread(NULL, m_stackSize, entryPoint, this, CREATE_SUSPENDED, &m_threadID); m_threadHandle = CreateThread(NULL, m_stackSize, entryPoint, this, CREATE_SUSPENDED, &m_threadID);
@@ -161,7 +160,6 @@ C4JThread::C4JThread( const char* mainThreadName)
// sceKernelChangeThreadPriority(m_threadID, g_DefaultPriority + 1); // sceKernelChangeThreadPriority(m_threadID, g_DefaultPriority + 1);
g_DefaultCPU = SCE_KERNEL_CPU_MASK_USER_ALL;//sceKernelGetThreadCpuAffinityMask(m_threadID); g_DefaultCPU = SCE_KERNEL_CPU_MASK_USER_ALL;//sceKernelGetThreadCpuAffinityMask(m_threadID);
#else #else
m_completionFlag = new Event(Event::e_modeManualClear);
m_threadID = GetCurrentThreadId(); m_threadID = GetCurrentThreadId();
m_threadHandle = GetCurrentThread(); m_threadHandle = GetCurrentThread();
#endif #endif
@@ -175,7 +173,9 @@ C4JThread::C4JThread( const char* mainThreadName)
C4JThread::~C4JThread() C4JThread::~C4JThread()
{ {
#if defined __PS3__ || defined __ORBIS__ || defined __PSVITA__
delete m_completionFlag; delete m_completionFlag;
#endif
#if defined __ORBIS__ #if defined __ORBIS__
scePthreadJoin(m_threadID, NULL); scePthreadJoin(m_threadID, NULL);
@@ -243,7 +243,6 @@ DWORD WINAPI C4JThread::entryPoint(LPVOID lpParam)
C4JThread* pThread = (C4JThread*)lpParam; C4JThread* pThread = (C4JThread*)lpParam;
SetThreadName(-1, pThread->m_threadName); SetThreadName(-1, pThread->m_threadName);
pThread->m_exitCode = (*pThread->m_startFunc)(pThread->m_threadParam); pThread->m_exitCode = (*pThread->m_startFunc)(pThread->m_threadParam);
pThread->m_completionFlag->Set();
pThread->m_isRunning = false; pThread->m_isRunning = false;
return pThread->m_exitCode; return pThread->m_exitCode;
} }
@@ -389,7 +388,7 @@ DWORD C4JThread::WaitForCompletion( int timeoutMs )
// return m_exitCode; // return m_exitCode;
#else #else
return m_completionFlag->WaitForSignal(timeoutMs); return WaitForSingleObject(m_threadHandle, timeoutMs);
#endif // __PS3__ #endif // __PS3__
} }
+7 -9
View File
@@ -27,15 +27,13 @@ ComplexItemDataPacket::ComplexItemDataPacket(short itemType, short itemId, charA
memcpy(this->data.data, data.data, data.length); memcpy(this->data.data, data.data, data.length);
} }
void ComplexItemDataPacket::read(DataInputStream *dis) //throws IOException void ComplexItemDataPacket::read(DataInputStream *dis) //throws IOException
{ {
itemType = dis->readShort(); itemType = dis->readShort();
itemId = dis->readShort(); itemId = dis->readShort();
int dataLength = dis->readShort() & 0xffff; data = charArray(dis->readUnsignedShort() & 0xffff);
if(dataLength > 32767) dataLength = 0; dis->readFully(data);
data = charArray(dataLength);
dis->readFully(data);
} }
void ComplexItemDataPacket::write(DataOutputStream *dos) //throws IOException void ComplexItemDataPacket::write(DataOutputStream *dos) //throws IOException
+84 -86
View File
@@ -29,7 +29,6 @@ void Connection::_init()
running = true; running = true;
quitting = false; quitting = false;
disconnected = false; disconnected = false;
m_closeState = 0;
disconnectReason = DisconnectPacket::eDisconnect_None; disconnectReason = DisconnectPacket::eDisconnect_None;
noInputTicks = 0; noInputTicks = 0;
estimatedRemaining = 0; estimatedRemaining = 0;
@@ -44,21 +43,14 @@ void Connection::_init()
} }
// 4J Jev, need to delete the critical section. // 4J Jev, need to delete the critical section.
Connection::~Connection() Connection::~Connection()
{ {
LONG closeState = InterlockedCompareExchange(&m_closeState, 1, 0); // 4J Stu - Just to be sure, make sure the read and write threads terminate themselves before the connection object is destroyed
if (closeState == 0) running = false;
{ if( dis ) dis->close(); // The input stream needs closed before the readThread, or the readThread
shutdownConnectionResources(); // may get stuck whilst blocking waiting on a read
InterlockedExchange(&m_closeState, 2); readThread->WaitForCompletion(INFINITE);
} writeThread->WaitForCompletion(INFINITE);
else if (closeState == 1)
{
while (InterlockedCompareExchange(&m_closeState, 2, 2) != 2)
{
Sleep(0);
}
}
DeleteCriticalSection(&writeLock); DeleteCriticalSection(&writeLock);
DeleteCriticalSection(&threadCounterLock); DeleteCriticalSection(&threadCounterLock);
@@ -82,37 +74,6 @@ Connection::~Connection()
dis = NULL; dis = NULL;
} }
void Connection::shutdownConnectionResources()
{
running = false;
if( dis ) dis->close();
if( readThread ) readThread->WaitForCompletion(INFINITE);
if( writeThread ) writeThread->WaitForCompletion(INFINITE);
delete dis;
dis = NULL;
if( bufferedDos )
{
bufferedDos->close();
bufferedDos->deleteChildStream();
delete bufferedDos;
bufferedDos = NULL;
}
if( byteArrayDos )
{
byteArrayDos->close();
delete byteArrayDos;
byteArrayDos = NULL;
}
if( socket )
{
socket->close(packetListener != NULL ? packetListener->isServerPacketListener() : false);
socket = NULL;
}
}
Connection::Connection(Socket *socket, const wstring& id, PacketListener *packetListener) // throws IOException Connection::Connection(Socket *socket, const wstring& id, PacketListener *packetListener) // throws IOException
{ {
_init(); _init();
@@ -147,8 +108,8 @@ Connection::Connection(Socket *socket, const wstring& id, PacketListener *packet
const char *szId = wstringtofilename(id); const char *szId = wstringtofilename(id);
char readThreadName[256]; char readThreadName[256];
char writeThreadName[256]; char writeThreadName[256];
sprintf_s(readThreadName, sizeof(readThreadName), "%.240s read\n", szId); sprintf(readThreadName,"%s read\n",szId);
sprintf_s(writeThreadName, sizeof(writeThreadName), "%.240s write\n", szId); sprintf(writeThreadName,"%s write\n",szId);
readThread = new C4JThread(runRead, (void*)this, readThreadName, READ_STACK_SIZE); readThread = new C4JThread(runRead, (void*)this, readThreadName, READ_STACK_SIZE);
writeThread = new C4JThread(runWrite, this, writeThreadName, WRITE_STACK_SIZE); writeThread = new C4JThread(runWrite, this, writeThreadName, WRITE_STACK_SIZE);
@@ -403,38 +364,80 @@ close("disconnect.genericReason", "Internal exception: " + e.toString());
}*/ }*/
void Connection::close(DisconnectPacket::eDisconnectReason reason, ...) void Connection::close(DisconnectPacket::eDisconnectReason reason, ...)
{ {
// printf("Con:0x%x close\n",this); // printf("Con:0x%x close\n",this);
if (InterlockedCompareExchange(&m_closeState, 1, 0) != 0) return; if (!running) return;
// printf("Con:0x%x close doing something\n",this); // printf("Con:0x%x close doing something\n",this);
disconnected = true; disconnected = true;
va_list input; va_list input;
va_start( input, reason ); va_start( input, reason );
disconnectReason = reason; disconnectReason = reason;//va_arg( input, const wstring );
disconnectReasonObjects = NULL;
va_end(input); vector<void *> objs = vector<void *>();
void *i = NULL;
// int count = 0, sum = 0, i = first; while (i != NULL)
// va_list marker; {
// i = va_arg( input, void* );
// va_start( marker, first ); objs.push_back(i);
// while( i != -1 ) }
// {
// sum += i; if( objs.size() )
// count++; {
// i = va_arg( marker, int); disconnectReasonObjects = &objs[0];
// } }
// va_end( marker ); else
// return( sum ? (sum / count) : 0 ); {
disconnectReasonObjects = NULL;
}
// CreateThread(NULL, 0, runClose, this, 0, &closeThreadID);
// int count = 0, sum = 0, i = first;
shutdownConnectionResources(); // va_list marker;
InterlockedExchange(&m_closeState, 2); //
// va_start( marker, first );
// while( i != -1 )
// {
// sum += i;
// count++;
// i = va_arg( marker, int);
// }
// va_end( marker );
// return( sum ? (sum / count) : 0 );
// CreateThread(NULL, 0, runClose, this, 0, &closeThreadID);
running = false;
if( dis ) dis->close(); // The input stream needs closed before the readThread, or the readThread
// may get stuck whilst blocking waiting on a read
// Make sure that the read & write threads are dead before we go and kill the streams that they depend on
readThread->WaitForCompletion(INFINITE);
writeThread->WaitForCompletion(INFINITE);
delete dis;
dis = NULL;
if( bufferedDos )
{
bufferedDos->close();
bufferedDos->deleteChildStream();
delete bufferedDos;
bufferedDos = NULL;
}
if( byteArrayDos )
{
byteArrayDos->close();
delete byteArrayDos;
byteArrayDos = NULL;
}
if( socket )
{
socket->close(packetListener->isServerPacketListener());
socket = NULL;
}
} }
void Connection::tick() void Connection::tick()
@@ -497,11 +500,6 @@ void Connection::tick()
// MGH - moved the packet handling outside of the incoming_cs block, as it was locking up sometimes when disconnecting // MGH - moved the packet handling outside of the incoming_cs block, as it was locking up sometimes when disconnecting
for(int i=0; i<packetsToHandle.size();i++) for(int i=0; i<packetsToHandle.size();i++)
{ {
// if a packet handler disconnected this connection, drop any remaining queued packets
if (disconnected || quitting || packetListener == NULL)
{
break;
}
PIXBeginNamedEvent(0,"Handling packet %d\n",packetsToHandle[i]->getId()); PIXBeginNamedEvent(0,"Handling packet %d\n",packetsToHandle[i]->getId());
packetsToHandle[i]->handle(packetListener); packetsToHandle[i]->handle(packetListener);
PIXEndNamedEvent(); PIXEndNamedEvent();
-2
View File
@@ -49,7 +49,6 @@ private:
DataOutputStream *byteArrayDos; // 4J This dos allows us to write individual packets to the socket DataOutputStream *byteArrayDos; // 4J This dos allows us to write individual packets to the socket
ByteArrayOutputStream *baos; ByteArrayOutputStream *baos;
Socket::SocketOutputStream *sos; Socket::SocketOutputStream *sos;
volatile LONG m_closeState;
bool running; bool running;
@@ -88,7 +87,6 @@ public:
private: private:
void _init(); void _init();
void shutdownConnectionResources();
// 4J Jev, these might be better of as private // 4J Jev, these might be better of as private
CRITICAL_SECTION threadCounterLock; CRITICAL_SECTION threadCounterLock;
+3 -4
View File
@@ -213,7 +213,7 @@ ConsoleSaveFileOriginal::~ConsoleSaveFileOriginal()
VirtualFree( pvHeap, MAX_PAGE_COUNT * CSF_PAGE_SIZE, MEM_DECOMMIT ); VirtualFree( pvHeap, MAX_PAGE_COUNT * CSF_PAGE_SIZE, MEM_DECOMMIT );
pagesCommitted = 0; pagesCommitted = 0;
// Make sure we don't have any thumbnail data still waiting round - we can't need it now we've destroyed the save file anyway // Make sure we don't have any thumbnail data still waiting round - we can't need it now we've destroyed the save file anyway
#if defined _XBOX || defined _WINDOWS64 #if defined _XBOX
app.GetSaveThumbnail(NULL,NULL); app.GetSaveThumbnail(NULL,NULL);
#elif defined __PS3__ #elif defined __PS3__
app.GetSaveThumbnail(NULL,NULL, NULL,NULL); app.GetSaveThumbnail(NULL,NULL, NULL,NULL);
@@ -749,7 +749,7 @@ void ConsoleSaveFileOriginal::Flush(bool autosave, bool updateThumbnail )
PBYTE pbDataSaveImage=NULL; PBYTE pbDataSaveImage=NULL;
DWORD dwDataSizeSaveImage=0; DWORD dwDataSizeSaveImage=0;
#if ( defined _XBOX || defined _DURANGO || defined _WINDOWS64 ) #if ( defined _XBOX || defined _DURANGO )
app.GetSaveThumbnail(&pbThumbnailData,&dwThumbnailDataSize); app.GetSaveThumbnail(&pbThumbnailData,&dwThumbnailDataSize);
#elif ( defined __PS3__ || defined __ORBIS__ || defined __PSVITA__ ) #elif ( defined __PS3__ || defined __ORBIS__ || defined __PSVITA__ )
app.GetSaveThumbnail(&pbThumbnailData,&dwThumbnailDataSize,&pbDataSaveImage,&dwDataSizeSaveImage); app.GetSaveThumbnail(&pbThumbnailData,&dwThumbnailDataSize,&pbDataSaveImage,&dwDataSizeSaveImage);
@@ -819,8 +819,7 @@ void ConsoleSaveFileOriginal::Flush(bool autosave, bool updateThumbnail )
int ConsoleSaveFileOriginal::SaveSaveDataCallback(LPVOID lpParam,bool bRes) int ConsoleSaveFileOriginal::SaveSaveDataCallback(LPVOID lpParam,bool bRes)
{ {
(void)lpParam; ConsoleSaveFile *pClass=(ConsoleSaveFile *)lpParam;
(void)bRes;
return 0; return 0;
} }
+2 -2
View File
@@ -586,7 +586,7 @@ ConsoleSaveFileSplit::~ConsoleSaveFileSplit()
VirtualFree( pvHeap, MAX_PAGE_COUNT * CSF_PAGE_SIZE, MEM_DECOMMIT ); VirtualFree( pvHeap, MAX_PAGE_COUNT * CSF_PAGE_SIZE, MEM_DECOMMIT );
pagesCommitted = 0; pagesCommitted = 0;
// Make sure we don't have any thumbnail data still waiting round - we can't need it now we've destroyed the save file anyway // Make sure we don't have any thumbnail data still waiting round - we can't need it now we've destroyed the save file anyway
#if defined _XBOX || defined _WINDOWS64 #if defined _XBOX
app.GetSaveThumbnail(NULL,NULL); app.GetSaveThumbnail(NULL,NULL);
#elif defined __PS3__ #elif defined __PS3__
app.GetSaveThumbnail(NULL,NULL, NULL,NULL); app.GetSaveThumbnail(NULL,NULL, NULL,NULL);
@@ -1412,7 +1412,7 @@ void ConsoleSaveFileSplit::Flush(bool autosave, bool updateThumbnail)
PBYTE pbDataSaveImage=NULL; PBYTE pbDataSaveImage=NULL;
DWORD dwDataSizeSaveImage=0; DWORD dwDataSizeSaveImage=0;
#if ( defined _XBOX || defined _DURANGO || defined _WINDOWS64 ) #if ( defined _XBOX || defined _DURANGO )
app.GetSaveThumbnail(&pbThumbnailData,&dwThumbnailDataSize); app.GetSaveThumbnail(&pbThumbnailData,&dwThumbnailDataSize);
#elif ( defined __PS3__ || defined __ORBIS__ ) #elif ( defined __PS3__ || defined __ORBIS__ )
app.GetSaveThumbnail(&pbThumbnailData,&dwThumbnailDataSize,&pbDataSaveImage,&dwDataSizeSaveImage); app.GetSaveThumbnail(&pbThumbnailData,&dwThumbnailDataSize,&pbDataSaveImage,&dwDataSizeSaveImage);
@@ -32,9 +32,6 @@ void ContainerSetContentPacket::read(DataInputStream *dis) //throws IOException
{ {
containerId = dis->readByte(); containerId = dis->readByte();
int count = dis->readShort(); int count = dis->readShort();
if(count < 0 || count > 256) count = 0;
items = ItemInstanceArray(count); items = ItemInstanceArray(count);
for (int i = 0; i < count; i++) for (int i = 0; i < count; i++)
{ {
+1 -1
View File
@@ -35,7 +35,7 @@ void ContainerSetSlotPacket::read(DataInputStream *dis) //throws IOException
// 4J Stu - TU-1 hotfix // 4J Stu - TU-1 hotfix
// Fix for #13142 - Holding down the A button on the furnace ingredient slot causes the UI to display incorrect item counts // Fix for #13142 - Holding down the A button on the furnace ingredient slot causes the UI to display incorrect item counts
BYTE byteId = dis->readByte(); BYTE byteId = dis->readByte();
containerId = (char)(signed char)byteId; containerId = *(char *)&byteId;
slot = dis->readShort(); slot = dis->readShort();
item = readItem(dis); item = readItem(dis);
} }
+1 -1
View File
@@ -43,7 +43,7 @@ void CustomPayloadPacket::read(DataInputStream *dis)
identifier = readUtf(dis, 20); identifier = readUtf(dis, 20);
length = dis->readShort(); length = dis->readShort();
if (length > 0 && length <= Short::MAX_VALUE) if (length > 0 && length < Short::MAX_VALUE)
{ {
if(data.data != NULL) if(data.data != NULL)
{ {
-4
View File
@@ -303,10 +303,6 @@ wstring DataInputStream::readUTF()
int b = stream->read(); int b = stream->read();
unsigned short UTFLength = (unsigned short) (((a & 0xff) << 8) | (b & 0xff)); unsigned short UTFLength = (unsigned short) (((a & 0xff) << 8) | (b & 0xff));
const unsigned short MAX_UTF_LENGTH = 32767;
if( UTFLength > MAX_UTF_LENGTH )
return outputString;
//// 4J Stu - I decided while writing DataOutputStream that we didn't need to bother using the UTF8 format //// 4J Stu - I decided while writing DataOutputStream that we didn't need to bother using the UTF8 format
//// used in the java libs, and just write in/out as wchar_t all the time //// used in the java libs, and just write in/out as wchar_t all the time
-21
View File
@@ -432,27 +432,6 @@ void DirectoryLevelStorage::save(shared_ptr<Player> player)
CompoundTag *DirectoryLevelStorage::load(shared_ptr<Player> player) CompoundTag *DirectoryLevelStorage::load(shared_ptr<Player> player)
{ {
CompoundTag *tag = loadPlayerDataTag( player->getXuid() ); CompoundTag *tag = loadPlayerDataTag( player->getXuid() );
#ifdef _WINDOWS64
if (tag == NULL)
{
const PlayerUID WIN64_XUID_BASE = (PlayerUID)0xe000d45248242f2e;
for (int i = 0; i < MINECRAFT_NET_MAX_PLAYERS; i++)
{
PlayerUID oldXuid = WIN64_XUID_BASE + i;
tag = loadPlayerDataTag(oldXuid);
if (tag != NULL)
{
ConsoleSavePath oldFile = ConsoleSavePath(playerDir.getName() + _toString(oldXuid) + L".dat");
if (m_saveFile->doesFileExist(oldFile))
{
m_saveFile->deleteFile(m_saveFile->createFile(oldFile));
}
app.DebugPrintf("Migrated player data from old XUID %llu to new XUID %llu\n", oldXuid, player->getXuid());
break;
}
}
}
#endif
if (tag != NULL) if (tag != NULL)
{ {
player->load(tag); player->load(tag);
-5
View File
@@ -50,11 +50,6 @@ public:
#ifdef _XBOX_ONE #ifdef _XBOX_ONE
eDisconnect_ExitedGame, eDisconnect_ExitedGame,
#endif #endif
eDisconnect_NotWhitelisted = 100,
eDisconnect_ServerBanned,
eDisconnect_IPBanned,
eDisconnect_InvalidUsername,
}; };
// 4J Stu - The reason was a string, but we need to send a non-locale specific reason // 4J Stu - The reason was a string, but we need to send a non-locale specific reason
-1
View File
@@ -152,7 +152,6 @@ void EnchantmentMenu::slotsChanged() // 4J used to take a shared_ptr<Container>
bool EnchantmentMenu::clickMenuButton(shared_ptr<Player> player, int i) bool EnchantmentMenu::clickMenuButton(shared_ptr<Player> player, int i)
{ {
if (i < 0 || i >= 3) return false;
shared_ptr<ItemInstance> item = enchantSlots->getItem(0); shared_ptr<ItemInstance> item = enchantSlots->getItem(0);
if (costs[i] > 0 && item != NULL && (player->experienceLevel >= costs[i] || player->abilities.instabuild) ) if (costs[i] > 0 && item != NULL && (player->experienceLevel >= costs[i] || player->abilities.instabuild) )
{ {
-2
View File
@@ -56,8 +56,6 @@ void ExplodePacket::read(DataInputStream *dis) //throws IOException
r = dis->readFloat(); r = dis->readFloat();
int count = dis->readInt(); int count = dis->readInt();
if(count < 0 || count > 32768) count = 0;
int xp = (int)x; int xp = (int)x;
int yp = (int)y; int yp = (int)y;
int zp = (int)z; int zp = (int)z;
+1 -1
View File
@@ -40,7 +40,7 @@ void GameCommandPacket::read(DataInputStream *dis)
command = (EGameCommand)dis->readInt(); command = (EGameCommand)dis->readInt();
length = dis->readShort(); length = dis->readShort();
if (length > 0 && length <= Short::MAX_VALUE) if (length > 0 && length < Short::MAX_VALUE)
{ {
if(data.data != NULL) if(data.data != NULL)
{ {
+1 -6
View File
@@ -1,6 +1,5 @@
#include "stdafx.h" #include "stdafx.h"
#include <xhash> #include <xhash>
#include <functional>
#include "Hasher.h" #include "Hasher.h"
@@ -20,11 +19,7 @@ wstring Hasher::getHash(wstring &name)
//return new BigInteger(1, m.digest()).toString(16); //return new BigInteger(1, m.digest()).toString(16);
// TODO 4J Stu - Will this hash us with the same distribution as the MD5? // TODO 4J Stu - Will this hash us with the same distribution as the MD5?
#if !defined(_MSC_VER) || _MSC_VER >= 1900 return _toString( hash_value( s ) );
return _toString( std::hash<wstring>{}( s ) );
#else
return _toString( stdext::hash_value( s ) );
#endif
//} //}
//catch (NoSuchAlgorithmException e) //catch (NoSuchAlgorithmException e)
//{ //{
-2
View File
@@ -7,8 +7,6 @@ wstring I18n::get(const wstring& id, ...)
{ {
#ifdef __PSVITA__ // 4J - vita doesn't like having a reference type as the last parameter passed to va_start - we shouldn't need this method anyway #ifdef __PSVITA__ // 4J - vita doesn't like having a reference type as the last parameter passed to va_start - we shouldn't need this method anyway
return L""; return L"";
#elif _MSC_VER >= 1930 // VS2022+ also disallows va_start with reference types
return id;
#else #else
va_list va; va_list va;
va_start(va, id); va_start(va, id);
-1
View File
@@ -35,7 +35,6 @@ public:
void load(DataInput *dis, int tagDepth) void load(DataInput *dis, int tagDepth)
{ {
int length = dis->readInt(); int length = dis->readInt();
if (length < 0 || length > 65536) length = 0;
if ( data.data ) delete[] data.data; if ( data.data ) delete[] data.data;
data = intArray(length); data = intArray(length);
+3
View File
@@ -143,6 +143,9 @@ void Inventory::grabTexture(int id, int data, bool checkData, bool mayReplace)
void Inventory::swapPaint(int wheel) void Inventory::swapPaint(int wheel)
{ {
if (wheel > 0) wheel = 1;
if (wheel < 0) wheel = -1;
selected -= wheel; selected -= wheel;
while (selected < 0) while (selected < 0)
-2
View File
@@ -24,8 +24,6 @@ wstring Language::getElement(const wstring& elementId, ...)
{ {
#ifdef __PSVITA__ // 4J - vita doesn't like having a reference type as the last parameter passed to va_start - we shouldn't need this method anyway #ifdef __PSVITA__ // 4J - vita doesn't like having a reference type as the last parameter passed to va_start - we shouldn't need this method anyway
return L""; return L"";
#elif _MSC_VER >= 1930 // VS2022+ also disallows va_start with reference types
return elementId;
#else #else
va_list args; va_list args;
va_start(args, elementId); va_start(args, elementId);
+1 -2
View File
@@ -1951,8 +1951,7 @@ AABBList *Level::getCubes(shared_ptr<Entity> source, AABB *box, bool noEntities/
// 4J - now add in collision for any blocks which have actually been removed, but haven't had their render data updated to reflect this yet. This is to stop the player // 4J - now add in collision for any blocks which have actually been removed, but haven't had their render data updated to reflect this yet. This is to stop the player
// being able to move the view position inside a tile which is (visually) still there, and see out of the world. This is particularly a problem when moving upwards in // being able to move the view position inside a tile which is (visually) still there, and see out of the world. This is particularly a problem when moving upwards in
// creative mode as the player can get very close to the edge of tiles whilst looking upwards and can therefore very quickly move inside one. // creative mode as the player can get very close to the edge of tiles whilst looking upwards and can therefore very quickly move inside one.
if(Minecraft::GetInstance()->levelRenderer != NULL) Minecraft::GetInstance()->levelRenderer->destroyedTileManager->addAABBs( this, box, &boxes);
Minecraft::GetInstance()->levelRenderer->destroyedTileManager->addAABBs( this, box, &boxes);
// 4J - added // 4J - added
if( noEntities ) return &boxes; if( noEntities ) return &boxes;
+2 -4
View File
@@ -37,13 +37,11 @@ public:
} }
type = dis->readByte(); type = dis->readByte();
int size = dis->readInt(); int size = dis->readInt();
if (size < 0 || size > 10000) size = 0;
list.clear(); list.clear();
for (int i = 0; i < size; i++) for (int i = 0; i < size; i++)
{ {
Tag *tag = Tag::newTag(type, L""); Tag *tag = Tag::newTag(type, L"");
if (tag == NULL) break;
tag->load(dis, tagDepth); tag->load(dis, tagDepth);
list.push_back(tag); list.push_back(tag);
} }
@@ -60,7 +58,7 @@ public:
void print(char *prefix, ostream out) void print(char *prefix, ostream out)
{ {
Tag::print(out); Tag::print(prefix, out);
out << prefix << "{" << endl; out << prefix << "{" << endl;
@@ -69,7 +67,7 @@ public:
strcat( newPrefix, " "); strcat( newPrefix, " ");
AUTO_VAR(itEnd, list.end()); AUTO_VAR(itEnd, list.end());
for (AUTO_VAR(it, list.begin()); it != itEnd; it++) for (AUTO_VAR(it, list.begin()); it != itEnd; it++)
(*it)->print(out); (*it)->print(newPrefix, out);
delete[] newPrefix; delete[] newPrefix;
out << prefix << "}" << endl; out << prefix << "}" << endl;
} }
+2 -16
View File
@@ -14,7 +14,6 @@ C4JThread *McRegionChunkStorage::s_saveThreads[3];
McRegionChunkStorage::McRegionChunkStorage(ConsoleSaveFile *saveFile, const wstring &prefix) : m_prefix( prefix ) McRegionChunkStorage::McRegionChunkStorage(ConsoleSaveFile *saveFile, const wstring &prefix) : m_prefix( prefix )
{ {
m_saveFile = saveFile; m_saveFile = saveFile;
InitializeCriticalSectionAndSpinCount(&m_csEntityData, 4000);
// Make sure that if there are any files for regions to be created, that they are created in the order that suits us for making the initial level save work fast // Make sure that if there are any files for regions to be created, that they are created in the order that suits us for making the initial level save work fast
if( prefix == L"" ) if( prefix == L"" )
@@ -69,7 +68,6 @@ McRegionChunkStorage::~McRegionChunkStorage()
{ {
delete it->second.data; delete it->second.data;
} }
DeleteCriticalSection(&m_csEntityData);
} }
LevelChunk *McRegionChunkStorage::load(Level *level, int x, int z) LevelChunk *McRegionChunkStorage::load(Level *level, int x, int z)
@@ -82,14 +80,12 @@ LevelChunk *McRegionChunkStorage::load(Level *level, int x, int z)
{ {
__int64 index = ((__int64)(x) << 32) | (((__int64)(z))&0x00000000FFFFFFFF); __int64 index = ((__int64)(x) << 32) | (((__int64)(z))&0x00000000FFFFFFFF);
EnterCriticalSection(&m_csEntityData);
AUTO_VAR(it, m_entityData.find(index)); AUTO_VAR(it, m_entityData.find(index));
if(it != m_entityData.end()) if(it != m_entityData.end())
{ {
delete it->second.data; delete it->second.data;
m_entityData.erase(it); m_entityData.erase(it);
} }
LeaveCriticalSection(&m_csEntityData);
} }
#endif #endif
@@ -248,12 +244,11 @@ void McRegionChunkStorage::saveEntities(Level *level, LevelChunk *levelChunk)
PIXBeginNamedEvent(0,"Saving entities"); PIXBeginNamedEvent(0,"Saving entities");
__int64 index = ((__int64)(levelChunk->x) << 32) | (((__int64)(levelChunk->z))&0x00000000FFFFFFFF); __int64 index = ((__int64)(levelChunk->x) << 32) | (((__int64)(levelChunk->z))&0x00000000FFFFFFFF);
delete m_entityData[index].data;
CompoundTag *newTag = new CompoundTag(); CompoundTag *newTag = new CompoundTag();
bool savedEntities = OldChunkStorage::saveEntities(levelChunk, level, newTag); bool savedEntities = OldChunkStorage::saveEntities(levelChunk, level, newTag);
EnterCriticalSection(&m_csEntityData);
delete m_entityData[index].data;
if(savedEntities) if(savedEntities)
{ {
ByteArrayOutputStream bos; ByteArrayOutputStream bos;
@@ -273,7 +268,6 @@ void McRegionChunkStorage::saveEntities(Level *level, LevelChunk *levelChunk)
m_entityData.erase(it); m_entityData.erase(it);
} }
} }
LeaveCriticalSection(&m_csEntityData);
delete newTag; delete newTag;
PIXEndNamedEvent(); PIXEndNamedEvent();
#endif #endif
@@ -284,22 +278,16 @@ void McRegionChunkStorage::loadEntities(Level *level, LevelChunk *levelChunk)
#ifdef SPLIT_SAVES #ifdef SPLIT_SAVES
__int64 index = ((__int64)(levelChunk->x) << 32) | (((__int64)(levelChunk->z))&0x00000000FFFFFFFF); __int64 index = ((__int64)(levelChunk->x) << 32) | (((__int64)(levelChunk->z))&0x00000000FFFFFFFF);
EnterCriticalSection(&m_csEntityData);
AUTO_VAR(it, m_entityData.find(index)); AUTO_VAR(it, m_entityData.find(index));
if(it != m_entityData.end()) if(it != m_entityData.end())
{ {
ByteArrayInputStream bais(it->second); ByteArrayInputStream bais(it->second);
DataInputStream dis(&bais); DataInputStream dis(&bais);
CompoundTag *tag = NbtIo::read(&dis); CompoundTag *tag = NbtIo::read(&dis);
LeaveCriticalSection(&m_csEntityData);
OldChunkStorage::loadEntities(levelChunk, level, tag); OldChunkStorage::loadEntities(levelChunk, level, tag);
bais.reset(); bais.reset();
delete tag; delete tag;
} }
else
{
LeaveCriticalSection(&m_csEntityData);
}
#endif #endif
} }
@@ -318,7 +306,6 @@ void McRegionChunkStorage::flush()
DataOutputStream dos(&bos); DataOutputStream dos(&bos);
PIXBeginNamedEvent(0,"Writing to stream"); PIXBeginNamedEvent(0,"Writing to stream");
EnterCriticalSection(&m_csEntityData);
dos.writeInt(m_entityData.size()); dos.writeInt(m_entityData.size());
for(AUTO_VAR(it,m_entityData.begin()); it != m_entityData.end(); ++it) for(AUTO_VAR(it,m_entityData.begin()); it != m_entityData.end(); ++it)
@@ -326,7 +313,6 @@ void McRegionChunkStorage::flush()
dos.writeLong(it->first); dos.writeLong(it->first);
dos.write(it->second,0,it->second.length); dos.write(it->second,0,it->second.length);
} }
LeaveCriticalSection(&m_csEntityData);
bos.flush(); bos.flush();
PIXEndNamedEvent(); PIXEndNamedEvent();
PIXEndNamedEvent(); PIXEndNamedEvent();
-1
View File
@@ -17,7 +17,6 @@ private:
static CRITICAL_SECTION cs_memory; static CRITICAL_SECTION cs_memory;
unordered_map<__int64, byteArray> m_entityData; unordered_map<__int64, byteArray> m_entityData;
CRITICAL_SECTION m_csEntityData;
static std::deque<DataOutputStream *> s_chunkDataQueue; static std::deque<DataOutputStream *> s_chunkDataQueue;
static int s_runningThreadCount; static int s_runningThreadCount;
+2 -2
View File
@@ -77,7 +77,7 @@ void MinecartTNT::destroy(DamageSource *source)
void MinecartTNT::explode(double speedSqr) void MinecartTNT::explode(double speedSqr)
{ {
if (!level->isClientSide) if (!level->isClientSide && app.GetGameHostOption(eGameHostOption_TNT))
{ {
double speed = sqrt(speedSqr); double speed = sqrt(speedSqr);
if (speed > 5) speed = 5; if (speed > 5) speed = 5;
@@ -121,7 +121,7 @@ void MinecartTNT::primeFuse()
{ {
fuse = 80; fuse = 80;
if (!level->isClientSide) if (!level->isClientSide && app.GetGameHostOption(eGameHostOption_TNT))
{ {
level->broadcastEntityEvent(shared_from_this(), EVENT_PRIME); level->broadcastEntityEvent(shared_from_this(), EVENT_PRIME);
level->playEntitySound(shared_from_this(), eSoundType_RANDOM_FUSE, 1, 1.0f); level->playEntitySound(shared_from_this(), eSoundType_RANDOM_FUSE, 1, 1.0f);
+1 -1
View File
@@ -1124,7 +1124,7 @@
<ExceptionHandling>Sync</ExceptionHandling> <ExceptionHandling>Sync</ExceptionHandling>
<BufferSecurityCheck>false</BufferSecurityCheck> <BufferSecurityCheck>false</BufferSecurityCheck>
<PrecompiledHeaderOutputFile>$(OutDir)$(ProjectName).pch</PrecompiledHeaderOutputFile> <PrecompiledHeaderOutputFile>$(OutDir)$(ProjectName).pch</PrecompiledHeaderOutputFile>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary> <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<PreprocessorDefinitions>_LARGE_WORLDS;_DEBUG_MENUS_ENABLED;_DEBUG;_LIB;_CRT_NON_CONFORMING_SWPRINTFS;_CRT_SECURE_NO_WARNINGS;_WINDOWS64;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>_LARGE_WORLDS;_DEBUG_MENUS_ENABLED;_DEBUG;_LIB;_CRT_NON_CONFORMING_SWPRINTFS;_CRT_SECURE_NO_WARNINGS;_WINDOWS64;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<CallAttributedProfiling>Disabled</CallAttributedProfiling> <CallAttributedProfiling>Disabled</CallAttributedProfiling>
<RuntimeTypeInfo>true</RuntimeTypeInfo> <RuntimeTypeInfo>true</RuntimeTypeInfo>
+8 -6
View File
@@ -32,6 +32,13 @@ TilePos MobSpawner::getRandomPosWithin(Level *level, int cx, int cz)
return TilePos(x, y, z); return TilePos(x, y, z);
} }
#ifdef __PSVITA__
// AP - See CustomMap.h for an explanation of this
CustomMap MobSpawner::chunksToPoll;
#else
unordered_map<ChunkPos,bool,ChunkPosKeyHash,ChunkPosKeyEq> MobSpawner::chunksToPoll;
#endif
const int MobSpawner::tick(ServerLevel *level, bool spawnEnemies, bool spawnFriendlies, bool spawnPersistent) const int MobSpawner::tick(ServerLevel *level, bool spawnEnemies, bool spawnFriendlies, bool spawnPersistent)
{ {
#ifndef _CONTENT_PACKAGE #ifndef _CONTENT_PACKAGE
@@ -92,12 +99,7 @@ const int MobSpawner::tick(ServerLevel *level, bool spawnEnemies, bool spawnFrie
return 0; return 0;
} }
MemSect(20); MemSect(20);
#ifdef __PSVITA__ chunksToPoll.clear();
// AP - See CustomMap.h for an explanation of this
CustomMap MobSpawner::chunksToPoll;
#else
unordered_map<ChunkPos,bool,ChunkPosKeyHash,ChunkPosKeyEq> chunksToPoll;
#endif
#if 0 #if 0
AUTO_VAR(itEnd, level->players.end()); AUTO_VAR(itEnd, level->players.end());
+8
View File
@@ -17,6 +17,14 @@ private:
protected: protected:
static TilePos getRandomPosWithin(Level *level, int cx, int cz); static TilePos getRandomPosWithin(Level *level, int cx, int cz);
private:
#ifdef __PSVITA__
// AP - See CustomMap.h for an explanation of this
static CustomMap chunksToPoll;
#else
static unordered_map<ChunkPos,bool,ChunkPosKeyHash,ChunkPosKeyEq> chunksToPoll;
#endif
public: public:
static const int tick(ServerLevel *level, bool spawnEnemies, bool spawnFriendlies, bool spawnPersistent); static const int tick(ServerLevel *level, bool spawnEnemies, bool spawnFriendlies, bool spawnPersistent);
static bool isSpawnPositionOk(MobCategory *category, Level *level, int x, int y, int z); static bool isSpawnPositionOk(MobCategory *category, Level *level, int x, int y, int z);
+1 -1
View File
@@ -79,7 +79,7 @@ bool NoteBlockTile::triggerEvent(Level *level, int x, int y, int z, int i, int n
break; break;
} }
app.DebugPrintf("NoteBlockTile::triggerEvent - playSound - pitch = %f\n",pitch); app.DebugPrintf("NoteBlockTile::triggerEvent - playSound - pitch = %f\n",pitch);
level->playSound(x + 0.5, y + 0.5, z + 0.5, iSound, 3, pitch); level->playSound(x + 0.5, y + 0.5, z + 0.5, iSound, 3, pitch, 64.0);
level->addParticle(eParticleType_note, x + 0.5, y + 1.2, z + 0.5, note / 24.0, 0, 0); level->addParticle(eParticleType_note, x + 0.5, y + 1.2, z + 0.5, note / 24.0, 0, 0);
return true; return true;
+23 -22
View File
@@ -476,28 +476,29 @@ LevelChunk *OldChunkStorage::load(Level *level, DataInputStream *dis)
CompoundTag *tag = NbtIo::read(dis); CompoundTag *tag = NbtIo::read(dis);
if (tag != NULL) loadEntities(levelChunk, level, tag);
{
loadEntities(levelChunk, level, tag); if (tag->contains(L"TileTicks"))
{
if (tag->contains(L"TileTicks")) PIXBeginNamedEvent(0,"Loading TileTicks");
{ ListTag<CompoundTag> *tileTicks = (ListTag<CompoundTag> *) tag->getList(L"TileTicks");
ListTag<CompoundTag> *tileTicks = (ListTag<CompoundTag> *) tag->getList(L"TileTicks");
if (tileTicks != NULL)
if (tileTicks != NULL) {
{ for (int i = 0; i < tileTicks->size(); i++)
for (int i = 0; i < tileTicks->size(); i++) {
{ CompoundTag *teTag = tileTicks->get(i);
CompoundTag *teTag = tileTicks->get(i);
level->forceAddTileTick(teTag->getInt(L"x"), teTag->getInt(L"y"), teTag->getInt(L"z"), teTag->getInt(L"i"), teTag->getInt(L"t"), teTag->getInt(L"p"));
level->forceAddTileTick(teTag->getInt(L"x"), teTag->getInt(L"y"), teTag->getInt(L"z"), teTag->getInt(L"i"), teTag->getInt(L"t")); }
} }
} PIXEndNamedEvent();
} }
delete tag; delete tag;
}
PIXEndNamedEvent();
return levelChunk; return levelChunk;
} }
+4 -5
View File
@@ -265,11 +265,10 @@ void Packet::updatePacketStatsPIX()
#endif #endif
} }
shared_ptr<Packet> Packet::getPacket(int id) shared_ptr<Packet> Packet::getPacket(int id)
{ {
auto it = idToCreateMap.find(id); // 4J: Removed try/catch
if (it == idToCreateMap.end()) return nullptr; return idToCreateMap[id]();
return it->second();
} }
void Packet::writeBytes(DataOutputStream *dataoutputstream, byteArray bytes) void Packet::writeBytes(DataOutputStream *dataoutputstream, byteArray bytes)
+9
View File
@@ -218,10 +218,12 @@ bool PistonBaseTile::triggerEvent(Level *level, int x, int y, int z, int param1,
if (extend && param1 == TRIGGER_CONTRACT) if (extend && param1 == TRIGGER_CONTRACT)
{ {
level->setData(x, y, z, facing | EXTENDED_BIT, UPDATE_CLIENTS); level->setData(x, y, z, facing | EXTENDED_BIT, UPDATE_CLIENTS);
ignoreUpdate(false);
return false; return false;
} }
else if (!extend && param1 == TRIGGER_EXTEND) else if (!extend && param1 == TRIGGER_EXTEND)
{ {
ignoreUpdate(false);
return false; return false;
} }
} }
@@ -247,6 +249,7 @@ bool PistonBaseTile::triggerEvent(Level *level, int x, int y, int z, int param1,
} }
else else
{ {
ignoreUpdate(false);
return false; return false;
} }
PIXEndNamedEvent(); PIXEndNamedEvent();
@@ -340,6 +343,12 @@ bool PistonBaseTile::triggerEvent(Level *level, int x, int y, int z, int param1,
ignoreUpdate(false); ignoreUpdate(false);
level->updateNeighborsAt(x, y, z, id);
int stepX = x + Facing::STEP_X[facing];
int stepY = y + Facing::STEP_Y[facing];
int stepZ = z + Facing::STEP_Z[facing];
level->updateNeighborsAt(stepX, stepY, stepZ, id);
return true; return true;
} }
+8 -10
View File
@@ -2706,16 +2706,14 @@ int Player::getTexture()
} }
} }
int Player::hash_fnct(const shared_ptr<Player> k) int Player::hash_fnct(const shared_ptr<Player> k)
{ {
// TODO 4J Stu - Should we just be using the pointers and hashing them? // TODO 4J Stu - Should we just be using the pointers and hashing them?
#ifdef __PS3__ #ifdef __PS3__
return (int)boost::hash_value( k->name ); // 4J Stu - Names are completely unique? return (int)boost::hash_value( k->name ); // 4J Stu - Names are completely unique?
#elif !defined(_MSC_VER) || _MSC_VER >= 1900 #else
return (int)std::hash<wstring>{}( k->name ); // 4J Stu - Names are completely unique? return (int)std::hash_value( k->name ); // 4J Stu - Names are completely unique?
#else #endif //__PS3__
return (int)stdext::hash_value( k->name ); // 4J Stu - Names are completely unique?
#endif
} }
bool Player::eq_test(const shared_ptr<Player> x, const shared_ptr<Player> y) bool Player::eq_test(const shared_ptr<Player> x, const shared_ptr<Player> y)
+2 -31
View File
@@ -180,39 +180,11 @@ int PotionBrewing::getAppearanceValue(int brew)
return valueOf(brew, 5, 4, 3, 2, 1); return valueOf(brew, 5, 4, 3, 2, 1);
} }
static unsigned int GetFallbackPotionColour(eMinecraftColour id)
{
switch (id)
{
case eMinecraftColour_Potion_BaseColour: return 0x385DC6;
case eMinecraftColour_Effect_MovementSpeed: return 0x7CAFC6;
case eMinecraftColour_Effect_MovementSlowDown: return 0x5A6C81;
case eMinecraftColour_Effect_DigSpeed: return 0xD9C043;
case eMinecraftColour_Effect_DigSlowdown: return 0x4A4217;
case eMinecraftColour_Effect_DamageBoost: return 0x932423;
case eMinecraftColour_Effect_Heal: return 0xF82423;
case eMinecraftColour_Effect_Harm: return 0x430A09;
case eMinecraftColour_Effect_Jump: return 0x786297;
case eMinecraftColour_Effect_Confusion: return 0x551D4A;
case eMinecraftColour_Effect_Regeneration: return 0xCD5CAB;
case eMinecraftColour_Effect_DamageResistance: return 0x99453A;
case eMinecraftColour_Effect_FireResistance: return 0xE49A3A;
case eMinecraftColour_Effect_WaterBreathing: return 0x2E5299;
case eMinecraftColour_Effect_Invisiblity: return 0x7F8392;
case eMinecraftColour_Effect_Blindness: return 0x1F1F23;
case eMinecraftColour_Effect_NightVision: return 0x1F1FA1;
case eMinecraftColour_Effect_Hunger: return 0x587653;
case eMinecraftColour_Effect_Weakness: return 0x484D48;
case eMinecraftColour_Effect_Poison: return 0x4E9331;
default: return 0xFFFFFF;
}
}
int PotionBrewing::getColorValue(vector<MobEffectInstance *> *effects) int PotionBrewing::getColorValue(vector<MobEffectInstance *> *effects)
{ {
ColourTable *colourTable = Minecraft::GetInstance()->getColourTable(); ColourTable *colourTable = Minecraft::GetInstance()->getColourTable();
int baseColor = colourTable != NULL ? colourTable->getColor(eMinecraftColour_Potion_BaseColour) : GetFallbackPotionColour(eMinecraftColour_Potion_BaseColour); int baseColor = colourTable->getColor( eMinecraftColour_Potion_BaseColour );
if (effects == NULL || effects->empty()) if (effects == NULL || effects->empty())
{ {
@@ -228,8 +200,7 @@ int PotionBrewing::getColorValue(vector<MobEffectInstance *> *effects)
for(AUTO_VAR(it, effects->begin()); it != effects->end(); ++it) for(AUTO_VAR(it, effects->begin()); it != effects->end(); ++it)
{ {
MobEffectInstance *effect = *it; MobEffectInstance *effect = *it;
eMinecraftColour effectColorId = MobEffect::effects[effect->getId()]->getColor(); int potionColor = colourTable->getColor( MobEffect::effects[effect->getId()]->getColor() );
int potionColor = colourTable != NULL ? colourTable->getColor(effectColorId) : GetFallbackPotionColour(effectColorId);
for (int potency = 0; potency <= effect->getAmplifier(); potency++) for (int potency = 0; potency <= effect->getAmplifier(); potency++)
{ {
-2
View File
@@ -62,7 +62,6 @@ void PreLoginPacket::read(DataInputStream *dis) //throws IOException
m_friendsOnlyBits = dis->readByte(); m_friendsOnlyBits = dis->readByte();
m_ugcPlayersVersion = dis->readInt(); m_ugcPlayersVersion = dis->readInt();
m_dwPlayerCount = dis->readByte(); m_dwPlayerCount = dis->readByte();
if( m_dwPlayerCount > MINECRAFT_NET_MAX_PLAYERS ) m_dwPlayerCount = MINECRAFT_NET_MAX_PLAYERS;
if( m_dwPlayerCount > 0 ) if( m_dwPlayerCount > 0 )
{ {
m_playerXuids = new PlayerUID[m_dwPlayerCount]; m_playerXuids = new PlayerUID[m_dwPlayerCount];
@@ -75,7 +74,6 @@ void PreLoginPacket::read(DataInputStream *dis) //throws IOException
{ {
m_szUniqueSaveName[i]=dis->readByte(); m_szUniqueSaveName[i]=dis->readByte();
} }
m_szUniqueSaveName[m_iSaveNameLen - 1] = 0;
m_serverSettings = dis->readInt(); m_serverSettings = dis->readInt();
m_hostIndex = dis->readByte(); m_hostIndex = dis->readByte();
+1 -1
View File
@@ -778,7 +778,7 @@ void RandomLevelSource::postProcess(ChunkSource *parent, int xt, int zt)
mineShaftFeature->postProcess(level, pprandom, xt, zt); mineShaftFeature->postProcess(level, pprandom, xt, zt);
hasVillage = villageFeature->postProcess(level, pprandom, xt, zt); hasVillage = villageFeature->postProcess(level, pprandom, xt, zt);
strongholdFeature->postProcess(level, pprandom, xt, zt); strongholdFeature->postProcess(level, pprandom, xt, zt);
scatteredFeature->postProcess(level, pprandom, xt, zt); scatteredFeature->postProcess(level, random, xt, zt);
} }
PIXEndNamedEvent(); PIXEndNamedEvent();
+3 -3
View File
@@ -1099,7 +1099,7 @@ ShapedRecipy *Recipes::addShapedRecipy(ItemInstance *result, ...)
break; break;
case L'c': case L'c':
wchFrom=(wchar_t)va_arg(vl,int); wchFrom=va_arg(vl,wchar_t);
break; break;
case L'z': case L'z':
pItemInstance=va_arg(vl,ItemInstance *); pItemInstance=va_arg(vl,ItemInstance *);
@@ -1116,7 +1116,7 @@ ShapedRecipy *Recipes::addShapedRecipy(ItemInstance *result, ...)
mappings->insert(myMap::value_type(wchFrom,pItemInstance)); mappings->insert(myMap::value_type(wchFrom,pItemInstance));
break; break;
case L'g': case L'g':
wchFrom=(wchar_t)va_arg(vl,int); wchFrom=va_arg(vl,wchar_t);
switch(wchFrom) switch(wchFrom)
{ {
// case L'W': // case L'W':
@@ -1214,7 +1214,7 @@ void Recipes::addShapelessRecipy(ItemInstance *result,... )
ingredients->push_back(new ItemInstance(pTile)); ingredients->push_back(new ItemInstance(pTile));
break; break;
case L'g': case L'g':
wchFrom=(wchar_t)va_arg(vl,int); wchFrom=va_arg(vl,wchar_t);
switch(wchFrom) switch(wchFrom)
{ {
+2 -20
View File
@@ -10,7 +10,6 @@ byteArray RegionFile::emptySector(SECTOR_BYTES);
RegionFile::RegionFile(ConsoleSaveFile *saveFile, File *path) RegionFile::RegionFile(ConsoleSaveFile *saveFile, File *path)
{ {
InitializeCriticalSectionAndSpinCount(&m_cs, 4000);
_lastModified = 0; _lastModified = 0;
m_saveFile = saveFile; m_saveFile = saveFile;
@@ -39,12 +38,7 @@ RegionFile::RegionFile(ConsoleSaveFile *saveFile, File *path)
} }
*/ */
wstring saveName = fileName->getPath(); fileEntry = m_saveFile->createFile( fileName->getName() );
for (size_t i = 0; i < saveName.size(); i++)
{
if (saveName[i] == L'\\') saveName[i] = L'/';
}
fileEntry = m_saveFile->createFile( ConsoleSavePath(saveName) );
m_saveFile->setFilePointer( fileEntry, 0, NULL, FILE_END ); m_saveFile->setFilePointer( fileEntry, 0, NULL, FILE_END );
if ( fileEntry->getFileSize() < SECTOR_BYTES) if ( fileEntry->getFileSize() < SECTOR_BYTES)
@@ -141,8 +135,6 @@ void RegionFile::writeAllOffsets() // used for the file ConsoleSaveFile conversi
{ {
if(m_bIsEmpty == false) if(m_bIsEmpty == false)
{ {
EnterCriticalSection(&m_cs);
// save all the offsets and timestamps // save all the offsets and timestamps
m_saveFile->LockSaveAccess(); m_saveFile->LockSaveAccess();
@@ -155,7 +147,6 @@ void RegionFile::writeAllOffsets() // used for the file ConsoleSaveFile conversi
m_saveFile->writeFile(fileEntry, chunkTimestamps, SECTOR_BYTES, &numberOfBytesWritten); m_saveFile->writeFile(fileEntry, chunkTimestamps, SECTOR_BYTES, &numberOfBytesWritten);
m_saveFile->ReleaseSaveAccess(); m_saveFile->ReleaseSaveAccess();
LeaveCriticalSection(&m_cs);
} }
} }
@@ -165,7 +156,6 @@ RegionFile::~RegionFile()
delete[] chunkTimestamps; delete[] chunkTimestamps;
delete sectorFree; delete sectorFree;
m_saveFile->closeHandle( fileEntry ); m_saveFile->closeHandle( fileEntry );
DeleteCriticalSection(&m_cs);
} }
__int64 RegionFile::lastModified() __int64 RegionFile::lastModified()
@@ -175,10 +165,8 @@ __int64 RegionFile::lastModified()
int RegionFile::getSizeDelta() // TODO - was synchronized int RegionFile::getSizeDelta() // TODO - was synchronized
{ {
EnterCriticalSection(&m_cs);
int ret = sizeDelta; int ret = sizeDelta;
sizeDelta = 0; sizeDelta = 0;
LeaveCriticalSection(&m_cs);
return ret; return ret;
} }
@@ -190,14 +178,12 @@ DataInputStream *RegionFile::getChunkDataInputStream(int x, int z) // TODO - was
return NULL; return NULL;
} }
EnterCriticalSection(&m_cs);
// 4J - removed try/catch // 4J - removed try/catch
// try { // try {
int offset = getOffset(x, z); int offset = getOffset(x, z);
if (offset == 0) if (offset == 0)
{ {
// debugln("READ", x, z, "miss"); // debugln("READ", x, z, "miss");
LeaveCriticalSection(&m_cs);
return NULL; return NULL;
} }
@@ -206,7 +192,6 @@ DataInputStream *RegionFile::getChunkDataInputStream(int x, int z) // TODO - was
if (sectorNumber + numSectors > sectorFree->size()) if (sectorNumber + numSectors > sectorFree->size())
{ {
LeaveCriticalSection(&m_cs);
// debugln("READ", x, z, "invalid sector"); // debugln("READ", x, z, "invalid sector");
return NULL; return NULL;
} }
@@ -242,7 +227,7 @@ DataInputStream *RegionFile::getChunkDataInputStream(int x, int z) // TODO - was
if (length > SECTOR_BYTES * numSectors) if (length > SECTOR_BYTES * numSectors)
{ {
// debugln("READ", x, z, "invalid length: " + length + " > 4096 * " + numSectors); // debugln("READ", x, z, "invalid length: " + length + " > 4096 * " + numSectors);
LeaveCriticalSection(&m_cs);
m_saveFile->ReleaseSaveAccess(); m_saveFile->ReleaseSaveAccess();
return NULL; return NULL;
} }
@@ -255,7 +240,6 @@ DataInputStream *RegionFile::getChunkDataInputStream(int x, int z) // TODO - was
m_saveFile->readFile(fileEntry,data,length,&numberOfBytesRead); m_saveFile->readFile(fileEntry,data,length,&numberOfBytesRead);
m_saveFile->ReleaseSaveAccess(); m_saveFile->ReleaseSaveAccess();
LeaveCriticalSection(&m_cs);
Compression::getCompression()->SetDecompressionType(m_saveFile->getSavePlatform()); // if this save is from another platform, set the correct decompression type Compression::getCompression()->SetDecompressionType(m_saveFile->getSavePlatform()); // if this save is from another platform, set the correct decompression type
@@ -306,7 +290,6 @@ void RegionFile::write(int x, int z, byte *data, int length) // TODO - was sync
return; return;
} }
EnterCriticalSection(&m_cs);
m_saveFile->LockSaveAccess(); m_saveFile->LockSaveAccess();
{ {
int offset = getOffset(x, z); int offset = getOffset(x, z);
@@ -413,7 +396,6 @@ void RegionFile::write(int x, int z, byte *data, int length) // TODO - was sync
setTimestamp(x, z, (int) (System::currentTimeMillis() / 1000L)); setTimestamp(x, z, (int) (System::currentTimeMillis() / 1000L));
} }
m_saveFile->ReleaseSaveAccess(); m_saveFile->ReleaseSaveAccess();
LeaveCriticalSection(&m_cs);
// } catch (IOException e) { // } catch (IOException e) {
// e.printStackTrace(); // e.printStackTrace();
-1
View File
@@ -33,7 +33,6 @@ private:
int sizeDelta; int sizeDelta;
__int64 _lastModified; __int64 _lastModified;
bool m_bIsEmpty; // 4J added bool m_bIsEmpty; // 4J added
CRITICAL_SECTION m_cs;
public: public:
RegionFile(ConsoleSaveFile *saveFile, File *path); RegionFile(ConsoleSaveFile *saveFile, File *path);
-4
View File
@@ -38,7 +38,6 @@ RegionFile *RegionFileCache::_getRegionFile(ConsoleSaveFile *saveFile, const wst
} }
MemSect(0); MemSect(0);
EnterCriticalSection(&m_cs);
RegionFile *ref = NULL; RegionFile *ref = NULL;
AUTO_VAR(it, cache.find(file)); AUTO_VAR(it, cache.find(file));
if( it != cache.end() ) if( it != cache.end() )
@@ -47,7 +46,6 @@ RegionFile *RegionFileCache::_getRegionFile(ConsoleSaveFile *saveFile, const wst
// 4J Jev, put back in. // 4J Jev, put back in.
if (ref != NULL) if (ref != NULL)
{ {
LeaveCriticalSection(&m_cs);
return ref; return ref;
} }
@@ -65,7 +63,6 @@ RegionFile *RegionFileCache::_getRegionFile(ConsoleSaveFile *saveFile, const wst
RegionFile *reg = new RegionFile(saveFile, &file); RegionFile *reg = new RegionFile(saveFile, &file);
cache[file] = reg; // 4J - this was originally a softReferenc cache[file] = reg; // 4J - this was originally a softReferenc
LeaveCriticalSection(&m_cs);
return reg; return reg;
} }
@@ -88,7 +85,6 @@ void RegionFileCache::_clear() // 4J - TODO was synchronized
// } // }
} }
cache.clear(); cache.clear();
LeaveCriticalSection(&m_cs);
} }
int RegionFileCache::_getSizeDelta(ConsoleSaveFile *saveFile, const wstring &prefix, int chunkX, int chunkZ) int RegionFileCache::_getSizeDelta(ConsoleSaveFile *saveFile, const wstring &prefix, int chunkX, int chunkZ)
+2 -3
View File
@@ -10,14 +10,13 @@ private:
static const int MAX_CACHE_SIZE = 256; static const int MAX_CACHE_SIZE = 256;
unordered_map<File, RegionFile *, FileKeyHash, FileKeyEq> cache; unordered_map<File, RegionFile *, FileKeyHash, FileKeyEq> cache;
CRITICAL_SECTION m_cs;
static RegionFileCache s_defaultCache; static RegionFileCache s_defaultCache;
public: public:
// Made public and non-static so we can have a cache for input and output files // Made public and non-static so we can have a cache for input and output files
RegionFileCache() { InitializeCriticalSectionAndSpinCount(&m_cs, 4000); } RegionFileCache() {}
~RegionFileCache() { DeleteCriticalSection(&m_cs); } ~RegionFileCache();
RegionFile *_getRegionFile(ConsoleSaveFile *saveFile, const wstring &prefix, int chunkX, int chunkZ); // 4J - TODO was synchronized RegionFile *_getRegionFile(ConsoleSaveFile *saveFile, const wstring &prefix, int chunkX, int chunkZ); // 4J - TODO was synchronized
void _clear(); // 4J - TODO was synchronized void _clear(); // 4J - TODO was synchronized
+7 -9
View File
@@ -19,15 +19,13 @@ RemoveEntitiesPacket::~RemoveEntitiesPacket()
delete ids.data; delete ids.data;
} }
void RemoveEntitiesPacket::read(DataInputStream *dis) //throws IOException void RemoveEntitiesPacket::read(DataInputStream *dis) //throws IOException
{ {
int count = dis->readByte(); ids = intArray(dis->readByte());
if(count < 0) count = 0; for(unsigned int i = 0; i < ids.length; ++i)
ids = intArray(count); {
for(unsigned int i = 0; i < ids.length; ++i) ids[i] = dis->readInt();
{ }
ids[i] = dis->readInt();
}
} }
void RemoveEntitiesPacket::write(DataOutputStream *dos) //throws IOException void RemoveEntitiesPacket::write(DataOutputStream *dos) //throws IOException
-5
View File
@@ -138,11 +138,6 @@ void Socket::pushDataToQueue(const BYTE * pbData, DWORD dwDataSize, bool fromHos
} }
EnterCriticalSection(&m_queueLockNetwork[queueIdx]); EnterCriticalSection(&m_queueLockNetwork[queueIdx]);
if(m_queueNetwork[queueIdx].size() + dwDataSize > 2 * 1024 * 1024)
{
LeaveCriticalSection(&m_queueLockNetwork[queueIdx]);
return;
}
for( unsigned int i = 0; i < dwDataSize; i++ ) for( unsigned int i = 0; i < dwDataSize; i++ )
{ {
m_queueNetwork[queueIdx].push(*pbData++); m_queueNetwork[queueIdx].push(*pbData++);
+7 -8
View File
@@ -600,14 +600,13 @@ bool SparseDataStorage::isCompressed()
} }
void SparseDataStorage::write(DataOutputStream *dos) void SparseDataStorage::write(DataOutputStream *dos)
{ {
__int64 snapshot = dataAndCount; int count = ( dataAndCount >> 48 ) & 0xffff;
int count = ( snapshot >> 48 ) & 0xffff; dos->writeInt(count);
dos->writeInt(count); unsigned char *dataPointer = (unsigned char *)(dataAndCount & 0x0000ffffffffffff);
unsigned char *dataPointer = (unsigned char *)(snapshot & 0x0000ffffffffffff); byteArray wrapper(dataPointer, count * 128 + 128);
byteArray wrapper(dataPointer, count * 128 + 128); dos->write(wrapper);
dos->write(wrapper);
} }
void SparseDataStorage::read(DataInputStream *dis) void SparseDataStorage::read(DataInputStream *dis)
+7 -8
View File
@@ -617,14 +617,13 @@ bool SparseLightStorage::isCompressed()
} }
void SparseLightStorage::write(DataOutputStream *dos) void SparseLightStorage::write(DataOutputStream *dos)
{ {
__int64 snapshot = dataAndCount; int count = ( dataAndCount >> 48 ) & 0xffff;
int count = ( snapshot >> 48 ) & 0xffff; dos->writeInt(count);
dos->writeInt(count); unsigned char *dataPointer = (unsigned char *)(dataAndCount & 0x0000ffffffffffff);
unsigned char *dataPointer = (unsigned char *)(snapshot & 0x0000ffffffffffff); byteArray wrapper(dataPointer, count * 128 + 128);
byteArray wrapper(dataPointer, count * 128 + 128); dos->write(wrapper);
dos->write(wrapper);
} }
void SparseLightStorage::read(DataInputStream *dis) void SparseLightStorage::read(DataInputStream *dis)
+4 -1
View File
@@ -189,7 +189,10 @@ void StemTile::spawnResources(Level *level, int x, int y, int z, int data, float
if (fruit == Tile::melon) seed = Item::seeds_melon; if (fruit == Tile::melon) seed = Item::seeds_melon;
for (int i = 0; i < 3; i++) for (int i = 0; i < 3; i++)
{ {
popResource(level, x, y, z, shared_ptr<ItemInstance>(new ItemInstance(seed))); if (level->random->nextInt(15) <= data)
{
popResource(level, x, y, z, shared_ptr<ItemInstance>(new ItemInstance(seed)));
}
} }
} }
-19
View File
@@ -9,7 +9,6 @@
StructureFeature::StructureFeature() StructureFeature::StructureFeature()
{ {
InitializeCriticalSectionAndSpinCount(&m_csCachedStructures, 4000);
#ifdef ENABLE_STRUCTURE_SAVING #ifdef ENABLE_STRUCTURE_SAVING
savedData = nullptr; savedData = nullptr;
#endif #endif
@@ -17,13 +16,10 @@ StructureFeature::StructureFeature()
StructureFeature::~StructureFeature() StructureFeature::~StructureFeature()
{ {
EnterCriticalSection(&m_csCachedStructures);
for( AUTO_VAR(it, cachedStructures.begin()); it != cachedStructures.end(); it++ ) for( AUTO_VAR(it, cachedStructures.begin()); it != cachedStructures.end(); it++ )
{ {
delete it->second; delete it->second;
} }
LeaveCriticalSection(&m_csCachedStructures);
DeleteCriticalSection(&m_csCachedStructures);
} }
void StructureFeature::addFeature(Level *level, int x, int z, int xOffs, int zOffs, byteArray blocks) void StructureFeature::addFeature(Level *level, int x, int z, int xOffs, int zOffs, byteArray blocks)
@@ -34,13 +30,10 @@ void StructureFeature::addFeature(Level *level, int x, int z, int xOffs, int zOf
restoreSavedData(level); restoreSavedData(level);
EnterCriticalSection(&m_csCachedStructures);
if (cachedStructures.find(ChunkPos::hashCode(x, z)) != cachedStructures.end()) if (cachedStructures.find(ChunkPos::hashCode(x, z)) != cachedStructures.end())
{ {
LeaveCriticalSection(&m_csCachedStructures);
return; return;
} }
LeaveCriticalSection(&m_csCachedStructures);
// clear random key // clear random key
random->nextInt(); random->nextInt();
@@ -48,10 +41,8 @@ void StructureFeature::addFeature(Level *level, int x, int z, int xOffs, int zOf
if (isFeatureChunk(x, z,level->getLevelData()->getGenerator() == LevelType::lvl_flat)) if (isFeatureChunk(x, z,level->getLevelData()->getGenerator() == LevelType::lvl_flat))
{ {
StructureStart *start = createStructureStart(x, z); StructureStart *start = createStructureStart(x, z);
EnterCriticalSection(&m_csCachedStructures);
cachedStructures[ChunkPos::hashCode(x, z)] = start; cachedStructures[ChunkPos::hashCode(x, z)] = start;
saveFeature(x, z, start); saveFeature(x, z, start);
LeaveCriticalSection(&m_csCachedStructures);
} }
} }
@@ -67,7 +58,6 @@ bool StructureFeature::postProcess(Level *level, Random *random, int chunkX, int
int cz = (chunkZ << 4); // + 8; int cz = (chunkZ << 4); // + 8;
bool intersection = false; bool intersection = false;
EnterCriticalSection(&m_csCachedStructures);
for( AUTO_VAR(it, cachedStructures.begin()); it != cachedStructures.end(); it++ ) for( AUTO_VAR(it, cachedStructures.begin()); it != cachedStructures.end(); it++ )
{ {
StructureStart *structureStart = it->second; StructureStart *structureStart = it->second;
@@ -86,7 +76,6 @@ bool StructureFeature::postProcess(Level *level, Random *random, int chunkX, int
} }
} }
} }
LeaveCriticalSection(&m_csCachedStructures);
return intersection; return intersection;
} }
@@ -95,7 +84,6 @@ bool StructureFeature::isIntersection(int cellX, int cellZ)
{ {
restoreSavedData(level); restoreSavedData(level);
EnterCriticalSection(&m_csCachedStructures);
for( AUTO_VAR(it, cachedStructures.begin()); it != cachedStructures.end(); it++ ) for( AUTO_VAR(it, cachedStructures.begin()); it != cachedStructures.end(); it++ )
{ {
StructureStart *structureStart = it->second; StructureStart *structureStart = it->second;
@@ -109,14 +97,12 @@ bool StructureFeature::isIntersection(int cellX, int cellZ)
StructurePiece *next = *it2++; StructurePiece *next = *it2++;
if (next->getBoundingBox()->intersects(cellX, cellZ, cellX, cellZ)) if (next->getBoundingBox()->intersects(cellX, cellZ, cellX, cellZ))
{ {
LeaveCriticalSection(&m_csCachedStructures);
return true; return true;
} }
} }
} }
} }
} }
LeaveCriticalSection(&m_csCachedStructures);
return false; return false;
} }
@@ -129,7 +115,6 @@ bool StructureFeature::isInsideFeature(int cellX, int cellY, int cellZ)
StructureStart *StructureFeature::getStructureAt(int cellX, int cellY, int cellZ) StructureStart *StructureFeature::getStructureAt(int cellX, int cellY, int cellZ)
{ {
//for (StructureStart structureStart : cachedStructures.values()) //for (StructureStart structureStart : cachedStructures.values())
EnterCriticalSection(&m_csCachedStructures);
for(AUTO_VAR(it, cachedStructures.begin()); it != cachedStructures.end(); ++it) for(AUTO_VAR(it, cachedStructures.begin()); it != cachedStructures.end(); ++it)
{ {
StructureStart *pStructureStart = it->second; StructureStart *pStructureStart = it->second;
@@ -153,14 +138,12 @@ StructureStart *StructureFeature::getStructureAt(int cellX, int cellY, int cellZ
StructurePiece* piece = *it2; StructurePiece* piece = *it2;
if ( piece->getBoundingBox()->isInside(cellX, cellY, cellZ) ) if ( piece->getBoundingBox()->isInside(cellX, cellY, cellZ) )
{ {
LeaveCriticalSection(&m_csCachedStructures);
return pStructureStart; return pStructureStart;
} }
} }
} }
} }
} }
LeaveCriticalSection(&m_csCachedStructures);
return NULL; return NULL;
} }
@@ -199,7 +182,6 @@ TilePos *StructureFeature::getNearestGeneratedFeature(Level *level, int cellX, i
double minDistance = DBL_MAX; double minDistance = DBL_MAX;
TilePos *selected = NULL; TilePos *selected = NULL;
EnterCriticalSection(&m_csCachedStructures);
for(AUTO_VAR(it, cachedStructures.begin()); it != cachedStructures.end(); ++it) for(AUTO_VAR(it, cachedStructures.begin()); it != cachedStructures.end(); ++it)
{ {
StructureStart *pStructureStart = it->second; StructureStart *pStructureStart = it->second;
@@ -223,7 +205,6 @@ TilePos *StructureFeature::getNearestGeneratedFeature(Level *level, int cellX, i
} }
} }
} }
LeaveCriticalSection(&m_csCachedStructures);
if (selected != NULL) if (selected != NULL)
{ {
return selected; return selected;
-1
View File
@@ -27,7 +27,6 @@ private:
protected: protected:
unordered_map<__int64, StructureStart *> cachedStructures; unordered_map<__int64, StructureStart *> cachedStructures;
CRITICAL_SECTION m_csCachedStructures;
public: public:
StructureFeature(); StructureFeature();
+1 -4
View File
@@ -343,10 +343,8 @@ vector<shared_ptr<SynchedEntityData::DataItem> > *SynchedEntityData::unpack(Data
vector<shared_ptr<DataItem> > *result = NULL; vector<shared_ptr<DataItem> > *result = NULL;
int currentHeader = input->readByte(); int currentHeader = input->readByte();
int itemCount = 0;
const int MAX_ENTITY_DATA_ITEMS = 256;
while (currentHeader != EOF_MARKER && itemCount < MAX_ENTITY_DATA_ITEMS) while (currentHeader != EOF_MARKER)
{ {
if (result == NULL) if (result == NULL)
@@ -401,7 +399,6 @@ vector<shared_ptr<SynchedEntityData::DataItem> > *SynchedEntityData::unpack(Data
break; break;
} }
result->push_back(item); result->push_back(item);
itemCount++;
currentHeader = input->readByte(); currentHeader = input->readByte();
} }
+15 -27
View File
@@ -79,44 +79,32 @@ Tag *Tag::setName(const wstring& name)
Tag *Tag::readNamedTag(DataInput *dis) Tag *Tag::readNamedTag(DataInput *dis)
{ {
static __declspec(thread) int depth = 0; return readNamedTag(dis,0);
static __declspec(thread) int totalTagCount = 0; }
if (depth == 0)
totalTagCount = 0;
depth++;
if (depth > 256)
{
depth--;
return new EndTag();
}
totalTagCount++;
const int MAX_TOTAL_TAGS = 32768;
if (totalTagCount > MAX_TOTAL_TAGS)
{
depth--;
return new EndTag();
}
Tag *Tag::readNamedTag(DataInput *dis, int tagDepth)
{
byte type = dis->readByte(); byte type = dis->readByte();
if (type == 0) { depth--; return new EndTag(); } if (type == 0) return new EndTag();
// 4J Stu - readByte can return -1, so if it's that then also mark as the end tag
if(type == 255) if(type == 255)
{ {
depth--; app.DebugPrintf("readNamedTag read a type of 255\n");
#ifndef _CONTENT_PACKAGE
__debugbreak();
#endif
return new EndTag(); return new EndTag();
} }
wstring name = dis->readUTF(); wstring name = dis->readUTF();//new String(bytes, "UTF-8");
Tag *tag = newTag(type, name); Tag *tag = newTag(type, name);
if (tag == NULL) { depth--; return new EndTag(); } // short length = dis.readShort();
// byte[] bytes = new byte[length];
// dis.readFully(bytes);
tag->load(dis); tag->load(dis, tagDepth);
depth--;
return tag; return tag;
} }
+2 -21
View File
@@ -123,17 +123,7 @@ void TextureAndGeometryPacket::read(DataInputStream *dis) //throws IOException
{ {
textureName = dis->readUTF(); textureName = dis->readUTF();
dwSkinID = (DWORD)dis->readInt(); dwSkinID = (DWORD)dis->readInt();
dwTextureBytes = (DWORD)dis->readShort();
short rawTextureBytes = dis->readShort();
if(rawTextureBytes <= 0)
{
dwTextureBytes = 0;
}
else
{
dwTextureBytes = (DWORD)(unsigned short)rawTextureBytes;
if(dwTextureBytes > 65536) dwTextureBytes = 0;
}
if(dwTextureBytes>0) if(dwTextureBytes>0)
{ {
@@ -146,16 +136,7 @@ void TextureAndGeometryPacket::read(DataInputStream *dis) //throws IOException
} }
uiAnimOverrideBitmask = dis->readInt(); uiAnimOverrideBitmask = dis->readInt();
short rawBoxC = dis->readShort(); dwBoxC = (DWORD)dis->readShort();
if(rawBoxC <= 0)
{
dwBoxC = 0;
}
else
{
dwBoxC = (DWORD)(unsigned short)rawBoxC;
if(dwBoxC > 256) dwBoxC = 0; // sane limit for skin boxes
}
if(dwBoxC>0) if(dwBoxC>0)
{ {
+2 -12
View File
@@ -37,19 +37,9 @@ void TexturePacket::handle(PacketListener *listener)
void TexturePacket::read(DataInputStream *dis) //throws IOException void TexturePacket::read(DataInputStream *dis) //throws IOException
{ {
textureName = dis->readUTF(); textureName = dis->readUTF();
short rawBytes = dis->readShort(); dwBytes = (DWORD)dis->readShort();
if(rawBytes <= 0)
{
dwBytes = 0;
return;
}
dwBytes = (DWORD)(unsigned short)rawBytes;
if(dwBytes > 65536)
{
dwBytes = 0;
return;
}
if(dwBytes>0)
{ {
this->pbData= new BYTE [dwBytes]; this->pbData= new BYTE [dwBytes];
+5 -5
View File
@@ -20,11 +20,11 @@ void SetThreadName( DWORD dwThreadID, LPCSTR szThreadName )
info.dwFlags = 0; info.dwFlags = 0;
#if ( defined _WINDOWS64 | defined _DURANGO ) #if ( defined _WINDOWS64 | defined _DURANGO )
__try __try
{ {
RaiseException( 0x406D1388, 0, sizeof(info)/sizeof(ULONG_PTR), (ULONG_PTR *)&info ); RaiseException( 0x406D1388, 0, sizeof(info)/sizeof(DWORD), (ULONG_PTR *)&info );
} }
__except( EXCEPTION_EXECUTE_HANDLER ) __except( GetExceptionCode()==0x406D1388 ? EXCEPTION_CONTINUE_EXECUTION : EXCEPTION_EXECUTE_HANDLER )
{ {
} }
#endif #endif
@@ -42,7 +42,7 @@ void UpdateGameRuleProgressPacket::read(DataInputStream *dis) //throws IOExcepti
m_dataTag = dis->readInt(); m_dataTag = dis->readInt();
int dataLength = dis->readInt(); int dataLength = dis->readInt();
if(dataLength > 0 && dataLength <= 65536) if(dataLength > 0)
{ {
m_data = byteArray(dataLength); m_data = byteArray(dataLength);
dis->readFully(m_data); dis->readFully(m_data);
+112 -135
View File
@@ -180,143 +180,120 @@ HRESULT Compression::CompressRLE(void *pDestination, unsigned int *pDestSize, vo
return S_OK; return S_OK;
} }
HRESULT Compression::DecompressLZXRLE(void *pDestination, unsigned int *pDestSize, void *pSource, unsigned int SrcSize) HRESULT Compression::DecompressLZXRLE(void *pDestination, unsigned int *pDestSize, void *pSource, unsigned int SrcSize)
{ {
EnterCriticalSection(&rleDecompressLock); EnterCriticalSection(&rleDecompressLock);
// 4J Stu - Fix for #13676 - Crash: Crash while attempting to load a world after updating TU // 4J Stu - Fix for #13676 - Crash: Crash while attempting to load a world after updating TU
// Some saves can have chunks that decompress into very large sizes, so I have doubled the size of this buffer // Some saves can have chunks that decompress into very large sizes, so I have doubled the size of this buffer
// Ideally we should be able to dynamically allocate the buffer if it's going to be too big, as most chunks // Ideally we should be able to dynamically allocate the buffer if it's going to be too big, as most chunks
// only use 5% of this buffer // only use 5% of this buffer
// 4J Stu - Changed this again to dynamically allocate a buffer if it's going to be too big // 4J Stu - Changed this again to dynamically allocate a buffer if it's going to be too big
unsigned char *pucIn = NULL; unsigned char *pucIn = NULL;
//const unsigned int staticRleSize = 1024*200; //const unsigned int staticRleSize = 1024*200;
//static unsigned char rleBuf[staticRleSize]; //static unsigned char rleBuf[staticRleSize];
unsigned int rleSize = staticRleSize; unsigned int rleSize = staticRleSize;
unsigned char *dynamicRleBuf = NULL; unsigned char *dynamicRleBuf = NULL;
if(*pDestSize > rleSize)
unsigned int safeRleSize = max(rleSize, *pDestSize); {
rleSize = *pDestSize;
const unsigned int MAX_RLE_ALLOC = 16 * 1024 * 1024; // 16 MB dynamicRleBuf = new unsigned char[rleSize];
if(safeRleSize > MAX_RLE_ALLOC) Decompress(dynamicRleBuf, &rleSize, pSource, SrcSize);
{ pucIn = (unsigned char *)dynamicRleBuf;
LeaveCriticalSection(&rleDecompressLock); }
*pDestSize = 0; else
return E_FAIL; {
} Decompress(rleDecompressBuf, &rleSize, pSource, SrcSize);
pucIn = (unsigned char *)rleDecompressBuf;
if(safeRleSize > staticRleSize) }
{
rleSize = safeRleSize; //unsigned char *pucIn = (unsigned char *)rleDecompressBuf;
dynamicRleBuf = new unsigned char[rleSize]; unsigned char *pucEnd = pucIn + rleSize;
Decompress(dynamicRleBuf, &rleSize, pSource, SrcSize); unsigned char *pucOut = (unsigned char *)pDestination;
pucIn = (unsigned char *)dynamicRleBuf;
} while( pucIn != pucEnd )
else {
{ unsigned char thisOne = *pucIn++;
Decompress(rleDecompressBuf, &rleSize, pSource, SrcSize); if( thisOne == 255 )
pucIn = (unsigned char *)rleDecompressBuf; {
} unsigned int count = *pucIn++;
if( count < 3 )
//unsigned char *pucIn = (unsigned char *)rleDecompressBuf; {
unsigned char *pucEnd = pucIn + rleSize; count++;
unsigned char *pucOut = (unsigned char *)pDestination; for( unsigned int i = 0; i < count; i++ )
unsigned char *pucOutEnd = pucOut + *pDestSize; {
*pucOut++ = 255;
while( pucIn != pucEnd ) }
{ }
unsigned char thisOne = *pucIn++; else
if( thisOne == 255 ) {
{ count++;
if( pucIn >= pucEnd ) break; unsigned char data = *pucIn++;
unsigned int count = *pucIn++; for( unsigned int i = 0; i < count; i++ )
if( count < 3 ) {
{ *pucOut++ = data;
count++; }
if( pucOut + count > pucOutEnd ) { pucOut = pucOutEnd; break; } }
for( unsigned int i = 0; i < count; i++ ) }
{ else
*pucOut++ = 255; {
} *pucOut++ = thisOne;
} }
else }
{ *pDestSize = (unsigned int)(pucOut - (unsigned char *)pDestination);
count++;
if( pucIn >= pucEnd ) break; // printf("Decompressed from %d to %d to %d\n",SrcSize,rleSize,*pDestSize);
unsigned char data = *pucIn++;
if( pucOut + count > pucOutEnd ) { pucOut = pucOutEnd; break; } if(dynamicRleBuf != NULL) delete [] dynamicRleBuf;
for( unsigned int i = 0; i < count; i++ )
{ LeaveCriticalSection(&rleDecompressLock);
*pucOut++ = data; return S_OK;
}
}
}
else
{
if( pucOut >= pucOutEnd ) break;
*pucOut++ = thisOne;
}
}
*pDestSize = (unsigned int)(pucOut - (unsigned char *)pDestination);
// printf("Decompressed from %d to %d to %d\n",SrcSize,rleSize,*pDestSize);
if(dynamicRleBuf != NULL) delete [] dynamicRleBuf;
LeaveCriticalSection(&rleDecompressLock);
return S_OK;
} }
HRESULT Compression::DecompressRLE(void *pDestination, unsigned int *pDestSize, void *pSource, unsigned int SrcSize) HRESULT Compression::DecompressRLE(void *pDestination, unsigned int *pDestSize, void *pSource, unsigned int SrcSize)
{ {
EnterCriticalSection(&rleDecompressLock); EnterCriticalSection(&rleDecompressLock);
//unsigned char *pucIn = (unsigned char *)rleDecompressBuf; //unsigned char *pucIn = (unsigned char *)rleDecompressBuf;
unsigned char *pucIn = (unsigned char *)pSource; unsigned char *pucIn = (unsigned char *)pSource;
unsigned char *pucEnd = pucIn + SrcSize; unsigned char *pucEnd = pucIn + SrcSize;
unsigned char *pucOut = (unsigned char *)pDestination; unsigned char *pucOut = (unsigned char *)pDestination;
unsigned char *pucOutEnd = pucOut + *pDestSize;
while( pucIn != pucEnd )
while( pucIn != pucEnd ) {
{ unsigned char thisOne = *pucIn++;
unsigned char thisOne = *pucIn++; if( thisOne == 255 )
if( thisOne == 255 ) {
{ unsigned int count = *pucIn++;
if( pucIn >= pucEnd ) break; if( count < 3 )
unsigned int count = *pucIn++; {
if( count < 3 ) count++;
{ for( unsigned int i = 0; i < count; i++ )
count++; {
if( pucOut + count > pucOutEnd ) { pucOut = pucOutEnd; break; } *pucOut++ = 255;
for( unsigned int i = 0; i < count; i++ ) }
{ }
*pucOut++ = 255; else
} {
} count++;
else unsigned char data = *pucIn++;
{ for( unsigned int i = 0; i < count; i++ )
count++; {
if( pucIn >= pucEnd ) break; *pucOut++ = data;
unsigned char data = *pucIn++; }
if( pucOut + count > pucOutEnd ) { pucOut = pucOutEnd; break; } }
for( unsigned int i = 0; i < count; i++ ) }
{ else
*pucOut++ = data; {
} *pucOut++ = thisOne;
} }
} }
else *pDestSize = (unsigned int)(pucOut - (unsigned char *)pDestination);
{
if( pucOut >= pucOutEnd ) break; LeaveCriticalSection(&rleDecompressLock);
*pucOut++ = thisOne; return S_OK;
}
}
*pDestSize = (unsigned int)(pucOut - (unsigned char *)pDestination);
LeaveCriticalSection(&rleDecompressLock);
return S_OK;
} }
+1 -8
View File
@@ -52,14 +52,7 @@ void System::arraycopy(arrayWithLength<int> src, unsigned int srcPos, arrayWithL
//The current value of the system timer, in nanoseconds. //The current value of the system timer, in nanoseconds.
__int64 System::nanoTime() __int64 System::nanoTime()
{ {
static LARGE_INTEGER s_frequency = { 0 }; return GetTickCount() * 1000000LL;
if (s_frequency.QuadPart == 0)
QueryPerformanceFrequency(&s_frequency);
LARGE_INTEGER counter;
QueryPerformanceCounter(&counter);
return (__int64)((double)counter.QuadPart * 1000000000.0 / (double)s_frequency.QuadPart);
} }
//Returns the current time in milliseconds. Note that while the unit of time of the return value is a millisecond, //Returns the current time in milliseconds. Note that while the unit of time of the return value is a millisecond,
+11 -38
View File
@@ -13,27 +13,15 @@
typedef unsigned char byte; typedef unsigned char byte;
#ifndef XUSER_INDEX_ANY const int XUSER_INDEX_ANY = 255;
const int XUSER_INDEX_ANY = 255; const int XUSER_INDEX_FOCUS = 254;
#endif
#ifndef XUSER_INDEX_FOCUS #ifdef __PSVITA__
const int XUSER_INDEX_FOCUS = 254; const int XUSER_MAX_COUNT = 1;
#endif const int MINECRAFT_NET_MAX_PLAYERS = 4;
#else
#ifdef __PSVITA__ const int XUSER_MAX_COUNT = 4;
#ifndef XUSER_MAX_COUNT const int MINECRAFT_NET_MAX_PLAYERS = 8;
const int XUSER_MAX_COUNT = 1;
#endif
const int MINECRAFT_NET_MAX_PLAYERS = 4;
#else
#ifndef XUSER_MAX_COUNT
const int XUSER_MAX_COUNT = 4;
#endif
#if defined(_DEDICATED_SERVER) || defined(_WINDOWS64)
const int MINECRAFT_NET_MAX_PLAYERS = 255;
#else
const int MINECRAFT_NET_MAX_PLAYERS = 8;
#endif
#endif #endif
@@ -227,19 +215,10 @@ public:
int GetUserIndex(); int GetUserIndex();
void SetCustomDataValue(ULONG_PTR ulpCustomDataValue); void SetCustomDataValue(ULONG_PTR ulpCustomDataValue);
ULONG_PTR GetCustomDataValue(); ULONG_PTR GetCustomDataValue();
BYTE m_smallId;
bool m_isRemote;
bool m_isHostPlayer;
wchar_t m_gamertag[32];
private: private:
ULONG_PTR m_customData; ULONG_PTR m_customData;
}; };
void Win64_SetupRemoteQNetPlayer(IQNetPlayer *player, BYTE smallId, bool isHost, bool isLocal);
PlayerUID Win64_UsernameToXuid(const char* username);
PlayerUID Win64_UsernameToXuid(const wchar_t* username);
const int QNET_GETSENDQUEUESIZE_SECONDARY_TYPE = 0; const int QNET_GETSENDQUEUESIZE_SECONDARY_TYPE = 0;
const int QNET_GETSENDQUEUESIZE_MESSAGES = 0; const int QNET_GETSENDQUEUESIZE_MESSAGES = 0;
const int QNET_GETSENDQUEUESIZE_BYTES = 0; const int QNET_GETSENDQUEUESIZE_BYTES = 0;
@@ -330,15 +309,9 @@ public:
bool IsHost(); bool IsHost();
HRESULT JoinGameFromInviteInfo(DWORD dwUserIndex, DWORD dwUserMask, const INVITE_INFO *pInviteInfo); HRESULT JoinGameFromInviteInfo(DWORD dwUserIndex, DWORD dwUserMask, const INVITE_INFO *pInviteInfo);
void HostGame(); void HostGame();
void ClientJoinGame();
void EndGame(); void EndGame();
static void SetPlayerCapacity(DWORD capacity);
static DWORD GetPlayerCapacity(); static IQNetPlayer m_player[4];
static IQNetPlayer *m_player;
static DWORD s_playerCapacity;
static DWORD s_playerCount;
static bool s_isHosting;
}; };
#ifdef _DURANGO #ifdef _DURANGO
-2
View File
@@ -1,2 +0,0 @@
#pragma once
#include "extraX64.h"
-2
View File
@@ -1,2 +0,0 @@
#pragma once
#include "extraX64.h"
-2
View File
@@ -1,2 +0,0 @@
#pragma once
#include "extraX64.h"
-2
View File
@@ -1,2 +0,0 @@
#pragma once
#include "extraX64.h"
-2
View File
@@ -1,2 +0,0 @@
#pragma once
#include "extraX64.h"
-2
View File
@@ -1,2 +0,0 @@
#pragma once
#include "extraX64.h"
+12 -12
View File
@@ -1,19 +1,19 @@
# mc-pie-LCE # Project Cafeberry
This project is a modified version of the December 17th 2014 Codebase, aimed at backporting the newer title updates back to the codebase, with cross-play across all platfoms (including PC). Cafeberry is a project aiming to update the December 17th 2014 codebase (mostly) via decompilation, with a focus on consoles.
[![Discord](https://img.shields.io/badge/Discord-Join%20Server-5865F2?logo=discord&logoColor=white)](https://discord.gg/aPAF5WFaW)
# Status # Status
| Platform | Development Status | Known Issues | | Platform | Development Status | Known Issues |
| :------- | :-------------------- | :------------------------------------------------------------------------ | | :------------- | :-------------------- | :------------------------------------------------------------------------ |
| PS3 | Active | All TU19 blocks display as stone blocks when placed (missing SPU code). | | PS3 | Active | SPU variants for TU19 blocks are missing, needs to be further optimized. |
| Xbox 360 | Likely cancelled | Missing XUI files for GUIs added in TU25+. See notes. | | Xbox 360 | On hold | Havent tested, should work? |
| PS4 | Active | Only Buildable on Windows 7 With 1.70 SDK. See Notes | | PS4 | Active | Only Buildable on Windows 7 With 1.70 SDK. See Notes |
| Xbox One | On hold | Needs to be re-coded to run on Developer Mode UWP instead. | | Xbox One | On hold | Needs to be re-coded to run on Developer Mode UWP instead. |
| PS Vita | On hold | Fails during compilation due to missing network library dependencies. | | PS Vita | On hold | Fails during compilation due to missing network library dependencies. |
| Wii U & Switch | Work in progress | UI System (ImXui) is still in progress, need to decompile the rest. |
**Notes:** **Notes:**
- **Xbox 360:** TU25 and newer TUs include new GUIs, but we lack the XUI files for them, solutions:
1. Recreate the GUIs from scratch using the XUI designer (insanely difficult to get accurate to actual LCE)
- **PS4:** Can't be built on Windows 10+ because the 1.70 SDK only supports Windows 7, solutions: - **PS4:** Can't be built on Windows 10+ because the 1.70 SDK only supports Windows 7, solutions:
1. Attempt to add support for 4.50 SDK (difficult or unlikely to work) 1. Attempt to add support for 4.50 SDK (difficult or unlikely to work)
2. Getting the 1.70 SDK on Windows 10+ (annoying to do) 2. Getting the 1.70 SDK on Windows 10+ (annoying to do)