mirror of
https://github.com/LCEMP/LCEMP.git
synced 2026-04-24 16:03:50 +00:00
Merge branch 'LCEMP:main' into CustomSkins
This commit is contained in:
commit
43bd0bd05e
14
.gitignore
vendored
14
.gitignore
vendored
|
|
@ -29,6 +29,17 @@ ipch/
|
|||
*.ilk
|
||||
*.exp
|
||||
|
||||
# ===========================================
|
||||
# CLion files
|
||||
# ===========================================
|
||||
.idea
|
||||
|
||||
# ===========================================
|
||||
# CMake
|
||||
# ===========================================
|
||||
cmake-build-debug
|
||||
cmake-build-release
|
||||
|
||||
# ===========================================
|
||||
# Archives & packaged binaries
|
||||
# ===========================================
|
||||
|
|
@ -44,6 +55,8 @@ Minecraft.Client/music/
|
|||
*.binka
|
||||
|
||||
# Common Media - UI (SWF), Graphics (PNG), Sound (WAV), Fonts
|
||||
Assets
|
||||
Assets/Common/Media/
|
||||
Minecraft.Client/Common/Media/
|
||||
# Game resource textures, art, audio, etc.
|
||||
Minecraft.Client/Common/res/
|
||||
|
|
@ -73,6 +86,7 @@ Minecraft.Client/Windows64/GameHDD/
|
|||
*.png
|
||||
# But allow source code PNG references to be noted
|
||||
!Minecraft.Client/Common/Media/Graphics/.gitkeep
|
||||
!Assets/Common/Media/Graphics/.gitkeep
|
||||
|
||||
# SWF UI files (Flash-based UI assets)
|
||||
*.swf
|
||||
|
|
|
|||
71
CMakeLists.txt
Normal file
71
CMakeLists.txt
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
cmake_minimum_required(VERSION 3.10)
|
||||
project("LCEMP")
|
||||
|
||||
set(LCEMP_WORKING_DIR "${CMAKE_CURRENT_SOURCE_DIR}/Assets" CACHE STRING "The working directory for MinecraftClient")
|
||||
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
|
||||
if(NOT WIN32)
|
||||
message(FATAL_ERROR "Windows is currently the only supported OS")
|
||||
endif()
|
||||
|
||||
# Fix linking errors with other libs compiled with an older CRT
|
||||
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
|
||||
|
||||
include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/Sources.cmake")
|
||||
|
||||
list(TRANSFORM MINECRAFT_WORLD_SOURCES PREPEND "${CMAKE_CURRENT_SOURCE_DIR}/Minecraft.World/")
|
||||
list(TRANSFORM MINECRAFT_CLIENT_SOURCES PREPEND "${CMAKE_CURRENT_SOURCE_DIR}/Minecraft.Client/")
|
||||
|
||||
add_library(MinecraftWorld STATIC ${MINECRAFT_WORLD_SOURCES})
|
||||
add_executable(MinecraftClient WIN32 ${MINECRAFT_CLIENT_SOURCES})
|
||||
|
||||
set_property(TARGET MinecraftClient PROPERTY VS_DEBUGGER_WORKING_DIRECTORY "${LCEMP_WORKING_DIR}")
|
||||
|
||||
if(MSVC)
|
||||
# /MT and /MTd options set the CRT version to multi-threaded static mode
|
||||
# which is what the 4J libs were compiled with
|
||||
target_compile_options(MinecraftWorld PRIVATE /W3 /MP $<$<CONFIG:Debug>:/MTd> $<$<NOT:$<CONFIG:Debug>>:/MT> /EHsc)
|
||||
target_compile_options(MinecraftClient PRIVATE /W3 /MP $<$<CONFIG:Debug>:/MTd> $<$<NOT:$<CONFIG:Debug>>:/MT> /EHsc)
|
||||
endif()
|
||||
|
||||
target_compile_definitions(MinecraftWorld PRIVATE
|
||||
$<$<CONFIG:Debug>:_LARGE_WORLDS;_DEBUG_MENUS_ENABLED;_DEBUG;_LIB;_CRT_NON_CONFORMING_SWPRINTFS;_CRT_SECURE_NO_WARNINGS;_WINDOWS64>
|
||||
$<$<NOT:$<CONFIG:Debug>>:_LARGE_WORLDS;_DEBUG_MENUS_ENABLED;_LIB;_CRT_NON_CONFORMING_SWPRINTFS;_CRT_SECURE_NO_WARNINGS;_WINDOWS64>
|
||||
)
|
||||
|
||||
target_compile_definitions(MinecraftClient PRIVATE
|
||||
$<$<CONFIG:Debug>:_LARGE_WORLDS;_DEBUG_MENUS_ENABLED;_DEBUG;_CRT_NON_CONFORMING_SWPRINTFS;_CRT_SECURE_NO_WARNINGS;_WINDOWS64>
|
||||
$<$<NOT:$<CONFIG:Debug>>:_LARGE_WORLDS;_DEBUG_MENUS_ENABLED;_CRT_NON_CONFORMING_SWPRINTFS;_CRT_SECURE_NO_WARNINGS;_WINDOWS64>
|
||||
)
|
||||
|
||||
target_include_directories(MinecraftWorld PUBLIC
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/Minecraft.World"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/Minecraft.World/x64headers"
|
||||
)
|
||||
|
||||
target_include_directories(MinecraftClient PRIVATE
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/Minecraft.Client"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/Minecraft.Client/Windows64/Iggy/include"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/Minecraft.Client/Xbox/Sentient/Include"
|
||||
)
|
||||
|
||||
target_link_libraries(MinecraftClient PRIVATE
|
||||
MinecraftWorld
|
||||
d3d11
|
||||
XInput9_1_0
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/Minecraft.Client/Windows64/Iggy/lib/iggy_w64.lib"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/Minecraft.Client/Windows64/Miles/lib/mss64.lib"
|
||||
$<$<CONFIG:Debug>:
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/Minecraft.Client/Windows64/4JLibs/libs/4J_Input_d.lib"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/Minecraft.Client/Windows64/4JLibs/libs/4J_Storage_d.lib"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/Minecraft.Client/Windows64/4JLibs/libs/4J_Profile_d.lib"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/Minecraft.Client/Windows64/4JLibs/libs/4J_Render_PC_d.lib"
|
||||
>
|
||||
$<$<NOT:$<CONFIG:Debug>>:
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/Minecraft.Client/Windows64/4JLibs/libs/4J_Input_r.lib"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/Minecraft.Client/Windows64/4JLibs/libs/4J_Storage_r.lib"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/Minecraft.Client/Windows64/4JLibs/libs/4J_Profile_r.lib"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/Minecraft.Client/Windows64/4JLibs/libs/4J_Render_PC.lib"
|
||||
>
|
||||
)
|
||||
|
|
@ -52,6 +52,11 @@
|
|||
#endif
|
||||
#include "DLCTexturePack.h"
|
||||
|
||||
#ifdef _WINDOWS64
|
||||
#include "Xbox\Network\NetworkPlayerXbox.h"
|
||||
#include "Common\Network\PlatformNetworkManagerStub.h"
|
||||
#endif
|
||||
|
||||
#ifdef _DURANGO
|
||||
#include "..\Minecraft.World\DurangoStats.h"
|
||||
#include "..\Minecraft.World\GenericStats.h"
|
||||
|
|
@ -758,6 +763,27 @@ void ClientConnection::handleAddPlayer(shared_ptr<AddPlayerPacket> packet)
|
|||
player->displayName = player->name;
|
||||
#endif
|
||||
|
||||
#ifdef _WINDOWS64
|
||||
{
|
||||
PlayerUID pktXuid = player->getXuid();
|
||||
const PlayerUID WIN64_XUID_BASE = (PlayerUID)0xe000d45248242f2e;
|
||||
if (pktXuid >= WIN64_XUID_BASE && pktXuid < WIN64_XUID_BASE + MINECRAFT_NET_MAX_PLAYERS)
|
||||
{
|
||||
BYTE smallId = (BYTE)(pktXuid - WIN64_XUID_BASE);
|
||||
INetworkPlayer *np = g_NetworkManager.GetPlayerBySmallId(smallId);
|
||||
if (np != NULL)
|
||||
{
|
||||
NetworkPlayerXbox *npx = (NetworkPlayerXbox *)np;
|
||||
IQNetPlayer *qp = npx->GetQNetPlayer();
|
||||
if (qp != NULL && qp->m_gamertag[0] == 0)
|
||||
{
|
||||
wcsncpy_s(qp->m_gamertag, 32, packet->name.c_str(), _TRUNCATE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// printf("\t\t\t\t%d: Add player\n",packet->id,packet->yRot);
|
||||
|
||||
int item = packet->carriedItem;
|
||||
|
|
@ -893,6 +919,39 @@ void ClientConnection::handleMoveEntitySmall(shared_ptr<MoveEntityPacketSmall> p
|
|||
|
||||
void ClientConnection::handleRemoveEntity(shared_ptr<RemoveEntitiesPacket> packet)
|
||||
{
|
||||
#ifdef _WINDOWS64
|
||||
if (!g_NetworkManager.IsHost())
|
||||
{
|
||||
for (int i = 0; i < packet->ids.length; i++)
|
||||
{
|
||||
shared_ptr<Entity> entity = getEntity(packet->ids[i]);
|
||||
if (entity != NULL && entity->GetType() == eTYPE_PLAYER)
|
||||
{
|
||||
shared_ptr<Player> player = dynamic_pointer_cast<Player>(entity);
|
||||
if (player != NULL)
|
||||
{
|
||||
PlayerUID xuid = player->getXuid();
|
||||
INetworkPlayer *np = g_NetworkManager.GetPlayerByXuid(xuid);
|
||||
if (np != NULL)
|
||||
{
|
||||
NetworkPlayerXbox *npx = (NetworkPlayerXbox *)np;
|
||||
IQNetPlayer *qp = npx->GetQNetPlayer();
|
||||
if (qp != NULL)
|
||||
{
|
||||
extern CPlatformNetworkManagerStub *g_pPlatformNetworkManager;
|
||||
g_pPlatformNetworkManager->NotifyPlayerLeaving(qp);
|
||||
qp->m_smallId = 0;
|
||||
qp->m_isRemote = false;
|
||||
qp->m_isHostPlayer = false;
|
||||
qp->m_gamertag[0] = 0;
|
||||
qp->SetCustomDataValue(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
for (int i = 0; i < packet->ids.length; i++)
|
||||
{
|
||||
level->removeEntity(packet->ids[i]);
|
||||
|
|
|
|||
|
|
@ -240,6 +240,28 @@ void CPlatformNetworkManagerStub::DoWork()
|
|||
IQNet::s_playerCount--;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 1; i < MINECRAFT_NET_MAX_PLAYERS; i++)
|
||||
{
|
||||
IQNetPlayer *qp = &IQNet::m_player[i];
|
||||
if (qp->GetCustomDataValue() == 0)
|
||||
continue;
|
||||
INetworkPlayer *np = (INetworkPlayer *)qp->GetCustomDataValue();
|
||||
Socket *sock = np->GetSocket();
|
||||
if (sock != NULL && sock->isClosing())
|
||||
{
|
||||
WinsockNetLayer::CloseConnectionBySmallId((BYTE)i);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (_iQNetStubState == QNET_STATE_GAME_PLAY && !m_pIQNet->IsHost())
|
||||
{
|
||||
if (!WinsockNetLayer::IsConnected() && !g_NetworkManager.IsLeavingGame())
|
||||
{
|
||||
if (app.GetDisconnectReason() == DisconnectPacket::eDisconnect_None)
|
||||
app.SetDisconnectReason(DisconnectPacket::eDisconnect_Quitting);
|
||||
app.SetAction(ProfileManager.GetPrimaryPad(), eAppAction_ExitWorld, (void *)TRUE);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
@ -811,7 +833,21 @@ INetworkPlayer * CPlatformNetworkManagerStub::GetPlayerByXuid(PlayerUID xuid)
|
|||
|
||||
INetworkPlayer * CPlatformNetworkManagerStub::GetPlayerBySmallId(unsigned char smallId)
|
||||
{
|
||||
return getNetworkPlayer(m_pIQNet->GetPlayerBySmallId(smallId));
|
||||
IQNetPlayer *qnetPlayer = m_pIQNet->GetPlayerBySmallId(smallId);
|
||||
if (qnetPlayer == NULL)
|
||||
return NULL;
|
||||
|
||||
INetworkPlayer *networkPlayer = getNetworkPlayer(qnetPlayer);
|
||||
#ifdef _WINDOWS64
|
||||
if (networkPlayer == NULL && smallId != 0 && !m_pIQNet->IsHost())
|
||||
{
|
||||
qnetPlayer->m_isRemote = true;
|
||||
qnetPlayer->m_isHostPlayer = false;
|
||||
NotifyPlayerJoined(qnetPlayer);
|
||||
networkPlayer = getNetworkPlayer(qnetPlayer);
|
||||
}
|
||||
#endif
|
||||
return networkPlayer;
|
||||
}
|
||||
|
||||
INetworkPlayer *CPlatformNetworkManagerStub::GetHostPlayer()
|
||||
|
|
|
|||
|
|
@ -8,6 +8,20 @@
|
|||
#include "ChoiceTask.h"
|
||||
#include "..\..\..\Minecraft.World\Material.h"
|
||||
|
||||
#ifdef _WINDOWS64
|
||||
#include "..\..\KeyboardMouseInput.h"
|
||||
|
||||
static int ActionToVK(int action)
|
||||
{
|
||||
switch (action)
|
||||
{
|
||||
case ACTION_MENU_A: return KeyboardMouseInput::KEY_CONFIRM;
|
||||
case ACTION_MENU_B: return KeyboardMouseInput::KEY_CANCEL;
|
||||
default: return 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
ChoiceTask::ChoiceTask(Tutorial *tutorial, int descriptionId, int promptId /*= -1*/, bool requiresUserInput /*= false*/,
|
||||
int iConfirmMapping /*= 0*/, int iCancelMapping /*= 0*/,
|
||||
eTutorial_CompletionAction cancelAction /*= e_Tutorial_Completion_None*/, ETelemetryChallenges telemetryEvent /*= eTelemetryTutorial_NoEvent*/)
|
||||
|
|
@ -51,11 +65,24 @@ bool ChoiceTask::isCompleted()
|
|||
// If the player is under water then allow all keypresses so they can jump out
|
||||
if( pMinecraft->localplayers[tutorial->getPad()]->isUnderLiquid(Material::water) ) return false;
|
||||
|
||||
if(!m_bConfirmMappingComplete && InputManager.GetValue(pMinecraft->player->GetXboxPad(), m_iConfirmMapping) > 0 )
|
||||
int xboxPad = pMinecraft->player->GetXboxPad();
|
||||
#ifdef _WINDOWS64
|
||||
if(!m_bConfirmMappingComplete &&
|
||||
(InputManager.GetValue(xboxPad, m_iConfirmMapping) > 0
|
||||
|| g_KBMInput.IsKeyDown(ActionToVK(m_iConfirmMapping))))
|
||||
#else
|
||||
if(!m_bConfirmMappingComplete && InputManager.GetValue(xboxPad, m_iConfirmMapping) > 0 )
|
||||
#endif
|
||||
{
|
||||
m_bConfirmMappingComplete = true;
|
||||
}
|
||||
if(!m_bCancelMappingComplete && InputManager.GetValue(pMinecraft->player->GetXboxPad(), m_iCancelMapping) > 0 )
|
||||
#ifdef _WINDOWS64
|
||||
if(!m_bCancelMappingComplete &&
|
||||
(InputManager.GetValue(xboxPad, m_iCancelMapping) > 0
|
||||
|| g_KBMInput.IsKeyDown(ActionToVK(m_iCancelMapping))))
|
||||
#else
|
||||
if(!m_bCancelMappingComplete && InputManager.GetValue(xboxPad, m_iCancelMapping) > 0 )
|
||||
#endif
|
||||
{
|
||||
m_bCancelMappingComplete = true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,10 @@
|
|||
#include "TutorialConstraints.h"
|
||||
#include "ControllerTask.h"
|
||||
|
||||
#ifdef _WINDOWS64
|
||||
#include "..\..\KeyboardMouseInput.h"
|
||||
#endif
|
||||
|
||||
ControllerTask::ControllerTask(Tutorial *tutorial, int descriptionId, bool enablePreCompletion, bool showMinimumTime,
|
||||
int mappings[], unsigned int mappingsLength, int iCompletionMaskA[], int iCompletionMaskACount, int iSouthpawMappings[], unsigned int uiSouthpawMappingsCount)
|
||||
: TutorialTask( tutorial, descriptionId, enablePreCompletion, NULL, showMinimumTime )
|
||||
|
|
@ -66,7 +70,11 @@ bool ControllerTask::isCompleted()
|
|||
}
|
||||
else
|
||||
{
|
||||
#ifdef _WINDOWS64
|
||||
bAllComplete = true;
|
||||
#else
|
||||
bAllComplete = false;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
iCurrent++;
|
||||
|
|
@ -87,7 +95,11 @@ bool ControllerTask::isCompleted()
|
|||
}
|
||||
else
|
||||
{
|
||||
#ifdef _WINDOWS64
|
||||
bAllComplete = true;
|
||||
#else
|
||||
bAllComplete = false;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
iCurrent++;
|
||||
|
|
|
|||
|
|
@ -8,6 +8,20 @@
|
|||
#include "InfoTask.h"
|
||||
#include "..\..\..\Minecraft.World\Material.h"
|
||||
|
||||
#ifdef _WINDOWS64
|
||||
#include "..\..\KeyboardMouseInput.h"
|
||||
|
||||
static int ActionToVK(int action)
|
||||
{
|
||||
switch (action)
|
||||
{
|
||||
case ACTION_MENU_A: return KeyboardMouseInput::KEY_CONFIRM;
|
||||
case ACTION_MENU_B: return KeyboardMouseInput::KEY_CANCEL;
|
||||
default: return 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
InfoTask::InfoTask(Tutorial *tutorial, int descriptionId, int promptId /*= -1*/, bool requiresUserInput /*= false*/,
|
||||
int iMapping /*= 0*/, ETelemetryChallenges telemetryEvent /*= eTelemetryTutorial_NoEvent*/)
|
||||
: TutorialTask( tutorial, descriptionId, false, NULL, true, false, false )
|
||||
|
|
@ -65,12 +79,16 @@ bool InfoTask::isCompleted()
|
|||
bool current = (*it).second;
|
||||
if(!current)
|
||||
{
|
||||
#ifdef _WINDOWS64
|
||||
if( InputManager.GetValue(pMinecraft->player->GetXboxPad(), (*it).first) > 0 || g_KBMInput.IsKeyDown(ActionToVK((*it).first)) )
|
||||
#else
|
||||
if( InputManager.GetValue(pMinecraft->player->GetXboxPad(), (*it).first) > 0 )
|
||||
#endif
|
||||
{
|
||||
(*it).second = true;
|
||||
bAllComplete=true;
|
||||
}
|
||||
else
|
||||
if (!(*it).second)
|
||||
{
|
||||
bAllComplete = false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -471,7 +471,7 @@ void IUIScene_AbstractContainerMenu::onMouseTick()
|
|||
#endif
|
||||
|
||||
#ifdef _WINDOWS64
|
||||
if (!g_KBMInput.IsMouseGrabbed())
|
||||
if (!g_KBMInput.IsMouseGrabbed() && g_KBMInput.IsKBMActive())
|
||||
{
|
||||
int deltaX = g_KBMInput.GetMouseDeltaX();
|
||||
int deltaY = g_KBMInput.GetMouseDeltaY();
|
||||
|
|
@ -716,7 +716,7 @@ void IUIScene_AbstractContainerMenu::onMouseTick()
|
|||
// If there is no stick input, and we are over a slot, then snap pointer to slot centre.
|
||||
// 4J - TomK - only if this particular component allows so!
|
||||
#ifdef _WINDOWS64
|
||||
if(g_KBMInput.IsMouseGrabbed() && CanHaveFocus(eSectionUnderPointer))
|
||||
if((g_KBMInput.IsMouseGrabbed() || !g_KBMInput.IsKBMActive()) && CanHaveFocus(eSectionUnderPointer))
|
||||
#else
|
||||
if(CanHaveFocus(eSectionUnderPointer))
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -691,7 +691,7 @@ void UIController::tickInput()
|
|||
#endif
|
||||
{
|
||||
#ifdef _WINDOWS64
|
||||
if (!g_KBMInput.IsMouseGrabbed())
|
||||
if (!g_KBMInput.IsMouseGrabbed() && g_KBMInput.IsKBMActive())
|
||||
{
|
||||
UIScene *pScene = NULL;
|
||||
for (int grp = 0; grp < eUIGroup_COUNT && !pScene; ++grp)
|
||||
|
|
@ -729,20 +729,23 @@ void UIController::tickInput()
|
|||
S32 numFocusables = 0;
|
||||
IggyPlayerGetFocusableObjects(movie, ¤tFocus, focusables, 64, &numFocusables);
|
||||
|
||||
IggyFocusHandle hitObject = IGGY_FOCUS_NULL;
|
||||
for (S32 i = 0; i < numFocusables; ++i)
|
||||
if (numFocusables > 0 && numFocusables <= 64)
|
||||
{
|
||||
if (mouseX >= focusables[i].x0 && mouseX <= focusables[i].x1 &&
|
||||
mouseY >= focusables[i].y0 && mouseY <= focusables[i].y1)
|
||||
IggyFocusHandle hitObject = IGGY_FOCUS_NULL;
|
||||
for (S32 i = 0; i < numFocusables; ++i)
|
||||
{
|
||||
hitObject = focusables[i].object;
|
||||
break;
|
||||
if (mouseX >= focusables[i].x0 && mouseX <= focusables[i].x1 &&
|
||||
mouseY >= focusables[i].y0 && mouseY <= focusables[i].y1)
|
||||
{
|
||||
hitObject = focusables[i].object;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (hitObject != IGGY_FOCUS_NULL && hitObject != currentFocus)
|
||||
{
|
||||
IggyPlayerSetFocusRS(movie, hitObject, 0);
|
||||
if (hitObject != IGGY_FOCUS_NULL && hitObject != currentFocus)
|
||||
{
|
||||
IggyPlayerSetFocusRS(movie, hitObject, 0);
|
||||
}
|
||||
}
|
||||
|
||||
if (g_KBMInput.IsMouseButtonDown(0) || g_KBMInput.IsMouseButtonPressed(0))
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@ void UIScene_AbstractContainerMenu::handleDestroy()
|
|||
g_savedInventoryCursorPos.y = m_pointerPos.y;
|
||||
g_savedInventoryCursorPos.hasSavedPos = true;
|
||||
|
||||
g_KBMInput.SetScreenCursorHidden(false);
|
||||
g_KBMInput.SetCursorHiddenForUI(false);
|
||||
#endif
|
||||
|
||||
|
|
@ -82,6 +83,7 @@ void UIScene_AbstractContainerMenu::InitDataAssociations(int iPad, AbstractConta
|
|||
void UIScene_AbstractContainerMenu::PlatformInitialize(int iPad, int startIndex)
|
||||
{
|
||||
#ifdef _WINDOWS64
|
||||
g_KBMInput.SetScreenCursorHidden(true);
|
||||
g_KBMInput.SetCursorHiddenForUI(true);
|
||||
#endif
|
||||
|
||||
|
|
@ -123,8 +125,8 @@ void UIScene_AbstractContainerMenu::PlatformInitialize(int iPad, int startIndex)
|
|||
#ifdef __ORBIS__
|
||||
// we need to map the touchpad rectangle to the UI rectangle. While it works great for the creative menu, it is much too sensitive for the smaller menus.
|
||||
//X coordinate of the touch point (0 to 1919)
|
||||
//Y coordinate of the touch point (0 to 941: DUALSHOCK<EFBFBD>4 wireless controllers and the CUH-ZCT1J/CAP-ZCT1J/CAP-ZCT1U controllers for the PlayStation<6F>4 development tool,
|
||||
//0 to 753: JDX-1000x series controllers for the PlayStation<EFBFBD>4 development tool,)
|
||||
//Y coordinate of the touch point (0 to 941: DUALSHOCK®4 wireless controllers and the CUH-ZCT1J/CAP-ZCT1J/CAP-ZCT1U controllers for the PlayStation®4 development tool,
|
||||
//0 to 753: JDX-1000x series controllers for the PlayStation®4 development tool,)
|
||||
m_fTouchPadMulX=fPanelWidth/1919.0f;
|
||||
m_fTouchPadMulY=fPanelHeight/941.0f;
|
||||
m_fTouchPadDeadZoneX=15.0f*m_fTouchPadMulX;
|
||||
|
|
|
|||
|
|
@ -168,7 +168,7 @@ void PIXSetMarkerDeprecated(int a, char *b, ...) {}
|
|||
|
||||
bool IsEqualXUID(PlayerUID a, PlayerUID b)
|
||||
{
|
||||
#if defined(__PS3__) || defined(__ORBIS__) || defined (__PSVITA__) || defined(_DURANGO)
|
||||
#if defined(__PS3__) || defined(__ORBIS__) || defined (__PSVITA__) || defined(_DURANGO) || defined(_WINDOWS64)
|
||||
return (a == b);
|
||||
#else
|
||||
return false;
|
||||
|
|
@ -232,13 +232,17 @@ void Win64_SetupRemoteQNetPlayer(IQNetPlayer *player, BYTE smallId, bool isHost,
|
|||
IQNet::s_playerCount = smallId + 1;
|
||||
}
|
||||
|
||||
static bool Win64_IsActivePlayer(IQNetPlayer *p, DWORD index);
|
||||
|
||||
HRESULT IQNet::AddLocalPlayerByUserIndex(DWORD dwUserIndex){ return S_OK; }
|
||||
IQNetPlayer *IQNet::GetHostPlayer() { return &m_player[0]; }
|
||||
IQNetPlayer *IQNet::GetLocalPlayerByUserIndex(DWORD dwUserIndex)
|
||||
{
|
||||
if (s_isHosting)
|
||||
{
|
||||
if (dwUserIndex < MINECRAFT_NET_MAX_PLAYERS && !m_player[dwUserIndex].m_isRemote)
|
||||
if (dwUserIndex < MINECRAFT_NET_MAX_PLAYERS &&
|
||||
!m_player[dwUserIndex].m_isRemote &&
|
||||
Win64_IsActivePlayer(&m_player[dwUserIndex], dwUserIndex))
|
||||
return &m_player[dwUserIndex];
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -246,7 +250,7 @@ IQNetPlayer *IQNet::GetLocalPlayerByUserIndex(DWORD dwUserIndex)
|
|||
return NULL;
|
||||
for (DWORD i = 0; i < s_playerCount; i++)
|
||||
{
|
||||
if (!m_player[i].m_isRemote)
|
||||
if (!m_player[i].m_isRemote && Win64_IsActivePlayer(&m_player[i], i))
|
||||
return &m_player[i];
|
||||
}
|
||||
return NULL;
|
||||
|
|
@ -272,19 +276,21 @@ IQNetPlayer *IQNet::GetPlayerByIndex(DWORD dwPlayerIndex)
|
|||
}
|
||||
IQNetPlayer *IQNet::GetPlayerBySmallId(BYTE SmallId)
|
||||
{
|
||||
for (DWORD i = 0; i < s_playerCount; i++)
|
||||
{
|
||||
if (m_player[i].m_smallId == SmallId && Win64_IsActivePlayer(&m_player[i], i)) return &m_player[i];
|
||||
}
|
||||
return NULL;
|
||||
if (SmallId >= MINECRAFT_NET_MAX_PLAYERS)
|
||||
return NULL;
|
||||
|
||||
m_player[SmallId].m_smallId = SmallId;
|
||||
if (SmallId >= s_playerCount)
|
||||
s_playerCount = SmallId + 1;
|
||||
return &m_player[SmallId];
|
||||
}
|
||||
IQNetPlayer *IQNet::GetPlayerByXuid(PlayerUID xuid)
|
||||
{
|
||||
for (DWORD i = 0; i < s_playerCount; i++)
|
||||
for (DWORD i = 0; i < MINECRAFT_NET_MAX_PLAYERS; i++)
|
||||
{
|
||||
if (Win64_IsActivePlayer(&m_player[i], i) && m_player[i].GetXuid() == xuid) return &m_player[i];
|
||||
}
|
||||
return &m_player[0];
|
||||
return NULL;
|
||||
}
|
||||
DWORD IQNet::GetPlayerCount()
|
||||
{
|
||||
|
|
@ -299,15 +305,28 @@ QNET_STATE IQNet::GetState() { return _iQNetStubState; }
|
|||
bool IQNet::IsHost() { return s_isHosting; }
|
||||
HRESULT IQNet::JoinGameFromInviteInfo(DWORD dwUserIndex, DWORD dwUserMask, const INVITE_INFO *pInviteInfo) { return S_OK; }
|
||||
void IQNet::HostGame() { _iQNetStubState = QNET_STATE_SESSION_STARTING; s_isHosting = true; }
|
||||
void IQNet::ClientJoinGame() { _iQNetStubState = QNET_STATE_SESSION_STARTING; s_isHosting = false; }
|
||||
void IQNet::ClientJoinGame()
|
||||
{
|
||||
_iQNetStubState = QNET_STATE_SESSION_STARTING;
|
||||
s_isHosting = false;
|
||||
|
||||
for (int i = 0; i < MINECRAFT_NET_MAX_PLAYERS; i++)
|
||||
{
|
||||
m_player[i].m_smallId = (BYTE)i;
|
||||
m_player[i].m_isRemote = true;
|
||||
m_player[i].m_isHostPlayer = false;
|
||||
m_player[i].m_gamertag[0] = 0;
|
||||
m_player[i].SetCustomDataValue(0);
|
||||
}
|
||||
}
|
||||
void IQNet::EndGame()
|
||||
{
|
||||
_iQNetStubState = QNET_STATE_IDLE;
|
||||
s_isHosting = false;
|
||||
s_playerCount = 1;
|
||||
for (int i = 1; i < MINECRAFT_NET_MAX_PLAYERS; i++)
|
||||
for (int i = 0; i < MINECRAFT_NET_MAX_PLAYERS; i++)
|
||||
{
|
||||
m_player[i].m_smallId = 0;
|
||||
m_player[i].m_smallId = (BYTE)i;
|
||||
m_player[i].m_isRemote = false;
|
||||
m_player[i].m_isHostPlayer = false;
|
||||
m_player[i].m_gamertag[0] = 0;
|
||||
|
|
|
|||
|
|
@ -552,6 +552,10 @@ void GameRenderer::moveCameraToPlayer(float a)
|
|||
double zd = Mth::cos(yRot / 180 * PI) * Mth::cos(xRot / 180 * PI) * cameraDist;
|
||||
double yd = -Mth::sin(xRot / 180 * PI) * cameraDist;
|
||||
|
||||
// Invert Y offset if in third-person front view (camera faces player)
|
||||
if (localplayer->ThirdPersonView() == 2)
|
||||
yd = Mth::sin(xRot / 180 * PI) * cameraDist;
|
||||
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
float xo = (float)((i & 1) * 2 - 1);
|
||||
|
|
@ -588,7 +592,18 @@ void GameRenderer::moveCameraToPlayer(float a)
|
|||
|
||||
if (!mc->options->fixedCamera)
|
||||
{
|
||||
glRotatef(player->xRotO + (player->xRot - player->xRotO) * a, 1, 0, 0);
|
||||
//glRotatef(player->xRotO + (player->xRot - player->xRotO) * a, 1, 0, 0);
|
||||
|
||||
float pitch = player->xRotO + (player->xRot - player->xRotO) * a;
|
||||
|
||||
// Invert pitch if in third-person front view (camera faces player)
|
||||
if(localplayer->ThirdPersonView() == 2)
|
||||
{
|
||||
pitch = -pitch;
|
||||
}
|
||||
|
||||
glRotatef(pitch, 1, 0, 0);
|
||||
|
||||
if( localplayer->ThirdPersonView() == 2 )
|
||||
{
|
||||
// Third person view is now 0 for disabled, 1 for original, 2 for flipped
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ void Input::tick(LocalPlayer *player)
|
|||
float kbXA = 0.0f;
|
||||
float kbYA = 0.0f;
|
||||
#ifdef _WINDOWS64
|
||||
if (iPad == 0 && g_KBMInput.IsMouseGrabbed())
|
||||
if (iPad == 0 && g_KBMInput.IsMouseGrabbed() && g_KBMInput.IsKBMActive())
|
||||
{
|
||||
if( pMinecraft->localgameModes[iPad]->isInputAllowed(MINECRAFT_ACTION_LEFT) || pMinecraft->localgameModes[iPad]->isInputAllowed(MINECRAFT_ACTION_RIGHT) )
|
||||
kbXA = g_KBMInput.GetMoveX();
|
||||
|
|
@ -94,7 +94,7 @@ void Input::tick(LocalPlayer *player)
|
|||
}
|
||||
|
||||
#ifdef _WINDOWS64
|
||||
if (iPad == 0 && g_KBMInput.IsMouseGrabbed())
|
||||
if (iPad == 0 && g_KBMInput.IsMouseGrabbed() && g_KBMInput.IsKBMActive())
|
||||
{
|
||||
// Left Shift = sneak (hold to crouch)
|
||||
if (pMinecraft->localgameModes[iPad]->isInputAllowed(MINECRAFT_ACTION_SNEAK_TOGGLE))
|
||||
|
|
@ -166,7 +166,7 @@ void Input::tick(LocalPlayer *player)
|
|||
float turnY = ty * abs(ty) * turnSpeed;
|
||||
|
||||
#ifdef _WINDOWS64
|
||||
if (iPad == 0 && g_KBMInput.IsMouseGrabbed())
|
||||
if (iPad == 0 && g_KBMInput.IsMouseGrabbed() && g_KBMInput.IsKBMActive())
|
||||
{
|
||||
float mouseSensitivity = ((float)app.GetGameSettings(iPad,eGameSetting_Sensitivity_InGame)) / 100.0f;
|
||||
float mouseLookScale = 5.0f;
|
||||
|
|
@ -190,7 +190,7 @@ void Input::tick(LocalPlayer *player)
|
|||
unsigned int jump = InputManager.GetValue(iPad, MINECRAFT_ACTION_JUMP);
|
||||
bool kbJump = false;
|
||||
#ifdef _WINDOWS64
|
||||
kbJump = (iPad == 0) && g_KBMInput.IsMouseGrabbed() && g_KBMInput.IsKeyDown(KeyboardMouseInput::KEY_JUMP);
|
||||
kbJump = (iPad == 0) && g_KBMInput.IsMouseGrabbed() && g_KBMInput.IsKBMActive() && g_KBMInput.IsKeyDown(KeyboardMouseInput::KEY_JUMP);
|
||||
#endif
|
||||
if( (jump > 0 || kbJump) && pMinecraft->localgameModes[iPad]->isInputAllowed(MINECRAFT_ACTION_JUMP) )
|
||||
jumping = true;
|
||||
|
|
|
|||
|
|
@ -36,6 +36,8 @@ void KeyboardMouseInput::Init()
|
|||
m_cursorHiddenForUI = false;
|
||||
m_windowFocused = true;
|
||||
m_hasInput = false;
|
||||
m_kbmActive = true;
|
||||
m_screenWantsCursorHidden = false;
|
||||
|
||||
RAWINPUTDEVICE rid;
|
||||
rid.usUsagePage = 0x01; // HID_USAGE_PAGE_GENERIC
|
||||
|
|
|
|||
|
|
@ -23,6 +23,8 @@ public:
|
|||
static const int KEY_DROP = 'Q';
|
||||
static const int KEY_CRAFTING = VK_TAB;
|
||||
static const int KEY_CRAFTING_ALT = 'R';
|
||||
static const int KEY_CONFIRM = VK_RETURN;
|
||||
static const int KEY_CANCEL = VK_ESCAPE;
|
||||
static const int KEY_PAUSE = VK_ESCAPE;
|
||||
static const int KEY_THIRD_PERSON = VK_F5;
|
||||
static const int KEY_DEBUG_INFO = VK_F3;
|
||||
|
|
@ -66,6 +68,12 @@ public:
|
|||
|
||||
bool HasAnyInput() const { return m_hasInput; }
|
||||
|
||||
void SetKBMActive(bool active) { m_kbmActive = active; }
|
||||
bool IsKBMActive() const { return m_kbmActive; }
|
||||
|
||||
void SetScreenCursorHidden(bool hidden) { m_screenWantsCursorHidden = hidden; }
|
||||
bool IsScreenCursorHidden() const { return m_screenWantsCursorHidden; }
|
||||
|
||||
float GetMoveX() const;
|
||||
float GetMoveY() const;
|
||||
|
||||
|
|
@ -107,6 +115,10 @@ private:
|
|||
bool m_windowFocused;
|
||||
|
||||
bool m_hasInput;
|
||||
|
||||
bool m_kbmActive;
|
||||
|
||||
bool m_screenWantsCursorHidden;
|
||||
};
|
||||
|
||||
extern KeyboardMouseInput g_KBMInput;
|
||||
|
|
|
|||
|
|
@ -1293,7 +1293,7 @@ if not exist "$(TargetDir)\savedata" mkdir "$(TargetDir)\savedata"</Command>
|
|||
<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</AdditionalDependencies>
|
||||
<AdditionalDependencies>d3d11.lib;d3dcompiler.lib;..\Minecraft.World\x64_Debug\Minecraft.World.lib;%(AdditionalDependencies);XInput9_1_0.lib;..\Minecraft.Client\Windows64\Miles\Lib\mss64.lib</AdditionalDependencies>
|
||||
<ShowProgress>NotSet</ShowProgress>
|
||||
<SuppressStartupBanner>false</SuppressStartupBanner>
|
||||
</Link>
|
||||
|
|
@ -1432,7 +1432,7 @@ xcopy /q /y /i /s /e $(ProjectDir)Durango\CU $(LayoutDir)Image\Loose\CU</Comman
|
|||
<Link>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<ProgramDatabaseFile>$(OutDir)$(ProjectName).pdb</ProgramDatabaseFile>
|
||||
<AdditionalDependencies>d3d11.lib;..\Minecraft.World\x64_Release\Minecraft.World.lib;XInput9_1_0.lib;Windows64\Iggy\lib\iggy_w64.lib;..\Minecraft.Client\Windows64\Miles\Lib\mss64.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalDependencies>d3d11.lib;d3dcompiler.lib;..\Minecraft.World\x64_Release\Minecraft.World.lib;XInput9_1_0.lib;Windows64\Iggy\lib\iggy_w64.lib;..\Minecraft.Client\Windows64\Miles\Lib\mss64.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<ShowProgress>NotSet</ShowProgress>
|
||||
<SuppressStartupBanner>false</SuppressStartupBanner>
|
||||
</Link>
|
||||
|
|
@ -1484,7 +1484,7 @@ copy /Y "$(ProjectDir)Durango\Sound\Minecraft.msscmp" "$(OutDir)Durango\Sound\"<
|
|||
<Link>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<ProgramDatabaseFile>$(OutDir)$(ProjectName).pdb</ProgramDatabaseFile>
|
||||
<AdditionalDependencies>d3d11.lib;..\Minecraft.World\x64_Release\Minecraft.World.lib;XInput9_1_0.lib;Windows64\Iggy\lib\iggy_w64.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalDependencies>d3d11.lib;d3dcompiler.lib;..\Minecraft.World\x64_Release\Minecraft.World.lib;XInput9_1_0.lib;Windows64\Iggy\lib\iggy_w64.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<ShowProgress>NotSet</ShowProgress>
|
||||
<SuppressStartupBanner>false</SuppressStartupBanner>
|
||||
</Link>
|
||||
|
|
@ -16657,6 +16657,37 @@ xcopy /q /y /i /s /e $(ProjectDir)Durango\CU $(LayoutDir)Image\Loose\CU</Comman
|
|||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|ORBIS'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='ContentPackage_Vita|ORBIS'">true</ExcludedFromBuild>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Windows64\Windows64_PostProcess.h">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='ContentPackage|Durango'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='CONTENTPACKAGE_SYMBOLS|Durango'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='ReleaseForArt|Durango'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='ContentPackage_NO_TU|Durango'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='DebugContentPackage|Durango'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Durango'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='ContentPackage_Vita|Durango'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Durango'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='ContentPackage|Xbox 360'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='CONTENTPACKAGE_SYMBOLS|Xbox 360'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='ReleaseForArt|Xbox 360'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='ContentPackage_NO_TU|Xbox 360'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|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)'=='ContentPackage|x64'">false</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='CONTENTPACKAGE_SYMBOLS|x64'">false</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='ReleaseForArt|x64'">false</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='ContentPackage_NO_TU|x64'">false</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='ContentPackage_Vita|x64'">false</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='ContentPackage|ORBIS'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='CONTENTPACKAGE_SYMBOLS|ORBIS'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='ReleaseForArt|ORBIS'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='ContentPackage_NO_TU|ORBIS'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|ORBIS'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|ORBIS'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='ContentPackage_Vita|ORBIS'">true</ExcludedFromBuild>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Windows64\Windows64_UIController.h">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Durango'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='ContentPackage_Vita|Durango'">true</ExcludedFromBuild>
|
||||
|
|
@ -29116,6 +29147,51 @@ xcopy /q /y /i /s /e $(ProjectDir)Durango\CU $(LayoutDir)Image\Loose\CU</Comman
|
|||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|ORBIS'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='ContentPackage_Vita|ORBIS'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Windows64\Windows64_PostProcess.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='ContentPackage|Durango'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='CONTENTPACKAGE_SYMBOLS|Durango'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='ReleaseForArt|Durango'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='ContentPackage_NO_TU|Durango'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='DebugContentPackage|Durango'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Durango'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='ContentPackage_Vita|Durango'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Durango'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='ContentPackage|Xbox 360'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='CONTENTPACKAGE_SYMBOLS|Xbox 360'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='ReleaseForArt|Xbox 360'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='ContentPackage_NO_TU|Xbox 360'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|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)'=='ContentPackage|x64'">false</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='CONTENTPACKAGE_SYMBOLS|x64'">false</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='ReleaseForArt|x64'">false</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='ContentPackage_NO_TU|x64'">false</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='ContentPackage_Vita|x64'">false</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='ContentPackage|PS3'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='ContentPackage|PSVita'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='CONTENTPACKAGE_SYMBOLS|PS3'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='CONTENTPACKAGE_SYMBOLS|PSVita'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='ReleaseForArt|PS3'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='ReleaseForArt|PSVita'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='ContentPackage_NO_TU|PS3'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='ContentPackage_NO_TU|PSVita'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|PS3'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='ContentPackage_Vita|PS3'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|PSVita'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='ContentPackage_Vita|PSVita'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|PS3'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|PSVita'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='ContentPackage|ORBIS'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='CONTENTPACKAGE_SYMBOLS|ORBIS'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='ReleaseForArt|ORBIS'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='ContentPackage_NO_TU|ORBIS'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|ORBIS'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|ORBIS'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='ContentPackage_Vita|ORBIS'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Windows64\Network\WinsockNetLayer.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='ContentPackage|Durango'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='CONTENTPACKAGE_SYMBOLS|Durango'">true</ExcludedFromBuild>
|
||||
|
|
|
|||
|
|
@ -62,6 +62,7 @@
|
|||
#include "..\Minecraft.World\StrongholdFeature.h"
|
||||
#include "..\Minecraft.World\IntCache.h"
|
||||
#include "..\Minecraft.World\Villager.h"
|
||||
#include "..\Minecraft.World\EntityIO.h" // for mobs
|
||||
#include "..\Minecraft.World\SparseLightStorage.h"
|
||||
#include "..\Minecraft.World\SparseDataStorage.h"
|
||||
#include "TextureManager.h"
|
||||
|
|
@ -1456,7 +1457,7 @@ void Minecraft::run_middle()
|
|||
{
|
||||
if(InputManager.ButtonDown(i, MINECRAFT_ACTION_SNEAK_TOGGLE)) localplayers[i]->ullButtonsPressed|=1LL<<MINECRAFT_ACTION_SNEAK_TOGGLE;
|
||||
#ifdef _WINDOWS64
|
||||
if(i == 0 && g_KBMInput.IsKeyDown(KeyboardMouseInput::KEY_SNEAK)) localplayers[i]->ullButtonsPressed|=1LL<<MINECRAFT_ACTION_SNEAK_TOGGLE;
|
||||
if(i == 0 && g_KBMInput.IsKBMActive() && g_KBMInput.IsKeyDown(KeyboardMouseInput::KEY_SNEAK)) localplayers[i]->ullButtonsPressed|=1LL<<MINECRAFT_ACTION_SNEAK_TOGGLE;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
|
|
@ -1469,22 +1470,41 @@ void Minecraft::run_middle()
|
|||
#ifdef _WINDOWS64
|
||||
if (i == 0)
|
||||
{
|
||||
if(g_KBMInput.IsMouseButtonPressed(KeyboardMouseInput::MOUSE_LEFT))
|
||||
localplayers[i]->ullButtonsPressed|=1LL<<MINECRAFT_ACTION_ACTION;
|
||||
if (g_KBMInput.IsKBMActive())
|
||||
{
|
||||
if(g_KBMInput.IsMouseButtonPressed(KeyboardMouseInput::MOUSE_LEFT))
|
||||
localplayers[i]->ullButtonsPressed|=1LL<<MINECRAFT_ACTION_ACTION;
|
||||
|
||||
if(g_KBMInput.IsMouseButtonPressed(KeyboardMouseInput::MOUSE_RIGHT))
|
||||
localplayers[i]->ullButtonsPressed|=1LL<<MINECRAFT_ACTION_USE;
|
||||
if(g_KBMInput.IsMouseButtonPressed(KeyboardMouseInput::MOUSE_RIGHT))
|
||||
localplayers[i]->ullButtonsPressed|=1LL<<MINECRAFT_ACTION_USE;
|
||||
|
||||
if(g_KBMInput.IsKeyPressed(KeyboardMouseInput::KEY_INVENTORY))
|
||||
localplayers[i]->ullButtonsPressed|=1LL<<MINECRAFT_ACTION_INVENTORY;
|
||||
if(g_KBMInput.IsKeyPressed(KeyboardMouseInput::KEY_INVENTORY))
|
||||
localplayers[i]->ullButtonsPressed|=1LL<<MINECRAFT_ACTION_INVENTORY;
|
||||
|
||||
if(g_KBMInput.IsKeyPressed(KeyboardMouseInput::KEY_DROP))
|
||||
localplayers[i]->ullButtonsPressed|=1LL<<MINECRAFT_ACTION_DROP;
|
||||
if(g_KBMInput.IsKeyPressed(KeyboardMouseInput::KEY_DROP))
|
||||
localplayers[i]->ullButtonsPressed|=1LL<<MINECRAFT_ACTION_DROP;
|
||||
|
||||
if(g_KBMInput.IsKeyPressed(KeyboardMouseInput::KEY_CRAFTING) || g_KBMInput.IsKeyPressed(KeyboardMouseInput::KEY_CRAFTING_ALT))
|
||||
localplayers[i]->ullButtonsPressed|=1LL<<MINECRAFT_ACTION_CRAFTING;
|
||||
if(g_KBMInput.IsKeyPressed(KeyboardMouseInput::KEY_CRAFTING) || g_KBMInput.IsKeyPressed(KeyboardMouseInput::KEY_CRAFTING_ALT))
|
||||
localplayers[i]->ullButtonsPressed|=1LL<<MINECRAFT_ACTION_CRAFTING;
|
||||
|
||||
if(g_KBMInput.IsKeyPressed(KeyboardMouseInput::KEY_PAUSE))
|
||||
int wheel = g_KBMInput.GetMouseWheel();
|
||||
if (wheel > 0)
|
||||
localplayers[i]->ullButtonsPressed|=1LL<<MINECRAFT_ACTION_RIGHT_SCROLL;
|
||||
else if (wheel < 0)
|
||||
localplayers[i]->ullButtonsPressed|=1LL<<MINECRAFT_ACTION_LEFT_SCROLL;
|
||||
|
||||
for (int slot = 0; slot < 9; slot++)
|
||||
{
|
||||
if (g_KBMInput.IsKeyPressed('1' + slot))
|
||||
{
|
||||
if (localplayers[i]->inventory)
|
||||
localplayers[i]->inventory->selected = slot;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Utility keys always work regardless of KBM active state
|
||||
if(g_KBMInput.IsKeyPressed(KeyboardMouseInput::KEY_PAUSE) && !ui.IsTutorialVisible(i))
|
||||
{
|
||||
localplayers[i]->ullButtonsPressed|=1LL<<MINECRAFT_ACTION_PAUSEMENU;
|
||||
app.DebugPrintf("PAUSE PRESSED (keyboard) - ipad = %d\n",i);
|
||||
|
|
@ -1503,21 +1523,6 @@ void Minecraft::run_middle()
|
|||
{
|
||||
showFpsCounter = !showFpsCounter;
|
||||
}
|
||||
|
||||
int wheel = g_KBMInput.GetMouseWheel();
|
||||
if (wheel > 0)
|
||||
localplayers[i]->ullButtonsPressed|=1LL<<MINECRAFT_ACTION_RIGHT_SCROLL;
|
||||
else if (wheel < 0)
|
||||
localplayers[i]->ullButtonsPressed|=1LL<<MINECRAFT_ACTION_LEFT_SCROLL;
|
||||
|
||||
for (int slot = 0; slot < 9; slot++)
|
||||
{
|
||||
if (g_KBMInput.IsKeyPressed('1' + slot))
|
||||
{
|
||||
if (localplayers[i]->inventory)
|
||||
localplayers[i]->inventory->selected = slot;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
@ -3266,7 +3271,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures)
|
|||
wheel = -1;
|
||||
}
|
||||
#ifdef _WINDOWS64
|
||||
if (iPad == 0 && wheel == 0)
|
||||
if (iPad == 0 && wheel == 0 && g_KBMInput.IsKBMActive())
|
||||
{
|
||||
int mw = g_KBMInput.GetMouseWheel();
|
||||
if (mw > 0) wheel = -1;
|
||||
|
|
@ -3296,63 +3301,85 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures)
|
|||
}
|
||||
|
||||
#ifdef _WINDOWS64 // allows for the player to get the block they are looking at in creative by middle clicking.
|
||||
if (iPad == 0 && player->abilities.instabuild && g_KBMInput.IsMouseButtonPressed(KeyboardMouseInput::MOUSE_MIDDLE) && hitResult != NULL && hitResult->type == HitResult::TILE)
|
||||
if (iPad == 0 && g_KBMInput.IsKBMActive() && player->abilities.instabuild && g_KBMInput.IsMouseButtonPressed(KeyboardMouseInput::MOUSE_MIDDLE) && hitResult != NULL && (hitResult->type == HitResult::TILE || hitResult->type == HitResult::ENTITY))
|
||||
{
|
||||
//printf("MIDDLE CLICK TEST!!");
|
||||
int tileId = level->getTile(hitResult->x, hitResult->y, hitResult->z);
|
||||
Tile *tile = (tileId > 0 && tileId < Tile::TILE_NUM_COUNT) ? Tile::tiles[tileId] : NULL;
|
||||
//printf("MIDDLE CLICK TEST!!"); // windermed was here.
|
||||
int cloneId = -1;
|
||||
int cloneData = 0;
|
||||
bool checkData = false;
|
||||
|
||||
if (tile != NULL)
|
||||
// if its a tile
|
||||
if (hitResult->type == HitResult::TILE)
|
||||
{
|
||||
int cloneId = tile->cloneTileId(level, hitResult->x, hitResult->y, hitResult->z);
|
||||
|
||||
if (cloneId > 0 && cloneId < Item::ITEM_NUM_COUNT && Item::items[cloneId] != NULL)
|
||||
int tileId = level->getTile(hitResult->x, hitResult->y, hitResult->z);
|
||||
Tile* tile = (tileId > 0 && tileId < Tile::TILE_NUM_COUNT) ? Tile::tiles[tileId] : NULL;
|
||||
if (tile != NULL)
|
||||
{
|
||||
int cloneData = tile->cloneTileData(level, hitResult->x, hitResult->y, hitResult->z);
|
||||
bool checkData = Item::items[cloneId]->isStackedByData();
|
||||
|
||||
int quickbarSlot = -1;
|
||||
|
||||
for (int slot = 0; slot < Inventory::getSelectionSize(); ++slot)
|
||||
{
|
||||
shared_ptr<ItemInstance> quickbarItem = player->inventory->items[slot];
|
||||
if (quickbarItem == NULL || quickbarItem->id != cloneId)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!checkData || quickbarItem->getAuxValue() == cloneData)
|
||||
{
|
||||
quickbarSlot = slot;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (quickbarSlot >= 0)
|
||||
{
|
||||
player->inventory->selected = quickbarSlot;
|
||||
}
|
||||
else
|
||||
{
|
||||
player->inventory->grabTexture(cloneId, cloneData, checkData, true);
|
||||
}
|
||||
|
||||
// should prevent ghost items/blocks
|
||||
shared_ptr<ItemInstance> selctedItem = player->inventory->getSelected();
|
||||
if (gameMode != NULL && selctedItem != NULL)
|
||||
{
|
||||
const int creativeHotbarSlotStart = 36;
|
||||
gameMode->handleCreativeModeItemAdd(selctedItem, creativeHotbarSlotStart + player->inventory->selected);
|
||||
}
|
||||
|
||||
if (gameMode != NULL && gameMode->getTutorial() != NULL)
|
||||
{
|
||||
gameMode->getTutorial()->onSelectedItemChanged(player->inventory->getSelected());
|
||||
}
|
||||
|
||||
player->updateRichPresence();
|
||||
cloneId = tile->cloneTileId(level, hitResult->x, hitResult->y, hitResult->z);
|
||||
cloneData = tile->cloneTileData(level, hitResult->x, hitResult->y, hitResult->z);
|
||||
}
|
||||
}
|
||||
|
||||
// if its an entity
|
||||
else if (hitResult->type == HitResult::ENTITY && hitResult->entity != NULL)
|
||||
{
|
||||
int entityIoId = EntityIO::eTypeToIoid(hitResult->entity->GetType());
|
||||
if (entityIoId > 0 && EntityIO::idsSpawnableInCreative.find(entityIoId) != EntityIO::idsSpawnableInCreative.end())
|
||||
{
|
||||
cloneId = Item::monsterPlacer_Id;
|
||||
cloneData = entityIoId;
|
||||
checkData = true;
|
||||
}
|
||||
}
|
||||
|
||||
// if we have a valid cloneId, try to find it in the quickbar and select it, otherwise just grab it.
|
||||
if (cloneId > 0 && cloneId < Item::ITEM_NUM_COUNT && Item::items[cloneId] != NULL)
|
||||
{
|
||||
if (hitResult->type == HitResult::TILE)
|
||||
{
|
||||
checkData = Item::items[cloneId]->isStackedByData();
|
||||
}
|
||||
|
||||
int quickbarSlot = -1;
|
||||
for (int slot = 0; slot < Inventory::getSelectionSize(); ++slot)
|
||||
{
|
||||
shared_ptr<ItemInstance> quickbarItem = player->inventory->items[slot];
|
||||
if (quickbarItem == NULL || quickbarItem->id != cloneId)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!checkData || quickbarItem->getAuxValue() == cloneData)
|
||||
{
|
||||
quickbarSlot = slot;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (quickbarSlot >= 0)
|
||||
{
|
||||
player->inventory->selected = quickbarSlot;
|
||||
}
|
||||
else
|
||||
{
|
||||
player->inventory->grabTexture(cloneId, cloneData, checkData, true);
|
||||
}
|
||||
|
||||
// should prevent ghost items/blocks
|
||||
shared_ptr<ItemInstance> selectedItem = player->inventory->getSelected();
|
||||
if (gameMode != NULL && selectedItem != NULL)
|
||||
{
|
||||
const int creativeQuickbarSlotStart = 36;
|
||||
gameMode->handleCreativeModeItemAdd(selectedItem, creativeQuickbarSlotStart + player->inventory->selected);
|
||||
}
|
||||
|
||||
if (gameMode != NULL && gameMode->getTutorial() != NULL)
|
||||
{
|
||||
gameMode->getTutorial()->onSelectedItemChanged(player->inventory->getSelected());
|
||||
}
|
||||
|
||||
player->updateRichPresence();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
@ -3367,7 +3394,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures)
|
|||
}
|
||||
|
||||
#ifdef _WINDOWS64
|
||||
bool actionHeld = InputManager.ButtonDown(iPad, MINECRAFT_ACTION_ACTION) || (iPad == 0 && g_KBMInput.IsMouseButtonDown(KeyboardMouseInput::MOUSE_LEFT));
|
||||
bool actionHeld = InputManager.ButtonDown(iPad, MINECRAFT_ACTION_ACTION) || (iPad == 0 && g_KBMInput.IsKBMActive() && g_KBMInput.IsMouseButtonDown(KeyboardMouseInput::MOUSE_LEFT));
|
||||
#else
|
||||
bool actionHeld = InputManager.ButtonDown(iPad, MINECRAFT_ACTION_ACTION);
|
||||
#endif
|
||||
|
|
@ -3398,7 +3425,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures)
|
|||
}
|
||||
*/
|
||||
#ifdef _WINDOWS64
|
||||
bool useHeld = InputManager.ButtonDown(iPad, MINECRAFT_ACTION_USE) || (iPad == 0 && g_KBMInput.IsMouseButtonDown(KeyboardMouseInput::MOUSE_RIGHT));
|
||||
bool useHeld = InputManager.ButtonDown(iPad, MINECRAFT_ACTION_USE) || (iPad == 0 && g_KBMInput.IsKBMActive() && g_KBMInput.IsMouseButtonDown(KeyboardMouseInput::MOUSE_RIGHT));
|
||||
#else
|
||||
bool useHeld = InputManager.ButtonDown(iPad, MINECRAFT_ACTION_USE);
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
// Code implemented by LCEMP, credit if used on other repos
|
||||
|
||||
#include "stdafx.h"
|
||||
|
||||
#ifdef _WINDOWS64
|
||||
|
|
@ -213,6 +215,14 @@ bool WinsockNetLayer::JoinGame(const char *ip, int port)
|
|||
|
||||
s_isHost = false;
|
||||
s_hostSmallId = 0;
|
||||
s_connected = false;
|
||||
s_active = false;
|
||||
|
||||
if (s_hostConnectionSocket != INVALID_SOCKET)
|
||||
{
|
||||
closesocket(s_hostConnectionSocket);
|
||||
s_hostConnectionSocket = INVALID_SOCKET;
|
||||
}
|
||||
|
||||
struct addrinfo hints = {};
|
||||
struct addrinfo *result = NULL;
|
||||
|
|
@ -231,37 +241,55 @@ bool WinsockNetLayer::JoinGame(const char *ip, int port)
|
|||
return false;
|
||||
}
|
||||
|
||||
s_hostConnectionSocket = socket(result->ai_family, result->ai_socktype, result->ai_protocol);
|
||||
if (s_hostConnectionSocket == INVALID_SOCKET)
|
||||
bool connected = false;
|
||||
BYTE assignedSmallId = 0;
|
||||
const int maxAttempts = 12;
|
||||
|
||||
for (int attempt = 0; attempt < maxAttempts; ++attempt)
|
||||
{
|
||||
app.DebugPrintf("socket() failed: %d\n", WSAGetLastError());
|
||||
freeaddrinfo(result);
|
||||
return false;
|
||||
s_hostConnectionSocket = socket(result->ai_family, result->ai_socktype, result->ai_protocol);
|
||||
if (s_hostConnectionSocket == INVALID_SOCKET)
|
||||
{
|
||||
app.DebugPrintf("socket() failed: %d\n", WSAGetLastError());
|
||||
break;
|
||||
}
|
||||
|
||||
int noDelay = 1;
|
||||
setsockopt(s_hostConnectionSocket, IPPROTO_TCP, TCP_NODELAY, (const char *)&noDelay, sizeof(noDelay));
|
||||
|
||||
iResult = connect(s_hostConnectionSocket, result->ai_addr, (int)result->ai_addrlen);
|
||||
if (iResult == SOCKET_ERROR)
|
||||
{
|
||||
int err = WSAGetLastError();
|
||||
app.DebugPrintf("connect() to %s:%d failed (attempt %d/%d): %d\n", ip, port, attempt + 1, maxAttempts, err);
|
||||
closesocket(s_hostConnectionSocket);
|
||||
s_hostConnectionSocket = INVALID_SOCKET;
|
||||
Sleep(200);
|
||||
continue;
|
||||
}
|
||||
|
||||
BYTE assignBuf[1];
|
||||
int bytesRecv = recv(s_hostConnectionSocket, (char *)assignBuf, 1, 0);
|
||||
if (bytesRecv != 1)
|
||||
{
|
||||
app.DebugPrintf("Failed to receive small ID assignment from host (attempt %d/%d)\n", attempt + 1, maxAttempts);
|
||||
closesocket(s_hostConnectionSocket);
|
||||
s_hostConnectionSocket = INVALID_SOCKET;
|
||||
Sleep(200);
|
||||
continue;
|
||||
}
|
||||
|
||||
assignedSmallId = assignBuf[0];
|
||||
connected = true;
|
||||
break;
|
||||
}
|
||||
|
||||
int noDelay = 1;
|
||||
setsockopt(s_hostConnectionSocket, IPPROTO_TCP, TCP_NODELAY, (const char *)&noDelay, sizeof(noDelay));
|
||||
|
||||
iResult = connect(s_hostConnectionSocket, result->ai_addr, (int)result->ai_addrlen);
|
||||
freeaddrinfo(result);
|
||||
if (iResult == SOCKET_ERROR)
|
||||
{
|
||||
app.DebugPrintf("connect() to %s:%d failed: %d\n", ip, port, WSAGetLastError());
|
||||
closesocket(s_hostConnectionSocket);
|
||||
s_hostConnectionSocket = INVALID_SOCKET;
|
||||
return false;
|
||||
}
|
||||
|
||||
BYTE assignBuf[1];
|
||||
int bytesRecv = recv(s_hostConnectionSocket, (char *)assignBuf, 1, 0);
|
||||
if (bytesRecv != 1)
|
||||
if (!connected)
|
||||
{
|
||||
app.DebugPrintf("Failed to receive small ID assignment from host\n");
|
||||
closesocket(s_hostConnectionSocket);
|
||||
s_hostConnectionSocket = INVALID_SOCKET;
|
||||
return false;
|
||||
}
|
||||
s_localSmallId = assignBuf[0];
|
||||
s_localSmallId = assignedSmallId;
|
||||
|
||||
app.DebugPrintf("Win64 LAN: Connected to %s:%d, assigned smallId=%d\n", ip, port, s_localSmallId);
|
||||
|
||||
|
|
@ -479,7 +507,8 @@ DWORD WINAPI WinsockNetLayer::RecvThreadProc(LPVOID param)
|
|||
BYTE clientSmallId = s_connections[connIdx].smallId;
|
||||
LeaveCriticalSection(&s_connectionsLock);
|
||||
|
||||
BYTE *recvBuf = new BYTE[WIN64_NET_RECV_BUFFER_SIZE];
|
||||
std::vector<BYTE> recvBuf;
|
||||
recvBuf.resize(WIN64_NET_RECV_BUFFER_SIZE);
|
||||
|
||||
while (s_active)
|
||||
{
|
||||
|
|
@ -490,33 +519,47 @@ DWORD WINAPI WinsockNetLayer::RecvThreadProc(LPVOID param)
|
|||
break;
|
||||
}
|
||||
|
||||
int packetSize = (header[0] << 24) | (header[1] << 16) | (header[2] << 8) | header[3];
|
||||
int packetSize =
|
||||
((uint32_t)header[0] << 24) |
|
||||
((uint32_t)header[1] << 16) |
|
||||
((uint32_t)header[2] << 8) |
|
||||
((uint32_t)header[3]);
|
||||
|
||||
if (packetSize <= 0 || packetSize > WIN64_NET_RECV_BUFFER_SIZE)
|
||||
if (packetSize <= 0 || packetSize > WIN64_NET_MAX_PACKET_SIZE)
|
||||
{
|
||||
app.DebugPrintf("Win64 LAN: Invalid packet size %d from client smallId=%d\n", packetSize, clientSmallId);
|
||||
app.DebugPrintf("Win64 LAN: Invalid packet size %d from client smallId=%d (max=%d)\n",
|
||||
packetSize,
|
||||
clientSmallId,
|
||||
(int)WIN64_NET_MAX_PACKET_SIZE);
|
||||
break;
|
||||
}
|
||||
|
||||
if (!RecvExact(sock, recvBuf, packetSize))
|
||||
if ((int)recvBuf.size() < packetSize)
|
||||
{
|
||||
recvBuf.resize(packetSize);
|
||||
app.DebugPrintf("Win64 LAN: Resized host recv buffer to %d bytes for client smallId=%d\n", packetSize, clientSmallId);
|
||||
}
|
||||
|
||||
if (!RecvExact(sock, &recvBuf[0], packetSize))
|
||||
{
|
||||
app.DebugPrintf("Win64 LAN: Client smallId=%d disconnected (body)\n", clientSmallId);
|
||||
break;
|
||||
}
|
||||
|
||||
HandleDataReceived(clientSmallId, s_hostSmallId, recvBuf, packetSize);
|
||||
HandleDataReceived(clientSmallId, s_hostSmallId, &recvBuf[0], packetSize);
|
||||
}
|
||||
|
||||
delete[] recvBuf;
|
||||
|
||||
EnterCriticalSection(&s_connectionsLock);
|
||||
for (size_t i = 0; i < s_connections.size(); i++)
|
||||
{
|
||||
if (s_connections[i].smallId == clientSmallId)
|
||||
{
|
||||
s_connections[i].active = false;
|
||||
closesocket(s_connections[i].tcpSocket);
|
||||
s_connections[i].tcpSocket = INVALID_SOCKET;
|
||||
if (s_connections[i].tcpSocket != INVALID_SOCKET)
|
||||
{
|
||||
closesocket(s_connections[i].tcpSocket);
|
||||
s_connections[i].tcpSocket = INVALID_SOCKET;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -550,9 +593,26 @@ void WinsockNetLayer::PushFreeSmallId(BYTE smallId)
|
|||
LeaveCriticalSection(&s_freeSmallIdLock);
|
||||
}
|
||||
|
||||
void WinsockNetLayer::CloseConnectionBySmallId(BYTE smallId)
|
||||
{
|
||||
EnterCriticalSection(&s_connectionsLock);
|
||||
for (size_t i = 0; i < s_connections.size(); i++)
|
||||
{
|
||||
if (s_connections[i].smallId == smallId && s_connections[i].active && s_connections[i].tcpSocket != INVALID_SOCKET)
|
||||
{
|
||||
closesocket(s_connections[i].tcpSocket);
|
||||
s_connections[i].tcpSocket = INVALID_SOCKET;
|
||||
app.DebugPrintf("Win64 LAN: Force-closed TCP connection for smallId=%d\n", smallId);
|
||||
break;
|
||||
}
|
||||
}
|
||||
LeaveCriticalSection(&s_connectionsLock);
|
||||
}
|
||||
|
||||
DWORD WINAPI WinsockNetLayer::ClientRecvThreadProc(LPVOID param)
|
||||
{
|
||||
BYTE *recvBuf = new BYTE[WIN64_NET_RECV_BUFFER_SIZE];
|
||||
std::vector<BYTE> recvBuf;
|
||||
recvBuf.resize(WIN64_NET_RECV_BUFFER_SIZE);
|
||||
|
||||
while (s_active && s_hostConnectionSocket != INVALID_SOCKET)
|
||||
{
|
||||
|
|
@ -565,23 +625,29 @@ DWORD WINAPI WinsockNetLayer::ClientRecvThreadProc(LPVOID param)
|
|||
|
||||
int packetSize = (header[0] << 24) | (header[1] << 16) | (header[2] << 8) | header[3];
|
||||
|
||||
if (packetSize <= 0 || packetSize > WIN64_NET_RECV_BUFFER_SIZE)
|
||||
if (packetSize <= 0 || packetSize > WIN64_NET_MAX_PACKET_SIZE)
|
||||
{
|
||||
app.DebugPrintf("Win64 LAN: Invalid packet size %d from host\n", packetSize);
|
||||
app.DebugPrintf("Win64 LAN: Invalid packet size %d from host (max=%d)\n",
|
||||
packetSize,
|
||||
(int)WIN64_NET_MAX_PACKET_SIZE);
|
||||
break;
|
||||
}
|
||||
|
||||
if (!RecvExact(s_hostConnectionSocket, recvBuf, packetSize))
|
||||
if ((int)recvBuf.size() < packetSize)
|
||||
{
|
||||
recvBuf.resize(packetSize);
|
||||
app.DebugPrintf("Win64 LAN: Resized client recv buffer to %d bytes\n", packetSize);
|
||||
}
|
||||
|
||||
if (!RecvExact(s_hostConnectionSocket, &recvBuf[0], packetSize))
|
||||
{
|
||||
app.DebugPrintf("Win64 LAN: Disconnected from host (body)\n");
|
||||
break;
|
||||
}
|
||||
|
||||
HandleDataReceived(s_hostSmallId, s_localSmallId, recvBuf, packetSize);
|
||||
HandleDataReceived(s_hostSmallId, s_localSmallId, &recvBuf[0], packetSize);
|
||||
}
|
||||
|
||||
delete[] recvBuf;
|
||||
|
||||
s_connected = false;
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@
|
|||
#define WIN64_NET_DEFAULT_PORT 25565
|
||||
#define WIN64_NET_MAX_CLIENTS 7
|
||||
#define WIN64_NET_RECV_BUFFER_SIZE 65536
|
||||
#define WIN64_NET_MAX_PACKET_SIZE (4 * 1024 * 1024)
|
||||
#define WIN64_LAN_DISCOVERY_PORT 25566
|
||||
#define WIN64_LAN_BROADCAST_MAGIC 0x4D434C4E
|
||||
|
||||
|
|
@ -81,6 +82,7 @@ public:
|
|||
|
||||
static bool PopDisconnectedSmallId(BYTE *outSmallId);
|
||||
static void PushFreeSmallId(BYTE smallId);
|
||||
static void CloseConnectionBySmallId(BYTE smallId);
|
||||
|
||||
static bool StartAdvertising(int gamePort, const wchar_t *hostName, unsigned int gameSettings, unsigned int texPackId, unsigned char subTexId, unsigned short netVer);
|
||||
static void StopAdvertising();
|
||||
|
|
|
|||
|
|
@ -37,8 +37,11 @@
|
|||
#include "Resource.h"
|
||||
#include "..\..\Minecraft.World\compression.h"
|
||||
#include "..\..\Minecraft.World\OldChunkStorage.h"
|
||||
|
||||
#include "Network\WinsockNetLayer.h"
|
||||
|
||||
#include "Windows64_PostProcess.h"
|
||||
|
||||
#include "Xbox/resource.h"
|
||||
|
||||
HINSTANCE hMyInst;
|
||||
|
|
@ -343,54 +346,23 @@ ID3D11Device* g_pd3dDevice = NULL;
|
|||
ID3D11DeviceContext* g_pImmediateContext = NULL;
|
||||
IDXGISwapChain* g_pSwapChain = NULL;
|
||||
|
||||
static WORD g_originalGammaRamp[3][256];
|
||||
static bool g_gammaRampSaved = false;
|
||||
ID3D11RenderTargetView* g_pRenderTargetView = NULL;
|
||||
ID3D11DepthStencilView* g_pDepthStencilView = NULL;
|
||||
ID3D11Texture2D* g_pDepthStencilBuffer = NULL;
|
||||
|
||||
void Windows64_UpdateGamma(unsigned short usGamma)
|
||||
{
|
||||
if (!g_hWnd) return;
|
||||
|
||||
HDC hdc = GetDC(g_hWnd);
|
||||
if (!hdc) return;
|
||||
|
||||
if (!g_gammaRampSaved)
|
||||
{
|
||||
GetDeviceGammaRamp(hdc, g_originalGammaRamp);
|
||||
g_gammaRampSaved = true;
|
||||
}
|
||||
|
||||
float gamma = (float)usGamma / 32768.0f;
|
||||
if (gamma < 0.01f) gamma = 0.01f;
|
||||
if (gamma < 0.0f) gamma = 0.0f;
|
||||
if (gamma > 1.0f) gamma = 1.0f;
|
||||
|
||||
float invGamma = 1.0f / (0.5f + gamma * 0.5f);
|
||||
|
||||
WORD ramp[3][256];
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
float normalized = (float)i / 255.0f;
|
||||
float corrected = powf(normalized, invGamma);
|
||||
WORD val = (WORD)(corrected * 65535.0f + 0.5f);
|
||||
ramp[0][i] = val;
|
||||
ramp[1][i] = val;
|
||||
ramp[2][i] = val;
|
||||
}
|
||||
|
||||
SetDeviceGammaRamp(hdc, ramp);
|
||||
ReleaseDC(g_hWnd, hdc);
|
||||
SetGammaValue(0.5f * powf(4.0f, gamma));
|
||||
}
|
||||
|
||||
void Windows64_RestoreGamma()
|
||||
{
|
||||
if (!g_gammaRampSaved || !g_hWnd) return;
|
||||
HDC hdc = GetDC(g_hWnd);
|
||||
if (!hdc) return;
|
||||
SetDeviceGammaRamp(hdc, g_originalGammaRamp);
|
||||
ReleaseDC(g_hWnd, hdc);
|
||||
|
||||
}
|
||||
ID3D11RenderTargetView* g_pRenderTargetView = NULL;
|
||||
ID3D11DepthStencilView* g_pDepthStencilView = NULL;
|
||||
ID3D11Texture2D* g_pDepthStencilBuffer = NULL;
|
||||
|
||||
//
|
||||
// FUNCTION: WndProc(HWND, UINT, WPARAM, LPARAM)
|
||||
|
|
@ -712,6 +684,7 @@ app.DebugPrintf("width: %d, height: %d\n", width, height);
|
|||
|
||||
// Create a depth stencil buffer
|
||||
D3D11_TEXTURE2D_DESC descDepth;
|
||||
ZeroMemory(&descDepth, sizeof(descDepth));
|
||||
|
||||
descDepth.Width = width;
|
||||
descDepth.Height = height;
|
||||
|
|
@ -727,6 +700,7 @@ app.DebugPrintf("width: %d, height: %d\n", width, height);
|
|||
hr = g_pd3dDevice->CreateTexture2D(&descDepth, NULL, &g_pDepthStencilBuffer);
|
||||
|
||||
D3D11_DEPTH_STENCIL_VIEW_DESC descDSView;
|
||||
ZeroMemory(&descDSView, sizeof(descDSView));
|
||||
descDSView.Format = DXGI_FORMAT_D24_UNORM_S8_UINT;
|
||||
descDSView.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2D;
|
||||
descDSView.Texture2D.MipSlice = 0;
|
||||
|
|
@ -775,6 +749,8 @@ void CleanupDevice()
|
|||
extern void Windows64_RestoreGamma();
|
||||
Windows64_RestoreGamma();
|
||||
|
||||
CleanupGammaPostProcess();
|
||||
|
||||
if( g_pImmediateContext ) g_pImmediateContext->ClearState();
|
||||
|
||||
if( g_pRenderTargetView ) g_pRenderTargetView->Release();
|
||||
|
|
@ -859,6 +835,8 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
|
|||
return 0;
|
||||
}
|
||||
|
||||
InitGammaPostProcess();
|
||||
|
||||
#if 0
|
||||
// Main message loop
|
||||
MSG msg = {0};
|
||||
|
|
@ -1185,6 +1163,33 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
|
|||
PIXBeginNamedEvent(0,"Input manager tick");
|
||||
InputManager.Tick();
|
||||
|
||||
// detect input mode
|
||||
if (InputManager.IsPadConnected(0))
|
||||
{
|
||||
bool controllerUsed = InputManager.ButtonPressed(0) ||
|
||||
InputManager.GetJoypadStick_LX(0, false) != 0.0f ||
|
||||
InputManager.GetJoypadStick_LY(0, false) != 0.0f ||
|
||||
InputManager.GetJoypadStick_RX(0, false) != 0.0f ||
|
||||
InputManager.GetJoypadStick_RY(0, false) != 0.0f;
|
||||
|
||||
if (controllerUsed)
|
||||
g_KBMInput.SetKBMActive(false);
|
||||
else if (g_KBMInput.HasAnyInput())
|
||||
g_KBMInput.SetKBMActive(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_KBMInput.SetKBMActive(true);
|
||||
}
|
||||
|
||||
if (!g_KBMInput.IsMouseGrabbed())
|
||||
{
|
||||
if (!g_KBMInput.IsKBMActive())
|
||||
g_KBMInput.SetCursorHiddenForUI(true);
|
||||
else if (!g_KBMInput.IsScreenCursorHidden())
|
||||
g_KBMInput.SetCursorHiddenForUI(false);
|
||||
}
|
||||
|
||||
PIXEndNamedEvent();
|
||||
PIXBeginNamedEvent(0,"Profile manager tick");
|
||||
// ProfileManager.Tick();
|
||||
|
|
@ -1308,6 +1313,8 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
|
|||
|
||||
RenderManager.Set_matrixDirty();
|
||||
#endif
|
||||
ApplyGammaPostProcess();
|
||||
|
||||
// Present the frame.
|
||||
RenderManager.Present();
|
||||
|
||||
|
|
|
|||
251
Minecraft.Client/Windows64/Windows64_PostProcess.cpp
Normal file
251
Minecraft.Client/Windows64/Windows64_PostProcess.cpp
Normal file
|
|
@ -0,0 +1,251 @@
|
|||
#include "stdafx.h"
|
||||
#include "Windows64_PostProcess.h"
|
||||
#include <d3dcompiler.h>
|
||||
#pragma comment(lib, "d3dcompiler.lib")
|
||||
|
||||
extern ID3D11Device* g_pd3dDevice;
|
||||
extern ID3D11DeviceContext* g_pImmediateContext;
|
||||
extern IDXGISwapChain* g_pSwapChain;
|
||||
extern ID3D11RenderTargetView* g_pRenderTargetView;
|
||||
|
||||
static ID3D11Texture2D* g_pGammaOffscreenTex = NULL;
|
||||
static ID3D11ShaderResourceView* g_pGammaOffscreenSRV = NULL;
|
||||
static ID3D11RenderTargetView* g_pGammaOffscreenRTV = NULL;
|
||||
static ID3D11VertexShader* g_pGammaVS = NULL;
|
||||
static ID3D11PixelShader* g_pGammaPS = NULL;
|
||||
static ID3D11Buffer* g_pGammaCB = NULL;
|
||||
static ID3D11SamplerState* g_pGammaSampler = NULL;
|
||||
static ID3D11RasterizerState* g_pGammaRastState = NULL;
|
||||
static ID3D11DepthStencilState* g_pGammaDepthState = NULL;
|
||||
static ID3D11BlendState* g_pGammaBlendState = NULL;
|
||||
static bool g_gammaPostProcessReady = false;
|
||||
static float g_gammaValue = 1.0f;
|
||||
|
||||
struct GammaCBData
|
||||
{
|
||||
float gamma;
|
||||
float pad[3];
|
||||
};
|
||||
|
||||
static const char* g_gammaVSCode =
|
||||
"void main(uint id : SV_VertexID, out float4 pos : SV_Position, out float2 uv : TEXCOORD0)\n"
|
||||
"{\n"
|
||||
" uv = float2((id << 1) & 2, id & 2);\n"
|
||||
" pos = float4(uv * float2(2.0, -2.0) + float2(-1.0, 1.0), 0.0, 1.0);\n"
|
||||
"}\n";
|
||||
|
||||
static const char* g_gammaPSCode =
|
||||
"cbuffer GammaCB : register(b0)\n"
|
||||
"{\n"
|
||||
" float gamma;\n"
|
||||
" float3 pad;\n"
|
||||
"};\n"
|
||||
"Texture2D sceneTex : register(t0);\n"
|
||||
"SamplerState sceneSampler : register(s0);\n"
|
||||
"float4 main(float4 pos : SV_Position, float2 uv : TEXCOORD0) : SV_Target\n"
|
||||
"{\n"
|
||||
" float4 color = sceneTex.Sample(sceneSampler, uv);\n"
|
||||
" color.rgb = pow(max(color.rgb, 0.0), 1.0 / gamma);\n"
|
||||
" return color;\n"
|
||||
"}\n";
|
||||
|
||||
|
||||
void SetGammaValue(float gamma)
|
||||
{
|
||||
g_gammaValue = gamma;
|
||||
}
|
||||
|
||||
bool InitGammaPostProcess()
|
||||
{
|
||||
if (!g_pd3dDevice || !g_pSwapChain) return false;
|
||||
|
||||
HRESULT hr;
|
||||
|
||||
ID3D11Texture2D* pBackBuffer = NULL;
|
||||
hr = g_pSwapChain->GetBuffer(0, __uuidof(ID3D11Texture2D), (LPVOID*)&pBackBuffer);
|
||||
if (FAILED(hr)) return false;
|
||||
|
||||
D3D11_TEXTURE2D_DESC bbDesc;
|
||||
pBackBuffer->GetDesc(&bbDesc);
|
||||
pBackBuffer->Release();
|
||||
|
||||
D3D11_TEXTURE2D_DESC texDesc;
|
||||
ZeroMemory(&texDesc, sizeof(texDesc));
|
||||
texDesc.Width = bbDesc.Width;
|
||||
texDesc.Height = bbDesc.Height;
|
||||
texDesc.MipLevels = 1;
|
||||
texDesc.ArraySize = 1;
|
||||
texDesc.Format = bbDesc.Format;
|
||||
texDesc.SampleDesc.Count = 1;
|
||||
texDesc.SampleDesc.Quality = 0;
|
||||
texDesc.Usage = D3D11_USAGE_DEFAULT;
|
||||
texDesc.BindFlags = D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_RENDER_TARGET;
|
||||
hr = g_pd3dDevice->CreateTexture2D(&texDesc, NULL, &g_pGammaOffscreenTex);
|
||||
if (FAILED(hr)) return false;
|
||||
|
||||
hr = g_pd3dDevice->CreateShaderResourceView(g_pGammaOffscreenTex, NULL, &g_pGammaOffscreenSRV);
|
||||
if (FAILED(hr)) return false;
|
||||
|
||||
hr = g_pd3dDevice->CreateRenderTargetView(g_pGammaOffscreenTex, NULL, &g_pGammaOffscreenRTV);
|
||||
if (FAILED(hr)) return false;
|
||||
|
||||
ID3DBlob* vsBlob = NULL;
|
||||
ID3DBlob* errBlob = NULL;
|
||||
hr = D3DCompile(g_gammaVSCode, strlen(g_gammaVSCode), "GammaVS", NULL, NULL, "main", "vs_4_0", 0, 0, &vsBlob, &errBlob);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
if (errBlob) errBlob->Release();
|
||||
return false;
|
||||
}
|
||||
hr = g_pd3dDevice->CreateVertexShader(vsBlob->GetBufferPointer(), vsBlob->GetBufferSize(), NULL, &g_pGammaVS);
|
||||
vsBlob->Release();
|
||||
if (errBlob) errBlob->Release();
|
||||
if (FAILED(hr)) return false;
|
||||
|
||||
errBlob = NULL;
|
||||
ID3DBlob* psBlob = NULL;
|
||||
hr = D3DCompile(g_gammaPSCode, strlen(g_gammaPSCode), "GammaPS", NULL, NULL, "main", "ps_4_0", 0, 0, &psBlob, &errBlob);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
if (errBlob) errBlob->Release();
|
||||
return false;
|
||||
}
|
||||
hr = g_pd3dDevice->CreatePixelShader(psBlob->GetBufferPointer(), psBlob->GetBufferSize(), NULL, &g_pGammaPS);
|
||||
psBlob->Release();
|
||||
if (errBlob) errBlob->Release();
|
||||
if (FAILED(hr)) return false;
|
||||
|
||||
D3D11_BUFFER_DESC cbDesc;
|
||||
ZeroMemory(&cbDesc, sizeof(cbDesc));
|
||||
cbDesc.ByteWidth = sizeof(GammaCBData);
|
||||
cbDesc.Usage = D3D11_USAGE_DYNAMIC;
|
||||
cbDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
|
||||
cbDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
|
||||
GammaCBData initData = { 1.0f, {0, 0, 0} };
|
||||
D3D11_SUBRESOURCE_DATA srData;
|
||||
srData.pSysMem = &initData;
|
||||
srData.SysMemPitch = 0;
|
||||
srData.SysMemSlicePitch = 0;
|
||||
hr = g_pd3dDevice->CreateBuffer(&cbDesc, &srData, &g_pGammaCB);
|
||||
if (FAILED(hr)) return false;
|
||||
|
||||
D3D11_SAMPLER_DESC sampDesc;
|
||||
ZeroMemory(&sampDesc, sizeof(sampDesc));
|
||||
sampDesc.Filter = D3D11_FILTER_MIN_MAG_MIP_POINT;
|
||||
sampDesc.AddressU = D3D11_TEXTURE_ADDRESS_CLAMP;
|
||||
sampDesc.AddressV = D3D11_TEXTURE_ADDRESS_CLAMP;
|
||||
sampDesc.AddressW = D3D11_TEXTURE_ADDRESS_CLAMP;
|
||||
hr = g_pd3dDevice->CreateSamplerState(&sampDesc, &g_pGammaSampler);
|
||||
if (FAILED(hr)) return false;
|
||||
|
||||
D3D11_RASTERIZER_DESC rasDesc;
|
||||
ZeroMemory(&rasDesc, sizeof(rasDesc));
|
||||
rasDesc.FillMode = D3D11_FILL_SOLID;
|
||||
rasDesc.CullMode = D3D11_CULL_NONE;
|
||||
rasDesc.DepthClipEnable = FALSE;
|
||||
hr = g_pd3dDevice->CreateRasterizerState(&rasDesc, &g_pGammaRastState);
|
||||
if (FAILED(hr)) return false;
|
||||
|
||||
// Depth stencil state (disabled)
|
||||
D3D11_DEPTH_STENCIL_DESC dsDesc;
|
||||
ZeroMemory(&dsDesc, sizeof(dsDesc));
|
||||
dsDesc.DepthEnable = FALSE;
|
||||
dsDesc.StencilEnable = FALSE;
|
||||
hr = g_pd3dDevice->CreateDepthStencilState(&dsDesc, &g_pGammaDepthState);
|
||||
if (FAILED(hr)) return false;
|
||||
|
||||
D3D11_BLEND_DESC blendDesc;
|
||||
ZeroMemory(&blendDesc, sizeof(blendDesc));
|
||||
blendDesc.RenderTarget[0].BlendEnable = FALSE;
|
||||
blendDesc.RenderTarget[0].RenderTargetWriteMask = D3D11_COLOR_WRITE_ENABLE_ALL;
|
||||
hr = g_pd3dDevice->CreateBlendState(&blendDesc, &g_pGammaBlendState);
|
||||
if (FAILED(hr)) return false;
|
||||
|
||||
g_gammaPostProcessReady = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
void ApplyGammaPostProcess()
|
||||
{
|
||||
if (!g_gammaPostProcessReady) return;
|
||||
|
||||
if (g_gammaValue > 0.99f && g_gammaValue < 1.01f) return;
|
||||
|
||||
ID3D11DeviceContext* ctx = g_pImmediateContext;
|
||||
|
||||
ID3D11Texture2D* pBackBuffer = NULL;
|
||||
HRESULT hr = g_pSwapChain->GetBuffer(0, __uuidof(ID3D11Texture2D), (LPVOID*)&pBackBuffer);
|
||||
if (FAILED(hr)) return;
|
||||
ctx->CopyResource(g_pGammaOffscreenTex, pBackBuffer);
|
||||
|
||||
D3D11_MAPPED_SUBRESOURCE mapped;
|
||||
hr = ctx->Map(g_pGammaCB, 0, D3D11_MAP_WRITE_DISCARD, 0, &mapped);
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
GammaCBData* cb = (GammaCBData*)mapped.pData;
|
||||
cb->gamma = g_gammaValue;
|
||||
ctx->Unmap(g_pGammaCB, 0);
|
||||
}
|
||||
|
||||
ID3D11RenderTargetView* oldRTV = NULL;
|
||||
ID3D11DepthStencilView* oldDSV = NULL;
|
||||
ctx->OMGetRenderTargets(1, &oldRTV, &oldDSV);
|
||||
|
||||
UINT numViewports = 1;
|
||||
D3D11_VIEWPORT oldViewport;
|
||||
ctx->RSGetViewports(&numViewports, &oldViewport);
|
||||
|
||||
ID3D11RenderTargetView* bbRTV = g_pRenderTargetView;
|
||||
ctx->OMSetRenderTargets(1, &bbRTV, NULL);
|
||||
|
||||
// Set viewport to full screen
|
||||
D3D11_TEXTURE2D_DESC bbDesc;
|
||||
pBackBuffer->GetDesc(&bbDesc);
|
||||
pBackBuffer->Release();
|
||||
|
||||
D3D11_VIEWPORT vp;
|
||||
vp.Width = (FLOAT)bbDesc.Width;
|
||||
vp.Height = (FLOAT)bbDesc.Height;
|
||||
vp.MinDepth = 0.0f;
|
||||
vp.MaxDepth = 1.0f;
|
||||
vp.TopLeftX = 0;
|
||||
vp.TopLeftY = 0;
|
||||
ctx->RSSetViewports(1, &vp);
|
||||
|
||||
ctx->IASetInputLayout(NULL);
|
||||
ctx->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
|
||||
ctx->VSSetShader(g_pGammaVS, NULL, 0);
|
||||
ctx->PSSetShader(g_pGammaPS, NULL, 0);
|
||||
ctx->PSSetShaderResources(0, 1, &g_pGammaOffscreenSRV);
|
||||
ctx->PSSetSamplers(0, 1, &g_pGammaSampler);
|
||||
ctx->PSSetConstantBuffers(0, 1, &g_pGammaCB);
|
||||
ctx->RSSetState(g_pGammaRastState);
|
||||
ctx->OMSetDepthStencilState(g_pGammaDepthState, 0);
|
||||
float blendFactor[4] = { 0, 0, 0, 0 };
|
||||
ctx->OMSetBlendState(g_pGammaBlendState, blendFactor, 0xFFFFFFFF);
|
||||
|
||||
ctx->Draw(3, 0);
|
||||
|
||||
ID3D11ShaderResourceView* nullSRV = NULL;
|
||||
ctx->PSSetShaderResources(0, 1, &nullSRV);
|
||||
|
||||
ctx->OMSetRenderTargets(1, &oldRTV, oldDSV);
|
||||
ctx->RSSetViewports(1, &oldViewport);
|
||||
if (oldRTV) oldRTV->Release();
|
||||
if (oldDSV) oldDSV->Release();
|
||||
}
|
||||
|
||||
void CleanupGammaPostProcess()
|
||||
{
|
||||
if (g_pGammaBlendState) { g_pGammaBlendState->Release(); g_pGammaBlendState = NULL; }
|
||||
if (g_pGammaDepthState) { g_pGammaDepthState->Release(); g_pGammaDepthState = NULL; }
|
||||
if (g_pGammaRastState) { g_pGammaRastState->Release(); g_pGammaRastState = NULL; }
|
||||
if (g_pGammaSampler) { g_pGammaSampler->Release(); g_pGammaSampler = NULL; }
|
||||
if (g_pGammaCB) { g_pGammaCB->Release(); g_pGammaCB = NULL; }
|
||||
if (g_pGammaPS) { g_pGammaPS->Release(); g_pGammaPS = NULL; }
|
||||
if (g_pGammaVS) { g_pGammaVS->Release(); g_pGammaVS = NULL; }
|
||||
if (g_pGammaOffscreenRTV) { g_pGammaOffscreenRTV->Release(); g_pGammaOffscreenRTV = NULL; }
|
||||
if (g_pGammaOffscreenSRV) { g_pGammaOffscreenSRV->Release(); g_pGammaOffscreenSRV = NULL; }
|
||||
if (g_pGammaOffscreenTex) { g_pGammaOffscreenTex->Release(); g_pGammaOffscreenTex = NULL; }
|
||||
g_gammaPostProcessReady = false;
|
||||
}
|
||||
8
Minecraft.Client/Windows64/Windows64_PostProcess.h
Normal file
8
Minecraft.Client/Windows64/Windows64_PostProcess.h
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
#pragma once
|
||||
|
||||
#include <d3d11.h>
|
||||
|
||||
bool InitGammaPostProcess();
|
||||
void ApplyGammaPostProcess();
|
||||
void CleanupGammaPostProcess();
|
||||
void SetGammaValue(float gamma);
|
||||
28
Minecraft.Client/crt_compat.cpp
Normal file
28
Minecraft.Client/crt_compat.cpp
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
// CRT compatibility shim for linking VS2012-era libraries with VS2022
|
||||
// Provides symbols removed in the Universal CRT (VS2015+)
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
|
||||
// __iob_func was removed in VS2015. Old code (e.g. libpng) references it.
|
||||
// Provide a shim that returns the stdio file pointers.
|
||||
extern "C" FILE* __iob_func(void)
|
||||
{
|
||||
// The old __iob_func returned an array of {stdin, stdout, stderr}.
|
||||
// In the Universal CRT, these are functions, not a contiguous array.
|
||||
// We return a static array mimicking the old layout.
|
||||
static FILE iob[3];
|
||||
iob[0] = *stdin;
|
||||
iob[1] = *stdout;
|
||||
iob[2] = *stderr;
|
||||
return iob;
|
||||
}
|
||||
|
||||
// std::_Winerror_map was an internal MSVC runtime function used by
|
||||
// std::system_category::message(). Old .lib files compiled with VS2012
|
||||
// may reference it. Provide a minimal stub.
|
||||
namespace std {
|
||||
const char* _Winerror_map(int) {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
#include "stdafx.h"
|
||||
#include <xhash>
|
||||
#include <functional>
|
||||
|
||||
#include "Hasher.h"
|
||||
|
||||
|
|
@ -19,7 +20,11 @@ wstring Hasher::getHash(wstring &name)
|
|||
//return new BigInteger(1, m.digest()).toString(16);
|
||||
|
||||
// TODO 4J Stu - Will this hash us with the same distribution as the MD5?
|
||||
return _toString( hash_value( s ) );
|
||||
#if _MSC_VER >= 1900
|
||||
return _toString( std::hash<wstring>{}( s ) );
|
||||
#else
|
||||
return _toString( stdext::hash_value( s ) );
|
||||
#endif
|
||||
//}
|
||||
//catch (NoSuchAlgorithmException e)
|
||||
//{
|
||||
|
|
|
|||
|
|
@ -3,14 +3,15 @@
|
|||
#include "I18n.h"
|
||||
|
||||
Language *I18n::lang = Language::getInstance();
|
||||
wstring I18n::get(const wstring& id, ...)
|
||||
{
|
||||
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
|
||||
return L"";
|
||||
#elif _MSC_VER >= 1930 // VS2022+ also disallows va_start with reference types
|
||||
return id;
|
||||
#else
|
||||
va_list va;
|
||||
va_start(va, id);
|
||||
return I18n::get(id, va);
|
||||
return I18n::get(id, va);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -24,6 +24,8 @@ 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
|
||||
return L"";
|
||||
#elif _MSC_VER >= 1930 // VS2022+ also disallows va_start with reference types
|
||||
return elementId;
|
||||
#else
|
||||
va_list args;
|
||||
va_start(args, elementId);
|
||||
|
|
|
|||
|
|
@ -2560,9 +2560,11 @@ int Player::hash_fnct(const shared_ptr<Player> k)
|
|||
// TODO 4J Stu - Should we just be using the pointers and hashing them?
|
||||
#ifdef __PS3__
|
||||
return (int)boost::hash_value( k->name ); // 4J Stu - Names are completely unique?
|
||||
#elif _MSC_VER >= 1900
|
||||
return (int)std::hash<wstring>{}( k->name ); // 4J Stu - Names are completely unique?
|
||||
#else
|
||||
return (int)std::hash_value( k->name ); // 4J Stu - Names are completely unique?
|
||||
#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)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
# Minecraft LCEMP
|
||||
LCEMP is my Minecraft Legacy Console Edition source fork that enables LAN multiplayer hosting along side more complete pc compatibility.
|
||||
|
||||
If you use my multiplayer code or other fixes from this repo in other LCE-based projects, credit me (and the project) and link the repo
|
||||
|
||||
## notes:
|
||||
- This is NOT the full source code.
|
||||
- You need to provide the required asset files yourself.
|
||||
|
|
|
|||
1162
cmake/Sources.cmake
Normal file
1162
cmake/Sources.cmake
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue