forked from cafeberry/cafeberry
Compare commits
44
Commits
kbm
...
networking
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
faf3a3edea | ||
|
|
1e747b70e7 | ||
|
|
e16d566853 | ||
|
|
fc988df2cc | ||
|
|
ca4a561d07 | ||
|
|
1e47ff84a9 | ||
|
|
a2dad85bb1 | ||
|
|
0405a47bd1 | ||
|
|
0e7da09615 | ||
|
|
ad7dd528f7 | ||
|
|
83e11bdf9b | ||
|
|
5065c28b5c | ||
|
|
4e368283e1 | ||
|
|
4b962fcb21 | ||
|
|
a1541c590d | ||
|
|
9e3077c3bc | ||
|
|
494235878e | ||
|
|
feeff55924 | ||
|
|
f404e4b4e4 | ||
|
|
67a8111974 | ||
|
|
6853eab85f | ||
|
|
125819419f | ||
|
|
ebbd54288b | ||
|
|
92891de261 | ||
|
|
6167e04f82 | ||
|
|
0443166b6a | ||
|
|
4b0520c938 | ||
|
|
2840b7620b | ||
|
|
5451249347 | ||
|
|
de8bf25fbe | ||
|
|
64e95393c8 | ||
|
|
ea3621971f | ||
|
|
ce3e83039d | ||
|
|
42f09f93e5 | ||
|
|
9f8dab8ebb | ||
|
|
5ebaab0ac9 | ||
|
|
92209cf909 | ||
|
|
94f1cefcf9 | ||
|
|
e254228cf5 | ||
|
|
b87d044cf0 | ||
|
|
01abe05b18 | ||
|
|
2170209e26 | ||
|
|
991369547a | ||
|
|
dbd90a75c9 |
+11
-2
@@ -6,15 +6,24 @@
|
||||
/*Release*
|
||||
/*ContentPackage*
|
||||
|
||||
# Minecraft.Server
|
||||
/Minecraft.Server/x64
|
||||
/Minecraft.Server/x64_*
|
||||
/Minecraft.Server/*Debug
|
||||
/Minecraft.Server/*Release*
|
||||
/Minecraft.Server/*Server*
|
||||
/Minecraft.Server/*ContentPackage*
|
||||
|
||||
# Minecraft.Client
|
||||
/Minecraft.Client/x64
|
||||
/Minecraft.Client/x64_*
|
||||
/Minecraft.Client/*Debug
|
||||
/Minecraft.Client/*Release*
|
||||
/Minecraft.Client/*Server*
|
||||
/Minecraft.Client/*ContentPackage*
|
||||
/Minecraft.Client/Windows64/GameHDD
|
||||
|
||||
# Minecraft.world
|
||||
# Minecraft.World
|
||||
/Minecraft.World/x64
|
||||
/Minecraft.World/x64_*
|
||||
/Minecraft.World/*Debug
|
||||
@@ -43,4 +52,4 @@ Minecraft.Client/Common/Media/XURs
|
||||
*.opensdf
|
||||
*.v11.suo
|
||||
*.vcxproj.user
|
||||
*.aps
|
||||
*.aps
|
||||
|
||||
@@ -402,6 +402,7 @@ void Chunk::rebuild()
|
||||
}
|
||||
|
||||
Tile *tile = Tile::tiles[tileId];
|
||||
if (!tile) continue;
|
||||
if (currentLayer == 0 && tile->isEntityTile())
|
||||
{
|
||||
shared_ptr<TileEntity> et = region->getTileEntity(x, y, z);
|
||||
@@ -739,9 +740,9 @@ void Chunk::rebuild_SPU()
|
||||
{
|
||||
// 4J - get tile from those copied into our local array in earlier optimisation
|
||||
unsigned char tileId = pOutData->getTile(x,y,z);
|
||||
if (tileId > 0)
|
||||
if (tileId > 0 && tileId != 0xff)
|
||||
{
|
||||
if (currentLayer == 0 && Tile::tiles[tileId]->isEntityTile())
|
||||
if (currentLayer == 0 && Tile::tiles[tileId] && Tile::tiles[tileId]->isEntityTile())
|
||||
{
|
||||
shared_ptr<TileEntity> et = region.getTileEntity(x, y, z);
|
||||
if (TileEntityRenderDispatcher::instance->hasRenderer(et))
|
||||
@@ -754,6 +755,7 @@ void Chunk::rebuild_SPU()
|
||||
{
|
||||
|
||||
Tile *tile = Tile::tiles[tileId];
|
||||
if (!tile) continue;
|
||||
int renderLayer = tile->getRenderLayer();
|
||||
|
||||
if (renderLayer != currentLayer)
|
||||
|
||||
@@ -50,11 +50,16 @@
|
||||
#else
|
||||
#include "Common\UI\UI.h"
|
||||
#endif
|
||||
#ifdef __PS3__
|
||||
#if defined __PS3__ && !defined DISABLE_PSN
|
||||
#include "PS3/Network/SonyVoiceChat.h"
|
||||
#endif
|
||||
#include "DLCTexturePack.h"
|
||||
|
||||
#if defined _WINDOWS64 || defined DISABLE_PSN || defined _DISABLE_XBLIVE
|
||||
#include "Xbox\Network\NetworkPlayerXbox.h"
|
||||
#include "Common\Network\PlatformNetworkManager.h"
|
||||
#endif
|
||||
|
||||
#ifdef _DURANGO
|
||||
#include "..\Minecraft.World\DurangoStats.h"
|
||||
#include "..\Minecraft.World\GenericStats.h"
|
||||
@@ -298,6 +303,10 @@ void ClientConnection::handleLogin(shared_ptr<LoginPacket> packet)
|
||||
level->isClientSide = true;
|
||||
minecraft->setLevel(level);
|
||||
}
|
||||
else
|
||||
{
|
||||
level = (MultiPlayerLevel *)dimensionLevel;
|
||||
}
|
||||
|
||||
minecraft->player->setPlayerIndex( packet->m_playerIndex );
|
||||
minecraft->player->setCustomSkin( app.GetPlayerSkinId(m_userIndex) );
|
||||
@@ -771,6 +780,7 @@ void ClientConnection::handleAddPlayer(shared_ptr<AddPlayerPacket> packet)
|
||||
player->yRotp = packet->yRot;
|
||||
player->yHeadRot = packet->yHeadRot * 360 / 256.0f;
|
||||
player->setXuid(packet->xuid);
|
||||
player->setOnlineXuid(packet->OnlineXuid);
|
||||
|
||||
#ifdef _DURANGO
|
||||
// On Durango request player display name from network manager
|
||||
@@ -781,6 +791,32 @@ void ClientConnection::handleAddPlayer(shared_ptr<AddPlayerPacket> packet)
|
||||
player->m_displayName = player->name;
|
||||
#endif
|
||||
|
||||
#if defined _WINDOWS64 || defined DISABLE_PSN || defined _DISABLE_XBLIVE
|
||||
{
|
||||
PlayerUID netXuid = packet->OnlineXuid;
|
||||
const PlayerUID WIN64_XUID_BASE = (PlayerUID)0xe000d45248242f2e;
|
||||
if (netXuid >= WIN64_XUID_BASE && netXuid < WIN64_XUID_BASE + MINECRAFT_NET_MAX_PLAYERS)
|
||||
{
|
||||
BYTE smallId = (BYTE)(netXuid - WIN64_XUID_BASE);
|
||||
INetworkPlayer *np = g_NetworkManager.GetPlayerBySmallId(smallId);
|
||||
if (np != NULL)
|
||||
{
|
||||
NetworkPlayerXbox *npx = (NetworkPlayerXbox *)np;
|
||||
IQNetPlayer *qp = npx->GetQNetPlayer();
|
||||
if (qp != NULL)
|
||||
{
|
||||
wcsncpy(qp->m_gamertag, packet->name.c_str(), 31);
|
||||
qp->m_gamertag[31] = L'\0';
|
||||
if (g_NetworkManager.IsHost())
|
||||
{
|
||||
g_NetworkManager.UpdateAndSetGameSessionData();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// printf("\t\t\t\t%d: Add player\n",packet->id,packet->yRot);
|
||||
|
||||
int item = packet->carriedItem;
|
||||
@@ -1004,6 +1040,7 @@ void ClientConnection::handleChunkVisibility(shared_ptr<ChunkVisibilityPacket> p
|
||||
void ClientConnection::handleChunkTilesUpdate(shared_ptr<ChunkTilesUpdatePacket> packet)
|
||||
{
|
||||
// 4J - changed to encode level in packet
|
||||
if (packet->levelIdx >= minecraft->levels.length) return;
|
||||
MultiPlayerLevel *dimensionLevel = (MultiPlayerLevel *)minecraft->levels[packet->levelIdx];
|
||||
if( dimensionLevel )
|
||||
{
|
||||
@@ -1073,6 +1110,7 @@ void ClientConnection::handleChunkTilesUpdate(shared_ptr<ChunkTilesUpdatePacket>
|
||||
void ClientConnection::handleBlockRegionUpdate(shared_ptr<BlockRegionUpdatePacket> packet)
|
||||
{
|
||||
// 4J - changed to encode level in packet
|
||||
if (packet->levelIdx >= minecraft->levels.length) return;
|
||||
MultiPlayerLevel *dimensionLevel = (MultiPlayerLevel *)minecraft->levels[packet->levelIdx];
|
||||
if( dimensionLevel )
|
||||
{
|
||||
@@ -1130,6 +1168,8 @@ void ClientConnection::handleTileUpdate(shared_ptr<TileUpdatePacket> packet)
|
||||
destroyTilePacket = true;
|
||||
}
|
||||
// 4J - changed to encode level in packet
|
||||
if (packet->levelIdx >= minecraft->levels.length) return;
|
||||
|
||||
MultiPlayerLevel *dimensionLevel = (MultiPlayerLevel *)minecraft->levels[packet->levelIdx];
|
||||
if( dimensionLevel )
|
||||
{
|
||||
@@ -1769,6 +1809,7 @@ void ClientConnection::handleEntityActionAtPosition(shared_ptr<EntityActionAtPos
|
||||
|
||||
void ClientConnection::handlePreLogin(shared_ptr<PreLoginPacket> packet)
|
||||
{
|
||||
app.DebugPrintf("ClientConnection::handlePreLogin ENTER (user %d)\n", m_userIndex);
|
||||
// printf("Client: handlePreLogin\n");
|
||||
#if 1
|
||||
// 4J - Check that we can play with all the players already in the game who have Friends-Only UGC set
|
||||
@@ -1794,6 +1835,7 @@ void ClientConnection::handlePreLogin(shared_ptr<PreLoginPacket> packet)
|
||||
}
|
||||
|
||||
#ifdef _XBOX
|
||||
#if !defined(_DISABLE_XBLIVE)
|
||||
if(!g_NetworkManager.IsHost() && !app.GetGameHostOption(eGameHostOption_FriendsOfFriends))
|
||||
{
|
||||
if(m_userIndex == ProfileManager.GetPrimaryPad() )
|
||||
@@ -1937,6 +1979,16 @@ void ClientConnection::handlePreLogin(shared_ptr<PreLoginPacket> packet)
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
// Offline/system-link games have no Xbox Live friend list, so grant all
|
||||
// pre-login permissions (the Xbox Live-only checks above would otherwise
|
||||
// fail and reject the client's own pre-login before Login is ever sent).
|
||||
canPlay = TRUE;
|
||||
canPlayLocal = TRUE;
|
||||
isAtLeastOneFriend = TRUE;
|
||||
isFriendsWithHost = TRUE;
|
||||
cantPlayContentRestricted = FALSE;
|
||||
#endif // _DISABLE_XBLIVE
|
||||
#else
|
||||
// TODO - handle this kind of things for non-360 platforms
|
||||
canPlay = TRUE;
|
||||
@@ -1944,7 +1996,7 @@ void ClientConnection::handlePreLogin(shared_ptr<PreLoginPacket> packet)
|
||||
isAtLeastOneFriend = TRUE;
|
||||
cantPlayContentRestricted= FALSE;
|
||||
|
||||
#if ( defined __PS3__ || defined __ORBIS__ || defined __PSVITA__)
|
||||
#if !defined DISABLE_PSN && ( defined __PS3__ || defined __ORBIS__ || defined __PSVITA__)
|
||||
|
||||
if(!g_NetworkManager.IsHost() && !app.GetGameHostOption(eGameHostOption_FriendsOfFriends))
|
||||
{
|
||||
@@ -2226,7 +2278,8 @@ void ClientConnection::handlePreLogin(shared_ptr<PreLoginPacket> packet)
|
||||
}
|
||||
BOOL allAllowed, friendsAllowed;
|
||||
ProfileManager.AllowedPlayerCreatedContent(m_userIndex,true,&allAllowed,&friendsAllowed);
|
||||
send( shared_ptr<LoginPacket>( new LoginPacket(minecraft->user->name, SharedConstants::NETWORK_PROTOCOL_VERSION, offlineXUID, onlineXUID, (allAllowed!=TRUE && friendsAllowed==TRUE),
|
||||
app.DebugPrintf("ClientConnection::handlePreLogin SENDING LoginPacket (user %d)\n", m_userIndex);
|
||||
send( shared_ptr<LoginPacket>( new LoginPacket(minecraft->user->name, SharedConstants::NETWORK_PROTOCOL_VERSION, offlineXUID, onlineXUID, (allAllowed!=TRUE && friendsAllowed==TRUE),
|
||||
packet->m_ugcPlayersVersion, app.GetPlayerSkinId(m_userIndex), app.GetPlayerCapeId(m_userIndex), ProfileManager.IsGuest( m_userIndex ))));
|
||||
|
||||
if(!g_NetworkManager.IsHost() )
|
||||
@@ -2276,6 +2329,7 @@ void ClientConnection::handleAddMob(shared_ptr<AddMobPacket> packet)
|
||||
float xRot = packet->xRot * 360 / 256.0f;
|
||||
|
||||
shared_ptr<LivingEntity> mob = dynamic_pointer_cast<LivingEntity>(EntityIO::newById(packet->type, level));
|
||||
if (mob == NULL) return;
|
||||
mob->xp = packet->x;
|
||||
mob->yp = packet->y;
|
||||
mob->zp = packet->z;
|
||||
@@ -3519,10 +3573,12 @@ void ClientConnection::handleCustomPayload(shared_ptr<CustomPayloadPacket> custo
|
||||
}
|
||||
#else
|
||||
UIScene *scene = ui.GetTopScene(m_userIndex, eUILayer_Scene);
|
||||
UIScene_TradingMenu *screen = (UIScene_TradingMenu *)scene;
|
||||
trader = screen->getMerchant();
|
||||
UIScene_TradingMenu *screen = dynamic_cast<UIScene_TradingMenu *>(scene);
|
||||
if (screen != NULL)
|
||||
trader = screen->getMerchant();
|
||||
#endif
|
||||
|
||||
if (trader == NULL) return;
|
||||
MerchantRecipeList *recipeList = MerchantRecipeList::createFromStream(&input);
|
||||
trader->overrideOffers(recipeList);
|
||||
}
|
||||
|
||||
@@ -162,7 +162,7 @@ MOJANG_DATA;
|
||||
typedef struct
|
||||
{
|
||||
eDLCContentType eDLCType;
|
||||
#if defined( __PS3__) || defined(__ORBIS__) || defined (__PSVITA__)
|
||||
#if !defined(DISABLE_PSN) && (defined( __PS3__) || defined(__ORBIS__) || defined (__PSVITA__))
|
||||
char chImageURL[256];//SCE_NP_COMMERCE2_URL_LEN
|
||||
#else
|
||||
|
||||
|
||||
@@ -12,7 +12,8 @@ $directories = @(
|
||||
"PSVITA_GAME\Common\res",
|
||||
"PSVITA_GAME\Common\Media",
|
||||
"PSVITA_GAME\PSVita\Sound",
|
||||
"PSVITA_GAME\PSVita\Tutorial"
|
||||
"PSVITA_GAME\PSVita\Tutorial",
|
||||
"PSVITA_GAME\savedata"
|
||||
)
|
||||
|
||||
foreach ($dir in $directories) {
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
param(
|
||||
[string]$OutDir,
|
||||
[string]$ProjectDir
|
||||
)
|
||||
|
||||
Write-Host "Server Postbuild: script started. Output Directory: $OutDir, Project Directory: $ProjectDir"
|
||||
|
||||
$directories = @(
|
||||
"Windows64\GameHDD",
|
||||
"Common\Media",
|
||||
"Common\res",
|
||||
"redist64"
|
||||
)
|
||||
|
||||
foreach ($dir in $directories) {
|
||||
New-Item -ItemType Directory -Path (Join-Path $OutDir $dir) -Force | Out-Null
|
||||
}
|
||||
|
||||
$folderCopies = @(
|
||||
@{ Source = "Common\Media"; Dest = "Common\Media" },
|
||||
@{ Source = "Common\res"; Dest = "Common\res" },
|
||||
@{ Source = "Common\Postbuilds\Contents\Windows64\redist64"; Dest = "redist64" }
|
||||
)
|
||||
|
||||
foreach ($copy in $folderCopies) {
|
||||
$src = Join-Path "$ProjectDir\..\Minecraft.Client" $copy.Source
|
||||
$dst = Join-Path $OutDir $copy.Dest
|
||||
|
||||
if (Test-Path $src) {
|
||||
xcopy /q /y /i /s /e /d "$src" "$dst" 2>$null
|
||||
}
|
||||
}
|
||||
|
||||
$fileCopies = @(
|
||||
@{ Source = "Common\Postbuilds\Contents\Windows64\Effects.msscmp"; Dest = "Effects.msscmp" },
|
||||
@{ Source = "Common\Postbuilds\Contents\Windows64\iggy_w64.dll"; Dest = "iggy_w64.dll" },
|
||||
@{ Source = "Common\Postbuilds\Contents\Windows64\mss64.dll"; Dest = "mss64.dll" }
|
||||
)
|
||||
|
||||
foreach ($copy in $fileCopies) {
|
||||
$src = Join-Path "$ProjectDir\..\Minecraft.Client" $copy.Source
|
||||
$dst = Join-Path $OutDir $copy.Dest
|
||||
if (Test-Path $src) {
|
||||
Copy-Item -Path $src -Destination $dst -Force
|
||||
}
|
||||
}
|
||||
|
||||
$deleteDirs = @(
|
||||
"Common\Media\Sound",
|
||||
"Common\Media\Graphics",
|
||||
"Common\Media\de-DE",
|
||||
"Common\Media\es-ES",
|
||||
"Common\Media\fr-FR",
|
||||
"Common\Media\it-IT",
|
||||
"Common\Media\ja-JP",
|
||||
"Common\Media\ko-KR",
|
||||
"Common\Media\pt-BR",
|
||||
"Common\Media\pt-PT",
|
||||
"Common\Media\zh-CHT"
|
||||
)
|
||||
|
||||
foreach ($dir in $deleteDirs) {
|
||||
$path = Join-Path $OutDir $dir
|
||||
if (Test-Path $path) {
|
||||
Remove-Item $path -Recurse -Force -ErrorAction SilentlyContinue
|
||||
}
|
||||
}
|
||||
|
||||
$delDirs = @(
|
||||
"Common\Media",
|
||||
"Common\Media\font"
|
||||
)
|
||||
|
||||
foreach ($dir in $delDirs) {
|
||||
if ($delDirs -contains $dir) {
|
||||
$path = Join-Path $OutDir $dir
|
||||
if (Test-Path $path) {
|
||||
Get-ChildItem -Path $path -Recurse -Include *.swf, *.txt, *.resx, *.xml, *.loc, *.lang, *.col, *.h, *.xui, *.abc, "Mojang Font_7.ttf", "Mojang Font_11.ttf", MediaDurango.arc, MediaOrbis.arc, MediaPS3.arc, MediaPSVita.arc -File |
|
||||
Remove-Item -Force -ErrorAction SilentlyContinue
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,15 +1,27 @@
|
||||
#include "stdafx.h"
|
||||
#if defined(_WINDOWS64) && defined(MINECRAFT_SERVER_BUILD)
|
||||
#include "../../Minecraft.Server/ServerLogManager.h"
|
||||
#endif
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
// Name: DebugSpewV()
|
||||
// Desc: Internal helper function
|
||||
//--------------------------------------------------------------------------------------
|
||||
#ifndef _CONTENT_PACKAGE
|
||||
static VOID DebugSpewV( const CHAR* strFormat, const va_list pArgList )
|
||||
static VOID DebugSpewV( const CHAR* strFormat, va_list pArgList )
|
||||
{
|
||||
#if defined __PS3__ || defined __ORBIS__ || defined __PSVITA__
|
||||
assert(0);
|
||||
#else
|
||||
#if defined(_WINDOWS64) && defined(MINECRAFT_SERVER_BUILD)
|
||||
// Dedicated server routes legacy debug spew through ServerLogger to preserve CLI prompt handling.
|
||||
if (ServerRuntime::ServerLogManager::ShouldForwardClientDebugLogs())
|
||||
{
|
||||
ServerRuntime::ServerLogManager::ForwardClientDebugSpewLogV(strFormat, pArgList);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
CHAR str[2048];
|
||||
// Use the secure CRT to avoid buffer overruns. Specify a count of
|
||||
// _TRUNCATE so that too long strings will be silently truncated
|
||||
|
||||
@@ -30,6 +30,9 @@
|
||||
#include "GameRules\ConsoleGameRules.h"
|
||||
#include "GameRules\ConsoleSchematicFile.h"
|
||||
#include "..\User.h"
|
||||
#if defined(_WINDOWS64) && defined(MINECRAFT_SERVER_BUILD)
|
||||
#include "..\..\Minecraft.Server\ServerLogManager.h"
|
||||
#endif
|
||||
#include "..\\EntityRenderDispatcher.h"
|
||||
#include "..\TexturePackRepository.h"
|
||||
#include "..\DLCTexturePack.h"
|
||||
@@ -230,12 +233,21 @@ void CMinecraftApp::DebugPrintf(const char *szFormat, ...)
|
||||
{
|
||||
|
||||
#ifndef _FINAL_BUILD
|
||||
char buf[1024];
|
||||
va_list ap;
|
||||
va_start(ap, szFormat);
|
||||
vsnprintf(buf, sizeof(buf), szFormat, ap);
|
||||
va_end(ap);
|
||||
OutputDebugStringA(buf);
|
||||
va_list ap;
|
||||
va_start(ap, szFormat);
|
||||
#if defined(_WINDOWS64) && defined(MINECRAFT_SERVER_BUILD)
|
||||
// Dedicated server routes client debug spew through ServerLogger so CLI output stays prompt-safe.
|
||||
if (ServerRuntime::ServerLogManager::ShouldForwardClientDebugLogs())
|
||||
{
|
||||
ServerRuntime::ServerLogManager::ForwardClientAppDebugLogV(szFormat, ap);
|
||||
va_end(ap);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
char buf[1024];
|
||||
vsnprintf(buf, sizeof(buf), szFormat, ap);
|
||||
va_end(ap);
|
||||
OutputDebugStringA(buf);
|
||||
#endif
|
||||
|
||||
}
|
||||
@@ -243,13 +255,22 @@ void CMinecraftApp::DebugPrintf(const char *szFormat, ...)
|
||||
void CMinecraftApp::DebugPrintf(int user, const char *szFormat, ...)
|
||||
{
|
||||
#ifndef _FINAL_BUILD
|
||||
if(user == USER_NONE)
|
||||
return;
|
||||
char buf[1024];
|
||||
va_list ap;
|
||||
va_start(ap, szFormat);
|
||||
vsnprintf(buf, sizeof(buf), szFormat, ap);
|
||||
va_end(ap);
|
||||
if(user == USER_NONE)
|
||||
return;
|
||||
va_list ap;
|
||||
va_start(ap, szFormat);
|
||||
#if defined(_WINDOWS64) && defined(MINECRAFT_SERVER_BUILD)
|
||||
// Dedicated server routes client debug spew through ServerLogger so CLI output stays prompt-safe.
|
||||
if (ServerRuntime::ServerLogManager::ShouldForwardClientDebugLogs())
|
||||
{
|
||||
ServerRuntime::ServerLogManager::ForwardClientUserDebugLogV(user, szFormat, ap);
|
||||
va_end(ap);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
char buf[1024];
|
||||
vsnprintf(buf, sizeof(buf), szFormat, ap);
|
||||
va_end(ap);
|
||||
#ifdef __PS3__
|
||||
unsigned int writelen;
|
||||
sys_tty_write(SYS_TTYP_USER1 + ( user - 1 ), buf, strlen(buf), &writelen );
|
||||
@@ -4889,11 +4910,13 @@ void CMinecraftApp::SignInChangeCallback(LPVOID pParam,bool bPrimaryPlayerChange
|
||||
// 4J Stu - On PS4 we can also cause to exit players if they are signed out here, but we shouldn't do that if
|
||||
// we are going to switch to an offline game as it will likely crash due to incompatible parallel processes
|
||||
bool switchToOffline = false;
|
||||
#ifndef _DISABLE_XBLIVE
|
||||
// If it's an online game, and the primary profile is no longer signed into LIVE then we act as if disconnected
|
||||
if( !ProfileManager.IsSignedInLive( ProfileManager.GetLockedProfile() ) && !g_NetworkManager.IsLocalGame() )
|
||||
{
|
||||
switchToOffline = true;
|
||||
}
|
||||
#endif
|
||||
|
||||
//printf("Old: %x, New: %x, Changed: %x\n", m_ulLastSignInData, ulSignInData, changedPlayers);
|
||||
for(unsigned int i = 0; i < XUSER_MAX_COUNT; ++i)
|
||||
@@ -4958,6 +4981,7 @@ void CMinecraftApp::SignInChangeCallback(LPVOID pParam,bool bPrimaryPlayerChange
|
||||
|
||||
g_NetworkManager.HandleSignInChange();
|
||||
}
|
||||
#ifndef _DISABLE_XBLIVE
|
||||
// Some menus require the player to be signed in to live, so if this callback happens and the primary player is
|
||||
// no longer signed in then nav back
|
||||
else if ( pApp->GetLiveLinkRequired() && !ProfileManager.IsSignedInLive( ProfileManager.GetLockedProfile() ) )
|
||||
@@ -4969,6 +4993,7 @@ void CMinecraftApp::SignInChangeCallback(LPVOID pParam,bool bPrimaryPlayerChange
|
||||
pApp->SetAction(iPrimaryPlayer,eAppAction_EthernetDisconnected);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if ( defined __PS3__ || defined __ORBIS__ || defined _DURANGO || defined __PSVITA__ )
|
||||
// 4J-JEV: Need to kick of loading of profile data for sub-sign in players.
|
||||
@@ -5094,6 +5119,9 @@ void CMinecraftApp::NotificationsCallback(LPVOID pParam,DWORD dwNotification, un
|
||||
#if defined __PS3__ || defined __PSVITA__ || defined __ORBIS__
|
||||
int CMinecraftApp::MustSignInFullVersionPurchaseReturned(void *pParam,int iPad,C4JStorage::EMessageResult result)
|
||||
{
|
||||
#ifdef DISABLE_PSN
|
||||
return 0;
|
||||
#else
|
||||
if(result==C4JStorage::EMessage_ResultAccept)
|
||||
{
|
||||
#ifdef __PS3__
|
||||
@@ -5106,11 +5134,15 @@ int CMinecraftApp::MustSignInFullVersionPurchaseReturned(void *pParam,int iPad,C
|
||||
}
|
||||
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined __PS3__ || defined __PSVITA__ || defined __ORBIS__
|
||||
int CMinecraftApp::MustSignInFullVersionPurchaseReturnedExitTrial(void *pParam,int iPad,C4JStorage::EMessageResult result)
|
||||
{
|
||||
#ifdef DISABLE_PSN
|
||||
return 0;
|
||||
#else
|
||||
if(result==C4JStorage::EMessage_ResultAccept)
|
||||
{
|
||||
#ifdef __PS3__
|
||||
@@ -5126,6 +5158,7 @@ int CMinecraftApp::MustSignInFullVersionPurchaseReturnedExitTrial(void *pParam,i
|
||||
app.SetAction(iPad,eAppAction_ExitWorldTrial);
|
||||
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -6777,7 +6810,7 @@ wstring CMinecraftApp::GetIconReplacement(unsigned int uiIcon)
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined(__PS3__) || defined(__ORBIS__) || defined (__PSVITA__)
|
||||
#if !defined(DISABLE_PSN) && (defined(__PS3__) || defined(__ORBIS__) || defined (__PSVITA__))
|
||||
unordered_map<PlayerUID, MOJANG_DATA *, PlayerUID::Hash> CMinecraftApp::MojangData;
|
||||
unordered_map<int, char * > CMinecraftApp::DLCTextures_PackID;
|
||||
unordered_map<string, DLC_INFO * > CMinecraftApp::DLCInfo;
|
||||
@@ -6788,6 +6821,12 @@ unordered_map<int, wstring > CMinecraftApp::DLCTextures_PackID; // for mash-up
|
||||
//unordered_map<ULONGLONG,DLC_INFO * > CMinecraftApp::DLCInfo_Trial; // full offerid, dlc_info
|
||||
unordered_map<wstring,DLC_INFO * > CMinecraftApp::DLCInfo_Full; // full offerid, dlc_info
|
||||
unordered_map<wstring, wstring > CMinecraftApp::DLCInfo_SkinName; // skin name, full offer id
|
||||
#elif defined(DISABLE_PSN)
|
||||
unordered_map<PlayerUID, MOJANG_DATA *, PlayerUID::Hash> CMinecraftApp::MojangData;
|
||||
unordered_map<int, ULONGLONG > CMinecraftApp::DLCTextures_PackID;
|
||||
unordered_map<ULONGLONG, DLC_INFO * > CMinecraftApp::DLCInfo_Trial;
|
||||
unordered_map<ULONGLONG, DLC_INFO * > CMinecraftApp::DLCInfo_Full;
|
||||
unordered_map<wstring, ULONGLONG > CMinecraftApp::DLCInfo_SkinName;
|
||||
#else
|
||||
unordered_map<PlayerUID, MOJANG_DATA *> CMinecraftApp::MojangData;
|
||||
unordered_map<int, ULONGLONG > CMinecraftApp::DLCTextures_PackID;
|
||||
@@ -6870,7 +6909,7 @@ HRESULT CMinecraftApp::RegisterConfigValues(WCHAR *pType, int iValue)
|
||||
return hr;
|
||||
}
|
||||
|
||||
#if (defined _XBOX || defined _WINDOWS64)
|
||||
#if (defined _XBOX || defined _WINDOWS64 || defined DISABLE_PSN)
|
||||
HRESULT CMinecraftApp::RegisterDLCData(WCHAR *pType, WCHAR *pBannerName, int iGender, __uint64 ullOfferID_Full, __uint64 ullOfferID_Trial, WCHAR *pFirstSkin, unsigned int uiSortIndex, int iConfig, WCHAR *pDataFile)
|
||||
{
|
||||
HRESULT hr=S_OK;
|
||||
@@ -6887,12 +6926,20 @@ HRESULT CMinecraftApp::RegisterDLCData(WCHAR *pType, WCHAR *pBannerName, int iGe
|
||||
// ignore the names if we don't recognize them
|
||||
if(pBannerName!=L"")
|
||||
{
|
||||
#ifdef __PSVITA__
|
||||
wcsncpy_s( pDLCData->wchBanner, MAX_BANNERNAME_SIZE, pBannerName, MAX_BANNERNAME_SIZE);
|
||||
#else
|
||||
wcsncpy_s( pDLCData->wchBanner, pBannerName, MAX_BANNERNAME_SIZE);
|
||||
#endif
|
||||
}
|
||||
|
||||
if(pDataFile[0]!=0)
|
||||
{
|
||||
#ifdef __PSVITA__
|
||||
wcsncpy_s( pDLCData->wchDataFile, MAX_BANNERNAME_SIZE, pDataFile, MAX_BANNERNAME_SIZE);
|
||||
#else
|
||||
wcsncpy_s( pDLCData->wchDataFile, pDataFile, MAX_BANNERNAME_SIZE);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -7062,7 +7109,7 @@ HRESULT CMinecraftApp::RegisterDLCData(char *pchDLCName, unsigned int uiSortInde
|
||||
|
||||
|
||||
|
||||
#if defined( __PS3__) || defined(__ORBIS__) || defined(__PSVITA__)
|
||||
#if !defined(DISABLE_PSN) && (defined( __PS3__) || defined(__ORBIS__) || defined(__PSVITA__))
|
||||
bool CMinecraftApp::GetDLCFullOfferIDForSkinID(const wstring &FirstSkin,ULONGLONG *pullVal)
|
||||
{
|
||||
AUTO_VAR(it, DLCInfo_SkinName.find(FirstSkin));
|
||||
@@ -7330,7 +7377,7 @@ DLC_INFO *CMinecraftApp::GetDLCInfoForProductName(WCHAR *pwchProductName)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#elif defined(__PS3__) || defined(__ORBIS__) || defined (__PSVITA__)
|
||||
#elif !defined(DISABLE_PSN) && (defined(__PS3__) || defined(__ORBIS__) || defined (__PSVITA__))
|
||||
#else
|
||||
|
||||
DLC_INFO *CMinecraftApp::GetDLCInfoForFullOfferID(ULONGLONG ullOfferID_Full)
|
||||
@@ -9441,7 +9488,7 @@ byteArray CMinecraftApp::getArchiveFile(const wstring &filename)
|
||||
|
||||
// DLC
|
||||
|
||||
#if defined(__PS3__) || defined(__ORBIS__) || defined (__PSVITA__)
|
||||
#if !defined(DISABLE_PSN) && (defined(__PS3__) || defined(__ORBIS__) || defined (__PSVITA__))
|
||||
int CMinecraftApp::GetDLCInfoCount()
|
||||
{
|
||||
return (int)DLCInfo.size();
|
||||
|
||||
@@ -594,7 +594,7 @@ public:
|
||||
MOJANG_DATA *GetMojangDataForXuid(PlayerUID xuid);
|
||||
static HRESULT RegisterConfigValues(WCHAR *pType, int iValue);
|
||||
|
||||
#if defined(__PS3__) || defined(__ORBIS__) || defined(__PSVITA__)
|
||||
#if !defined(DISABLE_PSN) && (defined(__PS3__) || defined(__ORBIS__) || defined(__PSVITA__))
|
||||
HRESULT RegisterDLCData(char *pchDLCName, unsigned int uiSortIndex, char *pchImageURL);
|
||||
bool GetDLCFullOfferIDForSkinID(const wstring &FirstSkin,ULONGLONG *pullVal);
|
||||
DLC_INFO *GetDLCInfoForTrialOfferID(ULONGLONG ullOfferID_Trial);
|
||||
@@ -631,7 +631,7 @@ private:
|
||||
|
||||
std::vector <SCreditTextItemDef *> vDLCCredits;
|
||||
|
||||
#if defined(__PS3__) || defined(__ORBIS__) || defined (__PSVITA__)
|
||||
#if !defined(DISABLE_PSN) && (defined(__PS3__) || defined(__ORBIS__) || defined (__PSVITA__))
|
||||
static unordered_map<PlayerUID,MOJANG_DATA *, PlayerUID::Hash > MojangData;
|
||||
static unordered_map<int, char * > DLCTextures_PackID; // for mash-up packs & texture packs
|
||||
static unordered_map<string,DLC_INFO * > DLCInfo;
|
||||
@@ -642,6 +642,12 @@ private:
|
||||
//static unordered_map<wstring,DLC_INFO * > DLCInfo_Trial; // full offerid, dlc_info
|
||||
static unordered_map<wstring,DLC_INFO * > DLCInfo_Full; // full offerid, dlc_info
|
||||
static unordered_map<wstring, wstring > DLCInfo_SkinName; // skin name, full offer id
|
||||
#elif defined(DISABLE_PSN)
|
||||
static unordered_map<PlayerUID,MOJANG_DATA *, PlayerUID::Hash > MojangData;
|
||||
static unordered_map<int, ULONGLONG > DLCTextures_PackID; // for mash-up packs & texture packs
|
||||
static unordered_map<ULONGLONG,DLC_INFO * > DLCInfo_Trial; // full offerid, dlc_info
|
||||
static unordered_map<ULONGLONG,DLC_INFO * > DLCInfo_Full; // full offerid, dlc_info
|
||||
static unordered_map<wstring, ULONGLONG > DLCInfo_SkinName; // skin name, full offer id
|
||||
#else
|
||||
static unordered_map<PlayerUID,MOJANG_DATA * > MojangData;
|
||||
static unordered_map<int, ULONGLONG > DLCTextures_PackID; // for mash-up packs & texture packs
|
||||
@@ -772,7 +778,7 @@ public:
|
||||
void ClearTMSPPFilesRetrieved();
|
||||
unsigned int AddTMSPPFileTypeRequest(eDLCContentType eType, bool bPromote=false);
|
||||
int GetDLCInfoTexturesOffersCount();
|
||||
#if defined( __PS3__) || defined(__ORBIS__) || defined(__PSVITA__)
|
||||
#if !defined(DISABLE_PSN) && (defined( __PS3__) || defined(__ORBIS__) || defined(__PSVITA__))
|
||||
DLC_INFO *GetDLCInfo(int iIndex);
|
||||
DLC_INFO *GetDLCInfo(char *);
|
||||
DLC_INFO *GetDLCInfoFromTPackID(int iTPID);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
base64.cpp and base64.h
|
||||
|
||||
Copyright (C) 2004-2008 René Nyffenegger
|
||||
Copyright (C) 2004-2008 René Nyffenegger
|
||||
|
||||
This source code is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the author be held liable for any damages
|
||||
@@ -21,7 +21,7 @@
|
||||
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
René Nyffenegger rene.nyffenegger@adp-gmbh.ch
|
||||
René Nyffenegger rene.nyffenegger@adp-gmbh.ch
|
||||
|
||||
*/
|
||||
|
||||
@@ -41,7 +41,7 @@ static inline bool is_base64(unsigned char c) {
|
||||
}
|
||||
|
||||
// 4J ADDED,
|
||||
std::string base64_encode(std::string str)
|
||||
std::string base64_encode(const std::string& str)
|
||||
{
|
||||
return base64_encode( reinterpret_cast<const unsigned char*>(str.c_str()), str.length() );
|
||||
}
|
||||
|
||||
@@ -2,6 +2,6 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
std::string base64_encode(std::string str);
|
||||
std::string base64_encode(const std::string& str);
|
||||
std::string base64_encode(unsigned char const* , unsigned int len);
|
||||
std::string base64_decode(std::string const& s);
|
||||
@@ -70,9 +70,9 @@ void CGameNetworkManager::Initialise()
|
||||
ServerStoppedCreate( false );
|
||||
ServerReadyCreate( false );
|
||||
int flagIndexSize = LevelRenderer::getGlobalChunkCount() / (Level::maxBuildHeight / 16); // dividing here by number of renderer chunks in one column
|
||||
#ifdef _XBOX
|
||||
#if !defined(_DISABLE_XBLIVE) && defined _XBOX
|
||||
s_pPlatformNetworkManager = new CPlatformNetworkManagerXbox();
|
||||
#elif defined __PS3__ || defined __ORBIS__ || defined __PSVITA__
|
||||
#elif !defined(DISABLE_PSN) && (defined __PS3__ || defined __ORBIS__ || defined __PSVITA__)
|
||||
s_pPlatformNetworkManager = new CPlatformNetworkManagerSony();
|
||||
#elif defined _DURANGO
|
||||
s_pPlatformNetworkManager = new CPlatformNetworkManagerDurango();
|
||||
@@ -104,12 +104,14 @@ void CGameNetworkManager::DoWork()
|
||||
{
|
||||
case XN_LIVE_LINK_STATE_CHANGED:
|
||||
{
|
||||
#ifndef _DISABLE_XBLIVE
|
||||
int iPrimaryPlayer = g_NetworkManager.GetPrimaryPad();
|
||||
bool bConnected = (pNotification->uiParam!=0)?true:false;
|
||||
if((g_NetworkManager.GetLockedProfile()!=-1) && iPrimaryPlayer!=-1 && bConnected == false && g_NetworkManager.IsInSession() )
|
||||
{
|
||||
app.SetAction(iPrimaryPlayer,eAppAction_EthernetDisconnected);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
case XN_LIVE_INVITE_ACCEPTED:
|
||||
@@ -171,6 +173,11 @@ bool CGameNetworkManager::_RunNetworkGame(LPVOID lpParameter)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Client needs QNET_STATE_GAME_PLAY so that IsInGameplay() returns true
|
||||
s_pPlatformNetworkManager->SetGamePlayState();
|
||||
}
|
||||
|
||||
if( g_NetworkManager.IsLeavingGame() ) return false;
|
||||
|
||||
@@ -340,10 +347,12 @@ bool CGameNetworkManager::StartNetworkGame(Minecraft *minecraft, LPVOID lpParame
|
||||
|
||||
// 4J Stu - Wait a while to make sure that DLC is loaded. This is the last point before the network communication starts
|
||||
// so the latest we can check this
|
||||
#ifndef DISABLE_PSN
|
||||
while( !app.DLCInstallProcessCompleted() && app.DLCInstallPending() && !g_NetworkManager.IsLeavingGame() )
|
||||
{
|
||||
Sleep( 10 );
|
||||
}
|
||||
#endif
|
||||
if( g_NetworkManager.IsLeavingGame() )
|
||||
{
|
||||
MinecraftServer::HaltServer();
|
||||
@@ -353,12 +362,24 @@ bool CGameNetworkManager::StartNetworkGame(Minecraft *minecraft, LPVOID lpParame
|
||||
// PRIMARY PLAYER
|
||||
|
||||
vector<ClientConnection *> createdConnections;
|
||||
ClientConnection *connection;
|
||||
ClientConnection *connection = NULL;
|
||||
|
||||
if( g_NetworkManager.IsHost() )
|
||||
#ifdef MINECRAFT_SERVER_BUILD
|
||||
{
|
||||
app.DebugPrintf("Dedicated server mode: skipping local host client connection\n");
|
||||
|
||||
// Keep telemetry behavior consistent with the host path.
|
||||
INT multiplayerInstanceId = TelemetryManager->GenerateMultiplayerInstanceId();
|
||||
TelemetryManager->SetMultiplayerInstanceId(multiplayerInstanceId);
|
||||
|
||||
app.SetGameMode( eMode_Multiplayer );
|
||||
}
|
||||
#else
|
||||
{
|
||||
connection = new ClientConnection(minecraft, NULL);
|
||||
}
|
||||
#endif
|
||||
else
|
||||
{
|
||||
INetworkPlayer *pNetworkPlayer = g_NetworkManager.GetLocalPlayerByUserIndex(ProfileManager.GetLockedProfile());
|
||||
@@ -384,155 +405,159 @@ bool CGameNetworkManager::StartNetworkGame(Minecraft *minecraft, LPVOID lpParame
|
||||
connection = new ClientConnection(minecraft, socket);
|
||||
}
|
||||
|
||||
if( !connection->createdOk )
|
||||
if (connection != NULL)
|
||||
{
|
||||
assert(false);
|
||||
delete connection;
|
||||
connection = NULL;
|
||||
MinecraftServer::HaltServer();
|
||||
return false;
|
||||
}
|
||||
|
||||
connection->send( shared_ptr<PreLoginPacket>( new PreLoginPacket(minecraft->user->name) ) );
|
||||
|
||||
// Tick connection until we're ready to go. The stages involved in this are:
|
||||
// (1) Creating the ClientConnection sends a prelogin packet to the server
|
||||
// (2) the server sends a prelogin back, which is handled by the clientConnection, and returns a login packet
|
||||
// (3) the server sends a login back, which is handled by the client connection to start the game
|
||||
if( !g_NetworkManager.IsHost() )
|
||||
{
|
||||
Minecraft::GetInstance()->progressRenderer->progressStart(IDS_PROGRESS_CONNECTING);
|
||||
}
|
||||
else
|
||||
{
|
||||
// 4J Stu - Host needs to generate a unique multiplayer id for sentient telemetry reporting
|
||||
INT multiplayerInstanceId = TelemetryManager->GenerateMultiplayerInstanceId();
|
||||
TelemetryManager->SetMultiplayerInstanceId(multiplayerInstanceId);
|
||||
}
|
||||
TexturePack *tPack = Minecraft::GetInstance()->skins->getSelected();
|
||||
do
|
||||
{
|
||||
app.DebugPrintf("ticking connection A\n");
|
||||
connection->tick();
|
||||
|
||||
// 4J Stu - We were ticking this way too fast which could cause the connection to time out
|
||||
// The connections should tick at 20 per second
|
||||
Sleep(50);
|
||||
} while ( (IsInSession() && !connection->isStarted() && !connection->isClosed() && !g_NetworkManager.IsLeavingGame()) || tPack->isLoadingData() || (Minecraft::GetInstance()->skins->needsUIUpdate() || ui.IsReloadingSkins()) );
|
||||
ui.CleanUpSkinsReload();
|
||||
|
||||
// 4J Stu - Fix for #11279 - CRASH: TCR 001: BAS Game Stability: Signing out of game will cause title to crash
|
||||
// We need to break out of the above loop if m_bLeavingGame is set, and close the connection
|
||||
if( g_NetworkManager.IsLeavingGame() || !IsInSession() )
|
||||
{
|
||||
connection->close();
|
||||
}
|
||||
|
||||
if( connection->isStarted() && !connection->isClosed() )
|
||||
{
|
||||
createdConnections.push_back( connection );
|
||||
|
||||
int primaryPad = ProfileManager.GetPrimaryPad();
|
||||
app.SetRichPresenceContext(primaryPad,CONTEXT_GAME_STATE_BLANK);
|
||||
if (GetPlayerCount() > 1) // Are we offline or online, and how many players are there
|
||||
if( !connection->createdOk )
|
||||
{
|
||||
if (IsLocalGame()) ProfileManager.SetCurrentGameActivity(primaryPad,CONTEXT_PRESENCE_MULTIPLAYEROFFLINE,false);
|
||||
else ProfileManager.SetCurrentGameActivity(primaryPad,CONTEXT_PRESENCE_MULTIPLAYER,false);
|
||||
assert(false);
|
||||
delete connection;
|
||||
connection = NULL;
|
||||
MinecraftServer::HaltServer();
|
||||
return false;
|
||||
}
|
||||
|
||||
connection->send( shared_ptr<PreLoginPacket>( new PreLoginPacket(minecraft->user->name) ) );
|
||||
|
||||
// Tick connection until we're ready to go. The stages involved in this are:
|
||||
// (1) Creating the ClientConnection sends a prelogin packet to the server
|
||||
// (2) the server sends a prelogin back, which is handled by the clientConnection, and returns a login packet
|
||||
// (3) the server sends a login back, which is handled by the client connection to start the game
|
||||
if( !g_NetworkManager.IsHost() )
|
||||
{
|
||||
Minecraft::GetInstance()->progressRenderer->progressStart(IDS_PROGRESS_CONNECTING);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(IsLocalGame()) ProfileManager.SetCurrentGameActivity(primaryPad,CONTEXT_PRESENCE_MULTIPLAYER_1POFFLINE,false);
|
||||
else ProfileManager.SetCurrentGameActivity(primaryPad,CONTEXT_PRESENCE_MULTIPLAYER_1P,false);
|
||||
// 4J Stu - Host needs to generate a unique multiplayer id for sentient telemetry reporting
|
||||
INT multiplayerInstanceId = TelemetryManager->GenerateMultiplayerInstanceId();
|
||||
TelemetryManager->SetMultiplayerInstanceId(multiplayerInstanceId);
|
||||
}
|
||||
TexturePack *tPack = Minecraft::GetInstance()->skins->getSelected();
|
||||
do
|
||||
{
|
||||
app.DebugPrintf("ticking connection A\n");
|
||||
connection->tick();
|
||||
|
||||
// 4J Stu - We were ticking this way too fast which could cause the connection to time out
|
||||
// The connections should tick at 20 per second
|
||||
Sleep(50);
|
||||
} while ( (IsInSession() && !connection->isStarted() && !connection->isClosed() && !g_NetworkManager.IsLeavingGame()) || tPack->isLoadingData() || (Minecraft::GetInstance()->skins->needsUIUpdate() || ui.IsReloadingSkins()) );
|
||||
ui.CleanUpSkinsReload();
|
||||
|
||||
// 4J Stu - Fix for #11279 - CRASH: TCR 001: BAS Game Stability: Signing out of game will cause title to crash
|
||||
// We need to break out of the above loop if m_bLeavingGame is set, and close the connection
|
||||
if( g_NetworkManager.IsLeavingGame() || !IsInSession() )
|
||||
{
|
||||
connection->close();
|
||||
}
|
||||
|
||||
|
||||
// ALL OTHER LOCAL PLAYERS
|
||||
for(int idx = 0; idx < XUSER_MAX_COUNT; ++idx)
|
||||
if( connection->isStarted() && !connection->isClosed() )
|
||||
{
|
||||
// Already have setup the primary pad
|
||||
if(idx == ProfileManager.GetPrimaryPad() ) continue;
|
||||
|
||||
if( GetLocalPlayerByUserIndex(idx) != NULL && !ProfileManager.IsSignedIn(idx) )
|
||||
{
|
||||
INetworkPlayer *pNetworkPlayer = g_NetworkManager.GetLocalPlayerByUserIndex(idx);
|
||||
Socket *socket = pNetworkPlayer->GetSocket();
|
||||
app.DebugPrintf("Closing socket due to player %d not being signed in any more\n");
|
||||
if( !socket->close(false) ) socket->close(true);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
// By default when we host we only have the local player, but currently allow multiple local players to join
|
||||
// when joining any other way, so just because they are signed in doesn't mean they are in the session
|
||||
// 4J Stu - If they are in the session, then we should add them to the game. Otherwise we won't be able to add them later
|
||||
INetworkPlayer *pNetworkPlayer = g_NetworkManager.GetLocalPlayerByUserIndex(idx);
|
||||
if( pNetworkPlayer == NULL )
|
||||
continue;
|
||||
|
||||
ClientConnection *connection;
|
||||
|
||||
Socket *socket = pNetworkPlayer->GetSocket();
|
||||
connection = new ClientConnection(minecraft, socket, idx);
|
||||
|
||||
minecraft->addPendingLocalConnection(idx, connection);
|
||||
//minecraft->createExtraLocalPlayer(idx, (convStringToWstring( ProfileManager.GetGamertag(idx) )).c_str(), idx, connection);
|
||||
|
||||
// Open the socket on the server end to accept incoming data
|
||||
Socket::addIncomingSocket(socket);
|
||||
|
||||
connection->send( shared_ptr<PreLoginPacket>( new PreLoginPacket(convStringToWstring( ProfileManager.GetGamertag(idx) )) ) );
|
||||
|
||||
createdConnections.push_back( connection );
|
||||
|
||||
// Tick connection until we're ready to go. The stages involved in this are:
|
||||
// (1) Creating the ClientConnection sends a prelogin packet to the server
|
||||
// (2) the server sends a prelogin back, which is handled by the clientConnection, and returns a login packet
|
||||
// (3) the server sends a login back, which is handled by the client connection to start the game
|
||||
do
|
||||
int primaryPad = ProfileManager.GetPrimaryPad();
|
||||
app.SetRichPresenceContext(primaryPad,CONTEXT_GAME_STATE_BLANK);
|
||||
if (GetPlayerCount() > 1) // Are we offline or online, and how many players are there
|
||||
{
|
||||
// We need to keep ticking the connections for players that already logged in
|
||||
for(AUTO_VAR(it, createdConnections.begin()); it < createdConnections.end(); ++it)
|
||||
{
|
||||
(*it)->tick();
|
||||
}
|
||||
|
||||
// 4J Stu - We were ticking this way too fast which could cause the connection to time out
|
||||
// The connections should tick at 20 per second
|
||||
Sleep(50);
|
||||
app.DebugPrintf("<***> %d %d %d %d %d\n",IsInSession(), !connection->isStarted(),!connection->isClosed(),ProfileManager.IsSignedIn(idx),!g_NetworkManager.IsLeavingGame());
|
||||
#if defined _XBOX || __PS3__
|
||||
} while (IsInSession() && !connection->isStarted() && !connection->isClosed() && ProfileManager.IsSignedIn(idx) && !g_NetworkManager.IsLeavingGame() );
|
||||
#else
|
||||
// TODO - This SHOULD be something just like the code above but temporarily changing here so that we don't have to depend on the profilemanager behaviour
|
||||
} while (IsInSession() && !connection->isStarted() && !connection->isClosed() && !g_NetworkManager.IsLeavingGame() );
|
||||
#endif
|
||||
|
||||
// 4J Stu - Fix for #11279 - CRASH: TCR 001: BAS Game Stability: Signing out of game will cause title to crash
|
||||
// We need to break out of the above loop if m_bLeavingGame is set, and stop creating new connections
|
||||
// The connections in the createdConnections vector get closed at the end of the thread
|
||||
if( g_NetworkManager.IsLeavingGame() || !IsInSession() ) break;
|
||||
|
||||
if( ProfileManager.IsSignedIn(idx) && !connection->isClosed() )
|
||||
{
|
||||
app.SetRichPresenceContext(idx,CONTEXT_GAME_STATE_BLANK);
|
||||
if (IsLocalGame()) ProfileManager.SetCurrentGameActivity(idx,CONTEXT_PRESENCE_MULTIPLAYEROFFLINE,false);
|
||||
else ProfileManager.SetCurrentGameActivity(idx,CONTEXT_PRESENCE_MULTIPLAYER,false);
|
||||
if (IsLocalGame()) ProfileManager.SetCurrentGameActivity(primaryPad,CONTEXT_PRESENCE_MULTIPLAYEROFFLINE,false);
|
||||
else ProfileManager.SetCurrentGameActivity(primaryPad,CONTEXT_PRESENCE_MULTIPLAYER,false);
|
||||
}
|
||||
else
|
||||
{
|
||||
connection->close();
|
||||
AUTO_VAR(it, find( createdConnections.begin(), createdConnections.end(), connection ));
|
||||
if(it != createdConnections.end() ) createdConnections.erase( it );
|
||||
if(IsLocalGame()) ProfileManager.SetCurrentGameActivity(primaryPad,CONTEXT_PRESENCE_MULTIPLAYER_1POFFLINE,false);
|
||||
else ProfileManager.SetCurrentGameActivity(primaryPad,CONTEXT_PRESENCE_MULTIPLAYER_1P,false);
|
||||
}
|
||||
}
|
||||
|
||||
app.SetGameMode( eMode_Multiplayer );
|
||||
}
|
||||
else if ( connection->isClosed() || !IsInSession())
|
||||
{
|
||||
// assert(false);
|
||||
MinecraftServer::HaltServer();
|
||||
return false;
|
||||
|
||||
// ALL OTHER LOCAL PLAYERS
|
||||
for(int idx = 0; idx < XUSER_MAX_COUNT; ++idx)
|
||||
{
|
||||
// Already have setup the primary pad
|
||||
if(idx == ProfileManager.GetPrimaryPad() ) continue;
|
||||
|
||||
if( GetLocalPlayerByUserIndex(idx) != NULL && !ProfileManager.IsSignedIn(idx) )
|
||||
{
|
||||
INetworkPlayer *pNetworkPlayer = g_NetworkManager.GetLocalPlayerByUserIndex(idx);
|
||||
Socket *socket = pNetworkPlayer->GetSocket();
|
||||
app.DebugPrintf("Closing socket due to player %d not being signed in any more\n");
|
||||
if( !socket->close(false) ) socket->close(true);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
// By default when we host we only have the local player, but currently allow multiple local players to join
|
||||
// when joining any other way, so just because they are signed in doesn't mean they are in the session
|
||||
// 4J Stu - If they are in the session, then we should add them to the game. Otherwise we won't be able to add them later
|
||||
INetworkPlayer *pNetworkPlayer = g_NetworkManager.GetLocalPlayerByUserIndex(idx);
|
||||
if( pNetworkPlayer == NULL )
|
||||
continue;
|
||||
|
||||
ClientConnection *connection;
|
||||
|
||||
Socket *socket = pNetworkPlayer->GetSocket();
|
||||
connection = new ClientConnection(minecraft, socket, idx);
|
||||
|
||||
minecraft->addPendingLocalConnection(idx, connection);
|
||||
//minecraft->createExtraLocalPlayer(idx, (convStringToWstring( ProfileManager.GetGamertag(idx) )).c_str(), idx, connection);
|
||||
|
||||
// Open the socket on the server end to accept incoming data
|
||||
Socket::addIncomingSocket(socket);
|
||||
|
||||
connection->send( shared_ptr<PreLoginPacket>( new PreLoginPacket(convStringToWstring( ProfileManager.GetGamertag(idx) )) ) );
|
||||
|
||||
createdConnections.push_back( connection );
|
||||
|
||||
// Tick connection until we're ready to go. The stages involved in this are:
|
||||
// (1) Creating the ClientConnection sends a prelogin packet to the server
|
||||
// (2) the server sends a prelogin back, which is handled by the clientConnection, and returns a login packet
|
||||
// (3) the server sends a login back, which is handled by the client connection to start the game
|
||||
do
|
||||
{
|
||||
// We need to keep ticking the connections for players that already logged in
|
||||
for(AUTO_VAR(it, createdConnections.begin()); it < createdConnections.end(); ++it)
|
||||
{
|
||||
(*it)->tick();
|
||||
}
|
||||
|
||||
// 4J Stu - We were ticking this way too fast which could cause the connection to time out
|
||||
// The connections should tick at 20 per second
|
||||
Sleep(50);
|
||||
app.DebugPrintf("<***> %d %d %d %d %d\n",IsInSession(), !connection->isStarted(),!connection->isClosed(),ProfileManager.IsSignedIn(idx),!g_NetworkManager.IsLeavingGame());
|
||||
#if defined _XBOX || defined __PS3__ && !defined DISABLE_PSN
|
||||
} while (IsInSession() && !connection->isStarted() && !connection->isClosed() && ProfileManager.IsSignedIn(idx) && !g_NetworkManager.IsLeavingGame() );
|
||||
#else
|
||||
// TODO - This SHOULD be something just like the code above but temporarily changing here so that we don't have to depend on the profilemanager behaviour
|
||||
} while (IsInSession() && !connection->isStarted() && !connection->isClosed() && !g_NetworkManager.IsLeavingGame() );
|
||||
#endif
|
||||
|
||||
// 4J Stu - Fix for #11279 - CRASH: TCR 001: BAS Game Stability: Signing out of game will cause title to crash
|
||||
// We need to break out of the above loop if m_bLeavingGame is set, and stop creating new connections
|
||||
// The connections in the createdConnections vector get closed at the end of the thread
|
||||
if( g_NetworkManager.IsLeavingGame() || !IsInSession() ) break;
|
||||
|
||||
if( ProfileManager.IsSignedIn(idx) && !connection->isClosed() )
|
||||
{
|
||||
app.SetRichPresenceContext(idx,CONTEXT_GAME_STATE_BLANK);
|
||||
if (IsLocalGame()) ProfileManager.SetCurrentGameActivity(idx,CONTEXT_PRESENCE_MULTIPLAYEROFFLINE,false);
|
||||
else ProfileManager.SetCurrentGameActivity(idx,CONTEXT_PRESENCE_MULTIPLAYER,false);
|
||||
}
|
||||
else
|
||||
{
|
||||
connection->close();
|
||||
AUTO_VAR(it, find( createdConnections.begin(), createdConnections.end(), connection ));
|
||||
if(it != createdConnections.end() ) createdConnections.erase( it );
|
||||
}
|
||||
}
|
||||
|
||||
app.SetGameMode( eMode_Multiplayer );
|
||||
}
|
||||
else if ( connection->isClosed() || !IsInSession())
|
||||
{
|
||||
// assert(false);
|
||||
|
||||
MinecraftServer::HaltServer();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -542,7 +567,7 @@ bool CGameNetworkManager::StartNetworkGame(Minecraft *minecraft, LPVOID lpParame
|
||||
{
|
||||
(*it)->close();
|
||||
}
|
||||
// assert(false);
|
||||
//assert(false);
|
||||
MinecraftServer::HaltServer();
|
||||
return false;
|
||||
}
|
||||
@@ -779,7 +804,11 @@ int CGameNetworkManager::JoinFromInvite_SignInReturned(void *pParam,bool bContin
|
||||
|
||||
app.DebugPrintf("JoinFromInvite_SignInReturned, iPad %d\n",iPad);
|
||||
// It's possible that the player has not signed in - they can back out
|
||||
#ifndef _DISABLE_XBLIVE
|
||||
if(ProfileManager.IsSignedIn(iPad) && ProfileManager.IsSignedInLive(iPad) )
|
||||
#else
|
||||
if(ProfileManager.IsSignedIn(iPad))
|
||||
#endif
|
||||
{
|
||||
app.DebugPrintf("JoinFromInvite_SignInReturned, passed sign-in tests\n");
|
||||
int localUsersMask = 0;
|
||||
@@ -791,14 +820,16 @@ int CGameNetworkManager::JoinFromInvite_SignInReturned(void *pParam,bool bContin
|
||||
if(ProfileManager.IsSignedIn(index) )
|
||||
{
|
||||
++joiningUsers;
|
||||
#ifndef _DISABLE_XBLIVE
|
||||
if( !ProfileManager.AllowedToPlayMultiplayer(index) ) noPrivileges = true;
|
||||
#endif
|
||||
localUsersMask |= GetLocalPlayerMask( index );
|
||||
}
|
||||
}
|
||||
|
||||
// Check if user-created content is allowed, as we cannot play multiplayer if it's not
|
||||
bool noUGC = false;
|
||||
#if defined(__PS3__) || defined(__PSVITA__)
|
||||
#if !defined(DISABLE_PSN) && (defined(__PS3__) || defined(__PSVITA__))
|
||||
ProfileManager.GetChatAndContentRestrictions(iPad,false,&noUGC,NULL,NULL);
|
||||
#elif defined(__ORBIS__)
|
||||
ProfileManager.GetChatAndContentRestrictions(iPad,false,NULL,&noUGC,NULL);
|
||||
@@ -887,6 +918,12 @@ bool CGameNetworkManager::IsNetworkThreadRunning()
|
||||
|
||||
int CGameNetworkManager::RunNetworkGameThreadProc( void* lpParameter )
|
||||
{
|
||||
if( g_NetworkManager.m_bNetworkThreadRunning )
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
g_NetworkManager.m_bNetworkThreadRunning = true;
|
||||
|
||||
// Share AABB & Vec3 pools with default (main thread) - should be ok as long as we don't tick the main thread whilst this thread is running
|
||||
AABB::UseDefaultThreadStorage();
|
||||
Vec3::UseDefaultThreadStorage();
|
||||
@@ -894,7 +931,6 @@ int CGameNetworkManager::RunNetworkGameThreadProc( void* lpParameter )
|
||||
Tile::CreateNewThreadStorage();
|
||||
IntCache::CreateNewThreadStorage();
|
||||
|
||||
g_NetworkManager.m_bNetworkThreadRunning = true;
|
||||
bool success = g_NetworkManager._RunNetworkGame(lpParameter);
|
||||
g_NetworkManager.m_bNetworkThreadRunning = false;
|
||||
if( !success)
|
||||
@@ -902,7 +938,7 @@ int CGameNetworkManager::RunNetworkGameThreadProc( void* lpParameter )
|
||||
TexturePack *tPack = Minecraft::GetInstance()->skins->getSelected();
|
||||
while ( tPack->isLoadingData() || (Minecraft::GetInstance()->skins->needsUIUpdate() || ui.IsReloadingSkins()) )
|
||||
{
|
||||
Sleep(1);
|
||||
Sleep(0);
|
||||
}
|
||||
ui.CleanUpSkinsReload();
|
||||
if(app.GetDisconnectReason() == DisconnectPacket::eDisconnect_None)
|
||||
@@ -939,7 +975,7 @@ int CGameNetworkManager::ServerThreadProc( void* lpParameter )
|
||||
{
|
||||
while((Minecraft::GetInstance()->skins->needsUIUpdate() || ui.IsReloadingSkins()))
|
||||
{
|
||||
Sleep(1);
|
||||
Sleep(0);
|
||||
}
|
||||
param->levelGen->loadBaseSaveData();
|
||||
}
|
||||
@@ -981,7 +1017,7 @@ int CGameNetworkManager::ExitAndJoinFromInviteThreadProc( void* lpParam )
|
||||
|
||||
while( g_NetworkManager.IsInSession() )
|
||||
{
|
||||
Sleep(1);
|
||||
Sleep(0);
|
||||
}
|
||||
|
||||
// Xbox should always be online when receiving invites - on PS3 we need to check & ask the user to sign in
|
||||
@@ -1011,6 +1047,9 @@ int CGameNetworkManager::ExitAndJoinFromInviteThreadProc( void* lpParam )
|
||||
// The pair of methods MustSignInReturned_0 & PSNSignInReturned_0 handle this
|
||||
int CGameNetworkManager::MustSignInReturned_0(void *pParam,int iPad,C4JStorage::EMessageResult result)
|
||||
{
|
||||
#ifdef DISABLE_PSN
|
||||
return 0;
|
||||
#else
|
||||
if(result==C4JStorage::EMessage_ResultAccept)
|
||||
{
|
||||
#ifdef __PS3__
|
||||
@@ -1029,10 +1068,14 @@ int CGameNetworkManager::MustSignInReturned_0(void *pParam,int iPad,C4JStorage::
|
||||
}
|
||||
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
int CGameNetworkManager::PSNSignInReturned_0(void* pParam, bool bContinue, int iPad)
|
||||
{
|
||||
#ifdef DISABLE_PSN
|
||||
return 0;
|
||||
#else
|
||||
JoinFromInviteData *inviteData = (JoinFromInviteData *)pParam;
|
||||
|
||||
// If the invite data isn't set up yet (indicated by it being all zeroes, easiest detected via the net version), then try and get it again... this can happen if we got
|
||||
@@ -1065,12 +1108,16 @@ int CGameNetworkManager::PSNSignInReturned_0(void* pParam, bool bContinue, int i
|
||||
}
|
||||
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
// This case happens when we were in the main menus when we got an invite, and weren't signed in... now can proceed with the normal flow of code for this situation
|
||||
// The pair of methods MustSignInReturned_1 & PSNSignInReturned_1 handle this
|
||||
int CGameNetworkManager::MustSignInReturned_1(void *pParam,int iPad,C4JStorage::EMessageResult result)
|
||||
{
|
||||
#ifdef DISABLE_PSN
|
||||
return 0;
|
||||
#else
|
||||
if(result==C4JStorage::EMessage_ResultAccept)
|
||||
{
|
||||
#ifdef __PS3__
|
||||
@@ -1082,10 +1129,14 @@ int CGameNetworkManager::MustSignInReturned_1(void *pParam,int iPad,C4JStorage::
|
||||
#endif
|
||||
}
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
int CGameNetworkManager::PSNSignInReturned_1(void* pParam, bool bContinue, int iPad)
|
||||
{
|
||||
#ifdef DISABLE_PSN
|
||||
return 0;
|
||||
#else
|
||||
INVITE_INFO *inviteInfo = (INVITE_INFO *)pParam;
|
||||
|
||||
// If the invite data isn't set up yet (indicated by it being all zeroes, easiest detected via the net version), then try and get it again... this can happen if we got
|
||||
@@ -1113,6 +1164,7 @@ int CGameNetworkManager::PSNSignInReturned_1(void* pParam, bool bContinue, int i
|
||||
}
|
||||
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1241,7 +1293,7 @@ int CGameNetworkManager::ChangeSessionTypeThreadProc( void* lpParam )
|
||||
// wait for the current session to end
|
||||
while( g_NetworkManager.IsInSession() )
|
||||
{
|
||||
Sleep(1);
|
||||
Sleep(0);
|
||||
}
|
||||
|
||||
// Reset this flag as the we don't need to know that we only lost the room only from this point onwards, the behaviour is exactly the same
|
||||
@@ -1450,7 +1502,7 @@ void CGameNetworkManager::StateChange_AnyToEnding(bool bStateWasPlaying)
|
||||
if(pNetworkPlayer != NULL && ProfileManager.IsSignedIn( i ) )
|
||||
{
|
||||
app.DebugPrintf("Stats save for an offline game for the player at index %d\n", i );
|
||||
Minecraft::GetInstance()->forceStatsSave(pNetworkPlayer->GetUserIndex());
|
||||
//Minecraft::GetInstance()->forceStatsSave(pNetworkPlayer->GetUserIndex());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1483,7 +1535,10 @@ void CGameNetworkManager::CreateSocket( INetworkPlayer *pNetworkPlayer, bool loc
|
||||
Minecraft *pMinecraft = Minecraft::GetInstance();
|
||||
|
||||
Socket *socket = NULL;
|
||||
shared_ptr<MultiplayerLocalPlayer> mpPlayer = pMinecraft->localplayers[pNetworkPlayer->GetUserIndex()];
|
||||
shared_ptr<MultiplayerLocalPlayer> mpPlayer = nullptr;
|
||||
int userIdx = pNetworkPlayer->GetUserIndex();
|
||||
if (userIdx >= 0 && userIdx < XUSER_MAX_COUNT)
|
||||
mpPlayer = pMinecraft->localplayers[userIdx];
|
||||
if( localPlayer && mpPlayer != NULL && mpPlayer->connection != NULL)
|
||||
{
|
||||
// If we already have a MultiplayerLocalPlayer here then we are doing a session type change
|
||||
@@ -1643,6 +1698,7 @@ void CGameNetworkManager::GameInviteReceived( int userIndex, const INVITE_INFO *
|
||||
{
|
||||
if (ProfileManager.IsSignedIn(i) && (i == ProfileManager.GetPrimaryPad() || isLocalMultiplayerAvailable))
|
||||
{
|
||||
#ifndef _DISABLE_XBLIVE
|
||||
if (isSignedInLive && !ProfileManager.IsSignedInLive(i))
|
||||
{
|
||||
// Record the first non signed in live pad
|
||||
@@ -1650,6 +1706,9 @@ void CGameNetworkManager::GameInviteReceived( int userIndex, const INVITE_INFO *
|
||||
}
|
||||
|
||||
isSignedInLive = isSignedInLive && ProfileManager.IsSignedInLive(i);
|
||||
#else
|
||||
isSignedInLive = true;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1721,7 +1780,9 @@ void CGameNetworkManager::GameInviteReceived( int userIndex, const INVITE_INFO *
|
||||
if(index==userIndex || pMinecraft->localplayers[index]!=NULL )
|
||||
{
|
||||
++joiningUsers;
|
||||
#ifndef _DISABLE_XBLIVE
|
||||
if( !ProfileManager.AllowedToPlayMultiplayer(index) ) noPrivileges = true;
|
||||
#endif
|
||||
localUsersMask |= GetLocalPlayerMask( index );
|
||||
}
|
||||
}
|
||||
@@ -1793,7 +1854,7 @@ void CGameNetworkManager::GameInviteReceived( int userIndex, const INVITE_INFO *
|
||||
#endif
|
||||
if( !g_NetworkManager.IsInSession() )
|
||||
{
|
||||
#if defined (__PS3__) || defined (__PSVITA__)
|
||||
#if !defined(DISABLE_PSN) && (defined (__PS3__) || defined (__PSVITA__))
|
||||
// PS3 is more complicated here - we need to make sure that the player is online. If they are then we can do the same as the xbox, if not we need to try and get them online and then, if they do sign in, go down the same path
|
||||
|
||||
// Determine why they're not "signed in live"
|
||||
@@ -1825,7 +1886,7 @@ void CGameNetworkManager::GameInviteReceived( int userIndex, const INVITE_INFO *
|
||||
// joinData->pInviteInfo = pInviteInfo;
|
||||
|
||||
// tell the app to process this
|
||||
#ifdef __PSVITA__
|
||||
#if !defined(DISABLE_PSN) && defined(__PSVITA__)
|
||||
if(((CPlatformNetworkManagerSony*)s_pPlatformNetworkManager)->checkValidInviteData(pInviteInfo))
|
||||
#endif
|
||||
{
|
||||
@@ -1876,6 +1937,7 @@ void CGameNetworkManager::HandleInviteWhenInMenus( int userIndex, const INVITE_I
|
||||
if(!app.IsLocalMultiplayerAvailable())
|
||||
#endif
|
||||
{
|
||||
#ifndef _DISABLE_XBLIVE
|
||||
bool noPrivileges=!ProfileManager.AllowedToPlayMultiplayer(userIndex);
|
||||
|
||||
if(noPrivileges)
|
||||
@@ -1886,6 +1948,7 @@ void CGameNetworkManager::HandleInviteWhenInMenus( int userIndex, const INVITE_I
|
||||
}
|
||||
else
|
||||
{
|
||||
#endif
|
||||
ProfileManager.SetLockedProfile(userIndex);
|
||||
ProfileManager.SetPrimaryPad(userIndex);
|
||||
|
||||
@@ -1908,7 +1971,9 @@ void CGameNetworkManager::HandleInviteWhenInMenus( int userIndex, const INVITE_I
|
||||
{
|
||||
app.DebugPrintf( "Failed joining game from invite\n" );
|
||||
}
|
||||
#ifndef _DISABLE_XBLIVE
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1943,7 +2008,7 @@ void CGameNetworkManager::HandleDisconnect(bool bLostRoomOnly)
|
||||
if((g_NetworkManager.GetLockedProfile()!=-1) && iPrimaryPlayer!=-1 && g_NetworkManager.IsInSession() )
|
||||
{
|
||||
m_bLastDisconnectWasLostRoomOnly = bLostRoomOnly;
|
||||
#if defined __PS3__ || defined __PSVITA__ || defined __ORBIS__
|
||||
#if !defined(DISABLE_PSN) && (defined __PS3__ || defined __PSVITA__ || defined __ORBIS__)
|
||||
m_bSignedOutofPSN=bPSNSignout;
|
||||
#endif
|
||||
app.SetAction(iPrimaryPlayer,eAppAction_EthernetDisconnected);
|
||||
@@ -2068,7 +2133,7 @@ void CGameNetworkManager::FakeLocalPlayerJoined()
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __PSVITA__
|
||||
#if !defined(DISABLE_PSN) && defined(__PSVITA__)
|
||||
bool CGameNetworkManager::usingAdhocMode()
|
||||
{
|
||||
return ((CPlatformNetworkManagerSony*)s_pPlatformNetworkManager)->usingAdhocMode();
|
||||
@@ -2083,5 +2148,17 @@ void CGameNetworkManager::startAdhocMatching()
|
||||
{
|
||||
((CPlatformNetworkManagerSony*)s_pPlatformNetworkManager)->startAdhocMatching();
|
||||
}
|
||||
#elif defined(__PSVITA__)
|
||||
bool CGameNetworkManager::usingAdhocMode()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void CGameNetworkManager::setAdhocMode(bool bAdhoc)
|
||||
{
|
||||
}
|
||||
|
||||
void CGameNetworkManager::startAdhocMatching()
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,17 +1,19 @@
|
||||
#pragma once
|
||||
using namespace std;
|
||||
#include <vector>
|
||||
#ifndef _DISABLE_XBLIVE
|
||||
#include <qnet.h>
|
||||
#endif
|
||||
#include "..\..\..\Minecraft.World\C4JThread.h"
|
||||
#include "NetworkPlayerInterface.h"
|
||||
#ifdef _XBOX
|
||||
#if defined _XBOX && !defined _DISABLE_XBLIVE
|
||||
#include "..\..\Xbox\Network\PlatformNetworkManagerXbox.h"
|
||||
#elif defined __PS3__ || defined __ORBIS__ || defined __PSVITA__
|
||||
#elif !defined DISABLE_PSN && (defined __PS3__ || defined __ORBIS__ || defined __PSVITA__)
|
||||
#include "..\..\Common\Network\Sony\PlatformNetworkManagerSony.h"
|
||||
#elif defined _DURANGO
|
||||
#include "..\..\Durango\Network\PlatformNetworkManagerDurango.h"
|
||||
#else
|
||||
#include "PlatformNetworkManagerStub.h"
|
||||
#include "PlatformNetworkManager.h"
|
||||
#endif
|
||||
#include "SessionInfo.h"
|
||||
|
||||
@@ -30,9 +32,9 @@ const int NON_QNET_SENDDATA_ACK_REQUIRED = 1;
|
||||
|
||||
class CGameNetworkManager
|
||||
{
|
||||
#ifdef _XBOX
|
||||
#if defined _XBOX && !defined _DISABLE_XBLIVE
|
||||
friend class CPlatformNetworkManagerXbox;
|
||||
#elif defined __PS3__ || defined __ORBIS__ || defined __PSVITA__
|
||||
#elif !defined DISABLE_PSN && (defined __PS3__ || defined __ORBIS__ || defined __PSVITA__)
|
||||
friend class CPlatformNetworkManagerSony;
|
||||
#elif defined _DURANGO
|
||||
friend class CPlatformNetworkManagerDurango;
|
||||
|
||||
@@ -0,0 +1,94 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
const int QNET_GETSENDQUEUESIZE_SECONDARY_TYPE = 0;
|
||||
const int QNET_GETSENDQUEUESIZE_MESSAGES = 0;
|
||||
const int QNET_GETSENDQUEUESIZE_BYTES = 0;
|
||||
|
||||
const int QNET_SENDDATA_LOW_PRIORITY = 0;
|
||||
const int QNET_SENDDATA_SECONDARY = 0;
|
||||
|
||||
const int QNET_SENDDATA_RELIABLE = 0;
|
||||
const int QNET_SENDDATA_SEQUENTIAL = 0;
|
||||
|
||||
#define QNET_E_SESSION_FULL 0
|
||||
#define QNET_USER_MASK_USER0 1
|
||||
#define QNET_USER_MASK_USER1 2
|
||||
#define QNET_USER_MASK_USER2 4
|
||||
#define QNET_USER_MASK_USER3 8
|
||||
|
||||
typedef enum _QNET_STATE
|
||||
{
|
||||
QNET_STATE_IDLE,
|
||||
QNET_STATE_SESSION_HOSTING,
|
||||
QNET_STATE_SESSION_JOINING,
|
||||
QNET_STATE_GAME_LOBBY,
|
||||
QNET_STATE_SESSION_REGISTERING,
|
||||
QNET_STATE_SESSION_STARTING,
|
||||
QNET_STATE_GAME_PLAY,
|
||||
QNET_STATE_SESSION_ENDING,
|
||||
QNET_STATE_SESSION_LEAVING,
|
||||
QNET_STATE_SESSION_DELETING
|
||||
} QNET_STATE, * PQNET_STATE;
|
||||
|
||||
class IQNetPlayer
|
||||
{
|
||||
public:
|
||||
BYTE GetSmallId();
|
||||
void SendData(IQNetPlayer *player, const void *pvData, DWORD dwDataSize, DWORD dwFlags);
|
||||
bool IsSameSystem(IQNetPlayer *player);
|
||||
DWORD GetSendQueueSize( IQNetPlayer *player, DWORD dwFlags );
|
||||
DWORD GetCurrentRtt();
|
||||
bool IsHost();
|
||||
bool IsGuest();
|
||||
bool IsLocal();
|
||||
PlayerUID GetXuid();
|
||||
LPCWSTR GetGamertag();
|
||||
int GetSessionIndex();
|
||||
bool IsTalking();
|
||||
bool IsMutedByLocalUser(DWORD dwUserIndex);
|
||||
bool HasVoice();
|
||||
bool HasCamera();
|
||||
int GetUserIndex();
|
||||
void SetCustomDataValue(ULONG_PTR ulpCustomDataValue);
|
||||
ULONG_PTR GetCustomDataValue();
|
||||
|
||||
BYTE m_smallId;
|
||||
bool m_isRemote;
|
||||
bool m_isHostPlayer;
|
||||
wchar_t m_gamertag[32];
|
||||
private:
|
||||
ULONG_PTR m_customData;
|
||||
};
|
||||
|
||||
void Win64_SetupRemoteQNetPlayer(IQNetPlayer *player, BYTE smallId, bool isHost, bool isLocal);
|
||||
|
||||
class IQNetCallbacks
|
||||
{
|
||||
};
|
||||
|
||||
class IQNetGameSearch
|
||||
{
|
||||
};
|
||||
|
||||
class IQNet
|
||||
{
|
||||
public:
|
||||
HRESULT AddLocalPlayerByUserIndex(DWORD dwUserIndex);
|
||||
IQNetPlayer *GetHostPlayer();
|
||||
IQNetPlayer *GetLocalPlayerByUserIndex(DWORD dwUserIndex);
|
||||
IQNetPlayer *GetPlayerByIndex(DWORD dwPlayerIndex);
|
||||
IQNetPlayer *GetPlayerBySmallId(BYTE SmallId);
|
||||
IQNetPlayer *GetPlayerByXuid(PlayerUID xuid);
|
||||
DWORD GetPlayerCount();
|
||||
QNET_STATE GetState();
|
||||
bool IsHost();
|
||||
HRESULT JoinGameFromInviteInfo(DWORD dwUserIndex, DWORD dwUserMask, const INVITE_INFO *pInviteInfo);
|
||||
void HostGame();
|
||||
void ClientJoinGame();
|
||||
void EndGame();
|
||||
|
||||
static IQNetPlayer m_player[MINECRAFT_NET_MAX_PLAYERS];
|
||||
static DWORD s_playerCount;
|
||||
static bool s_isHosting;
|
||||
};
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,248 @@
|
||||
#pragma once
|
||||
|
||||
#if defined _WINDOWS64
|
||||
#include <WinSock2.h>
|
||||
#include <WS2tcpip.h>
|
||||
#elif defined _XBOX
|
||||
#include <stdint.h>
|
||||
#include <winsockx.h>
|
||||
#include <xtl.h>
|
||||
#elif defined __PS3__ || defined __ORBIS__
|
||||
#include <sys/socket.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/tcp.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/select.h>
|
||||
#elif defined __PSVITA__
|
||||
#include <net.h>
|
||||
#endif
|
||||
|
||||
#ifdef __PS3__
|
||||
#include <netex/net.h>
|
||||
#include <netex/errno.h>
|
||||
#endif
|
||||
|
||||
#include "SocketManagers\NetworkSocketManager.h"
|
||||
|
||||
#include <vector>
|
||||
#include "..\..\Common\Network\NetworkPlayerInterface.h"
|
||||
|
||||
#ifdef _WINDOWS64
|
||||
#pragma comment(lib, "Ws2_32.lib")
|
||||
#endif
|
||||
|
||||
#define NETWORK_LAN_DEFAULT_PORT 25565
|
||||
#define NETWORK_LAN_MAX_CLIENTS 7
|
||||
#define NETWORK_LAN_SMALLID_REJECT 0xFF
|
||||
#define NETWORK_LAN_RECV_BUFFER_SIZE 65536
|
||||
#define NETWORK_LAN_MAX_PACKET_SIZE (3 * 1024 * 1024)
|
||||
#define NETWORK_LAN_DISCOVERY_PORT 25566
|
||||
#define NETWORK_LAN_BROADCAST_MAGIC 0x4D434C4E
|
||||
#define NETWORK_LAN_BROADCAST_PLAYERS 8
|
||||
|
||||
#ifdef __PS3__
|
||||
typedef int SOCKET;
|
||||
#define INVALID_SOCKET -1
|
||||
#define closesocket socketclose
|
||||
#elif defined(__ORBIS__)
|
||||
typedef int SOCKET;
|
||||
#define INVALID_SOCKET -1
|
||||
#define SO_NBIO SCE_NET_SO_NBIO
|
||||
#define sys_net_errno errno
|
||||
#define SYS_NET_EINPROGRESS EINPROGRESS
|
||||
#define socketselect select
|
||||
#define closesocket sceNetSocketClose
|
||||
#define socketclose sceNetSocketClose
|
||||
#elif defined(__PSVITA__)
|
||||
typedef SceNetId SOCKET;
|
||||
typedef SceNetSockaddr sockaddr;
|
||||
typedef SceNetSocklen_t socklen_t;
|
||||
|
||||
#define getsockopt sceNetGetsockopt
|
||||
#define setsockopt sceNetSetsockopt
|
||||
#define recv sceNetRecv
|
||||
#define send sceNetSend
|
||||
#define bind sceNetBind
|
||||
#define sendto sceNetSendto
|
||||
#define recvfrom sceNetRecvfrom
|
||||
#define listen sceNetListen
|
||||
#define connect sceNetConnect
|
||||
#define accept sceNetAccept
|
||||
#define closesocket sceNetSocketClose
|
||||
#define socketclose sceNetSocketClose
|
||||
#define inet_ntop sceNetInetNtop
|
||||
|
||||
#define SOL_SOCKET SCE_NET_SOL_SOCKET
|
||||
#define AF_INET SCE_NET_AF_INET
|
||||
#define SOCK_STREAM SCE_NET_SOCK_STREAM
|
||||
#define sys_net_errno sce_net_errno
|
||||
#define SYS_NET_EINPROGRESS SCE_NET_EINPROGRESS
|
||||
|
||||
#define htonl sceNetHtonl
|
||||
#define htons sceNetHtons
|
||||
#define ntohl sceNetNtohl
|
||||
#define ntohs sceNetNtohs
|
||||
|
||||
#define SO_BROADCAST SCE_NET_SO_BROADCAST
|
||||
#define SO_ERROR SCE_NET_SO_ERROR
|
||||
#define SO_RCVTIMEO SCE_NET_SO_RCVTIMEO
|
||||
#define SO_REUSEADDR SCE_NET_SO_REUSEADDR
|
||||
#define SO_NBIO SCE_NET_SO_NBIO
|
||||
#define SOCK_DGRAM SCE_NET_SOCK_DGRAM
|
||||
|
||||
#define INADDR_ANY SCE_NET_INADDR_ANY
|
||||
#define IPPROTO_TCP SCE_NET_IPPROTO_TCP
|
||||
#define IPPROTO_UDP SCE_NET_IPPROTO_UDP
|
||||
#define TCP_NODELAY SCE_NET_TCP_NODELAY
|
||||
#define INADDR_BROADCAST SCE_NET_INADDR_BROADCAST
|
||||
|
||||
#define INVALID_SOCKET -1
|
||||
#endif
|
||||
|
||||
class Socket;
|
||||
|
||||
#define NETWORK_LAN_PLAYER_NAME_SIZE 32
|
||||
|
||||
#pragma pack(push, 1)
|
||||
struct LANBroadcast
|
||||
{
|
||||
DWORD magic;
|
||||
WORD netVersion;
|
||||
WORD gamePort;
|
||||
char hostName[32];
|
||||
BYTE playerCount;
|
||||
BYTE maxPlayers;
|
||||
DWORD gameHostSettings;
|
||||
DWORD texturePackParentId;
|
||||
BYTE subTexturePackId;
|
||||
BYTE isJoinable;
|
||||
char playerNames[NETWORK_LAN_BROADCAST_PLAYERS][NETWORK_LAN_PLAYER_NAME_SIZE];
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
struct LANSession
|
||||
{
|
||||
char hostIP[64];
|
||||
int hostPort;
|
||||
wchar_t hostName[32];
|
||||
unsigned short netVersion;
|
||||
unsigned char playerCount;
|
||||
unsigned char maxPlayers;
|
||||
unsigned int gameHostSettings;
|
||||
unsigned int texturePackParentId;
|
||||
unsigned char subTexturePackId;
|
||||
bool isJoinable;
|
||||
DWORD lastSeenTick;
|
||||
char playerNames[NETWORK_LAN_BROADCAST_PLAYERS][NETWORK_LAN_PLAYER_NAME_SIZE];
|
||||
};
|
||||
|
||||
struct RemoteConnection
|
||||
{
|
||||
SOCKET tcpSocket;
|
||||
BYTE smallId;
|
||||
C4JThread* recvThread;
|
||||
volatile bool active;
|
||||
CRITICAL_SECTION sendLock;
|
||||
};
|
||||
|
||||
class NetworkSocketLayer
|
||||
{
|
||||
public:
|
||||
static bool Initialize();
|
||||
static void Shutdown();
|
||||
|
||||
static bool HostGame(int port);
|
||||
static bool JoinGame(const char *ip, int port);
|
||||
|
||||
static bool SendToSmallId(BYTE targetSmallId, const void *data, int dataSize);
|
||||
static bool SendOnSocket(SOCKET sock, const void *data, int dataSize);
|
||||
|
||||
static bool IsHosting() { return s_isHost; }
|
||||
static bool IsConnected() { return s_connected; }
|
||||
static bool IsActive() { return s_active; }
|
||||
|
||||
static BYTE GetLocalSmallId() { return s_localSmallId; }
|
||||
static BYTE GetHostSmallId() { return s_hostSmallId; }
|
||||
|
||||
static SOCKET GetSocketForSmallId(BYTE smallId);
|
||||
|
||||
static void HandleDataReceived(BYTE fromSmallId, BYTE toSmallId, unsigned char *data, unsigned int dataSize);
|
||||
|
||||
static bool PopDisconnectedSmallId(BYTE *outSmallId);
|
||||
static void PushFreeSmallId(BYTE smallId);
|
||||
static void CloseConnectionBySmallId(BYTE smallId);
|
||||
|
||||
static bool IsSmallIdConnected(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();
|
||||
static void UpdateAdvertisePlayerCount(BYTE count);
|
||||
static void UpdateAdvertiseJoinable(bool joinable);
|
||||
static void UpdateAdvertisePlayerNames(BYTE count, const char playerNames[][XUSER_NAME_SIZE]);
|
||||
|
||||
static bool StartDiscovery();
|
||||
static void StopDiscovery();
|
||||
static vector<LANSession> GetDiscoveredSessions();
|
||||
|
||||
static int GetHostPort() { return s_hostGamePort; }
|
||||
|
||||
private:
|
||||
static int AcceptThreadProc(void* param);
|
||||
static int RecvThreadProc(void* param);
|
||||
static int ClientRecvThreadProc(void* param);
|
||||
static int AdvertiseThreadProc(void* param);
|
||||
static int DiscoveryThreadProc(void* param);
|
||||
|
||||
static NetworkSocketManager *s_pPlatformSocketManager;
|
||||
static SOCKET s_listenSocket;
|
||||
static SOCKET s_hostConnectionSocket;
|
||||
static C4JThread* s_acceptThread;
|
||||
static C4JThread* s_clientRecvThread;
|
||||
|
||||
static bool s_isHost;
|
||||
static bool s_connected;
|
||||
static bool s_active;
|
||||
static bool s_initialized;
|
||||
|
||||
static BYTE s_localSmallId;
|
||||
static BYTE s_hostSmallId;
|
||||
static BYTE s_nextSmallId;
|
||||
|
||||
static CRITICAL_SECTION s_sendLock;
|
||||
static CRITICAL_SECTION s_connectionsLock;
|
||||
|
||||
static RemoteConnection s_connections[NETWORK_LAN_MAX_CLIENTS + 1];
|
||||
|
||||
static SOCKET s_advertiseSock;
|
||||
static C4JThread* s_advertiseThread;
|
||||
static volatile bool s_advertising;
|
||||
static LANBroadcast s_advertiseData;
|
||||
static CRITICAL_SECTION s_advertiseLock;
|
||||
static int s_hostGamePort;
|
||||
|
||||
static SOCKET s_discoverySock;
|
||||
static C4JThread* s_discoveryThread;
|
||||
static volatile bool s_discovering;
|
||||
static CRITICAL_SECTION s_discoveryLock;
|
||||
static std::vector<LANSession> s_discoveredSessions;
|
||||
|
||||
static CRITICAL_SECTION s_disconnectLock;
|
||||
static std::vector<BYTE> s_disconnectedSmallIds;
|
||||
|
||||
static CRITICAL_SECTION s_freeSmallIdLock;
|
||||
static std::vector<BYTE> s_freeSmallIds;
|
||||
};
|
||||
|
||||
extern bool g_MultiplayerHost;
|
||||
extern bool g_MultiplayerJoin;
|
||||
extern int g_MultiplayerPort;
|
||||
extern char g_MultiplayerIP[256];
|
||||
|
||||
#ifdef MINECRAFT_SERVER_BUILD
|
||||
extern int g_DedicatedServerPort;
|
||||
extern char g_DedicatedServerBindIP[256];
|
||||
extern bool g_DedicatedServerLanAdvertise;
|
||||
#endif
|
||||
+460
-45
@@ -1,14 +1,20 @@
|
||||
#include "stdafx.h"
|
||||
#include "stdafx.h"
|
||||
#include "..\..\..\Minecraft.World\Socket.h"
|
||||
#include "..\..\..\Minecraft.World\StringHelpers.h"
|
||||
#include "PlatformNetworkManagerStub.h"
|
||||
#include "PlatformNetworkManager.h"
|
||||
#include "..\..\Xbox\Network\NetworkPlayerXbox.h" // TODO - stub version of this?
|
||||
#include "..\..\Minecraft.h"
|
||||
#include "..\..\User.h"
|
||||
#include "..\..\Common\Network\NetworkSocketLayer.h"
|
||||
|
||||
CPlatformNetworkManagerStub *g_pPlatformNetworkManager;
|
||||
|
||||
|
||||
void CPlatformNetworkManagerStub::NotifyPlayerJoined(IQNetPlayer *pQNetPlayer )
|
||||
{
|
||||
if (getNetworkPlayer(pQNetPlayer) != NULL)
|
||||
return;
|
||||
|
||||
const char * pszDescription;
|
||||
|
||||
// 4J Stu - We create a fake socket for every where that we need an INBOUND queue of game data. Outbound
|
||||
@@ -89,7 +95,7 @@ void CPlatformNetworkManagerStub::NotifyPlayerJoined(IQNetPlayer *pQNetPlayer )
|
||||
if( m_pIQNet->IsHost() )
|
||||
{
|
||||
// 4J-PB - only the host should do this
|
||||
// g_NetworkManager.UpdateAndSetGameSessionData();
|
||||
g_NetworkManager.UpdateAndSetGameSessionData();
|
||||
SystemFlagAddPlayer( networkPlayer );
|
||||
}
|
||||
|
||||
@@ -114,18 +120,58 @@ void CPlatformNetworkManagerStub::NotifyPlayerJoined(IQNetPlayer *pQNetPlayer )
|
||||
}
|
||||
}
|
||||
|
||||
void CPlatformNetworkManagerStub::NotifyPlayerLeaving(IQNetPlayer *pQNetPlayer)
|
||||
{
|
||||
app.DebugPrintf("Player 0x%p \"%ls\" leaving.\n", pQNetPlayer, pQNetPlayer->GetGamertag());
|
||||
|
||||
INetworkPlayer *networkPlayer = getNetworkPlayer(pQNetPlayer);
|
||||
if (networkPlayer == NULL)
|
||||
return;
|
||||
|
||||
Socket *socket = networkPlayer->GetSocket();
|
||||
if (socket != NULL)
|
||||
{
|
||||
if (m_pIQNet->IsHost())
|
||||
g_NetworkManager.CloseConnection(networkPlayer);
|
||||
}
|
||||
|
||||
if (m_pIQNet->IsHost())
|
||||
{
|
||||
SystemFlagRemovePlayer(networkPlayer);
|
||||
}
|
||||
|
||||
g_NetworkManager.PlayerLeaving(networkPlayer);
|
||||
|
||||
if (m_pIQNet->IsHost())
|
||||
{
|
||||
g_NetworkManager.UpdateAndSetGameSessionData(networkPlayer);
|
||||
}
|
||||
|
||||
for (int idx = 0; idx < XUSER_MAX_COUNT; ++idx)
|
||||
{
|
||||
if (playerChangedCallback[idx] != NULL)
|
||||
playerChangedCallback[idx](playerChangedCallbackParam[idx], networkPlayer, true);
|
||||
}
|
||||
|
||||
removeNetworkPlayer(pQNetPlayer);
|
||||
}
|
||||
|
||||
bool CPlatformNetworkManagerStub::Initialise(CGameNetworkManager *pGameNetworkManager, int flagIndexSize)
|
||||
{
|
||||
m_pGameNetworkManager = pGameNetworkManager;
|
||||
m_flagIndexSize = flagIndexSize;
|
||||
m_pIQNet = new IQNet();
|
||||
g_pPlatformNetworkManager = this;
|
||||
for( int i = 0; i < XUSER_MAX_COUNT; i++ )
|
||||
{
|
||||
playerChangedCallback[ i ] = NULL;
|
||||
}
|
||||
|
||||
NetworkSocketLayer::Initialize();
|
||||
|
||||
m_bLeavingGame = false;
|
||||
m_bLeaveGameOnTick = false;
|
||||
m_bLeaveGameOnTick = false;
|
||||
m_bHostChanged = false;
|
||||
|
||||
m_bSearchResultsReady = false;
|
||||
@@ -174,6 +220,76 @@ bool CPlatformNetworkManagerStub::isSystemPrimaryPlayer(IQNetPlayer *pQNetPlayer
|
||||
// We call this twice a frame, either side of the render call so is a good place to "tick" things
|
||||
void CPlatformNetworkManagerStub::DoWork()
|
||||
{
|
||||
extern QNET_STATE _iQNetStubState;
|
||||
if (_iQNetStubState == QNET_STATE_SESSION_STARTING && app.GetGameStarted())
|
||||
{
|
||||
_iQNetStubState = QNET_STATE_GAME_PLAY;
|
||||
if (m_pIQNet->IsHost())
|
||||
NetworkSocketLayer::UpdateAdvertiseJoinable(true);
|
||||
}
|
||||
if (_iQNetStubState == QNET_STATE_IDLE)
|
||||
TickSearch();
|
||||
if (_iQNetStubState == QNET_STATE_GAME_PLAY && m_pIQNet->IsHost())
|
||||
{
|
||||
BYTE disconnectedSmallId;
|
||||
while (NetworkSocketLayer::PopDisconnectedSmallId(&disconnectedSmallId))
|
||||
{
|
||||
IQNetPlayer* qnetPlayer = m_pIQNet->GetPlayerBySmallId(disconnectedSmallId);
|
||||
if (qnetPlayer != NULL && qnetPlayer->m_smallId == disconnectedSmallId)
|
||||
{
|
||||
NotifyPlayerLeaving(qnetPlayer);
|
||||
qnetPlayer->m_smallId = 0;
|
||||
qnetPlayer->m_isRemote = false;
|
||||
qnetPlayer->m_isHostPlayer = false;
|
||||
//qnetPlayer->m_resolvedXuid = INVALID_XUID; // TODO: implement
|
||||
qnetPlayer->m_gamertag[0] = 0;
|
||||
qnetPlayer->SetCustomDataValue(0);
|
||||
// Recalculate s_playerCount as the highest active slot + 1.
|
||||
// A blind decrement would hide players at higher-indexed slots when a
|
||||
// lower-indexed player disconnects first: GetPlayerBySmallId scans
|
||||
// [0, s_playerCount) so any slot at or above the decremented count
|
||||
// becomes invisible, causing its disconnect to be missed (ghost player).
|
||||
while (IQNet::s_playerCount > 1 &&
|
||||
IQNet::m_player[IQNet::s_playerCount - 1].GetCustomDataValue() == 0)
|
||||
IQNet::s_playerCount--;
|
||||
}
|
||||
// NOTE: Do NOT call PushFreeSmallId here. The old PlayerConnection's
|
||||
// write thread may still be alive (it dies in PlayerList::tick when
|
||||
// m_smallIdsToClose is processed). If we recycle the smallId now,
|
||||
// AcceptThread can reuse it for a new connection, and the old write
|
||||
// thread's getPlayer() lookup will resolve to the NEW player, sending
|
||||
// stale game packets to the new client's TCP socket — corrupting its
|
||||
// login handshake (bad packet id crash). PushFreeSmallId and
|
||||
// ClearSocketForSmallId are called from PlayerList::tick after the
|
||||
// old Connection threads are dead.
|
||||
//
|
||||
// Clear chunk visibility flags for this system so rejoin gets fresh chunk state.
|
||||
SystemFlagRemoveBySmallId(disconnectedSmallId);
|
||||
}
|
||||
}
|
||||
|
||||
// Client-side host disconnect detection:
|
||||
// if TCP is gone, propagate through normal network-disconnect flow so UI returns to menus.
|
||||
// The processing from the Xbox version will be reused.
|
||||
if (_iQNetStubState == QNET_STATE_GAME_PLAY && !m_pIQNet->IsHost() && !m_bLeavingGame)
|
||||
{
|
||||
if (!NetworkSocketLayer::IsConnected())
|
||||
{
|
||||
if (!m_bLeaveGameOnTick)
|
||||
{
|
||||
m_bLeaveGameOnTick = true;
|
||||
#if defined __PS3__ || defined __PSVITA__ || defined __ORBIS__
|
||||
g_NetworkManager.HandleDisconnect(false, false);
|
||||
#else
|
||||
g_NetworkManager.HandleDisconnect(false);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_bLeaveGameOnTick = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int CPlatformNetworkManagerStub::GetPlayerCount()
|
||||
@@ -198,12 +314,27 @@ int CPlatformNetworkManagerStub::GetLocalPlayerMask(int playerIndex)
|
||||
|
||||
bool CPlatformNetworkManagerStub::AddLocalPlayerByUserIndex( int userIndex )
|
||||
{
|
||||
if (m_pIQNet->AddLocalPlayerByUserIndex(userIndex) != S_OK) return false;
|
||||
NotifyPlayerJoined(m_pIQNet->GetLocalPlayerByUserIndex(userIndex));
|
||||
return ( m_pIQNet->AddLocalPlayerByUserIndex(userIndex) == S_OK );
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CPlatformNetworkManagerStub::RemoveLocalPlayerByUserIndex( int userIndex )
|
||||
{
|
||||
if (userIndex > 0 && userIndex < XUSER_MAX_COUNT)
|
||||
{
|
||||
IQNetPlayer *qnetPlayer = m_pIQNet->GetLocalPlayerByUserIndex(userIndex);
|
||||
if (qnetPlayer != NULL)
|
||||
{
|
||||
NotifyPlayerLeaving(qnetPlayer);
|
||||
qnetPlayer->m_isRemote = true;
|
||||
qnetPlayer->m_isHostPlayer = false;
|
||||
qnetPlayer->m_gamertag[0] = 0;
|
||||
qnetPlayer->SetCustomDataValue(0);
|
||||
if (IQNet::s_playerCount > 1)
|
||||
IQNet::s_playerCount--;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -231,6 +362,8 @@ bool CPlatformNetworkManagerStub::LeaveGame(bool bMigrateHost)
|
||||
if( m_bLeavingGame ) return true;
|
||||
|
||||
m_bLeavingGame = true;
|
||||
m_bLeaveGameOnTick = false;
|
||||
NetworkSocketLayer::StopAdvertising();
|
||||
|
||||
// If we are the host wait for the game server to end
|
||||
if(m_pIQNet->IsHost() && g_NetworkManager.ServerStoppedValid())
|
||||
@@ -239,6 +372,20 @@ bool CPlatformNetworkManagerStub::LeaveGame(bool bMigrateHost)
|
||||
g_NetworkManager.ServerStoppedWait();
|
||||
g_NetworkManager.ServerStoppedDestroy();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pIQNet->EndGame();
|
||||
}
|
||||
|
||||
for (AUTO_VAR(it, currentNetworkPlayers.begin()); it != currentNetworkPlayers.end(); it++)
|
||||
delete *it;
|
||||
currentNetworkPlayers.clear();
|
||||
m_machineQNetPrimaryPlayers.clear();
|
||||
SystemFlagReset();
|
||||
|
||||
NetworkSocketLayer::Shutdown();
|
||||
NetworkSocketLayer::Initialize();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -259,10 +406,47 @@ void CPlatformNetworkManagerStub::HostGame(int localUsersMask, bool bOnlineGame,
|
||||
localUsersMask |= GetLocalPlayerMask( g_NetworkManager.GetPrimaryPad() );
|
||||
|
||||
m_bLeavingGame = false;
|
||||
m_bLeaveGameOnTick = false;
|
||||
|
||||
m_pIQNet->HostGame();
|
||||
|
||||
IQNet::m_player[0].m_smallId = 0;
|
||||
IQNet::m_player[0].m_isRemote = false;
|
||||
IQNet::m_player[0].m_isHostPlayer = true;
|
||||
#ifdef _WINDOWS64
|
||||
extern wchar_t g_Win64UsernameW[17];
|
||||
wcscpy_s(IQNet::m_player[0].m_gamertag, 32, g_Win64UsernameW);
|
||||
IQNet::s_playerCount = 1;
|
||||
#endif
|
||||
|
||||
if (getNetworkPlayer(&IQNet::m_player[0]) == NULL)
|
||||
NotifyPlayerJoined(&IQNet::m_player[0]);
|
||||
|
||||
_HostGame( localUsersMask, publicSlots, privateSlots );
|
||||
|
||||
int port = NETWORK_LAN_DEFAULT_PORT;
|
||||
if (!NetworkSocketLayer::IsActive())
|
||||
NetworkSocketLayer::HostGame(port);
|
||||
|
||||
if (NetworkSocketLayer::IsActive())
|
||||
{
|
||||
// For Dedicated Server, refer to `lan-advertise` in `server.properties`
|
||||
bool enableLanAdvertising = true;
|
||||
#ifdef MINECRAFT_SERVER_BUILD
|
||||
enableLanAdvertising = g_DedicatedServerLanAdvertise;
|
||||
#endif
|
||||
|
||||
if (enableLanAdvertising)
|
||||
{
|
||||
const wchar_t* hostName = IQNet::m_player[0].m_gamertag;
|
||||
unsigned int settings = app.GetGameHostOption(eGameHostOption_All);
|
||||
NetworkSocketLayer::StartAdvertising(port, hostName, settings, 0, 0, MINECRAFT_NET_VERSION);
|
||||
}
|
||||
else
|
||||
{
|
||||
NetworkSocketLayer::StopAdvertising();
|
||||
}
|
||||
}
|
||||
//#endif
|
||||
}
|
||||
|
||||
@@ -277,6 +461,46 @@ bool CPlatformNetworkManagerStub::_StartGame()
|
||||
|
||||
int CPlatformNetworkManagerStub::JoinGame(FriendSessionInfo *searchResult, int localUsersMask, int primaryUserIndex)
|
||||
{
|
||||
if (searchResult == NULL)
|
||||
return CGameNetworkManager::JOINGAME_FAIL_GENERAL;
|
||||
|
||||
const char *hostIP = searchResult->data.hostIP;
|
||||
int hostPort = searchResult->data.hostPort;
|
||||
|
||||
if (hostPort <= 0 || hostIP[0] == 0)
|
||||
return CGameNetworkManager::JOINGAME_FAIL_GENERAL;
|
||||
|
||||
m_bLeavingGame = false;
|
||||
IQNet::s_isHosting = false;
|
||||
m_pIQNet->ClientJoinGame();
|
||||
|
||||
IQNet::m_player[0].m_smallId = 0;
|
||||
IQNet::m_player[0].m_isRemote = true;
|
||||
IQNet::m_player[0].m_isHostPlayer = true;
|
||||
wcsncpy(IQNet::m_player[0].m_gamertag, searchResult->data.hostName, 31);
|
||||
IQNet::m_player[0].m_gamertag[31] = L'\0';
|
||||
|
||||
NetworkSocketLayer::StopDiscovery();
|
||||
|
||||
if (!NetworkSocketLayer::JoinGame(hostIP, hostPort))
|
||||
{
|
||||
app.DebugPrintf("Win64 LAN: Failed to connect to %s:%d\n", hostIP, hostPort);
|
||||
return CGameNetworkManager::JOINGAME_FAIL_GENERAL;
|
||||
}
|
||||
|
||||
BYTE localSmallId = NetworkSocketLayer::GetLocalSmallId();
|
||||
|
||||
IQNet::m_player[localSmallId].m_smallId = localSmallId;
|
||||
IQNet::m_player[localSmallId].m_isRemote = false;
|
||||
IQNet::m_player[localSmallId].m_isHostPlayer = false;
|
||||
|
||||
Minecraft *pMinecraft = Minecraft::GetInstance();
|
||||
wcsncpy(IQNet::m_player[localSmallId].m_gamertag, pMinecraft->user->name.c_str(), 32);
|
||||
IQNet::s_playerCount = localSmallId + 1;
|
||||
|
||||
NotifyPlayerJoined(&IQNet::m_player[0]);
|
||||
NotifyPlayerJoined(&IQNet::m_player[localSmallId]);
|
||||
|
||||
return CGameNetworkManager::JOINGAME_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -315,49 +539,82 @@ void CPlatformNetworkManagerStub::HandleSignInChange()
|
||||
|
||||
bool CPlatformNetworkManagerStub::_RunNetworkGame()
|
||||
{
|
||||
extern QNET_STATE _iQNetStubState;
|
||||
_iQNetStubState = QNET_STATE_GAME_PLAY;
|
||||
if (m_pIQNet->IsHost())
|
||||
NetworkSocketLayer::UpdateAdvertiseJoinable(true);
|
||||
|
||||
for (DWORD i = 0; i < IQNet::s_playerCount; i++)
|
||||
{
|
||||
if (IQNet::m_player[i].m_isRemote)
|
||||
{
|
||||
INetworkPlayer *pNetworkPlayer = getNetworkPlayer(&IQNet::m_player[i]);
|
||||
if (pNetworkPlayer != NULL && pNetworkPlayer->GetSocket() != NULL)
|
||||
{
|
||||
Socket::addIncomingSocket(pNetworkPlayer->GetSocket());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CPlatformNetworkManagerStub::SetGamePlayState()
|
||||
{
|
||||
extern QNET_STATE _iQNetStubState;
|
||||
|
||||
_iQNetStubState = QNET_STATE_GAME_PLAY;
|
||||
|
||||
if (m_pIQNet->IsHost())
|
||||
{
|
||||
NetworkSocketLayer::UpdateAdvertiseJoinable(true);
|
||||
}
|
||||
}
|
||||
|
||||
void CPlatformNetworkManagerStub::UpdateAndSetGameSessionData(INetworkPlayer *pNetworkPlayerLeaving /*= NULL*/)
|
||||
{
|
||||
// DWORD playerCount = m_pIQNet->GetPlayerCount();
|
||||
//
|
||||
// if( this->m_bLeavingGame )
|
||||
// return;
|
||||
//
|
||||
// if( GetHostPlayer() == NULL )
|
||||
// return;
|
||||
//
|
||||
// for(unsigned int i = 0; i < MINECRAFT_NET_MAX_PLAYERS; ++i)
|
||||
// {
|
||||
// if( i < playerCount )
|
||||
// {
|
||||
// INetworkPlayer *pNetworkPlayer = GetPlayerByIndex(i);
|
||||
//
|
||||
// // We can call this from NotifyPlayerLeaving but at that point the player is still considered in the session
|
||||
// if( pNetworkPlayer != pNetworkPlayerLeaving )
|
||||
// {
|
||||
// m_hostGameSessionData.players[i] = ((NetworkPlayerXbox *)pNetworkPlayer)->GetUID();
|
||||
//
|
||||
// char *temp;
|
||||
// temp = (char *)wstringtofilename( pNetworkPlayer->GetOnlineName() );
|
||||
// memcpy(m_hostGameSessionData.szPlayers[i],temp,XUSER_NAME_SIZE);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// m_hostGameSessionData.players[i] = NULL;
|
||||
// memset(m_hostGameSessionData.szPlayers[i],0,XUSER_NAME_SIZE);
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// m_hostGameSessionData.players[i] = NULL;
|
||||
// memset(m_hostGameSessionData.szPlayers[i],0,XUSER_NAME_SIZE);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// m_hostGameSessionData.hostPlayerUID = ((NetworkPlayerXbox *)GetHostPlayer())->GetQNetPlayer()->GetXuid();
|
||||
// m_hostGameSessionData.m_uiGameHostSettings = app.GetGameHostOption(eGameHostOption_All);
|
||||
if (this->m_bLeavingGame)
|
||||
return;
|
||||
|
||||
if (!m_pIQNet->IsHost())
|
||||
return;
|
||||
|
||||
DWORD playerCount = m_pIQNet->GetPlayerCount();
|
||||
|
||||
m_hostGameSessionData.m_uiGameHostSettings = app.GetGameHostOption(eGameHostOption_All);
|
||||
m_hostGameSessionData.playerCount = (unsigned char)playerCount;
|
||||
|
||||
for (unsigned int i = 0; i < MINECRAFT_NET_MAX_PLAYERS; ++i)
|
||||
{
|
||||
if (i < playerCount)
|
||||
{
|
||||
INetworkPlayer *pNetworkPlayer = GetPlayerByIndex(i);
|
||||
|
||||
if (pNetworkPlayer != NULL && pNetworkPlayer != pNetworkPlayerLeaving)
|
||||
{
|
||||
m_hostGameSessionData.players[i] = (GameSessionUID)(i + 1);
|
||||
|
||||
const wchar_t *name = pNetworkPlayer->GetOnlineName();
|
||||
char nameBuf[XUSER_NAME_SIZE];
|
||||
memset(nameBuf, 0, sizeof(nameBuf));
|
||||
wcstombs(nameBuf, name, XUSER_NAME_SIZE - 1);
|
||||
memcpy(m_hostGameSessionData.szPlayers[i], nameBuf, XUSER_NAME_SIZE);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_hostGameSessionData.players[i] = 0;
|
||||
memset(m_hostGameSessionData.szPlayers[i], 0, XUSER_NAME_SIZE);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_hostGameSessionData.players[i] = 0;
|
||||
memset(m_hostGameSessionData.szPlayers[i], 0, XUSER_NAME_SIZE);
|
||||
}
|
||||
}
|
||||
|
||||
// update the LAN advertiser with current player names and count
|
||||
NetworkSocketLayer::UpdateAdvertisePlayerNames(m_hostGameSessionData.playerCount, m_hostGameSessionData.szPlayers);
|
||||
}
|
||||
|
||||
int CPlatformNetworkManagerStub::RemovePlayerOnSocketClosedThreadProc( void* lpParam )
|
||||
@@ -395,6 +652,7 @@ CPlatformNetworkManagerStub::PlayerFlags::PlayerFlags(INetworkPlayer *pNetworkPl
|
||||
this->flags = new unsigned char [ count / 8 ];
|
||||
memset( this->flags, 0, count / 8 );
|
||||
this->count = count;
|
||||
this->m_smallId = (pNetworkPlayer && pNetworkPlayer->IsLocal()) ? 256 : (pNetworkPlayer ? (int)pNetworkPlayer->GetSmallId() : -1);
|
||||
}
|
||||
CPlatformNetworkManagerStub::PlayerFlags::~PlayerFlags()
|
||||
{
|
||||
@@ -432,6 +690,23 @@ void CPlatformNetworkManagerStub::SystemFlagRemovePlayer(INetworkPlayer *pNetwor
|
||||
}
|
||||
}
|
||||
|
||||
// Clear chunk flags for a system when they disconnect (by smallId). Call even when we don't find the player,
|
||||
// so we always clear and the smallId can be reused without stale "chunk seen" state.
|
||||
void CPlatformNetworkManagerStub::SystemFlagRemoveBySmallId(int smallId)
|
||||
{
|
||||
if (smallId < 0) return;
|
||||
for (unsigned int i = 0; i < m_playerFlags.size(); i++)
|
||||
{
|
||||
if (m_playerFlags[i]->m_smallId == smallId)
|
||||
{
|
||||
delete m_playerFlags[i];
|
||||
m_playerFlags[i] = m_playerFlags.back();
|
||||
m_playerFlags.pop_back();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CPlatformNetworkManagerStub::SystemFlagReset()
|
||||
{
|
||||
for( unsigned int i = 0; i < m_playerFlags.size(); i++ )
|
||||
@@ -503,10 +778,106 @@ wstring CPlatformNetworkManagerStub::GatherRTTStats()
|
||||
|
||||
void CPlatformNetworkManagerStub::TickSearch()
|
||||
{
|
||||
if (m_SessionsUpdatedCallback == NULL)
|
||||
return;
|
||||
|
||||
static DWORD lastSearchTime = 0;
|
||||
DWORD now = GetTickCount();
|
||||
if (now - lastSearchTime < 2000)
|
||||
return;
|
||||
lastSearchTime = now;
|
||||
|
||||
SearchForGames();
|
||||
}
|
||||
|
||||
void CPlatformNetworkManagerStub::SearchForGames()
|
||||
{
|
||||
std::vector<LANSession> lanSessions = NetworkSocketLayer::GetDiscoveredSessions();
|
||||
|
||||
if (g_MultiplayerJoin && g_MultiplayerIP[0] != '\0')
|
||||
{
|
||||
bool alreadyPresent = false;
|
||||
for (size_t i = 0; i < lanSessions.size(); i++)
|
||||
{
|
||||
if (strcmp(lanSessions[i].hostIP, g_MultiplayerIP) == 0 &&
|
||||
lanSessions[i].hostPort == g_MultiplayerPort)
|
||||
{
|
||||
alreadyPresent = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!alreadyPresent)
|
||||
{
|
||||
LANSession manual;
|
||||
memset(&manual, 0, sizeof(manual));
|
||||
strncpy(manual.hostIP, g_MultiplayerIP, sizeof(manual.hostIP) - 1);
|
||||
manual.hostIP[sizeof(manual.hostIP) - 1] = '\0';
|
||||
|
||||
manual.hostPort = g_MultiplayerPort;
|
||||
|
||||
swprintf(manual.hostName, 32, L"%hs:%d", g_MultiplayerIP, g_MultiplayerPort);
|
||||
manual.hostName[31] = L'\0';
|
||||
manual.playerCount = 0;
|
||||
manual.maxPlayers = MINECRAFT_NET_MAX_PLAYERS;
|
||||
manual.isJoinable = true;
|
||||
manual.lastSeenTick = GetTickCount();
|
||||
lanSessions.push_back(manual);
|
||||
}
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < friendsSessions[0].size(); i++)
|
||||
delete friendsSessions[0][i];
|
||||
friendsSessions[0].clear();
|
||||
|
||||
for (size_t i = 0; i < lanSessions.size(); i++)
|
||||
{
|
||||
FriendSessionInfo *info = new FriendSessionInfo();
|
||||
size_t nameLen = wcslen(lanSessions[i].hostName);
|
||||
info->displayLabel = new wchar_t[nameLen + 1];
|
||||
wcsncpy(info->displayLabel, lanSessions[i].hostName, nameLen);
|
||||
info->displayLabel[nameLen] = L'\0';
|
||||
info->displayLabelLength = (unsigned char)nameLen;
|
||||
info->displayLabelViewableStartIndex = 0;
|
||||
|
||||
info->data.netVersion = lanSessions[i].netVersion;
|
||||
info->data.m_uiGameHostSettings = lanSessions[i].gameHostSettings;
|
||||
info->data.texturePackParentId = lanSessions[i].texturePackParentId;
|
||||
info->data.subTexturePackId = lanSessions[i].subTexturePackId;
|
||||
info->data.isReadyToJoin = lanSessions[i].isJoinable;
|
||||
info->data.isJoinable = lanSessions[i].isJoinable;
|
||||
strncpy(info->data.hostIP, lanSessions[i].hostIP, sizeof(info->data.hostIP) - 1);
|
||||
info->data.hostIP[sizeof(info->data.hostIP) - 1] = '\0';
|
||||
info->data.hostPort = lanSessions[i].hostPort;
|
||||
wcsncpy(info->data.hostName, lanSessions[i].hostName, XUSER_NAME_SIZE - 1);
|
||||
info->data.hostName[XUSER_NAME_SIZE - 1] = L'\0';
|
||||
info->data.playerCount = lanSessions[i].playerCount;
|
||||
info->data.maxPlayers = lanSessions[i].maxPlayers;
|
||||
|
||||
memset(info->data.players, 0, sizeof(info->data.players));
|
||||
memset(info->data.szPlayers, 0, sizeof(info->data.szPlayers));
|
||||
for (int p = 0; p < NETWORK_LAN_BROADCAST_PLAYERS && p < lanSessions[i].playerCount; p++)
|
||||
{
|
||||
if (lanSessions[i].playerNames[p][0] != 0)
|
||||
{
|
||||
info->data.players[p] = (GameSessionUID)(p + 1);
|
||||
memcpy(info->data.szPlayers[p], lanSessions[i].playerNames[p], XUSER_NAME_SIZE);
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(__ORBIS__) || defined(__PSVITA__)
|
||||
SceNetInAddr ip_addr = {};
|
||||
sceNetInetPton(SCE_NET_AF_INET, lanSessions[i].hostIP, &ip_addr);
|
||||
info->sessionId = (ULONGLONG)((uint64_t)ip_addr.s_addr | ((uint64_t)lanSessions[i].hostPort << 32));
|
||||
#else
|
||||
info->sessionId = (ULONGLONG)((unsigned __int64)inet_addr(lanSessions[i].hostIP) | ((unsigned __int64)lanSessions[i].hostPort << 32));
|
||||
#endif
|
||||
friendsSessions[0].push_back(info);
|
||||
}
|
||||
|
||||
m_searchResultsCount[0] = (int)friendsSessions[0].size();
|
||||
|
||||
if (m_SessionsUpdatedCallback != NULL)
|
||||
m_SessionsUpdatedCallback(m_pSearchParam);
|
||||
}
|
||||
|
||||
int CPlatformNetworkManagerStub::SearchForGamesThreadProc( void* lpParameter )
|
||||
@@ -522,12 +893,42 @@ void CPlatformNetworkManagerStub::SetSearchResultsReady(int resultCount)
|
||||
|
||||
vector<FriendSessionInfo *> *CPlatformNetworkManagerStub::GetSessionList(int iPad, int localPlayers, bool partyOnly)
|
||||
{
|
||||
vector<FriendSessionInfo *> *filteredList = new vector<FriendSessionInfo *>();;
|
||||
vector<FriendSessionInfo *> *filteredList = new vector<FriendSessionInfo *>();
|
||||
for (size_t i = 0; i < friendsSessions[0].size(); i++)
|
||||
{
|
||||
FriendSessionInfo *src = friendsSessions[0][i];
|
||||
FriendSessionInfo *copy = new FriendSessionInfo();
|
||||
*copy = *src;
|
||||
if (src->displayLabel != NULL)
|
||||
{
|
||||
copy->displayLabel = new wchar_t[(size_t)src->displayLabelLength + 1];
|
||||
wcsncpy(copy->displayLabel, src->displayLabel, src->displayLabelLength);
|
||||
copy->displayLabel[src->displayLabelLength] = L'\0';
|
||||
}
|
||||
else
|
||||
{
|
||||
copy->displayLabel = NULL;
|
||||
}
|
||||
filteredList->push_back(copy);
|
||||
}
|
||||
return filteredList;
|
||||
}
|
||||
|
||||
bool CPlatformNetworkManagerStub::GetGameSessionInfo(int iPad, SessionID sessionId, FriendSessionInfo *foundSessionInfo)
|
||||
{
|
||||
for (size_t i = 0; i < friendsSessions[0].size(); i++)
|
||||
{
|
||||
if (friendsSessions[0][i]->sessionId == sessionId)
|
||||
{
|
||||
if (foundSessionInfo != NULL)
|
||||
{
|
||||
foundSessionInfo->sessionId = friendsSessions[0][i]->sessionId;
|
||||
foundSessionInfo->data = friendsSessions[0][i]->data;
|
||||
foundSessionInfo->hasPartyMember = friendsSessions[0][i]->hasPartyMember;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -570,9 +971,11 @@ void CPlatformNetworkManagerStub::removeNetworkPlayer(IQNetPlayer *pQNetPlayer)
|
||||
if( *it == pNetworkPlayer )
|
||||
{
|
||||
currentNetworkPlayers.erase(it);
|
||||
return;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
pQNetPlayer->SetCustomDataValue(0);
|
||||
}
|
||||
|
||||
INetworkPlayer *CPlatformNetworkManagerStub::getNetworkPlayer(IQNetPlayer *pQNetPlayer)
|
||||
@@ -598,7 +1001,19 @@ 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);
|
||||
if (networkPlayer == NULL && smallId != 0 && !m_pIQNet->IsHost())
|
||||
{
|
||||
qnetPlayer->m_isRemote = true;
|
||||
qnetPlayer->m_isHostPlayer = false;
|
||||
NotifyPlayerJoined(qnetPlayer);
|
||||
networkPlayer = getNetworkPlayer(qnetPlayer);
|
||||
}
|
||||
return networkPlayer;
|
||||
}
|
||||
|
||||
INetworkPlayer *CPlatformNetworkManagerStub::GetHostPlayer()
|
||||
+6
-2
@@ -1,4 +1,4 @@
|
||||
#pragma once
|
||||
#pragma once
|
||||
using namespace std;
|
||||
#include <vector>
|
||||
#include "..\..\..\Minecraft.World\C4JThread.h"
|
||||
@@ -54,6 +54,7 @@ public:
|
||||
|
||||
virtual void HandleSignInChange();
|
||||
|
||||
virtual void SetGamePlayState();
|
||||
virtual bool _RunNetworkGame();
|
||||
|
||||
private:
|
||||
@@ -98,12 +99,14 @@ private:
|
||||
INetworkPlayer *m_pNetworkPlayer;
|
||||
unsigned char *flags;
|
||||
unsigned int count;
|
||||
int m_smallId;
|
||||
PlayerFlags(INetworkPlayer *pNetworkPlayer, unsigned int count);
|
||||
~PlayerFlags();
|
||||
};
|
||||
vector<PlayerFlags *> m_playerFlags;
|
||||
void SystemFlagAddPlayer(INetworkPlayer *pNetworkPlayer);
|
||||
void SystemFlagRemovePlayer(INetworkPlayer *pNetworkPlayer);
|
||||
void SystemFlagRemoveBySmallId(int smallId);
|
||||
void SystemFlagReset();
|
||||
public:
|
||||
virtual void SystemFlagSet(INetworkPlayer *pNetworkPlayer, int index);
|
||||
@@ -161,8 +164,9 @@ public:
|
||||
virtual void GetFullFriendSessionInfo( FriendSessionInfo *foundSession, void (* FriendSessionUpdatedFn)(bool success, void *pParam), void *pParam );
|
||||
virtual void ForceFriendsSessionRefresh();
|
||||
|
||||
private:
|
||||
public:
|
||||
void NotifyPlayerJoined( IQNetPlayer *pQNetPlayer );
|
||||
void NotifyPlayerLeaving( IQNetPlayer *pQNetPlayer );
|
||||
|
||||
#ifndef _XBOX
|
||||
void FakeLocalPlayerJoined() { NotifyPlayerJoined(m_pIQNet->GetLocalPlayerByUserIndex(0)); }
|
||||
@@ -1,7 +1,11 @@
|
||||
#pragma once
|
||||
using namespace std;
|
||||
#include <vector>
|
||||
#ifndef _DISABLE_XBLIVE
|
||||
#include <qnet.h>
|
||||
#else
|
||||
#include "IQNet.h"
|
||||
#endif
|
||||
#include "..\..\..\Minecraft.World\C4JThread.h"
|
||||
#include "NetworkPlayerInterface.h"
|
||||
#include "SessionInfo.h"
|
||||
@@ -84,7 +88,7 @@ public:
|
||||
virtual void HandleSignInChange() = 0;
|
||||
|
||||
virtual bool _RunNetworkGame() = 0;
|
||||
|
||||
virtual void SetGamePlayState() {}
|
||||
private:
|
||||
virtual bool _LeaveGame(bool bMigrateHost, bool bLeaveRoom) = 0;
|
||||
virtual void _HostGame(int usersMask, unsigned char publicSlots = MINECRAFT_NET_MAX_PLAYERS, unsigned char privateSlots = 0) = 0;
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#if defined(__PS3__) || defined(__ORBIS__)
|
||||
#if !defined(DISABLE_PSN) && (defined(__PS3__) || defined(__ORBIS__))
|
||||
#include "..\..\Common\Network\Sony\SQRNetworkManager.h"
|
||||
#endif
|
||||
|
||||
|
||||
// A struct that we store in the QoS data when we are hosting the session. Max size 1020 bytes.
|
||||
#ifdef _XBOX
|
||||
#if defined _XBOX && !defined _DISABLE_XBLIVE
|
||||
typedef struct _GameSessionData
|
||||
{
|
||||
unsigned short netVersion; // 2 bytes
|
||||
@@ -32,7 +32,7 @@ typedef struct _GameSessionData
|
||||
subTexturePackId = 0;
|
||||
}
|
||||
} GameSessionData;
|
||||
#elif defined __PS3__ || defined __ORBIS__ || defined(__PSVITA__)
|
||||
#elif !defined DISABLE_PSN && (defined __PS3__ || defined __ORBIS__ || defined(__PSVITA__))
|
||||
typedef struct _GameSessionData
|
||||
{
|
||||
unsigned short netVersion; // 2 bytes
|
||||
@@ -47,6 +47,11 @@ typedef struct _GameSessionData
|
||||
unsigned char playerCount; // 1 byte
|
||||
bool isReadyToJoin; // 1 byte
|
||||
|
||||
char hostIP[64]; // 64 bytes
|
||||
int hostPort; // 4 bytes
|
||||
wchar_t hostName[XUSER_NAME_SIZE]; // 64 bytes ( 32*2 )
|
||||
unsigned char maxPlayers; // 1 byte
|
||||
|
||||
_GameSessionData()
|
||||
{
|
||||
netVersion = 0;
|
||||
@@ -57,7 +62,11 @@ typedef struct _GameSessionData
|
||||
subTexturePackId = 0;
|
||||
playerCount = 0;
|
||||
isReadyToJoin = false;
|
||||
|
||||
memset(hostIP, 0, sizeof(hostIP));
|
||||
hostPort = 0;
|
||||
memset(hostName, 0, sizeof(hostName));
|
||||
playerCount = 0;
|
||||
maxPlayers = MINECRAFT_NET_MAX_PLAYERS;
|
||||
}
|
||||
} GameSessionData;
|
||||
#else
|
||||
@@ -69,6 +78,16 @@ typedef struct _GameSessionData
|
||||
unsigned char subTexturePackId; // 1 byte
|
||||
|
||||
bool isReadyToJoin; // 1 byte
|
||||
bool isJoinable; // 1 byte
|
||||
|
||||
char hostIP[64]; // 64 bytes
|
||||
int hostPort; // 4 bytes
|
||||
wchar_t hostName[XUSER_NAME_SIZE]; // 64 bytes ( 32*2 )
|
||||
unsigned char playerCount; // 1 byte
|
||||
unsigned char maxPlayers; // 1 byte
|
||||
|
||||
GameSessionUID players[MINECRAFT_NET_MAX_PLAYERS];
|
||||
char szPlayers[MINECRAFT_NET_MAX_PLAYERS][XUSER_NAME_SIZE];
|
||||
|
||||
_GameSessionData()
|
||||
{
|
||||
@@ -76,6 +95,15 @@ typedef struct _GameSessionData
|
||||
m_uiGameHostSettings = 0;
|
||||
texturePackParentId = 0;
|
||||
subTexturePackId = 0;
|
||||
isReadyToJoin = false;
|
||||
isJoinable = true;
|
||||
memset(hostIP, 0, sizeof(hostIP));
|
||||
hostPort = 0;
|
||||
memset(hostName, 0, sizeof(hostName));
|
||||
playerCount = 0;
|
||||
maxPlayers = MINECRAFT_NET_MAX_PLAYERS;
|
||||
memset(players, 0, sizeof(players));
|
||||
memset(szPlayers, 0, sizeof(szPlayers));
|
||||
}
|
||||
} GameSessionData;
|
||||
#endif
|
||||
@@ -86,7 +114,7 @@ public:
|
||||
SessionID sessionId;
|
||||
#ifdef _XBOX
|
||||
XSESSION_SEARCHRESULT searchResult;
|
||||
#elif defined(__PS3__) || defined(__ORBIS__) || defined (__PSVITA__)
|
||||
#elif !defined(DISABLE_PSN) && (defined(__PS3__) || defined(__ORBIS__) || defined (__PSVITA__))
|
||||
SQRNetworkManager::SessionSearchResult searchResult;
|
||||
#elif defined(_DURANGO)
|
||||
DQRNetworkManager::SessionSearchResult searchResult;
|
||||
@@ -108,6 +136,6 @@ public:
|
||||
~FriendSessionInfo()
|
||||
{
|
||||
if(displayLabel!=NULL)
|
||||
delete displayLabel;
|
||||
delete[] displayLabel;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -0,0 +1,93 @@
|
||||
#include "stdafx.h"
|
||||
|
||||
#include "NetworkSocketManager.h"
|
||||
|
||||
#include <sys/socket.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/tcp.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/select.h>
|
||||
#include <netex/net.h>
|
||||
#include <netex/errno.h>
|
||||
|
||||
// PIEBOT: Adding this because Sony systems uses BSD apis
|
||||
// which uses socketclose instead of closesocket.
|
||||
int NetworkSocketManager::CloseSocket(SOCKET sock)
|
||||
{
|
||||
return socketclose(sock);
|
||||
}
|
||||
|
||||
int NetworkSocketManager::getSocketError(SOCKET socket)
|
||||
{
|
||||
return socket;
|
||||
}
|
||||
|
||||
bool NetworkSocketManager::IsSocketValid(SOCKET sock)
|
||||
{
|
||||
return sock >= 0;
|
||||
}
|
||||
|
||||
bool NetworkSocketManager::IsSentValid(int sent)
|
||||
{
|
||||
return sent >= 0;
|
||||
}
|
||||
|
||||
bool NetworkSocketManager::InitNetwork()
|
||||
{
|
||||
int result = sys_net_initialize_network();
|
||||
if (result != 0) {
|
||||
app.DebugPrintf("sys_net_initialize_network failed: %d\n", result);
|
||||
return false;
|
||||
}
|
||||
|
||||
result = cellNetCtlInit();
|
||||
if (result < 0) {
|
||||
app.DebugPrintf("cellNetCtlInit failed: %d\n", result);
|
||||
sys_net_finalize_network();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
SOCKET NetworkSocketManager::MakeHostSocket(int port)
|
||||
{
|
||||
SOCKET s_listenSocket;
|
||||
|
||||
struct sockaddr_in addr = {};
|
||||
|
||||
addr.sin_family = AF_INET;
|
||||
addr.sin_addr.s_addr = htonl(INADDR_ANY);
|
||||
addr.sin_port = htons((uint16_t)port);
|
||||
|
||||
s_listenSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
|
||||
if (s_listenSocket < 0)
|
||||
{
|
||||
app.DebugPrintf("socket() failed: %d\n", s_listenSocket);
|
||||
return INVALID_SOCKET;
|
||||
}
|
||||
|
||||
// PIEBOT: time for part 2, binding and listening.
|
||||
int opt = 1;
|
||||
setsockopt(s_listenSocket, SOL_SOCKET, SO_REUSEADDR, (const char *)&opt, sizeof(opt));
|
||||
|
||||
int iResult = ::bind(s_listenSocket, (struct sockaddr*)&addr, sizeof(addr));
|
||||
|
||||
if (iResult < 0)
|
||||
{
|
||||
app.DebugPrintf("bind() failed: %d\n", iResult);
|
||||
CloseSocket(s_listenSocket);
|
||||
return INVALID_SOCKET;
|
||||
}
|
||||
|
||||
iResult = listen(s_listenSocket, 5);
|
||||
if (iResult < 0)
|
||||
{
|
||||
app.DebugPrintf("listen() failed: %d\n", iResult);
|
||||
CloseSocket(s_listenSocket);
|
||||
return INVALID_SOCKET;
|
||||
}
|
||||
|
||||
return s_listenSocket;
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
#include "stdafx.h"
|
||||
|
||||
#include "NetworkSocketManager.h"
|
||||
|
||||
#include <sys/socket.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/tcp.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/select.h>
|
||||
|
||||
// PIEBOT: Adding this because Sony systems uses BSD apis
|
||||
// which uses socketclose instead of closesocket.
|
||||
int NetworkSocketManager::CloseSocket(SOCKET sock)
|
||||
{
|
||||
return socketclose(sock);
|
||||
}
|
||||
|
||||
int NetworkSocketManager::getSocketError(SOCKET socket)
|
||||
{
|
||||
return socket;
|
||||
}
|
||||
|
||||
bool NetworkSocketManager::IsSocketValid(SOCKET sock)
|
||||
{
|
||||
return sock >= 0;
|
||||
}
|
||||
|
||||
bool NetworkSocketManager::IsSentValid(int sent)
|
||||
{
|
||||
return sent >= 0;
|
||||
}
|
||||
|
||||
bool NetworkSocketManager::InitNetwork()
|
||||
{
|
||||
WSADATA wsaData;
|
||||
int result = WSAStartup(MAKEWORD(2, 2), &wsaData);
|
||||
if (result != 0)
|
||||
{
|
||||
app.DebugPrintf("WSAStartup failed: %d\n", result);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
SOCKET NetworkSocketManager::MakeHostSocket(int port)
|
||||
{
|
||||
SOCKET s_listenSocket = NULL;
|
||||
|
||||
struct sockaddr_in addr = {};
|
||||
|
||||
addr.sin_family = AF_INET;
|
||||
addr.sin_addr.s_addr = htonl(INADDR_ANY);
|
||||
addr.sin_port = htons((uint16_t)port);
|
||||
|
||||
s_listenSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
|
||||
if (s_listenSocket < 0)
|
||||
{
|
||||
app.DebugPrintf("socket() failed: %d\n", s_listenSocket);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// PIEBOT: time for part 2, binding and listening.
|
||||
int opt = 1;
|
||||
setsockopt(s_listenSocket, SOL_SOCKET, SO_REUSEADDR, (const char *)&opt, sizeof(opt));
|
||||
|
||||
int iResult = ::bind(s_listenSocket, (struct sockaddr*)&addr, sizeof(addr));
|
||||
|
||||
if (iResult < 0)
|
||||
{
|
||||
app.DebugPrintf("bind() failed: %d\n", iResult);
|
||||
closesocket(s_listenSocket);
|
||||
return INVALID_SOCKET;
|
||||
}
|
||||
|
||||
iResult = listen(s_listenSocket, 5);
|
||||
if (iResult < 0)
|
||||
{
|
||||
app.DebugPrintf("listen() failed: %d\n", iResult);
|
||||
closesocket(s_listenSocket);
|
||||
return INVALID_SOCKET;
|
||||
}
|
||||
|
||||
return s_listenSocket;
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
#include "stdafx.h"
|
||||
|
||||
#include "NetworkSocketManager.h"
|
||||
|
||||
#include <net.h>
|
||||
|
||||
// PIEBOT: Adding this because Sony systems uses BSD apis
|
||||
// which uses socketclose instead of closesocket.
|
||||
int NetworkSocketManager::CloseSocket(SOCKET sock)
|
||||
{
|
||||
return socketclose(sock);
|
||||
}
|
||||
|
||||
int NetworkSocketManager::getSocketError(SOCKET socket)
|
||||
{
|
||||
return socket;
|
||||
}
|
||||
|
||||
bool NetworkSocketManager::IsSocketValid(SOCKET sock)
|
||||
{
|
||||
return sock >= 0;
|
||||
}
|
||||
|
||||
bool NetworkSocketManager::IsSentValid(int sent)
|
||||
{
|
||||
return sent >= 0;
|
||||
}
|
||||
|
||||
bool NetworkSocketManager::InitNetwork()
|
||||
{
|
||||
SceNetInitParam param;
|
||||
static char memory[16 * 1024];
|
||||
|
||||
param.memory = memory;
|
||||
param.size = sizeof(memory);
|
||||
param.flags = 0;
|
||||
|
||||
int result = sceNetInit(¶m);
|
||||
// libnet is brought up before us by the platform layer, which reports EBUSY here.
|
||||
if (result < 0 && result != SCE_NET_ERROR_EBUSY) {
|
||||
app.DebugPrintf("sceNetInit failed: 0x%08x\n", result);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
SOCKET NetworkSocketManager::MakeHostSocket(int port)
|
||||
{
|
||||
SOCKET s_listenSocket = NULL;
|
||||
|
||||
SceNetSockaddrIn addr = {};
|
||||
addr.sin_len = sizeof(addr);
|
||||
addr.sin_family = AF_INET;
|
||||
addr.sin_addr.s_addr = htonl(INADDR_ANY);
|
||||
addr.sin_port = htons((uint16_t)port);
|
||||
|
||||
s_listenSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
|
||||
if (s_listenSocket < 0)
|
||||
{
|
||||
app.DebugPrintf("socket() failed: %d\n", s_listenSocket);
|
||||
return INVALID_SOCKET;
|
||||
}
|
||||
|
||||
// PIEBOT: time for part 2, binding and listening.
|
||||
int opt = 1;
|
||||
setsockopt(s_listenSocket, SOL_SOCKET, SO_REUSEADDR, (const char *)&opt, sizeof(opt));
|
||||
|
||||
int iResult = ::bind(s_listenSocket, (const sockaddr*)&addr, sizeof(addr));
|
||||
|
||||
if (iResult < 0)
|
||||
{
|
||||
app.DebugPrintf("bind() failed: %d\n", iResult);
|
||||
closesocket(s_listenSocket);
|
||||
return INVALID_SOCKET;
|
||||
}
|
||||
|
||||
iResult = listen(s_listenSocket, 5);
|
||||
if (iResult < 0)
|
||||
{
|
||||
app.DebugPrintf("listen() failed: %d\n", iResult);
|
||||
closesocket(s_listenSocket);
|
||||
return INVALID_SOCKET;
|
||||
}
|
||||
|
||||
return s_listenSocket;
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
#include "stdafx.h"
|
||||
|
||||
#include "NetworkSocketManager.h"
|
||||
|
||||
#include <WinSock2.h>
|
||||
#include <WS2tcpip.h>
|
||||
|
||||
// PIEBOT: Adding this because Sony systems uses BSD apis
|
||||
// which uses socketclose instead of closesocket.
|
||||
int NetworkSocketManager::CloseSocket(SOCKET sock)
|
||||
{
|
||||
return closesocket(sock);
|
||||
}
|
||||
|
||||
int NetworkSocketManager::getSocketError(SOCKET socket)
|
||||
{
|
||||
return WSAGetLastError();
|
||||
}
|
||||
|
||||
bool NetworkSocketManager::IsSocketValid(SOCKET sock)
|
||||
{
|
||||
return sock != INVALID_SOCKET;
|
||||
}
|
||||
|
||||
bool NetworkSocketManager::IsSentValid(int sent)
|
||||
{
|
||||
return sent != SOCKET_ERROR;
|
||||
}
|
||||
|
||||
bool NetworkSocketManager::InitNetwork()
|
||||
{
|
||||
WSADATA wsaData;
|
||||
int result = WSAStartup(MAKEWORD(2, 2), &wsaData);
|
||||
if (result != 0)
|
||||
{
|
||||
app.DebugPrintf("WSAStartup failed: %d\n", result);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
SOCKET NetworkSocketManager::MakeHostSocket(int port)
|
||||
{
|
||||
SOCKET s_listenSocket = NULL;
|
||||
struct addrinfo hints = {};
|
||||
struct addrinfo *result = NULL;
|
||||
|
||||
hints.ai_family = AF_INET;
|
||||
hints.ai_socktype = SOCK_STREAM;
|
||||
hints.ai_protocol = IPPROTO_TCP;
|
||||
hints.ai_flags = AI_PASSIVE;
|
||||
|
||||
char portStr[16];
|
||||
sprintf_s(portStr, "%d", port);
|
||||
|
||||
int iResult = getaddrinfo(NULL, portStr, &hints, &result);
|
||||
if (iResult != 0)
|
||||
{
|
||||
app.DebugPrintf("getaddrinfo failed: %d\n", iResult);
|
||||
return INVALID_SOCKET;
|
||||
}
|
||||
|
||||
s_listenSocket = socket(result->ai_family, result->ai_socktype, result->ai_protocol);
|
||||
if (s_listenSocket == INVALID_SOCKET)
|
||||
{
|
||||
app.DebugPrintf("socket() failed: %d\n", WSAGetLastError());
|
||||
freeaddrinfo(result);
|
||||
return INVALID_SOCKET;
|
||||
}
|
||||
|
||||
// PIEBOT: time for part 2, binding and listening.
|
||||
int opt = 1;
|
||||
setsockopt(s_listenSocket, SOL_SOCKET, SO_REUSEADDR, (const char *)&opt, sizeof(opt));
|
||||
|
||||
iResult = ::bind(s_listenSocket, result->ai_addr, (int)result->ai_addrlen);
|
||||
freeaddrinfo(result);
|
||||
if (iResult == SOCKET_ERROR)
|
||||
{
|
||||
app.DebugPrintf("bind() failed: %d\n", WSAGetLastError());
|
||||
closesocket(s_listenSocket);
|
||||
return INVALID_SOCKET;
|
||||
}
|
||||
|
||||
iResult = listen(s_listenSocket, SOMAXCONN);
|
||||
if (iResult == SOCKET_ERROR)
|
||||
{
|
||||
app.DebugPrintf("listen() failed: %d\n", WSAGetLastError());
|
||||
closesocket(s_listenSocket);
|
||||
return INVALID_SOCKET;
|
||||
}
|
||||
|
||||
return s_listenSocket;
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
#include "stdafx.h"
|
||||
|
||||
#include "NetworkSocketManager.h"
|
||||
|
||||
#include <stdint.h>
|
||||
#include <winsockx.h>
|
||||
#include <xtl.h>
|
||||
|
||||
// PIEBOT: Adding this because Sony systems uses BSD apis
|
||||
// which uses socketclose instead of closesocket.
|
||||
int NetworkSocketManager::CloseSocket(SOCKET sock)
|
||||
{
|
||||
return closesocket(sock);
|
||||
}
|
||||
|
||||
int NetworkSocketManager::getSocketError(SOCKET socket)
|
||||
{
|
||||
return WSAGetLastError();
|
||||
}
|
||||
|
||||
bool NetworkSocketManager::IsSocketValid(SOCKET sock)
|
||||
{
|
||||
return sock != INVALID_SOCKET;
|
||||
}
|
||||
|
||||
bool NetworkSocketManager::IsSentValid(int sent)
|
||||
{
|
||||
return sent != SOCKET_ERROR;
|
||||
}
|
||||
|
||||
bool NetworkSocketManager::InitNetwork()
|
||||
{
|
||||
WSADATA wsaData;
|
||||
int result = WSAStartup(MAKEWORD(2, 2), &wsaData);
|
||||
if (result != 0)
|
||||
{
|
||||
app.DebugPrintf("WSAStartup failed: %d\n", result);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
SOCKET NetworkSocketManager::MakeListenSocket(int port)
|
||||
{
|
||||
SOCKET s_listenSocket = NULL;
|
||||
struct sockaddr_in addr = {};
|
||||
addr.sin_family = AF_INET;
|
||||
addr.sin_addr.s_addr = htonl(INADDR_ANY);
|
||||
addr.sin_port = htons((WORD)port);
|
||||
|
||||
s_listenSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
|
||||
if (s_listenSocket == INVALID_SOCKET)
|
||||
{
|
||||
app.DebugPrintf("socket() failed: %d\n", WSAGetLastError());
|
||||
return INVALID_SOCKET;
|
||||
}
|
||||
|
||||
// PIEBOT: time for part 2, binding and listening.
|
||||
int opt = 1;
|
||||
setsockopt(s_listenSocket, SOL_SOCKET, SO_REUSEADDR, (const char *)&opt, sizeof(opt));
|
||||
|
||||
iResult = ::bind(s_listenSocket, (struct sockaddr*)&addr, sizeof(addr));
|
||||
if (iResult == SOCKET_ERROR)
|
||||
{
|
||||
app.DebugPrintf("bind() failed: %d\n", WSAGetLastError());
|
||||
closesocket(s_listenSocket);
|
||||
return INVALID_SOCKET;
|
||||
}
|
||||
|
||||
iResult = listen(s_listenSocket, SOMAXCONN);
|
||||
if (iResult == SOCKET_ERROR)
|
||||
{
|
||||
app.DebugPrintf("listen() failed: %d\n", WSAGetLastError());
|
||||
closesocket(s_listenSocket);
|
||||
return INVALID_SOCKET;
|
||||
}
|
||||
|
||||
return s_listenSocket;
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
#pragma once
|
||||
|
||||
#include "stdafx.h"
|
||||
|
||||
#ifdef _WINDOWS64
|
||||
#include <WinSock2.h>
|
||||
#elif defined _XBOX
|
||||
#include <winsockx.h>
|
||||
#else
|
||||
typedef int SOCKET;
|
||||
#define INVALID_SOCKET -1
|
||||
#endif
|
||||
|
||||
class NetworkSocketManager {
|
||||
public:
|
||||
bool IsSocketValid(SOCKET sock);
|
||||
bool IsSentValid(int sent);
|
||||
int getSocketError(SOCKET sock);
|
||||
int CloseSocket(SOCKET sock);
|
||||
int TCPaddrinfo(PCSTR ip, int port);
|
||||
bool InitNetwork();
|
||||
SOCKET MakeHostSocket(int port);
|
||||
};
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "stdafx.h"
|
||||
#include "NetworkPlayerSony.h"
|
||||
#ifndef DISABLE_PSN
|
||||
|
||||
NetworkPlayerSony::NetworkPlayerSony(SQRNetworkPlayer *qnetPlayer)
|
||||
{
|
||||
@@ -135,3 +136,4 @@ int NetworkPlayerSony::GetTimeSinceLastChunkPacket_ms()
|
||||
__int64 currentTime = System::currentTimeMillis();
|
||||
return (int)( currentTime - m_lastChunkPacketTime );
|
||||
}
|
||||
#endif
|
||||
@@ -1,5 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#ifndef _DISABLE_PSN
|
||||
#include "..\..\Common\Network\NetworkPlayerInterface.h"
|
||||
#include "SQRNetworkPlayer.h"
|
||||
|
||||
@@ -41,3 +41,4 @@ private:
|
||||
Socket *m_pSocket;
|
||||
__int64 m_lastChunkPacketTime;
|
||||
};
|
||||
#endif
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "stdafx.h"
|
||||
|
||||
#ifndef DISABLE_PSN
|
||||
#include "SQRNetworkManager.h"
|
||||
|
||||
bool SQRNetworkManager::s_safeToRespondToGameBootInvite = false;
|
||||
@@ -80,4 +80,5 @@ void SQRNetworkManager::TickWriteAcks()
|
||||
}
|
||||
}
|
||||
LeaveCriticalSection(&m_csAckQueue);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -80,7 +80,6 @@ public:
|
||||
bool inviteOnly;
|
||||
};
|
||||
|
||||
|
||||
// Externally exposed state. All internal states are mapped to one of these broader states.
|
||||
typedef enum
|
||||
{
|
||||
@@ -324,4 +323,4 @@ public:
|
||||
virtual void HandleAddLocalPlayerFailed(int idx) = 0;
|
||||
virtual void HandleDisconnect(bool bLostRoomOnly,bool bPSNSignOut=false) = 0;
|
||||
virtual void HandleInviteReceived( int userIndex, const SQRNetworkManager::PresenceSyncInfo *pInviteInfo) = 0;
|
||||
};
|
||||
};
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "stdafx.h"
|
||||
#ifndef DISABLE_PSN
|
||||
#include "SQRNetworkPlayer.h"
|
||||
|
||||
#ifdef __PS3__
|
||||
@@ -609,3 +610,4 @@ bool SQRNetworkPlayer::IsMutedByLocalUser(int userIndex)
|
||||
return SonyVoiceChat::isMutedPlayer(pMan->m_roomSyncData.players[userIndex].m_roomMemberId);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
@@ -124,7 +124,7 @@ class SQRNetworkPlayer
|
||||
int GetTotalSendQueueMessages();
|
||||
|
||||
|
||||
#ifdef __PSVITA__
|
||||
#if !defined(DISABLE_PSN) && defined(__PSVITA__)
|
||||
void SendInternal_VitaAdhoc(const void *data, unsigned int dataSize, EAdhocDataTag tag = e_dataTag_Normal);
|
||||
void SendMoreInternal_VitaAdhoc();
|
||||
#endif
|
||||
|
||||
@@ -54,7 +54,7 @@ void IUIScene_StartGame::HandleDLCMountingComplete()
|
||||
for(unsigned int i = 0; i < app.GetDLCInfoTexturesOffersCount(); ++i)
|
||||
{
|
||||
bTexturePackAlreadyListed=false;
|
||||
#if defined(__PS3__) || defined(__ORBIS__) || defined(__PSVITA__)
|
||||
#if !defined(DISABLE_PSN) && (defined(__PS3__) || defined(__ORBIS__) || defined(__PSVITA__))
|
||||
char *pchName=app.GetDLCInfoTextures(i);
|
||||
pDLCInfo=app.GetDLCInfo(pchName);
|
||||
#elif defined _XBOX_ONE
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#include "..\..\..\Minecraft.World\LevelType.h"
|
||||
#include "..\..\DLCTexturePack.h"
|
||||
|
||||
#ifdef __PSVITA__
|
||||
#if !defined(DISABLE_PSN) && defined(__PSVITA__)
|
||||
#include "PSVita\Network\SQRNetworkManager_AdHoc_Vita.h"
|
||||
#endif
|
||||
|
||||
@@ -959,11 +959,19 @@ void UIScene_CreateWorldMenu::checkStateAndStartGame()
|
||||
else
|
||||
{
|
||||
//ProfileManager.RequestSignInUI(false, false, false, true, false,&CScene_MultiGameCreate::StartGame_SignInReturned, this,ProfileManager.GetPrimaryPad());
|
||||
#if defined(_WINDOWS64) || defined(DISABLE_PSN) || defined(_DISABLE_XBLIVE)
|
||||
SignInInfo info;
|
||||
info.Func = &UIScene_CreateWorldMenu::StartGame_SignInReturned;
|
||||
info.lpParam = this;
|
||||
info.requireOnline = m_MoreOptionsParams.bOnlineGame;
|
||||
UIScene_CreateWorldMenu::StartGame_SignInReturned(this, true, ProfileManager.GetPrimaryPad());
|
||||
#else
|
||||
SignInInfo info;
|
||||
info.Func = &UIScene_CreateWorldMenu::StartGame_SignInReturned;
|
||||
info.lpParam = this;
|
||||
info.requireOnline = m_MoreOptionsParams.bOnlineGame;
|
||||
ui.NavigateToScene(ProfileManager.GetPrimaryPad(),eUIScene_QuadrantSignin,&info);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -1044,7 +1052,7 @@ void UIScene_CreateWorldMenu::CreateGame(UIScene_CreateWorldMenu* pClass, DWORD
|
||||
#endif
|
||||
|
||||
bool isClientSide = ProfileManager.IsSignedInLive(ProfileManager.GetPrimaryPad()) && pClass->m_MoreOptionsParams.bOnlineGame;
|
||||
#ifdef __PSVITA__
|
||||
#if !defined DISABLE_PSN && defined __PSVITA__
|
||||
if(CGameNetworkManager::usingAdhocMode())
|
||||
{
|
||||
if(SQRNetworkManager_AdHoc_Vita::GetAdhocStatus())// && pClass->m_MoreOptionsParams.bOnlineGame)
|
||||
@@ -1342,12 +1350,16 @@ int UIScene_CreateWorldMenu::ConfirmCreateReturned(void *pParam,int iPad,C4JStor
|
||||
|
||||
if(isClientSide && app.IsLocalMultiplayerAvailable())
|
||||
{
|
||||
#if defined(_WINDOWS64) || defined(DISABLE_PSN) || defined(_DISABLE_XBLIVE)
|
||||
UIScene_CreateWorldMenu::StartGame_SignInReturned(pClass, true, ProfileManager.GetPrimaryPad());
|
||||
#else
|
||||
//ProfileManager.RequestSignInUI(false, false, false, true, false,&UIScene_CreateWorldMenu::StartGame_SignInReturned, pClass,ProfileManager.GetPrimaryPad());
|
||||
SignInInfo info;
|
||||
info.Func = &UIScene_CreateWorldMenu::StartGame_SignInReturned;
|
||||
info.lpParam = pClass;
|
||||
info.requireOnline = pClass->m_MoreOptionsParams.bOnlineGame;
|
||||
ui.NavigateToScene(ProfileManager.GetPrimaryPad(),eUIScene_QuadrantSignin,&info);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1392,17 +1404,21 @@ int UIScene_CreateWorldMenu::ConfirmCreateReturned(void *pParam,int iPad,C4JStor
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef __ORBIS__
|
||||
#if defined(__ORBIS__)
|
||||
int UIScene_CreateWorldMenu::MustSignInReturnedPSN(void *pParam,int iPad,C4JStorage::EMessageResult result)
|
||||
{
|
||||
UIScene_CreateWorldMenu* pClass = (UIScene_CreateWorldMenu *)pParam;
|
||||
pClass->m_bIgnoreInput = false;
|
||||
#ifdef DISABLE_PSN
|
||||
UIScene_CreateWorldMenu::StartGame_SignInReturned(pClass, true, iPad);
|
||||
#else
|
||||
|
||||
if(result==C4JStorage::EMessage_ResultAccept)
|
||||
{
|
||||
SQRNetworkManager_Orbis::AttemptPSNSignIn(&UIScene_CreateWorldMenu::StartGame_SignInReturned, pClass, false, iPad);
|
||||
}
|
||||
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -195,7 +195,7 @@ void UIScene_DLCMainMenu::tick()
|
||||
{
|
||||
UIScene::tick();
|
||||
|
||||
#if defined(__PS3__) || defined(__ORBIS__) || defined (__PSVITA__)
|
||||
#if !defined(DISABLE_PSN) && (defined(__PS3__) || defined(__ORBIS__) || defined (__PSVITA__))
|
||||
if((m_bCategoriesShown==false) && (app.GetCommerceCategoriesRetrieved()))
|
||||
{
|
||||
// disable the timer display on this menu
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#include "Common\Network\Sony\SonyHttp.h"
|
||||
#endif
|
||||
|
||||
#ifdef __PSVITA__
|
||||
#if !defined(DISABLE_PSN) && defined(__PSVITA__)
|
||||
#include "PSVita\Network\SonyCommerce_Vita.h"
|
||||
#endif
|
||||
|
||||
@@ -191,13 +191,13 @@ void UIScene_DLCOffersMenu::handleInput(int iPad, int key, bool repeat, bool pre
|
||||
switch(iTextC)
|
||||
{
|
||||
case 0:
|
||||
m_labelHTMLSellText.init("Voici un fantastique mini-pack de 24 apparences pour personnaliser votre personnage Minecraft et vous mettre dans l'ambiance des fêtes de fin d'année.<br><br>1-4 joueurs<br>2-8 joueurs en réseau<br><br> Cet article fait l’objet d’une licence ou d’une sous-licence de Sony Computer Entertainment America, et est soumis aux conditions générales du service du réseau, au contrat d’utilisateur, aux restrictions d’utilisation de cet article et aux autres conditions applicables, disponibles sur le site www.us.playstation.com/support/useragreements. Si vous ne souhaitez pas accepter ces conditions, ne téléchargez pas ce produit. Cet article peut être utilisé avec un maximum de deux systèmes PlayStation®3 activés associés à ce compte Sony Entertainment Network. <br><br>'Minecraft' est une marque commerciale de Notch Development AB.");
|
||||
m_labelHTMLSellText.init("Voici un fantastique mini-pack de 24 apparences pour personnaliser votre personnage Minecraft et vous mettre dans l'ambiance des f�tes de fin d'ann�e.<br><br>1-4 joueurs<br>2-8 joueurs en r�seau<br><br> Cet article fait l�objet d�une licence ou d�une sous-licence de Sony Computer Entertainment America, et est soumis aux conditions g�n�rales du service du r�seau, au contrat d�utilisateur, aux restrictions d�utilisation de cet article et aux autres conditions applicables, disponibles sur le site www.us.playstation.com/support/useragreements. Si vous ne souhaitez pas accepter ces conditions, ne t�l�chargez pas ce produit. Cet article peut �tre utilis� avec un maximum de deux syst�mes PlayStation�3 activ�s associ�s � ce compte Sony Entertainment Network.�<br><br>'Minecraft' est une marque commerciale de Notch Development AB.");
|
||||
break;
|
||||
case 1:
|
||||
m_labelHTMLSellText.init("Un fabuloso minipack de 24 aspectos para personalizar tu personaje de Minecraft y ponerte a tono con las fiestas.<br><br>1-4 jugadores<br>2-8 jugadores en red<br><br> Sony Computer Entertainment America le concede la licencia o sublicencia de este artículo, que está sujeto a los términos de servicio y al acuerdo de usuario de la red. Las restricciones de uso de este artículo, así como otros términos aplicables, se encuentran en www.us.playstation.com/support/useragreements. Si no desea aceptar todos estos términos, no descargue este artículo. Este artículo puede usarse en hasta dos sistemas PlayStation®3 activados asociados con esta cuenta de Sony Entertainment Network. <br><br>'Minecraft' es una marca comercial de Notch Development AB.");
|
||||
m_labelHTMLSellText.init("Un fabuloso minipack de 24 aspectos para personalizar tu personaje de Minecraft y ponerte a tono con las fiestas.<br><br>1-4 jugadores<br>2-8 jugadores en red<br><br> Sony Computer Entertainment America le concede la licencia o sublicencia de este art�culo, que est� sujeto a los t�rminos de servicio y al acuerdo de usuario de la red. Las restricciones de uso de este art�culo, as� como otros t�rminos aplicables, se encuentran en www.us.playstation.com/support/useragreements. Si no desea aceptar todos estos t�rminos, no descargue este art�culo. Este art�culo puede usarse en hasta dos sistemas PlayStation�3 activados asociados con esta cuenta de Sony Entertainment Network.�<br><br>'Minecraft' es una marca comercial de Notch Development AB.");
|
||||
break;
|
||||
case 2:
|
||||
m_labelHTMLSellText.init("Este é um incrível pacote com 24 capas para personalizar seu personagem no Minecraft e entrar no clima de final de ano.<br><br>1-4 Jogadores<br>Jogadores em rede 2-8<br><br> Este item está sendo licenciado ou sublicenciado para você pela Sony Computer Entertainment America e está sujeito aos Termos de Serviço da Rede e Acordo do Usuário, as restrições de uso deste item e outros termos aplicáveis estão localizados em www.us.playstation.com/support/useragreements. Caso não queira aceitar todos esses termos, não baixe este item. Este item pode ser usado com até 2 sistemas PlayStation®3 ativados associados a esta Conta de Rede Sony Entertainment. <br><br>'Minecraft' é uma marca registrada da Notch Development AB");
|
||||
m_labelHTMLSellText.init("Este � um incr�vel pacote com 24 capas para personalizar seu personagem no Minecraft e entrar no clima de final de ano.<br><br>1-4 Jogadores<br>Jogadores em rede 2-8<br><br> Este item est� sendo licenciado ou sublicenciado para voc� pela Sony Computer Entertainment America e est� sujeito aos Termos de Servi�o da Rede e Acordo do Usu�rio, as restri��es de uso deste item e outros termos aplic�veis est�o localizados em www.us.playstation.com/support/useragreements. Caso n�o queira aceitar todos esses termos, n�o baixe este item. Este item pode ser usado com at� 2 sistemas PlayStation�3 ativados associados a esta Conta de Rede Sony Entertainment.�<br><br>'Minecraft' � uma marca registrada da Notch Development AB");
|
||||
break;
|
||||
}
|
||||
iTextC++;
|
||||
@@ -333,7 +333,7 @@ void UIScene_DLCOffersMenu::tick()
|
||||
{
|
||||
UIScene::tick();
|
||||
|
||||
#if defined(__PS3__) || defined(__ORBIS__) || defined (__PSVITA__)
|
||||
#if !defined(DISABLE_PSN) && (defined(__PS3__) || defined(__ORBIS__) || defined (__PSVITA__))
|
||||
|
||||
if(m_bAddAllDLCButtons)
|
||||
{
|
||||
@@ -504,7 +504,7 @@ void UIScene_DLCOffersMenu::tick()
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef __PSVITA__
|
||||
#if !defined(DISABLE_PSN) && defined(__PSVITA__)
|
||||
// MGH - fixes bug 5768 on Vita - should be extended properly to work for other platforms
|
||||
if((SonyCommerce_Vita::getPurchasabilityUpdated()) && app.GetCommerceProductListRetrieved()&& app.GetCommerceProductListInfoRetrieved() && m_iTotalDLC > 0)
|
||||
{
|
||||
|
||||
@@ -253,7 +253,7 @@ void UIScene_InGameInfoMenu::handleInput(int iPad, int key, bool repeat, bool pr
|
||||
}
|
||||
break;
|
||||
case ACTION_MENU_Y:
|
||||
#if defined(__PS3__) || defined(__ORBIS__)
|
||||
#if !defined(DISABLE_PSN) && (defined(__PS3__) || defined(__ORBIS__))
|
||||
if(pressed && iPad == ProfileManager.GetPrimaryPad())
|
||||
{
|
||||
#ifdef __PS3__
|
||||
@@ -290,7 +290,7 @@ void UIScene_InGameInfoMenu::handleInput(int iPad, int key, bool repeat, bool pr
|
||||
{
|
||||
#ifdef __PSVITA__
|
||||
PSVITA_STUBBED;
|
||||
#else
|
||||
#elif !defined(DISABLE_PSN)
|
||||
ProfileManager.ShowProfileCard(iPad,uid);
|
||||
#endif
|
||||
}
|
||||
@@ -502,6 +502,9 @@ UIScene_InGameInfoMenu::PlayerInfo *UIScene_InGameInfoMenu::BuildPlayerInfo(INet
|
||||
#if defined __PS3__ || defined __PSVITA__
|
||||
int UIScene_InGameInfoMenu::MustSignInReturnedPSN(void *pParam,int iPad,C4JStorage::EMessageResult result)
|
||||
{
|
||||
#ifdef DISABLE_PSN
|
||||
return 0;
|
||||
#else
|
||||
UIScene_InGameInfoMenu* pClass = (UIScene_InGameInfoMenu*)pParam;
|
||||
|
||||
if(result==C4JStorage::EMessage_ResultAccept)
|
||||
@@ -514,6 +517,7 @@ int UIScene_InGameInfoMenu::MustSignInReturnedPSN(void *pParam,int iPad,C4JStora
|
||||
}
|
||||
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
int UIScene_InGameInfoMenu::ViewInvites_SignInReturned(void *pParam,bool bContinue, int iPad)
|
||||
@@ -528,7 +532,7 @@ int UIScene_InGameInfoMenu::ViewInvites_SignInReturned(void *pParam,bool bContin
|
||||
#elif defined(__PS3__)
|
||||
int ret = sceNpBasicRecvMessageCustom(SCE_NP_BASIC_MESSAGE_MAIN_TYPE_INVITE, SCE_NP_BASIC_RECV_MESSAGE_OPTIONS_INCLUDE_BOOTABLE, SYS_MEMORY_CONTAINER_ID_INVALID);
|
||||
app.DebugPrintf("sceNpBasicRecvMessageCustom return %d ( %08x )\n", ret, ret);
|
||||
#else // __PSVITA__
|
||||
#elif !defined(DISABLE_PSN) // __PSVITA__
|
||||
SQRNetworkManager_Vita::RecvInviteGUI();
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include "..\..\MinecraftServer.h"
|
||||
#include "..\..\..\Minecraft.World\net.minecraft.world.level.h"
|
||||
#include "..\..\..\Minecraft.World\net.minecraft.world.h"
|
||||
#include "..\..\Common\Network\NetworkSocketLayer.h"
|
||||
|
||||
#define UPDATE_PLAYERS_TIMER_ID 0
|
||||
#define UPDATE_PLAYERS_TIMER_TIME 30000
|
||||
@@ -50,7 +51,6 @@ void UIScene_JoinMenu::tick()
|
||||
g_NetworkManager.GetFullFriendSessionInfo(m_selectedSession, &friendSessionUpdated, this);
|
||||
m_friendInfoRequestIssued = true;
|
||||
}
|
||||
|
||||
if( m_friendInfoUpdatedOK )
|
||||
{
|
||||
m_friendInfoUpdatedOK = false;
|
||||
@@ -59,7 +59,7 @@ void UIScene_JoinMenu::tick()
|
||||
|
||||
m_buttonListPlayers.init(eControl_GamePlayers);
|
||||
|
||||
#if defined(__PS3__) || defined(__ORBIS__) || defined __PSVITA__
|
||||
#if !defined(DISABLE_PSN) && (defined(__PS3__) || defined(__ORBIS__) || defined __PSVITA__)
|
||||
for( int i = 0; i < MINECRAFT_NET_MAX_PLAYERS; i++ )
|
||||
{
|
||||
if( m_selectedSession->data.players[i] != NULL )
|
||||
@@ -105,6 +105,21 @@ void UIScene_JoinMenu::tick()
|
||||
break;
|
||||
}
|
||||
}
|
||||
#elif defined(_WINDOWS64) || defined(DISABLE_PSN)
|
||||
for( int i = 0; i < MINECRAFT_NET_MAX_PLAYERS; i++ )
|
||||
{
|
||||
if( m_selectedSession->data.players[i] != 0 && m_selectedSession->data.szPlayers[i][0] != 0 )
|
||||
{
|
||||
string playerName(m_selectedSession->data.szPlayers[i], XUSER_NAME_SIZE);
|
||||
size_t end = playerName.find('\0');
|
||||
if (end != string::npos) playerName.resize(end);
|
||||
m_buttonListPlayers.addItem(playerName);
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
m_labelLabels[eLabel_Difficulty].init(app.GetString(IDS_LABEL_DIFFICULTY));
|
||||
@@ -353,6 +368,15 @@ void UIScene_JoinMenu::checkPrivilegeCallback(LPVOID lpParam, bool hasPrivilege,
|
||||
|
||||
void UIScene_JoinMenu::StartSharedLaunchFlow()
|
||||
{
|
||||
const bool bManualJoin = (g_MultiplayerJoin == true);
|
||||
if (bManualJoin)
|
||||
{
|
||||
JoinGame(this);
|
||||
return;
|
||||
}
|
||||
#if defined DISABLE_PSN
|
||||
JoinGame(this);
|
||||
#else
|
||||
if(!app.IsLocalMultiplayerAvailable())
|
||||
{
|
||||
JoinGame(this);
|
||||
@@ -371,12 +395,17 @@ void UIScene_JoinMenu::StartSharedLaunchFlow()
|
||||
ui.NavigateToScene(ProfileManager.GetPrimaryPad(),eUIScene_QuadrantSignin,&info);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
int UIScene_JoinMenu::StartGame_SignInReturned(void *pParam,bool bContinue, int iPad)
|
||||
{
|
||||
UIScene_JoinMenu* pClass = (UIScene_JoinMenu*)ui.GetSceneFromCallbackId((size_t)pParam);
|
||||
|
||||
#if defined DISABLE_PSN
|
||||
JoinGame(pClass);
|
||||
return 0;
|
||||
#else
|
||||
if(pClass)
|
||||
{
|
||||
if(bContinue==true)
|
||||
@@ -397,11 +426,18 @@ int UIScene_JoinMenu::StartGame_SignInReturned(void *pParam,bool bContinue, int
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
// Shared function to join the game that is the same whether we used the sign-in UI or not
|
||||
void UIScene_JoinMenu::JoinGame(UIScene_JoinMenu* pClass)
|
||||
{
|
||||
if (pClass == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
const bool bManualJoin = (g_MultiplayerJoin == true);
|
||||
|
||||
DWORD dwSignedInUsers = 0;
|
||||
bool noPrivileges = false;
|
||||
DWORD dwLocalUsersMask = 0;
|
||||
@@ -409,10 +445,14 @@ void UIScene_JoinMenu::JoinGame(UIScene_JoinMenu* pClass)
|
||||
int iPadNotSignedInLive = -1;
|
||||
|
||||
ProfileManager.SetLockedProfile(0); // TEMP!
|
||||
if (bManualJoin)
|
||||
{
|
||||
isSignedInLive = true;
|
||||
}
|
||||
|
||||
// If we're in SD mode, then only the primary player gets to play
|
||||
if (app.IsLocalMultiplayerAvailable())
|
||||
{
|
||||
{
|
||||
for(unsigned int index = 0; index < XUSER_MAX_COUNT; ++index)
|
||||
{
|
||||
if(ProfileManager.IsSignedIn(index))
|
||||
@@ -423,7 +463,7 @@ void UIScene_JoinMenu::JoinGame(UIScene_JoinMenu* pClass)
|
||||
iPadNotSignedInLive = index;
|
||||
}
|
||||
|
||||
if( !ProfileManager.AllowedToPlayMultiplayer(index) ) noPrivileges = true;
|
||||
if( !bManualJoin && !ProfileManager.AllowedToPlayMultiplayer(index) ) noPrivileges = true;
|
||||
dwLocalUsersMask |= CGameNetworkManager::GetLocalPlayerMask(index);
|
||||
isSignedInLive = isSignedInLive && ProfileManager.IsSignedInLive(index);
|
||||
}
|
||||
@@ -433,11 +473,13 @@ void UIScene_JoinMenu::JoinGame(UIScene_JoinMenu* pClass)
|
||||
{
|
||||
if(ProfileManager.IsSignedIn(ProfileManager.GetPrimaryPad()))
|
||||
{
|
||||
if( !ProfileManager.AllowedToPlayMultiplayer(ProfileManager.GetPrimaryPad()) ) noPrivileges = true;
|
||||
if( !bManualJoin && !ProfileManager.AllowedToPlayMultiplayer(ProfileManager.GetPrimaryPad()) ) noPrivileges = true;
|
||||
dwLocalUsersMask |= CGameNetworkManager::GetLocalPlayerMask(ProfileManager.GetPrimaryPad());
|
||||
|
||||
#ifndef DISABLE_PSN
|
||||
isSignedInLive = ProfileManager.IsSignedInLive(ProfileManager.GetPrimaryPad());
|
||||
#ifdef __PSVITA__
|
||||
#endif
|
||||
#if !defined DISABLE_PSN && defined __PSVITA__
|
||||
if(CGameNetworkManager::usingAdhocMode() && SQRNetworkManager_AdHoc_Vita::GetAdhocStatus())
|
||||
isSignedInLive = true;
|
||||
#endif
|
||||
@@ -446,7 +488,7 @@ void UIScene_JoinMenu::JoinGame(UIScene_JoinMenu* pClass)
|
||||
}
|
||||
|
||||
// If this is an online game but not all players are signed in to Live, stop!
|
||||
if (!isSignedInLive)
|
||||
if (!bManualJoin && !isSignedInLive)
|
||||
{
|
||||
#ifdef __ORBIS__
|
||||
// Check if PSN is unavailable because of age restriction
|
||||
@@ -475,15 +517,23 @@ void UIScene_JoinMenu::JoinGame(UIScene_JoinMenu* pClass)
|
||||
BOOL pccAllowed = TRUE;
|
||||
BOOL pccFriendsAllowed = TRUE;
|
||||
|
||||
#if defined(__PS3__) || defined(__PSVITA__)
|
||||
if(isSignedInLive)
|
||||
#if !defined(DISABLE_PSN) && (defined(__PS3__) || defined(__PSVITA__))
|
||||
if(!bManualJoin && isSignedInLive)
|
||||
{
|
||||
ProfileManager.GetChatAndContentRestrictions(ProfileManager.GetPrimaryPad(),false,&noUGC,NULL,NULL);
|
||||
}
|
||||
#else
|
||||
ProfileManager.AllowedPlayerCreatedContent(ProfileManager.GetPrimaryPad(),false,&pccAllowed,&pccFriendsAllowed);
|
||||
if(!pccAllowed && !pccFriendsAllowed) noUGC = true;
|
||||
if(!bManualJoin)
|
||||
{
|
||||
ProfileManager.AllowedPlayerCreatedContent(ProfileManager.GetPrimaryPad(),false,&pccAllowed,&pccFriendsAllowed);
|
||||
if(!pccAllowed && !pccFriendsAllowed) noUGC = true;
|
||||
}
|
||||
#endif
|
||||
if (bManualJoin)
|
||||
{
|
||||
noUGC = false;
|
||||
noPrivileges = false;
|
||||
}
|
||||
|
||||
|
||||
#ifdef __PSVITA__
|
||||
@@ -513,13 +563,16 @@ void UIScene_JoinMenu::JoinGame(UIScene_JoinMenu* pClass)
|
||||
ui.RequestErrorMessage( IDS_NO_MULTIPLAYER_PRIVILEGE_TITLE, IDS_NO_MULTIPLAYER_PRIVILEGE_JOIN_TEXT, uiIDA,1,ProfileManager.GetPrimaryPad());
|
||||
}
|
||||
else
|
||||
{
|
||||
#if defined(__ORBIS__) || defined(__PSVITA__)
|
||||
bool chatRestricted = false;
|
||||
ProfileManager.GetChatAndContentRestrictions(ProfileManager.GetPrimaryPad(),false,&chatRestricted,NULL,NULL);
|
||||
if(chatRestricted)
|
||||
{
|
||||
ProfileManager.DisplaySystemMessage( SCE_MSG_DIALOG_SYSMSG_TYPE_TRC_PSN_CHAT_RESTRICTION, ProfileManager.GetPrimaryPad() );
|
||||
#if defined(__ORBIS__) || defined(__PSVITA__)
|
||||
if(!bManualJoin)
|
||||
{
|
||||
bool chatRestricted = false;
|
||||
ProfileManager.GetChatAndContentRestrictions(ProfileManager.GetPrimaryPad(),false,&chatRestricted,NULL,NULL);
|
||||
if(chatRestricted)
|
||||
{
|
||||
ProfileManager.DisplaySystemMessage( SCE_MSG_DIALOG_SYSMSG_TYPE_TRC_PSN_CHAT_RESTRICTION, ProfileManager.GetPrimaryPad() );
|
||||
}
|
||||
}
|
||||
#endif
|
||||
CGameNetworkManager::eJoinGameResult result = g_NetworkManager.JoinGame( pClass->m_selectedSession, dwLocalUsersMask );
|
||||
@@ -529,6 +582,7 @@ void UIScene_JoinMenu::JoinGame(UIScene_JoinMenu* pClass)
|
||||
|
||||
if( result != CGameNetworkManager::JOINGAME_SUCCESS )
|
||||
{
|
||||
pClass->m_bIgnoreInput = false;
|
||||
int exitReasonStringId = -1;
|
||||
switch(result)
|
||||
{
|
||||
@@ -551,6 +605,21 @@ void UIScene_JoinMenu::JoinGame(UIScene_JoinMenu* pClass)
|
||||
ui.NavigateToHomeMenu();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LoadingInputParams *loadingParams = new LoadingInputParams();
|
||||
loadingParams->func = &CGameNetworkManager::RunNetworkGameThreadProc;
|
||||
loadingParams->lpParam = NULL;
|
||||
|
||||
UIFullscreenProgressCompletionData *completionData = new UIFullscreenProgressCompletionData();
|
||||
completionData->bShowBackground = TRUE;
|
||||
completionData->bShowLogo = TRUE;
|
||||
completionData->type = e_ProgressCompletion_CloseAllPlayersUIScenes;
|
||||
completionData->iPad = DEFAULT_XUI_MENU_USER;
|
||||
loadingParams->completionData = completionData;
|
||||
|
||||
ui.NavigateToScene(ProfileManager.GetPrimaryPad(), eUIScene_FullscreenProgress, loadingParams);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -595,7 +664,31 @@ void UIScene_JoinMenu::handleTimerComplete(int id)
|
||||
playersList.SetCurSel(selectedIndex);
|
||||
}
|
||||
#endif
|
||||
#if defined(_WINDOWS64) || defined(DISABLE_PSN)
|
||||
{
|
||||
bool success = g_NetworkManager.GetGameSessionInfo(m_iPad, m_selectedSession->sessionId, m_selectedSession);
|
||||
if (success)
|
||||
{
|
||||
m_buttonListPlayers.clearList();
|
||||
for (unsigned int i = 0; i < MINECRAFT_NET_MAX_PLAYERS; ++i)
|
||||
{
|
||||
if (m_selectedSession->data.players[i] != 0 && m_selectedSession->data.szPlayers[i][0] != 0)
|
||||
{
|
||||
string playerName(m_selectedSession->data.szPlayers[i], XUSER_NAME_SIZE);
|
||||
size_t end = playerName.find('\0');
|
||||
if (end != string::npos) playerName.resize(end);
|
||||
m_buttonListPlayers.addItem(playerName);
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
addTimer(UPDATE_PLAYERS_TIMER_ID, UPDATE_PLAYERS_TIMER_TIME);
|
||||
}
|
||||
break;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -731,7 +731,7 @@ void UIScene_LeaderboardsMenu::CopyLeaderboardEntry(LeaderboardManager::ReadScor
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef __PS3__
|
||||
#if !defined(DISABLE_PSN) && defined(__PS3__)
|
||||
// m_name can be unicode characters somehow for Japan - should use m_onlineID
|
||||
wstring wstr=convStringToWstring(statsRow->m_uid.getOnlineID());
|
||||
swprintf(leaderboardEntry->m_gamerTag, XUSER_NAME_SIZE, L"%ls",wstr.c_str());
|
||||
|
||||
@@ -879,6 +879,7 @@ void UIScene_LoadMenu::StartSharedLaunchFlow()
|
||||
app.SetGameHostOption(eGameHostOption_DisableSaving, m_MoreOptionsParams.bDisableSaving?1:0);
|
||||
StorageManager.SetSaveDisabled(m_MoreOptionsParams.bDisableSaving);
|
||||
|
||||
#ifdef _LARGE_WORLDS
|
||||
int newWorldSize = 0;
|
||||
int newHellScale = 0;
|
||||
switch(m_MoreOptionsParams.newWorldSize)
|
||||
@@ -911,6 +912,7 @@ void UIScene_LoadMenu::StartSharedLaunchFlow()
|
||||
app.SetGameNewWorldSize(newWorldSize, bUseMoat);
|
||||
app.SetGameNewHellScale(newHellScale);
|
||||
app.SetGameHostOption(eGameHostOption_WorldSize, m_MoreOptionsParams.newWorldSize);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1447,7 +1449,12 @@ int UIScene_LoadMenu::LoadDataComplete(void *pParam)
|
||||
#ifndef _WINDOWS64
|
||||
else
|
||||
{
|
||||
#if defined(_WINDOWS64) || defined(DISABLE_PSN) || defined(_DISABLE_XBLIVE)
|
||||
DWORD dwLocalUsersMask = CGameNetworkManager::GetLocalPlayerMask(ProfileManager.GetPrimaryPad());
|
||||
StartGameFromSave(pClass, dwLocalUsersMask);
|
||||
#else
|
||||
pClass->m_bRequestQuadrantSignin = true;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -1554,7 +1561,7 @@ void UIScene_LoadMenu::StartGameFromSave(UIScene_LoadMenu* pClass, DWORD dwLocal
|
||||
}
|
||||
|
||||
bool isClientSide = ProfileManager.IsSignedInLive(ProfileManager.GetPrimaryPad()) && pClass->m_MoreOptionsParams.bOnlineGame;
|
||||
#ifdef __PSVITA__
|
||||
#if !defined DISABLE_PSN && defined __PSVITA__
|
||||
if(CGameNetworkManager::usingAdhocMode())
|
||||
{
|
||||
if(SQRNetworkManager_AdHoc_Vita::GetAdhocStatus())// && pClass->m_MoreOptionsParams.bOnlineGame)
|
||||
@@ -1788,17 +1795,20 @@ void UIScene_LoadMenu::handleGainFocus(bool navBack)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef __ORBIS__
|
||||
#if defined __ORBIS__
|
||||
int UIScene_LoadMenu::MustSignInReturnedPSN(void *pParam,int iPad,C4JStorage::EMessageResult result)
|
||||
{
|
||||
UIScene_LoadMenu* pClass = (UIScene_LoadMenu *)pParam;
|
||||
pClass->m_bIgnoreInput = false;
|
||||
|
||||
#ifdef DISABLE_PSN
|
||||
UIScene_LoadMenu::StartGame_SignInReturned(pParam, true, iPad);
|
||||
#else
|
||||
if(result==C4JStorage::EMessage_ResultAccept)
|
||||
{
|
||||
SQRNetworkManager_Orbis::AttemptPSNSignIn(&UIScene_LoadMenu::StartGame_SignInReturned, pClass, false, iPad);
|
||||
}
|
||||
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#include "..\..\TexturePackRepository.h"
|
||||
#include "..\..\TexturePack.h"
|
||||
#include "..\Network\SessionInfo.h"
|
||||
#include "..\..\Common\Network\NetworkSocketLayer.h"
|
||||
#if defined(__PS3__) || defined(__ORBIS__) || defined(__PSVITA__)
|
||||
#include "Common\Network\Sony\SonyHttp.h"
|
||||
#include "Common\Network\Sony\SonyRemoteStorage.h"
|
||||
@@ -182,7 +183,7 @@ UIScene_LoadOrJoinMenu::UIScene_LoadOrJoinMenu(int iPad, void *initData, UILayer
|
||||
|
||||
Initialise();
|
||||
|
||||
#ifdef __PSVITA__
|
||||
#if !defined DISABLE_PSN && defined __PSVITA__
|
||||
if(CGameNetworkManager::usingAdhocMode() && SQRNetworkManager_AdHoc_Vita::GetAdhocStatus())
|
||||
{
|
||||
g_NetworkManager.startAdhocMatching(); // create the client matching context and clear out the friends list
|
||||
@@ -291,13 +292,7 @@ UIScene_LoadOrJoinMenu::~UIScene_LoadOrJoinMenu()
|
||||
g_NetworkManager.SetSessionsUpdatedCallback( NULL, NULL );
|
||||
app.SetLiveLinkRequired( false );
|
||||
|
||||
if(m_currentSessions)
|
||||
{
|
||||
for(AUTO_VAR(it, m_currentSessions->begin()); it < m_currentSessions->end(); ++it)
|
||||
{
|
||||
delete (*it);
|
||||
}
|
||||
}
|
||||
delete m_currentSessions;
|
||||
|
||||
#if TO_BE_IMPLEMENTED
|
||||
// Reset the background downloading, in case we changed it by attempting to download a texture pack
|
||||
@@ -1040,7 +1035,7 @@ void UIScene_LoadOrJoinMenu::handleInput(int iPad, int key, bool repeat, bool pr
|
||||
#endif
|
||||
break;
|
||||
case ACTION_MENU_Y:
|
||||
#if defined(__PS3__) || defined(__PSVITA__) || defined(__ORBIS__)
|
||||
#if !defined(DISABLE_PSN) && (defined(__PS3__) || defined(__PSVITA__) || defined(__ORBIS__))
|
||||
m_eAction = eAction_ViewInvites;
|
||||
if(pressed && iPad == ProfileManager.GetPrimaryPad())
|
||||
{
|
||||
@@ -1412,20 +1407,24 @@ void UIScene_LoadOrJoinMenu::CheckAndJoinGame(int gameIndex)
|
||||
if( m_buttonListGames.getItemCount() > 0 && gameIndex < m_currentSessions->size() )
|
||||
{
|
||||
#if defined(__PS3__) || defined(__ORBIS__) || defined(__PSVITA__)
|
||||
const bool bManualJoin = (g_MultiplayerJoin == true);
|
||||
// 4J-PB - is the player allowed to join games?
|
||||
bool noUGC=false;
|
||||
bool bContentRestricted=false;
|
||||
|
||||
// we're online, since we are joining a game
|
||||
ProfileManager.GetChatAndContentRestrictions(m_iPad,true,&noUGC,&bContentRestricted,NULL);
|
||||
// A direct LAN join should probnot use PSN matchmaking or account privileges (nansess)
|
||||
if(!bManualJoin)
|
||||
{
|
||||
ProfileManager.GetChatAndContentRestrictions(m_iPad,true,&noUGC,&bContentRestricted,NULL);
|
||||
}
|
||||
|
||||
#ifdef __ORBIS__
|
||||
// 4J Stu - On PS4 we don't restrict playing multiplayer based on chat restriction, so remove this check
|
||||
noUGC = false;
|
||||
|
||||
bool bPlayStationPlus=true;
|
||||
int iPadWithNoPlaystationPlus=0;
|
||||
bool isSignedInLive = true;
|
||||
int iPadWithNoPlaystationPlus=-1;
|
||||
bool isSignedInLive = true;
|
||||
int iPadNotSignedInLive = -1;
|
||||
for(unsigned int i = 0; i < XUSER_MAX_COUNT; ++i)
|
||||
{
|
||||
@@ -1441,6 +1440,7 @@ void UIScene_LoadOrJoinMenu::CheckAndJoinGame(int gameIndex)
|
||||
if(ProfileManager.HasPlayStationPlus(i)==false)
|
||||
{
|
||||
bPlayStationPlus=false;
|
||||
iPadWithNoPlaystationPlus = (int)i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1454,7 +1454,7 @@ void UIScene_LoadOrJoinMenu::CheckAndJoinGame(int gameIndex)
|
||||
}
|
||||
#endif
|
||||
|
||||
if(noUGC)
|
||||
if(!bManualJoin && noUGC)
|
||||
{
|
||||
// not allowed to join
|
||||
#ifndef __PSVITA__
|
||||
@@ -1470,7 +1470,7 @@ void UIScene_LoadOrJoinMenu::CheckAndJoinGame(int gameIndex)
|
||||
m_bIgnoreInput=false;
|
||||
return;
|
||||
}
|
||||
else if(bContentRestricted)
|
||||
else if(!bManualJoin && bContentRestricted)
|
||||
{
|
||||
ui.RequestContentRestrictedMessageBox();
|
||||
|
||||
@@ -1479,7 +1479,7 @@ void UIScene_LoadOrJoinMenu::CheckAndJoinGame(int gameIndex)
|
||||
}
|
||||
#ifdef __ORBIS__
|
||||
// If this is an online game but not all players are signed in to Live, stop!
|
||||
else if (!isSignedInLive)
|
||||
else if (!bManualJoin && !isSignedInLive)
|
||||
{
|
||||
UINT uiIDA[1];
|
||||
uiIDA[0]=IDS_CONFIRM_OK;
|
||||
@@ -1498,7 +1498,7 @@ void UIScene_LoadOrJoinMenu::CheckAndJoinGame(int gameIndex)
|
||||
}
|
||||
return;
|
||||
}
|
||||
else if(bPlayStationPlus==false)
|
||||
else if(!bManualJoin && bPlayStationPlus==false)
|
||||
{
|
||||
|
||||
if(ProfileManager.RequestingPlaystationPlus(iPadWithNoPlaystationPlus))
|
||||
@@ -1507,6 +1507,7 @@ void UIScene_LoadOrJoinMenu::CheckAndJoinGame(int gameIndex)
|
||||
UINT uiIDA[1];
|
||||
uiIDA[0]=IDS_OK;
|
||||
ui.RequestAlertMessage(IDS_ERROR_NETWORK_TITLE, IDS_ERROR_NETWORK, uiIDA, 1, ProfileManager.GetPrimaryPad(), NULL, NULL);
|
||||
m_bIgnoreInput=false;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1579,7 +1580,7 @@ void UIScene_LoadOrJoinMenu::CheckAndJoinGame(int gameIndex)
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef __PSVITA__
|
||||
#if !defined DISABLE_PSN && defined __PSVITA__
|
||||
if(CGameNetworkManager::usingAdhocMode() && !SQRNetworkManager_AdHoc_Vita::GetAdhocStatus())
|
||||
{
|
||||
// not connected to adhoc anymore, must have connected back to PSN to buy texture pack so sign in again
|
||||
@@ -1617,7 +1618,7 @@ void UIScene_LoadOrJoinMenu::LoadLevelGen(LevelGenerationOptions *levelGen)
|
||||
bool isClientSide = false;
|
||||
bool isPrivate = false;
|
||||
// TODO int maxPlayers = MINECRAFT_NET_MAX_PLAYERS;
|
||||
int maxPlayers = 8;
|
||||
int maxPlayers = MINECRAFT_NET_MAX_PLAYERS;
|
||||
|
||||
if( app.GetTutorialMode() )
|
||||
{
|
||||
@@ -2252,6 +2253,9 @@ int UIScene_LoadOrJoinMenu::MustSignInTexturePack(void *pParam,int iPad,C4JStora
|
||||
{
|
||||
UIScene_LoadOrJoinMenu* pClass = (UIScene_LoadOrJoinMenu*)pParam;
|
||||
|
||||
#ifdef DISABLE_PSN
|
||||
UIScene_LoadOrJoinMenu::MustSignInReturnedTexturePack(pClass, true, iPad);
|
||||
#else
|
||||
if(result==C4JStorage::EMessage_ResultAccept)
|
||||
{
|
||||
SQRNetworkManager_Vita::AttemptPSNSignIn(&UIScene_LoadOrJoinMenu::MustSignInReturnedTexturePack, pClass);
|
||||
@@ -2261,6 +2265,7 @@ int UIScene_LoadOrJoinMenu::MustSignInTexturePack(void *pParam,int iPad,C4JStora
|
||||
pClass->m_bIgnoreInput = false;
|
||||
}
|
||||
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -2406,6 +2411,9 @@ int UIScene_LoadOrJoinMenu::TexturePackDialogReturned(void *pParam,int iPad,C4JS
|
||||
#if defined __PS3__ || defined __PSVITA__ || defined __ORBIS__
|
||||
int UIScene_LoadOrJoinMenu::MustSignInReturnedPSN(void *pParam,int iPad,C4JStorage::EMessageResult result)
|
||||
{
|
||||
#ifdef DISABLE_PSN
|
||||
return 0;
|
||||
#else
|
||||
UIScene_LoadOrJoinMenu* pClass = (UIScene_LoadOrJoinMenu*)pParam;
|
||||
|
||||
if(result==C4JStorage::EMessage_ResultAccept)
|
||||
@@ -2424,6 +2432,7 @@ int UIScene_LoadOrJoinMenu::MustSignInReturnedPSN(void *pParam,int iPad,C4JStora
|
||||
}
|
||||
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
int UIScene_LoadOrJoinMenu::PSN_SignInReturned(void *pParam,bool bContinue, int iPad)
|
||||
@@ -2437,6 +2446,7 @@ int UIScene_LoadOrJoinMenu::PSN_SignInReturned(void *pParam,bool bContinue, int
|
||||
// Check if we're signed in to LIVE
|
||||
if(ProfileManager.IsSignedInLive(iPad))
|
||||
{
|
||||
#ifndef DISABLE_PSN
|
||||
#if defined(__PS3__)
|
||||
int ret = sceNpBasicRecvMessageCustom(SCE_NP_BASIC_MESSAGE_MAIN_TYPE_INVITE, SCE_NP_BASIC_RECV_MESSAGE_OPTIONS_INCLUDE_BOOTABLE, SYS_MEMORY_CONTAINER_ID_INVALID);
|
||||
app.DebugPrintf("sceNpBasicRecvMessageCustom return %d ( %08x )\n", ret, ret);
|
||||
@@ -2444,6 +2454,7 @@ int UIScene_LoadOrJoinMenu::PSN_SignInReturned(void *pParam,bool bContinue, int
|
||||
SQRNetworkManager_Vita::RecvInviteGUI();
|
||||
#else
|
||||
SQRNetworkManager_Orbis::RecvInviteGUI();
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "UIScene_MainMenu.h"
|
||||
#ifdef __ORBIS__
|
||||
#include <error_dialog.h>
|
||||
#include "..\..\Common\Network\NetworkSocketLayer.h"
|
||||
#endif
|
||||
|
||||
Random *UIScene_MainMenu::random = new Random();
|
||||
@@ -318,7 +319,16 @@ void UIScene_MainMenu::handlePress(F64 controlId, F64 childId)
|
||||
//CD - Added for audio
|
||||
ui.PlayUISFX(eSFX_Press);
|
||||
|
||||
ProfileManager.RefreshChatAndContentRestrictions(RefreshChatAndContentRestrictionsReturned_PlayGame, this);
|
||||
if(g_MultiplayerJoin)
|
||||
{
|
||||
// request only completes after the platform network timeout.
|
||||
// this needs to be done before hand or else the PS4 crashes ill need to look more into this
|
||||
CreateLoad_SignInReturned(this, true, primaryPad);
|
||||
}
|
||||
else
|
||||
{
|
||||
ProfileManager.RefreshChatAndContentRestrictions(RefreshChatAndContentRestrictionsReturned_PlayGame, this);
|
||||
}
|
||||
}
|
||||
#else
|
||||
m_eAction=eAction_RunGame;
|
||||
@@ -373,6 +383,10 @@ void UIScene_MainMenu::handlePress(F64 controlId, F64 childId)
|
||||
ui.NavigateToScene(primaryPad,eUIScene_TrialExitUpsell);
|
||||
}
|
||||
break;
|
||||
#elif defined _WINDOWS64
|
||||
case eControl_Exit:
|
||||
app.ExitGame();
|
||||
break;
|
||||
#endif
|
||||
|
||||
#ifdef _DURANGO
|
||||
@@ -547,6 +561,7 @@ int UIScene_MainMenu::MustSignInReturnedPSN(void *pParam,int iPad,C4JStorage::EM
|
||||
{
|
||||
UIScene_MainMenu* pClass = (UIScene_MainMenu*)pParam;
|
||||
|
||||
#ifndef DISABLE_PSN
|
||||
if(result==C4JStorage::EMessage_ResultAccept)
|
||||
{
|
||||
#ifdef __PS3__
|
||||
@@ -626,6 +641,9 @@ int UIScene_MainMenu::MustSignInReturnedPSN(void *pParam,int iPad,C4JStorage::EM
|
||||
pClass->m_bIgnorePress=false;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
CreateLoad_SignInReturned(pClass, true, 0);
|
||||
pClass->m_bIgnorePress=false;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -733,7 +751,7 @@ int UIScene_MainMenu::CreateLoad_SignInReturned(void *pParam, bool bContinue, in
|
||||
if(ProfileManager.IsFullVersion())
|
||||
{
|
||||
bool bSignedInLive = ProfileManager.IsSignedInLive(iPad);
|
||||
#ifdef __PSVITA__
|
||||
#if !defined DISABLE_PSN && defined __PSVITA__
|
||||
if(CGameNetworkManager::usingAdhocMode())
|
||||
{
|
||||
if(SQRNetworkManager_AdHoc_Vita::GetAdhocStatus())
|
||||
@@ -1089,6 +1107,12 @@ void UIScene_MainMenu::RefreshChatAndContentRestrictionsReturned_PlayGame(void *
|
||||
int primaryPad = ProfileManager.GetPrimaryPad();
|
||||
|
||||
UIScene_MainMenu* pClass = (UIScene_MainMenu*)pParam;
|
||||
const bool bManualJoin = (g_MultiplayerJoin == true);
|
||||
if (bManualJoin)
|
||||
{
|
||||
CreateLoad_SignInReturned(pClass, true, primaryPad);
|
||||
return;
|
||||
}
|
||||
|
||||
int (*signInReturnedFunc) (LPVOID,const bool, const int iPad) = NULL;
|
||||
|
||||
@@ -1318,7 +1342,7 @@ void UIScene_MainMenu::RunPlayGame(int iPad)
|
||||
{
|
||||
// are we offline?
|
||||
bool bSignedInLive = ProfileManager.IsSignedInLive(iPad);
|
||||
#ifdef __PSVITA__
|
||||
#if !defined DISABLE_PSN && defined __PSVITA__
|
||||
if(app.GetGameSettings(ProfileManager.GetPrimaryPad(),eGameSetting_PSVita_NetworkModeAdhoc) == true)
|
||||
{
|
||||
CGameNetworkManager::setAdhocMode(true);
|
||||
|
||||
@@ -409,7 +409,7 @@ void UIScene_PauseMenu::handleInput(int iPad, int key, bool repeat, bool pressed
|
||||
case ACTION_MENU_Y:
|
||||
{
|
||||
|
||||
#if defined(__PS3__) || defined(__ORBIS__)
|
||||
#if !defined(DISABLE_PSN) && (defined(__PS3__) || defined(__ORBIS__))
|
||||
if(pressed && iPad == ProfileManager.GetPrimaryPad())
|
||||
{
|
||||
#ifdef __ORBIS__
|
||||
@@ -1029,6 +1029,9 @@ int UIScene_PauseMenu::BanGameDialogReturned(void *pParam,int iPad,C4JStorage::E
|
||||
#if defined(__PS3__) || defined (__PSVITA__) || defined(__ORBIS__)
|
||||
int UIScene_PauseMenu::MustSignInReturnedPSN(void *pParam,int iPad,C4JStorage::EMessageResult result)
|
||||
{
|
||||
#ifdef DISABLE_PSN
|
||||
return 0;
|
||||
#else
|
||||
UIScene_PauseMenu* pClass = (UIScene_PauseMenu*)ui.GetSceneFromCallbackId((size_t)pParam);
|
||||
if(result==C4JStorage::EMessage_ResultAccept && pClass)
|
||||
{
|
||||
@@ -1091,6 +1094,7 @@ int UIScene_PauseMenu::MustSignInReturnedPSN(void *pParam,int iPad,C4JStorage::E
|
||||
}
|
||||
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
int UIScene_PauseMenu::ViewLeaderboards_SignInReturned(void *pParam,bool bContinue, int iPad)
|
||||
@@ -1131,6 +1135,9 @@ int UIScene_PauseMenu::ViewLeaderboards_SignInReturned(void *pParam,bool bContin
|
||||
|
||||
int UIScene_PauseMenu::WarningTrialTexturePackReturned(void *pParam,int iPad,C4JStorage::EMessageResult result)
|
||||
{
|
||||
#ifdef DISABLE_PSN
|
||||
return 0;
|
||||
#else
|
||||
UIScene_PauseMenu* pClass = (UIScene_PauseMenu*)ui.GetSceneFromCallbackId((size_t)pParam);
|
||||
|
||||
#ifdef __ORBIS__
|
||||
@@ -1244,7 +1251,7 @@ int UIScene_PauseMenu::WarningTrialTexturePackReturned(void *pParam,int iPad,C4J
|
||||
}
|
||||
}
|
||||
#endif //
|
||||
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1333,6 +1340,7 @@ int UIScene_PauseMenu::ViewInvites_SignInReturned(void *pParam,bool bContinue, i
|
||||
// Check if we're signed in to LIVE
|
||||
if(ProfileManager.IsSignedInLive(iPad))
|
||||
{
|
||||
#ifndef DISABLE_PSN
|
||||
#ifdef __ORBIS__
|
||||
SQRNetworkManager_Orbis::RecvInviteGUI();
|
||||
#elif defined __PS3__
|
||||
@@ -1340,6 +1348,7 @@ int UIScene_PauseMenu::ViewInvites_SignInReturned(void *pParam,bool bContinue, i
|
||||
app.DebugPrintf("sceNpBasicRecvMessageCustom return %d ( %08x )\n", ret, ret);
|
||||
#else // __PSVITA__
|
||||
PSVITA_STUBBED;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,7 +110,7 @@ void UIScene_SaveMessage::handlePress(F64 controlId, F64 childId)
|
||||
|
||||
m_bIgnoreInput=true;
|
||||
|
||||
#if defined(__PS3__) || defined(__ORBIS__) || defined(__PSVITA__)
|
||||
#if !defined(DISABLE_PSN) && (defined(__PS3__) || defined(__ORBIS__) || defined(__PSVITA__))
|
||||
// wait for the profile to be read - this has been kicked off earlier, so should be read by now
|
||||
addTimer(PROFILE_LOADED_TIMER_ID,PROFILE_LOADED_TIMER_TIME);
|
||||
#else
|
||||
@@ -141,13 +141,17 @@ void UIScene_SaveMessage::handleTimerComplete(int id)
|
||||
// set defaults - which has already been done
|
||||
killTimer(PROFILE_LOADED_TIMER_ID);
|
||||
ui.NavigateToHomeMenu();
|
||||
#ifndef DISABLE_PSN
|
||||
SQRNetworkManager::SafeToRespondToGameBootInvite();
|
||||
#endif
|
||||
app.SetOptionsCallbackStatus(0,C4JStorage::eOptions_Callback_Idle);
|
||||
break;
|
||||
case C4JStorage::eOptions_Callback_Read_CorruptDeleted:
|
||||
killTimer(PROFILE_LOADED_TIMER_ID);
|
||||
ui.NavigateToHomeMenu();
|
||||
#ifndef DISABLE_PSN
|
||||
SQRNetworkManager::SafeToRespondToGameBootInvite();
|
||||
#endif
|
||||
app.SetOptionsCallbackStatus(0,C4JStorage::eOptions_Callback_Idle);
|
||||
break;
|
||||
case C4JStorage::eOptions_Callback_Read_Corrupt:
|
||||
|
||||
@@ -46,6 +46,7 @@ UIScene_SignEntryMenu::UIScene_SignEntryMenu(int iPad, void *_initData, UILayer
|
||||
m_signRows[i].SetTitleAndText(IDS_SIGN_TITLE,IDS_SIGN_TITLE_TEXT);
|
||||
#endif
|
||||
m_textInputLines[i].init(m_sign->GetMessage(i).c_str(), i);
|
||||
m_textInputLines[i].SetCharLimit(15);
|
||||
}
|
||||
|
||||
parentLayer->addComponent(iPad,eUIComponent_MenuBackground);
|
||||
@@ -150,6 +151,7 @@ int UIScene_SignEntryMenu::KeyboardCompleteCallback(LPVOID lpParam,bool bRes)
|
||||
uint16_t pchText[128];
|
||||
ZeroMemory(pchText, 128 * sizeof(uint16_t) );
|
||||
InputManager.GetText(pchText);
|
||||
pchText[15] = 0;
|
||||
pClass->m_textInputLines[pClass->m_iEditingLine].setLabel((wchar_t *)pchText);
|
||||
}
|
||||
return 0;
|
||||
|
||||
@@ -1518,6 +1518,7 @@ void UIScene_SkinSelectMenu::HandleDLCMountingComplete()
|
||||
void UIScene_SkinSelectMenu::showNotOnlineDialog(int iPad)
|
||||
{
|
||||
// need to be signed in to live. get them to sign in to online
|
||||
#ifndef DISABLE_PSN
|
||||
#if defined(__PS3__)
|
||||
SQRNetworkManager_PS3::AttemptPSNSignIn(NULL, this);
|
||||
|
||||
@@ -1543,6 +1544,7 @@ void UIScene_SkinSelectMenu::showNotOnlineDialog(int iPad)
|
||||
UINT uiIDA[1] = { IDS_CONFIRM_OK };
|
||||
ui.RequestErrorMessage(IDS_PRO_NOTONLINE_TITLE, IDS_PRO_XBOXLIVE_NOTIFICATION, uiIDA, 1, iPad );
|
||||
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -1701,12 +1703,16 @@ int UIScene_SkinSelectMenu::MustSignInReturned(void *pParam,int iPad,C4JStorage:
|
||||
{
|
||||
if(result==C4JStorage::EMessage_ResultAccept)
|
||||
{
|
||||
#ifdef DISABLE_PSN
|
||||
UIScene_SkinSelectMenu::PSNSignInReturned(pParam, true, iPad);
|
||||
#else
|
||||
#ifdef __PS3__
|
||||
SQRNetworkManager_PS3::AttemptPSNSignIn(&UIScene_SkinSelectMenu::PSNSignInReturned, pParam,true);
|
||||
#elif defined __PSVITA__
|
||||
SQRNetworkManager_Vita::AttemptPSNSignIn(&UIScene_SkinSelectMenu::PSNSignInReturned, pParam,true);
|
||||
#elif defined __ORBIS__
|
||||
SQRNetworkManager_Orbis::AttemptPSNSignIn(&UIScene_SkinSelectMenu::PSNSignInReturned, pParam,true);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
return 0;
|
||||
|
||||
@@ -1105,6 +1105,7 @@ void CScene_Leaderboards::CopyLeaderboardEntry(PXUSER_STATS_ROW statsRow, Leader
|
||||
}
|
||||
|
||||
//Is the player
|
||||
#ifndef _DISABLE_XBLIVE
|
||||
if( statsRow->xuid == ((XboxLeaderboardManager*)LeaderboardManager::Instance())->GetMyXUID() )
|
||||
{
|
||||
leaderboardEntry->m_bPlayer = true;
|
||||
@@ -1143,6 +1144,7 @@ void CScene_Leaderboards::CopyLeaderboardEntry(PXUSER_STATS_ROW statsRow, Leader
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void CScene_Leaderboards::SetLeaderboardHeader()
|
||||
|
||||
@@ -76,7 +76,19 @@ HRESULT CScene_LoadGameSettings::OnInit( XUIMessageInit* pInitData, BOOL& bHandl
|
||||
XuiControlSetText(m_ButtonLoad,app.GetString(IDS_LOAD));
|
||||
XuiControlSetText(m_pTexturePacksList->m_hObj,app.GetString(IDS_DLC_MENU_TEXTUREPACKS));
|
||||
|
||||
#ifndef _DISABLE_XBLIVE
|
||||
#ifndef _DISABLE_XBLIVE
|
||||
#ifndef _DISABLE_XBLIVE
|
||||
m_bMultiplayerAllowed = ProfileManager.IsSignedInLive( m_iPad ) && ProfileManager.AllowedToPlayMultiplayer(m_iPad);
|
||||
#else
|
||||
m_bMultiplayerAllowed = true;
|
||||
#endif
|
||||
#else
|
||||
m_bMultiplayerAllowed = true;
|
||||
#endif
|
||||
#else
|
||||
m_bMultiplayerAllowed = true;
|
||||
#endif
|
||||
// 4J-PB - read the settings for the online flag. We'll only save this setting if the user changed it.
|
||||
bool bGameSetting_Online=(app.GetGameSettings(m_iPad,eGameSetting_Online)!=0);
|
||||
m_MoreOptionsParams.bOnlineSettingChangedBySystem=false;
|
||||
@@ -741,7 +753,10 @@ HRESULT CScene_LoadGameSettings::OnTimer( XUIMessageTimer *pTimer, BOOL& bHandle
|
||||
{
|
||||
case GAME_CREATE_ONLINE_TIMER_ID:
|
||||
{
|
||||
bool bMultiplayerAllowed = ProfileManager.IsSignedInLive( m_iPad ) && ProfileManager.AllowedToPlayMultiplayer(m_iPad);
|
||||
bool bMultiplayerAllowed = true;
|
||||
#ifndef _DISABLE_XBLIVE
|
||||
bMultiplayerAllowed = ProfileManager.IsSignedInLive( m_iPad ) && ProfileManager.AllowedToPlayMultiplayer(m_iPad);
|
||||
#endif
|
||||
|
||||
if(bMultiplayerAllowed != m_bMultiplayerAllowed)
|
||||
{
|
||||
@@ -1015,7 +1030,9 @@ int CScene_LoadGameSettings::StartGame_SignInReturned(void *pParam,bool bContinu
|
||||
{
|
||||
if(ProfileManager.IsSignedIn(index) )
|
||||
{
|
||||
#ifndef _DISABLE_XBLIVE
|
||||
if( !ProfileManager.AllowedToPlayMultiplayer(index) ) noPrivileges = true;
|
||||
#endif
|
||||
dwLocalUsersMask |= CGameNetworkManager::GetLocalPlayerMask(index);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,7 +67,19 @@ HRESULT CScene_MultiGameCreate::OnInit( XUIMessageInit* pInitData, BOOL& bHandle
|
||||
m_iPad=params->iPad;
|
||||
delete params;
|
||||
|
||||
#ifndef _DISABLE_XBLIVE
|
||||
#ifndef _DISABLE_XBLIVE
|
||||
#ifndef _DISABLE_XBLIVE
|
||||
m_bMultiplayerAllowed = ProfileManager.IsSignedInLive( m_iPad ) && ProfileManager.AllowedToPlayMultiplayer(m_iPad);
|
||||
#else
|
||||
m_bMultiplayerAllowed = true;
|
||||
#endif
|
||||
#else
|
||||
m_bMultiplayerAllowed = true;
|
||||
#endif
|
||||
#else
|
||||
m_bMultiplayerAllowed = true;
|
||||
#endif
|
||||
// 4J-PB - read the settings for the online flag. We'll only save this setting if the user changed it.
|
||||
bool bGameSetting_Online=(app.GetGameSettings(m_iPad,eGameSetting_Online)!=0);
|
||||
m_MoreOptionsParams.bOnlineSettingChangedBySystem=false;
|
||||
@@ -663,7 +675,10 @@ HRESULT CScene_MultiGameCreate::OnTimer( XUIMessageTimer *pTimer, BOOL& bHandled
|
||||
|
||||
case GAME_CREATE_ONLINE_TIMER_ID:
|
||||
{
|
||||
bool bMultiplayerAllowed = ProfileManager.IsSignedInLive( m_iPad ) && ProfileManager.AllowedToPlayMultiplayer(m_iPad);
|
||||
bool bMultiplayerAllowed = true;
|
||||
#ifndef _DISABLE_XBLIVE
|
||||
bMultiplayerAllowed = ProfileManager.IsSignedInLive( m_iPad ) && ProfileManager.AllowedToPlayMultiplayer(m_iPad);
|
||||
#endif
|
||||
|
||||
if(bMultiplayerAllowed != m_bMultiplayerAllowed)
|
||||
{
|
||||
@@ -824,7 +839,9 @@ int CScene_MultiGameCreate::StartGame_SignInReturned(void *pParam,bool bContinue
|
||||
{
|
||||
if(ProfileManager.IsSignedIn(index) )
|
||||
{
|
||||
#ifndef _DISABLE_XBLIVE
|
||||
if( !ProfileManager.AllowedToPlayMultiplayer(index) ) noPrivileges = true;
|
||||
#endif
|
||||
dwLocalUsersMask |= CGameNetworkManager::GetLocalPlayerMask(index);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,6 +37,7 @@ HRESULT CScene_MultiGameInfo::OnInit( XUIMessageInit* pInitData, BOOL& bHandled
|
||||
// 4J-PB - don't delete this - it's part of the joinload structure
|
||||
//delete initData;
|
||||
|
||||
#ifndef _DISABLE_XBLIVE
|
||||
for(unsigned int i = 0; i < MINECRAFT_NET_MAX_PLAYERS; ++i)
|
||||
{
|
||||
if( m_selectedSession->data.players[i] != NULL )
|
||||
@@ -59,6 +60,7 @@ HRESULT CScene_MultiGameInfo::OnInit( XUIMessageInit* pInitData, BOOL& bHandled
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
unsigned int uiGameHostSettings = m_selectedSession->data.m_uiGameHostSettings;
|
||||
switch(app.GetGameHostOption(uiGameHostSettings,eGameHostOption_Difficulty))
|
||||
@@ -185,12 +187,14 @@ HRESULT CScene_MultiGameInfo::OnKeyDown(XUIMessageInput* pInputData, BOOL& rfHan
|
||||
rfHandled = TRUE;
|
||||
break;
|
||||
case VK_PAD_Y:
|
||||
#ifndef _DISABLE_XBLIVE
|
||||
if(m_selectedSession != NULL && playersList.TreeHasFocus() && playersList.GetItemCount() > 0)
|
||||
{
|
||||
PlayerUID xuid = m_selectedSession->data.players[playersList.GetCurSel()];
|
||||
if( xuid != INVALID_XUID )
|
||||
hr = XShowGamerCardUI(ProfileManager.GetLockedProfile(), xuid);
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -270,7 +274,9 @@ void CScene_MultiGameInfo::JoinGame(CScene_MultiGameInfo* pClass)
|
||||
if(ProfileManager.IsSignedIn(index) )
|
||||
{
|
||||
++dwSignedInUsers;
|
||||
#ifndef _DISABLE_XBLIVE
|
||||
if( !ProfileManager.AllowedToPlayMultiplayer(index) ) noPrivileges = true;
|
||||
#endif
|
||||
dwLocalUsersMask |= CGameNetworkManager::GetLocalPlayerMask(index);
|
||||
}
|
||||
}
|
||||
@@ -280,7 +286,9 @@ void CScene_MultiGameInfo::JoinGame(CScene_MultiGameInfo* pClass)
|
||||
if(ProfileManager.IsSignedIn(ProfileManager.GetPrimaryPad()) )
|
||||
{
|
||||
++dwSignedInUsers;
|
||||
#ifndef _DISABLE_XBLIVE
|
||||
if( !ProfileManager.AllowedToPlayMultiplayer(ProfileManager.GetPrimaryPad()) ) noPrivileges = true;
|
||||
#endif
|
||||
dwLocalUsersMask |= CGameNetworkManager::GetLocalPlayerMask(ProfileManager.GetPrimaryPad());
|
||||
}
|
||||
}
|
||||
@@ -344,6 +352,21 @@ void CScene_MultiGameInfo::JoinGame(CScene_MultiGameInfo* pClass)
|
||||
app.NavigateToHomeMenu();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LoadingInputParams *loadingParams = new LoadingInputParams();
|
||||
loadingParams->func = &CGameNetworkManager::RunNetworkGameThreadProc;
|
||||
loadingParams->lpParam = NULL;
|
||||
|
||||
UIFullscreenProgressCompletionData *completionData = new UIFullscreenProgressCompletionData();
|
||||
completionData->bShowBackground = TRUE;
|
||||
completionData->bShowLogo = TRUE;
|
||||
completionData->type = e_ProgressCompletion_CloseAllPlayersUIScenes;
|
||||
completionData->iPad = DEFAULT_XUI_MENU_USER;
|
||||
loadingParams->completionData = completionData;
|
||||
|
||||
app.NavigateToScene(ProfileManager.GetPrimaryPad(), eUIScene_FullscreenProgress, loadingParams);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -351,6 +374,7 @@ HRESULT CScene_MultiGameInfo::OnTimer( XUIMessageTimer *pTimer, BOOL& bHandled )
|
||||
{
|
||||
if ( pTimer->nId == UPDATE_PLAYERS_TIMER_ID)
|
||||
{
|
||||
#ifndef _DISABLE_XBLIVE
|
||||
PlayerUID selectedPlayerXUID = m_selectedSession->data.players[playersList.GetCurSel()];
|
||||
|
||||
bool success = g_NetworkManager.GetGameSessionInfo(m_iPad, m_selectedSession->sessionId,m_selectedSession);
|
||||
@@ -384,6 +408,7 @@ HRESULT CScene_MultiGameInfo::OnTimer( XUIMessageTimer *pTimer, BOOL& bHandled )
|
||||
}
|
||||
playersList.SetCurSel(selectedIndex);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
using namespace std;
|
||||
#include <vector>
|
||||
#ifndef _DISABLE_XBLIVE
|
||||
#include <qnet.h>
|
||||
#include "../Media/XUI/xuiscene_multi_gameinfo.h"
|
||||
|
||||
|
||||
@@ -73,7 +73,11 @@ HRESULT CScene_MultiGameJoinLoad::OnInit( XUIMessageInit* pInitData, BOOL& bHand
|
||||
// }
|
||||
|
||||
m_initData= new JoinMenuInitData();
|
||||
#ifndef _DISABLE_XBLIVE
|
||||
m_bMultiplayerAllowed = ProfileManager.IsSignedInLive( m_iPad ) && ProfileManager.AllowedToPlayMultiplayer(m_iPad);
|
||||
#else
|
||||
m_bMultiplayerAllowed = true;
|
||||
#endif
|
||||
|
||||
XPARTY_USER_LIST partyList;
|
||||
|
||||
@@ -648,9 +652,11 @@ HRESULT CScene_MultiGameJoinLoad::OnKeyDown(XUIMessageInput* pInputData, BOOL& r
|
||||
DWORD nIndex = m_pGamesList->GetCurSel();
|
||||
FriendSessionInfo *pSelectedSession = currentSessions.at( nIndex );
|
||||
|
||||
#ifndef _DISABLE_XBLIVE
|
||||
PlayerUID xuid = pSelectedSession->data.hostPlayerUID;
|
||||
if( xuid != INVALID_XUID )
|
||||
hr = XShowGamerCardUI(ProfileManager.GetLockedProfile(), xuid);
|
||||
#endif
|
||||
CXuiSceneBase::PlayUISFX(eSFX_Press);
|
||||
}
|
||||
else if(DoesSavesListHaveFocus())
|
||||
@@ -766,7 +772,11 @@ HRESULT CScene_MultiGameJoinLoad::OnNavReturn(HXUIOBJ hSceneFrom,BOOL& rfHandled
|
||||
// start the texture pack timer again
|
||||
XuiSetTimer(m_hObj,CHECKFORAVAILABLETEXTUREPACKS_TIMER_ID,CHECKFORAVAILABLETEXTUREPACKS_TIMER_TIME);
|
||||
|
||||
m_bMultiplayerAllowed = ProfileManager.IsSignedInLive( m_iPad ) && ProfileManager.AllowedToPlayMultiplayer(m_iPad);
|
||||
#ifndef _DISABLE_XBLIVE
|
||||
m_bMultiplayerAllowed = ProfileManager.IsSignedInLive( m_iPad ) && ProfileManager.AllowedToPlayMultiplayer(m_iPad);
|
||||
#else
|
||||
m_bMultiplayerAllowed = true;
|
||||
#endif
|
||||
|
||||
// re-enable button presses
|
||||
m_bIgnoreInput=false;
|
||||
@@ -1641,7 +1651,10 @@ HRESULT CScene_MultiGameJoinLoad::OnTimer( XUIMessageTimer *pTimer, BOOL& bHandl
|
||||
m_bInParty=false;
|
||||
}
|
||||
|
||||
bool bMultiplayerAllowed = ProfileManager.IsSignedInLive( m_iPad ) && ProfileManager.AllowedToPlayMultiplayer(m_iPad);
|
||||
bool bMultiplayerAllowed = true;
|
||||
#ifndef _DISABLE_XBLIVE
|
||||
bMultiplayerAllowed = ProfileManager.IsSignedInLive( m_iPad ) && ProfileManager.AllowedToPlayMultiplayer(m_iPad);
|
||||
#endif
|
||||
if(bMultiplayerAllowed != m_bMultiplayerAllowed)
|
||||
{
|
||||
if( bMultiplayerAllowed )
|
||||
|
||||
@@ -145,10 +145,11 @@ void EnderDragonRenderer::render(shared_ptr<Entity> _mob, double x, double y, do
|
||||
int steps = 8;
|
||||
for (int i = 0; i <= steps; i++)
|
||||
{
|
||||
double d=i % steps * PI * 2 / steps;
|
||||
float s = sin(i % steps * PI * 2 / steps) * 0.75f;
|
||||
float c = cos(i % steps * PI * 2 / steps) * 0.75f;
|
||||
float u = i % steps * 1.0f / steps;
|
||||
int idx = i % steps;
|
||||
double d = idx * PI * 2 / steps;
|
||||
float s = sin(d) * 0.75f;
|
||||
float c = cos(d) * 0.75f;
|
||||
float u = idx * 1.0f / steps;
|
||||
//t->color(0x000000);
|
||||
t->vertexUV(s * 0.2f, c * 0.2f, 0, u, v1);
|
||||
//t->color(0xffffff);
|
||||
|
||||
@@ -94,6 +94,17 @@ void EntityRenderDispatcher::staticCtor()
|
||||
instance = new EntityRenderDispatcher();
|
||||
}
|
||||
|
||||
EntityRenderDispatcher::~EntityRenderDispatcher()
|
||||
{
|
||||
AUTO_VAR(itEnd, renderers.end());
|
||||
for( classToRendererMap::iterator it = renderers.begin(); it != itEnd; it++ )
|
||||
{
|
||||
delete it->second;
|
||||
it->second = NULL;
|
||||
}
|
||||
renderers.clear();
|
||||
}
|
||||
|
||||
EntityRenderDispatcher::EntityRenderDispatcher()
|
||||
{
|
||||
glEnable(GL_LIGHTING);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
#include "EntityRenderer.h"
|
||||
#include "..\Minecraft.World\Entity.h"
|
||||
#include "..\Minecraft.World\JavaIntHash.h"
|
||||
class Entity;
|
||||
class font;
|
||||
using namespace std;
|
||||
|
||||
@@ -37,6 +37,7 @@ public:
|
||||
|
||||
private:
|
||||
EntityRenderDispatcher();
|
||||
~EntityRenderDispatcher();
|
||||
|
||||
public:
|
||||
EntityRenderer *getRenderer(eINSTANCEOF e);
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
|
||||
#ifdef __PS3__
|
||||
#include "PS3\Sentient\SentientManager.h"
|
||||
#include "Common\Network\NetworkSocketLayer.h"
|
||||
#include "StatsCounter.h"
|
||||
#include "PS3\Social\SocialManager.h"
|
||||
#include <libsn.h>
|
||||
@@ -17,6 +18,7 @@
|
||||
#include "Durango\DurangoExtras\xcompress.h"
|
||||
#elif defined _WINDOWS64
|
||||
#include "Windows64\Sentient\SentientManager.h"
|
||||
#include "Common\Network\NetworkSocketLayer.h"
|
||||
#include "StatsCounter.h"
|
||||
#include "Windows64\Social\SocialManager.h"
|
||||
#include "Windows64\Sentient\DynamicConfigurations.h"
|
||||
@@ -26,6 +28,12 @@
|
||||
#include "PSVita\Social\SocialManager.h"
|
||||
#include "PSVita\Sentient\DynamicConfigurations.h"
|
||||
#include <libperf.h>
|
||||
#elif defined _XBOX
|
||||
#include "Xbox\Sentient\SentientManager.h"
|
||||
#include "StatsCounter.h"
|
||||
#include "Xbox\Social\SocialManager.h"
|
||||
#include "Xbox\Sentient\DynamicConfigurations.h"
|
||||
#include "Common\Network\IQNet.h"
|
||||
#else
|
||||
#include "Orbis\Sentient\SentientManager.h"
|
||||
#include "StatsCounter.h"
|
||||
@@ -34,6 +42,11 @@
|
||||
#include <perf.h>
|
||||
#endif
|
||||
|
||||
#if defined(DISABLE_PSN) || defined(_DISABLE_XBLIVE)
|
||||
#include "Common\Network\NetworkSocketLayer.h"
|
||||
#endif
|
||||
|
||||
#ifndef _DISABLE_XBLIVE
|
||||
#ifdef _WINDOWS64
|
||||
wchar_t fakeGamerTagW[32] = L"PlayerName";
|
||||
#endif
|
||||
@@ -63,6 +76,7 @@ HRESULT XPartyGetUserList(XPARTY_USER_LIST *pUserList) { return S_OK; }
|
||||
DWORD XContentGetThumbnail(DWORD dwUserIndex, const XCONTENT_DATA *pContentData, PBYTE pbThumbnail, PDWORD pcbThumbnail, PXOVERLAPPED *pOverlapped) { return 0; }
|
||||
void XShowAchievementsUI(int i) {}
|
||||
DWORD XBackgroundDownloadSetMode(XBACKGROUND_DOWNLOAD_MODE Mode) { return 0; }
|
||||
DWORD XamBackgroundDownloadSetMode(XBACKGROUND_DOWNLOAD_MODE Mode) { return 0; }
|
||||
|
||||
#ifndef _DURANGO
|
||||
void PIXAddNamedCounter(int a, char *b, ...) {}
|
||||
@@ -166,8 +180,10 @@ void PIXSetMarkerDeprecated(int a, char *b, ...) {}
|
||||
|
||||
bool IsEqualXUID(PlayerUID a, PlayerUID b)
|
||||
{
|
||||
#if defined(__PS3__) || defined(__ORBIS__) || defined (__PSVITA__) || defined(_DURANGO)
|
||||
#if !defined(DISABLE_PSN) && (defined(__PS3__) || defined(__ORBIS__) || defined (__PSVITA__) || defined(_DURANGO) || defined(_WINDOWS64) || defined(_XBOX))
|
||||
return (a == b);
|
||||
#elif defined(DISABLE_PSN)
|
||||
return (a.XUID == b.XUID);
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
@@ -183,53 +199,6 @@ D3DXVECTOR3::D3DXVECTOR3() {}
|
||||
D3DXVECTOR3::D3DXVECTOR3(float x,float y,float z) : x(x), y(y), z(z) {}
|
||||
D3DXVECTOR3& D3DXVECTOR3::operator += ( CONST D3DXVECTOR3& add ) { x += add.x; y += add.y; z += add.z; return *this; }
|
||||
|
||||
BYTE IQNetPlayer::GetSmallId() { return 0; }
|
||||
void IQNetPlayer::SendData(IQNetPlayer *player, const void *pvData, DWORD dwDataSize, DWORD dwFlags)
|
||||
{
|
||||
app.DebugPrintf("Sending from 0x%x to 0x%x %d bytes\n",this,player,dwDataSize);
|
||||
}
|
||||
bool IQNetPlayer::IsSameSystem(IQNetPlayer *player) { return true; }
|
||||
DWORD IQNetPlayer::GetSendQueueSize( IQNetPlayer *player, DWORD dwFlags ) { return 0; }
|
||||
DWORD IQNetPlayer::GetCurrentRtt() { return 0; }
|
||||
bool IQNetPlayer::IsHost() { return this == &IQNet::m_player[0]; }
|
||||
bool IQNetPlayer::IsGuest() { return false; }
|
||||
bool IQNetPlayer::IsLocal() { return true; }
|
||||
PlayerUID IQNetPlayer::GetXuid() { return INVALID_XUID; }
|
||||
#ifdef _WINDOWS64
|
||||
LPCWSTR IQNetPlayer::GetGamertag() { return fakeGamerTagW; }
|
||||
#else
|
||||
LPCWSTR IQNetPlayer::GetGamertag() { return L"stub"; }
|
||||
#endif
|
||||
int IQNetPlayer::GetSessionIndex() { return 0; }
|
||||
bool IQNetPlayer::IsTalking() { return false; }
|
||||
bool IQNetPlayer::IsMutedByLocalUser(DWORD dwUserIndex) { return false; }
|
||||
bool IQNetPlayer::HasVoice() { return false; }
|
||||
bool IQNetPlayer::HasCamera() { return false; }
|
||||
int IQNetPlayer::GetUserIndex() { return this - &IQNet::m_player[0]; }
|
||||
void IQNetPlayer::SetCustomDataValue(ULONG_PTR ulpCustomDataValue) {
|
||||
m_customData = ulpCustomDataValue;
|
||||
}
|
||||
ULONG_PTR IQNetPlayer::GetCustomDataValue() {
|
||||
return m_customData;
|
||||
}
|
||||
|
||||
IQNetPlayer IQNet::m_player[4];
|
||||
|
||||
bool _bQNetStubGameRunning = false;
|
||||
|
||||
HRESULT IQNet::AddLocalPlayerByUserIndex(DWORD dwUserIndex){ return S_OK; }
|
||||
IQNetPlayer *IQNet::GetHostPlayer() { return &m_player[0]; }
|
||||
IQNetPlayer *IQNet::GetLocalPlayerByUserIndex(DWORD dwUserIndex) { return &m_player[dwUserIndex]; }
|
||||
IQNetPlayer *IQNet::GetPlayerByIndex(DWORD dwPlayerIndex) { return &m_player[0]; }
|
||||
IQNetPlayer *IQNet::GetPlayerBySmallId(BYTE SmallId){ return &m_player[0]; }
|
||||
IQNetPlayer *IQNet::GetPlayerByXuid(PlayerUID xuid){ return &m_player[0]; }
|
||||
DWORD IQNet::GetPlayerCount() { return 1; }
|
||||
QNET_STATE IQNet::GetState() { return _bQNetStubGameRunning ? QNET_STATE_GAME_PLAY : QNET_STATE_IDLE; }
|
||||
bool IQNet::IsHost() { return true; }
|
||||
HRESULT IQNet::JoinGameFromInviteInfo(DWORD dwUserIndex, DWORD dwUserMask, const INVITE_INFO *pInviteInfo) { return S_OK; }
|
||||
void IQNet::HostGame() { _bQNetStubGameRunning = true; }
|
||||
void IQNet::EndGame() { _bQNetStubGameRunning = false; }
|
||||
|
||||
DWORD MinecraftDynamicConfigurations::GetTrialTime() { return DYNAMIC_CONFIG_DEFAULT_TRIAL_TIME; }
|
||||
|
||||
void XSetThreadProcessor(HANDLE a, int b) {}
|
||||
@@ -384,7 +353,7 @@ DWORD XEnableGuestSignin(BOOL fEnable) { return 0; }
|
||||
/////////////////////////////////////////////// Profile library
|
||||
#ifdef _WINDOWS64
|
||||
static void *profileData[4];
|
||||
static bool s_bProfileIsFullVersion;
|
||||
static bool s_bProfileIsFullVersion = true;
|
||||
void C_4JProfile::Initialise( DWORD dwTitleID,
|
||||
DWORD dwOfferID,
|
||||
unsigned short usProfileVersion,
|
||||
@@ -403,6 +372,7 @@ void C_4JProfile::Initialise( DWORD dwTitleID,
|
||||
GAME_SETTINGS *pGameSettings = (GAME_SETTINGS *)profileData[i];
|
||||
pGameSettings->ucMenuSensitivity=100; //eGameSetting_Sensitivity_InMenu
|
||||
pGameSettings->ucInterfaceOpacity=80; //eGameSetting_Sensitivity_InMenu
|
||||
pGameSettings->ucGamma=100; //eGameSetting_Gamma
|
||||
pGameSettings->usBitmaskValues|=0x0200; //eGameSetting_DisplaySplitscreenGamertags - on
|
||||
pGameSettings->usBitmaskValues|=0x0400; //eGameSetting_Hints - on
|
||||
pGameSettings->usBitmaskValues|=0x1000; //eGameSetting_Autosave - 2
|
||||
@@ -450,11 +420,265 @@ void C_4JProfile::Initialise( DWORD dwTitleID,
|
||||
pGameSettings->ucTutorialCompletion[28] |= 1<<0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif // DISABLE_XBLIVE
|
||||
BYTE IQNetPlayer::GetSmallId() { return m_smallId; }
|
||||
void IQNetPlayer::SendData(IQNetPlayer *player, const void *pvData, DWORD dwDataSize, DWORD dwFlags)
|
||||
{
|
||||
if (NetworkSocketLayer::IsActive())
|
||||
{
|
||||
NetworkSocketLayer::SendToSmallId(player->m_smallId, pvData, dwDataSize);
|
||||
}
|
||||
}
|
||||
bool IQNetPlayer::IsSameSystem(IQNetPlayer *player) { return (this == player) || (!m_isRemote && !player->m_isRemote); }
|
||||
DWORD IQNetPlayer::GetSendQueueSize( IQNetPlayer *player, DWORD dwFlags ) { return 0; }
|
||||
DWORD IQNetPlayer::GetCurrentRtt() { return 0; }
|
||||
bool IQNetPlayer::IsHost() { return m_isHostPlayer; }
|
||||
bool IQNetPlayer::IsGuest() { return false; }
|
||||
bool IQNetPlayer::IsLocal() { return !m_isRemote; }
|
||||
static void Win64_BuildSplitName(int iPad, char *outName, int outSize);
|
||||
|
||||
PlayerUID IQNetPlayer::GetXuid()
|
||||
{
|
||||
#if defined(_WINDOWS64) || defined(DISABLE_PSN) || defined(_DISABLE_XBLIVE)
|
||||
if (!m_isRemote)
|
||||
{
|
||||
int idx = (int)(this - &IQNet::m_player[0]);
|
||||
if (idx == 0)
|
||||
{
|
||||
extern char g_Win64Username[17];
|
||||
return Win64_UsernameToXuid(g_Win64Username);
|
||||
}
|
||||
if (idx > 0 && idx < XUSER_MAX_COUNT)
|
||||
{
|
||||
char splitName[32];
|
||||
Win64_BuildSplitName(idx, splitName, sizeof(splitName));
|
||||
return Win64_UsernameToXuid(splitName);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return (PlayerUID)(0xe000d45248242f2e + m_smallId);
|
||||
}
|
||||
|
||||
PlayerUID Win64_UsernameToXuid(const char* username)
|
||||
{
|
||||
uint64_t hash = 14695981039346656037ULL;
|
||||
for (const char* p = username; *p; ++p)
|
||||
{
|
||||
hash ^= (uint64_t)(unsigned char)(*p);
|
||||
hash *= 1099511628211ULL;
|
||||
}
|
||||
|
||||
const uint64_t WIN64_XUID_BASE = 0xe000d45248242f2e;
|
||||
if (hash >= WIN64_XUID_BASE && hash <= WIN64_XUID_BASE + MINECRAFT_NET_MAX_PLAYERS)
|
||||
hash = WIN64_XUID_BASE + MINECRAFT_NET_MAX_PLAYERS + 1;
|
||||
if (hash == 0)
|
||||
hash = 1;
|
||||
return (PlayerUID)hash;
|
||||
}
|
||||
|
||||
PlayerUID Win64_UsernameToXuid(const wchar_t* username)
|
||||
{
|
||||
char narrow[64];
|
||||
int i = 0;
|
||||
for (; username[i] && i < 63; ++i)
|
||||
narrow[i] = (char)(unsigned char)(username[i] & 0xFF);
|
||||
narrow[i] = 0;
|
||||
return Win64_UsernameToXuid(narrow);
|
||||
}
|
||||
|
||||
static void Win64_BuildSplitName(int iPad, char *outName, int outSize)
|
||||
{
|
||||
extern char g_Win64Username[17];
|
||||
char candidate[32];
|
||||
sprintf(candidate, "%s_%d", g_Win64Username, iPad);
|
||||
for (DWORD i = 0; i < MINECRAFT_NET_MAX_PLAYERS; i++)
|
||||
{
|
||||
if (!IQNet::m_player[i].m_isRemote) continue;
|
||||
if (IQNet::m_player[i].m_gamertag[0] == 0) continue;
|
||||
char remoteName[64];
|
||||
int j = 0;
|
||||
for (; IQNet::m_player[i].m_gamertag[j] && j < 63; ++j)
|
||||
remoteName[j] = (char)(unsigned char)(IQNet::m_player[i].m_gamertag[j] & 0xFF);
|
||||
remoteName[j] = 0;
|
||||
#if defined(_MSC_VER)
|
||||
if (_stricmp(candidate, remoteName) == 0)
|
||||
#else
|
||||
if (strcasecmp(candidate, remoteName) == 0)
|
||||
#endif
|
||||
{
|
||||
sprintf(candidate, "%s_%d_L", g_Win64Username, iPad);
|
||||
break;
|
||||
}
|
||||
}
|
||||
strncpy(outName, candidate, outSize - 1);
|
||||
outName[outSize - 1] = 0;
|
||||
}
|
||||
|
||||
static void Win64_BuildSplitNameW(int iPad, wchar_t *outName, int outSize)
|
||||
{
|
||||
char narrow[32];
|
||||
Win64_BuildSplitName(iPad, narrow, sizeof(narrow));
|
||||
for (int i = 0; i < outSize - 1 && narrow[i]; ++i)
|
||||
{
|
||||
outName[i] = (wchar_t)(unsigned char)narrow[i];
|
||||
outName[i + 1] = 0;
|
||||
}
|
||||
}
|
||||
LPCWSTR IQNetPlayer::GetGamertag() { return m_gamertag; }
|
||||
int IQNetPlayer::GetSessionIndex() { return m_smallId; }
|
||||
bool IQNetPlayer::IsTalking() { return false; }
|
||||
bool IQNetPlayer::IsMutedByLocalUser(DWORD dwUserIndex) { return false; }
|
||||
bool IQNetPlayer::HasVoice() { return false; }
|
||||
bool IQNetPlayer::HasCamera() { return false; }
|
||||
int IQNetPlayer::GetUserIndex() { return this - &IQNet::m_player[0]; }
|
||||
void IQNetPlayer::SetCustomDataValue(ULONG_PTR ulpCustomDataValue) {
|
||||
m_customData = ulpCustomDataValue;
|
||||
}
|
||||
ULONG_PTR IQNetPlayer::GetCustomDataValue() {
|
||||
return m_customData;
|
||||
}
|
||||
|
||||
IQNetPlayer IQNet::m_player[MINECRAFT_NET_MAX_PLAYERS];
|
||||
DWORD IQNet::s_playerCount = 1;
|
||||
bool IQNet::s_isHosting = true;
|
||||
|
||||
QNET_STATE _iQNetStubState = QNET_STATE_IDLE;
|
||||
|
||||
void Win64_SetupRemoteQNetPlayer(IQNetPlayer *player, BYTE smallId, bool isHost, bool isLocal)
|
||||
{
|
||||
player->m_smallId = smallId;
|
||||
player->m_isRemote = !isLocal;
|
||||
player->m_isHostPlayer = isHost;
|
||||
swprintf(player->m_gamertag, 32, L"Player%d", smallId);
|
||||
if (smallId >= IQNet::s_playerCount)
|
||||
IQNet::s_playerCount = smallId + 1;
|
||||
}
|
||||
|
||||
static bool Win64_IsActivePlayer(IQNetPlayer *p, DWORD index);
|
||||
|
||||
HRESULT IQNet::AddLocalPlayerByUserIndex(DWORD dwUserIndex)
|
||||
{
|
||||
// no E_FAIL on PS3.
|
||||
if (dwUserIndex >= MINECRAFT_NET_MAX_PLAYERS) return (HRESULT)0x80004005L;
|
||||
m_player[dwUserIndex].m_isRemote = false;
|
||||
m_player[dwUserIndex].m_smallId = (BYTE)dwUserIndex;
|
||||
if (dwUserIndex > 0)
|
||||
{
|
||||
wchar_t splitNameW[32];
|
||||
Win64_BuildSplitNameW((int)dwUserIndex, splitNameW, 32);
|
||||
wcsncpy(m_player[dwUserIndex].m_gamertag, splitNameW, 32 - 1);
|
||||
m_player[dwUserIndex].m_gamertag[32 - 1] = 0;
|
||||
}
|
||||
if (dwUserIndex >= (DWORD)s_playerCount)
|
||||
s_playerCount = dwUserIndex + 1;
|
||||
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)
|
||||
return &m_player[dwUserIndex];
|
||||
return NULL;
|
||||
}
|
||||
if (dwUserIndex != 0)
|
||||
return NULL;
|
||||
for (DWORD i = 0; i < s_playerCount; i++)
|
||||
{
|
||||
if (!m_player[i].m_isRemote && Win64_IsActivePlayer(&m_player[i], i))
|
||||
return &m_player[i];
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
static bool Win64_IsActivePlayer(IQNetPlayer *p, DWORD index)
|
||||
{
|
||||
if (index == 0) return true;
|
||||
if (p->GetCustomDataValue() != 0) return true;
|
||||
return (p->m_isRemote && p->m_gamertag[0] != 0);
|
||||
}
|
||||
|
||||
IQNetPlayer *IQNet::GetPlayerByIndex(DWORD dwPlayerIndex)
|
||||
{
|
||||
DWORD found = 0;
|
||||
for (DWORD i = 0; i < s_playerCount; i++)
|
||||
{
|
||||
if (Win64_IsActivePlayer(&m_player[i], i))
|
||||
{
|
||||
if (found == dwPlayerIndex) return &m_player[i];
|
||||
found++;
|
||||
}
|
||||
}
|
||||
return &m_player[0];
|
||||
}
|
||||
IQNetPlayer *IQNet::GetPlayerBySmallId(BYTE SmallId)
|
||||
{
|
||||
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 < MINECRAFT_NET_MAX_PLAYERS; i++)
|
||||
{
|
||||
if (Win64_IsActivePlayer(&m_player[i], i) && m_player[i].GetXuid() == xuid) return &m_player[i];
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
DWORD IQNet::GetPlayerCount()
|
||||
{
|
||||
DWORD count = 0;
|
||||
for (DWORD i = 0; i < s_playerCount; i++)
|
||||
{
|
||||
if (Win64_IsActivePlayer(&m_player[i], i)) count++;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
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;
|
||||
|
||||
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 = 0; i < MINECRAFT_NET_MAX_PLAYERS; i++)
|
||||
{
|
||||
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;
|
||||
m_player[i].SetCustomDataValue(0);
|
||||
}
|
||||
}
|
||||
#ifndef _DISABLE_XBLIVE
|
||||
#if defined _WINDOWS64 || (defined(__PS3__) && defined(DISABLE_PSN))
|
||||
void C_4JProfile::SetTrialTextStringTable(CXuiStringTable *pStringTable,int iAccept,int iReject) {}
|
||||
void C_4JProfile::SetTrialAwardText(eAwardType AwardType,int iTitle,int iText) {}
|
||||
int C_4JProfile::GetLockedProfile() { return 0; }
|
||||
void C_4JProfile::SetLockedProfile(int iProf) {}
|
||||
bool C_4JProfile::IsSignedIn(int iQuadrant) { return ( iQuadrant == 0); }
|
||||
bool C_4JProfile::IsSignedIn(int iQuadrant) { return (iQuadrant >= 0 && iQuadrant < XUSER_MAX_COUNT); }
|
||||
bool C_4JProfile::IsSignedInLive(int iProf) { return true; }
|
||||
bool C_4JProfile::IsGuest(int iQuadrant) { return false; }
|
||||
UINT C_4JProfile::RequestSignInUI(bool bFromInvite,bool bLocalGame,bool bNoGuestsAllowed,bool bMultiplayerSignIn,bool bAddUser, int( *Func)(LPVOID,const bool, const int iPad),LPVOID lpParam,int iQuadrant) { return 0; }
|
||||
@@ -462,11 +686,29 @@ UINT C_4JProfile::DisplayOfflineProfile(int( *Func)(LPVOID,const bool, const
|
||||
UINT C_4JProfile::RequestConvertOfflineToGuestUI(int( *Func)(LPVOID,const bool, const int iPad),LPVOID lpParam,int iQuadrant) { return 0; }
|
||||
void C_4JProfile::SetPrimaryPlayerChanged(bool bVal) {}
|
||||
bool C_4JProfile::QuerySigninStatus(void) { return true; }
|
||||
void C_4JProfile::GetXUID(int iPad, PlayerUID *pXuid,bool bOnlineXuid) {*pXuid = 0xe000d45248242f2e; }
|
||||
BOOL C_4JProfile::AreXUIDSEqual(PlayerUID xuid1,PlayerUID xuid2) { return false; }
|
||||
void C_4JProfile::GetXUID(int iPad, PlayerUID *pXuid,bool bOnlineXuid)
|
||||
{
|
||||
if (iPad == 0)
|
||||
{
|
||||
extern char g_Win64Username[17];
|
||||
*pXuid = Win64_UsernameToXuid(g_Win64Username);
|
||||
}
|
||||
else if (iPad > 0 && iPad < XUSER_MAX_COUNT)
|
||||
{
|
||||
char splitName[32];
|
||||
Win64_BuildSplitName(iPad, splitName, sizeof(splitName));
|
||||
*pXuid = Win64_UsernameToXuid(splitName);
|
||||
}
|
||||
else
|
||||
{
|
||||
*pXuid = INVALID_XUID;
|
||||
}
|
||||
}
|
||||
BOOL C_4JProfile::AreXUIDSEqual(PlayerUID xuid1,PlayerUID xuid2) { return xuid1 == xuid2; }
|
||||
BOOL C_4JProfile::XUIDIsGuest(PlayerUID xuid) { return false; }
|
||||
bool C_4JProfile::AllowedToPlayMultiplayer(int iProf) { return true; }
|
||||
|
||||
#endif
|
||||
#ifdef _WINDOWS64
|
||||
#if defined(__ORBIS__)
|
||||
bool C_4JProfile::GetChatAndContentRestrictions(int iPad, bool thisQuadrantOnly, bool *pbChatRestricted,bool *pbContentRestricted,int *piAge)
|
||||
{
|
||||
@@ -488,14 +730,31 @@ char fakeGamerTag[32] = "PlayerName";
|
||||
#ifdef _DURANGO
|
||||
void SetFakeGamertag(char *name){ strcpy_s(fakeGamerTag, name); }
|
||||
char* C_4JProfile::GetGamertag(int iPad){ return fakeGamerTag; }
|
||||
#elif _WINDOWS64
|
||||
void CConsoleMinecraftApp::SetFakeGamertag(char *name){ strcpy_s(fakeGamerTag, name); size_t chars = 0; mbstowcs_s(&chars, fakeGamerTagW, 32, name, _TRUNCATE); }
|
||||
char* C_4JProfile::GetGamertag(int iPad){ return fakeGamerTag; }
|
||||
wstring C_4JProfile::GetDisplayName(int iPad){ return fakeGamerTagW; }
|
||||
#else //str1k3r - every other platform BUT Windows64 and Durango
|
||||
void SetFakeGamertag(char *name){ strcpy_s(fakeGamerTag, name); size_t chars = 0; }
|
||||
char* C_4JProfile::GetGamertag(int iPad){ return fakeGamerTag; }
|
||||
wstring C_4JProfile::GetDisplayName(int iPad){ return L"PlayerName"; }
|
||||
#else
|
||||
static char s_win64SplitNames[4][32];
|
||||
char* C_4JProfile::GetGamertag(int iPad)
|
||||
{
|
||||
extern char g_Win64Username[17];
|
||||
if (iPad == 0) return g_Win64Username;
|
||||
if (iPad > 0 && iPad < XUSER_MAX_COUNT)
|
||||
{
|
||||
Win64_BuildSplitName(iPad, s_win64SplitNames[iPad], sizeof(s_win64SplitNames[iPad]));
|
||||
return s_win64SplitNames[iPad];
|
||||
}
|
||||
return g_Win64Username;
|
||||
}
|
||||
wstring C_4JProfile::GetDisplayName(int iPad)
|
||||
{
|
||||
extern wchar_t g_Win64UsernameW[17];
|
||||
if (iPad == 0) return g_Win64UsernameW;
|
||||
if (iPad > 0 && iPad < XUSER_MAX_COUNT)
|
||||
{
|
||||
wchar_t buf[32];
|
||||
Win64_BuildSplitNameW(iPad, buf, 32);
|
||||
return buf;
|
||||
}
|
||||
return g_Win64UsernameW;
|
||||
}
|
||||
#endif
|
||||
bool C_4JProfile::IsFullVersion() { return s_bProfileIsFullVersion; }
|
||||
void C_4JProfile::SetSignInChangeCallback(void ( *Func)(LPVOID, bool, unsigned int),LPVOID lpParam) {}
|
||||
@@ -661,4 +920,5 @@ void StatsCounter::WipeLeaderboards() {}
|
||||
|
||||
#ifdef __PS3__
|
||||
bool C_4JProfile::IsFullVersion() { return true; }
|
||||
#endif
|
||||
#endif
|
||||
@@ -105,8 +105,6 @@ GameRenderer::GameRenderer(Minecraft *mc)
|
||||
zoom = 1;
|
||||
zoom_x = 0;
|
||||
zoom_y = 0;
|
||||
rainXa = NULL;
|
||||
rainZa = NULL;
|
||||
lastActiveTime = Minecraft::currentTimeMillis();
|
||||
lastNsTime = 0;
|
||||
random = new Random();
|
||||
@@ -181,8 +179,9 @@ GameRenderer::GameRenderer(Minecraft *mc)
|
||||
// 4J Stu Added to go with 1.8.2 change
|
||||
GameRenderer::~GameRenderer()
|
||||
{
|
||||
if(rainXa != NULL) delete [] rainXa;
|
||||
if(rainZa != NULL) delete [] rainZa;
|
||||
delete random;
|
||||
delete cameraPos;
|
||||
delete lb;
|
||||
}
|
||||
|
||||
void GameRenderer::tick(bool first) // 4J - add bFirst
|
||||
@@ -838,19 +837,21 @@ void GameRenderer::updateLightTexture(float a)
|
||||
Level *level = player->level; // 4J - was mc->level when it was just to update the one light texture
|
||||
|
||||
float skyDarken1 = level->getSkyDarken((float) 1);
|
||||
float darken = skyDarken1 * 0.95f + 0.05f;
|
||||
float rsGsMul = skyDarken1 * 0.65f + 0.35f;
|
||||
float blockMul = blr * 0.1f + 1.5f;
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
float darken = skyDarken1 * 0.95f + 0.05f;
|
||||
float sky = level->dimension->brightnessRamp[i / 16] * darken;
|
||||
float block = level->dimension->brightnessRamp[i % 16] * (blr * 0.1f + 1.5f);
|
||||
float block = level->dimension->brightnessRamp[i % 16] * blockMul;
|
||||
|
||||
if (level->skyFlashTime > 0)
|
||||
{
|
||||
sky = level->dimension->brightnessRamp[i / 16];
|
||||
}
|
||||
|
||||
float rs = sky * (skyDarken1 * 0.65f + 0.35f);
|
||||
float gs = sky * (skyDarken1 * 0.65f + 0.35f);
|
||||
float rs = sky * rsGsMul;
|
||||
float gs = sky * rsGsMul;
|
||||
float bs = sky;
|
||||
|
||||
float rb = block;
|
||||
@@ -1526,27 +1527,30 @@ void GameRenderer::tickRain()
|
||||
int x = x0 + random->nextInt(r) - random->nextInt(r);
|
||||
int z = z0 + random->nextInt(r) - random->nextInt(r);
|
||||
int y = level->getTopRainBlock(x, z);
|
||||
int t = level->getTile(x, y - 1, z);
|
||||
Biome *biome = level->getBiome(x,z);
|
||||
if (y <= y0 + r && y >= y0 - r && biome->hasRain() && biome->getTemperature() >= 0.2f)
|
||||
if (y <= y0 + r && y >= y0 - r)
|
||||
{
|
||||
float xa = random->nextFloat();
|
||||
float za = random->nextFloat();
|
||||
if (t > 0)
|
||||
int t = level->getTile(x, y - 1, z);
|
||||
Biome *biome = level->getBiome(x,z);
|
||||
if (biome->hasRain() && biome->getTemperature() >= 0.2f)
|
||||
{
|
||||
if (Tile::tiles[t]->material == Material::lava)
|
||||
float xa = random->nextFloat();
|
||||
float za = random->nextFloat();
|
||||
if (t > 0)
|
||||
{
|
||||
mc->particleEngine->add( shared_ptr<SmokeParticle>( new SmokeParticle(level, x + xa, y + 0.1f - Tile::tiles[t]->getShapeY0(), z + za, 0, 0, 0) ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
if (random->nextInt(++rainPosSamples) == 0)
|
||||
if (Tile::tiles[t]->material == Material::lava)
|
||||
{
|
||||
rainPosX = x + xa;
|
||||
rainPosY = y + 0.1f - Tile::tiles[t]->getShapeY0();
|
||||
rainPosZ = z + za;
|
||||
mc->particleEngine->add( shared_ptr<SmokeParticle>( new SmokeParticle(level, x + xa, y + 0.1f - Tile::tiles[t]->getShapeY0(), z + za, 0, 0, 0) ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
if (random->nextInt(++rainPosSamples) == 0)
|
||||
{
|
||||
rainPosX = x + xa;
|
||||
rainPosY = y + 0.1f - Tile::tiles[t]->getShapeY0();
|
||||
rainPosZ = z + za;
|
||||
}
|
||||
mc->particleEngine->add( shared_ptr<WaterDropParticle>( new WaterDropParticle(level, x + xa, y + 0.1f - Tile::tiles[t]->getShapeY0(), z + za) ) );
|
||||
}
|
||||
mc->particleEngine->add( shared_ptr<WaterDropParticle>( new WaterDropParticle(level, x + xa, y + 0.1f - Tile::tiles[t]->getShapeY0(), z + za) ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1581,10 +1585,12 @@ void GameRenderer::renderSnowAndRain(float a)
|
||||
|
||||
turnOnLightLayer(a);
|
||||
|
||||
if (rainXa == NULL)
|
||||
static float rainXa[32 * 32];
|
||||
static float rainZa[32 * 32];
|
||||
static bool rainArraysInitialized = false;
|
||||
if (!rainArraysInitialized)
|
||||
{
|
||||
rainXa = new float[32 * 32];
|
||||
rainZa = new float[32 * 32];
|
||||
rainArraysInitialized = true;
|
||||
|
||||
for (int z = 0; z < 32; z++)
|
||||
{
|
||||
|
||||
@@ -128,8 +128,6 @@ private:
|
||||
void tickRain();
|
||||
private:
|
||||
// 4J - brought forward from 1.8.2
|
||||
float *rainXa;
|
||||
float *rainZa;
|
||||
protected:
|
||||
void renderSnowAndRain(float a);
|
||||
volatile int xMod;
|
||||
|
||||
@@ -10,7 +10,7 @@ ResourceLocation HorseRenderer::HORSE_DONKEY_LOCATION = ResourceLocation(TN_MOB_
|
||||
ResourceLocation HorseRenderer::HORSE_ZOMBIE_LOCATION = ResourceLocation(TN_MOB_HORSE_ZOMBIE);
|
||||
ResourceLocation HorseRenderer::HORSE_SKELETON_LOCATION = ResourceLocation(TN_MOB_HORSE_SKELETON);
|
||||
|
||||
std::map<wstring, ResourceLocation *> HorseRenderer::LAYERED_LOCATION_CACHE;
|
||||
std::map<wstring, ResourceLocation> HorseRenderer::LAYERED_LOCATION_CACHE;
|
||||
|
||||
HorseRenderer::HorseRenderer(Model *model, float f) : MobRenderer(model, f)
|
||||
{
|
||||
@@ -114,14 +114,14 @@ ResourceLocation *HorseRenderer::getOrCreateLayeredTextureLocation(shared_ptr<En
|
||||
ResourceLocation *location;
|
||||
if (it != LAYERED_LOCATION_CACHE.end())
|
||||
{
|
||||
location = it->second;
|
||||
location = &(it->second);
|
||||
}
|
||||
else
|
||||
{
|
||||
LAYERED_LOCATION_CACHE[textureName] = new ResourceLocation(horse->getLayeredTextureLayers());
|
||||
LAYERED_LOCATION_CACHE[textureName] = ResourceLocation(horse->getLayeredTextureLayers());
|
||||
|
||||
it = LAYERED_LOCATION_CACHE.find(textureName);
|
||||
location = it->second;
|
||||
location = &(it->second);
|
||||
}
|
||||
|
||||
return location;
|
||||
|
||||
@@ -8,7 +8,7 @@ class PathfinderMob;
|
||||
class HorseRenderer : public MobRenderer
|
||||
{
|
||||
private:
|
||||
static std::map<wstring, ResourceLocation *> LAYERED_LOCATION_CACHE;
|
||||
static std::map<wstring, ResourceLocation> LAYERED_LOCATION_CACHE;
|
||||
|
||||
static ResourceLocation HORSE_LOCATION;
|
||||
static ResourceLocation HORSE_MULE_LOCATION;
|
||||
|
||||
@@ -1964,7 +1964,11 @@ bool LevelRenderer::updateDirtyChunks()
|
||||
{
|
||||
if( (!onlyRebuild) ||
|
||||
globalChunkFlags[ pClipChunk->globalIdx ] & CHUNK_FLAG_COMPILED ||
|
||||
#ifdef _WINDOWS64
|
||||
( distSq < 96 * 96 ) ) // Always rebuild really near things or else building (say) at tower up into empty blocks when we are low on memory will not create render data
|
||||
#else
|
||||
( distSq < 20 * 20 ) ) // Always rebuild really near things or else building (say) at tower up into empty blocks when we are low on memory will not create render data
|
||||
#endif
|
||||
{
|
||||
considered++;
|
||||
// Is this chunk nearer than our nearest?
|
||||
|
||||
@@ -52,7 +52,9 @@ public:
|
||||
static const int CHUNK_SIZE = 16;
|
||||
#endif
|
||||
static const int CHUNK_Y_COUNT = Level::maxBuildHeight / CHUNK_SIZE;
|
||||
#if ( defined _XBOX_ONE || defined _WINDOWS64 )
|
||||
#if defined _WINDOWS64
|
||||
static const int MAX_COMMANDBUFFER_ALLOCATIONS = 2047 * 1024 * 1024; // whisper - added (wow)
|
||||
#elif ( defined _XBOX_ONE )
|
||||
static const int MAX_COMMANDBUFFER_ALLOCATIONS = 512 * 1024 * 1024; // 4J - added
|
||||
#elif defined __ORBIS__
|
||||
static const int MAX_COMMANDBUFFER_ALLOCATIONS = 448 * 1024 * 1024; // 4J - added - hard limit is 512 so giving a lot of headroom here for fragmentation (have seen 16MB lost to fragmentation in multiplayer crash dump before)
|
||||
|
||||
@@ -531,7 +531,7 @@ void LivingEntityRenderer::renderNameTag(shared_ptr<LivingEntity> mob, const wst
|
||||
int offs = 0;
|
||||
|
||||
wstring playerName;
|
||||
WCHAR wchName[2];
|
||||
WCHAR wchName[8];
|
||||
|
||||
if(mob->instanceof(eTYPE_PLAYER))
|
||||
{
|
||||
@@ -551,7 +551,7 @@ void LivingEntityRenderer::renderNameTag(shared_ptr<LivingEntity> mob, const wst
|
||||
}
|
||||
else
|
||||
{
|
||||
memset(wchName,0,sizeof(WCHAR)*2);
|
||||
memset(wchName,0,sizeof(wchName));
|
||||
swprintf(wchName, 2, L"%d",player->getPlayerIndex()+1);
|
||||
playerName=wchName;
|
||||
player->SetPlayerNameValidState(false);
|
||||
@@ -561,7 +561,7 @@ void LivingEntityRenderer::renderNameTag(shared_ptr<LivingEntity> mob, const wst
|
||||
playerName=name;
|
||||
break;
|
||||
case Player::ePlayerNameValid_False:
|
||||
memset(wchName,0,sizeof(WCHAR)*2);
|
||||
memset(wchName,0,sizeof(wchName));
|
||||
swprintf(wchName, 2, L"%d",player->getPlayerIndex()+1);
|
||||
playerName=wchName;
|
||||
break;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -732,6 +732,9 @@
|
||||
<Filter Include="Windows64\Windows64Extras">
|
||||
<UniqueIdentifier>{7a457cb8-28b7-4bbc-8209-e2ed3adeb8fd}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Common\Source Files\Network\SocketManager">
|
||||
<UniqueIdentifier>{3977f528-165f-4612-8fe6-bfb3f9a6983d}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="ReadMe.txt" />
|
||||
@@ -3124,9 +3127,6 @@
|
||||
<ClInclude Include="Xbox\Network\PlatformNetworkManagerXbox.h">
|
||||
<Filter>Xbox\Source Files\Network</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Common\Network\PlatformNetworkManagerStub.h">
|
||||
<Filter>Common\Source Files\Network</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Xbox\Network\NetworkPlayerXbox.h">
|
||||
<Filter>Xbox\Source Files\Network</Filter>
|
||||
</ClInclude>
|
||||
@@ -3628,9 +3628,6 @@
|
||||
<ClInclude Include="Orbis\Network\PsPlusUpsellWrapper_Orbis.h">
|
||||
<Filter>Orbis\Network</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Xbox\Network\extra.h">
|
||||
<Filter>Xbox\Source Files\Network</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Common\UI\UIScene_Keyboard.h">
|
||||
<Filter>Common\Source Files\UI\Scenes</Filter>
|
||||
</ClInclude>
|
||||
@@ -3793,6 +3790,15 @@
|
||||
<ClInclude Include="PSVita\PSVitaExtras\OldSdk.h">
|
||||
<Filter>PSVita</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Common\Network\IQNet.h">
|
||||
<Filter>Common\Source Files\Network</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Common\Network\NetworkSocketLayer.h">
|
||||
<Filter>Common\Source Files\Network</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Common\Network\PlatformNetworkManager.h">
|
||||
<Filter>Common\Source Files\Network</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Windows64\Windows64_Minecraft.h">
|
||||
<Filter>Windows64\Source Files</Filter>
|
||||
</ClInclude>
|
||||
@@ -3805,6 +3811,12 @@
|
||||
<ClInclude Include="Windows64\Windows64Extras\Windows64Stubs.h">
|
||||
<Filter>Windows64\Windows64Extras</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="PSVita\OldSdk.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Common\Network\SocketManagers\NetworkSocketManager.h">
|
||||
<Filter>Common\Source Files\Network\SocketManager</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="stdafx.cpp">
|
||||
@@ -5349,9 +5361,6 @@
|
||||
<ClCompile Include="Xbox\Network\PlatformNetworkManagerXbox.cpp">
|
||||
<Filter>Xbox\Source Files\Network</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Common\Network\PlatformNetworkManagerStub.cpp">
|
||||
<Filter>Common\Source Files\Network</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Xbox\Network\NetworkPlayerXbox.cpp">
|
||||
<Filter>Xbox\Source Files\Network</Filter>
|
||||
</ClCompile>
|
||||
@@ -5943,6 +5952,12 @@
|
||||
<ClCompile Include="PSVita\PSVitaExtras\OldSdk.cpp">
|
||||
<Filter>PSVita</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Common\Network\NetworkSocketLayer.cpp">
|
||||
<Filter>Common\Source Files\Network</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Common\Network\PlatformNetworkManager.cpp">
|
||||
<Filter>Common\Source Files\Network</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Xbox\Xbox_UIController.cpp">
|
||||
<Filter>Xbox</Filter>
|
||||
</ClCompile>
|
||||
@@ -5952,6 +5967,21 @@
|
||||
<ClCompile Include="Windows64\Windows64Extras\Windows64Stubs.cpp">
|
||||
<Filter>Windows64\Windows64Extras</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Common\Network\SocketManagers\CPlatformSocketManagerXbox.cpp">
|
||||
<Filter>Common\Source Files\Network\SocketManager</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Common\Network\SocketManagers\CPlatformSocketManagerPS3.cpp">
|
||||
<Filter>Common\Source Files\Network\SocketManager</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Common\Network\SocketManagers\CPlatformSocketManagerPS4.cpp">
|
||||
<Filter>Common\Source Files\Network\SocketManager</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Common\Network\SocketManagers\CPlatformSocketManagerPSVita.cpp">
|
||||
<Filter>Common\Source Files\Network\SocketManager</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Common\Network\SocketManagers\CPlatformSocketManagerWindows64.cpp">
|
||||
<Filter>Common\Source Files\Network\SocketManager</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Library Include="Xbox\4JLibs\libs\4J_Render_d.lib">
|
||||
|
||||
@@ -1299,9 +1299,9 @@ void Minecraft::run_middle()
|
||||
INetworkPlayer *pHostPlayer = g_NetworkManager.GetHostPlayer();
|
||||
|
||||
#ifdef _XBOX
|
||||
PlayerUID xuid=((NetworkPlayerXbox *)pHostPlayer)->GetUID();
|
||||
PlayerUID xuid=((pHostPlayer != NULL) ? ((NetworkPlayerXbox *)pHostPlayer)->GetUID() : 0);
|
||||
#else
|
||||
PlayerUID xuid=pHostPlayer->GetUID();
|
||||
PlayerUID xuid=(pHostPlayer != NULL) ? pHostPlayer->GetUID() : 0;
|
||||
#endif
|
||||
|
||||
if(app.IsInBannedLevelList(i,xuid,app.GetUniqueMapName()))
|
||||
@@ -3973,6 +3973,7 @@ void Minecraft::releaseLevel(int message)
|
||||
// time when exiting from an online game
|
||||
void Minecraft::forceStatsSave(int idx)
|
||||
{
|
||||
#ifndef DISABLE_PSN
|
||||
//4J Gordon: Force a stats save
|
||||
stats[idx]->save(idx, true);
|
||||
|
||||
@@ -3984,6 +3985,7 @@ void Minecraft::forceStatsSave(int idx)
|
||||
stats[idx]->saveLeaderboards();
|
||||
ProfileManager.SetLockedProfile(tempLockedProfile);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
// 4J Added
|
||||
@@ -4989,12 +4991,16 @@ ColourTable *Minecraft::getColourTable()
|
||||
int Minecraft::MustSignInReturnedPSN(void *pParam, int iPad, C4JStorage::EMessageResult result)
|
||||
{
|
||||
Minecraft* pMinecraft = (Minecraft *)pParam;
|
||||
#ifdef DISABLE_PSN
|
||||
Minecraft::InGame_SignInReturned(pMinecraft, true, iPad);
|
||||
#else
|
||||
|
||||
if(result == C4JStorage::EMessage_ResultAccept)
|
||||
{
|
||||
SQRNetworkManager_Orbis::AttemptPSNSignIn(&Minecraft::InGame_SignInReturned, pMinecraft, false, iPad);
|
||||
}
|
||||
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -27,9 +27,19 @@
|
||||
#include "..\Minecraft.World\Pos.h"
|
||||
#include "..\Minecraft.World\System.h"
|
||||
#include "..\Minecraft.World\StringHelpers.h"
|
||||
#include "../Minecraft.World/net.minecraft.world.entity.item.h"
|
||||
#include "../Minecraft.World/net.minecraft.world.item.h"
|
||||
#include "../Minecraft.World/net.minecraft.world.item.enchantment.h"
|
||||
#include "../Minecraft.World/net.minecraft.world.damagesource.h"
|
||||
#ifdef SPLIT_SAVES
|
||||
#include "..\Minecraft.World\ConsoleSaveFileSplit.h"
|
||||
#endif
|
||||
#if defined(_WINDOWS64) || defined(DISABLE_PSN) || defined(_DISABLE_XBLIVE)
|
||||
#include "Common/Network/NetworkSocketLayer.h"
|
||||
#endif
|
||||
#if defined(_WINDOWS64) && defined(MINECRAFT_SERVER_BUILD)
|
||||
#include "../Minecraft.Server/ServerLogger.h"
|
||||
#endif
|
||||
#include "..\Minecraft.World\ConsoleSaveFileOriginal.h"
|
||||
#include "..\Minecraft.World\Socket.h"
|
||||
#include "..\Minecraft.World\net.minecraft.world.entity.h"
|
||||
@@ -78,6 +88,464 @@ bool MinecraftServer::s_slowQueuePacketSent = false;
|
||||
|
||||
unordered_map<wstring, int> MinecraftServer::ironTimers;
|
||||
|
||||
#ifdef MINECRAFT_SERVER_BUILD
|
||||
static bool ShouldUseDedicatedServerProperties()
|
||||
{
|
||||
#if defined(MINECRAFT_SERVER_BUILD)
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
static int GetDedicatedServerInt(Settings *settings, const wchar_t *key, int defaultValue)
|
||||
{
|
||||
return (ShouldUseDedicatedServerProperties() && settings != nullptr) ? settings->getInt(key, defaultValue) : defaultValue;
|
||||
}
|
||||
|
||||
static bool GetDedicatedServerBool(Settings *settings, const wchar_t *key, bool defaultValue)
|
||||
{
|
||||
return (ShouldUseDedicatedServerProperties() && settings != nullptr) ? settings->getBoolean(key, defaultValue) : defaultValue;
|
||||
}
|
||||
|
||||
static wstring GetDedicatedServerString(Settings *settings, const wchar_t *key, const wstring &defaultValue)
|
||||
{
|
||||
return (ShouldUseDedicatedServerProperties() && settings != nullptr) ? settings->getString(key, defaultValue) : defaultValue;
|
||||
}
|
||||
|
||||
static void PrintConsoleLine(const wchar_t *prefix, const wstring &message)
|
||||
{
|
||||
wprintf(L"%ls%ls\n", prefix, message.c_str());
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
static bool TryParseIntValue(const wstring &text, int &value)
|
||||
{
|
||||
std::wistringstream stream(text);
|
||||
stream >> value;
|
||||
return !stream.fail() && stream.eof();
|
||||
}
|
||||
|
||||
static vector<wstring> SplitConsoleCommand(const wstring &command)
|
||||
{
|
||||
vector<wstring> tokens;
|
||||
std::wistringstream stream(command);
|
||||
wstring token;
|
||||
while (stream >> token)
|
||||
{
|
||||
tokens.push_back(token);
|
||||
}
|
||||
return tokens;
|
||||
}
|
||||
|
||||
static wstring JoinConsoleCommandTokens(const vector<wstring> &tokens, size_t startIndex)
|
||||
{
|
||||
wstring joined;
|
||||
for (size_t i = startIndex; i < tokens.size(); ++i)
|
||||
{
|
||||
if (!joined.empty()) joined += L" ";
|
||||
joined += tokens[i];
|
||||
}
|
||||
return joined;
|
||||
}
|
||||
|
||||
static shared_ptr<ServerPlayer> FindPlayerByName(PlayerList *playerList, const wstring &name)
|
||||
{
|
||||
if (playerList == nullptr) return nullptr;
|
||||
|
||||
for (size_t i = 0; i < playerList->players.size(); ++i)
|
||||
{
|
||||
shared_ptr<ServerPlayer> player = playerList->players[i];
|
||||
if (player != nullptr && equalsIgnoreCase(player->getName(), name))
|
||||
{
|
||||
return player;
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static void SetAllLevelTimes(MinecraftServer *server, int value)
|
||||
{
|
||||
for (unsigned int i = 0; i < server->levels.length; ++i)
|
||||
{
|
||||
if (server->levels[i] != nullptr)
|
||||
{
|
||||
server->levels[i]->setDayTime(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static bool ExecuteConsoleCommand(MinecraftServer *server, const wstring &rawCommand)
|
||||
{
|
||||
if (server == nullptr)
|
||||
return false;
|
||||
|
||||
wstring command = trimString(rawCommand);
|
||||
if (command.empty())
|
||||
return true;
|
||||
|
||||
if (command[0] == L'/')
|
||||
{
|
||||
command = trimString(command.substr(1));
|
||||
}
|
||||
|
||||
vector<wstring> tokens = SplitConsoleCommand(command);
|
||||
if (tokens.empty())
|
||||
return true;
|
||||
|
||||
const wstring action = toLower(tokens[0]);
|
||||
PlayerList *playerList = server->getPlayers();
|
||||
|
||||
if (action == L"help" || action == L"?")
|
||||
{
|
||||
server->info(L"Commands: help, stop, list, say <message>, save-all, time <set day|night|ticks|add ticks>, weather <clear|rain|thunder> [seconds], tp <player> <target>, give <player> <itemId> [amount] [aux], enchant <player> <enchantId> [level], kill <player>");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (action == L"stop")
|
||||
{
|
||||
server->info(L"Stopping server...");
|
||||
MinecraftServer::HaltServer();
|
||||
return true;
|
||||
}
|
||||
|
||||
if (action == L"list")
|
||||
{
|
||||
wstring playerNames = (playerList != nullptr) ? playerList->getPlayerNames() : L"";
|
||||
if (playerNames.empty()) playerNames = L"(none)";
|
||||
server->info(L"Players (" + std::to_wstring((playerList != nullptr) ? playerList->getPlayerCount() : 0) + L"): " + playerNames);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (action == L"say")
|
||||
{
|
||||
if (tokens.size() < 2)
|
||||
{
|
||||
server->warn(L"Usage: say <message>");
|
||||
return false;
|
||||
}
|
||||
|
||||
wstring message = L"[Server] " + JoinConsoleCommandTokens(tokens, 1);
|
||||
if (playerList != nullptr)
|
||||
{
|
||||
playerList->broadcastAll(std::make_shared<ChatPacket>(message));
|
||||
}
|
||||
server->info(message);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (action == L"save-all")
|
||||
{
|
||||
if (playerList != nullptr)
|
||||
{
|
||||
playerList->saveAll(nullptr, false);
|
||||
}
|
||||
server->info(L"World saved.");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (action == L"time")
|
||||
{
|
||||
if (tokens.size() < 2)
|
||||
{
|
||||
server->warn(L"Usage: time set <day|night|ticks> | time add <ticks>");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (toLower(tokens[1]) == L"add")
|
||||
{
|
||||
if (tokens.size() < 3)
|
||||
{
|
||||
server->warn(L"Usage: time add <ticks>");
|
||||
return false;
|
||||
}
|
||||
|
||||
int delta = 0;
|
||||
if (!TryParseIntValue(tokens[2], delta))
|
||||
{
|
||||
server->warn(L"Invalid tick value: " + tokens[2]);
|
||||
return false;
|
||||
}
|
||||
|
||||
for (unsigned int i = 0; i < server->levels.length; ++i)
|
||||
{
|
||||
if (server->levels[i] != nullptr)
|
||||
{
|
||||
server->levels[i]->setDayTime(server->levels[i]->getDayTime() + delta);
|
||||
}
|
||||
}
|
||||
|
||||
server->info(L"Added " + std::to_wstring(delta) + L" ticks.");
|
||||
return true;
|
||||
}
|
||||
|
||||
wstring timeValue = toLower(tokens[1]);
|
||||
if (timeValue == L"set")
|
||||
{
|
||||
if (tokens.size() < 3)
|
||||
{
|
||||
server->warn(L"Usage: time set <day|night|ticks>");
|
||||
return false;
|
||||
}
|
||||
timeValue = toLower(tokens[2]);
|
||||
}
|
||||
|
||||
int targetTime = 0;
|
||||
if (timeValue == L"day")
|
||||
{
|
||||
targetTime = 0;
|
||||
}
|
||||
else if (timeValue == L"night")
|
||||
{
|
||||
targetTime = 12500;
|
||||
}
|
||||
else if (!TryParseIntValue(timeValue, targetTime))
|
||||
{
|
||||
server->warn(L"Invalid time value: " + timeValue);
|
||||
return false;
|
||||
}
|
||||
|
||||
SetAllLevelTimes(server, targetTime);
|
||||
server->info(L"Time set to " + std::to_wstring(targetTime) + L".");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (action == L"weather")
|
||||
{
|
||||
if (tokens.size() < 2)
|
||||
{
|
||||
server->warn(L"Usage: weather <clear|rain|thunder> [seconds]");
|
||||
return false;
|
||||
}
|
||||
|
||||
int durationSeconds = 600;
|
||||
if (tokens.size() >= 3 && !TryParseIntValue(tokens[2], durationSeconds))
|
||||
{
|
||||
server->warn(L"Invalid duration: " + tokens[2]);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (server->levels[0] == nullptr)
|
||||
{
|
||||
server->warn(L"The overworld is not loaded.");
|
||||
return false;
|
||||
}
|
||||
|
||||
LevelData *levelData = server->levels[0]->getLevelData();
|
||||
int duration = durationSeconds * SharedConstants::TICKS_PER_SECOND;
|
||||
levelData->setRainTime(duration);
|
||||
levelData->setThunderTime(duration);
|
||||
|
||||
wstring weather = toLower(tokens[1]);
|
||||
if (weather == L"clear")
|
||||
{
|
||||
levelData->setRaining(false);
|
||||
levelData->setThundering(false);
|
||||
}
|
||||
else if (weather == L"rain")
|
||||
{
|
||||
levelData->setRaining(true);
|
||||
levelData->setThundering(false);
|
||||
}
|
||||
else if (weather == L"thunder")
|
||||
{
|
||||
levelData->setRaining(true);
|
||||
levelData->setThundering(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
server->warn(L"Usage: weather <clear|rain|thunder> [seconds]");
|
||||
return false;
|
||||
}
|
||||
|
||||
server->info(L"Weather set to " + weather + L".");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (action == L"tp" || action == L"teleport")
|
||||
{
|
||||
if (tokens.size() < 3)
|
||||
{
|
||||
server->warn(L"Usage: tp <player> <target>");
|
||||
return false;
|
||||
}
|
||||
|
||||
shared_ptr<ServerPlayer> subject = FindPlayerByName(playerList, tokens[1]);
|
||||
shared_ptr<ServerPlayer> destination = FindPlayerByName(playerList, tokens[2]);
|
||||
if (subject == nullptr)
|
||||
{
|
||||
server->warn(L"Unknown player: " + tokens[1]);
|
||||
return false;
|
||||
}
|
||||
if (destination == nullptr)
|
||||
{
|
||||
server->warn(L"Unknown player: " + tokens[2]);
|
||||
return false;
|
||||
}
|
||||
if (subject->level->dimension->id != destination->level->dimension->id || !subject->isAlive())
|
||||
{
|
||||
server->warn(L"Teleport failed because the players are not in the same dimension or the source player is dead.");
|
||||
return false;
|
||||
}
|
||||
|
||||
subject->ride(nullptr);
|
||||
subject->connection->teleport(destination->x, destination->y, destination->z, destination->yRot, destination->xRot);
|
||||
server->info(L"Teleported " + subject->getName() + L" to " + destination->getName() + L".");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (action == L"give")
|
||||
{
|
||||
if (tokens.size() < 3)
|
||||
{
|
||||
server->warn(L"Usage: give <player> <itemId> [amount] [aux]");
|
||||
return false;
|
||||
}
|
||||
|
||||
shared_ptr<ServerPlayer> player = FindPlayerByName(playerList, tokens[1]);
|
||||
if (player == nullptr)
|
||||
{
|
||||
server->warn(L"Unknown player: " + tokens[1]);
|
||||
return false;
|
||||
}
|
||||
|
||||
int itemId = 0;
|
||||
int amount = 1;
|
||||
int aux = 0;
|
||||
if (!TryParseIntValue(tokens[2], itemId))
|
||||
{
|
||||
server->warn(L"Invalid item id: " + tokens[2]);
|
||||
return false;
|
||||
}
|
||||
if (tokens.size() >= 4 && !TryParseIntValue(tokens[3], amount))
|
||||
{
|
||||
server->warn(L"Invalid amount: " + tokens[3]);
|
||||
return false;
|
||||
}
|
||||
if (tokens.size() >= 5 && !TryParseIntValue(tokens[4], aux))
|
||||
{
|
||||
server->warn(L"Invalid aux value: " + tokens[4]);
|
||||
return false;
|
||||
}
|
||||
if (itemId <= 0 || Item::items[itemId] == nullptr)
|
||||
{
|
||||
server->warn(L"Unknown item id: " + std::to_wstring(itemId));
|
||||
return false;
|
||||
}
|
||||
if (amount <= 0)
|
||||
{
|
||||
server->warn(L"Amount must be positive.");
|
||||
return false;
|
||||
}
|
||||
|
||||
shared_ptr<ItemInstance> itemInstance(new ItemInstance(itemId, amount, aux));
|
||||
shared_ptr<ItemEntity> drop = player->drop(itemInstance);
|
||||
if (drop != nullptr)
|
||||
{
|
||||
drop->throwTime = 0;
|
||||
}
|
||||
server->info(L"Gave item " + std::to_wstring(itemId) + L" x" + std::to_wstring(amount) + L" to " + player->getName() + L".");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (action == L"enchant")
|
||||
{
|
||||
if (tokens.size() < 3)
|
||||
{
|
||||
server->warn(L"Usage: enchant <player> <enchantId> [level]");
|
||||
return false;
|
||||
}
|
||||
|
||||
shared_ptr<ServerPlayer> player = FindPlayerByName(playerList, tokens[1]);
|
||||
if (player == nullptr)
|
||||
{
|
||||
server->warn(L"Unknown player: " + tokens[1]);
|
||||
return false;
|
||||
}
|
||||
|
||||
int enchantmentId = 0;
|
||||
int enchantmentLevel = 1;
|
||||
if (!TryParseIntValue(tokens[2], enchantmentId))
|
||||
{
|
||||
server->warn(L"Invalid enchantment id: " + tokens[2]);
|
||||
return false;
|
||||
}
|
||||
if (tokens.size() >= 4 && !TryParseIntValue(tokens[3], enchantmentLevel))
|
||||
{
|
||||
server->warn(L"Invalid enchantment level: " + tokens[3]);
|
||||
return false;
|
||||
}
|
||||
|
||||
shared_ptr<ItemInstance> selectedItem = player->getSelectedItem();
|
||||
if (selectedItem == nullptr)
|
||||
{
|
||||
server->warn(L"The player is not holding an item.");
|
||||
return false;
|
||||
}
|
||||
|
||||
Enchantment *enchantment = Enchantment::enchantments[enchantmentId];
|
||||
if (enchantment == nullptr)
|
||||
{
|
||||
server->warn(L"Unknown enchantment id: " + std::to_wstring(enchantmentId));
|
||||
return false;
|
||||
}
|
||||
if (!enchantment->canEnchant(selectedItem))
|
||||
{
|
||||
server->warn(L"That enchantment cannot be applied to the selected item.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (enchantmentLevel < enchantment->getMinLevel()) enchantmentLevel = enchantment->getMinLevel();
|
||||
if (enchantmentLevel > enchantment->getMaxLevel()) enchantmentLevel = enchantment->getMaxLevel();
|
||||
|
||||
if (selectedItem->hasTag())
|
||||
{
|
||||
ListTag<CompoundTag> *enchantmentTags = selectedItem->getEnchantmentTags();
|
||||
if (enchantmentTags != nullptr)
|
||||
{
|
||||
for (int i = 0; i < enchantmentTags->size(); i++)
|
||||
{
|
||||
int type = enchantmentTags->get(i)->getShort((wchar_t *)ItemInstance::TAG_ENCH_ID);
|
||||
if (Enchantment::enchantments[type] != nullptr && !Enchantment::enchantments[type]->isCompatibleWith(enchantment))
|
||||
{
|
||||
server->warn(L"That enchantment conflicts with an existing enchantment on the selected item.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
selectedItem->enchant(enchantment, enchantmentLevel);
|
||||
server->info(L"Enchanted " + player->getName() + L"'s held item with " + std::to_wstring(enchantmentId) + L" " + std::to_wstring(enchantmentLevel) + L".");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (action == L"kill")
|
||||
{
|
||||
if (tokens.size() < 2)
|
||||
{
|
||||
server->warn(L"Usage: kill <player>");
|
||||
return false;
|
||||
}
|
||||
|
||||
shared_ptr<ServerPlayer> player = FindPlayerByName(playerList, tokens[1]);
|
||||
if (player == nullptr)
|
||||
{
|
||||
server->warn(L"Unknown player: " + tokens[1]);
|
||||
return false;
|
||||
}
|
||||
|
||||
player->hurt(DamageSource::outOfWorld, 3.4e38f);
|
||||
server->info(L"Killed " + player->getName() + L".");
|
||||
return true;
|
||||
}
|
||||
|
||||
server->warn(L"Unknown command: " + command);
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
MinecraftServer::MinecraftServer()
|
||||
{
|
||||
// 4J - added initialisers
|
||||
@@ -105,6 +573,7 @@ MinecraftServer::MinecraftServer()
|
||||
playerIdleTimeout = 0;
|
||||
m_postUpdateThread = NULL;
|
||||
forceGameType = false;
|
||||
m_spawnProtectionRadius = 0;
|
||||
|
||||
commandDispatcher = new ServerCommandDispatcher();
|
||||
|
||||
@@ -149,6 +618,12 @@ bool MinecraftServer::initServer(__int64 seed, NetworkGameInitData *initData, DW
|
||||
logger.info("Loading properties");
|
||||
#endif
|
||||
settings = new Settings(new File(L"server.properties"));
|
||||
#ifdef MINECRAFT_SERVER_BUILD
|
||||
// Dedicated-only: spawn-protection radius in blocks; 0 disables protection.
|
||||
m_spawnProtectionRadius = GetDedicatedServerInt(settings, L"spawn-protection", 0);
|
||||
if (m_spawnProtectionRadius < 0) m_spawnProtectionRadius = 0;
|
||||
if (m_spawnProtectionRadius > 256) m_spawnProtectionRadius = 256;
|
||||
#endif
|
||||
|
||||
app.DebugPrintf("\n*** SERVER SETTINGS ***\n");
|
||||
app.DebugPrintf("ServerSettings: host-friends-only is %s\n",(app.GetGameHostOption(eGameHostOption_FriendsOfFriends)>0)?"on":"off");
|
||||
@@ -156,6 +631,7 @@ bool MinecraftServer::initServer(__int64 seed, NetworkGameInitData *initData, DW
|
||||
app.DebugPrintf("ServerSettings: pvp is %s\n",(app.GetGameHostOption(eGameHostOption_PvP)>0)?"on":"off");
|
||||
app.DebugPrintf("ServerSettings: fire spreads is %s\n",(app.GetGameHostOption(eGameHostOption_FireSpreads)>0)?"on":"off");
|
||||
app.DebugPrintf("ServerSettings: tnt explodes is %s\n",(app.GetGameHostOption(eGameHostOption_TNT)>0)?"on":"off");
|
||||
app.DebugPrintf("ServerSettings: spawn protection radius is %d\n", m_spawnProtectionRadius);
|
||||
app.DebugPrintf("\n");
|
||||
|
||||
// TODO 4J Stu - Init a load of settings based on data passed as params
|
||||
@@ -165,7 +641,7 @@ bool MinecraftServer::initServer(__int64 seed, NetworkGameInitData *initData, DW
|
||||
//localIp = settings->getString(L"server-ip", L"");
|
||||
//onlineMode = settings->getBoolean(L"online-mode", true);
|
||||
//motd = settings->getString(L"motd", L"A Minecraft Server");
|
||||
//motd.replace('§', '$');
|
||||
//motd.replace('§', '$');
|
||||
|
||||
setAnimals(settings->getBoolean(L"spawn-animals", true));
|
||||
setNpcsEnabled(settings->getBoolean(L"spawn-npcs", true));
|
||||
@@ -210,7 +686,7 @@ bool MinecraftServer::initServer(__int64 seed, NetworkGameInitData *initData, DW
|
||||
|
||||
// 4J-JEV: Need to wait for levelGenerationOptions to load.
|
||||
while ( app.getLevelGenerationOptions() != NULL && !app.getLevelGenerationOptions()->hasLoadedData() )
|
||||
Sleep(1);
|
||||
Sleep(0);
|
||||
|
||||
if ( app.getLevelGenerationOptions() != NULL && !app.getLevelGenerationOptions()->ready() )
|
||||
{
|
||||
@@ -319,7 +795,7 @@ int MinecraftServer::runPostUpdate(void* lpParam)
|
||||
{
|
||||
LeaveCriticalSection(&server->m_postProcessCS);
|
||||
}
|
||||
Sleep(1);
|
||||
Sleep(0);
|
||||
} while (!server->m_postUpdateTerminate && ShutdownManager::ShouldRun(ShutdownManager::ePostProcessThread));
|
||||
//#ifndef __PS3__
|
||||
// One final pass through updates to make sure we're done
|
||||
@@ -1175,7 +1651,13 @@ Level *MinecraftServer::getCommandSenderWorld()
|
||||
|
||||
int MinecraftServer::getSpawnProtectionRadius()
|
||||
{
|
||||
#ifdef MINECRAFT_SERVER_BUILD
|
||||
// Client-host mode must never apply dedicated-server spawn protection settings.
|
||||
if (!ShouldUseDedicatedServerProperties()) return 0;
|
||||
return m_spawnProtectionRadius;
|
||||
#else
|
||||
return 16;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool MinecraftServer::isUnderSpawnProtection(Level *level, int x, int y, int z, shared_ptr<Player> player)
|
||||
|
||||
@@ -40,6 +40,7 @@ typedef struct _NetworkGameInitData
|
||||
LevelGenerationOptions *levelGen;
|
||||
DWORD texturePackId;
|
||||
bool findSeed;
|
||||
bool dedicatedNoLocalHostPlayer;
|
||||
unsigned int xzSize;
|
||||
unsigned char hellScale;
|
||||
ESavePlatform savePlatform;
|
||||
@@ -52,6 +53,7 @@ typedef struct _NetworkGameInitData
|
||||
levelGen = NULL;
|
||||
texturePackId = 0;
|
||||
findSeed = false;
|
||||
dedicatedNoLocalHostPlayer = false;
|
||||
xzSize = LEVEL_LEGACY_WIDTH;
|
||||
hellScale = HELL_LEVEL_LEGACY_SCALE;
|
||||
savePlatform = SAVE_FILE_PLATFORM_LOCAL;
|
||||
@@ -113,6 +115,7 @@ public:
|
||||
int maxBuildHeight;
|
||||
int playerIdleTimeout;
|
||||
bool forceGameType;
|
||||
int m_spawnProtectionRadius;
|
||||
|
||||
private:
|
||||
// 4J Added
|
||||
@@ -236,7 +239,7 @@ public:
|
||||
static void SetTime(__int64 time) { setTimeAtEndOfTick = true; setTime = time; }
|
||||
|
||||
C4JThread::Event* m_serverPausedEvent;
|
||||
private:
|
||||
public:
|
||||
// 4J Added
|
||||
bool m_isServerPaused;
|
||||
|
||||
|
||||
@@ -85,6 +85,20 @@ bool MultiPlayerGameMode::destroyBlock(int x, int y, int z, int face)
|
||||
|
||||
if (oldTile == NULL) return false;
|
||||
|
||||
#if defined(_WINDOWS64) || defined(DISABLE_PSN) || defined(_DISABLE_XBLIVE)
|
||||
if (g_NetworkManager.IsHost())
|
||||
{
|
||||
level->levelEvent(LevelEvent::PARTICLES_DESTROY_BLOCK, x, y, z, oldTile->id + (level->getData(x, y, z) << Tile::TILE_NUM_SHIFT));
|
||||
int data = level->getData(x, y, z);
|
||||
bool changed = level->removeTile(x, y, z);
|
||||
if (changed)
|
||||
{
|
||||
oldTile->destroy(level, x, y, z, data);
|
||||
}
|
||||
return changed;
|
||||
}
|
||||
#endif
|
||||
|
||||
level->levelEvent(LevelEvent::PARTICLES_DESTROY_BLOCK, x, y, z, oldTile->id + (level->getData(x, y, z) << Tile::TILE_NUM_SHIFT));
|
||||
|
||||
int data = level->getData(x, y, z);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
base64.cpp and base64.h
|
||||
|
||||
Copyright (C) 2004-2008 René Nyffenegger
|
||||
Copyright (C) 2004-2008 René Nyffenegger
|
||||
|
||||
This source code is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the author be held liable for any damages
|
||||
@@ -21,7 +21,7 @@
|
||||
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
René Nyffenegger rene.nyffenegger@adp-gmbh.ch
|
||||
René Nyffenegger rene.nyffenegger@adp-gmbh.ch
|
||||
|
||||
*/
|
||||
|
||||
@@ -41,7 +41,7 @@ static inline bool is_base64(unsigned char c) {
|
||||
}
|
||||
|
||||
// 4J ADDED,
|
||||
std::string base64_encode(std::string str)
|
||||
std::string base64_encode(const std::string& str)
|
||||
{
|
||||
return base64_encode( reinterpret_cast<const unsigned char*>(str.c_str()), str.length() );
|
||||
}
|
||||
|
||||
@@ -2,6 +2,6 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
std::string base64_encode(std::string str);
|
||||
std::string base64_encode(const std::string& str);
|
||||
std::string base64_encode(unsigned char const* , unsigned int len);
|
||||
std::string base64_decode(std::string const& s);
|
||||
@@ -619,7 +619,6 @@ DWORD GetFileAttributesA(LPCSTR lpFileName)
|
||||
SceFiosStat statData;
|
||||
if(sceFiosStatSync(NULL, filePath, &statData) != SCE_FIOS_OK)
|
||||
{
|
||||
app.DebugPrintf("*** sceFiosStatSync Failed\n");
|
||||
return -1;
|
||||
}
|
||||
if(statData.statFlags & SCE_FIOS_STATUS_DIRECTORY )
|
||||
@@ -671,19 +670,25 @@ BOOL QueryPerformanceCounter(LARGE_INTEGER *lpPerformanceCount)
|
||||
|
||||
#ifndef _FINAL_BUILD
|
||||
|
||||
VOID OutputDebugStringW(LPCWSTR lpOutputString)
|
||||
{
|
||||
wprintf(lpOutputString);
|
||||
VOID OutputDebugStringW(LPCWSTR lpOutputString)
|
||||
{
|
||||
if (lpOutputString != NULL)
|
||||
wprintf(L"%ls", lpOutputString);
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
VOID OutputDebugStringA(LPCSTR lpOutputString)
|
||||
{
|
||||
printf(lpOutputString);
|
||||
VOID OutputDebugStringA(LPCSTR lpOutputString)
|
||||
{
|
||||
if (lpOutputString != NULL)
|
||||
printf("%s", lpOutputString);
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
VOID OutputDebugString(LPCSTR lpOutputString)
|
||||
{
|
||||
printf(lpOutputString);
|
||||
VOID OutputDebugString(LPCSTR lpOutputString)
|
||||
{
|
||||
if (lpOutputString != NULL)
|
||||
printf("%s", lpOutputString);
|
||||
fflush(stdout);
|
||||
}
|
||||
#endif // _CONTENT_PACKAGE
|
||||
|
||||
@@ -787,4 +792,4 @@ DWORD XGetLocale()
|
||||
DWORD XEnableGuestSignin(BOOL fEnable)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -525,7 +525,9 @@ void CConsoleMinecraftApp::CommerceTick()
|
||||
{
|
||||
SonyCommerce::ProductInfo *pProductInfo=&(pvProductList->at(j));
|
||||
// just want the final 16 characters of the product id
|
||||
#ifndef DISABLE_PSN
|
||||
RegisterDLCData(&pProductInfo->productId[20],0,pProductInfo->imageUrl);
|
||||
#endif
|
||||
}
|
||||
iter++;
|
||||
}
|
||||
@@ -1043,7 +1045,9 @@ void CConsoleMinecraftApp::SystemServiceTick()
|
||||
{
|
||||
case SCE_SYSTEM_SERVICE_EVENT_GAME_CUSTOM_DATA:
|
||||
{
|
||||
#ifndef DISABLE_PSN
|
||||
OrbisNPToolkit::getMessageData((SceNpGameCustomDataEventParam*)event.data.param);
|
||||
#endif
|
||||
// Processing after invitation
|
||||
//SceNpSessionInvitationEventParam* pInvite = (SceNpSessionInvitationEventParam*)event.data.param;
|
||||
//SQRNetworkManager_Orbis::GetInviteDataAndProcess(pInvite);
|
||||
|
||||
@@ -35,8 +35,12 @@
|
||||
#include "..\..\Minecraft.World\OldChunkStorage.h"
|
||||
#include "Leaderboards\OrbisLeaderboardManager.h"
|
||||
|
||||
#ifndef DISABLE_PSN
|
||||
#include "Network/Orbis_NPToolkit.h"
|
||||
#include "Orbis\Network\SonyVoiceChat_Orbis.h"
|
||||
#else
|
||||
#include "..\..\Minecraft.Client\Common\Network\NetworkSocketLayer.h"
|
||||
#endif
|
||||
|
||||
#define FIFTY_ONE_MB (1000000*51) // Maximum TCR space required for a save is 52MB (checking for this on a selected device)
|
||||
|
||||
@@ -57,6 +61,8 @@ DWORD dwProfileSettingsA[NUM_PROFILE_VALUES]=
|
||||
uint8_t * AddRichPresenceString(int iID);
|
||||
void FreeRichPresenceStrings();
|
||||
|
||||
char g_Win64Username[17] = {0};
|
||||
|
||||
BOOL g_bWidescreen = TRUE;
|
||||
|
||||
void DefineActions(void)
|
||||
@@ -369,7 +375,9 @@ void RegisterAwardsWithProfileManager()
|
||||
|
||||
// Rich Presence init - number of presences, number of contexts
|
||||
ProfileManager.RichPresenceInit(4,1);
|
||||
#ifndef DISABLE_PSN
|
||||
ProfileManager.SetRichPresenceSettingFn(SQRNetworkManager_Orbis::SetRichPresence);
|
||||
#endif
|
||||
char *pchRichPresenceString;
|
||||
|
||||
pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCE_GAMESTATE);
|
||||
@@ -533,7 +541,9 @@ int main(int argc, const char *argv[] )
|
||||
////////////////
|
||||
|
||||
app.InitTime();
|
||||
#ifndef DISABLE_PSN
|
||||
NPToolkit.init();
|
||||
#endif
|
||||
|
||||
// Set the number of possible joypad layouts that the user can switch between, and the number of actions
|
||||
InputManager.Initialise(1,5,MINECRAFT_ACTION_MAX, ACTION_MAX_MENU);
|
||||
@@ -559,6 +569,9 @@ int main(int argc, const char *argv[] )
|
||||
app.GAME_DEFINED_PROFILE_DATA_BYTES*XUSER_MAX_COUNT,
|
||||
&app.uiGameDefinedDataChangedBitmask);
|
||||
|
||||
strncpy(g_Win64Username, ProfileManager.GetGamertag(0), 17);
|
||||
g_Win64Username[16] = 0;
|
||||
|
||||
// register the awards
|
||||
RegisterAwardsWithProfileManager();
|
||||
|
||||
@@ -621,6 +634,7 @@ int main(int argc, const char *argv[] )
|
||||
// ProfileManager for XN_LIVE_INVITE_ACCEPTED for QNet.
|
||||
|
||||
g_NetworkManager.Initialise();
|
||||
NetworkSocketLayer::Initialize();
|
||||
|
||||
// debug switch to trial version
|
||||
ProfileManager.SetDebugFullOverride(true);
|
||||
@@ -681,7 +695,9 @@ int main(int argc, const char *argv[] )
|
||||
|
||||
while (TRUE)
|
||||
{
|
||||
#ifndef DISABLE_PSN
|
||||
SonyVoiceChat_Orbis::tick();
|
||||
#endif
|
||||
RenderManager.StartFrame();
|
||||
|
||||
app.UpdateTime();
|
||||
|
||||
@@ -74,12 +74,10 @@ PlayerUID::PlayerUID(wstring fromString)
|
||||
wstring onlineID = fromString.substr(15 + userIdLen + 1);
|
||||
if(onlineID.size() > 0)
|
||||
{
|
||||
wcstombs(m_onlineID, onlineID.c_str(), 16);
|
||||
m_bSignedIntoPSN = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_onlineID[0] = 0;
|
||||
m_bSignedIntoPSN = false;
|
||||
}
|
||||
}
|
||||
@@ -87,13 +85,8 @@ PlayerUID::PlayerUID(wstring fromString)
|
||||
|
||||
bool PlayerUID::operator==(const PlayerUID& rhs) const
|
||||
{
|
||||
// comparing online IDs
|
||||
if(isSignedIntoPSN() && rhs.isSignedIntoPSN())
|
||||
{
|
||||
return (strcmp(m_onlineID, rhs.m_onlineID) == 0);
|
||||
}
|
||||
// comparing offline IDs
|
||||
if(m_userID != rhs.m_userID)
|
||||
if(XUID != rhs.XUID)
|
||||
return false;
|
||||
for(int i=0; i<SCE_NET_ETHER_ADDR_LEN;i++)
|
||||
if(m_macAddress[i] != rhs.m_macAddress[i])return false;
|
||||
@@ -147,13 +140,13 @@ std::wstring PlayerUID::toString() const
|
||||
sprintf(macAddr, "%02x%02x%02x%02x%02x%02x", m[0],m[1],m[2],m[3],m[4],m[5]);
|
||||
sprintf(finalString, "%s_%s_%08d_%s", isPrimaryUser() ? "P" : "N",
|
||||
macAddr, m_userID,
|
||||
isSignedIntoPSN() ? m_onlineID : "");
|
||||
"");
|
||||
mbstowcs(finalStringW, finalString, 64);
|
||||
return std::wstring(finalStringW);
|
||||
}
|
||||
void PlayerUID::setOnlineID(SceNpOnlineId& id, bool bSignedIntoPSN)
|
||||
{
|
||||
memcpy(m_onlineID, id.data, SCE_NP_ONLINEID_MAX_LENGTH);
|
||||
//memcpy(m_onlineID, id.data, SCE_NP_ONLINEID_MAX_LENGTH);
|
||||
term = id.term;
|
||||
m_bSignedIntoPSN = bSignedIntoPSN;
|
||||
}
|
||||
@@ -180,7 +173,7 @@ bool PlayerUID::isPrimaryUser() const /* only true if we're on the local machine
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef DISABLE_PSN
|
||||
GameSessionUID::GameSessionUID()
|
||||
{
|
||||
memset(this,0,sizeof(GameSessionUID));
|
||||
@@ -214,4 +207,4 @@ GameSessionUID& GameSessionUID::operator=(const PlayerUID& rhs)
|
||||
m_bSignedIntoPSN = rhs.isSignedIntoPSN();
|
||||
return *this;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -9,17 +9,19 @@
|
||||
// (2) An offline ID, where there is also a primary login on the system. This has m_onlineID set up to copy the primary SceNpOnlineId, except with dummy[0] set to the controller ID of this other player
|
||||
// (3) An offline ID, where there isn't a primary PSN login on the system. This has SceNpOnlineId fully zeroed.
|
||||
|
||||
|
||||
#pragma pack(push, 4)
|
||||
class PlayerUID
|
||||
{
|
||||
char m_onlineID[SCE_NP_ONLINEID_MAX_LENGTH];
|
||||
// PS4 4JLibs needs exactly 28 bytes for playerUID,
|
||||
//char m_onlineID[SCE_NP_ONLINEID_MAX_LENGTH];
|
||||
char term;
|
||||
bool m_bSignedIntoPSN : 1;
|
||||
unsigned char m_quadrant : 2;
|
||||
uint8_t m_macAddress[SCE_NET_ETHER_ADDR_LEN];
|
||||
SceUserServiceUserId m_userID;
|
||||
|
||||
char m_padding[8];
|
||||
public:
|
||||
ULONGLONG XUID;
|
||||
|
||||
class Hash
|
||||
{
|
||||
@@ -30,6 +32,8 @@ public:
|
||||
PlayerUID();
|
||||
PlayerUID(SceUserServiceUserId userID, SceNpOnlineId& onlineID, bool bSignedInPSN, int quadrant);
|
||||
PlayerUID(std::wstring fromString);
|
||||
PlayerUID(ULONGLONG xuid) { XUID = xuid; }
|
||||
operator ULONGLONG() const { return XUID; }
|
||||
|
||||
bool operator==(const PlayerUID& rhs) const;
|
||||
bool operator!=(const PlayerUID& rhs);
|
||||
@@ -40,8 +44,7 @@ public:
|
||||
void setOnlineID(SceNpOnlineId& id, bool bSignedIntoPSN);
|
||||
void setUserID(unsigned int id);
|
||||
|
||||
|
||||
const char* getOnlineID() const { return m_onlineID; }
|
||||
const char* getOnlineID() const { return ""; }
|
||||
SceUserServiceUserId getUserID() const { return m_userID; }
|
||||
int getQuadrant() const { return m_quadrant; }
|
||||
bool isPrimaryUser() const; // only true if we're on the local machine and signed into the first quadrant;
|
||||
@@ -61,10 +64,10 @@ namespace std
|
||||
}
|
||||
};
|
||||
}
|
||||
#pragma pack(pop)
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef DISABLE_PSN
|
||||
class GameSessionUID
|
||||
{
|
||||
char m_onlineID[SCE_NP_ONLINEID_MAX_LENGTH];
|
||||
@@ -83,3 +86,4 @@ public:
|
||||
int getQuadrant() const { return m_quadrant; }
|
||||
bool isSignedIntoPSN() const { return m_bSignedIntoPSN; }
|
||||
};
|
||||
#endif
|
||||
@@ -53,16 +53,16 @@ HRESULT PS3LeaderboardManager::destroyTransactionContext(int transactionContext)
|
||||
return sceNpScoreDestroyTransactionCtx(transactionContext);
|
||||
}
|
||||
|
||||
HRESULT PS3LeaderboardManager::getFriendsList(const SceNpId &myNpId, SceNpId* &npIds, uint32_t &len)
|
||||
{
|
||||
EFilterMode filterMode = m_eFilterMode;
|
||||
m_eFilterMode = eFM_Friends;
|
||||
|
||||
HRESULT ret = fillByIdsQuery(myNpId, npIds, len);
|
||||
|
||||
m_eFilterMode = filterMode;
|
||||
|
||||
return ret;
|
||||
HRESULT PS3LeaderboardManager::getFriendsList(const SceNpId &myNpId, SceNpId* &npIds, uint32_t &len)
|
||||
{
|
||||
EFilterMode filterMode = m_eFilterMode;
|
||||
m_eFilterMode = eFM_Friends;
|
||||
|
||||
HRESULT ret = fillByIdsQuery(myNpId, npIds, len);
|
||||
|
||||
m_eFilterMode = filterMode;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
char *PS3LeaderboardManager::getComment(SceNpScoreComment *comment)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
base64.cpp and base64.h
|
||||
|
||||
Copyright (C) 2004-2008 René Nyffenegger
|
||||
Copyright (C) 2004-2008 René Nyffenegger
|
||||
|
||||
This source code is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the author be held liable for any damages
|
||||
@@ -21,7 +21,7 @@
|
||||
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
René Nyffenegger rene.nyffenegger@adp-gmbh.ch
|
||||
René Nyffenegger rene.nyffenegger@adp-gmbh.ch
|
||||
|
||||
*/
|
||||
|
||||
@@ -41,7 +41,7 @@ static inline bool is_base64(unsigned char c) {
|
||||
}
|
||||
|
||||
// 4J ADDED,
|
||||
std::string base64_encode(std::string str)
|
||||
std::string base64_encode(const std::string& str)
|
||||
{
|
||||
return base64_encode( reinterpret_cast<const unsigned char*>(str.c_str()), str.length() );
|
||||
}
|
||||
|
||||
@@ -2,6 +2,6 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
std::string base64_encode(std::string str);
|
||||
std::string base64_encode(const std::string& str);
|
||||
std::string base64_encode(unsigned char const* , unsigned int len);
|
||||
std::string base64_decode(std::string const& s);
|
||||
@@ -1,4 +1,6 @@
|
||||
#include "stdafx.h"
|
||||
|
||||
#ifndef DISABLE_PSN
|
||||
#include "SQRNetworkManager_PS3.h"
|
||||
#include "Common/Network/Sony/SQRNetworkPlayer.h"
|
||||
#ifdef __PS3__
|
||||
@@ -3621,4 +3623,5 @@ int SQRNetworkManager_PS3::GetJoiningReadyPercentage()
|
||||
{
|
||||
return 100;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1,5 +1,13 @@
|
||||
#include "stdafx.h"
|
||||
|
||||
#ifdef DISABLE_PSN
|
||||
// global func, so we can call from the profile lib
|
||||
void SonyCommerce_UpgradeTrial()
|
||||
{
|
||||
// we're now calling the app function here, which manages pending requests
|
||||
app.UpgradeTrial();
|
||||
}
|
||||
#else
|
||||
#include "SonyCommerce_PS3.h"
|
||||
#include "..\PS3Extras\ShutdownManager.h"
|
||||
#include <sys/event.h>
|
||||
@@ -1511,3 +1519,4 @@ void SonyCommerce_PS3::DownloadAlreadyPurchased( CallbackFunc cb, LPVOID lpParam
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "stdafx.h"
|
||||
|
||||
#ifndef DISABLE_PSN
|
||||
|
||||
|
||||
|
||||
@@ -762,3 +762,4 @@ void SonyVoiceChat::setState( EAVCState state )
|
||||
sm_state = state;
|
||||
printStateAndEvent();
|
||||
}
|
||||
#endif
|
||||
@@ -1,5 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#ifndef _DISABLE_PSN
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@@ -154,4 +154,5 @@ private:
|
||||
static void printStateAndEvent();
|
||||
|
||||
|
||||
};
|
||||
};
|
||||
#endif
|
||||
@@ -10,7 +10,9 @@
|
||||
#include "..\..\Minecraft.World\LevelSettings.h"
|
||||
#include "..\..\Minecraft.World\BiomeSource.h"
|
||||
#include "..\..\Minecraft.World\LevelType.h"
|
||||
#ifndef DISABLE_PSN
|
||||
#include "..\..\PS3\Network\SonyCommerce_PS3.h"
|
||||
#endif
|
||||
#include "..\..\Minecraft.World\StringHelpers.h"
|
||||
#include "PS3Extras\ShutdownManager.h"
|
||||
#include "PS3\Network\SonyRemoteStorage_PS3.h"
|
||||
@@ -539,6 +541,7 @@ void CConsoleMinecraftApp::TemporaryCreateGameStart()
|
||||
|
||||
void CConsoleMinecraftApp::CommerceInit()
|
||||
{
|
||||
#ifndef DISABLE_PSN
|
||||
m_bCommerceCategoriesRetrieved=false;
|
||||
m_bCommerceProductListRetrieved=false;
|
||||
m_bCommerceInitialised=false;
|
||||
@@ -551,10 +554,12 @@ void CConsoleMinecraftApp::CommerceInit()
|
||||
m_iCurrentCategory=0;
|
||||
m_iCurrentProduct=0;
|
||||
memset(m_pchSkuID,0,48);
|
||||
#endif
|
||||
}
|
||||
|
||||
void CConsoleMinecraftApp::CommerceTick()
|
||||
{
|
||||
#ifndef DISABLE_PSN
|
||||
// only tick this if the primary user is signed in to the PSN
|
||||
if(ProfileManager.IsSignedInLive(0))
|
||||
{
|
||||
@@ -674,6 +679,7 @@ void CConsoleMinecraftApp::CommerceTick()
|
||||
}
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
// was the primary player signed in and is now signed out?
|
||||
if(m_eCommerce_State!=eCommerce_State_Offline)
|
||||
|
||||
@@ -22,6 +22,7 @@ SYS_PROCESS_PARAM(1001, 0x10000); // thread priority, and stack size
|
||||
#include <sysutil/sysutil_msgdialog.h>
|
||||
|
||||
#include "PS3/Network/SonyRemoteStorage_PS3.h"
|
||||
#include "..\..\Minecraft.Client\Common\Network\NetworkSocketLayer.h"
|
||||
|
||||
// define to use spurs (otherwise SPU threads or raw will be used)
|
||||
#define USE_SPURS
|
||||
@@ -33,6 +34,9 @@ SYS_PROCESS_PARAM(1001, 0x10000); // thread priority, and stack size
|
||||
#include <sys/spu_image.h>
|
||||
#endif
|
||||
|
||||
#ifdef DISABLE_PSN
|
||||
#include "../Passphrase/ps3__np_conf.h"
|
||||
#endif
|
||||
/* Encrypted ID for protected data file (*) You must edit these binaries!! */
|
||||
char secureFileId[CELL_SAVEDATA_SECUREFILEID_SIZE] =
|
||||
{
|
||||
@@ -135,6 +139,8 @@ extern "C" void* __wrap__malloc_init(size_t a_Boundary, size_t a_Size)
|
||||
// for a long time.
|
||||
//-------------------------------------------------------------------------------------
|
||||
|
||||
char g_Win64Username[17] = {0};
|
||||
|
||||
BOOL g_bWidescreen = TRUE;
|
||||
//int g_numberOfSpeakersForMiles = 2; // number of speakers to pass to Miles, this is setup from init_audio_hardware
|
||||
|
||||
@@ -449,7 +455,9 @@ void RegisterAwardsWithProfileManager()
|
||||
// Rich Presence init - number of presences, number of contexts
|
||||
//printf("Rich presence strings are hard coded on PS3 for now, must change this!\n");
|
||||
ProfileManager.RichPresenceInit(-1,-1); // 4J-JEV - Presence and Context count not used.
|
||||
#ifndef DISABLE_PSN
|
||||
ProfileManager.SetRichPresenceSettingFn(SQRNetworkManager_PS3::SetRichPresence);
|
||||
#endif
|
||||
char *pchRichPresenceString;
|
||||
|
||||
pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCE_GAMESTATE);
|
||||
@@ -785,7 +793,9 @@ int main()
|
||||
|
||||
app.CommerceInit(); // MGH - moved this here so GetCommerce isn't NULL
|
||||
// 4J-PB - Kick of the check for trial or full version - requires ui to be initialised
|
||||
#ifndef DISABLE_PSN
|
||||
app.GetCommerce()->CheckForTrialUpgradeKey();
|
||||
#endif
|
||||
|
||||
static bool bTrialTimerDisplayed=true;
|
||||
|
||||
@@ -797,8 +807,13 @@ int main()
|
||||
app.InitTime();
|
||||
|
||||
// Initialise the profile manager with the game Title ID, Offer ID, a profile version number, and the number of profile values and settings
|
||||
#ifndef DISABLE_PSN
|
||||
ProfileManager.Initialise(SQRNetworkManager_PS3::GetSceNpCommsId(),
|
||||
SQRNetworkManager_PS3::GetSceNpCommsSig(),
|
||||
#else
|
||||
ProfileManager.Initialise(&s_npCommunicationId,
|
||||
&s_npCommunicationSignature,
|
||||
#endif
|
||||
PROFILE_VERSION_10,
|
||||
NUM_PROFILE_VALUES,
|
||||
NUM_PROFILE_SETTINGS,
|
||||
@@ -806,6 +821,9 @@ int main()
|
||||
app.GAME_DEFINED_PROFILE_DATA_BYTES*XUSER_MAX_COUNT,
|
||||
&app.uiGameDefinedDataChangedBitmask);
|
||||
|
||||
strncpy(g_Win64Username, ProfileManager.GetGamertag(0), 17);
|
||||
g_Win64Username[16] = 0;
|
||||
|
||||
app.DebugPrintf("+++Main - after ProfileManager.Initialise\n");
|
||||
|
||||
// register the awards
|
||||
@@ -976,6 +994,7 @@ int main()
|
||||
if(ShutdownManager::ShouldRun(ShutdownManager::eMainThread))
|
||||
{
|
||||
g_NetworkManager.Initialise();
|
||||
NetworkSocketLayer::Initialize();
|
||||
g_NetworkManager.SetLocalGame(true);
|
||||
}
|
||||
|
||||
@@ -1012,6 +1031,13 @@ int main()
|
||||
|
||||
while( ShutdownManager::ShouldRun(ShutdownManager::eMainThread) )
|
||||
{
|
||||
// PIEBOT: This previously was under SQRNetworkManager_PS3::Tick()
|
||||
// It ticks all callbacks for SysUtil, including the ones used in INP_OnScreenKeyboard.cpp
|
||||
// When we nuked SQRNetworkManager_PS3, We also unintentionally broke the on-screen keyboard.
|
||||
|
||||
// TO-DO: put it under app.Tick();
|
||||
cellSysutilCheckCallback();
|
||||
|
||||
app.UpdateTime();
|
||||
PIXBeginNamedEvent(0,"Input manager tick");
|
||||
InputManager.Tick();
|
||||
|
||||
@@ -160,7 +160,7 @@ bool PlayerUID::isPrimaryUser() const /* only true if we're on the local machine
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef DISABLE_PSN
|
||||
GameSessionUID::GameSessionUID()
|
||||
{
|
||||
memset(this,0,sizeof(GameSessionUID));
|
||||
@@ -194,4 +194,4 @@ GameSessionUID& GameSessionUID::operator=(const PlayerUID& rhs)
|
||||
m_bSignedIntoPSN = rhs.isSignedIntoPSN();
|
||||
return *this;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
|
||||
#pragma once
|
||||
//#include "stdafx.h"
|
||||
|
||||
|
||||
// Note - there are now 3 types of PlayerUID
|
||||
@@ -19,6 +20,7 @@ class PlayerUID
|
||||
CellSysutilUserId m_userID; // user logged on to the XMB
|
||||
|
||||
public:
|
||||
ULONGLONG XUID;
|
||||
|
||||
class Hash
|
||||
{
|
||||
@@ -29,6 +31,8 @@ public:
|
||||
PlayerUID();
|
||||
PlayerUID(CellSysutilUserId userID, SceNpOnlineId& onlineID, bool bSignedInPSN, int quadrant);
|
||||
PlayerUID(std::wstring fromString);
|
||||
PlayerUID(ULONGLONG xuid) { XUID = xuid; }
|
||||
operator ULONGLONG() const { return XUID; }
|
||||
|
||||
bool operator==(const PlayerUID& rhs) const;
|
||||
bool operator!=(const PlayerUID& rhs);
|
||||
@@ -51,7 +55,7 @@ private:
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef DISABLE_PSN
|
||||
class GameSessionUID
|
||||
{
|
||||
char m_onlineID[SCE_NET_NP_ONLINEID_MAX_LENGTH];
|
||||
@@ -70,3 +74,5 @@ public:
|
||||
int getQuadrant() const { return m_quadrant; }
|
||||
bool isSignedIntoPSN() const { return m_bSignedIntoPSN; }
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ class PlayerUID
|
||||
int m_userID; // user logged on to the XMB
|
||||
|
||||
public:
|
||||
ULONGLONG XUID;
|
||||
|
||||
class Hash
|
||||
{
|
||||
@@ -34,6 +35,8 @@ public:
|
||||
PlayerUID();
|
||||
PlayerUID(int userID, SceNpOnlineId& onlineID, bool bSignedInPSN, int quadrant);
|
||||
PlayerUID(std::wstring fromString);
|
||||
PlayerUID(ULONGLONG xuid) { XUID = xuid; }
|
||||
operator ULONGLONG() const { return XUID; }
|
||||
|
||||
bool operator==(const PlayerUID& rhs) const;
|
||||
bool operator!=(const PlayerUID& rhs);
|
||||
@@ -56,6 +59,7 @@ private:
|
||||
|
||||
typedef PlayerUID *PPlayerUID;
|
||||
|
||||
#ifndef DISABLE_PSN
|
||||
class GameSessionUID
|
||||
{
|
||||
char m_onlineID[SCE_NP_ONLINEID_MAX_LENGTH];
|
||||
@@ -76,6 +80,7 @@ public:
|
||||
void setForAdhoc();
|
||||
|
||||
};
|
||||
#endif
|
||||
|
||||
enum eAwardType
|
||||
{
|
||||
|
||||
@@ -46,4 +46,4 @@ 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)
|
||||
#define SCE_APPUTIL_APPEVENT_TYPE_NP_BASIC_JOINABLE_PRESENCE (3)
|
||||
|
||||
@@ -14,13 +14,18 @@
|
||||
#include "PSVita\Network\SonyRemoteStorage_Vita.h"
|
||||
#include "PSVita\Network\SonyCommerce_Vita.h"
|
||||
#include "..\..\Common\Network\Sony\SonyRemoteStorage.h"
|
||||
#include "PSVita/Network/PSVita_NPToolkit.h"
|
||||
#include <message_dialog.h>
|
||||
#include <savedata_dialog.h>
|
||||
#include "Common\UI\UI.h"
|
||||
#include "PSVita\PSVitaExtras\PSVitaStrings.h"
|
||||
|
||||
#ifndef DISABLE_PSN
|
||||
#include "PSVita/Network/PSVita_NPToolkit.h"
|
||||
#endif
|
||||
|
||||
#ifndef DISABLE_PSN
|
||||
#define VITA_COMMERCE_ENABLED
|
||||
#endif
|
||||
CConsoleMinecraftApp app;
|
||||
|
||||
CConsoleMinecraftApp::CConsoleMinecraftApp() : CMinecraftApp()
|
||||
@@ -41,6 +46,7 @@ CConsoleMinecraftApp::CConsoleMinecraftApp() : CMinecraftApp()
|
||||
|
||||
m_pSaveToDelete = NULL;
|
||||
m_pCheckoutProductInfo = NULL;
|
||||
m_pCommerce = NULL;
|
||||
}
|
||||
|
||||
void CConsoleMinecraftApp::SetRichPresenceContext(int iPad, int contextId)
|
||||
@@ -1000,6 +1006,7 @@ void CConsoleMinecraftApp::AppEventTick()
|
||||
res = sceAppUtilReceiveAppEvent(&eventParam);
|
||||
if (res == SCE_OK)
|
||||
{
|
||||
#ifndef DISABLE_PSN
|
||||
if (SCE_APPUTIL_APPEVENT_TYPE_NP_APP_DATA_MESSAGE == eventParam.type)
|
||||
{
|
||||
PSVitaNPToolkit::getMessageData(&eventParam);
|
||||
@@ -1014,6 +1021,7 @@ void CConsoleMinecraftApp::AppEventTick()
|
||||
app.DebugPrintf("unknown app event : 0x%08x\n", eventParam.type);
|
||||
assert(0);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1052,6 +1060,7 @@ void CConsoleMinecraftApp::AppEventTick()
|
||||
|
||||
bool CConsoleMinecraftApp::CheckForEmptyStore(int iPad)
|
||||
{
|
||||
#ifdef VITA_COMMERCE_ENABLED
|
||||
SonyCommerce::CategoryInfo *pCategories=app.GetCategoryInfo();
|
||||
|
||||
bool bEmptyStore=true;
|
||||
@@ -1081,6 +1090,9 @@ bool CConsoleMinecraftApp::CheckForEmptyStore(int iPad)
|
||||
}
|
||||
|
||||
return bEmptyStore;
|
||||
#else
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -3,7 +3,12 @@
|
||||
|
||||
#include "stdafx.h"
|
||||
|
||||
#ifndef DISABLE_PSN
|
||||
#include "Leaderboards\PSVitaLeaderboardManager.h"
|
||||
#include "Common\Network\Sony\SQRNetworkManager.h"
|
||||
#include "PSVita/Network/PSVita_NPToolkit.h"
|
||||
#include "PSVita\Network\SonyVoiceChat_Vita.h"
|
||||
#endif
|
||||
#include "PSVita\PSVitaExtras\ShutdownManager.h"
|
||||
|
||||
#include "PSVita_App.h"
|
||||
@@ -37,12 +42,10 @@
|
||||
#include "..\..\Minecraft.World\compression.h"
|
||||
#include "..\..\Minecraft.World\OldChunkStorage.h"
|
||||
#include "..\..\Minecraft.World\C4JThread.h"
|
||||
#include "Common\Network\Sony\SQRNetworkManager.h"
|
||||
#include "Common\UI\IUIScene_PauseMenu.h"
|
||||
#include "Conf.h"
|
||||
#include "PSVita/Network/PSVita_NPToolkit.h"
|
||||
#include "PSVita\Network\SonyVoiceChat_Vita.h"
|
||||
#include "..\..\Minecraft.World\FireworksRecipe.h"
|
||||
#include "..\..\Minecraft.Client\Common\Network\NetworkSocketLayer.h"
|
||||
|
||||
#include <libsysmodule.h>
|
||||
#include <libperf.h>
|
||||
@@ -68,6 +71,8 @@ void FreeRichPresenceStrings();
|
||||
// for a long time.
|
||||
//-------------------------------------------------------------------------------------
|
||||
|
||||
char g_Win64Username[17] = {0};
|
||||
|
||||
BOOL g_bWidescreen = TRUE;
|
||||
//int g_numberOfSpeakersForMiles = 2; // number of speakers to pass to Miles, this is setup from init_audio_hardware
|
||||
|
||||
@@ -304,7 +309,9 @@ void RegisterAwardsWithProfileManager()
|
||||
ProfileManager.RichPresenceInit(4,1);
|
||||
|
||||
//Chris TODO
|
||||
#ifndef DISABLE_PSN
|
||||
ProfileManager.SetRichPresenceSettingFn(SQRNetworkManager_Vita::SetRichPresence);
|
||||
#endif
|
||||
char *pchRichPresenceString;
|
||||
|
||||
pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCE_GAMESTATE);
|
||||
@@ -445,7 +452,9 @@ int main()
|
||||
}
|
||||
|
||||
app.InitTime();
|
||||
#ifndef DISABLE_PSN
|
||||
PSVitaNPToolkit::init();
|
||||
#endif
|
||||
|
||||
// initialise the storage manager with a default save display name, a Minimum save size, and a callback for displaying the saving message
|
||||
StorageManager.Init( 0, L"savegame.dat", "savePackName", FIFTY_ONE_MB, &CConsoleMinecraftApp::DisplaySavingMessage, (LPVOID)&app, NULL);
|
||||
@@ -522,6 +531,8 @@ int main()
|
||||
app.GAME_DEFINED_PROFILE_DATA_BYTES*XUSER_MAX_COUNT,
|
||||
&app.uiGameDefinedDataChangedBitmask);
|
||||
|
||||
strncpy(g_Win64Username, ProfileManager.GetGamertag(0), 17);
|
||||
g_Win64Username[16] = 0;
|
||||
|
||||
// register the awards
|
||||
RegisterAwardsWithProfileManager();
|
||||
@@ -572,11 +583,20 @@ int main()
|
||||
app.CommerceInit(); // MGH - moved this here so GetCommerce isn't NULL
|
||||
|
||||
// 4J-PB - Kick of the check for trial or full version - requires ui to be initialised
|
||||
#ifndef DISABLE_PSN
|
||||
app.GetCommerce()->CheckForTrialUpgradeKey();
|
||||
#endif
|
||||
|
||||
// debug switch to trial version
|
||||
//ProfileManager.SetDebugFullOverride(false);
|
||||
|
||||
#ifdef DISABLE_PSN
|
||||
// Set full mode. on DISABLE_PSN we cannot check if its trial or not.
|
||||
ProfileManager.SetFullVersion(true);
|
||||
ProfileManager.SetDebugFullOverride(true);
|
||||
StorageManager.SetSaveDisabled(false);
|
||||
#endif
|
||||
|
||||
//ProfileManager.AddDLC(2);
|
||||
StorageManager.SetDLCPackageRoot("DLCDrive");
|
||||
|
||||
@@ -641,6 +661,7 @@ int main()
|
||||
// XN_SYS_SIGNINCHANGED notifications. This does mean that we need to have a callback in the
|
||||
// ProfileManager for XN_LIVE_INVITE_ACCEPTED for QNet.
|
||||
g_NetworkManager.Initialise();
|
||||
NetworkSocketLayer::Initialize();
|
||||
g_NetworkManager.SetLocalGame(true);
|
||||
|
||||
// Set the default sound levels
|
||||
@@ -659,8 +680,9 @@ int main()
|
||||
|
||||
while( true )
|
||||
{
|
||||
#ifndef DISABLE_PSN
|
||||
SonyVoiceChat_Vita::tick();
|
||||
|
||||
#endif
|
||||
RenderManager.StartFrame();
|
||||
|
||||
// static bool bPlay=false;
|
||||
@@ -700,7 +722,9 @@ int main()
|
||||
g_NetworkManager.DoWork();
|
||||
PIXEndNamedEvent();
|
||||
|
||||
#ifndef DISABLE_PSN
|
||||
LeaderboardManager::Instance()->Tick();
|
||||
#endif
|
||||
// Render game graphics.
|
||||
if(app.GetGameStarted())
|
||||
{
|
||||
|
||||
Binary file not shown.
@@ -14,12 +14,37 @@
|
||||
#include "..\Minecraft.World\net.minecraft.world.item.h"
|
||||
#include "..\Minecraft.World\SharedConstants.h"
|
||||
#include "Settings.h"
|
||||
|
||||
#if defined(_WINDOWS64) && defined(MINECRAFT_SERVER_BUILD)
|
||||
#include "../Minecraft.Server/ServerLogManager.h"
|
||||
#include "../Minecraft.Server/Access/Access.h"
|
||||
#include "../Minecraft.World/Socket.h"
|
||||
#include <Common/Network/NetworkSocketLayer.h>
|
||||
#endif
|
||||
// #ifdef __PS3__
|
||||
// #include "PS3\Network\NetworkPlayerSony.h"
|
||||
// #endif
|
||||
|
||||
Random *PendingConnection::random = new Random();
|
||||
|
||||
#if defined(_WINDOWS64) && defined(MINECRAFT_SERVER_BUILD)
|
||||
namespace
|
||||
{
|
||||
static unsigned char GetPendingConnectionSmallId(Connection *connection)
|
||||
{
|
||||
if (connection != nullptr)
|
||||
{
|
||||
Socket *socket = connection->getSocket();
|
||||
if (socket != nullptr)
|
||||
{
|
||||
return socket->getSmallId();
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
PendingConnection::PendingConnection(MinecraftServer *server, Socket *socket, const wstring& id)
|
||||
{
|
||||
// 4J - added initialisers
|
||||
@@ -157,18 +182,155 @@ void PendingConnection::handleLogin(shared_ptr<LoginPacket> packet)
|
||||
|
||||
//if (true)// 4J removed !server->onlineMode)
|
||||
bool sentDisconnect = false;
|
||||
bool nameTaken = false;
|
||||
|
||||
#if defined(_WINDOWS64) && defined(MINECRAFT_SERVER_BUILD)
|
||||
{
|
||||
std::string connectionIp = "";
|
||||
int connectionPort = 0;
|
||||
|
||||
if (!connection || !connection->getSocket()) {
|
||||
disconnect(DisconnectPacket::eDisconnect_EndOfStream);
|
||||
return;
|
||||
}
|
||||
|
||||
unsigned char smallId = connection->getSocket()->getSmallId();
|
||||
if (smallId == 0) {
|
||||
disconnect(DisconnectPacket::eDisconnect_EndOfStream);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!ServerRuntime::ServerLogManager::TryGetConnectionRemoteIp(smallId, &connectionIp))
|
||||
{
|
||||
SOCKET sock = NetworkSocketLayer::GetSocketForSmallId(smallId);
|
||||
if (sock != INVALID_SOCKET)
|
||||
{
|
||||
sockaddr_in addr;
|
||||
int addrLen = sizeof(addr);
|
||||
if (getpeername(sock, (sockaddr*)&addr, &addrLen) == 0)
|
||||
{
|
||||
char ipBuf[64] = {};
|
||||
if (inet_ntop(AF_INET, &addr.sin_addr, ipBuf, sizeof(ipBuf)))
|
||||
{
|
||||
connectionIp = ipBuf;
|
||||
connectionPort = (int)ntohs(addr.sin_port);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (connectionIp.empty()) {
|
||||
disconnect(DisconnectPacket::eDisconnect_EndOfStream);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else {
|
||||
SOCKET sock = NetworkSocketLayer::GetSocketForSmallId(smallId);
|
||||
if (sock != INVALID_SOCKET)
|
||||
{
|
||||
sockaddr_in addr;
|
||||
int addrLen = sizeof(addr);
|
||||
if (getpeername(sock, (sockaddr*)&addr, &addrLen) == 0)
|
||||
connectionPort = (int)ntohs(addr.sin_port);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// Use the same Xuid choice as handleAcceptedLogin (offline first, online fallback).
|
||||
PlayerUID loginXuid = packet->m_offlineXuid;
|
||||
if (loginXuid == INVALID_XUID) loginXuid = packet->m_onlineXuid;
|
||||
|
||||
bool duplicateXuid = false;
|
||||
if (loginXuid != INVALID_XUID && server->getPlayers()->getPlayer(loginXuid) != NULL)
|
||||
{
|
||||
duplicateXuid = true;
|
||||
}
|
||||
else if (packet->m_onlineXuid != INVALID_XUID &&
|
||||
packet->m_onlineXuid != loginXuid &&
|
||||
server->getPlayers()->getPlayer(packet->m_onlineXuid) != NULL)
|
||||
{
|
||||
duplicateXuid = true;
|
||||
}
|
||||
|
||||
bool bannedXuid = false;
|
||||
if (packet->m_offlineXuid != INVALID_XUID)
|
||||
{
|
||||
bannedXuid = server->getPlayers()->isXuidBanned(packet->m_offlineXuid);
|
||||
}
|
||||
if (!bannedXuid && packet->m_onlineXuid != INVALID_XUID && packet->m_onlineXuid != packet->m_offlineXuid)
|
||||
{
|
||||
bannedXuid = server->getPlayers()->isXuidBanned(packet->m_onlineXuid);
|
||||
}
|
||||
|
||||
bool whitelistSatisfied = true;
|
||||
#if defined(_WINDOWS64) && defined(MINECRAFT_SERVER_BUILD)
|
||||
if (ServerRuntime::Access::IsWhitelistEnabled())
|
||||
{
|
||||
whitelistSatisfied = false;
|
||||
if (loginXuid != INVALID_XUID)
|
||||
{
|
||||
whitelistSatisfied = ServerRuntime::Access::IsPlayerWhitelisted(loginXuid);
|
||||
}
|
||||
if (!whitelistSatisfied && packet->m_onlineXuid != INVALID_XUID && packet->m_onlineXuid != loginXuid)
|
||||
{
|
||||
whitelistSatisfied = ServerRuntime::Access::IsPlayerWhitelisted(packet->m_onlineXuid);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if( sentDisconnect )
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
else if( server->getPlayers()->isXuidBanned( packet->m_onlineXuid ) )
|
||||
else if (bannedXuid)
|
||||
{
|
||||
#if defined(_WINDOWS64) && defined(MINECRAFT_SERVER_BUILD)
|
||||
ServerRuntime::ServerLogManager::OnRejectedPlayerLogin(GetPendingConnectionSmallId(connection), name, ServerRuntime::ServerLogManager::eLoginRejectReason_BannedXuid);
|
||||
#endif
|
||||
disconnect(DisconnectPacket::eDisconnect_Banned);
|
||||
}
|
||||
else if (!whitelistSatisfied)
|
||||
{
|
||||
#if defined(_WINDOWS64) && defined(MINECRAFT_SERVER_BUILD)
|
||||
ServerRuntime::ServerLogManager::OnRejectedPlayerLogin(GetPendingConnectionSmallId(connection), name, ServerRuntime::ServerLogManager::eLoginRejectReason_NotWhitelisted);
|
||||
#endif
|
||||
disconnect(DisconnectPacket::eDisconnect_Banned);
|
||||
}
|
||||
else if (duplicateXuid)
|
||||
{
|
||||
// Reject the incoming connection — a player with this UID is already
|
||||
// on the server. Allowing duplicates causes invisible players and
|
||||
// other undefined behaviour.
|
||||
app.DebugPrintf("LOGIN: Rejecting duplicate xuid for name: %ls\n", name.c_str());
|
||||
disconnect(DisconnectPacket::eDisconnect_Banned);
|
||||
}
|
||||
else
|
||||
{
|
||||
handleAcceptedLogin(packet);
|
||||
vector<shared_ptr<ServerPlayer> > &pl = server->getPlayers()->players;
|
||||
|
||||
for (unsigned int i = 0; i < pl.size(); i++)
|
||||
{
|
||||
if (pl[i] != NULL && pl[i]->name == name)
|
||||
{
|
||||
nameTaken = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (nameTaken)
|
||||
{
|
||||
#if defined(_WINDOWS64) && defined(MINECRAFT_SERVER_BUILD)
|
||||
ServerRuntime::ServerLogManager::OnRejectedPlayerLogin(GetPendingConnectionSmallId(connection), name, ServerRuntime::ServerLogManager::eLoginRejectReason_DuplicateName);
|
||||
#endif
|
||||
app.DebugPrintf("Rejecting duplicate name: %ls\n", name.c_str());
|
||||
|
||||
// to do: replace this with a dedicated duplicate name
|
||||
// message
|
||||
disconnect(DisconnectPacket::eDisconnect_Banned);
|
||||
}
|
||||
else
|
||||
{
|
||||
handleAcceptedLogin(packet);
|
||||
}
|
||||
}
|
||||
//else
|
||||
{
|
||||
@@ -214,6 +376,9 @@ void PendingConnection::handleAcceptedLogin(shared_ptr<LoginPacket> packet)
|
||||
shared_ptr<ServerPlayer> playerEntity = server->getPlayers()->getPlayerForLogin(this, name, playerXuid,packet->m_onlineXuid);
|
||||
if (playerEntity != NULL)
|
||||
{
|
||||
#if defined(_WINDOWS64) && defined(MINECRAFT_SERVER_BUILD)
|
||||
ServerRuntime::ServerLogManager::OnAcceptedPlayerLogin(GetPendingConnectionSmallId(connection), name);
|
||||
#endif
|
||||
server->getPlayers()->placeNewPlayer(connection, playerEntity, packet);
|
||||
connection = NULL; // We've moved responsibility for this over to the new PlayerConnection, NULL so we don't delete our reference to it here in our dtor
|
||||
}
|
||||
|
||||
@@ -539,7 +539,12 @@ void PlayerChunkMap::getChunkAndRemovePlayer(int x, int z, shared_ptr<ServerPlay
|
||||
// 4J - added - actually create & add player to a playerchunk, if there is one queued for this player.
|
||||
void PlayerChunkMap::tickAddRequests(shared_ptr<ServerPlayer> player)
|
||||
{
|
||||
if( addRequests.size() )
|
||||
#ifdef _WINDOWS64
|
||||
const int maxPerTick = 10;
|
||||
#else
|
||||
const int maxPerTick = 1;
|
||||
#endif
|
||||
for (int _processed = 0; _processed < maxPerTick && addRequests.size(); _processed++)
|
||||
{
|
||||
// Find the nearest chunk request to the player
|
||||
int px = (int)player->x;
|
||||
@@ -569,6 +574,10 @@ void PlayerChunkMap::tickAddRequests(shared_ptr<ServerPlayer> player)
|
||||
getChunk(itNearest->x, itNearest->z, true)->add(itNearest->player);
|
||||
addRequests.erase(itNearest);
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -32,6 +32,22 @@
|
||||
// 4J Added
|
||||
#include "..\Minecraft.World\net.minecraft.world.item.crafting.h"
|
||||
#include "Options.h"
|
||||
#if defined(_WINDOWS64) && defined(MINECRAFT_SERVER_BUILD)
|
||||
#include "..\Minecraft.Server\ServerLogManager.h"
|
||||
#endif
|
||||
|
||||
namespace
|
||||
{
|
||||
// Anti-cheat thresholds. Keep server-side checks authoritative even in host mode.
|
||||
// Base max squared displacement allowed per move packet before speed flags trigger.
|
||||
const double kMoveBaseAllowanceSq = 100.0;
|
||||
// Extra squared displacement allowance derived from current server-side velocity.
|
||||
const double kMoveVelocityAllowanceScale = 100.0;
|
||||
// Max squared distance for interact/attack when the target is visible (normal reach).
|
||||
const double kInteractReachSq = 6.0 * 6.0;
|
||||
// Stricter max squared distance used when LOS is blocked to reduce wall-hit abuse.
|
||||
const double kInteractBlockedReachSq = 3.0 * 3.0;
|
||||
}
|
||||
|
||||
Random PlayerConnection::random;
|
||||
|
||||
@@ -64,6 +80,13 @@ PlayerConnection::PlayerConnection(MinecraftServer *server, Connection *connecti
|
||||
m_offlineXUID = INVALID_XUID;
|
||||
m_onlineXUID = INVALID_XUID;
|
||||
m_bHasClientTickedOnce = false;
|
||||
m_logSmallId = 0;
|
||||
|
||||
// Cache the first valid transport smallId because disconnect teardown can clear it before the server logger runs.
|
||||
if (this->connection != NULL && this->connection->getSocket() != NULL)
|
||||
{
|
||||
m_logSmallId = this->connection->getSocket()->getSmallId();
|
||||
}
|
||||
|
||||
setShowOnMaps(app.GetGameHostOption(eGameHostOption_Gamertags)!=0?true:false);
|
||||
}
|
||||
@@ -74,6 +97,17 @@ PlayerConnection::~PlayerConnection()
|
||||
DeleteCriticalSection(&done_cs);
|
||||
}
|
||||
|
||||
unsigned char PlayerConnection::getLogSmallId()
|
||||
{
|
||||
// Fall back to the live socket only while the cached value is still empty.
|
||||
if (m_logSmallId == 0 && connection != NULL && connection->getSocket() != NULL)
|
||||
{
|
||||
m_logSmallId = connection->getSocket()->getSmallId();
|
||||
}
|
||||
|
||||
return m_logSmallId;
|
||||
}
|
||||
|
||||
void PlayerConnection::tick()
|
||||
{
|
||||
if( done ) return;
|
||||
@@ -116,6 +150,14 @@ void PlayerConnection::disconnect(DisconnectPacket::eDisconnectReason reason)
|
||||
return;
|
||||
}
|
||||
|
||||
#if defined(_WINDOWS64) && defined(MINECRAFT_SERVER_BUILD)
|
||||
ServerRuntime::ServerLogManager::OnPlayerDisconnected(
|
||||
getLogSmallId(),
|
||||
(player != NULL) ? player->name : std::wstring(),
|
||||
reason,
|
||||
true);
|
||||
#endif
|
||||
|
||||
app.DebugPrintf("PlayerConnection disconect reason: %d\n", reason );
|
||||
player->disconnect();
|
||||
|
||||
@@ -280,6 +322,20 @@ void PlayerConnection::handleMovePlayer(shared_ptr<MovePlayerPacket> packet)
|
||||
}
|
||||
*/
|
||||
|
||||
// Anti-cheat: reject movement packets that exceed server-authoritative bounds.
|
||||
double velocitySq = player->xd * player->xd + player->yd * player->yd + player->zd * player->zd;
|
||||
double maxAllowedSq = kMoveBaseAllowanceSq + (velocitySq * kMoveVelocityAllowanceScale);
|
||||
if (player->isAllowedToFly() || player->gameMode->isCreative())
|
||||
{
|
||||
// Creative / flight-allowed players can move farther legitimately per tick.
|
||||
maxAllowedSq *= 1.5;
|
||||
}
|
||||
if (dist > maxAllowedSq)
|
||||
{
|
||||
disconnect(DisconnectPacket::eDisconnect_MovedTooQuickly);
|
||||
return;
|
||||
}
|
||||
|
||||
float r = 1 / 16.0f;
|
||||
bool oldOk = level->getCubes(player, player->bb->copy()->shrink(r, r, r))->empty();
|
||||
|
||||
@@ -306,8 +362,8 @@ void PlayerConnection::handleMovePlayer(shared_ptr<MovePlayerPacket> packet)
|
||||
xDist = xt - player->x;
|
||||
yDist = yt - player->y;
|
||||
|
||||
// 4J-PB - line below will always be true!
|
||||
if (yDist > -0.5 || yDist < 0.5)
|
||||
// Clamp tiny Y drift noise to reduce false positives.
|
||||
if (yDist > -0.5 && yDist < 0.5)
|
||||
{
|
||||
yDist = 0;
|
||||
}
|
||||
@@ -428,7 +484,8 @@ void PlayerConnection::handlePlayerAction(shared_ptr<PlayerActionPacket> packet)
|
||||
|
||||
if (packet->action == PlayerActionPacket::START_DESTROY_BLOCK)
|
||||
{
|
||||
if (true) player->gameMode->startDestroyBlock(x, y, z, packet->face); // 4J - condition was !server->isUnderSpawnProtection(level, x, y, z, player) (from Java 1.6.4) but putting back to old behaviour
|
||||
// Anti-cheat: validate spawn protection on the server for mining start.
|
||||
if (!server->isUnderSpawnProtection(level, x, y, z, player)) player->gameMode->startDestroyBlock(x, y, z, packet->face);
|
||||
else player->connection->send( shared_ptr<TileUpdatePacket>( new TileUpdatePacket(x, y, z, level) ) );
|
||||
|
||||
}
|
||||
@@ -456,8 +513,6 @@ void PlayerConnection::handleUseItem(shared_ptr<UseItemPacket> packet)
|
||||
int face = packet->getFace();
|
||||
player->resetLastActionTime();
|
||||
|
||||
// 4J Stu - We don't have ops, so just use the levels setting
|
||||
bool canEditSpawn = level->canEditSpawn; // = level->dimension->id != 0 || server->players->isOp(player->name);
|
||||
if (packet->getFace() == 255)
|
||||
{
|
||||
if (item == NULL) return;
|
||||
@@ -467,7 +522,8 @@ void PlayerConnection::handleUseItem(shared_ptr<UseItemPacket> packet)
|
||||
{
|
||||
if (synched && player->distanceToSqr(x + 0.5, y + 0.5, z + 0.5) < 8 * 8)
|
||||
{
|
||||
if (true) // 4J - condition was !server->isUnderSpawnProtection(level, x, y, z, player) (from java 1.6.4) but putting back to old behaviour
|
||||
// Anti-cheat: block placement/use must pass server-side spawn protection.
|
||||
if (!server->isUnderSpawnProtection(level, x, y, z, player))
|
||||
{
|
||||
player->gameMode->useItemOn(player, level, item, x, y, z, face, packet->getClickX(), packet->getClickY(), packet->getClickZ());
|
||||
}
|
||||
@@ -536,7 +592,18 @@ void PlayerConnection::handleUseItem(shared_ptr<UseItemPacket> packet)
|
||||
void PlayerConnection::onDisconnect(DisconnectPacket::eDisconnectReason reason, void *reasonObjects)
|
||||
{
|
||||
EnterCriticalSection(&done_cs);
|
||||
if( done ) return;
|
||||
if( done )
|
||||
{
|
||||
LeaveCriticalSection(&done_cs);
|
||||
return;
|
||||
}
|
||||
#if defined(_WINDOWS64) && defined(MINECRAFT_SERVER_BUILD)
|
||||
ServerRuntime::ServerLogManager::OnPlayerDisconnected(
|
||||
getLogSmallId(),
|
||||
(player != NULL) ? player->name : std::wstring(),
|
||||
reason,
|
||||
false);
|
||||
#endif
|
||||
// logger.info(player.name + " lost connection: " + reason);
|
||||
// 4J-PB - removed, since it needs to be localised in the language the client is in
|
||||
//server->players->broadcastAll( shared_ptr<ChatPacket>( new ChatPacket(L"§e" + player->name + L" left the game.") ) );
|
||||
@@ -754,12 +821,13 @@ void PlayerConnection::handleInteract(shared_ptr<InteractPacket> packet)
|
||||
// even though the ray is blocked.
|
||||
if (target != NULL) // && player->canSee(target) && player->distanceToSqr(target) < 6 * 6)
|
||||
{
|
||||
//boole canSee = player->canSee(target);
|
||||
//double maxDist = 6 * 6;
|
||||
//if (!canSee)
|
||||
//{
|
||||
// maxDist = 3 * 3;
|
||||
//}
|
||||
// Anti-cheat: enforce reach and LOS on the server to reject forged hits.
|
||||
bool canSeeTarget = player->canSee(target);
|
||||
double maxDistSq = canSeeTarget ? kInteractReachSq : kInteractBlockedReachSq;
|
||||
if (player->distanceToSqr(target) > maxDistSq)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//if (player->distanceToSqr(target) < maxDist)
|
||||
//{
|
||||
@@ -1577,7 +1645,10 @@ bool PlayerConnection::isDisconnected()
|
||||
void PlayerConnection::handleDebugOptions(shared_ptr<DebugOptionsPacket> packet)
|
||||
{
|
||||
//Player player = dynamic_pointer_cast<Player>( player->shared_from_this() );
|
||||
player->SetDebugOptions(packet->m_uiVal);
|
||||
if(app.DebugSettingsOn())
|
||||
{
|
||||
player->SetDebugOptions(packet->m_uiVal);
|
||||
}
|
||||
}
|
||||
|
||||
void PlayerConnection::handleCraftItem(shared_ptr<CraftItemPacket> packet)
|
||||
@@ -1587,6 +1658,10 @@ void PlayerConnection::handleCraftItem(shared_ptr<CraftItemPacket> packet)
|
||||
if(iRecipe == -1)
|
||||
return;
|
||||
|
||||
int recipeCount = (int)Recipes::getInstance()->getRecipies()->size();
|
||||
if(iRecipe < 0 || iRecipe >= recipeCount)
|
||||
return;
|
||||
|
||||
Recipy::INGREDIENTS_REQUIRED *pRecipeIngredientsRequired=Recipes::getInstance()->getRecipeIngredientsArray();
|
||||
shared_ptr<ItemInstance> pTempItemInst=pRecipeIngredientsRequired[iRecipe].pRecipy->assemble(nullptr);
|
||||
|
||||
|
||||
@@ -37,6 +37,7 @@ private:
|
||||
int dropSpamTickCount;
|
||||
|
||||
bool m_bHasClientTickedOnce;
|
||||
unsigned char m_logSmallId;
|
||||
|
||||
public:
|
||||
PlayerConnection(MinecraftServer *server, Connection *connection, shared_ptr<ServerPlayer> player);
|
||||
@@ -45,6 +46,10 @@ public:
|
||||
void disconnect(DisconnectPacket::eDisconnectReason reason);
|
||||
|
||||
private:
|
||||
/**
|
||||
* Returns the stable network smallId used by dedicated-server logging and refreshes it from the live socket when possible
|
||||
*/
|
||||
unsigned char getLogSmallId();
|
||||
double xLastOk, yLastOk, zLastOk;
|
||||
bool synched;
|
||||
|
||||
|
||||
@@ -25,12 +25,16 @@
|
||||
#include "..\Minecraft.World\net.minecraft.world.level.saveddata.h"
|
||||
#include "..\Minecraft.World\JavaMath.h"
|
||||
#include "..\Minecraft.World\EntityIO.h"
|
||||
#ifdef _XBOX
|
||||
#if defined(_XBOX) || defined(_WINDOWS64) || defined(DISABLE_PSN)
|
||||
#include "Xbox\Network\NetworkPlayerXbox.h"
|
||||
#elif defined(__PS3__) || defined(__ORBIS__)
|
||||
#elif !defined(DISABLE_PSN) && (defined(__PS3__) || defined(__ORBIS__))
|
||||
#include "Common\Network\Sony\NetworkPlayerSony.h"
|
||||
#endif
|
||||
|
||||
#if defined(_WINDOWS64) && defined(MINECRAFT_SERVER_BUILD)
|
||||
#include "..\Minecraft.Server\Access\Access.h"
|
||||
#endif
|
||||
|
||||
// 4J - this class is fairly substantially altered as there didn't seem any point in porting code for banning, whitelisting, ops etc.
|
||||
|
||||
PlayerList::PlayerList(MinecraftServer *server)
|
||||
@@ -53,7 +57,11 @@ PlayerList::PlayerList(MinecraftServer *server)
|
||||
|
||||
//int viewDistance = server->settings->getInt(L"view-distance", 10);
|
||||
|
||||
#if defined(_WINDOWS64) || defined(DISABLE_PSN) || defined(_DISABLE_XBLIVE)
|
||||
maxPlayers = MINECRAFT_NET_MAX_PLAYERS;
|
||||
#else
|
||||
maxPlayers = server->settings->getInt(L"max-players", 20);
|
||||
#endif
|
||||
doWhiteList = false;
|
||||
|
||||
InitializeCriticalSection(&m_kickPlayersCS);
|
||||
@@ -90,7 +98,7 @@ void PlayerList::placeNewPlayer(Connection *connection, shared_ptr<ServerPlayer>
|
||||
player->setPlayerGamePrivilege(Player::ePlayerGamePrivilege_HOST,1);
|
||||
}
|
||||
|
||||
#if defined(__PS3__) || defined(__ORBIS__)
|
||||
#if !defined(DISABLE_PSN) && (defined(__PS3__) || defined(__ORBIS__))
|
||||
// PS3 networking library doesn't automatically assign PlayerUIDs to the network players for anything remote, so need to tell it what to set from the data in this packet now
|
||||
if( !g_NetworkManager.IsLocalGame() )
|
||||
{
|
||||
@@ -99,6 +107,15 @@ void PlayerList::placeNewPlayer(Connection *connection, shared_ptr<ServerPlayer>
|
||||
((NetworkPlayerSony *)networkPlayer)->SetUID( packet->m_onlineXuid );
|
||||
}
|
||||
}
|
||||
#elif defined(_WINDOWS64) || defined(DISABLE_PSN)
|
||||
if (networkPlayer != NULL && !networkPlayer->IsLocal())
|
||||
{
|
||||
NetworkPlayerXbox *nxp = (NetworkPlayerXbox *)networkPlayer;
|
||||
IQNetPlayer *qnp = nxp->GetQNetPlayer();
|
||||
wcsncpy(qnp->m_gamertag, player->name.c_str(), 31);
|
||||
qnp->m_gamertag[31] = L'\0';
|
||||
g_NetworkManager.UpdateAndSetGameSessionData();
|
||||
}
|
||||
#endif
|
||||
|
||||
// 4J Stu - TU-1 hotfix
|
||||
@@ -469,6 +486,7 @@ void PlayerList::remove(shared_ptr<ServerPlayer> player)
|
||||
//4J Stu - We don't want to save the map data for guests, so when we are sure that the player is gone delete the map
|
||||
if(player->isGuest()) playerIo->deleteMapFilesForPlayer(player);
|
||||
ServerLevel *level = player->getLevel();
|
||||
level->getTracker()->removeEntity(player);
|
||||
if (player->riding != NULL)
|
||||
{
|
||||
// remove mount first because the player unmounts when being
|
||||
@@ -497,7 +515,7 @@ void PlayerList::remove(shared_ptr<ServerPlayer> player)
|
||||
|
||||
shared_ptr<ServerPlayer> PlayerList::getPlayerForLogin(PendingConnection *pendingConnection, const wstring& userName, PlayerUID xuid, PlayerUID onlineXuid)
|
||||
{
|
||||
if (players.size() >= maxPlayers)
|
||||
if (players.size() >= (unsigned int)MINECRAFT_NET_MAX_PLAYERS)
|
||||
{
|
||||
pendingConnection->disconnect(DisconnectPacket::eDisconnect_ServerFull);
|
||||
return shared_ptr<ServerPlayer>();
|
||||
@@ -510,9 +528,14 @@ shared_ptr<ServerPlayer> PlayerList::getPlayerForLogin(PendingConnection *pendin
|
||||
|
||||
// Work out the base server player settings
|
||||
INetworkPlayer *networkPlayer = pendingConnection->connection->getSocket()->getPlayer();
|
||||
if(networkPlayer != NULL && !networkPlayer->IsHost())
|
||||
if (networkPlayer != NULL)
|
||||
{
|
||||
player->enableAllPlayerPrivileges( app.GetGameHostOption(eGameHostOption_TrustPlayers)>0 );
|
||||
if (!networkPlayer->IsHost())
|
||||
player->enableAllPlayerPrivileges( app.GetGameHostOption(eGameHostOption_TrustPlayers)>0 );
|
||||
|
||||
PlayerUID realXuid = networkPlayer->GetUID();
|
||||
player->setXuid(realXuid);
|
||||
player->setOnlineXuid(realXuid);
|
||||
}
|
||||
|
||||
// 4J Added
|
||||
@@ -1607,6 +1630,13 @@ bool PlayerList::isXuidBanned(PlayerUID xuid)
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(MINECRAFT_SERVER_BUILD)
|
||||
if (!banned)
|
||||
{
|
||||
banned = ServerRuntime::Access::IsPlayerBanned(xuid);
|
||||
}
|
||||
#endif
|
||||
|
||||
return banned;
|
||||
}
|
||||
|
||||
|
||||
@@ -38,13 +38,35 @@ PlayerRenderer::PlayerRenderer() : LivingEntityRenderer( new HumanoidModel(0), 0
|
||||
armorParts2 = new HumanoidModel(0.5f);
|
||||
}
|
||||
|
||||
static unsigned int HsvToArgb(float h, float s, float v)
|
||||
{
|
||||
float c = v * s;
|
||||
float x = c * (1.0f - fabsf(fmodf(h / 60.0f, 2.0f) - 1.0f));
|
||||
float m = v - c;
|
||||
float r, g, b;
|
||||
if (h < 60) { r = c; g = x; b = 0; }
|
||||
else if (h < 120) { r = x; g = c; b = 0; }
|
||||
else if (h < 180) { r = 0; g = c; b = x; }
|
||||
else if (h < 240) { r = 0; g = x; b = c; }
|
||||
else if (h < 300) { r = x; g = 0; b = c; }
|
||||
else { r = c; g = 0; b = x; }
|
||||
unsigned int ri = (unsigned int)((r + m) * 255.0f);
|
||||
unsigned int gi = (unsigned int)((g + m) * 255.0f);
|
||||
unsigned int bi = (unsigned int)((b + m) * 255.0f);
|
||||
return 0xFF000000 | (ri << 16) | (gi << 8) | bi;
|
||||
}
|
||||
|
||||
unsigned int PlayerRenderer::getNametagColour(int index)
|
||||
{
|
||||
if( index >= 0 && index < MINECRAFT_NET_MAX_PLAYERS)
|
||||
{
|
||||
return s_nametagColors[index];
|
||||
}
|
||||
return 0xFF000000;
|
||||
|
||||
float hue = fmodf(index * 137.508f, 360.0f);
|
||||
float sat = 0.65f + (float)(index % 3) * 0.15f;
|
||||
float val = 0.75f + (float)(index % 4) * 0.08f;
|
||||
return HsvToArgb(hue, sat, val);
|
||||
}
|
||||
|
||||
int PlayerRenderer::prepareArmor(shared_ptr<LivingEntity> _player, int layer, float a)
|
||||
|
||||
@@ -1086,7 +1086,9 @@ void ServerLevel::entityRemoved(shared_ptr<Entity> e)
|
||||
|
||||
shared_ptr<Entity> ServerLevel::getEntity(int id)
|
||||
{
|
||||
return entitiesById[id];
|
||||
AUTO_VAR(it, entitiesById.find(id));
|
||||
if(it != entitiesById.end()) return it->second;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool ServerLevel::addGlobalEntity(shared_ptr<Entity> e)
|
||||
|
||||
@@ -329,6 +329,10 @@ void ServerPlayer::doTickA()
|
||||
// 4J - split off the chunk sending bit of the tick here from ::doTick so we can do this exactly once per player per server tick
|
||||
void ServerPlayer::doChunkSendingTick(bool dontDelayChunks)
|
||||
{
|
||||
#if defined(_WINDOWS64) || defined(DISABLE_PSN) || defined(_DISABLE_XBLIVE)
|
||||
for (int _w64cs = 0; _w64cs < 4; _w64cs++)
|
||||
{
|
||||
#endif
|
||||
// printf("[%d] %s: sendChunks: %d, empty: %d\n",tickCount, connection->getNetworkPlayer()->GetUID().getOnlineID(),sendChunks,chunksToSend.empty());
|
||||
if (!chunksToSend.empty())
|
||||
{
|
||||
@@ -367,6 +371,17 @@ void ServerPlayer::doChunkSendingTick(bool dontDelayChunks)
|
||||
}
|
||||
else
|
||||
{
|
||||
#if defined(_WINDOWS64)
|
||||
if( dontDelayChunks ||
|
||||
((connection->countDelayedPackets() < 16 )&&
|
||||
(g_NetworkManager.GetHostPlayer()->GetSendQueueSizeMessages( NULL, true ) < 16 )&&
|
||||
!connection->done) )
|
||||
{
|
||||
lastBrupSendTickCount = tickCount;
|
||||
okToSend = true;
|
||||
MinecraftServer::s_slowQueuePacketSent = true;
|
||||
}
|
||||
#else
|
||||
bool canSendToPlayer = MinecraftServer::chunkPacketManagement_CanSendTo(connection->getNetworkPlayer());
|
||||
|
||||
// app.DebugPrintf(">>> %d\n", canSendToPlayer);
|
||||
@@ -408,6 +423,7 @@ void ServerPlayer::doChunkSendingTick(bool dontDelayChunks)
|
||||
{
|
||||
// app.DebugPrintf(" - <NOT OK>\n");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
if (okToSend)
|
||||
@@ -485,6 +501,9 @@ void ServerPlayer::doChunkSendingTick(bool dontDelayChunks)
|
||||
}
|
||||
}
|
||||
}
|
||||
#if defined(_WINDOWS64) || defined(DISABLE_PSN) || defined(_DISABLE_XBLIVE)
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void ServerPlayer::doTickB()
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user