Compare commits
14
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
77ac64d9e1 | ||
|
|
c79904f326 | ||
|
|
bc7d4ff1d8 | ||
|
|
2ed4b1fe9e | ||
|
|
0855e6ddf4 | ||
|
|
49d02788c0 | ||
|
|
f3ac01c76e | ||
|
|
b9d67d14af | ||
|
|
7c95bfc0bd | ||
|
|
ac9f3cbca3 | ||
|
|
cdc08700e4 | ||
|
|
41db813a6d | ||
|
|
ecf7fc7f61 | ||
|
|
67ceccf2d4 |
@@ -51,7 +51,7 @@ void C_4JProfile::SetPrimaryPad(int iPad) {}
|
|||||||
|
|
||||||
static char s_gamertag[64] = "Player";
|
static char s_gamertag[64] = "Player";
|
||||||
char* C_4JProfile::GetGamertag(int iPad) { return s_gamertag; }
|
char* C_4JProfile::GetGamertag(int iPad) { return s_gamertag; }
|
||||||
wstring C_4JProfile::GetDisplayName(int iPad) { return L"Player"; }
|
std::wstring C_4JProfile::GetDisplayName(int iPad) { return L"Player"; }
|
||||||
bool C_4JProfile::IsFullVersion() { return true; }
|
bool C_4JProfile::IsFullVersion() { return true; }
|
||||||
void C_4JProfile::SetSignInChangeCallback(void(*Func)(LPVOID, bool, unsigned int), LPVOID lpParam) {}
|
void C_4JProfile::SetSignInChangeCallback(void(*Func)(LPVOID, bool, unsigned int), LPVOID lpParam) {}
|
||||||
void C_4JProfile::SetNotificationsCallback(void(*Func)(LPVOID, DWORD, unsigned int), LPVOID lpParam) {}
|
void C_4JProfile::SetNotificationsCallback(void(*Func)(LPVOID, DWORD, unsigned int), LPVOID lpParam) {}
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ public:
|
|||||||
int GetPrimaryPad();
|
int GetPrimaryPad();
|
||||||
void SetPrimaryPad(int iPad);
|
void SetPrimaryPad(int iPad);
|
||||||
char* GetGamertag(int iPad);
|
char* GetGamertag(int iPad);
|
||||||
wstring GetDisplayName(int iPad);
|
std::wstring GetDisplayName(int iPad);
|
||||||
bool IsFullVersion();
|
bool IsFullVersion();
|
||||||
void SetSignInChangeCallback(void ( *Func)(LPVOID, bool, unsigned int),LPVOID lpParam);
|
void SetSignInChangeCallback(void ( *Func)(LPVOID, bool, unsigned int),LPVOID lpParam);
|
||||||
void SetNotificationsCallback(void ( *Func)(LPVOID, DWORD, unsigned int),LPVOID lpParam);
|
void SetNotificationsCallback(void ( *Func)(LPVOID, DWORD, unsigned int),LPVOID lpParam);
|
||||||
|
|||||||
@@ -322,7 +322,7 @@ public:
|
|||||||
C4JStorage::ETMSStatus TMSPP_ReadFile(int iPad,C4JStorage::eGlobalStorage eStorageFacility,C4JStorage::eTMS_FILETYPEVAL eFileTypeVal,LPCSTR szFilename,int( *Func)(LPVOID,int,int,PTMSPP_FILEDATA, LPCSTR)=NULL,LPVOID lpParam=NULL, int iUserData=0);
|
C4JStorage::ETMSStatus TMSPP_ReadFile(int iPad,C4JStorage::eGlobalStorage eStorageFacility,C4JStorage::eTMS_FILETYPEVAL eFileTypeVal,LPCSTR szFilename,int( *Func)(LPVOID,int,int,PTMSPP_FILEDATA, LPCSTR)=NULL,LPVOID lpParam=NULL, int iUserData=0);
|
||||||
// C4JStorage::ETMSStatus TMSPP_ReadFileList(int iPad,C4JStorage::eGlobalStorage eStorageFacility,CHAR *pchFilePath,int( *Func)(LPVOID,int,int,PTMSPP_FILE_LIST)=NULL,LPVOID lpParam=NULL, int iUserData=0);
|
// C4JStorage::ETMSStatus TMSPP_ReadFileList(int iPad,C4JStorage::eGlobalStorage eStorageFacility,CHAR *pchFilePath,int( *Func)(LPVOID,int,int,PTMSPP_FILE_LIST)=NULL,LPVOID lpParam=NULL, int iUserData=0);
|
||||||
// C4JStorage::ETMSStatus TMSPP_DeleteFile(int iPad,LPCSTR szFilePath,C4JStorage::eTMS_FILETYPEVAL eFileTypeVal,int( *Func)(LPVOID,int,int),LPVOID lpParam=NULL, int iUserData=0);
|
// C4JStorage::ETMSStatus TMSPP_DeleteFile(int iPad,LPCSTR szFilePath,C4JStorage::eTMS_FILETYPEVAL eFileTypeVal,int( *Func)(LPVOID,int,int),LPVOID lpParam=NULL, int iUserData=0);
|
||||||
// bool TMSPP_InFileList(eGlobalStorage eStorageFacility, int iPad,const wstring &Filename);
|
// bool TMSPP_InFileList(eGlobalStorage eStorageFacility, int iPad,const std::wstring &Filename);
|
||||||
// unsigned int CRC(unsigned char *buf, int len);
|
// unsigned int CRC(unsigned char *buf, int len);
|
||||||
|
|
||||||
// enum eXBLWS
|
// enum eXBLWS
|
||||||
|
|||||||
@@ -265,7 +265,7 @@ typedef struct _LaunchMoreOptionsMenuInitData
|
|||||||
|
|
||||||
_LaunchMoreOptionsMenuInitData()
|
_LaunchMoreOptionsMenuInitData()
|
||||||
{
|
{
|
||||||
memset(this,0,sizeof(_LaunchMoreOptionsMenuInitData));
|
memset((void*)this,0,sizeof(_LaunchMoreOptionsMenuInitData));
|
||||||
bOnlineGame = TRUE;
|
bOnlineGame = TRUE;
|
||||||
bAllowFriendsOfFriends = TRUE;
|
bAllowFriendsOfFriends = TRUE;
|
||||||
bPVP = TRUE;
|
bPVP = TRUE;
|
||||||
|
|||||||
@@ -500,7 +500,7 @@ void SetFakeGamertag(char *name){ strcpy_s(fakeGamerTag, name); }
|
|||||||
char* C_4JProfile::GetGamertag(int iPad){ return fakeGamerTag; }
|
char* C_4JProfile::GetGamertag(int iPad){ return fakeGamerTag; }
|
||||||
#else
|
#else
|
||||||
char* C_4JProfile::GetGamertag(int iPad){ return "PlayerName"; }
|
char* C_4JProfile::GetGamertag(int iPad){ return "PlayerName"; }
|
||||||
wstring C_4JProfile::GetDisplayName(int iPad){ return L"PlayerName"; }
|
std::wstring C_4JProfile::GetDisplayName(int iPad){ return L"PlayerName"; }
|
||||||
#endif
|
#endif
|
||||||
bool C_4JProfile::IsFullVersion() { return s_bProfileIsFullVersion; }
|
bool C_4JProfile::IsFullVersion() { return s_bProfileIsFullVersion; }
|
||||||
void C_4JProfile::SetSignInChangeCallback(void ( *Func)(LPVOID, bool, unsigned int),LPVOID lpParam) {}
|
void C_4JProfile::SetSignInChangeCallback(void ( *Func)(LPVOID, bool, unsigned int),LPVOID lpParam) {}
|
||||||
|
|||||||
@@ -229,7 +229,7 @@ class ZipFile
|
|||||||
public:
|
public:
|
||||||
ZipFile(File *file) {}
|
ZipFile(File *file) {}
|
||||||
InputStream *getInputStream(ZipEntry *entry) { return NULL; }
|
InputStream *getInputStream(ZipEntry *entry) { return NULL; }
|
||||||
ZipEntry *getEntry(const wstring& name) {return NULL;}
|
ZipEntry *getEntry(const std::wstring& name) {return NULL;}
|
||||||
void close() {}
|
void close() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -245,7 +245,7 @@ public:
|
|||||||
static void create() {}
|
static void create() {}
|
||||||
static void destroy() {}
|
static void destroy() {}
|
||||||
static bool isKeyDown(int) {return false;}
|
static bool isKeyDown(int) {return false;}
|
||||||
static wstring getKeyName(int) { return L"KEYNAME"; }
|
static std::wstring getKeyName(int) { return L"KEYNAME"; }
|
||||||
static void enableRepeatEvents(bool) {}
|
static void enableRepeatEvents(bool) {}
|
||||||
static const int KEY_A = 0;
|
static const int KEY_A = 0;
|
||||||
static const int KEY_B = 1;
|
static const int KEY_B = 1;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "Build/stdafx.h"
|
#include "Build/stdafx.h"
|
||||||
#include "ClientConstants.h"
|
#include "ClientConstants.h"
|
||||||
|
|
||||||
const wstring ClientConstants::VERSION_STRING = wstring(L"Minecraft Xbox ") + VER_FILEVERSION_STR_W;//+ SharedConstants::VERSION_STRING;
|
const std::wstring ClientConstants::VERSION_STRING = std::wstring(L"Minecraft Xbox ") + VER_FILEVERSION_STR_W;//+ SharedConstants::VERSION_STRING;
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
class ClientConstants
|
class ClientConstants
|
||||||
{
|
{
|
||||||
@@ -12,7 +12,7 @@ class ClientConstants
|
|||||||
|
|
||||||
// INTERNAL DEVELOPMENT SETTINGS
|
// INTERNAL DEVELOPMENT SETTINGS
|
||||||
public:
|
public:
|
||||||
static const wstring VERSION_STRING;
|
static const std::wstring VERSION_STRING;
|
||||||
|
|
||||||
static const bool DEADMAU5_CAMERA_CHEATS = false;
|
static const bool DEADMAU5_CAMERA_CHEATS = false;
|
||||||
static const bool IS_DEMO_VERSION = false;
|
static const bool IS_DEMO_VERSION = false;
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ EGameCommand TeleportCommand::getId()
|
|||||||
return eGameCommand_Teleport;
|
return eGameCommand_Teleport;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TeleportCommand::execute(shared_ptr<CommandSender> source, byteArray commandData)
|
void TeleportCommand::execute(std::shared_ptr<CommandSender> source, byteArray commandData)
|
||||||
{
|
{
|
||||||
ByteArrayInputStream bais(commandData);
|
ByteArrayInputStream bais(commandData);
|
||||||
DataInputStream dis(&bais);
|
DataInputStream dis(&bais);
|
||||||
@@ -26,8 +26,8 @@ void TeleportCommand::execute(shared_ptr<CommandSender> source, byteArray comman
|
|||||||
|
|
||||||
PlayerList *players = MinecraftServer::getInstance()->getPlayerList();
|
PlayerList *players = MinecraftServer::getInstance()->getPlayerList();
|
||||||
|
|
||||||
shared_ptr<ServerPlayer> subject = players->getPlayer(subjectID);
|
std::shared_ptr<ServerPlayer> subject = players->getPlayer(subjectID);
|
||||||
shared_ptr<ServerPlayer> destination = players->getPlayer(destinationID);
|
std::shared_ptr<ServerPlayer> destination = players->getPlayer(destinationID);
|
||||||
|
|
||||||
if(subject != NULL && destination != NULL && subject->level->dimension->id == destination->level->dimension->id && subject->isAlive() )
|
if(subject != NULL && destination != NULL && subject->level->dimension->id == destination->level->dimension->id && subject->isAlive() )
|
||||||
{
|
{
|
||||||
@@ -78,7 +78,7 @@ void TeleportCommand::execute(shared_ptr<CommandSender> source, byteArray comman
|
|||||||
//}
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
shared_ptr<GameCommandPacket> TeleportCommand::preparePacket(PlayerUID subject, PlayerUID destination)
|
std::shared_ptr<GameCommandPacket> TeleportCommand::preparePacket(PlayerUID subject, PlayerUID destination)
|
||||||
{
|
{
|
||||||
ByteArrayOutputStream baos;
|
ByteArrayOutputStream baos;
|
||||||
DataOutputStream dos(&baos);
|
DataOutputStream dos(&baos);
|
||||||
@@ -86,5 +86,5 @@ shared_ptr<GameCommandPacket> TeleportCommand::preparePacket(PlayerUID subject,
|
|||||||
dos.writePlayerUID(subject);
|
dos.writePlayerUID(subject);
|
||||||
dos.writePlayerUID(destination);
|
dos.writePlayerUID(destination);
|
||||||
|
|
||||||
return shared_ptr<GameCommandPacket>( new GameCommandPacket(eGameCommand_Teleport, baos.toByteArray() ));
|
return std::shared_ptr<GameCommandPacket>( new GameCommandPacket(eGameCommand_Teleport, baos.toByteArray() ));
|
||||||
}
|
}
|
||||||
@@ -6,7 +6,7 @@ class TeleportCommand : public Command
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual EGameCommand getId();
|
virtual EGameCommand getId();
|
||||||
virtual void execute(shared_ptr<CommandSender> source, byteArray commandData);
|
virtual void execute(std::shared_ptr<CommandSender> source, byteArray commandData);
|
||||||
|
|
||||||
static shared_ptr<GameCommandPacket> preparePacket(PlayerUID subject, PlayerUID destination);
|
static std::shared_ptr<GameCommandPacket> preparePacket(PlayerUID subject, PlayerUID destination);
|
||||||
};
|
};
|
||||||
@@ -21,7 +21,7 @@ void CreativeMode::init()
|
|||||||
// initPlayer();
|
// initPlayer();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CreativeMode::enableCreativeForPlayer(shared_ptr<Player> player)
|
void CreativeMode::enableCreativeForPlayer(std::shared_ptr<Player> player)
|
||||||
{
|
{
|
||||||
// please check ServerPlayerGameMode.java if you change these
|
// please check ServerPlayerGameMode.java if you change these
|
||||||
player->abilities.mayfly = true;
|
player->abilities.mayfly = true;
|
||||||
@@ -29,7 +29,7 @@ void CreativeMode::enableCreativeForPlayer(shared_ptr<Player> player)
|
|||||||
player->abilities.invulnerable = true;
|
player->abilities.invulnerable = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CreativeMode::disableCreativeForPlayer(shared_ptr<Player> player)
|
void CreativeMode::disableCreativeForPlayer(std::shared_ptr<Player> player)
|
||||||
{
|
{
|
||||||
player->abilities.mayfly = false;
|
player->abilities.mayfly = false;
|
||||||
player->abilities.flying = false;
|
player->abilities.flying = false;
|
||||||
@@ -37,7 +37,7 @@ void CreativeMode::disableCreativeForPlayer(shared_ptr<Player> player)
|
|||||||
player->abilities.invulnerable = false;
|
player->abilities.invulnerable = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CreativeMode::adjustPlayer(shared_ptr<Player> player)
|
void CreativeMode::adjustPlayer(std::shared_ptr<Player> player)
|
||||||
{
|
{
|
||||||
enableCreativeForPlayer(player);
|
enableCreativeForPlayer(player);
|
||||||
|
|
||||||
@@ -45,7 +45,7 @@ void CreativeMode::adjustPlayer(shared_ptr<Player> player)
|
|||||||
{
|
{
|
||||||
if (player->inventory->items[i] == NULL)
|
if (player->inventory->items[i] == NULL)
|
||||||
{
|
{
|
||||||
player->inventory->items[i] = shared_ptr<ItemInstance>( new ItemInstance(User::allowedTiles[i]) );
|
player->inventory->items[i] = std::shared_ptr<ItemInstance>( new ItemInstance(User::allowedTiles[i]) );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -63,7 +63,7 @@ void CreativeMode::creativeDestroyBlock(Minecraft *minecraft, GameMode *gameMode
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CreativeMode::useItemOn(shared_ptr<Player> player, Level *level, shared_ptr<ItemInstance> item, int x, int y, int z, int face, bool bTestUseOnOnly, bool *pbUsedItem)
|
bool CreativeMode::useItemOn(std::shared_ptr<Player> player, Level *level, std::shared_ptr<ItemInstance> item, int x, int y, int z, int face, bool bTestUseOnOnly, bool *pbUsedItem)
|
||||||
{
|
{
|
||||||
int t = level->getTile(x, y, z);
|
int t = level->getTile(x, y, z);
|
||||||
if (t > 0)
|
if (t > 0)
|
||||||
|
|||||||
@@ -9,11 +9,11 @@ private:
|
|||||||
public:
|
public:
|
||||||
CreativeMode(Minecraft *minecraft);
|
CreativeMode(Minecraft *minecraft);
|
||||||
virtual void init();
|
virtual void init();
|
||||||
static void enableCreativeForPlayer(shared_ptr<Player> player);
|
static void enableCreativeForPlayer(std::shared_ptr<Player> player);
|
||||||
static void disableCreativeForPlayer(shared_ptr<Player> player);
|
static void disableCreativeForPlayer(std::shared_ptr<Player> player);
|
||||||
virtual void adjustPlayer(shared_ptr<Player> player);
|
virtual void adjustPlayer(std::shared_ptr<Player> player);
|
||||||
static void creativeDestroyBlock(Minecraft *minecraft, GameMode *gameMode, int x, int y, int z, int face);
|
static void creativeDestroyBlock(Minecraft *minecraft, GameMode *gameMode, int x, int y, int z, int face);
|
||||||
virtual bool useItemOn(shared_ptr<Player> player, Level *level, shared_ptr<ItemInstance> item, int x, int y, int z, int face, bool bTestUseOnOnly=false, bool *pbUsedItem = NULL);
|
virtual bool useItemOn(std::shared_ptr<Player> player, Level *level, std::shared_ptr<ItemInstance> item, int x, int y, int z, int face, bool bTestUseOnOnly=false, bool *pbUsedItem = NULL);
|
||||||
virtual void startDestroyBlock(int x, int y, int z, int face);
|
virtual void startDestroyBlock(int x, int y, int z, int face);
|
||||||
virtual void continueDestroyBlock(int x, int y, int z, int face);
|
virtual void continueDestroyBlock(int x, int y, int z, int face);
|
||||||
virtual void stopDestroyBlock();
|
virtual void stopDestroyBlock();
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ void DemoMode::tick()
|
|||||||
else if (day == 1)
|
else if (day == 1)
|
||||||
{
|
{
|
||||||
Options *options = minecraft->options;
|
Options *options = minecraft->options;
|
||||||
wstring message;
|
std::wstring message;
|
||||||
|
|
||||||
if (time == 100) {
|
if (time == 100) {
|
||||||
minecraft.gui.addMessage("Seed: " + minecraft.level.getSeed());
|
minecraft.gui.addMessage("Seed: " + minecraft.level.getSeed());
|
||||||
@@ -95,7 +95,7 @@ bool DemoMode::destroyBlock(int x, int y, int z, int face)
|
|||||||
return SurvivalMode::destroyBlock(x, y, z, face);
|
return SurvivalMode::destroyBlock(x, y, z, face);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DemoMode::useItem(shared_ptr<Player> player, Level *level, shared_ptr<ItemInstance> item)
|
bool DemoMode::useItem(std::shared_ptr<Player> player, Level *level, std::shared_ptr<ItemInstance> item)
|
||||||
{
|
{
|
||||||
if (demoHasEnded)
|
if (demoHasEnded)
|
||||||
{
|
{
|
||||||
@@ -105,7 +105,7 @@ bool DemoMode::useItem(shared_ptr<Player> player, Level *level, shared_ptr<ItemI
|
|||||||
return SurvivalMode::useItem(player, level, item);
|
return SurvivalMode::useItem(player, level, item);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DemoMode::useItemOn(shared_ptr<Player> player, Level *level, shared_ptr<ItemInstance> item, int x, int y, int z, int face)
|
bool DemoMode::useItemOn(std::shared_ptr<Player> player, Level *level, std::shared_ptr<ItemInstance> item, int x, int y, int z, int face)
|
||||||
{
|
{
|
||||||
if (demoHasEnded) {
|
if (demoHasEnded) {
|
||||||
outputDemoReminder();
|
outputDemoReminder();
|
||||||
@@ -114,7 +114,7 @@ bool DemoMode::useItemOn(shared_ptr<Player> player, Level *level, shared_ptr<Ite
|
|||||||
return SurvivalMode::useItemOn(player, level, item, x, y, z, face);
|
return SurvivalMode::useItemOn(player, level, item, x, y, z, face);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DemoMode::attack(shared_ptr<Player> player, shared_ptr<Entity> entity)
|
void DemoMode::attack(std::shared_ptr<Player> player, std::shared_ptr<Entity> entity)
|
||||||
{
|
{
|
||||||
if (demoHasEnded)
|
if (demoHasEnded)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ public:
|
|||||||
virtual void startDestroyBlock(int x, int y, int z, int face);
|
virtual void startDestroyBlock(int x, int y, int z, int face);
|
||||||
virtual void continueDestroyBlock(int x, int y, int z, int face);
|
virtual void continueDestroyBlock(int x, int y, int z, int face);
|
||||||
virtual bool destroyBlock(int x, int y, int z, int face);
|
virtual bool destroyBlock(int x, int y, int z, int face);
|
||||||
virtual bool useItem(shared_ptr<Player> player, Level *level, shared_ptr<ItemInstance> item);
|
virtual bool useItem(std::shared_ptr<Player> player, Level *level, std::shared_ptr<ItemInstance> item);
|
||||||
virtual bool useItemOn(shared_ptr<Player> player, Level *level, shared_ptr<ItemInstance> item, int x, int y, int z, int face);
|
virtual bool useItemOn(std::shared_ptr<Player> player, Level *level, std::shared_ptr<ItemInstance> item, int x, int y, int z, int face);
|
||||||
virtual void attack(shared_ptr<Player> player, shared_ptr<Entity> entity);
|
virtual void attack(std::shared_ptr<Player> player, std::shared_ptr<Entity> entity);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -47,11 +47,11 @@ void GameMode::render(float a)
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GameMode::useItem(shared_ptr<Player> player, Level *level, shared_ptr<ItemInstance> item, bool bTestUseOnly)
|
bool GameMode::useItem(std::shared_ptr<Player> player, Level *level, std::shared_ptr<ItemInstance> item, bool bTestUseOnly)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameMode::initPlayer(shared_ptr<Player> player)
|
void GameMode::initPlayer(std::shared_ptr<Player> player)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,11 +59,11 @@ void GameMode::tick()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameMode::adjustPlayer(shared_ptr<Player> player)
|
void GameMode::adjustPlayer(std::shared_ptr<Player> player)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
//bool GameMode::useItemOn(shared_ptr<Player> player, Level *level, shared_ptr<ItemInstance> item, int x, int y, int z, int face, bool bTestUseOnOnly)
|
//bool GameMode::useItemOn(std::shared_ptr<Player> player, Level *level, std::shared_ptr<ItemInstance> item, int x, int y, int z, int face, bool bTestUseOnOnly)
|
||||||
//{
|
//{
|
||||||
// // 4J-PB - Adding a test only version to allow tooltips to be displayed
|
// // 4J-PB - Adding a test only version to allow tooltips to be displayed
|
||||||
// int t = level->getTile(x, y, z);
|
// int t = level->getTile(x, y, z);
|
||||||
@@ -101,27 +101,27 @@ void GameMode::adjustPlayer(shared_ptr<Player> player)
|
|||||||
//}
|
//}
|
||||||
|
|
||||||
|
|
||||||
shared_ptr<Player> GameMode::createPlayer(Level *level)
|
std::shared_ptr<Player> GameMode::createPlayer(Level *level)
|
||||||
{
|
{
|
||||||
return shared_ptr<Player>( new LocalPlayer(minecraft, level, minecraft->user, level->dimension->id) );
|
return std::shared_ptr<Player>( new LocalPlayer(minecraft, level, minecraft->user, level->dimension->id) );
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GameMode::interact(shared_ptr<Player> player, shared_ptr<Entity> entity)
|
bool GameMode::interact(std::shared_ptr<Player> player, std::shared_ptr<Entity> entity)
|
||||||
{
|
{
|
||||||
return player->interact(entity);
|
return player->interact(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameMode::attack(shared_ptr<Player> player, shared_ptr<Entity> entity)
|
void GameMode::attack(std::shared_ptr<Player> player, std::shared_ptr<Entity> entity)
|
||||||
{
|
{
|
||||||
player->attack(entity);
|
player->attack(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
shared_ptr<ItemInstance> GameMode::handleInventoryMouseClick(int containerId, int slotNum, int buttonNum, bool quickKeyHeld, shared_ptr<Player> player)
|
std::shared_ptr<ItemInstance> GameMode::handleInventoryMouseClick(int containerId, int slotNum, int buttonNum, bool quickKeyHeld, std::shared_ptr<Player> player)
|
||||||
{
|
{
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameMode::handleCloseInventory(int containerId, shared_ptr<Player> player)
|
void GameMode::handleCloseInventory(int containerId, std::shared_ptr<Player> player)
|
||||||
{
|
{
|
||||||
player->containerMenu->removed(player);
|
player->containerMenu->removed(player);
|
||||||
delete player->containerMenu;
|
delete player->containerMenu;
|
||||||
@@ -138,7 +138,7 @@ bool GameMode::isCutScene()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameMode::releaseUsingItem(shared_ptr<Player> player)
|
void GameMode::releaseUsingItem(std::shared_ptr<Player> player)
|
||||||
{
|
{
|
||||||
player->releaseUsingItem();
|
player->releaseUsingItem();
|
||||||
}
|
}
|
||||||
@@ -163,21 +163,21 @@ bool GameMode::hasFarPickRange()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameMode::handleCreativeModeItemAdd(shared_ptr<ItemInstance> clicked, int i)
|
void GameMode::handleCreativeModeItemAdd(std::shared_ptr<ItemInstance> clicked, int i)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameMode::handleCreativeModeItemDrop(shared_ptr<ItemInstance> clicked)
|
void GameMode::handleCreativeModeItemDrop(std::shared_ptr<ItemInstance> clicked)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GameMode::handleCraftItem(int recipe, shared_ptr<Player> player)
|
bool GameMode::handleCraftItem(int recipe, std::shared_ptr<Player> player)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4J-PB
|
// 4J-PB
|
||||||
void GameMode::handleDebugOptions(unsigned int uiVal, shared_ptr<Player> player)
|
void GameMode::handleDebugOptions(unsigned int uiVal, std::shared_ptr<Player> player)
|
||||||
{
|
{
|
||||||
player->SetDebugOptions(uiVal);
|
player->SetDebugOptions(uiVal);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,32 +25,32 @@ public:
|
|||||||
virtual void stopDestroyBlock() = 0;
|
virtual void stopDestroyBlock() = 0;
|
||||||
virtual void render(float a);
|
virtual void render(float a);
|
||||||
virtual float getPickRange() = 0;
|
virtual float getPickRange() = 0;
|
||||||
virtual void initPlayer(shared_ptr<Player> player);
|
virtual void initPlayer(std::shared_ptr<Player> player);
|
||||||
virtual void tick();
|
virtual void tick();
|
||||||
virtual bool canHurtPlayer() = 0;
|
virtual bool canHurtPlayer() = 0;
|
||||||
virtual void adjustPlayer(shared_ptr<Player> player);
|
virtual void adjustPlayer(std::shared_ptr<Player> player);
|
||||||
virtual bool useItem(shared_ptr<Player> player, Level *level, shared_ptr<ItemInstance> item, bool bTestUseOnly=false);
|
virtual bool useItem(std::shared_ptr<Player> player, Level *level, std::shared_ptr<ItemInstance> item, bool bTestUseOnly=false);
|
||||||
virtual bool useItemOn(shared_ptr<Player> player, Level *level, shared_ptr<ItemInstance> item, int x, int y, int z, int face, bool bTestUseOnOnly=false, bool *pbUsedItem = NULL) = 0;
|
virtual bool useItemOn(std::shared_ptr<Player> player, Level *level, std::shared_ptr<ItemInstance> item, int x, int y, int z, int face, bool bTestUseOnOnly=false, bool *pbUsedItem = NULL) = 0;
|
||||||
|
|
||||||
virtual shared_ptr<Player> createPlayer(Level *level);
|
virtual std::shared_ptr<Player> createPlayer(Level *level);
|
||||||
virtual bool interact(shared_ptr<Player> player, shared_ptr<Entity> entity);
|
virtual bool interact(std::shared_ptr<Player> player, std::shared_ptr<Entity> entity);
|
||||||
virtual void attack(shared_ptr<Player> player, shared_ptr<Entity> entity);
|
virtual void attack(std::shared_ptr<Player> player, std::shared_ptr<Entity> entity);
|
||||||
virtual shared_ptr<ItemInstance> handleInventoryMouseClick(int containerId, int slotNum, int buttonNum, bool quickKeyHeld, shared_ptr<Player> player);
|
virtual std::shared_ptr<ItemInstance> handleInventoryMouseClick(int containerId, int slotNum, int buttonNum, bool quickKeyHeld, std::shared_ptr<Player> player);
|
||||||
virtual void handleCloseInventory(int containerId, shared_ptr<Player> player);
|
virtual void handleCloseInventory(int containerId, std::shared_ptr<Player> player);
|
||||||
virtual void handleInventoryButtonClick(int containerId, int buttonId);
|
virtual void handleInventoryButtonClick(int containerId, int buttonId);
|
||||||
|
|
||||||
virtual bool isCutScene();
|
virtual bool isCutScene();
|
||||||
virtual void releaseUsingItem(shared_ptr<Player> player);
|
virtual void releaseUsingItem(std::shared_ptr<Player> player);
|
||||||
virtual bool hasExperience();
|
virtual bool hasExperience();
|
||||||
virtual bool hasMissTime();
|
virtual bool hasMissTime();
|
||||||
virtual bool hasInfiniteItems();
|
virtual bool hasInfiniteItems();
|
||||||
virtual bool hasFarPickRange();
|
virtual bool hasFarPickRange();
|
||||||
virtual void handleCreativeModeItemAdd(shared_ptr<ItemInstance> clicked, int i);
|
virtual void handleCreativeModeItemAdd(std::shared_ptr<ItemInstance> clicked, int i);
|
||||||
virtual void handleCreativeModeItemDrop(shared_ptr<ItemInstance> clicked);
|
virtual void handleCreativeModeItemDrop(std::shared_ptr<ItemInstance> clicked);
|
||||||
|
|
||||||
// 4J Stu - Added so we can send packets for this in the network game
|
// 4J Stu - Added so we can send packets for this in the network game
|
||||||
virtual bool handleCraftItem(int recipe, shared_ptr<Player> player);
|
virtual bool handleCraftItem(int recipe, std::shared_ptr<Player> player);
|
||||||
virtual void handleDebugOptions(unsigned int uiVal, shared_ptr<Player> player);
|
virtual void handleDebugOptions(unsigned int uiVal, std::shared_ptr<Player> player);
|
||||||
|
|
||||||
// 4J Stu - Added for tutorial checks
|
// 4J Stu - Added for tutorial checks
|
||||||
virtual bool isInputAllowed(int mapping) { return true; }
|
virtual bool isInputAllowed(int mapping) { return true; }
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ const Options::Option *Options::Option::getItem(int id)
|
|||||||
return &options[id];
|
return &options[id];
|
||||||
}
|
}
|
||||||
|
|
||||||
Options::Option::Option(const wstring& captionId, bool hasProgress, bool isBoolean) : _isProgress(hasProgress), _isBoolean(isBoolean), captionId(captionId)
|
Options::Option::Option(const std::wstring& captionId, bool hasProgress, bool isBoolean) : _isProgress(hasProgress), _isBoolean(isBoolean), captionId(captionId)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -79,29 +79,29 @@ int Options::Option::getId() const
|
|||||||
return (int)(this-options);
|
return (int)(this-options);
|
||||||
}
|
}
|
||||||
|
|
||||||
wstring Options::Option::getCaptionId() const
|
std::wstring Options::Option::getCaptionId() const
|
||||||
{
|
{
|
||||||
return captionId;
|
return captionId;
|
||||||
}
|
}
|
||||||
|
|
||||||
const wstring Options::RENDER_DISTANCE_NAMES[] =
|
const std::wstring Options::RENDER_DISTANCE_NAMES[] =
|
||||||
{
|
{
|
||||||
L"options.renderDistance.far", L"options.renderDistance.normal", L"options.renderDistance.short", L"options.renderDistance.tiny"
|
L"options.renderDistance.far", L"options.renderDistance.normal", L"options.renderDistance.short", L"options.renderDistance.tiny"
|
||||||
};
|
};
|
||||||
const wstring Options::DIFFICULTY_NAMES[] =
|
const std::wstring Options::DIFFICULTY_NAMES[] =
|
||||||
{
|
{
|
||||||
L"options.difficulty.peaceful", L"options.difficulty.easy", L"options.difficulty.normal", L"options.difficulty.hard"
|
L"options.difficulty.peaceful", L"options.difficulty.easy", L"options.difficulty.normal", L"options.difficulty.hard"
|
||||||
};
|
};
|
||||||
const wstring Options::GUI_SCALE[] =
|
const std::wstring Options::GUI_SCALE[] =
|
||||||
{
|
{
|
||||||
L"options.guiScale.auto", L"options.guiScale.small", L"options.guiScale.normal", L"options.guiScale.large"
|
L"options.guiScale.auto", L"options.guiScale.small", L"options.guiScale.normal", L"options.guiScale.large"
|
||||||
};
|
};
|
||||||
const wstring Options::FRAMERATE_LIMITS[] =
|
const std::wstring Options::FRAMERATE_LIMITS[] =
|
||||||
{
|
{
|
||||||
L"performance.max", L"performance.balanced", L"performance.powersaver"
|
L"performance.max", L"performance.balanced", L"performance.powersaver"
|
||||||
};
|
};
|
||||||
|
|
||||||
const wstring Options::PARTICLES[] = {
|
const std::wstring Options::PARTICLES[] = {
|
||||||
L"options.particles.all", L"options.particles.decreased", L"options.particles.minimal"
|
L"options.particles.all", L"options.particles.decreased", L"options.particles.minimal"
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -184,13 +184,13 @@ Options::Options()
|
|||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
wstring Options::getKeyDescription(int i)
|
std::wstring Options::getKeyDescription(int i)
|
||||||
{
|
{
|
||||||
Language *language = Language::getInstance();
|
Language *language = Language::getInstance();
|
||||||
return language->getElement(keyMappings[i]->name);
|
return language->getElement(keyMappings[i]->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
wstring Options::getKeyMessage(int i)
|
std::wstring Options::getKeyMessage(int i)
|
||||||
{
|
{
|
||||||
int key = keyMappings[i]->key;
|
int key = keyMappings[i]->key;
|
||||||
if (key < 0) {
|
if (key < 0) {
|
||||||
@@ -307,12 +307,12 @@ bool Options::getBooleanValue(const Options::Option *item)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
wstring Options::getMessage(const Options::Option *item)
|
std::wstring Options::getMessage(const Options::Option *item)
|
||||||
{
|
{
|
||||||
// 4J TODO, should these wstrings append rather than add?
|
// 4J TODO, should these std::wstrings append rather than add?
|
||||||
|
|
||||||
Language *language = Language::getInstance();
|
Language *language = Language::getInstance();
|
||||||
wstring caption = language->getElement(item->getCaptionId()) + L": ";
|
std::wstring caption = language->getElement(item->getCaptionId()) + L": ";
|
||||||
|
|
||||||
if (item->isProgress())
|
if (item->isProgress())
|
||||||
{
|
{
|
||||||
@@ -411,14 +411,14 @@ void Options::load()
|
|||||||
// 4J - was new BufferedReader(new FileReader(optionsFile));
|
// 4J - was new BufferedReader(new FileReader(optionsFile));
|
||||||
BufferedReader *br = new BufferedReader(new InputStreamReader( new FileInputStream( optionsFile ) ) );
|
BufferedReader *br = new BufferedReader(new InputStreamReader( new FileInputStream( optionsFile ) ) );
|
||||||
|
|
||||||
wstring line = L"";
|
std::wstring line = L"";
|
||||||
while ((line = br->readLine()) != L"") // 4J - was check against NULL - do we need to distinguish between empty lines and a fail here?
|
while ((line = br->readLine()) != L"") // 4J - was check against NULL - do we need to distinguish between empty lines and a fail here?
|
||||||
{
|
{
|
||||||
// 4J - removed try/catch
|
// 4J - removed try/catch
|
||||||
// try {
|
// try {
|
||||||
wstring cmds[2];
|
std::wstring cmds[2];
|
||||||
int splitpos = (int)line.find(L":");
|
int splitpos = (int)line.find(L":");
|
||||||
if( splitpos == wstring::npos )
|
if( splitpos == std::wstring::npos )
|
||||||
{
|
{
|
||||||
cmds[0] = line;
|
cmds[0] = line;
|
||||||
cmds[1] = L"";
|
cmds[1] = L"";
|
||||||
@@ -469,7 +469,7 @@ void Options::load()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
float Options::readFloat(wstring string)
|
float Options::readFloat(std::wstring string)
|
||||||
{
|
{
|
||||||
if (string == L"true") return 1;
|
if (string == L"true") return 1;
|
||||||
if (string == L"false") return 0;
|
if (string == L"false") return 0;
|
||||||
@@ -488,20 +488,20 @@ void Options::save()
|
|||||||
|
|
||||||
dos.writeChars(L"music:" + _toString<float>(music) + L"\n");
|
dos.writeChars(L"music:" + _toString<float>(music) + L"\n");
|
||||||
dos.writeChars(L"sound:" + _toString<float>(sound) + L"\n");
|
dos.writeChars(L"sound:" + _toString<float>(sound) + L"\n");
|
||||||
dos.writeChars(L"invertYMouse:" + wstring(invertYMouse ? L"true" : L"false") + L"\n");
|
dos.writeChars(L"invertYMouse:" + std::wstring(invertYMouse ? L"true" : L"false") + L"\n");
|
||||||
dos.writeChars(L"mouseSensitivity:" + _toString<float>(sensitivity));
|
dos.writeChars(L"mouseSensitivity:" + _toString<float>(sensitivity));
|
||||||
dos.writeChars(L"fov:" + _toString<float>(fov));
|
dos.writeChars(L"fov:" + _toString<float>(fov));
|
||||||
dos.writeChars(L"gamma:" + _toString<float>(gamma));
|
dos.writeChars(L"gamma:" + _toString<float>(gamma));
|
||||||
dos.writeChars(L"viewDistance:" + _toString<int>(viewDistance));
|
dos.writeChars(L"viewDistance:" + _toString<int>(viewDistance));
|
||||||
dos.writeChars(L"guiScale:" + _toString<int>(guiScale));
|
dos.writeChars(L"guiScale:" + _toString<int>(guiScale));
|
||||||
dos.writeChars(L"particles:" + _toString<int>(particles));
|
dos.writeChars(L"particles:" + _toString<int>(particles));
|
||||||
dos.writeChars(L"bobView:" + wstring(bobView ? L"true" : L"false"));
|
dos.writeChars(L"bobView:" + std::wstring(bobView ? L"true" : L"false"));
|
||||||
dos.writeChars(L"anaglyph3d:" + wstring(anaglyph3d ? L"true" : L"false"));
|
dos.writeChars(L"anaglyph3d:" + std::wstring(anaglyph3d ? L"true" : L"false"));
|
||||||
dos.writeChars(L"advancedOpengl:" + wstring(advancedOpengl ? L"true" : L"false"));
|
dos.writeChars(L"advancedOpengl:" + std::wstring(advancedOpengl ? L"true" : L"false"));
|
||||||
dos.writeChars(L"fpsLimit:" + _toString<int>(framerateLimit));
|
dos.writeChars(L"fpsLimit:" + _toString<int>(framerateLimit));
|
||||||
dos.writeChars(L"difficulty:" + _toString<int>(difficulty));
|
dos.writeChars(L"difficulty:" + _toString<int>(difficulty));
|
||||||
dos.writeChars(L"fancyGraphics:" + wstring(fancyGraphics ? L"true" : L"false"));
|
dos.writeChars(L"fancyGraphics:" + std::wstring(fancyGraphics ? L"true" : L"false"));
|
||||||
dos.writeChars(L"ao:" + wstring(ambientOcclusion ? L"true" : L"false"));
|
dos.writeChars(L"ao:" + std::wstring(ambientOcclusion ? L"true" : L"false"));
|
||||||
dos.writeChars(L"clouds:" + _toString<bool>(renderClouds));
|
dos.writeChars(L"clouds:" + _toString<bool>(renderClouds));
|
||||||
dos.writeChars(L"skin:" + skin);
|
dos.writeChars(L"skin:" + skin);
|
||||||
dos.writeChars(L"lastServer:" + lastMpIp);
|
dos.writeChars(L"lastServer:" + lastMpIp);
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
using namespace std;
|
|
||||||
class Minecraft;
|
class Minecraft;
|
||||||
class KeyMapping;
|
class KeyMapping;
|
||||||
#include "../../Minecraft.World/IO/Files/File.h"
|
#include "../../Minecraft.World/IO/Files/File.h"
|
||||||
@@ -37,24 +37,24 @@ public:
|
|||||||
private:
|
private:
|
||||||
const bool _isProgress;
|
const bool _isProgress;
|
||||||
const bool _isBoolean;
|
const bool _isBoolean;
|
||||||
const wstring captionId;
|
const std::wstring captionId;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static const Option *getItem(int id);
|
static const Option *getItem(int id);
|
||||||
|
|
||||||
Option(const wstring& captionId, bool hasProgress, bool isBoolean);
|
Option(const std::wstring& captionId, bool hasProgress, bool isBoolean);
|
||||||
bool isProgress() const;
|
bool isProgress() const;
|
||||||
bool isBoolean() const;
|
bool isBoolean() const;
|
||||||
int getId() const;
|
int getId() const;
|
||||||
wstring getCaptionId() const;
|
std::wstring getCaptionId() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static const wstring RENDER_DISTANCE_NAMES[];
|
static const std::wstring RENDER_DISTANCE_NAMES[];
|
||||||
static const wstring DIFFICULTY_NAMES[];
|
static const std::wstring DIFFICULTY_NAMES[];
|
||||||
static const wstring GUI_SCALE[];
|
static const std::wstring GUI_SCALE[];
|
||||||
static const wstring FRAMERATE_LIMITS[];
|
static const std::wstring FRAMERATE_LIMITS[];
|
||||||
static const wstring PARTICLES[];
|
static const std::wstring PARTICLES[];
|
||||||
|
|
||||||
public:
|
public:
|
||||||
float music;
|
float music;
|
||||||
@@ -69,7 +69,7 @@ public:
|
|||||||
bool fancyGraphics;
|
bool fancyGraphics;
|
||||||
bool ambientOcclusion;
|
bool ambientOcclusion;
|
||||||
bool renderClouds;
|
bool renderClouds;
|
||||||
wstring skin;
|
std::wstring skin;
|
||||||
|
|
||||||
KeyMapping *keyUp;
|
KeyMapping *keyUp;
|
||||||
KeyMapping *keyLeft;
|
KeyMapping *keyLeft;
|
||||||
@@ -99,7 +99,7 @@ public:
|
|||||||
bool hideGui;
|
bool hideGui;
|
||||||
bool thirdPersonView;
|
bool thirdPersonView;
|
||||||
bool renderDebug;
|
bool renderDebug;
|
||||||
wstring lastMpIp;
|
std::wstring lastMpIp;
|
||||||
|
|
||||||
bool isFlying;
|
bool isFlying;
|
||||||
bool smoothCamera;
|
bool smoothCamera;
|
||||||
@@ -114,17 +114,17 @@ public:
|
|||||||
void init(); // 4J added
|
void init(); // 4J added
|
||||||
Options(Minecraft *minecraft, File workingDirectory);
|
Options(Minecraft *minecraft, File workingDirectory);
|
||||||
Options();
|
Options();
|
||||||
wstring getKeyDescription(int i);
|
std::wstring getKeyDescription(int i);
|
||||||
wstring getKeyMessage(int i);
|
std::wstring getKeyMessage(int i);
|
||||||
void setKey(int i, int key);
|
void setKey(int i, int key);
|
||||||
void set(const Options::Option *item, float value);
|
void set(const Options::Option *item, float value);
|
||||||
void toggle(const Options::Option *option, int dir);
|
void toggle(const Options::Option *option, int dir);
|
||||||
float getProgressValue(const Options::Option *item);
|
float getProgressValue(const Options::Option *item);
|
||||||
bool getBooleanValue(const Options::Option *item);
|
bool getBooleanValue(const Options::Option *item);
|
||||||
wstring getMessage(const Options::Option *item);
|
std::wstring getMessage(const Options::Option *item);
|
||||||
void load();
|
void load();
|
||||||
private:
|
private:
|
||||||
float readFloat(wstring string);
|
float readFloat(std::wstring string);
|
||||||
public:
|
public:
|
||||||
void save();
|
void save();
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ void Settings::saveProperties()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
wstring Settings::getString(const wstring& key, const wstring& defaultValue)
|
std::wstring Settings::getString(const std::wstring& key, const std::wstring& defaultValue)
|
||||||
{
|
{
|
||||||
if(properties.find(key) == properties.end())
|
if(properties.find(key) == properties.end())
|
||||||
{
|
{
|
||||||
@@ -25,7 +25,7 @@ wstring Settings::getString(const wstring& key, const wstring& defaultValue)
|
|||||||
return properties[key];
|
return properties[key];
|
||||||
}
|
}
|
||||||
|
|
||||||
int Settings::getInt(const wstring& key, int defaultValue)
|
int Settings::getInt(const std::wstring& key, int defaultValue)
|
||||||
{
|
{
|
||||||
if(properties.find(key) == properties.end())
|
if(properties.find(key) == properties.end())
|
||||||
{
|
{
|
||||||
@@ -35,7 +35,7 @@ int Settings::getInt(const wstring& key, int defaultValue)
|
|||||||
return _fromString<int>(properties[key]);
|
return _fromString<int>(properties[key]);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Settings::getBoolean(const wstring& key, bool defaultValue)
|
bool Settings::getBoolean(const std::wstring& key, bool defaultValue)
|
||||||
{
|
{
|
||||||
if(properties.find(key) == properties.end())
|
if(properties.find(key) == properties.end())
|
||||||
{
|
{
|
||||||
@@ -48,7 +48,7 @@ bool Settings::getBoolean(const wstring& key, bool defaultValue)
|
|||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Settings::setBooleanAndSave(const wstring& key, bool value)
|
void Settings::setBooleanAndSave(const std::wstring& key, bool value)
|
||||||
{
|
{
|
||||||
properties[key] = _toString<bool>(value);
|
properties[key] = _toString<bool>(value);
|
||||||
saveProperties();
|
saveProperties();
|
||||||
|
|||||||
@@ -1,21 +1,21 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
class File;
|
class File;
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
class Settings
|
class Settings
|
||||||
{
|
{
|
||||||
// public static Logger logger = Logger.getLogger("Minecraft");
|
// public static Logger logger = Logger.getLogger("Minecraft");
|
||||||
// private Properties properties = new Properties();
|
// private Properties properties = new Properties();
|
||||||
private:
|
private:
|
||||||
unordered_map<wstring,wstring> properties; // 4J - TODO was Properties type, will need to implement something we can serialise/deserialise too
|
std::unordered_map<std::wstring,std::wstring> properties; // 4J - TODO was Properties type, will need to implement something we can serialise/deserialise too
|
||||||
//File *file;
|
//File *file;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Settings(File *file);
|
Settings(File *file);
|
||||||
void generateNewProperties();
|
void generateNewProperties();
|
||||||
void saveProperties();
|
void saveProperties();
|
||||||
wstring getString(const wstring& key, const wstring& defaultValue);
|
std::wstring getString(const std::wstring& key, const std::wstring& defaultValue);
|
||||||
int getInt(const wstring& key, int defaultValue);
|
int getInt(const std::wstring& key, int defaultValue);
|
||||||
bool getBoolean(const wstring& key, bool defaultValue);
|
bool getBoolean(const std::wstring& key, bool defaultValue);
|
||||||
void setBooleanAndSave(const wstring& key, bool value);
|
void setBooleanAndSave(const std::wstring& key, bool value);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ Stat** StatsCounter::LARGE_STATS[] = {
|
|||||||
&Stats::timePlayed
|
&Stats::timePlayed
|
||||||
};
|
};
|
||||||
|
|
||||||
unordered_map<Stat*, int> StatsCounter::statBoards;
|
std::unordered_map<Stat*, int> StatsCounter::statBoards;
|
||||||
|
|
||||||
StatsCounter::StatsCounter()
|
StatsCounter::StatsCounter()
|
||||||
{
|
{
|
||||||
@@ -64,7 +64,7 @@ void StatsCounter::award(Stat* stat, unsigned int difficulty, unsigned int count
|
|||||||
requiresSave = true;
|
requiresSave = true;
|
||||||
|
|
||||||
//If this stat is on a leaderboard, mark that leaderboard as needing updated
|
//If this stat is on a leaderboard, mark that leaderboard as needing updated
|
||||||
unordered_map<Stat*, int>::iterator leaderboardEntry = statBoards.find(stat);
|
std::unordered_map<Stat*, int>::iterator leaderboardEntry = statBoards.find(stat);
|
||||||
if( leaderboardEntry != statBoards.end() )
|
if( leaderboardEntry != statBoards.end() )
|
||||||
{
|
{
|
||||||
app.DebugPrintf("[StatsCounter] award(): %X\n", leaderboardEntry->second << difficulty);
|
app.DebugPrintf("[StatsCounter] award(): %X\n", leaderboardEntry->second << difficulty);
|
||||||
@@ -150,8 +150,8 @@ void StatsCounter::parse(void* data)
|
|||||||
StatContainer newVal;
|
StatContainer newVal;
|
||||||
|
|
||||||
//For each stat
|
//For each stat
|
||||||
vector<Stat *>::iterator end = Stats::all->end();
|
std::vector<Stat *>::iterator end = Stats::all->end();
|
||||||
for( vector<Stat *>::iterator iter = Stats::all->begin() ; iter != end ; ++iter )
|
for( std::vector<Stat *>::iterator iter = Stats::all->begin() ; iter != end ; ++iter )
|
||||||
{
|
{
|
||||||
if( !(*iter)->isAchievement() )
|
if( !(*iter)->isAchievement() )
|
||||||
{
|
{
|
||||||
@@ -230,8 +230,8 @@ void StatsCounter::save(int player, bool force)
|
|||||||
|
|
||||||
//For each stat
|
//For each stat
|
||||||
StatsMap::iterator val;
|
StatsMap::iterator val;
|
||||||
vector<Stat *>::iterator end = Stats::all->end();
|
std::vector<Stat *>::iterator end = Stats::all->end();
|
||||||
for( vector<Stat *>::iterator iter = Stats::all->begin() ; iter != end ; ++iter )
|
for( std::vector<Stat *>::iterator iter = Stats::all->begin() ; iter != end ; ++iter )
|
||||||
{
|
{
|
||||||
//If the stat is in the map write out it's value
|
//If the stat is in the map write out it's value
|
||||||
val = stats.find(*iter);
|
val = stats.find(*iter);
|
||||||
@@ -1283,8 +1283,8 @@ bool StatsCounter::isLargeStat(Stat* stat)
|
|||||||
|
|
||||||
void StatsCounter::dumpStatsToTTY()
|
void StatsCounter::dumpStatsToTTY()
|
||||||
{
|
{
|
||||||
vector<Stat*>::iterator statsEnd = Stats::all->end();
|
std::vector<Stat*>::iterator statsEnd = Stats::all->end();
|
||||||
for( vector<Stat*>::iterator statsIter = Stats::all->begin() ; statsIter!=statsEnd ; ++statsIter )
|
for( std::vector<Stat*>::iterator statsIter = Stats::all->begin() ; statsIter!=statsEnd ; ++statsIter )
|
||||||
{
|
{
|
||||||
app.DebugPrintf("%ls\t\t%u\t%u\t%u\t%u\n",
|
app.DebugPrintf("%ls\t\t%u\t%u\t%u\t%u\n",
|
||||||
(*statsIter)->name.c_str(),
|
(*statsIter)->name.c_str(),
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ class Stat;
|
|||||||
class Achievement;
|
class Achievement;
|
||||||
class StatsSyncher;
|
class StatsSyncher;
|
||||||
class User;
|
class User;
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
class StatsCounter
|
class StatsCounter
|
||||||
{
|
{
|
||||||
@@ -28,7 +28,7 @@ private:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef unordered_map<Stat*, StatContainer> StatsMap;
|
typedef std::unordered_map<Stat*, StatContainer> StatsMap;
|
||||||
|
|
||||||
//static const int STAT_DATA_OFFSET = 32;
|
//static const int STAT_DATA_OFFSET = 32;
|
||||||
static const int LARGE_STATS_COUNT = 8;
|
static const int LARGE_STATS_COUNT = 8;
|
||||||
@@ -69,7 +69,7 @@ private:
|
|||||||
int saveCounter;
|
int saveCounter;
|
||||||
|
|
||||||
int modifiedBoards;
|
int modifiedBoards;
|
||||||
static unordered_map<Stat*, int> statBoards;
|
static std::unordered_map<Stat*, int> statBoards;
|
||||||
int flushCounter;
|
int flushCounter;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ class StatsCounter;
|
|||||||
class User;
|
class User;
|
||||||
class File;
|
class File;
|
||||||
class Stat;
|
class Stat;
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
class StatsSyncher
|
class StatsSyncher
|
||||||
{
|
{
|
||||||
@@ -14,8 +14,8 @@ private:
|
|||||||
|
|
||||||
volatile bool busy;
|
volatile bool busy;
|
||||||
|
|
||||||
volatile unordered_map<Stat *, int> *serverStats;
|
volatile std::unordered_map<Stat *, int> *serverStats;
|
||||||
volatile unordered_map<Stat *, int> *failedSentStats;
|
volatile std::unordered_map<Stat *, int> *failedSentStats;
|
||||||
|
|
||||||
StatsCounter *statsCounter;
|
StatsCounter *statsCounter;
|
||||||
File *unsentFile, *lastServerFile;
|
File *unsentFile, *lastServerFile;
|
||||||
@@ -28,19 +28,19 @@ private:
|
|||||||
public:
|
public:
|
||||||
StatsSyncher(User *user, StatsCounter *statsCounter, File *dir);
|
StatsSyncher(User *user, StatsCounter *statsCounter, File *dir);
|
||||||
private:
|
private:
|
||||||
void attemptRename(File *dir, const wstring& name, File *to);
|
void attemptRename(File *dir, const std::wstring& name, File *to);
|
||||||
unordered_map<Stat *, int> *loadStatsFromDisk(File *file, File *tmp, File *old);
|
std::unordered_map<Stat *, int> *loadStatsFromDisk(File *file, File *tmp, File *old);
|
||||||
unordered_map<Stat *, int> *loadStatsFromDisk(File *file);
|
std::unordered_map<Stat *, int> *loadStatsFromDisk(File *file);
|
||||||
void doSend(unordered_map<Stat *, int> *stats);
|
void doSend(std::unordered_map<Stat *, int> *stats);
|
||||||
void doSave(unordered_map<Stat *, int> *stats, File *file, File *tmp, File *old);
|
void doSave(std::unordered_map<Stat *, int> *stats, File *file, File *tmp, File *old);
|
||||||
protected:
|
protected:
|
||||||
unordered_map<Stat *, int> *doGetStats();
|
std::unordered_map<Stat *, int> *doGetStats();
|
||||||
public:
|
public:
|
||||||
void getStatsFromServer();
|
void getStatsFromServer();
|
||||||
void saveUnsent(unordered_map<Stat *, int> *stats);
|
void saveUnsent(std::unordered_map<Stat *, int> *stats);
|
||||||
void sendUnsent(unordered_map<Stat *, int> *stats, unordered_map<Stat *, int> *fullStats);
|
void sendUnsent(std::unordered_map<Stat *, int> *stats, std::unordered_map<Stat *, int> *fullStats);
|
||||||
void forceSendUnsent(unordered_map<Stat *, int> *stats);
|
void forceSendUnsent(std::unordered_map<Stat *, int> *stats);
|
||||||
void forceSaveUnsent(unordered_map<Stat *, int> *stats);
|
void forceSaveUnsent(std::unordered_map<Stat *, int> *stats);
|
||||||
bool maySave();
|
bool maySave();
|
||||||
bool maySend();
|
bool maySend();
|
||||||
void tick();
|
void tick();
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ SurvivalMode::SurvivalMode(SurvivalMode *copy) : GameMode( copy->minecraft )
|
|||||||
destroyDelay = copy->destroyDelay;
|
destroyDelay = copy->destroyDelay;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SurvivalMode::initPlayer(shared_ptr<Player> player)
|
void SurvivalMode::initPlayer(std::shared_ptr<Player> player)
|
||||||
{
|
{
|
||||||
player->yRot = -180;
|
player->yRot = -180;
|
||||||
}
|
}
|
||||||
@@ -65,7 +65,7 @@ bool SurvivalMode::destroyBlock(int x, int y, int z, int face)
|
|||||||
int data = minecraft->level->getData(x, y, z);
|
int data = minecraft->level->getData(x, y, z);
|
||||||
bool changed = GameMode::destroyBlock(x, y, z, face);
|
bool changed = GameMode::destroyBlock(x, y, z, face);
|
||||||
|
|
||||||
shared_ptr<ItemInstance> item = minecraft->player->getSelectedItem();
|
std::shared_ptr<ItemInstance> item = minecraft->player->getSelectedItem();
|
||||||
bool couldDestroy = minecraft->player->canDestroy(Tile::tiles[t]);
|
bool couldDestroy = minecraft->player->canDestroy(Tile::tiles[t]);
|
||||||
if (item != NULL)
|
if (item != NULL)
|
||||||
{
|
{
|
||||||
@@ -173,9 +173,9 @@ void SurvivalMode::initLevel(Level *level)
|
|||||||
GameMode::initLevel(level);
|
GameMode::initLevel(level);
|
||||||
}
|
}
|
||||||
|
|
||||||
shared_ptr<Player> SurvivalMode::createPlayer(Level *level)
|
std::shared_ptr<Player> SurvivalMode::createPlayer(Level *level)
|
||||||
{
|
{
|
||||||
shared_ptr<Player> player = GameMode::createPlayer(level);
|
std::shared_ptr<Player> player = GameMode::createPlayer(level);
|
||||||
// player.inventory.add(new ItemInstance(Item.pickAxe_diamond));
|
// player.inventory.add(new ItemInstance(Item.pickAxe_diamond));
|
||||||
// player.inventory.add(new ItemInstance(Item.hatchet_diamond));
|
// player.inventory.add(new ItemInstance(Item.hatchet_diamond));
|
||||||
// player.inventory.add(new ItemInstance(Tile.torch, 64));
|
// player.inventory.add(new ItemInstance(Tile.torch, 64));
|
||||||
@@ -191,7 +191,7 @@ void SurvivalMode::tick()
|
|||||||
//minecraft->soundEngine->playMusicTick();
|
//minecraft->soundEngine->playMusicTick();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SurvivalMode::useItemOn(shared_ptr<Player> player, Level *level, shared_ptr<ItemInstance> item, int x, int y, int z, int face, bool bTestUseOnOnly, bool *pbUsedItem)
|
bool SurvivalMode::useItemOn(std::shared_ptr<Player> player, Level *level, std::shared_ptr<ItemInstance> item, int x, int y, int z, int face, bool bTestUseOnOnly, bool *pbUsedItem)
|
||||||
{
|
{
|
||||||
int t = level->getTile(x, y, z);
|
int t = level->getTile(x, y, z);
|
||||||
if (t > 0)
|
if (t > 0)
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ private:
|
|||||||
public:
|
public:
|
||||||
SurvivalMode(Minecraft *minecraft);
|
SurvivalMode(Minecraft *minecraft);
|
||||||
SurvivalMode(SurvivalMode *copy);
|
SurvivalMode(SurvivalMode *copy);
|
||||||
virtual void initPlayer(shared_ptr<Player> player);
|
virtual void initPlayer(std::shared_ptr<Player> player);
|
||||||
virtual void init();
|
virtual void init();
|
||||||
virtual bool canHurtPlayer();
|
virtual bool canHurtPlayer();
|
||||||
virtual bool destroyBlock(int x, int y, int z, int face);
|
virtual bool destroyBlock(int x, int y, int z, int face);
|
||||||
@@ -25,8 +25,8 @@ public:
|
|||||||
virtual void render(float a);
|
virtual void render(float a);
|
||||||
virtual float getPickRange();
|
virtual float getPickRange();
|
||||||
virtual void initLevel(Level *level);
|
virtual void initLevel(Level *level);
|
||||||
virtual shared_ptr<Player> createPlayer(Level *level);
|
virtual std::shared_ptr<Player> createPlayer(Level *level);
|
||||||
virtual void tick();
|
virtual void tick();
|
||||||
virtual bool useItemOn(shared_ptr<Player> player, Level *level, shared_ptr<ItemInstance> item, int x, int y, int z, int face, bool bTestUseOnOnly=false, bool *pbUsedItem=NULL);
|
virtual bool useItemOn(std::shared_ptr<Player> player, Level *level, std::shared_ptr<ItemInstance> item, int x, int y, int z, int face, bool bTestUseOnOnly=false, bool *pbUsedItem=NULL);
|
||||||
virtual bool hasExperience();
|
virtual bool hasExperience();
|
||||||
};
|
};
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
#include "../Build/stdafx.h"
|
#include "../Build/stdafx.h"
|
||||||
#include "ConsoleInput.h"
|
#include "ConsoleInput.h"
|
||||||
|
|
||||||
ConsoleInput::ConsoleInput(const wstring& msg, ConsoleInputSource *source)
|
ConsoleInput::ConsoleInput(const std::wstring& msg, ConsoleInputSource *source)
|
||||||
{
|
{
|
||||||
this->msg = msg;
|
this->msg = msg;
|
||||||
this->source = source;
|
this->source = source;
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "ConsoleInputSource.h"
|
#include "ConsoleInputSource.h"
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
class ConsoleInput
|
class ConsoleInput
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
wstring msg;
|
std::wstring msg;
|
||||||
ConsoleInputSource *source;
|
ConsoleInputSource *source;
|
||||||
|
|
||||||
ConsoleInput(const wstring& msg, ConsoleInputSource *source);
|
ConsoleInput(const std::wstring& msg, ConsoleInputSource *source);
|
||||||
};
|
};
|
||||||
@@ -3,7 +3,7 @@
|
|||||||
class ConsoleInputSource
|
class ConsoleInputSource
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual void info(const wstring& string) = 0;
|
virtual void info(const std::wstring& string) = 0;
|
||||||
virtual void warn(const wstring& string) = 0;
|
virtual void warn(const std::wstring& string) = 0;
|
||||||
virtual wstring getConsoleName() = 0;
|
virtual std::wstring getConsoleName() = 0;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#include "../Build/stdafx.h"
|
#include "../Build/stdafx.h"
|
||||||
#include "KeyMapping.h"
|
#include "KeyMapping.h"
|
||||||
|
|
||||||
KeyMapping::KeyMapping(const wstring& name, int key)
|
KeyMapping::KeyMapping(const std::wstring& name, int key)
|
||||||
{
|
{
|
||||||
this->name = name;
|
this->name = name;
|
||||||
this->key = key;
|
this->key = key;
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
using namespace std;
|
|
||||||
// 4J Stu - Not updated to 1.8.2 as we don't use this
|
// 4J Stu - Not updated to 1.8.2 as we don't use this
|
||||||
class KeyMapping
|
class KeyMapping
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
wstring name;
|
std::wstring name;
|
||||||
int key;
|
int key;
|
||||||
KeyMapping(const wstring& name, int key);
|
KeyMapping(const std::wstring& name, int key);
|
||||||
};
|
};
|
||||||
@@ -11,7 +11,7 @@ LevelSettings DemoLevel::DEMO_LEVEL_SETTINGS = LevelSettings(
|
|||||||
1.0
|
1.0
|
||||||
);
|
);
|
||||||
|
|
||||||
DemoLevel::DemoLevel(shared_ptr<LevelStorage> levelStorage, const wstring& levelName) : Level(levelStorage, levelName, &DEMO_LEVEL_SETTINGS)
|
DemoLevel::DemoLevel(std::shared_ptr<LevelStorage> levelStorage, const std::wstring& levelName) : Level(levelStorage, levelName, &DEMO_LEVEL_SETTINGS)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ private:
|
|||||||
static const int DEMO_SPAWN_Z = -731;
|
static const int DEMO_SPAWN_Z = -731;
|
||||||
static LevelSettings DEMO_LEVEL_SETTINGS;
|
static LevelSettings DEMO_LEVEL_SETTINGS;
|
||||||
public:
|
public:
|
||||||
DemoLevel(shared_ptr<LevelStorage> levelStorage, const wstring& levelName);
|
DemoLevel(std::shared_ptr<LevelStorage> levelStorage, const std::wstring& levelName);
|
||||||
DemoLevel(Level *level, Dimension *dimension);
|
DemoLevel(Level *level, Dimension *dimension);
|
||||||
protected:
|
protected:
|
||||||
virtual void setInitialSpawn();
|
virtual void setInitialSpawn();
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
#include "../../Minecraft.World/Level/Storage/SavedDataStorage.h"
|
#include "../../Minecraft.World/Level/Storage/SavedDataStorage.h"
|
||||||
#include "../../Minecraft.World/Level/DerivedLevelData.h"
|
#include "../../Minecraft.World/Level/DerivedLevelData.h"
|
||||||
|
|
||||||
DerivedServerLevel::DerivedServerLevel(MinecraftServer *server, shared_ptr<LevelStorage> levelStorage, const wstring& levelName, int dimension, LevelSettings *levelSettings, ServerLevel *wrapped)
|
DerivedServerLevel::DerivedServerLevel(MinecraftServer *server, std::shared_ptr<LevelStorage> levelStorage, const std::wstring& levelName, int dimension, LevelSettings *levelSettings, ServerLevel *wrapped)
|
||||||
: ServerLevel(server, levelStorage, levelName, dimension, levelSettings)
|
: ServerLevel(server, levelStorage, levelName, dimension, levelSettings)
|
||||||
{
|
{
|
||||||
// 4J-PB - we're going to override the savedDataStorage, so we need to delete the current one
|
// 4J-PB - we're going to override the savedDataStorage, so we need to delete the current one
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
class DerivedServerLevel : public ServerLevel
|
class DerivedServerLevel : public ServerLevel
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DerivedServerLevel(MinecraftServer *server, shared_ptr<LevelStorage>levelStorage, const wstring& levelName, int dimension, LevelSettings *levelSettings, ServerLevel *wrapped);
|
DerivedServerLevel(MinecraftServer *server, std::shared_ptr<LevelStorage>levelStorage, const std::wstring& levelName, int dimension, LevelSettings *levelSettings, ServerLevel *wrapped);
|
||||||
~DerivedServerLevel();
|
~DerivedServerLevel();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ MultiPlayerLevel::ResetInfo::ResetInfo(int x, int y, int z, int tile, int data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
MultiPlayerLevel::MultiPlayerLevel(ClientConnection *connection, LevelSettings *levelSettings, int dimension, int difficulty)
|
MultiPlayerLevel::MultiPlayerLevel(ClientConnection *connection, LevelSettings *levelSettings, int dimension, int difficulty)
|
||||||
: Level(shared_ptr<MockedLevelStorage >(new MockedLevelStorage()), L"MpServer", Dimension::getNew(dimension), levelSettings, false)
|
: Level(std::shared_ptr<MockedLevelStorage >(new MockedLevelStorage()), L"MpServer", Dimension::getNew(dimension), levelSettings, false)
|
||||||
{
|
{
|
||||||
minecraft = Minecraft::GetInstance();
|
minecraft = Minecraft::GetInstance();
|
||||||
|
|
||||||
@@ -108,7 +108,7 @@ void MultiPlayerLevel::tick()
|
|||||||
EnterCriticalSection(&m_entitiesCS);
|
EnterCriticalSection(&m_entitiesCS);
|
||||||
for (int i = 0; i < 10 && !reEntries.empty(); i++)
|
for (int i = 0; i < 10 && !reEntries.empty(); i++)
|
||||||
{
|
{
|
||||||
shared_ptr<Entity> e = *(reEntries.begin());
|
std::shared_ptr<Entity> e = *(reEntries.begin());
|
||||||
|
|
||||||
if (find(entities.begin(), entities.end(), e) == entities.end() ) addEntity(e);
|
if (find(entities.begin(), entities.end(), e) == entities.end() ) addEntity(e);
|
||||||
}
|
}
|
||||||
@@ -117,7 +117,7 @@ void MultiPlayerLevel::tick()
|
|||||||
|
|
||||||
PIXBeginNamedEvent(0,"Connection ticking");
|
PIXBeginNamedEvent(0,"Connection ticking");
|
||||||
// 4J HEG - Copy the connections vector to prevent crash when moving to Nether
|
// 4J HEG - Copy the connections vector to prevent crash when moving to Nether
|
||||||
vector<ClientConnection *> connectionsTemp = connections;
|
std::vector<ClientConnection *> connectionsTemp = connections;
|
||||||
for(AUTO_VAR(connection, connectionsTemp.begin()); connection < connectionsTemp.end(); ++connection )
|
for(AUTO_VAR(connection, connectionsTemp.begin()); connection < connectionsTemp.end(); ++connection )
|
||||||
{
|
{
|
||||||
(*connection)->tick();
|
(*connection)->tick();
|
||||||
@@ -403,7 +403,7 @@ void MultiPlayerLevel::setChunkVisible(int x, int z, bool visible)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MultiPlayerLevel::addEntity(shared_ptr<Entity> e)
|
bool MultiPlayerLevel::addEntity(std::shared_ptr<Entity> e)
|
||||||
{
|
{
|
||||||
bool ok = Level::addEntity(e);
|
bool ok = Level::addEntity(e);
|
||||||
forced.insert(e);
|
forced.insert(e);
|
||||||
@@ -416,7 +416,7 @@ bool MultiPlayerLevel::addEntity(shared_ptr<Entity> e)
|
|||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MultiPlayerLevel::removeEntity(shared_ptr<Entity> e)
|
void MultiPlayerLevel::removeEntity(std::shared_ptr<Entity> e)
|
||||||
{
|
{
|
||||||
// 4J Stu - Add this remove from the reEntries collection to stop us continually removing and re-adding things,
|
// 4J Stu - Add this remove from the reEntries collection to stop us continually removing and re-adding things,
|
||||||
// in particular the MultiPlayerLocalPlayer when they die
|
// in particular the MultiPlayerLocalPlayer when they die
|
||||||
@@ -430,7 +430,7 @@ void MultiPlayerLevel::removeEntity(shared_ptr<Entity> e)
|
|||||||
forced.erase(e);
|
forced.erase(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MultiPlayerLevel::entityAdded(shared_ptr<Entity> e)
|
void MultiPlayerLevel::entityAdded(std::shared_ptr<Entity> e)
|
||||||
{
|
{
|
||||||
Level::entityAdded(e);
|
Level::entityAdded(e);
|
||||||
AUTO_VAR(it, reEntries.find(e));
|
AUTO_VAR(it, reEntries.find(e));
|
||||||
@@ -440,7 +440,7 @@ void MultiPlayerLevel::entityAdded(shared_ptr<Entity> e)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MultiPlayerLevel::entityRemoved(shared_ptr<Entity> e)
|
void MultiPlayerLevel::entityRemoved(std::shared_ptr<Entity> e)
|
||||||
{
|
{
|
||||||
Level::entityRemoved(e);
|
Level::entityRemoved(e);
|
||||||
AUTO_VAR(it, forced.find(e));
|
AUTO_VAR(it, forced.find(e));
|
||||||
@@ -450,9 +450,9 @@ void MultiPlayerLevel::entityRemoved(shared_ptr<Entity> e)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MultiPlayerLevel::putEntity(int id, shared_ptr<Entity> e)
|
void MultiPlayerLevel::putEntity(int id, std::shared_ptr<Entity> e)
|
||||||
{
|
{
|
||||||
shared_ptr<Entity> old = getEntity(id);
|
std::shared_ptr<Entity> old = getEntity(id);
|
||||||
if (old != NULL)
|
if (old != NULL)
|
||||||
{
|
{
|
||||||
removeEntity(old);
|
removeEntity(old);
|
||||||
@@ -467,16 +467,16 @@ void MultiPlayerLevel::putEntity(int id, shared_ptr<Entity> e)
|
|||||||
entitiesById[id] = e;
|
entitiesById[id] = e;
|
||||||
}
|
}
|
||||||
|
|
||||||
shared_ptr<Entity> MultiPlayerLevel::getEntity(int id)
|
std::shared_ptr<Entity> MultiPlayerLevel::getEntity(int id)
|
||||||
{
|
{
|
||||||
AUTO_VAR(it, entitiesById.find(id));
|
AUTO_VAR(it, entitiesById.find(id));
|
||||||
if( it == entitiesById.end() ) return nullptr;
|
if( it == entitiesById.end() ) return nullptr;
|
||||||
return it->second;
|
return it->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
shared_ptr<Entity> MultiPlayerLevel::removeEntity(int id)
|
std::shared_ptr<Entity> MultiPlayerLevel::removeEntity(int id)
|
||||||
{
|
{
|
||||||
shared_ptr<Entity> e;
|
std::shared_ptr<Entity> e;
|
||||||
AUTO_VAR(it, entitiesById.find(id));
|
AUTO_VAR(it, entitiesById.find(id));
|
||||||
if( it != entitiesById.end() )
|
if( it != entitiesById.end() )
|
||||||
{
|
{
|
||||||
@@ -493,11 +493,11 @@ shared_ptr<Entity> MultiPlayerLevel::removeEntity(int id)
|
|||||||
|
|
||||||
// 4J Added to remove the entities from the forced list
|
// 4J Added to remove the entities from the forced list
|
||||||
// This gets called when a chunk is unloaded, but we only do half an unload to remove entities slightly differently
|
// This gets called when a chunk is unloaded, but we only do half an unload to remove entities slightly differently
|
||||||
void MultiPlayerLevel::removeEntities(vector<shared_ptr<Entity> > *list)
|
void MultiPlayerLevel::removeEntities(std::vector<std::shared_ptr<Entity> > *list)
|
||||||
{
|
{
|
||||||
for(AUTO_VAR(it, list->begin()); it < list->end(); ++it)
|
for(AUTO_VAR(it, list->begin()); it < list->end(); ++it)
|
||||||
{
|
{
|
||||||
shared_ptr<Entity> e = *it;
|
std::shared_ptr<Entity> e = *it;
|
||||||
|
|
||||||
AUTO_VAR(reIt, reEntries.find(e));
|
AUTO_VAR(reIt, reEntries.find(e));
|
||||||
if (reIt!=reEntries.end())
|
if (reIt!=reEntries.end())
|
||||||
@@ -609,7 +609,7 @@ void MultiPlayerLevel::disconnect(bool sendDisconnect /*= true*/)
|
|||||||
{
|
{
|
||||||
for(AUTO_VAR(it, connections.begin()); it < connections.end(); ++it )
|
for(AUTO_VAR(it, connections.begin()); it < connections.end(); ++it )
|
||||||
{
|
{
|
||||||
(*it)->sendAndDisconnect( shared_ptr<DisconnectPacket>( new DisconnectPacket(DisconnectPacket::eDisconnect_Quitting) ) );
|
(*it)->sendAndDisconnect( std::shared_ptr<DisconnectPacket>( new DisconnectPacket(DisconnectPacket::eDisconnect_Quitting) ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -730,7 +730,7 @@ void MultiPlayerLevel::animateTickDoWork()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MultiPlayerLevel::playSound(shared_ptr<Entity> entity, int iSound, float volume, float pitch)
|
void MultiPlayerLevel::playSound(std::shared_ptr<Entity> entity, int iSound, float volume, float pitch)
|
||||||
{
|
{
|
||||||
playLocalSound(entity->x, entity->y - entity->heightOffset, entity->z, iSound, volume, pitch);
|
playLocalSound(entity->x, entity->y - entity->heightOffset, entity->z, iSound, volume, pitch);
|
||||||
}
|
}
|
||||||
@@ -790,7 +790,7 @@ void MultiPlayerLevel::removeAllPendingEntityRemovals()
|
|||||||
AUTO_VAR(endIt, entitiesToRemove.end());
|
AUTO_VAR(endIt, entitiesToRemove.end());
|
||||||
for (AUTO_VAR(it, entitiesToRemove.begin()); it != endIt; it++)
|
for (AUTO_VAR(it, entitiesToRemove.begin()); it != endIt; it++)
|
||||||
{
|
{
|
||||||
shared_ptr<Entity> e = *it;
|
std::shared_ptr<Entity> e = *it;
|
||||||
int xc = e->xChunk;
|
int xc = e->xChunk;
|
||||||
int zc = e->zChunk;
|
int zc = e->zChunk;
|
||||||
if (e->inChunk && hasChunk(xc, zc))
|
if (e->inChunk && hasChunk(xc, zc))
|
||||||
@@ -809,10 +809,10 @@ void MultiPlayerLevel::removeAllPendingEntityRemovals()
|
|||||||
|
|
||||||
//for (int i = 0; i < entities.size(); i++)
|
//for (int i = 0; i < entities.size(); i++)
|
||||||
EnterCriticalSection(&m_entitiesCS);
|
EnterCriticalSection(&m_entitiesCS);
|
||||||
vector<shared_ptr<Entity> >::iterator it = entities.begin();
|
std::vector<std::shared_ptr<Entity> >::iterator it = entities.begin();
|
||||||
while( it != entities.end() )
|
while( it != entities.end() )
|
||||||
{
|
{
|
||||||
shared_ptr<Entity> e = *it;//entities.at(i);
|
std::shared_ptr<Entity> e = *it;//entities.at(i);
|
||||||
|
|
||||||
if (e->riding != NULL)
|
if (e->riding != NULL)
|
||||||
{
|
{
|
||||||
@@ -853,7 +853,7 @@ void MultiPlayerLevel::removeClientConnection(ClientConnection *c, bool sendDisc
|
|||||||
{
|
{
|
||||||
if( sendDisconnect )
|
if( sendDisconnect )
|
||||||
{
|
{
|
||||||
c->sendAndDisconnect( shared_ptr<DisconnectPacket>( new DisconnectPacket(DisconnectPacket::eDisconnect_Quitting) ) );
|
c->sendAndDisconnect( std::shared_ptr<DisconnectPacket>( new DisconnectPacket(DisconnectPacket::eDisconnect_Quitting) ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
AUTO_VAR(it, find( connections.begin(), connections.end(), c ));
|
AUTO_VAR(it, find( connections.begin(), connections.end(), c ));
|
||||||
@@ -886,7 +886,7 @@ void MultiPlayerLevel::removeUnusedTileEntitiesInRegion(int x0, int y0, int z0,
|
|||||||
for (unsigned int i = 0; i < tileEntityList.size();)
|
for (unsigned int i = 0; i < tileEntityList.size();)
|
||||||
{
|
{
|
||||||
bool removed = false;
|
bool removed = false;
|
||||||
shared_ptr<TileEntity> te = tileEntityList[i];
|
std::shared_ptr<TileEntity> te = tileEntityList[i];
|
||||||
if (te->x >= x0 && te->y >= y0 && te->z >= z0 && te->x < x1 && te->y < y1 && te->z < z1)
|
if (te->x >= x0 && te->y >= y0 && te->z >= z0 && te->x < x1 && te->y < y1 && te->z < z1)
|
||||||
{
|
{
|
||||||
LevelChunk *lc = getChunk(te->x >> 4, te->z >> 4);
|
LevelChunk *lc = getChunk(te->x >> 4, te->z >> 4);
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
using namespace std;
|
|
||||||
#include "../../Minecraft.World/Util/HashExtension.h"
|
#include "../../Minecraft.World/Util/HashExtension.h"
|
||||||
#include "../../Minecraft.World/Headers/net.minecraft.world.level.h"
|
#include "../../Minecraft.World/Headers/net.minecraft.world.level.h"
|
||||||
#include "../../Minecraft.World/Headers/net.minecraft.world.entity.h"
|
#include "../../Minecraft.World/Headers/net.minecraft.world.entity.h"
|
||||||
@@ -8,7 +8,7 @@ using namespace std;
|
|||||||
class ClientConnection;
|
class ClientConnection;
|
||||||
class MultiPlayerChunkCache;
|
class MultiPlayerChunkCache;
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
class MultiPlayerLevel : public Level
|
class MultiPlayerLevel : public Level
|
||||||
{
|
{
|
||||||
@@ -22,7 +22,7 @@ private:
|
|||||||
ResetInfo(int x, int y, int z, int tile, int data);
|
ResetInfo(int x, int y, int z, int tile, int data);
|
||||||
};
|
};
|
||||||
|
|
||||||
vector<ResetInfo> updatesToReset; // 4J - was linked list but vector seems more appropriate
|
std::vector<ResetInfo> updatesToReset; // 4J - was linked list but vector seems more appropriate
|
||||||
bool m_bEnableResetChanges; // 4J Added
|
bool m_bEnableResetChanges; // 4J Added
|
||||||
public:
|
public:
|
||||||
void unshareChunkAt(int x, int z); // 4J - added
|
void unshareChunkAt(int x, int z); // 4J - added
|
||||||
@@ -34,7 +34,7 @@ private:
|
|||||||
int unshareCheckZ; // 4J - added
|
int unshareCheckZ; // 4J - added
|
||||||
int compressCheckX; // 4J - added
|
int compressCheckX; // 4J - added
|
||||||
int compressCheckZ; // 4J - added
|
int compressCheckZ; // 4J - added
|
||||||
vector<ClientConnection *> connections; // 4J Stu - Made this a vector as we can have more than one local connection
|
std::vector<ClientConnection *> connections; // 4J Stu - Made this a vector as we can have more than one local connection
|
||||||
MultiPlayerChunkCache *chunkCache;
|
MultiPlayerChunkCache *chunkCache;
|
||||||
Minecraft *minecraft;
|
Minecraft *minecraft;
|
||||||
|
|
||||||
@@ -54,21 +54,21 @@ public:
|
|||||||
void setChunkVisible(int x, int z, bool visible);
|
void setChunkVisible(int x, int z, bool visible);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
unordered_map<int, shared_ptr<Entity>, IntKeyHash2, IntKeyEq> entitiesById; // 4J - was IntHashMap
|
std::unordered_map<int, std::shared_ptr<Entity>, IntKeyHash2, IntKeyEq> entitiesById; // 4J - was IntHashMap
|
||||||
unordered_set<shared_ptr<Entity> > forced;
|
std::unordered_set<std::shared_ptr<Entity> > forced;
|
||||||
unordered_set<shared_ptr<Entity> > reEntries;
|
std::unordered_set<std::shared_ptr<Entity> > reEntries;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual bool addEntity(shared_ptr<Entity> e);
|
virtual bool addEntity(std::shared_ptr<Entity> e);
|
||||||
virtual void removeEntity(shared_ptr<Entity> e);
|
virtual void removeEntity(std::shared_ptr<Entity> e);
|
||||||
protected:
|
protected:
|
||||||
virtual void entityAdded(shared_ptr<Entity> e);
|
virtual void entityAdded(std::shared_ptr<Entity> e);
|
||||||
virtual void entityRemoved(shared_ptr<Entity> e);
|
virtual void entityRemoved(std::shared_ptr<Entity> e);
|
||||||
public:
|
public:
|
||||||
void putEntity(int id, shared_ptr<Entity> e);
|
void putEntity(int id, std::shared_ptr<Entity> e);
|
||||||
shared_ptr<Entity> getEntity(int id);
|
std::shared_ptr<Entity> getEntity(int id);
|
||||||
shared_ptr<Entity> removeEntity(int id);
|
std::shared_ptr<Entity> removeEntity(int id);
|
||||||
virtual void removeEntities(vector<shared_ptr<Entity> > *list); // 4J Added override
|
virtual void removeEntities(std::vector<std::shared_ptr<Entity> > *list); // 4J Added override
|
||||||
virtual bool setDataNoUpdate(int x, int y, int z, int data);
|
virtual bool setDataNoUpdate(int x, int y, int z, int data);
|
||||||
virtual bool setTileAndDataNoUpdate(int x, int y, int z, int tile, int data);
|
virtual bool setTileAndDataNoUpdate(int x, int y, int z, int tile, int data);
|
||||||
virtual bool setTileNoUpdate(int x, int y, int z, int tile);
|
virtual bool setTileNoUpdate(int x, int y, int z, int tile);
|
||||||
@@ -82,12 +82,12 @@ protected:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
void animateTickDoWork(); // 4J added
|
void animateTickDoWork(); // 4J added
|
||||||
unordered_set<int> chunksToAnimate; // 4J added
|
std::unordered_set<int> chunksToAnimate; // 4J added
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void removeAllPendingEntityRemovals();
|
void removeAllPendingEntityRemovals();
|
||||||
|
|
||||||
virtual void playSound(shared_ptr<Entity> entity, int iSound, float volume, float pitch);
|
virtual void playSound(std::shared_ptr<Entity> entity, int iSound, float volume, float pitch);
|
||||||
|
|
||||||
virtual void playLocalSound(double x, double y, double z, int iSound, float volume, float pitch, float fClipSoundDist=16.0f);
|
virtual void playLocalSound(double x, double y, double z, int iSound, float volume, float pitch, float fClipSoundDist=16.0f);
|
||||||
|
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ void ServerLevel::staticCtor()
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
ServerLevel::ServerLevel(MinecraftServer *server, shared_ptr<LevelStorage>levelStorage, const wstring& levelName, int dimension, LevelSettings *levelSettings) : Level(levelStorage, levelName, levelSettings, Dimension::getNew(dimension), false)
|
ServerLevel::ServerLevel(MinecraftServer *server, std::shared_ptr<LevelStorage>levelStorage, const std::wstring& levelName, int dimension, LevelSettings *levelSettings) : Level(levelStorage, levelName, levelSettings, Dimension::getNew(dimension), false)
|
||||||
{
|
{
|
||||||
InitializeCriticalSection(&m_limiterCS);
|
InitializeCriticalSection(&m_limiterCS);
|
||||||
InitializeCriticalSection(&m_tickNextTickCS);
|
InitializeCriticalSection(&m_tickNextTickCS);
|
||||||
@@ -277,10 +277,10 @@ void ServerLevel::tick()
|
|||||||
|
|
||||||
Biome::MobSpawnerData *ServerLevel::getRandomMobSpawnAt(MobCategory *mobCategory, int x, int y, int z)
|
Biome::MobSpawnerData *ServerLevel::getRandomMobSpawnAt(MobCategory *mobCategory, int x, int y, int z)
|
||||||
{
|
{
|
||||||
vector<Biome::MobSpawnerData *> *mobList = getChunkSource()->getMobsAt(mobCategory, x, y, z);
|
std::vector<Biome::MobSpawnerData *> *mobList = getChunkSource()->getMobsAt(mobCategory, x, y, z);
|
||||||
if (mobList == NULL || mobList->empty()) return NULL;
|
if (mobList == NULL || mobList->empty()) return NULL;
|
||||||
|
|
||||||
return (Biome::MobSpawnerData *) WeighedRandom::getRandomItem(random, (vector<WeighedRandomItem *> *)mobList);
|
return (Biome::MobSpawnerData *) WeighedRandom::getRandomItem(random, (std::vector<WeighedRandomItem *> *)mobList);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerLevel::updateSleepingPlayerList()
|
void ServerLevel::updateSleepingPlayerList()
|
||||||
@@ -289,7 +289,7 @@ void ServerLevel::updateSleepingPlayerList()
|
|||||||
m_bAtLeastOnePlayerSleeping = false;
|
m_bAtLeastOnePlayerSleeping = false;
|
||||||
|
|
||||||
AUTO_VAR(itEnd, players.end());
|
AUTO_VAR(itEnd, players.end());
|
||||||
for (vector<shared_ptr<Player> >::iterator it = players.begin(); it != itEnd; it++)
|
for (std::vector<std::shared_ptr<Player> >::iterator it = players.begin(); it != itEnd; it++)
|
||||||
{
|
{
|
||||||
if (!(*it)->isSleeping())
|
if (!(*it)->isSleeping())
|
||||||
{
|
{
|
||||||
@@ -310,7 +310,7 @@ void ServerLevel::awakenAllPlayers()
|
|||||||
m_bAtLeastOnePlayerSleeping = false;
|
m_bAtLeastOnePlayerSleeping = false;
|
||||||
|
|
||||||
AUTO_VAR(itEnd, players.end());
|
AUTO_VAR(itEnd, players.end());
|
||||||
for (vector<shared_ptr<Player> >::iterator it = players.begin(); it != itEnd; it++)
|
for (std::vector<std::shared_ptr<Player> >::iterator it = players.begin(); it != itEnd; it++)
|
||||||
{
|
{
|
||||||
if ((*it)->isSleeping())
|
if ((*it)->isSleeping())
|
||||||
{
|
{
|
||||||
@@ -335,7 +335,7 @@ bool ServerLevel::allPlayersAreSleeping()
|
|||||||
{
|
{
|
||||||
// all players are sleeping, but have they slept long enough?
|
// all players are sleeping, but have they slept long enough?
|
||||||
AUTO_VAR(itEnd, players.end());
|
AUTO_VAR(itEnd, players.end());
|
||||||
for (vector<shared_ptr<Player> >::iterator it = players.begin(); it != itEnd; it++ )
|
for (std::vector<std::shared_ptr<Player> >::iterator it = players.begin(); it != itEnd; it++ )
|
||||||
{
|
{
|
||||||
// System.out.println(player->entityId + ": " + player->getSleepTimer());
|
// System.out.println(player->entityId + ": " + player->getSleepTimer());
|
||||||
if (! (*it)->isSleepingLongEnough())
|
if (! (*it)->isSleepingLongEnough())
|
||||||
@@ -467,7 +467,7 @@ void ServerLevel::tickTiles()
|
|||||||
|
|
||||||
if (isRainingAt(x, y, z))
|
if (isRainingAt(x, y, z))
|
||||||
{
|
{
|
||||||
addGlobalEntity( shared_ptr<LightningBolt>( new LightningBolt(this, x, y, z) ) );
|
addGlobalEntity( std::shared_ptr<LightningBolt>( new LightningBolt(this, x, y, z) ) );
|
||||||
lightningTime = 2;
|
lightningTime = 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -625,10 +625,10 @@ bool ServerLevel::tickPendingTicks(bool force)
|
|||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
vector<TickNextTickData> *ServerLevel::fetchTicksInChunk(LevelChunk *chunk, bool remove)
|
std::vector<TickNextTickData> *ServerLevel::fetchTicksInChunk(LevelChunk *chunk, bool remove)
|
||||||
{
|
{
|
||||||
EnterCriticalSection(&m_tickNextTickCS);
|
EnterCriticalSection(&m_tickNextTickCS);
|
||||||
vector<TickNextTickData> *results = new vector<TickNextTickData>;
|
std::vector<TickNextTickData> *results = new std::vector<TickNextTickData>;
|
||||||
|
|
||||||
ChunkPos *pos = chunk->getPos();
|
ChunkPos *pos = chunk->getPos();
|
||||||
int west = pos->x << 4;
|
int west = pos->x << 4;
|
||||||
@@ -665,7 +665,7 @@ vector<TickNextTickData> *ServerLevel::fetchTicksInChunk(LevelChunk *chunk, bool
|
|||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerLevel::tick(shared_ptr<Entity> e, bool actual)
|
void ServerLevel::tick(std::shared_ptr<Entity> e, bool actual)
|
||||||
{
|
{
|
||||||
if (!server->isAnimals() && ((e->GetType() & eTYPE_ANIMAL) || (e->GetType() & eTYPE_WATERANIMAL)))
|
if (!server->isAnimals() && ((e->GetType() & eTYPE_ANIMAL) || (e->GetType() & eTYPE_WATERANIMAL)))
|
||||||
{
|
{
|
||||||
@@ -681,7 +681,7 @@ void ServerLevel::tick(shared_ptr<Entity> e, bool actual)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerLevel::forceTick(shared_ptr<Entity> e, bool actual)
|
void ServerLevel::forceTick(std::shared_ptr<Entity> e, bool actual)
|
||||||
{
|
{
|
||||||
Level::tick(e, actual);
|
Level::tick(e, actual);
|
||||||
}
|
}
|
||||||
@@ -693,12 +693,12 @@ ChunkSource *ServerLevel::createChunkSource()
|
|||||||
return cache;
|
return cache;
|
||||||
}
|
}
|
||||||
|
|
||||||
vector<shared_ptr<TileEntity> > *ServerLevel::getTileEntitiesInRegion(int x0, int y0, int z0, int x1, int y1, int z1)
|
std::vector<std::shared_ptr<TileEntity> > *ServerLevel::getTileEntitiesInRegion(int x0, int y0, int z0, int x1, int y1, int z1)
|
||||||
{
|
{
|
||||||
vector<shared_ptr<TileEntity> > *result = new vector<shared_ptr<TileEntity> >;
|
std::vector<std::shared_ptr<TileEntity> > *result = new std::vector<std::shared_ptr<TileEntity> >;
|
||||||
for (unsigned int i = 0; i < tileEntityList.size(); i++)
|
for (unsigned int i = 0; i < tileEntityList.size(); i++)
|
||||||
{
|
{
|
||||||
shared_ptr<TileEntity> te = tileEntityList[i];
|
std::shared_ptr<TileEntity> te = tileEntityList[i];
|
||||||
if (te->x >= x0 && te->y >= y0 && te->z >= z0 && te->x < x1 && te->y < y1 && te->z < z1)
|
if (te->x >= x0 && te->y >= y0 && te->z >= z0 && te->x < x1 && te->y < y1 && te->z < z1)
|
||||||
{
|
{
|
||||||
result->push_back(te);
|
result->push_back(te);
|
||||||
@@ -707,7 +707,7 @@ vector<shared_ptr<TileEntity> > *ServerLevel::getTileEntitiesInRegion(int x0, in
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ServerLevel::mayInteract(shared_ptr<Player> player, int xt, int yt, int zt, int content)
|
bool ServerLevel::mayInteract(std::shared_ptr<Player> player, int xt, int yt, int zt, int content)
|
||||||
{
|
{
|
||||||
// 4J-PB - This will look like a bug to players, and we really should have a message to explain why we're not allowing lava to be placed at or near a spawn point
|
// 4J-PB - This will look like a bug to players, and we really should have a message to explain why we're not allowing lava to be placed at or near a spawn point
|
||||||
// We'll need to do this in a future update
|
// We'll need to do this in a future update
|
||||||
@@ -750,7 +750,7 @@ void ServerLevel::setInitialSpawn(LevelSettings *levelSettings)
|
|||||||
isFindingSpawn = true;
|
isFindingSpawn = true;
|
||||||
|
|
||||||
BiomeSource *biomeSource = dimension->biomeSource;
|
BiomeSource *biomeSource = dimension->biomeSource;
|
||||||
vector<Biome *> playerSpawnBiomes = biomeSource->getPlayerSpawnBiomes();
|
std::vector<Biome *> playerSpawnBiomes = biomeSource->getPlayerSpawnBiomes();
|
||||||
Random random(getSeed());
|
Random random(getSeed());
|
||||||
|
|
||||||
TilePos *findBiome = biomeSource->findBiome(0, 0, 16 * 16, playerSpawnBiomes, &random);
|
TilePos *findBiome = biomeSource->findBiome(0, 0, 16 * 16, playerSpawnBiomes, &random);
|
||||||
@@ -814,7 +814,7 @@ void ServerLevel::generateBonusItemsNearSpawn()
|
|||||||
|
|
||||||
if( getTile( x, y, z ) == Tile::chest_Id )
|
if( getTile( x, y, z ) == Tile::chest_Id )
|
||||||
{
|
{
|
||||||
shared_ptr<ChestTileEntity> chest = dynamic_pointer_cast<ChestTileEntity>(getTileEntity(x, y, z));
|
std::shared_ptr<ChestTileEntity> chest = dynamic_pointer_cast<ChestTileEntity>(getTileEntity(x, y, z));
|
||||||
if (chest != NULL)
|
if (chest != NULL)
|
||||||
{
|
{
|
||||||
if( chest->isBonusChest )
|
if( chest->isBonusChest )
|
||||||
@@ -896,7 +896,7 @@ void ServerLevel::save(bool force, ProgressListener *progressListener, bool bAut
|
|||||||
{
|
{
|
||||||
// 4J Stu - This will come in a later change anyway
|
// 4J Stu - This will come in a later change anyway
|
||||||
// clean cache
|
// clean cache
|
||||||
vector<LevelChunk *> *loadedChunkList = cache->getLoadedChunkList();
|
std::vector<LevelChunk *> *loadedChunkList = cache->getLoadedChunkList();
|
||||||
for (AUTO_VAR(it, loadedChunkList->begin()); it != loadedChunkList->end(); ++it)
|
for (AUTO_VAR(it, loadedChunkList->begin()); it != loadedChunkList->end(); ++it)
|
||||||
{
|
{
|
||||||
LevelChunk *lc = *it;
|
LevelChunk *lc = *it;
|
||||||
@@ -948,11 +948,11 @@ void ServerLevel::saveLevelData()
|
|||||||
savedDataStorage->save();
|
savedDataStorage->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerLevel::entityAdded(shared_ptr<Entity> e)
|
void ServerLevel::entityAdded(std::shared_ptr<Entity> e)
|
||||||
{
|
{
|
||||||
Level::entityAdded(e);
|
Level::entityAdded(e);
|
||||||
entitiesById[e->entityId] = e;
|
entitiesById[e->entityId] = e;
|
||||||
vector<shared_ptr<Entity> > *es = e->getSubEntities();
|
std::vector<std::shared_ptr<Entity> > *es = e->getSubEntities();
|
||||||
if (es != NULL)
|
if (es != NULL)
|
||||||
{
|
{
|
||||||
//for (int i = 0; i < es.length; i++)
|
//for (int i = 0; i < es.length; i++)
|
||||||
@@ -964,11 +964,11 @@ void ServerLevel::entityAdded(shared_ptr<Entity> e)
|
|||||||
entityAddedExtra(e); // 4J added
|
entityAddedExtra(e); // 4J added
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerLevel::entityRemoved(shared_ptr<Entity> e)
|
void ServerLevel::entityRemoved(std::shared_ptr<Entity> e)
|
||||||
{
|
{
|
||||||
Level::entityRemoved(e);
|
Level::entityRemoved(e);
|
||||||
entitiesById.erase(e->entityId);
|
entitiesById.erase(e->entityId);
|
||||||
vector<shared_ptr<Entity> > *es = e->getSubEntities();
|
std::vector<std::shared_ptr<Entity> > *es = e->getSubEntities();
|
||||||
if (es != NULL)
|
if (es != NULL)
|
||||||
{
|
{
|
||||||
//for (int i = 0; i < es.length; i++)
|
//for (int i = 0; i < es.length; i++)
|
||||||
@@ -980,32 +980,32 @@ void ServerLevel::entityRemoved(shared_ptr<Entity> e)
|
|||||||
entityRemovedExtra(e); // 4J added
|
entityRemovedExtra(e); // 4J added
|
||||||
}
|
}
|
||||||
|
|
||||||
shared_ptr<Entity> ServerLevel::getEntity(int id)
|
std::shared_ptr<Entity> ServerLevel::getEntity(int id)
|
||||||
{
|
{
|
||||||
return entitiesById[id];
|
return entitiesById[id];
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ServerLevel::addGlobalEntity(shared_ptr<Entity> e)
|
bool ServerLevel::addGlobalEntity(std::shared_ptr<Entity> e)
|
||||||
{
|
{
|
||||||
if (Level::addGlobalEntity(e))
|
if (Level::addGlobalEntity(e))
|
||||||
{
|
{
|
||||||
server->getPlayers()->broadcast(e->x, e->y, e->z, 512, dimension->id, shared_ptr<AddGlobalEntityPacket>( new AddGlobalEntityPacket(e) ) );
|
server->getPlayers()->broadcast(e->x, e->y, e->z, 512, dimension->id, std::shared_ptr<AddGlobalEntityPacket>( new AddGlobalEntityPacket(e) ) );
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerLevel::broadcastEntityEvent(shared_ptr<Entity> e, uint8_t event)
|
void ServerLevel::broadcastEntityEvent(std::shared_ptr<Entity> e, uint8_t event)
|
||||||
{
|
{
|
||||||
shared_ptr<Packet> p = shared_ptr<EntityEventPacket>( new EntityEventPacket(e->entityId, event) );
|
std::shared_ptr<Packet> p = std::shared_ptr<EntityEventPacket>( new EntityEventPacket(e->entityId, event) );
|
||||||
server->getLevel(dimension->id)->getTracker()->broadcastAndSend(e, p);
|
server->getLevel(dimension->id)->getTracker()->broadcastAndSend(e, p);
|
||||||
}
|
}
|
||||||
|
|
||||||
shared_ptr<Explosion> ServerLevel::explode(shared_ptr<Entity> source, double x, double y, double z, float r, bool fire, bool destroyBlocks)
|
std::shared_ptr<Explosion> ServerLevel::explode(std::shared_ptr<Entity> source, double x, double y, double z, float r, bool fire, bool destroyBlocks)
|
||||||
{
|
{
|
||||||
// instead of calling super, we run the same explosion code here except
|
// instead of calling super, we run the same explosion code here except
|
||||||
// we don't generate any particles
|
// we don't generate any particles
|
||||||
shared_ptr<Explosion> explosion = shared_ptr<Explosion>( new Explosion(this, source, x, y, z, r) );
|
std::shared_ptr<Explosion> explosion = std::shared_ptr<Explosion>( new Explosion(this, source, x, y, z, r) );
|
||||||
explosion->fire = fire;
|
explosion->fire = fire;
|
||||||
explosion->destroyBlocks = destroyBlocks;
|
explosion->destroyBlocks = destroyBlocks;
|
||||||
explosion->explode();
|
explosion->explode();
|
||||||
@@ -1016,10 +1016,10 @@ shared_ptr<Explosion> ServerLevel::explode(shared_ptr<Entity> source, double x,
|
|||||||
explosion->toBlow.clear();
|
explosion->toBlow.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
vector<shared_ptr<ServerPlayer> > sentTo;
|
std::vector<std::shared_ptr<ServerPlayer> > sentTo;
|
||||||
for(AUTO_VAR(it, players.begin()); it != players.end(); ++it)
|
for(AUTO_VAR(it, players.begin()); it != players.end(); ++it)
|
||||||
{
|
{
|
||||||
shared_ptr<ServerPlayer> player = dynamic_pointer_cast<ServerPlayer>(*it);
|
std::shared_ptr<ServerPlayer> player = dynamic_pointer_cast<ServerPlayer>(*it);
|
||||||
if (player->dimension != dimension->id) continue;
|
if (player->dimension != dimension->id) continue;
|
||||||
|
|
||||||
bool knockbackOnly = false;
|
bool knockbackOnly = false;
|
||||||
@@ -1034,7 +1034,7 @@ shared_ptr<Explosion> ServerLevel::explode(shared_ptr<Entity> source, double x,
|
|||||||
{
|
{
|
||||||
for(unsigned int j = 0; j < sentTo.size(); j++ )
|
for(unsigned int j = 0; j < sentTo.size(); j++ )
|
||||||
{
|
{
|
||||||
shared_ptr<ServerPlayer> player2 = sentTo[j];
|
std::shared_ptr<ServerPlayer> player2 = sentTo[j];
|
||||||
INetworkPlayer *otherPlayer = player2->connection->getNetworkPlayer();
|
INetworkPlayer *otherPlayer = player2->connection->getNetworkPlayer();
|
||||||
if( otherPlayer != NULL && thisPlayer->IsSameSystem(otherPlayer) )
|
if( otherPlayer != NULL && thisPlayer->IsSameSystem(otherPlayer) )
|
||||||
{
|
{
|
||||||
@@ -1049,7 +1049,7 @@ shared_ptr<Explosion> ServerLevel::explode(shared_ptr<Entity> source, double x,
|
|||||||
Vec3 *knockbackVec = explosion->getHitPlayerKnockback(player);
|
Vec3 *knockbackVec = explosion->getHitPlayerKnockback(player);
|
||||||
//app.DebugPrintf("Sending %s with knockback (%f,%f,%f)\n", knockbackOnly?"knockbackOnly":"allExplosion",knockbackVec->x,knockbackVec->y,knockbackVec->z);
|
//app.DebugPrintf("Sending %s with knockback (%f,%f,%f)\n", knockbackOnly?"knockbackOnly":"allExplosion",knockbackVec->x,knockbackVec->y,knockbackVec->z);
|
||||||
// If the player is not the primary on the system, then we only want to send info for the knockback
|
// If the player is not the primary on the system, then we only want to send info for the knockback
|
||||||
player->connection->send( shared_ptr<ExplodePacket>( new ExplodePacket(x, y, z, r, &explosion->toBlow, knockbackVec, knockbackOnly)));
|
player->connection->send( std::shared_ptr<ExplodePacket>( new ExplodePacket(x, y, z, r, &explosion->toBlow, knockbackVec, knockbackOnly)));
|
||||||
sentTo.push_back( player );
|
sentTo.push_back( player );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1088,7 +1088,7 @@ void ServerLevel::runTileEvents()
|
|||||||
if (doTileEvent(&(*it)))
|
if (doTileEvent(&(*it)))
|
||||||
{
|
{
|
||||||
TileEventData te = *it;
|
TileEventData te = *it;
|
||||||
server->getPlayers()->broadcast(te.getX(), te.getY(), te.getZ(), 64, dimension->id, shared_ptr<TileEventPacket>( new TileEventPacket(te.getX(), te.getY(), te.getZ(), te.getTile(), te.getParamA(), te.getParamB())));
|
server->getPlayers()->broadcast(te.getX(), te.getY(), te.getZ(), 64, dimension->id, std::shared_ptr<TileEventPacket>( new TileEventPacket(te.getX(), te.getY(), te.getZ(), te.getTile(), te.getParamA(), te.getParamB())));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tileEvents[runList].clear();
|
tileEvents[runList].clear();
|
||||||
@@ -1119,11 +1119,11 @@ void ServerLevel::tickWeather()
|
|||||||
{
|
{
|
||||||
if (wasRaining)
|
if (wasRaining)
|
||||||
{
|
{
|
||||||
server->getPlayers()->broadcastAll( shared_ptr<GameEventPacket>( new GameEventPacket(GameEventPacket::STOP_RAINING, 0) ) );
|
server->getPlayers()->broadcastAll( std::shared_ptr<GameEventPacket>( new GameEventPacket(GameEventPacket::STOP_RAINING, 0) ) );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
server->getPlayers()->broadcastAll( shared_ptr<GameEventPacket>( new GameEventPacket(GameEventPacket::START_RAINING, 0) ) );
|
server->getPlayers()->broadcastAll( std::shared_ptr<GameEventPacket>( new GameEventPacket(GameEventPacket::START_RAINING, 0) ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1144,7 +1144,7 @@ void ServerLevel::setTimeAndAdjustTileTicks(__int64 newTime)
|
|||||||
__int64 delta = newTime - levelData->getTime();
|
__int64 delta = newTime - levelData->getTime();
|
||||||
// 4J - can't directly adjust m_delay in a set as it has a const interator, since changing values in here might change the ordering of the elements in the set.
|
// 4J - can't directly adjust m_delay in a set as it has a const interator, since changing values in here might change the ordering of the elements in the set.
|
||||||
// Instead move to a vector, do the adjustment, put back in the set.
|
// Instead move to a vector, do the adjustment, put back in the set.
|
||||||
vector<TickNextTickData> temp;
|
std::vector<TickNextTickData> temp;
|
||||||
for(AUTO_VAR(it, tickNextTickList.begin()); it != tickNextTickList.end(); ++it)
|
for(AUTO_VAR(it, tickNextTickList.begin()); it != tickNextTickList.end(); ++it)
|
||||||
{
|
{
|
||||||
temp.push_back(*it);
|
temp.push_back(*it);
|
||||||
@@ -1185,7 +1185,7 @@ void ServerLevel::runQueuedSendTileUpdates()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 4J - added special versions of addEntity and extra processing on entity removed and added so we can limit the number of itementities created
|
// 4J - added special versions of addEntity and extra processing on entity removed and added so we can limit the number of itementities created
|
||||||
bool ServerLevel::addEntity(shared_ptr<Entity> e)
|
bool ServerLevel::addEntity(std::shared_ptr<Entity> e)
|
||||||
{
|
{
|
||||||
// If its an item entity, and we've got to our capacity, delete the oldest
|
// If its an item entity, and we've got to our capacity, delete the oldest
|
||||||
if( dynamic_pointer_cast<ItemEntity>(e) != NULL )
|
if( dynamic_pointer_cast<ItemEntity>(e) != NULL )
|
||||||
@@ -1244,7 +1244,7 @@ bool ServerLevel::addEntity(shared_ptr<Entity> e)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Maintain a cound of primed tnt & falling tiles in this level
|
// Maintain a cound of primed tnt & falling tiles in this level
|
||||||
void ServerLevel::entityAddedExtra(shared_ptr<Entity> e)
|
void ServerLevel::entityAddedExtra(std::shared_ptr<Entity> e)
|
||||||
{
|
{
|
||||||
if( dynamic_pointer_cast<ItemEntity>(e) != NULL )
|
if( dynamic_pointer_cast<ItemEntity>(e) != NULL )
|
||||||
{
|
{
|
||||||
@@ -1289,7 +1289,7 @@ void ServerLevel::entityAddedExtra(shared_ptr<Entity> e)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Maintain a cound of primed tnt & falling tiles in this level, and remove any item entities from our list
|
// Maintain a cound of primed tnt & falling tiles in this level, and remove any item entities from our list
|
||||||
void ServerLevel::entityRemovedExtra(shared_ptr<Entity> e)
|
void ServerLevel::entityRemovedExtra(std::shared_ptr<Entity> e)
|
||||||
{
|
{
|
||||||
if( dynamic_pointer_cast<ItemEntity>(e) != NULL )
|
if( dynamic_pointer_cast<ItemEntity>(e) != NULL )
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ class MinecraftServer;
|
|||||||
class Node;
|
class Node;
|
||||||
class EntityTracker;
|
class EntityTracker;
|
||||||
class PlayerChunkMap;
|
class PlayerChunkMap;
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
class ServerLevel : public Level
|
class ServerLevel : public Level
|
||||||
{
|
{
|
||||||
@@ -19,9 +19,9 @@ private:
|
|||||||
|
|
||||||
CRITICAL_SECTION m_tickNextTickCS; // 4J added
|
CRITICAL_SECTION m_tickNextTickCS; // 4J added
|
||||||
set<TickNextTickData, TickNextTickDataKeyCompare> tickNextTickList; // 4J Was TreeSet
|
set<TickNextTickData, TickNextTickDataKeyCompare> tickNextTickList; // 4J Was TreeSet
|
||||||
unordered_set<TickNextTickData, TickNextTickDataKeyHash, TickNextTickDataKeyEq> tickNextTickSet; // 4J Was HashSet
|
std::unordered_set<TickNextTickData, TickNextTickDataKeyHash, TickNextTickDataKeyEq> tickNextTickSet; // 4J Was HashSet
|
||||||
|
|
||||||
vector<Pos *> m_queuedSendTileUpdates; // 4J added
|
std::vector<Pos *> m_queuedSendTileUpdates; // 4J added
|
||||||
CRITICAL_SECTION m_csQueueSendTileUpdates;
|
CRITICAL_SECTION m_csQueueSendTileUpdates;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@@ -37,11 +37,11 @@ private:
|
|||||||
bool m_bAtLeastOnePlayerSleeping; // 4J Added
|
bool m_bAtLeastOnePlayerSleeping; // 4J Added
|
||||||
static WeighedTreasureArray RANDOM_BONUS_ITEMS; // 4J - brought forward from 1.3.2
|
static WeighedTreasureArray RANDOM_BONUS_ITEMS; // 4J - brought forward from 1.3.2
|
||||||
|
|
||||||
vector<TileEventData> tileEvents[2];
|
std::vector<TileEventData> tileEvents[2];
|
||||||
int activeTileEventsList;
|
int activeTileEventsList;
|
||||||
public:
|
public:
|
||||||
static void staticCtor();
|
static void staticCtor();
|
||||||
ServerLevel(MinecraftServer *server, shared_ptr<LevelStorage>levelStorage, const wstring& levelName, int dimension, LevelSettings *levelSettings);
|
ServerLevel(MinecraftServer *server, std::shared_ptr<LevelStorage>levelStorage, const std::wstring& levelName, int dimension, LevelSettings *levelSettings);
|
||||||
~ServerLevel();
|
~ServerLevel();
|
||||||
void tick();
|
void tick();
|
||||||
Biome::MobSpawnerData *getRandomMobSpawnAt(MobCategory *mobCategory, int x, int y, int z);
|
Biome::MobSpawnerData *getRandomMobSpawnAt(MobCategory *mobCategory, int x, int y, int z);
|
||||||
@@ -64,16 +64,16 @@ public:
|
|||||||
void forceAddTileTick(int x, int y, int z, int tileId, int tickDelay);
|
void forceAddTileTick(int x, int y, int z, int tileId, int tickDelay);
|
||||||
void tickEntities();
|
void tickEntities();
|
||||||
bool tickPendingTicks(bool force);
|
bool tickPendingTicks(bool force);
|
||||||
vector<TickNextTickData> *fetchTicksInChunk(LevelChunk *chunk, bool remove);
|
std::vector<TickNextTickData> *fetchTicksInChunk(LevelChunk *chunk, bool remove);
|
||||||
virtual void tick(shared_ptr<Entity> e, bool actual);
|
virtual void tick(std::shared_ptr<Entity> e, bool actual);
|
||||||
void forceTick(shared_ptr<Entity> e, bool actual);
|
void forceTick(std::shared_ptr<Entity> e, bool actual);
|
||||||
bool AllPlayersAreSleeping() { return allPlayersSleeping;} // 4J added for a message to other players
|
bool AllPlayersAreSleeping() { return allPlayersSleeping;} // 4J added for a message to other players
|
||||||
bool isAtLeastOnePlayerSleeping() { return m_bAtLeastOnePlayerSleeping;}
|
bool isAtLeastOnePlayerSleeping() { return m_bAtLeastOnePlayerSleeping;}
|
||||||
protected:
|
protected:
|
||||||
ChunkSource *createChunkSource(); // 4J - was virtual, but was called from parent ctor
|
ChunkSource *createChunkSource(); // 4J - was virtual, but was called from parent ctor
|
||||||
public:
|
public:
|
||||||
vector<shared_ptr<TileEntity> > *getTileEntitiesInRegion(int x0, int y0, int z0, int x1, int y1, int z1);
|
std::vector<std::shared_ptr<TileEntity> > *getTileEntitiesInRegion(int x0, int y0, int z0, int x1, int y1, int z1);
|
||||||
virtual bool mayInteract(shared_ptr<Player> player, int xt, int yt, int zt, int id);
|
virtual bool mayInteract(std::shared_ptr<Player> player, int xt, int yt, int zt, int id);
|
||||||
protected:
|
protected:
|
||||||
virtual void initializeLevel(LevelSettings *settings);
|
virtual void initializeLevel(LevelSettings *settings);
|
||||||
virtual void setInitialSpawn(LevelSettings *settings);
|
virtual void setInitialSpawn(LevelSettings *settings);
|
||||||
@@ -90,16 +90,16 @@ public:
|
|||||||
private:
|
private:
|
||||||
void saveLevelData();
|
void saveLevelData();
|
||||||
|
|
||||||
typedef unordered_map<int, shared_ptr<Entity> , IntKeyHash2, IntKeyEq> intEntityMap;
|
typedef std::unordered_map<int, std::shared_ptr<Entity> , IntKeyHash2, IntKeyEq> intEntityMap;
|
||||||
intEntityMap entitiesById; // 4J - was IntHashMap, using same hashing function as this uses
|
intEntityMap entitiesById; // 4J - was IntHashMap, using same hashing function as this uses
|
||||||
protected:
|
protected:
|
||||||
virtual void entityAdded(shared_ptr<Entity> e);
|
virtual void entityAdded(std::shared_ptr<Entity> e);
|
||||||
virtual void entityRemoved(shared_ptr<Entity> e);
|
virtual void entityRemoved(std::shared_ptr<Entity> e);
|
||||||
public:
|
public:
|
||||||
shared_ptr<Entity> getEntity(int id);
|
std::shared_ptr<Entity> getEntity(int id);
|
||||||
virtual bool addGlobalEntity(shared_ptr<Entity> e);
|
virtual bool addGlobalEntity(std::shared_ptr<Entity> e);
|
||||||
void broadcastEntityEvent(shared_ptr<Entity> e, uint8_t event);
|
void broadcastEntityEvent(std::shared_ptr<Entity> e, uint8_t event);
|
||||||
virtual shared_ptr<Explosion> explode(shared_ptr<Entity> source, double x, double y, double z, float r, bool fire, bool destroyBlocks);
|
virtual std::shared_ptr<Explosion> explode(std::shared_ptr<Entity> source, double x, double y, double z, float r, bool fire, bool destroyBlocks);
|
||||||
virtual void tileEvent(int x, int y, int z, int tile, int b0, int b1);
|
virtual void tileEvent(int x, int y, int z, int tile, int b0, int b1);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -134,14 +134,14 @@ public:
|
|||||||
int m_primedTntCount;
|
int m_primedTntCount;
|
||||||
int m_fallingTileCount;
|
int m_fallingTileCount;
|
||||||
CRITICAL_SECTION m_limiterCS;
|
CRITICAL_SECTION m_limiterCS;
|
||||||
list< shared_ptr<Entity> > m_itemEntities;
|
list< std::shared_ptr<Entity> > m_itemEntities;
|
||||||
list< shared_ptr<Entity> > m_hangingEntities;
|
list< std::shared_ptr<Entity> > m_hangingEntities;
|
||||||
list< shared_ptr<Entity> > m_arrowEntities;
|
list< std::shared_ptr<Entity> > m_arrowEntities;
|
||||||
list< shared_ptr<Entity> > m_experienceOrbEntities;
|
list< std::shared_ptr<Entity> > m_experienceOrbEntities;
|
||||||
|
|
||||||
virtual bool addEntity(shared_ptr<Entity> e);
|
virtual bool addEntity(std::shared_ptr<Entity> e);
|
||||||
void entityAddedExtra(shared_ptr<Entity> e);
|
void entityAddedExtra(std::shared_ptr<Entity> e);
|
||||||
void entityRemovedExtra(shared_ptr<Entity> e);
|
void entityRemovedExtra(std::shared_ptr<Entity> e);
|
||||||
|
|
||||||
virtual bool newPrimedTntAllowed();
|
virtual bool newPrimedTntAllowed();
|
||||||
virtual bool newFallingTileAllowed();
|
virtual bool newFallingTileAllowed();
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ ServerLevelListener::ServerLevelListener(MinecraftServer *server, ServerLevel *l
|
|||||||
|
|
||||||
// 4J removed -
|
// 4J removed -
|
||||||
/*
|
/*
|
||||||
void ServerLevelListener::addParticle(const wstring& name, double x, double y, double z, double xa, double ya, double za)
|
void ServerLevelListener::addParticle(const std::wstring& name, double x, double y, double z, double xa, double ya, double za)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
@@ -33,22 +33,22 @@ void ServerLevelListener::allChanged()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerLevelListener::entityAdded(shared_ptr<Entity> entity)
|
void ServerLevelListener::entityAdded(std::shared_ptr<Entity> entity)
|
||||||
{
|
{
|
||||||
MemSect(10);
|
MemSect(10);
|
||||||
level->getTracker()->addEntity(entity);
|
level->getTracker()->addEntity(entity);
|
||||||
MemSect(0);
|
MemSect(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerLevelListener::entityRemoved(shared_ptr<Entity> entity)
|
void ServerLevelListener::entityRemoved(std::shared_ptr<Entity> entity)
|
||||||
{
|
{
|
||||||
level->getTracker()->removeEntity(entity);
|
level->getTracker()->removeEntity(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4J added
|
// 4J added
|
||||||
void ServerLevelListener::playerRemoved(shared_ptr<Entity> entity)
|
void ServerLevelListener::playerRemoved(std::shared_ptr<Entity> entity)
|
||||||
{
|
{
|
||||||
shared_ptr<ServerPlayer> player = dynamic_pointer_cast<ServerPlayer>(entity);
|
std::shared_ptr<ServerPlayer> player = dynamic_pointer_cast<ServerPlayer>(entity);
|
||||||
player->getLevel()->getTracker()->removePlayer(entity);
|
player->getLevel()->getTracker()->removePlayer(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -62,11 +62,11 @@ void ServerLevelListener::playSound(int iSound, double x, double y, double z, fl
|
|||||||
{
|
{
|
||||||
// 4J-PB - I don't want to broadcast player sounds to my local machine, since we're already playing these in the LevelRenderer::playSound.
|
// 4J-PB - I don't want to broadcast player sounds to my local machine, since we're already playing these in the LevelRenderer::playSound.
|
||||||
// The PC version does seem to do this and the result is I can stop walking , and then I'll hear my footstep sound with a delay
|
// The PC version does seem to do this and the result is I can stop walking , and then I'll hear my footstep sound with a delay
|
||||||
server->getPlayers()->broadcast(x, y, z, volume > 1 ? 16 * volume : 16, level->dimension->id, shared_ptr<LevelSoundPacket>(new LevelSoundPacket(iSound, x, y, z, volume, pitch)));
|
server->getPlayers()->broadcast(x, y, z, volume > 1 ? 16 * volume : 16, level->dimension->id, std::shared_ptr<LevelSoundPacket>(new LevelSoundPacket(iSound, x, y, z, volume, pitch)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerLevelListener::playSound(shared_ptr<Entity> entity,int iSound, double x, double y, double z, float volume, float pitch, float fClipSoundDist)
|
void ServerLevelListener::playSound(std::shared_ptr<Entity> entity,int iSound, double x, double y, double z, float volume, float pitch, float fClipSoundDist)
|
||||||
{
|
{
|
||||||
if(iSound < 0)
|
if(iSound < 0)
|
||||||
{
|
{
|
||||||
@@ -76,8 +76,8 @@ void ServerLevelListener::playSound(shared_ptr<Entity> entity,int iSound, double
|
|||||||
{
|
{
|
||||||
// 4J-PB - I don't want to broadcast player sounds to my local machine, since we're already playing these in the LevelRenderer::playSound.
|
// 4J-PB - I don't want to broadcast player sounds to my local machine, since we're already playing these in the LevelRenderer::playSound.
|
||||||
// The PC version does seem to do this and the result is I can stop walking , and then I'll hear my footstep sound with a delay
|
// The PC version does seem to do this and the result is I can stop walking , and then I'll hear my footstep sound with a delay
|
||||||
shared_ptr<Player> player= dynamic_pointer_cast<Player>(entity);
|
std::shared_ptr<Player> player= dynamic_pointer_cast<Player>(entity);
|
||||||
server->getPlayers()->broadcast(player,x, y, z, volume > 1 ? 16 * volume : 16, level->dimension->id, shared_ptr<LevelSoundPacket>(new LevelSoundPacket(iSound, x, y, z, volume, pitch)));
|
server->getPlayers()->broadcast(player,x, y, z, volume > 1 ? 16 * volume : 16, level->dimension->id, std::shared_ptr<LevelSoundPacket>(new LevelSoundPacket(iSound, x, y, z, volume, pitch)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -98,13 +98,13 @@ void ServerLevelListener::tileLightChanged(int x, int y, int z)
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerLevelListener::playStreamingMusic(const wstring& name, int x, int y, int z)
|
void ServerLevelListener::playStreamingMusic(const std::wstring& name, int x, int y, int z)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerLevelListener::levelEvent(shared_ptr<Player> source, int type, int x, int y, int z, int data)
|
void ServerLevelListener::levelEvent(std::shared_ptr<Player> source, int type, int x, int y, int z, int data)
|
||||||
{
|
{
|
||||||
server->getPlayers()->broadcast(source, x, y, z, 64, level->dimension->id, shared_ptr<LevelEventPacket>( new LevelEventPacket(type, x, y, z, data) ) );
|
server->getPlayers()->broadcast(source, x, y, z, 64, level->dimension->id, std::shared_ptr<LevelEventPacket>( new LevelEventPacket(type, x, y, z, data) ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerLevelListener::destroyTileProgress(int id, int x, int y, int z, int progress)
|
void ServerLevelListener::destroyTileProgress(int id, int x, int y, int z, int progress)
|
||||||
@@ -112,7 +112,7 @@ void ServerLevelListener::destroyTileProgress(int id, int x, int y, int z, int p
|
|||||||
//for (ServerPlayer p : server->getPlayers()->players)
|
//for (ServerPlayer p : server->getPlayers()->players)
|
||||||
for(AUTO_VAR(it, server->getPlayers()->players.begin()); it != server->getPlayers()->players.end(); ++it)
|
for(AUTO_VAR(it, server->getPlayers()->players.begin()); it != server->getPlayers()->players.end(); ++it)
|
||||||
{
|
{
|
||||||
shared_ptr<ServerPlayer> p = *it;
|
std::shared_ptr<ServerPlayer> p = *it;
|
||||||
if (p == NULL || p->level != level || p->entityId == id) continue;
|
if (p == NULL || p->level != level || p->entityId == id) continue;
|
||||||
double xd = (double) x - p->x;
|
double xd = (double) x - p->x;
|
||||||
double yd = (double) y - p->y;
|
double yd = (double) y - p->y;
|
||||||
@@ -120,7 +120,7 @@ void ServerLevelListener::destroyTileProgress(int id, int x, int y, int z, int p
|
|||||||
|
|
||||||
if (xd * xd + yd * yd + zd * zd < 32 * 32)
|
if (xd * xd + yd * yd + zd * zd < 32 * 32)
|
||||||
{
|
{
|
||||||
p->connection->send(shared_ptr<TileDestructionPacket>(new TileDestructionPacket(id, x, y, z, progress)));
|
p->connection->send(std::shared_ptr<TileDestructionPacket>(new TileDestructionPacket(id, x, y, z, progress)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -15,19 +15,19 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
ServerLevelListener(MinecraftServer *server, ServerLevel *level);
|
ServerLevelListener(MinecraftServer *server, ServerLevel *level);
|
||||||
// 4J removed - virtual void addParticle(const wstring& name, double x, double y, double z, double xa, double ya, double za);
|
// 4J removed - virtual void addParticle(const std::wstring& name, double x, double y, double z, double xa, double ya, double za);
|
||||||
virtual void addParticle(ePARTICLE_TYPE name, double x, double y, double z, double xa, double ya, double za); // 4J added
|
virtual void addParticle(ePARTICLE_TYPE name, double x, double y, double z, double xa, double ya, double za); // 4J added
|
||||||
virtual void allChanged();
|
virtual void allChanged();
|
||||||
virtual void entityAdded(shared_ptr<Entity> entity);
|
virtual void entityAdded(std::shared_ptr<Entity> entity);
|
||||||
virtual void entityRemoved(shared_ptr<Entity> entity);
|
virtual void entityRemoved(std::shared_ptr<Entity> entity);
|
||||||
virtual void playerRemoved(shared_ptr<Entity> entity); // 4J added - for when a player is removed from the level's player array, not just the entity storage
|
virtual void playerRemoved(std::shared_ptr<Entity> entity); // 4J added - for when a player is removed from the level's player array, not just the entity storage
|
||||||
virtual void playSound(int iSound, double x, double y, double z, float volume, float pitch, float fClipSoundDist);
|
virtual void playSound(int iSound, double x, double y, double z, float volume, float pitch, float fClipSoundDist);
|
||||||
virtual void playSound(shared_ptr<Entity> entity,int iSound, double x, double y, double z, float volume, float pitch, float fClipSoundDist);
|
virtual void playSound(std::shared_ptr<Entity> entity,int iSound, double x, double y, double z, float volume, float pitch, float fClipSoundDist);
|
||||||
virtual void setTilesDirty(int x0, int y0, int z0, int x1, int y1, int z1, Level *level); // 4J - added level param
|
virtual void setTilesDirty(int x0, int y0, int z0, int x1, int y1, int z1, Level *level); // 4J - added level param
|
||||||
virtual void skyColorChanged();
|
virtual void skyColorChanged();
|
||||||
virtual void tileChanged(int x, int y, int z);
|
virtual void tileChanged(int x, int y, int z);
|
||||||
virtual void tileLightChanged(int x, int y, int z);
|
virtual void tileLightChanged(int x, int y, int z);
|
||||||
virtual void playStreamingMusic(const wstring& name, int x, int y, int z);
|
virtual void playStreamingMusic(const std::wstring& name, int x, int y, int z);
|
||||||
virtual void levelEvent(shared_ptr<Player> source, int type, int x, int y, int z, int data);
|
virtual void levelEvent(std::shared_ptr<Player> source, int type, int x, int y, int z, int data);
|
||||||
virtual void destroyTileProgress(int id, int x, int y, int z, int progress);
|
virtual void destroyTileProgress(int id, int x, int y, int z, int progress);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -236,7 +236,7 @@ void Minecraft::clearConnectionFailed()
|
|||||||
app.SetDisconnectReason(DisconnectPacket::eDisconnect_None);
|
app.SetDisconnectReason(DisconnectPacket::eDisconnect_None);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Minecraft::connectTo(const wstring& server, int port)
|
void Minecraft::connectTo(const std::wstring& server, int port)
|
||||||
{
|
{
|
||||||
connectToIp = server;
|
connectToIp = server;
|
||||||
connectToPort = port;
|
connectToPort = port;
|
||||||
@@ -489,7 +489,7 @@ File Minecraft::getWorkingDirectory()
|
|||||||
return workDir;
|
return workDir;
|
||||||
}
|
}
|
||||||
|
|
||||||
File Minecraft::getWorkingDirectory(const wstring& applicationName)
|
File Minecraft::getWorkingDirectory(const std::wstring& applicationName)
|
||||||
{
|
{
|
||||||
#if 0
|
#if 0
|
||||||
// 4J - original version
|
// 4J - original version
|
||||||
@@ -514,7 +514,7 @@ File Minecraft::getWorkingDirectory(const wstring& applicationName)
|
|||||||
if (!workingDirectory.exists()) if (!workingDirectory.mkdirs()) throw new RuntimeException("The working directory could not be created: " + workingDirectory);
|
if (!workingDirectory.exists()) if (!workingDirectory.mkdirs()) throw new RuntimeException("The working directory could not be created: " + workingDirectory);
|
||||||
return workingDirectory;
|
return workingDirectory;
|
||||||
#else
|
#else
|
||||||
wstring userHome = L"home"; // 4J - TODO
|
std::wstring userHome = L"home"; // 4J - TODO
|
||||||
File workingDirectory(userHome, applicationName);
|
File workingDirectory(userHome, applicationName);
|
||||||
// 4J Removed
|
// 4J Removed
|
||||||
//if (!workingDirectory.exists())
|
//if (!workingDirectory.exists())
|
||||||
@@ -620,7 +620,7 @@ void Minecraft::setScreen(Screen *screen)
|
|||||||
}*/
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
void Minecraft::checkGlError(const wstring& string)
|
void Minecraft::checkGlError(const std::wstring& string)
|
||||||
{
|
{
|
||||||
// 4J - TODO
|
// 4J - TODO
|
||||||
}
|
}
|
||||||
@@ -977,7 +977,7 @@ bool Minecraft::addLocalPlayer(int idx)
|
|||||||
if(success)
|
if(success)
|
||||||
{
|
{
|
||||||
app.DebugPrintf("Adding temp local player on pad %d\n", idx);
|
app.DebugPrintf("Adding temp local player on pad %d\n", idx);
|
||||||
localplayers[idx] = shared_ptr<MultiplayerLocalPlayer>( new MultiplayerLocalPlayer(this, level, user, NULL ) );
|
localplayers[idx] = std::shared_ptr<MultiplayerLocalPlayer>( new MultiplayerLocalPlayer(this, level, user, NULL ) );
|
||||||
localgameModes[idx] = NULL;
|
localgameModes[idx] = NULL;
|
||||||
|
|
||||||
updatePlayerViewportAssignments();
|
updatePlayerViewportAssignments();
|
||||||
@@ -1025,7 +1025,7 @@ void Minecraft::addPendingLocalConnection(int idx, ClientConnection *connection)
|
|||||||
m_pendingLocalConnections[idx] = connection;
|
m_pendingLocalConnections[idx] = connection;
|
||||||
}
|
}
|
||||||
|
|
||||||
shared_ptr<MultiplayerLocalPlayer> Minecraft::createExtraLocalPlayer(int idx, const wstring& name, int iPad, int iDimension, ClientConnection *clientConnection /*= NULL*/,MultiPlayerLevel *levelpassedin)
|
std::shared_ptr<MultiplayerLocalPlayer> Minecraft::createExtraLocalPlayer(int idx, const std::wstring& name, int iPad, int iDimension, ClientConnection *clientConnection /*= NULL*/,MultiPlayerLevel *levelpassedin)
|
||||||
{
|
{
|
||||||
if( clientConnection == NULL) return nullptr;
|
if( clientConnection == NULL) return nullptr;
|
||||||
|
|
||||||
@@ -1037,7 +1037,7 @@ shared_ptr<MultiplayerLocalPlayer> Minecraft::createExtraLocalPlayer(int idx, co
|
|||||||
// A temp player displaying a connecting screen
|
// A temp player displaying a connecting screen
|
||||||
tempScreenSection = localplayers[idx]->m_iScreenSection;
|
tempScreenSection = localplayers[idx]->m_iScreenSection;
|
||||||
}
|
}
|
||||||
wstring prevname = user->name;
|
std::wstring prevname = user->name;
|
||||||
user->name = name;
|
user->name = name;
|
||||||
|
|
||||||
// Don't need this any more
|
// Don't need this any more
|
||||||
@@ -1141,7 +1141,7 @@ void Minecraft::removeLocalPlayerIdx(int idx)
|
|||||||
{
|
{
|
||||||
if( getLevel( localplayers[idx]->dimension )->isClientSide )
|
if( getLevel( localplayers[idx]->dimension )->isClientSide )
|
||||||
{
|
{
|
||||||
shared_ptr<MultiplayerLocalPlayer> mplp = localplayers[idx];
|
std::shared_ptr<MultiplayerLocalPlayer> mplp = localplayers[idx];
|
||||||
( (MultiPlayerLevel *)getLevel( localplayers[idx]->dimension ) )->removeClientConnection(mplp->connection, true);
|
( (MultiPlayerLevel *)getLevel( localplayers[idx]->dimension ) )->removeClientConnection(mplp->connection, true);
|
||||||
delete mplp->connection;
|
delete mplp->connection;
|
||||||
mplp->connection = NULL;
|
mplp->connection = NULL;
|
||||||
@@ -1163,7 +1163,7 @@ void Minecraft::removeLocalPlayerIdx(int idx)
|
|||||||
}
|
}
|
||||||
else if( m_pendingLocalConnections[idx] != NULL )
|
else if( m_pendingLocalConnections[idx] != NULL )
|
||||||
{
|
{
|
||||||
m_pendingLocalConnections[idx]->sendAndDisconnect( shared_ptr<DisconnectPacket>( new DisconnectPacket(DisconnectPacket::eDisconnect_Quitting) ) );;
|
m_pendingLocalConnections[idx]->sendAndDisconnect( std::shared_ptr<DisconnectPacket>( new DisconnectPacket(DisconnectPacket::eDisconnect_Quitting) ) );;
|
||||||
delete m_pendingLocalConnections[idx];
|
delete m_pendingLocalConnections[idx];
|
||||||
m_pendingLocalConnections[idx] = NULL;
|
m_pendingLocalConnections[idx] = NULL;
|
||||||
g_NetworkManager.RemoveLocalPlayerByUserIndex(idx);
|
g_NetworkManager.RemoveLocalPlayerByUserIndex(idx);
|
||||||
@@ -1584,7 +1584,7 @@ void Minecraft::run_middle()
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// create the localplayer
|
// create the localplayer
|
||||||
shared_ptr<Player> player = localplayers[i];
|
std::shared_ptr<Player> player = localplayers[i];
|
||||||
if( player == NULL)
|
if( player == NULL)
|
||||||
{
|
{
|
||||||
player = createExtraLocalPlayer(i, (convStringToWstring( ProfileManager.GetGamertag(i) )).c_str(), i, level->dimension->id);
|
player = createExtraLocalPlayer(i, (convStringToWstring( ProfileManager.GetGamertag(i) )).c_str(), i, level->dimension->id);
|
||||||
@@ -1800,7 +1800,7 @@ void Minecraft::run_middle()
|
|||||||
// if (pause) timer.a = 1;
|
// if (pause) timer.a = 1;
|
||||||
|
|
||||||
PIXBeginNamedEvent(0,"Sound engine update");
|
PIXBeginNamedEvent(0,"Sound engine update");
|
||||||
soundEngine->tick((shared_ptr<Mob> *)localplayers, timer->a);
|
soundEngine->tick((std::shared_ptr<Mob> *)localplayers, timer->a);
|
||||||
PIXEndNamedEvent();
|
PIXEndNamedEvent();
|
||||||
|
|
||||||
PIXBeginNamedEvent(0,"Light update");
|
PIXBeginNamedEvent(0,"Light update");
|
||||||
@@ -2345,7 +2345,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// no hit result, but we may have something in our hand that we can do something with
|
// no hit result, but we may have something in our hand that we can do something with
|
||||||
shared_ptr<ItemInstance> itemInstance = player->inventory->getSelected();
|
std::shared_ptr<ItemInstance> itemInstance = player->inventory->getSelected();
|
||||||
|
|
||||||
// 4J-JEV: Moved all this here to avoid having it in 3 different places.
|
// 4J-JEV: Moved all this here to avoid having it in 3 different places.
|
||||||
if (itemInstance)
|
if (itemInstance)
|
||||||
@@ -2716,14 +2716,14 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures)
|
|||||||
// is there an object in hand?
|
// is there an object in hand?
|
||||||
if(player->inventory->IsHeldItem())
|
if(player->inventory->IsHeldItem())
|
||||||
{
|
{
|
||||||
shared_ptr<ItemInstance> heldItem=player->inventory->getSelected();
|
std::shared_ptr<ItemInstance> heldItem=player->inventory->getSelected();
|
||||||
int iID=heldItem->getItem()->id;
|
int iID=heldItem->getItem()->id;
|
||||||
|
|
||||||
switch(iID)
|
switch(iID)
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
shared_ptr<Animal> animal = dynamic_pointer_cast<Animal>(hitResult->entity);
|
std::shared_ptr<Animal> animal = dynamic_pointer_cast<Animal>(hitResult->entity);
|
||||||
|
|
||||||
if(!animal->isBaby() && !animal->isInLove() && (animal->getAge() == 0) && animal->isFood(heldItem))
|
if(!animal->isBaby() && !animal->isInLove() && (animal->getAge() == 0) && animal->isFood(heldItem))
|
||||||
{
|
{
|
||||||
@@ -2740,7 +2740,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures)
|
|||||||
// is there an object in hand?
|
// is there an object in hand?
|
||||||
if(player->inventory->IsHeldItem())
|
if(player->inventory->IsHeldItem())
|
||||||
{
|
{
|
||||||
shared_ptr<ItemInstance> heldItem=player->inventory->getSelected();
|
std::shared_ptr<ItemInstance> heldItem=player->inventory->getSelected();
|
||||||
int iID=heldItem->getItem()->id;
|
int iID=heldItem->getItem()->id;
|
||||||
|
|
||||||
// It's an item
|
// It's an item
|
||||||
@@ -2752,7 +2752,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures)
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
shared_ptr<Animal> animal = dynamic_pointer_cast<Animal>(hitResult->entity);
|
std::shared_ptr<Animal> animal = dynamic_pointer_cast<Animal>(hitResult->entity);
|
||||||
|
|
||||||
if(!animal->isBaby() && !animal->isInLove() && (animal->getAge() == 0) && animal->isFood(heldItem))
|
if(!animal->isBaby() && !animal->isInLove() && (animal->getAge() == 0) && animal->isFood(heldItem))
|
||||||
{
|
{
|
||||||
@@ -2769,7 +2769,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures)
|
|||||||
{
|
{
|
||||||
if(player->isAllowedToAttackAnimals()) *piAction=IDS_TOOLTIPS_HIT;
|
if(player->isAllowedToAttackAnimals()) *piAction=IDS_TOOLTIPS_HIT;
|
||||||
|
|
||||||
shared_ptr<ItemInstance> heldItem=player->inventory->getSelected();
|
std::shared_ptr<ItemInstance> heldItem=player->inventory->getSelected();
|
||||||
int iID=heldItem->getItem()->id;
|
int iID=heldItem->getItem()->id;
|
||||||
|
|
||||||
// It's an item
|
// It's an item
|
||||||
@@ -2783,13 +2783,13 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures)
|
|||||||
case Item::shears_Id:
|
case Item::shears_Id:
|
||||||
{
|
{
|
||||||
if(player->isAllowedToAttackAnimals()) *piAction=IDS_TOOLTIPS_HIT;
|
if(player->isAllowedToAttackAnimals()) *piAction=IDS_TOOLTIPS_HIT;
|
||||||
shared_ptr<Animal> animal = dynamic_pointer_cast<Animal>(hitResult->entity);
|
std::shared_ptr<Animal> animal = dynamic_pointer_cast<Animal>(hitResult->entity);
|
||||||
if(!animal->isBaby()) *piUse=IDS_TOOLTIPS_SHEAR;
|
if(!animal->isBaby()) *piUse=IDS_TOOLTIPS_SHEAR;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
shared_ptr<Animal> animal = dynamic_pointer_cast<Animal>(hitResult->entity);
|
std::shared_ptr<Animal> animal = dynamic_pointer_cast<Animal>(hitResult->entity);
|
||||||
|
|
||||||
if(!animal->isBaby() && !animal->isInLove() && (animal->getAge() == 0) && animal->isFood(heldItem))
|
if(!animal->isBaby() && !animal->isInLove() && (animal->getAge() == 0) && animal->isFood(heldItem))
|
||||||
{
|
{
|
||||||
@@ -2842,7 +2842,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures)
|
|||||||
// is there an object in hand?
|
// is there an object in hand?
|
||||||
if(player->inventory->IsHeldItem())
|
if(player->inventory->IsHeldItem())
|
||||||
{
|
{
|
||||||
shared_ptr<ItemInstance> heldItem=player->inventory->getSelected();
|
std::shared_ptr<ItemInstance> heldItem=player->inventory->getSelected();
|
||||||
int iID=heldItem->getItem()->id;
|
int iID=heldItem->getItem()->id;
|
||||||
|
|
||||||
if(iID==Item::coal->id)
|
if(iID==Item::coal->id)
|
||||||
@@ -2864,14 +2864,14 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures)
|
|||||||
if(player->isAllowedToAttackAnimals()) *piAction=IDS_TOOLTIPS_HIT;
|
if(player->isAllowedToAttackAnimals()) *piAction=IDS_TOOLTIPS_HIT;
|
||||||
if(player->inventory->IsHeldItem())
|
if(player->inventory->IsHeldItem())
|
||||||
{
|
{
|
||||||
shared_ptr<ItemInstance> heldItem=player->inventory->getSelected();
|
std::shared_ptr<ItemInstance> heldItem=player->inventory->getSelected();
|
||||||
int iID=heldItem->getItem()->id;
|
int iID=heldItem->getItem()->id;
|
||||||
|
|
||||||
switch(iID)
|
switch(iID)
|
||||||
{
|
{
|
||||||
case Item::dye_powder_Id:
|
case Item::dye_powder_Id:
|
||||||
{
|
{
|
||||||
shared_ptr<Sheep> sheep = dynamic_pointer_cast<Sheep>(hitResult->entity);
|
std::shared_ptr<Sheep> sheep = dynamic_pointer_cast<Sheep>(hitResult->entity);
|
||||||
// convert to tile-based color value (0 is white instead of black)
|
// convert to tile-based color value (0 is white instead of black)
|
||||||
int newColor = ClothTile::getTileDataForItemAuxValue(heldItem->getAuxValue());
|
int newColor = ClothTile::getTileDataForItemAuxValue(heldItem->getAuxValue());
|
||||||
|
|
||||||
@@ -2884,7 +2884,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures)
|
|||||||
break;
|
break;
|
||||||
case Item::shears_Id:
|
case Item::shears_Id:
|
||||||
{
|
{
|
||||||
shared_ptr<Sheep> sheep = dynamic_pointer_cast<Sheep>(hitResult->entity);
|
std::shared_ptr<Sheep> sheep = dynamic_pointer_cast<Sheep>(hitResult->entity);
|
||||||
|
|
||||||
// can only shear a sheep that hasn't been sheared
|
// can only shear a sheep that hasn't been sheared
|
||||||
if(!sheep->isSheared() )
|
if(!sheep->isSheared() )
|
||||||
@@ -2896,7 +2896,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures)
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
shared_ptr<Animal> animal = dynamic_pointer_cast<Animal>(hitResult->entity);
|
std::shared_ptr<Animal> animal = dynamic_pointer_cast<Animal>(hitResult->entity);
|
||||||
|
|
||||||
if(!animal->isBaby() && !animal->isInLove() && (animal->getAge() == 0) && animal->isFood(heldItem))
|
if(!animal->isBaby() && !animal->isInLove() && (animal->getAge() == 0) && animal->isFood(heldItem))
|
||||||
{
|
{
|
||||||
@@ -2926,7 +2926,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures)
|
|||||||
{
|
{
|
||||||
if(player->inventory->IsHeldItem())
|
if(player->inventory->IsHeldItem())
|
||||||
{
|
{
|
||||||
shared_ptr<ItemInstance> heldItem=player->inventory->getSelected();
|
std::shared_ptr<ItemInstance> heldItem=player->inventory->getSelected();
|
||||||
int iID=heldItem->getItem()->id;
|
int iID=heldItem->getItem()->id;
|
||||||
|
|
||||||
switch(iID)
|
switch(iID)
|
||||||
@@ -2936,7 +2936,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures)
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
shared_ptr<Animal> animal = dynamic_pointer_cast<Animal>(hitResult->entity);
|
std::shared_ptr<Animal> animal = dynamic_pointer_cast<Animal>(hitResult->entity);
|
||||||
|
|
||||||
if(!animal->isBaby() && !animal->isInLove() && (animal->getAge() == 0) && animal->isFood(heldItem))
|
if(!animal->isBaby() && !animal->isInLove() && (animal->getAge() == 0) && animal->isFood(heldItem))
|
||||||
{
|
{
|
||||||
@@ -2954,8 +2954,8 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures)
|
|||||||
// can be tamed, fed, and made to sit/stand, or enter love mode
|
// can be tamed, fed, and made to sit/stand, or enter love mode
|
||||||
{
|
{
|
||||||
int iID=-1;
|
int iID=-1;
|
||||||
shared_ptr<ItemInstance> heldItem=nullptr;
|
std::shared_ptr<ItemInstance> heldItem=nullptr;
|
||||||
shared_ptr<Wolf> wolf = dynamic_pointer_cast<Wolf>(hitResult->entity);
|
std::shared_ptr<Wolf> wolf = dynamic_pointer_cast<Wolf>(hitResult->entity);
|
||||||
|
|
||||||
if(player->inventory->IsHeldItem())
|
if(player->inventory->IsHeldItem())
|
||||||
{
|
{
|
||||||
@@ -3044,8 +3044,8 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures)
|
|||||||
case eTYPE_OZELOT:
|
case eTYPE_OZELOT:
|
||||||
{
|
{
|
||||||
int iID=-1;
|
int iID=-1;
|
||||||
shared_ptr<ItemInstance> heldItem=nullptr;
|
std::shared_ptr<ItemInstance> heldItem=nullptr;
|
||||||
shared_ptr<Ozelot> ocelot = dynamic_pointer_cast<Ozelot>(hitResult->entity);
|
std::shared_ptr<Ozelot> ocelot = dynamic_pointer_cast<Ozelot>(hitResult->entity);
|
||||||
|
|
||||||
if(player->inventory->IsHeldItem())
|
if(player->inventory->IsHeldItem())
|
||||||
{
|
{
|
||||||
@@ -3106,7 +3106,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures)
|
|||||||
case eTYPE_PLAYER:
|
case eTYPE_PLAYER:
|
||||||
{
|
{
|
||||||
// Fix for #58576 - TU6: Content: Gameplay: Hit button prompt is available when attacking a host who has "Invisible" option turned on
|
// Fix for #58576 - TU6: Content: Gameplay: Hit button prompt is available when attacking a host who has "Invisible" option turned on
|
||||||
shared_ptr<Player> TargetPlayer = dynamic_pointer_cast<Player>(hitResult->entity);
|
std::shared_ptr<Player> TargetPlayer = dynamic_pointer_cast<Player>(hitResult->entity);
|
||||||
|
|
||||||
if(!TargetPlayer->hasInvisiblePrivilege()) // This means they are invisible, not just that they have the privilege
|
if(!TargetPlayer->hasInvisiblePrivilege()) // This means they are invisible, not just that they have the privilege
|
||||||
{
|
{
|
||||||
@@ -3119,7 +3119,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures)
|
|||||||
break;
|
break;
|
||||||
case eTYPE_ITEM_FRAME:
|
case eTYPE_ITEM_FRAME:
|
||||||
{
|
{
|
||||||
shared_ptr<ItemFrame> itemFrame = dynamic_pointer_cast<ItemFrame>(hitResult->entity);
|
std::shared_ptr<ItemFrame> itemFrame = dynamic_pointer_cast<ItemFrame>(hitResult->entity);
|
||||||
|
|
||||||
// is the frame occupied?
|
// is the frame occupied?
|
||||||
if(itemFrame->getItem()!=NULL)
|
if(itemFrame->getItem()!=NULL)
|
||||||
@@ -3141,7 +3141,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures)
|
|||||||
break;
|
break;
|
||||||
case eTYPE_VILLAGER:
|
case eTYPE_VILLAGER:
|
||||||
{
|
{
|
||||||
shared_ptr<Villager> villager = dynamic_pointer_cast<Villager>(hitResult->entity);
|
std::shared_ptr<Villager> villager = dynamic_pointer_cast<Villager>(hitResult->entity);
|
||||||
if (!villager->isBaby())
|
if (!villager->isBaby())
|
||||||
{
|
{
|
||||||
*piUse=IDS_TOOLTIPS_TRADE;
|
*piUse=IDS_TOOLTIPS_TRADE;
|
||||||
@@ -3151,8 +3151,8 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures)
|
|||||||
break;
|
break;
|
||||||
case eTYPE_ZOMBIE:
|
case eTYPE_ZOMBIE:
|
||||||
{
|
{
|
||||||
shared_ptr<Zombie> zomb = dynamic_pointer_cast<Zombie>(hitResult->entity);
|
std::shared_ptr<Zombie> zomb = dynamic_pointer_cast<Zombie>(hitResult->entity);
|
||||||
shared_ptr<ItemInstance> heldItem=nullptr;
|
std::shared_ptr<ItemInstance> heldItem=nullptr;
|
||||||
|
|
||||||
if(player->inventory->IsHeldItem())
|
if(player->inventory->IsHeldItem())
|
||||||
{
|
{
|
||||||
@@ -3337,9 +3337,9 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures)
|
|||||||
|
|
||||||
if((player->ullButtonsPressed&(1LL<<MINECRAFT_ACTION_SPAWN_CREEPER)) && app.GetMobsDontAttackEnabled())
|
if((player->ullButtonsPressed&(1LL<<MINECRAFT_ACTION_SPAWN_CREEPER)) && app.GetMobsDontAttackEnabled())
|
||||||
{
|
{
|
||||||
//shared_ptr<Mob> mob = dynamic_pointer_cast<Mob>(Creeper::_class->newInstance( level ));
|
//std::shared_ptr<Mob> mob = dynamic_pointer_cast<Mob>(Creeper::_class->newInstance( level ));
|
||||||
//shared_ptr<Mob> mob = dynamic_pointer_cast<Mob>(Wolf::_class->newInstance( level ));
|
//std::shared_ptr<Mob> mob = dynamic_pointer_cast<Mob>(Wolf::_class->newInstance( level ));
|
||||||
shared_ptr<Mob> mob = dynamic_pointer_cast<Mob>(shared_ptr<Spider>(new Spider( level )));
|
std::shared_ptr<Mob> mob = dynamic_pointer_cast<Mob>(std::shared_ptr<Spider>(new Spider( level )));
|
||||||
mob->moveTo(player->x+1, player->y, player->z+1, level->random->nextFloat() * 360, 0);
|
mob->moveTo(player->x+1, player->y, player->z+1, level->random->nextFloat() * 360, 0);
|
||||||
level->addEntity(mob);
|
level->addEntity(mob);
|
||||||
}
|
}
|
||||||
@@ -3369,14 +3369,14 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures)
|
|||||||
|
|
||||||
if((player->ullButtonsPressed&(1LL<<MINECRAFT_ACTION_INVENTORY)) && gameMode->isInputAllowed(MINECRAFT_ACTION_INVENTORY))
|
if((player->ullButtonsPressed&(1LL<<MINECRAFT_ACTION_INVENTORY)) && gameMode->isInputAllowed(MINECRAFT_ACTION_INVENTORY))
|
||||||
{
|
{
|
||||||
shared_ptr<LocalPlayer> player = dynamic_pointer_cast<LocalPlayer>( Minecraft::GetInstance()->player );
|
std::shared_ptr<LocalPlayer> player = dynamic_pointer_cast<LocalPlayer>( Minecraft::GetInstance()->player );
|
||||||
ui.PlayUISFX(eSFX_Press);
|
ui.PlayUISFX(eSFX_Press);
|
||||||
app.LoadInventoryMenu(iPad,player);
|
app.LoadInventoryMenu(iPad,player);
|
||||||
}
|
}
|
||||||
|
|
||||||
if((player->ullButtonsPressed&(1LL<<MINECRAFT_ACTION_CRAFTING)) && gameMode->isInputAllowed(MINECRAFT_ACTION_CRAFTING))
|
if((player->ullButtonsPressed&(1LL<<MINECRAFT_ACTION_CRAFTING)) && gameMode->isInputAllowed(MINECRAFT_ACTION_CRAFTING))
|
||||||
{
|
{
|
||||||
shared_ptr<LocalPlayer> player = dynamic_pointer_cast<LocalPlayer>( Minecraft::GetInstance()->player );
|
std::shared_ptr<LocalPlayer> player = dynamic_pointer_cast<LocalPlayer>( Minecraft::GetInstance()->player );
|
||||||
|
|
||||||
// 4J-PB - reordered the if statement so creative mode doesn't bring up the crafting table
|
// 4J-PB - reordered the if statement so creative mode doesn't bring up the crafting table
|
||||||
// Fix for #39014 - TU5: Creative Mode: Pressing X to access the creative menu while looking at a crafting table causes the crafting menu to display
|
// Fix for #39014 - TU5: Creative Mode: Pressing X to access the creative menu while looking at a crafting table causes the crafting menu to display
|
||||||
@@ -3439,8 +3439,8 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures)
|
|||||||
#endif
|
#endif
|
||||||
if( selected || wheel != 0 || (player->ullButtonsPressed&(1LL<<MINECRAFT_ACTION_DROP)) )
|
if( selected || wheel != 0 || (player->ullButtonsPressed&(1LL<<MINECRAFT_ACTION_DROP)) )
|
||||||
{
|
{
|
||||||
wstring itemName = L"";
|
std::wstring itemName = L"";
|
||||||
shared_ptr<ItemInstance> selectedItem = player->getSelectedItem();
|
std::shared_ptr<ItemInstance> selectedItem = player->getSelectedItem();
|
||||||
// Dropping items happens over network, so if we only have one then assume that we dropped it and should hide the item
|
// Dropping items happens over network, so if we only have one then assume that we dropped it and should hide the item
|
||||||
int iCount=0;
|
int iCount=0;
|
||||||
|
|
||||||
@@ -3708,7 +3708,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures)
|
|||||||
setLocalPlayerIdx(idx);
|
setLocalPlayerIdx(idx);
|
||||||
gameRenderer->setupCamera(timer->a, i);
|
gameRenderer->setupCamera(timer->a, i);
|
||||||
Camera::prepare(localplayers[idx], localplayers[idx]->ThirdPersonView() == 2);
|
Camera::prepare(localplayers[idx], localplayers[idx]->ThirdPersonView() == 2);
|
||||||
shared_ptr<Mob> cameraEntity = cameraTargetPlayer;
|
std::shared_ptr<Mob> cameraEntity = cameraTargetPlayer;
|
||||||
double xOff = cameraEntity->xOld + (cameraEntity->x - cameraEntity->xOld) * timer->a;
|
double xOff = cameraEntity->xOld + (cameraEntity->x - cameraEntity->xOld) * timer->a;
|
||||||
double yOff = cameraEntity->yOld + (cameraEntity->y - cameraEntity->yOld) * timer->a;
|
double yOff = cameraEntity->yOld + (cameraEntity->y - cameraEntity->yOld) * timer->a;
|
||||||
double zOff = cameraEntity->zOld + (cameraEntity->z - cameraEntity->zOld) * timer->a;
|
double zOff = cameraEntity->zOld + (cameraEntity->z - cameraEntity->zOld) * timer->a;
|
||||||
@@ -3782,16 +3782,16 @@ bool Minecraft::isClientSide()
|
|||||||
return level != NULL && level->isClientSide;
|
return level != NULL && level->isClientSide;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Minecraft::selectLevel(ConsoleSaveFile *saveFile, const wstring& levelId, const wstring& levelName, LevelSettings *levelSettings)
|
void Minecraft::selectLevel(ConsoleSaveFile *saveFile, const std::wstring& levelId, const std::wstring& levelName, LevelSettings *levelSettings)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Minecraft::saveSlot(int slot, const wstring& name)
|
bool Minecraft::saveSlot(int slot, const std::wstring& name)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Minecraft::loadSlot(const wstring& userName, int slot)
|
bool Minecraft::loadSlot(const std::wstring& userName, int slot)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -3834,8 +3834,8 @@ MultiPlayerLevel *Minecraft::getLevel(int dimension)
|
|||||||
//}
|
//}
|
||||||
|
|
||||||
// Also causing ambiguous call for some reason
|
// Also causing ambiguous call for some reason
|
||||||
// as it is matching shared_ptr<Player> from the func below with bool from this one
|
// as it is matching std::shared_ptr<Player> from the func below with bool from this one
|
||||||
//void Minecraft::setLevel(Level *level, const wstring& message, bool doForceStatsSave /*= true*/)
|
//void Minecraft::setLevel(Level *level, const std::wstring& message, bool doForceStatsSave /*= true*/)
|
||||||
//{
|
//{
|
||||||
// setLevel(level, message, NULL, doForceStatsSave);
|
// setLevel(level, message, NULL, doForceStatsSave);
|
||||||
//}
|
//}
|
||||||
@@ -3848,7 +3848,7 @@ void Minecraft::forceaddLevel(MultiPlayerLevel *level)
|
|||||||
else levels[0] = level;
|
else levels[0] = level;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Minecraft::setLevel(MultiPlayerLevel *level, int message /*=-1*/, shared_ptr<Player> forceInsertPlayer /*=NULL*/, bool doForceStatsSave /*=true*/, bool bPrimaryPlayerSignedOut /*=false*/)
|
void Minecraft::setLevel(MultiPlayerLevel *level, int message /*=-1*/, std::shared_ptr<Player> forceInsertPlayer /*=NULL*/, bool doForceStatsSave /*=true*/, bool bPrimaryPlayerSignedOut /*=false*/)
|
||||||
{
|
{
|
||||||
EnterCriticalSection(&m_setLevelCS);
|
EnterCriticalSection(&m_setLevelCS);
|
||||||
bool playerAdded = false;
|
bool playerAdded = false;
|
||||||
@@ -3913,7 +3913,7 @@ void Minecraft::setLevel(MultiPlayerLevel *level, int message /*=-1*/, shared_pt
|
|||||||
// Delete all the player objects
|
// Delete all the player objects
|
||||||
for(unsigned int idx = 0; idx < XUSER_MAX_COUNT; ++idx)
|
for(unsigned int idx = 0; idx < XUSER_MAX_COUNT; ++idx)
|
||||||
{
|
{
|
||||||
shared_ptr<MultiplayerLocalPlayer> mplp = localplayers[idx];
|
std::shared_ptr<MultiplayerLocalPlayer> mplp = localplayers[idx];
|
||||||
if(mplp != NULL && mplp->connection != NULL )
|
if(mplp != NULL && mplp->connection != NULL )
|
||||||
{
|
{
|
||||||
delete mplp->connection;
|
delete mplp->connection;
|
||||||
@@ -4106,11 +4106,11 @@ void Minecraft::prepareLevel(int title)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Minecraft::fileDownloaded(const wstring& name, File *file)
|
void Minecraft::fileDownloaded(const std::wstring& name, File *file)
|
||||||
{
|
{
|
||||||
int p = (int)name.find(L"/");
|
int p = (int)name.find(L"/");
|
||||||
wstring category = name.substr(0, p);
|
std::wstring category = name.substr(0, p);
|
||||||
wstring name2 = name.substr(p + 1);
|
std::wstring name2 = name.substr(p + 1);
|
||||||
toLower(category);
|
toLower(category);
|
||||||
if (category==L"sound")
|
if (category==L"sound")
|
||||||
{
|
{
|
||||||
@@ -4134,25 +4134,25 @@ void Minecraft::fileDownloaded(const wstring& name, File *file)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
wstring Minecraft::gatherStats1()
|
std::wstring Minecraft::gatherStats1()
|
||||||
{
|
{
|
||||||
//return levelRenderer->gatherStats1();
|
//return levelRenderer->gatherStats1();
|
||||||
return L"Time to autosave: " + _toString<unsigned int>( app.SecondsToAutosave() ) + L"s";
|
return L"Time to autosave: " + _toString<unsigned int>( app.SecondsToAutosave() ) + L"s";
|
||||||
}
|
}
|
||||||
|
|
||||||
wstring Minecraft::gatherStats2()
|
std::wstring Minecraft::gatherStats2()
|
||||||
{
|
{
|
||||||
return g_NetworkManager.GatherStats();
|
return g_NetworkManager.GatherStats();
|
||||||
//return levelRenderer->gatherStats2();
|
//return levelRenderer->gatherStats2();
|
||||||
}
|
}
|
||||||
|
|
||||||
wstring Minecraft::gatherStats3()
|
std::wstring Minecraft::gatherStats3()
|
||||||
{
|
{
|
||||||
return g_NetworkManager.GatherRTTStats();
|
return g_NetworkManager.GatherRTTStats();
|
||||||
//return L"P: " + particleEngine->countParticles() + L". T: " + level->gatherStats();
|
//return L"P: " + particleEngine->countParticles() + L". T: " + level->gatherStats();
|
||||||
}
|
}
|
||||||
|
|
||||||
wstring Minecraft::gatherStats4()
|
std::wstring Minecraft::gatherStats4()
|
||||||
{
|
{
|
||||||
return level->gatherChunkSourceStats();
|
return level->gatherChunkSourceStats();
|
||||||
}
|
}
|
||||||
@@ -4160,7 +4160,7 @@ wstring Minecraft::gatherStats4()
|
|||||||
void Minecraft::respawnPlayer(int iPad, int dimension, int newEntityId)
|
void Minecraft::respawnPlayer(int iPad, int dimension, int newEntityId)
|
||||||
{
|
{
|
||||||
gameRenderer->DisableUpdateThread(); // 4J - don't do updating whilst we are adjusting the player & localplayer array
|
gameRenderer->DisableUpdateThread(); // 4J - don't do updating whilst we are adjusting the player & localplayer array
|
||||||
shared_ptr<MultiplayerLocalPlayer> localPlayer = localplayers[iPad];
|
std::shared_ptr<MultiplayerLocalPlayer> localPlayer = localplayers[iPad];
|
||||||
|
|
||||||
level->validateSpawn();
|
level->validateSpawn();
|
||||||
level->removeAllPendingEntityRemovals();
|
level->removeAllPendingEntityRemovals();
|
||||||
@@ -4171,7 +4171,7 @@ void Minecraft::respawnPlayer(int iPad, int dimension, int newEntityId)
|
|||||||
level->removeEntity(localPlayer);
|
level->removeEntity(localPlayer);
|
||||||
}
|
}
|
||||||
|
|
||||||
shared_ptr<Player> oldPlayer = localPlayer;
|
std::shared_ptr<Player> oldPlayer = localPlayer;
|
||||||
cameraTargetPlayer = nullptr;
|
cameraTargetPlayer = nullptr;
|
||||||
|
|
||||||
// 4J-PB - copy and set the players xbox pad
|
// 4J-PB - copy and set the players xbox pad
|
||||||
@@ -4260,15 +4260,15 @@ void Minecraft::respawnPlayer(int iPad, int dimension, int newEntityId)
|
|||||||
gameRenderer->EnableUpdateThread();
|
gameRenderer->EnableUpdateThread();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Minecraft::start(const wstring& name, const wstring& sid)
|
void Minecraft::start(const std::wstring& name, const std::wstring& sid)
|
||||||
{
|
{
|
||||||
startAndConnectTo(name, sid, L"");
|
startAndConnectTo(name, sid, L"");
|
||||||
}
|
}
|
||||||
|
|
||||||
void Minecraft::startAndConnectTo(const wstring& name, const wstring& sid, const wstring& url)
|
void Minecraft::startAndConnectTo(const std::wstring& name, const std::wstring& sid, const std::wstring& url)
|
||||||
{
|
{
|
||||||
bool fullScreen = false;
|
bool fullScreen = false;
|
||||||
wstring userName = name;
|
std::wstring userName = name;
|
||||||
|
|
||||||
/* 4J - removed window handling things here
|
/* 4J - removed window handling things here
|
||||||
final Frame frame = new Frame("Minecraft");
|
final Frame frame = new Frame("Minecraft");
|
||||||
@@ -4367,8 +4367,8 @@ int g_iMainThreadId;
|
|||||||
|
|
||||||
void Minecraft::main()
|
void Minecraft::main()
|
||||||
{
|
{
|
||||||
wstring name;
|
std::wstring name;
|
||||||
wstring sessionId;
|
std::wstring sessionId;
|
||||||
|
|
||||||
//g_iMainThreadId = GetCurrentThreadId();
|
//g_iMainThreadId = GetCurrentThreadId();
|
||||||
|
|
||||||
@@ -4452,7 +4452,7 @@ bool Minecraft::renderDebug()
|
|||||||
return (m_instance != NULL && m_instance->options->renderDebug);
|
return (m_instance != NULL && m_instance->options->renderDebug);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Minecraft::handleClientSideCommand(const wstring& chatMessage)
|
bool Minecraft::handleClientSideCommand(const std::wstring& chatMessage)
|
||||||
{
|
{
|
||||||
/* 4J - TODO
|
/* 4J - TODO
|
||||||
if (chatMessage.startsWith("/")) {
|
if (chatMessage.startsWith("/")) {
|
||||||
@@ -4559,7 +4559,7 @@ bool mayUse = true;
|
|||||||
|
|
||||||
if(button==1 && (player->isSleeping() && level != NULL && level->isClientSide))
|
if(button==1 && (player->isSleeping() && level != NULL && level->isClientSide))
|
||||||
{
|
{
|
||||||
shared_ptr<MultiplayerLocalPlayer> mplp = dynamic_pointer_cast<MultiplayerLocalPlayer>( player );
|
std::shared_ptr<MultiplayerLocalPlayer> mplp = dynamic_pointer_cast<MultiplayerLocalPlayer>( player );
|
||||||
|
|
||||||
if(mplp) mplp->StopSleeping();
|
if(mplp) mplp->StopSleeping();
|
||||||
|
|
||||||
@@ -4608,7 +4608,7 @@ gameMode->startDestroyBlock(x, y, z, hitResult->f);
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
shared_ptr<ItemInstance> item = player->inventory->getSelected();
|
std::shared_ptr<ItemInstance> item = player->inventory->getSelected();
|
||||||
int oldCount = item != NULL ? item->count : 0;
|
int oldCount = item != NULL ? item->count : 0;
|
||||||
if (gameMode->useItemOn(player, level, item, x, y, z, face))
|
if (gameMode->useItemOn(player, level, item, x, y, z, face))
|
||||||
{
|
{
|
||||||
@@ -4634,7 +4634,7 @@ gameRenderer->itemInHandRenderer->itemPlaced();
|
|||||||
|
|
||||||
if (mayUse && button == 1)
|
if (mayUse && button == 1)
|
||||||
{
|
{
|
||||||
shared_ptr<ItemInstance> item = player->inventory->getSelected();
|
std::shared_ptr<ItemInstance> item = player->inventory->getSelected();
|
||||||
if (item != NULL)
|
if (item != NULL)
|
||||||
{
|
{
|
||||||
if (gameMode->useItem(player, level, item))
|
if (gameMode->useItem(player, level, item))
|
||||||
@@ -4721,7 +4721,7 @@ void Minecraft::inGameSignInCheckAllPrivilegesCallback(LPVOID lpParam, bool hasP
|
|||||||
else if( ProfileManager.IsSignedInLive(iPad) && ProfileManager.AllowedToPlayMultiplayer(iPad) )
|
else if( ProfileManager.IsSignedInLive(iPad) && ProfileManager.AllowedToPlayMultiplayer(iPad) )
|
||||||
{
|
{
|
||||||
// create the local player for the iPad
|
// create the local player for the iPad
|
||||||
shared_ptr<Player> player = pClass->localplayers[iPad];
|
std::shared_ptr<Player> player = pClass->localplayers[iPad];
|
||||||
if( player == NULL)
|
if( player == NULL)
|
||||||
{
|
{
|
||||||
if( pClass->level->isClientSide )
|
if( pClass->level->isClientSide )
|
||||||
@@ -4731,7 +4731,7 @@ void Minecraft::inGameSignInCheckAllPrivilegesCallback(LPVOID lpParam, bool hasP
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// create the local player for the iPad
|
// create the local player for the iPad
|
||||||
shared_ptr<Player> player = pClass->localplayers[iPad];
|
std::shared_ptr<Player> player = pClass->localplayers[iPad];
|
||||||
if( player == NULL)
|
if( player == NULL)
|
||||||
{
|
{
|
||||||
player = pClass->createExtraLocalPlayer(iPad, (convStringToWstring( ProfileManager.GetGamertag(iPad) )).c_str(), iPad, pClass->level->dimension->id);
|
player = pClass->createExtraLocalPlayer(iPad, (convStringToWstring( ProfileManager.GetGamertag(iPad) )).c_str(), iPad, pClass->level->dimension->id);
|
||||||
@@ -4802,7 +4802,7 @@ int Minecraft::InGame_SignInReturned(void *pParam,bool bContinue, int iPad)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// create the local player for the iPad
|
// create the local player for the iPad
|
||||||
shared_ptr<Player> player = pMinecraftClass->localplayers[iPad];
|
std::shared_ptr<Player> player = pMinecraftClass->localplayers[iPad];
|
||||||
if( player == NULL)
|
if( player == NULL)
|
||||||
{
|
{
|
||||||
player = pMinecraftClass->createExtraLocalPlayer(iPad, (convStringToWstring( ProfileManager.GetGamertag(iPad) )).c_str(), iPad, pMinecraftClass->level->dimension->id);
|
player = pMinecraftClass->createExtraLocalPlayer(iPad, (convStringToWstring( ProfileManager.GetGamertag(iPad) )).c_str(), iPad, pMinecraftClass->level->dimension->id);
|
||||||
@@ -4831,7 +4831,7 @@ void Minecraft::tickAllConnections()
|
|||||||
int oldIdx = getLocalPlayerIdx();
|
int oldIdx = getLocalPlayerIdx();
|
||||||
for(unsigned int i = 0; i < XUSER_MAX_COUNT; i++ )
|
for(unsigned int i = 0; i < XUSER_MAX_COUNT; i++ )
|
||||||
{
|
{
|
||||||
shared_ptr<MultiplayerLocalPlayer> mplp = localplayers[i];
|
std::shared_ptr<MultiplayerLocalPlayer> mplp = localplayers[i];
|
||||||
if( mplp && mplp->connection)
|
if( mplp && mplp->connection)
|
||||||
{
|
{
|
||||||
setLocalPlayerIdx(i);
|
setLocalPlayerIdx(i);
|
||||||
@@ -4841,7 +4841,7 @@ void Minecraft::tickAllConnections()
|
|||||||
setLocalPlayerIdx(oldIdx);
|
setLocalPlayerIdx(oldIdx);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Minecraft::addPendingClientTextureRequest(const wstring &textureName)
|
bool Minecraft::addPendingClientTextureRequest(const std::wstring &textureName)
|
||||||
{
|
{
|
||||||
AUTO_VAR(it, find( m_pendingTextureRequests.begin(), m_pendingTextureRequests.end(), textureName));
|
AUTO_VAR(it, find( m_pendingTextureRequests.begin(), m_pendingTextureRequests.end(), textureName));
|
||||||
if( it == m_pendingTextureRequests.end() )
|
if( it == m_pendingTextureRequests.end() )
|
||||||
@@ -4852,7 +4852,7 @@ bool Minecraft::addPendingClientTextureRequest(const wstring &textureName)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Minecraft::handleClientTextureReceived(const wstring &textureName)
|
void Minecraft::handleClientTextureReceived(const std::wstring &textureName)
|
||||||
{
|
{
|
||||||
AUTO_VAR(it, find( m_pendingTextureRequests.begin(), m_pendingTextureRequests.end(), textureName));
|
AUTO_VAR(it, find( m_pendingTextureRequests.begin(), m_pendingTextureRequests.end(), textureName));
|
||||||
if( it != m_pendingTextureRequests.end() )
|
if( it != m_pendingTextureRequests.end() )
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ class PsPlusUpsellWrapper;
|
|||||||
#undef linux
|
#undef linux
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
class Minecraft
|
class Minecraft
|
||||||
{
|
{
|
||||||
@@ -56,7 +56,7 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static const wstring VERSION_STRING;
|
static const std::wstring VERSION_STRING;
|
||||||
Minecraft(Component *mouseComponent, Canvas *parent, MinecraftApplet *minecraftApplet, int width, int height, bool fullscreen);
|
Minecraft(Component *mouseComponent, Canvas *parent, MinecraftApplet *minecraftApplet, int width, int height, bool fullscreen);
|
||||||
void init();
|
void init();
|
||||||
|
|
||||||
@@ -94,11 +94,11 @@ public:
|
|||||||
|
|
||||||
MultiPlayerLevel *level;
|
MultiPlayerLevel *level;
|
||||||
LevelRenderer *levelRenderer;
|
LevelRenderer *levelRenderer;
|
||||||
shared_ptr<MultiplayerLocalPlayer> player;
|
std::shared_ptr<MultiplayerLocalPlayer> player;
|
||||||
|
|
||||||
MultiPlayerLevelArray levels;
|
MultiPlayerLevelArray levels;
|
||||||
|
|
||||||
shared_ptr<MultiplayerLocalPlayer> localplayers[XUSER_MAX_COUNT];
|
std::shared_ptr<MultiplayerLocalPlayer> localplayers[XUSER_MAX_COUNT];
|
||||||
MultiPlayerGameMode *localgameModes[XUSER_MAX_COUNT];
|
MultiPlayerGameMode *localgameModes[XUSER_MAX_COUNT];
|
||||||
int localPlayerIdx;
|
int localPlayerIdx;
|
||||||
ItemInHandRenderer *localitemInHandRenderers[XUSER_MAX_COUNT];
|
ItemInHandRenderer *localitemInHandRenderers[XUSER_MAX_COUNT];
|
||||||
@@ -114,7 +114,7 @@ public:
|
|||||||
void addPendingLocalConnection(int idx, ClientConnection *connection);
|
void addPendingLocalConnection(int idx, ClientConnection *connection);
|
||||||
void connectionDisconnected(int idx, DisconnectPacket::eDisconnectReason reason) { m_connectionFailed[idx] = true; m_connectionFailedReason[idx] = reason; }
|
void connectionDisconnected(int idx, DisconnectPacket::eDisconnectReason reason) { m_connectionFailed[idx] = true; m_connectionFailedReason[idx] = reason; }
|
||||||
|
|
||||||
shared_ptr<MultiplayerLocalPlayer> createExtraLocalPlayer(int idx, const wstring& name, int pad, int iDimension, ClientConnection *clientConnection = NULL,MultiPlayerLevel *levelpassedin=NULL);
|
std::shared_ptr<MultiplayerLocalPlayer> createExtraLocalPlayer(int idx, const std::wstring& name, int pad, int iDimension, ClientConnection *clientConnection = NULL,MultiPlayerLevel *levelpassedin=NULL);
|
||||||
void createPrimaryLocalPlayer(int iPad);
|
void createPrimaryLocalPlayer(int iPad);
|
||||||
bool setLocalPlayerIdx(int idx);
|
bool setLocalPlayerIdx(int idx);
|
||||||
int getLocalPlayerIdx();
|
int getLocalPlayerIdx();
|
||||||
@@ -123,10 +123,10 @@ public:
|
|||||||
void updatePlayerViewportAssignments();
|
void updatePlayerViewportAssignments();
|
||||||
int unoccupiedQuadrant; // 4J - added
|
int unoccupiedQuadrant; // 4J - added
|
||||||
|
|
||||||
shared_ptr<Mob> cameraTargetPlayer;
|
std::shared_ptr<Mob> cameraTargetPlayer;
|
||||||
ParticleEngine *particleEngine;
|
ParticleEngine *particleEngine;
|
||||||
User *user;
|
User *user;
|
||||||
wstring serverDomain;
|
std::wstring serverDomain;
|
||||||
Canvas *parent;
|
Canvas *parent;
|
||||||
bool appletMode;
|
bool appletMode;
|
||||||
|
|
||||||
@@ -181,12 +181,12 @@ public:
|
|||||||
StatsCounter* stats[4];
|
StatsCounter* stats[4];
|
||||||
|
|
||||||
private:
|
private:
|
||||||
wstring connectToIp;
|
std::wstring connectToIp;
|
||||||
int connectToPort;
|
int connectToPort;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void clearConnectionFailed();
|
void clearConnectionFailed();
|
||||||
void connectTo(const wstring& server, int port);
|
void connectTo(const std::wstring& server, int port);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void renderLoadingScreen();
|
void renderLoadingScreen();
|
||||||
@@ -199,14 +199,14 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
static File getWorkingDirectory();
|
static File getWorkingDirectory();
|
||||||
static File getWorkingDirectory(const wstring& applicationName);
|
static File getWorkingDirectory(const std::wstring& applicationName);
|
||||||
private:
|
private:
|
||||||
static OS getPlatform();
|
static OS getPlatform();
|
||||||
public:
|
public:
|
||||||
LevelStorageSource *getLevelSource();
|
LevelStorageSource *getLevelSource();
|
||||||
void setScreen(Screen *screen);
|
void setScreen(Screen *screen);
|
||||||
private:
|
private:
|
||||||
void checkGlError(const wstring& string);
|
void checkGlError(const std::wstring& string);
|
||||||
|
|
||||||
#ifdef __ORBIS__
|
#ifdef __ORBIS__
|
||||||
PsPlusUpsellWrapper *m_pPsPlusUpsell;
|
PsPlusUpsellWrapper *m_pPsPlusUpsell;
|
||||||
@@ -215,7 +215,7 @@ private:
|
|||||||
public:
|
public:
|
||||||
void destroy();
|
void destroy();
|
||||||
volatile bool running;
|
volatile bool running;
|
||||||
wstring fpsString;
|
std::wstring fpsString;
|
||||||
void run();
|
void run();
|
||||||
// 4J-PB - split the run into 3 parts so we can run it from our xbox game loop
|
// 4J-PB - split the run into 3 parts so we can run it from our xbox game loop
|
||||||
static Minecraft *GetInstance();
|
static Minecraft *GetInstance();
|
||||||
@@ -269,36 +269,36 @@ private:
|
|||||||
void reloadSound();
|
void reloadSound();
|
||||||
public:
|
public:
|
||||||
bool isClientSide();
|
bool isClientSide();
|
||||||
void selectLevel(ConsoleSaveFile *saveFile, const wstring& levelId, const wstring& levelName, LevelSettings *levelSettings);
|
void selectLevel(ConsoleSaveFile *saveFile, const std::wstring& levelId, const std::wstring& levelName, LevelSettings *levelSettings);
|
||||||
//void toggleDimension(int targetDimension);
|
//void toggleDimension(int targetDimension);
|
||||||
bool saveSlot(int slot, const wstring& name);
|
bool saveSlot(int slot, const std::wstring& name);
|
||||||
bool loadSlot(const wstring& userName, int slot);
|
bool loadSlot(const std::wstring& userName, int slot);
|
||||||
void releaseLevel(int message);
|
void releaseLevel(int message);
|
||||||
// 4J Stu - Added the doForceStatsSave param
|
// 4J Stu - Added the doForceStatsSave param
|
||||||
//void setLevel(Level *level, bool doForceStatsSave = true);
|
//void setLevel(Level *level, bool doForceStatsSave = true);
|
||||||
//void setLevel(Level *level, const wstring& message, bool doForceStatsSave = true);
|
//void setLevel(Level *level, const std::wstring& message, bool doForceStatsSave = true);
|
||||||
void setLevel(MultiPlayerLevel *level, int message = -1, shared_ptr<Player> forceInsertPlayer = nullptr, bool doForceStatsSave = true,bool bPrimaryPlayerSignedOut=false);
|
void setLevel(MultiPlayerLevel *level, int message = -1, std::shared_ptr<Player> forceInsertPlayer = nullptr, bool doForceStatsSave = true,bool bPrimaryPlayerSignedOut=false);
|
||||||
// 4J-PB - added to force in the 'other' level when the main player creates the level at game load time
|
// 4J-PB - added to force in the 'other' level when the main player creates the level at game load time
|
||||||
void forceaddLevel(MultiPlayerLevel *level);
|
void forceaddLevel(MultiPlayerLevel *level);
|
||||||
void prepareLevel(int title); // 4J - changed to public
|
void prepareLevel(int title); // 4J - changed to public
|
||||||
void fileDownloaded(const wstring& name, File *file);
|
void fileDownloaded(const std::wstring& name, File *file);
|
||||||
// OpenGLCapabilities getOpenGLCapabilities(); // 4J - removed
|
// OpenGLCapabilities getOpenGLCapabilities(); // 4J - removed
|
||||||
|
|
||||||
wstring gatherStats1();
|
std::wstring gatherStats1();
|
||||||
wstring gatherStats2();
|
std::wstring gatherStats2();
|
||||||
wstring gatherStats3();
|
std::wstring gatherStats3();
|
||||||
wstring gatherStats4();
|
std::wstring gatherStats4();
|
||||||
|
|
||||||
void respawnPlayer(int iPad,int dimension,int newEntityId);
|
void respawnPlayer(int iPad,int dimension,int newEntityId);
|
||||||
static void start(const wstring& name, const wstring& sid);
|
static void start(const std::wstring& name, const std::wstring& sid);
|
||||||
static void startAndConnectTo(const wstring& name, const wstring& sid, const wstring& url);
|
static void startAndConnectTo(const std::wstring& name, const std::wstring& sid, const std::wstring& url);
|
||||||
ClientConnection *getConnection(int iPad); // 4J Stu added iPad param
|
ClientConnection *getConnection(int iPad); // 4J Stu added iPad param
|
||||||
static void main();
|
static void main();
|
||||||
static bool renderNames();
|
static bool renderNames();
|
||||||
static bool useFancyGraphics();
|
static bool useFancyGraphics();
|
||||||
static bool useAmbientOcclusion();
|
static bool useAmbientOcclusion();
|
||||||
static bool renderDebug();
|
static bool renderDebug();
|
||||||
bool handleClientSideCommand(const wstring& chatMessage);
|
bool handleClientSideCommand(const std::wstring& chatMessage);
|
||||||
|
|
||||||
static int maxSupportedTextureSize();
|
static int maxSupportedTextureSize();
|
||||||
void delayTextureReload();
|
void delayTextureReload();
|
||||||
@@ -331,15 +331,15 @@ public:
|
|||||||
Level *animateTickLevel; // 4J added
|
Level *animateTickLevel; // 4J added
|
||||||
|
|
||||||
// 4J - When a client requests a texture, it should add it to here while we are waiting for it
|
// 4J - When a client requests a texture, it should add it to here while we are waiting for it
|
||||||
vector<wstring> m_pendingTextureRequests;
|
std::vector<std::wstring> m_pendingTextureRequests;
|
||||||
vector<wstring> m_pendingGeometryRequests; // additional skin box geometry
|
std::vector<std::wstring> m_pendingGeometryRequests; // additional skin box geometry
|
||||||
|
|
||||||
// 4J Added
|
// 4J Added
|
||||||
bool addPendingClientTextureRequest(const wstring &textureName);
|
bool addPendingClientTextureRequest(const std::wstring &textureName);
|
||||||
void handleClientTextureReceived(const wstring &textureName);
|
void handleClientTextureReceived(const std::wstring &textureName);
|
||||||
void clearPendingClientTextureRequests() { m_pendingTextureRequests.clear(); }
|
void clearPendingClientTextureRequests() { m_pendingTextureRequests.clear(); }
|
||||||
bool addPendingClientGeometryRequest(const wstring &textureName);
|
bool addPendingClientGeometryRequest(const std::wstring &textureName);
|
||||||
void handleClientGeometryReceived(const wstring &textureName);
|
void handleClientGeometryReceived(const std::wstring &textureName);
|
||||||
void clearPendingClientGeometryRequests() { m_pendingGeometryRequests.clear(); }
|
void clearPendingClientGeometryRequests() { m_pendingGeometryRequests.clear(); }
|
||||||
|
|
||||||
unsigned int getCurrentTexturePackId();
|
unsigned int getCurrentTexturePackId();
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ int MinecraftServer::s_slowQueuePlayerIndex = 0;
|
|||||||
int MinecraftServer::s_slowQueueLastTime = 0;
|
int MinecraftServer::s_slowQueueLastTime = 0;
|
||||||
bool MinecraftServer::s_slowQueuePacketSent = false;
|
bool MinecraftServer::s_slowQueuePacketSent = false;
|
||||||
|
|
||||||
unordered_map<wstring, int> MinecraftServer::ironTimers;
|
std::unordered_map<std::wstring, int> MinecraftServer::ironTimers;
|
||||||
|
|
||||||
MinecraftServer::MinecraftServer()
|
MinecraftServer::MinecraftServer()
|
||||||
{
|
{
|
||||||
@@ -77,7 +77,7 @@ MinecraftServer::MinecraftServer()
|
|||||||
m_bLoaded = false;
|
m_bLoaded = false;
|
||||||
stopped = false;
|
stopped = false;
|
||||||
tickCount = 0;
|
tickCount = 0;
|
||||||
wstring progressStatus;
|
std::wstring progressStatus;
|
||||||
progress = 0;
|
progress = 0;
|
||||||
motd = L"";
|
motd = L"";
|
||||||
|
|
||||||
@@ -203,8 +203,8 @@ bool MinecraftServer::initServer(__int64 seed, NetworkGameInitData *initData, DW
|
|||||||
|
|
||||||
__int64 levelNanoTime = System::nanoTime();
|
__int64 levelNanoTime = System::nanoTime();
|
||||||
|
|
||||||
wstring levelName = settings->getString(L"level-name", L"world");
|
std::wstring levelName = settings->getString(L"level-name", L"world");
|
||||||
wstring levelTypeString;
|
std::wstring levelTypeString;
|
||||||
|
|
||||||
bool gameRuleUseFlatWorld = false;
|
bool gameRuleUseFlatWorld = false;
|
||||||
if(app.getLevelGenerationOptions() != NULL)
|
if(app.getLevelGenerationOptions() != NULL)
|
||||||
@@ -244,7 +244,7 @@ bool MinecraftServer::initServer(__int64 seed, NetworkGameInitData *initData, DW
|
|||||||
//settings->setProperty(L"max-build-height", maxBuildHeight);
|
//settings->setProperty(L"max-build-height", maxBuildHeight);
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
wstring levelSeedString = settings->getString(L"level-seed", L"");
|
std::wstring levelSeedString = settings->getString(L"level-seed", L"");
|
||||||
__int64 levelSeed = (new Random())->nextLong();
|
__int64 levelSeed = (new Random())->nextLong();
|
||||||
if (levelSeedString.length() > 0)
|
if (levelSeedString.length() > 0)
|
||||||
{
|
{
|
||||||
@@ -378,7 +378,7 @@ void MinecraftServer::postProcessTerminate(ProgressRenderer *mcprogress)
|
|||||||
DeleteCriticalSection(&m_postProcessCS);
|
DeleteCriticalSection(&m_postProcessCS);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MinecraftServer::loadLevel(LevelStorageSource *storageSource, const wstring& name, __int64 levelSeed, LevelType *pLevelType, NetworkGameInitData *initData)
|
bool MinecraftServer::loadLevel(LevelStorageSource *storageSource, const std::wstring& name, __int64 levelSeed, LevelType *pLevelType, NetworkGameInitData *initData)
|
||||||
{
|
{
|
||||||
// 4J - TODO - do with new save stuff
|
// 4J - TODO - do with new save stuff
|
||||||
// if (storageSource->requiresConversion(name))
|
// if (storageSource->requiresConversion(name))
|
||||||
@@ -398,7 +398,7 @@ bool MinecraftServer::loadLevel(LevelStorageSource *storageSource, const wstring
|
|||||||
if( app.GetGameHostOption(eGameHostOption_BonusChest ) ) levelSettings->enableStartingBonusItems();
|
if( app.GetGameHostOption(eGameHostOption_BonusChest ) ) levelSettings->enableStartingBonusItems();
|
||||||
|
|
||||||
// 4J - temp - load existing level
|
// 4J - temp - load existing level
|
||||||
shared_ptr<McRegionLevelStorage> storage = nullptr;
|
std::shared_ptr<McRegionLevelStorage> storage = nullptr;
|
||||||
bool levelChunksNeedConverted = false;
|
bool levelChunksNeedConverted = false;
|
||||||
if( initData->saveData != NULL )
|
if( initData->saveData != NULL )
|
||||||
{
|
{
|
||||||
@@ -416,7 +416,7 @@ bool MinecraftServer::loadLevel(LevelStorageSource *storageSource, const wstring
|
|||||||
levelChunksNeedConverted = true;
|
levelChunksNeedConverted = true;
|
||||||
pSave->ConvertToLocalPlatform(); // check if we need to convert this file from PS3->PS4
|
pSave->ConvertToLocalPlatform(); // check if we need to convert this file from PS3->PS4
|
||||||
|
|
||||||
storage = shared_ptr<McRegionLevelStorage>(new McRegionLevelStorage(pSave, File(L"."), name, true));
|
storage = std::shared_ptr<McRegionLevelStorage>(new McRegionLevelStorage(pSave, File(L"."), name, true));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -441,9 +441,9 @@ bool MinecraftServer::loadLevel(LevelStorageSource *storageSource, const wstring
|
|||||||
newFormatSave = new ConsoleSaveFileSplit( L"" );
|
newFormatSave = new ConsoleSaveFileSplit( L"" );
|
||||||
}
|
}
|
||||||
|
|
||||||
storage = shared_ptr<McRegionLevelStorage>(new McRegionLevelStorage(newFormatSave, File(L"."), name, true));
|
storage = std::shared_ptr<McRegionLevelStorage>(new McRegionLevelStorage(newFormatSave, File(L"."), name, true));
|
||||||
#else
|
#else
|
||||||
storage = shared_ptr<McRegionLevelStorage>(new McRegionLevelStorage(new ConsoleSaveFileOriginal( L"" ), File(L"."), name, true));
|
storage = std::shared_ptr<McRegionLevelStorage>(new McRegionLevelStorage(new ConsoleSaveFileOriginal( L"" ), File(L"."), name, true));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -750,7 +750,7 @@ bool MinecraftServer::loadLevel(LevelStorageSource *storageSource, const wstring
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MinecraftServer::setProgress(const wstring& status, int progress)
|
void MinecraftServer::setProgress(const std::wstring& status, int progress)
|
||||||
{
|
{
|
||||||
progressStatus = status;
|
progressStatus = status;
|
||||||
this->progress = progress;
|
this->progress = progress;
|
||||||
@@ -1258,7 +1258,7 @@ void MinecraftServer::run(__int64 seed, void *lpParameter)
|
|||||||
players->saveAll(Minecraft::GetInstance()->progressRenderer);
|
players->saveAll(Minecraft::GetInstance()->progressRenderer);
|
||||||
}
|
}
|
||||||
|
|
||||||
players->broadcastAll( shared_ptr<UpdateProgressPacket>( new UpdateProgressPacket(20) ) );
|
players->broadcastAll( std::shared_ptr<UpdateProgressPacket>( new UpdateProgressPacket(20) ) );
|
||||||
|
|
||||||
for (unsigned int j = 0; j < levels.length; j++)
|
for (unsigned int j = 0; j < levels.length; j++)
|
||||||
{
|
{
|
||||||
@@ -1269,7 +1269,7 @@ void MinecraftServer::run(__int64 seed, void *lpParameter)
|
|||||||
ServerLevel *level = levels[levels.length - 1 - j];
|
ServerLevel *level = levels[levels.length - 1 - j];
|
||||||
level->save(true, Minecraft::GetInstance()->progressRenderer, (eAction==eXuiServerAction_AutoSaveGame));
|
level->save(true, Minecraft::GetInstance()->progressRenderer, (eAction==eXuiServerAction_AutoSaveGame));
|
||||||
|
|
||||||
players->broadcastAll( shared_ptr<UpdateProgressPacket>( new UpdateProgressPacket(33 + (j*33) ) ) );
|
players->broadcastAll( std::shared_ptr<UpdateProgressPacket>( new UpdateProgressPacket(33 + (j*33) ) ) );
|
||||||
}
|
}
|
||||||
if( !s_bServerHalted )
|
if( !s_bServerHalted )
|
||||||
{
|
{
|
||||||
@@ -1282,16 +1282,16 @@ void MinecraftServer::run(__int64 seed, void *lpParameter)
|
|||||||
case eXuiServerAction_DropItem:
|
case eXuiServerAction_DropItem:
|
||||||
// Find the player, and drop the id at their feet
|
// Find the player, and drop the id at their feet
|
||||||
{
|
{
|
||||||
shared_ptr<ServerPlayer> player = players->players.at(0);
|
std::shared_ptr<ServerPlayer> player = players->players.at(0);
|
||||||
size_t id = (size_t) param;
|
size_t id = (size_t) param;
|
||||||
player->drop( shared_ptr<ItemInstance>( new ItemInstance(id, 1, 0 ) ) );
|
player->drop( std::shared_ptr<ItemInstance>( new ItemInstance(id, 1, 0 ) ) );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case eXuiServerAction_SpawnMob:
|
case eXuiServerAction_SpawnMob:
|
||||||
{
|
{
|
||||||
shared_ptr<ServerPlayer> player = players->players.at(0);
|
std::shared_ptr<ServerPlayer> player = players->players.at(0);
|
||||||
eINSTANCEOF factory = (eINSTANCEOF)((size_t)param);
|
eINSTANCEOF factory = (eINSTANCEOF)((size_t)param);
|
||||||
shared_ptr<Mob> mob = dynamic_pointer_cast<Mob>(EntityIO::newByEnumType(factory,player->level ));
|
std::shared_ptr<Mob> mob = dynamic_pointer_cast<Mob>(EntityIO::newByEnumType(factory,player->level ));
|
||||||
mob->moveTo(player->x+1, player->y, player->z+1, player->level->random->nextFloat() * 360, 0);
|
mob->moveTo(player->x+1, player->y, player->z+1, player->level->random->nextFloat() * 360, 0);
|
||||||
mob->setDespawnProtected(); // 4J added, default to being protected against despawning (has to be done after initial position is set)
|
mob->setDespawnProtected(); // 4J added, default to being protected against despawning (has to be done after initial position is set)
|
||||||
player->level->addEntity(mob);
|
player->level->addEntity(mob);
|
||||||
@@ -1319,20 +1319,20 @@ void MinecraftServer::run(__int64 seed, void *lpParameter)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case eXuiServerAction_ServerSettingChanged_Gamertags:
|
case eXuiServerAction_ServerSettingChanged_Gamertags:
|
||||||
players->broadcastAll( shared_ptr<ServerSettingsChangedPacket>( new ServerSettingsChangedPacket( ServerSettingsChangedPacket::HOST_OPTIONS, app.GetGameHostOption(eGameHostOption_Gamertags)) ) );
|
players->broadcastAll( std::shared_ptr<ServerSettingsChangedPacket>( new ServerSettingsChangedPacket( ServerSettingsChangedPacket::HOST_OPTIONS, app.GetGameHostOption(eGameHostOption_Gamertags)) ) );
|
||||||
break;
|
break;
|
||||||
case eXuiServerAction_ServerSettingChanged_BedrockFog:
|
case eXuiServerAction_ServerSettingChanged_BedrockFog:
|
||||||
players->broadcastAll( shared_ptr<ServerSettingsChangedPacket>( new ServerSettingsChangedPacket( ServerSettingsChangedPacket::HOST_IN_GAME_SETTINGS, app.GetGameHostOption(eGameHostOption_All)) ) );
|
players->broadcastAll( std::shared_ptr<ServerSettingsChangedPacket>( new ServerSettingsChangedPacket( ServerSettingsChangedPacket::HOST_IN_GAME_SETTINGS, app.GetGameHostOption(eGameHostOption_All)) ) );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case eXuiServerAction_ServerSettingChanged_Difficulty:
|
case eXuiServerAction_ServerSettingChanged_Difficulty:
|
||||||
players->broadcastAll( shared_ptr<ServerSettingsChangedPacket>( new ServerSettingsChangedPacket( ServerSettingsChangedPacket::HOST_DIFFICULTY, Minecraft::GetInstance()->options->difficulty) ) );
|
players->broadcastAll( std::shared_ptr<ServerSettingsChangedPacket>( new ServerSettingsChangedPacket( ServerSettingsChangedPacket::HOST_DIFFICULTY, Minecraft::GetInstance()->options->difficulty) ) );
|
||||||
break;
|
break;
|
||||||
case eXuiServerAction_ExportSchematic:
|
case eXuiServerAction_ExportSchematic:
|
||||||
#ifndef _CONTENT_PACKAGE
|
#ifndef _CONTENT_PACKAGE
|
||||||
app.EnterSaveNotificationSection();
|
app.EnterSaveNotificationSection();
|
||||||
|
|
||||||
//players->broadcastAll( shared_ptr<UpdateProgressPacket>( new UpdateProgressPacket(20) ) );
|
//players->broadcastAll( std::shared_ptr<UpdateProgressPacket>( new UpdateProgressPacket(20) ) );
|
||||||
|
|
||||||
if( !s_bServerHalted )
|
if( !s_bServerHalted )
|
||||||
{
|
{
|
||||||
@@ -1347,7 +1347,7 @@ void MinecraftServer::run(__int64 seed, void *lpParameter)
|
|||||||
wchar_t filename[128];
|
wchar_t filename[128];
|
||||||
swprintf(filename,128,L"%ls%dx%dx%d.sch",initData->name,(initData->endX - initData->startX + 1), (initData->endY - initData->startY + 1), (initData->endZ - initData->startZ + 1));
|
swprintf(filename,128,L"%ls%dx%dx%d.sch",initData->name,(initData->endX - initData->startX + 1), (initData->endY - initData->startY + 1), (initData->endZ - initData->startZ + 1));
|
||||||
|
|
||||||
File dataFile = File( targetFileDir, wstring(filename) );
|
File dataFile = File( targetFileDir, std::wstring(filename) );
|
||||||
if(dataFile.exists()) dataFile._delete();
|
if(dataFile.exists()) dataFile._delete();
|
||||||
FileOutputStream fos = FileOutputStream(dataFile);
|
FileOutputStream fos = FileOutputStream(dataFile);
|
||||||
DataOutputStream dos = DataOutputStream(&fos);
|
DataOutputStream dos = DataOutputStream(&fos);
|
||||||
@@ -1370,7 +1370,7 @@ void MinecraftServer::run(__int64 seed, void *lpParameter)
|
|||||||
pos->m_yRot, pos->m_elev
|
pos->m_yRot, pos->m_elev
|
||||||
);
|
);
|
||||||
|
|
||||||
shared_ptr<ServerPlayer> player = players->players.at(pos->player);
|
std::shared_ptr<ServerPlayer> player = players->players.at(pos->player);
|
||||||
player->debug_setPosition( pos->m_camX, pos->m_camY, pos->m_camZ,
|
player->debug_setPosition( pos->m_camX, pos->m_camY, pos->m_camZ,
|
||||||
pos->m_yRot, pos->m_elev );
|
pos->m_yRot, pos->m_elev );
|
||||||
|
|
||||||
@@ -1427,20 +1427,20 @@ void MinecraftServer::run(__int64 seed, void *lpParameter)
|
|||||||
|
|
||||||
void MinecraftServer::broadcastStartSavingPacket()
|
void MinecraftServer::broadcastStartSavingPacket()
|
||||||
{
|
{
|
||||||
players->broadcastAll( shared_ptr<GameEventPacket>( new GameEventPacket(GameEventPacket::START_SAVING, 0) ) );;
|
players->broadcastAll( std::shared_ptr<GameEventPacket>( new GameEventPacket(GameEventPacket::START_SAVING, 0) ) );;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MinecraftServer::broadcastStopSavingPacket()
|
void MinecraftServer::broadcastStopSavingPacket()
|
||||||
{
|
{
|
||||||
if( !s_bServerHalted )
|
if( !s_bServerHalted )
|
||||||
{
|
{
|
||||||
players->broadcastAll( shared_ptr<GameEventPacket>( new GameEventPacket(GameEventPacket::STOP_SAVING, 0) ) );;
|
players->broadcastAll( std::shared_ptr<GameEventPacket>( new GameEventPacket(GameEventPacket::STOP_SAVING, 0) ) );;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MinecraftServer::tick()
|
void MinecraftServer::tick()
|
||||||
{
|
{
|
||||||
vector<wstring> toRemove;
|
std::vector<std::wstring> toRemove;
|
||||||
for (AUTO_VAR(it, ironTimers.begin()); it != ironTimers.end(); it++ )
|
for (AUTO_VAR(it, ironTimers.begin()); it != ironTimers.end(); it++ )
|
||||||
{
|
{
|
||||||
int t = it->second;
|
int t = it->second;
|
||||||
@@ -1469,7 +1469,7 @@ void MinecraftServer::tick()
|
|||||||
/* if(m_lastSentDifficulty != pMinecraft->options->difficulty)
|
/* if(m_lastSentDifficulty != pMinecraft->options->difficulty)
|
||||||
{
|
{
|
||||||
m_lastSentDifficulty = pMinecraft->options->difficulty;
|
m_lastSentDifficulty = pMinecraft->options->difficulty;
|
||||||
players->broadcastAll( shared_ptr<ServerSettingsChangedPacket>( new ServerSettingsChangedPacket( ServerSettingsChangedPacket::HOST_DIFFICULTY, pMinecraft->options->difficulty) ) );
|
players->broadcastAll( std::shared_ptr<ServerSettingsChangedPacket>( new ServerSettingsChangedPacket( ServerSettingsChangedPacket::HOST_DIFFICULTY, pMinecraft->options->difficulty) ) );
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
for (unsigned int i = 0; i < levels.length; i++)
|
for (unsigned int i = 0; i < levels.length; i++)
|
||||||
@@ -1489,7 +1489,7 @@ void MinecraftServer::tick()
|
|||||||
|
|
||||||
if (tickCount % 20 == 0)
|
if (tickCount % 20 == 0)
|
||||||
{
|
{
|
||||||
players->broadcastAll( shared_ptr<SetTimePacket>( new SetTimePacket(level->getTime() ) ), level->dimension->id);
|
players->broadcastAll( std::shared_ptr<SetTimePacket>( new SetTimePacket(level->getTime() ) ), level->dimension->id);
|
||||||
}
|
}
|
||||||
// #ifndef __PS3__
|
// #ifndef __PS3__
|
||||||
static __int64 stc = 0;
|
static __int64 stc = 0;
|
||||||
@@ -1561,7 +1561,7 @@ void MinecraftServer::tick()
|
|||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
void MinecraftServer::handleConsoleInput(const wstring& msg, ConsoleInputSource *source)
|
void MinecraftServer::handleConsoleInput(const std::wstring& msg, ConsoleInputSource *source)
|
||||||
{
|
{
|
||||||
consoleInput.push_back(new ConsoleInput(msg, source));
|
consoleInput.push_back(new ConsoleInput(msg, source));
|
||||||
}
|
}
|
||||||
@@ -1599,20 +1599,20 @@ void MinecraftServer::HaltServer(bool bPrimaryPlayerSignedOut)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
File *MinecraftServer::getFile(const wstring& name)
|
File *MinecraftServer::getFile(const std::wstring& name)
|
||||||
{
|
{
|
||||||
return new File(name);
|
return new File(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MinecraftServer::info(const wstring& string)
|
void MinecraftServer::info(const std::wstring& string)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void MinecraftServer::warn(const wstring& string)
|
void MinecraftServer::warn(const std::wstring& string)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
wstring MinecraftServer::getConsoleName()
|
std::wstring MinecraftServer::getConsoleName()
|
||||||
{
|
{
|
||||||
return L"CONSOLE";
|
return L"CONSOLE";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,8 +24,8 @@ typedef struct _LoadSaveDataThreadParam
|
|||||||
{
|
{
|
||||||
LPVOID data;
|
LPVOID data;
|
||||||
__int64 fileSize;
|
__int64 fileSize;
|
||||||
const wstring saveName;
|
const std::wstring saveName;
|
||||||
_LoadSaveDataThreadParam(LPVOID data, __int64 filesize, const wstring &saveName) : data( data ), fileSize( filesize ), saveName( saveName ) {}
|
_LoadSaveDataThreadParam(LPVOID data, __int64 filesize, const std::wstring &saveName) : data( data ), fileSize( filesize ), saveName( saveName ) {}
|
||||||
} LoadSaveDataThreadParam;
|
} LoadSaveDataThreadParam;
|
||||||
|
|
||||||
typedef struct _NetworkGameInitData
|
typedef struct _NetworkGameInitData
|
||||||
@@ -54,24 +54,24 @@ typedef struct _NetworkGameInitData
|
|||||||
}
|
}
|
||||||
} NetworkGameInitData;
|
} NetworkGameInitData;
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
// 4J Stu - 1.0.1 updates the server to implement the ServerInterface class, but I don't think we will use any of the functions that defines so not implementing here
|
// 4J Stu - 1.0.1 updates the server to implement the ServerInterface class, but I don't think we will use any of the functions that defines so not implementing here
|
||||||
class MinecraftServer : public ConsoleInputSource
|
class MinecraftServer : public ConsoleInputSource
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static const wstring VERSION;
|
static const std::wstring VERSION;
|
||||||
static const int TICK_STATS_SPAN = SharedConstants::TICKS_PER_SECOND * 5;
|
static const int TICK_STATS_SPAN = SharedConstants::TICKS_PER_SECOND * 5;
|
||||||
|
|
||||||
// static Logger logger = Logger.getLogger("Minecraft");
|
// static Logger logger = Logger.getLogger("Minecraft");
|
||||||
static unordered_map<wstring, int> ironTimers;
|
static std::unordered_map<std::wstring, int> ironTimers;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static const int DEFAULT_MINECRAFT_PORT = 25565;
|
static const int DEFAULT_MINECRAFT_PORT = 25565;
|
||||||
static const int MS_PER_TICK = 1000 / SharedConstants::TICKS_PER_SECOND;
|
static const int MS_PER_TICK = 1000 / SharedConstants::TICKS_PER_SECOND;
|
||||||
|
|
||||||
// 4J Stu - Added 1.0.1, Not needed
|
// 4J Stu - Added 1.0.1, Not needed
|
||||||
//wstring localIp;
|
//std::wstring localIp;
|
||||||
//int port;
|
//int port;
|
||||||
public:
|
public:
|
||||||
ServerConnection *connection;
|
ServerConnection *connection;
|
||||||
@@ -93,19 +93,19 @@ public:
|
|||||||
int tickCount;
|
int tickCount;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
wstring progressStatus;
|
std::wstring progressStatus;
|
||||||
int progress;
|
int progress;
|
||||||
private:
|
private:
|
||||||
// vector<Tickable *> tickables = new ArrayList<Tickable>(); // 4J - removed
|
// std::vector<Tickable *> tickables = new ArrayList<Tickable>(); // 4J - removed
|
||||||
CommandDispatcher *commandDispatcher;
|
CommandDispatcher *commandDispatcher;
|
||||||
vector<ConsoleInput *> consoleInput; // 4J - was synchronizedList - TODO - investigate
|
std::vector<ConsoleInput *> consoleInput; // 4J - was synchronizedList - TODO - investigate
|
||||||
public:
|
public:
|
||||||
bool onlineMode;
|
bool onlineMode;
|
||||||
bool animals;
|
bool animals;
|
||||||
bool npcs;
|
bool npcs;
|
||||||
bool pvp;
|
bool pvp;
|
||||||
bool allowFlight;
|
bool allowFlight;
|
||||||
wstring motd;
|
std::wstring motd;
|
||||||
int maxBuildHeight;
|
int maxBuildHeight;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -127,8 +127,8 @@ private:
|
|||||||
// 4J Added - LoadSaveDataThreadParam
|
// 4J Added - LoadSaveDataThreadParam
|
||||||
bool initServer(__int64 seed, NetworkGameInitData *initData, DWORD initSettings, bool findSeed);
|
bool initServer(__int64 seed, NetworkGameInitData *initData, DWORD initSettings, bool findSeed);
|
||||||
void postProcessTerminate(ProgressRenderer *mcprogress);
|
void postProcessTerminate(ProgressRenderer *mcprogress);
|
||||||
bool loadLevel(LevelStorageSource *storageSource, const wstring& name, __int64 levelSeed, LevelType *pLevelType, NetworkGameInitData *initData);
|
bool loadLevel(LevelStorageSource *storageSource, const std::wstring& name, __int64 levelSeed, LevelType *pLevelType, NetworkGameInitData *initData);
|
||||||
void setProgress(const wstring& status, int progress);
|
void setProgress(const std::wstring& status, int progress);
|
||||||
void endProgress();
|
void endProgress();
|
||||||
void saveAllChunks();
|
void saveAllChunks();
|
||||||
void saveGameRules();
|
void saveGameRules();
|
||||||
@@ -162,16 +162,16 @@ public:
|
|||||||
private:
|
private:
|
||||||
void tick();
|
void tick();
|
||||||
public:
|
public:
|
||||||
void handleConsoleInput(const wstring& msg, ConsoleInputSource *source);
|
void handleConsoleInput(const std::wstring& msg, ConsoleInputSource *source);
|
||||||
void handleConsoleInputs();
|
void handleConsoleInputs();
|
||||||
// void addTickable(Tickable tickable); // 4J removed
|
// void addTickable(Tickable tickable); // 4J removed
|
||||||
static void main(__int64 seed, void *lpParameter);
|
static void main(__int64 seed, void *lpParameter);
|
||||||
static void HaltServer(bool bPrimaryPlayerSignedOut=false);
|
static void HaltServer(bool bPrimaryPlayerSignedOut=false);
|
||||||
|
|
||||||
File *getFile(const wstring& name);
|
File *getFile(const std::wstring& name);
|
||||||
void info(const wstring& string);
|
void info(const std::wstring& string);
|
||||||
void warn(const wstring& string);
|
void warn(const std::wstring& string);
|
||||||
wstring getConsoleName();
|
std::wstring getConsoleName();
|
||||||
ServerLevel *getLevel(int dimension);
|
ServerLevel *getLevel(int dimension);
|
||||||
void setLevel(int dimension, ServerLevel *level); // 4J added
|
void setLevel(int dimension, ServerLevel *level); // 4J added
|
||||||
static MinecraftServer *getInstance() { return server; } // 4J added
|
static MinecraftServer *getInstance() { return server; } // 4J added
|
||||||
@@ -204,7 +204,7 @@ private:
|
|||||||
ChunkSource *chunkSource;
|
ChunkSource *chunkSource;
|
||||||
postProcessRequest(int x, int z, ChunkSource *chunkSource) : x(x), z(z), chunkSource(chunkSource) {}
|
postProcessRequest(int x, int z, ChunkSource *chunkSource) : x(x), z(z), chunkSource(chunkSource) {}
|
||||||
};
|
};
|
||||||
vector<postProcessRequest> m_postProcessRequests;
|
std::vector<postProcessRequest> m_postProcessRequests;
|
||||||
CRITICAL_SECTION m_postProcessCS;
|
CRITICAL_SECTION m_postProcessCS;
|
||||||
public:
|
public:
|
||||||
void addPostProcessRequest(ChunkSource *chunkSource, int x, int z);
|
void addPostProcessRequest(ChunkSource *chunkSource, int x, int z);
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -21,7 +21,7 @@ private:
|
|||||||
bool done;
|
bool done;
|
||||||
Connection *connection;
|
Connection *connection;
|
||||||
public:
|
public:
|
||||||
wstring message;
|
std::wstring message;
|
||||||
bool createdOk; // 4J added
|
bool createdOk; // 4J added
|
||||||
private:
|
private:
|
||||||
Minecraft *minecraft;
|
Minecraft *minecraft;
|
||||||
@@ -44,97 +44,97 @@ private:
|
|||||||
DWORD m_userIndex; // 4J Added
|
DWORD m_userIndex; // 4J Added
|
||||||
public:
|
public:
|
||||||
SavedDataStorage *savedDataStorage;
|
SavedDataStorage *savedDataStorage;
|
||||||
ClientConnection(Minecraft *minecraft, const wstring& ip, int port);
|
ClientConnection(Minecraft *minecraft, const std::wstring& ip, int port);
|
||||||
ClientConnection(Minecraft *minecraft, Socket *socket, int iUserIndex = -1);
|
ClientConnection(Minecraft *minecraft, Socket *socket, int iUserIndex = -1);
|
||||||
~ClientConnection();
|
~ClientConnection();
|
||||||
void tick();
|
void tick();
|
||||||
INetworkPlayer *getNetworkPlayer();
|
INetworkPlayer *getNetworkPlayer();
|
||||||
virtual void handleLogin(shared_ptr<LoginPacket> packet);
|
virtual void handleLogin(std::shared_ptr<LoginPacket> packet);
|
||||||
virtual void handleAddEntity(shared_ptr<AddEntityPacket> packet);
|
virtual void handleAddEntity(std::shared_ptr<AddEntityPacket> packet);
|
||||||
virtual void handleAddExperienceOrb(shared_ptr<AddExperienceOrbPacket> packet);
|
virtual void handleAddExperienceOrb(std::shared_ptr<AddExperienceOrbPacket> packet);
|
||||||
virtual void handleAddGlobalEntity(shared_ptr<AddGlobalEntityPacket> packet);
|
virtual void handleAddGlobalEntity(std::shared_ptr<AddGlobalEntityPacket> packet);
|
||||||
virtual void handleAddPainting(shared_ptr<AddPaintingPacket> packet);
|
virtual void handleAddPainting(std::shared_ptr<AddPaintingPacket> packet);
|
||||||
virtual void handleSetEntityMotion(shared_ptr<SetEntityMotionPacket> packet);
|
virtual void handleSetEntityMotion(std::shared_ptr<SetEntityMotionPacket> packet);
|
||||||
virtual void handleSetEntityData(shared_ptr<SetEntityDataPacket> packet);
|
virtual void handleSetEntityData(std::shared_ptr<SetEntityDataPacket> packet);
|
||||||
virtual void handleAddPlayer(shared_ptr<AddPlayerPacket> packet);
|
virtual void handleAddPlayer(std::shared_ptr<AddPlayerPacket> packet);
|
||||||
virtual void handleTeleportEntity(shared_ptr<TeleportEntityPacket> packet);
|
virtual void handleTeleportEntity(std::shared_ptr<TeleportEntityPacket> packet);
|
||||||
virtual void handleMoveEntity(shared_ptr<MoveEntityPacket> packet);
|
virtual void handleMoveEntity(std::shared_ptr<MoveEntityPacket> packet);
|
||||||
virtual void handleRotateMob(shared_ptr<RotateHeadPacket> packet);
|
virtual void handleRotateMob(std::shared_ptr<RotateHeadPacket> packet);
|
||||||
virtual void handleMoveEntitySmall(shared_ptr<MoveEntityPacketSmall> packet);
|
virtual void handleMoveEntitySmall(std::shared_ptr<MoveEntityPacketSmall> packet);
|
||||||
virtual void handleRemoveEntity(shared_ptr<RemoveEntitiesPacket> packet);
|
virtual void handleRemoveEntity(std::shared_ptr<RemoveEntitiesPacket> packet);
|
||||||
virtual void handleMovePlayer(shared_ptr<MovePlayerPacket> packet);
|
virtual void handleMovePlayer(std::shared_ptr<MovePlayerPacket> packet);
|
||||||
|
|
||||||
Random *random;
|
Random *random;
|
||||||
|
|
||||||
// 4J Added
|
// 4J Added
|
||||||
virtual void handleChunkVisibilityArea(shared_ptr<ChunkVisibilityAreaPacket> packet);
|
virtual void handleChunkVisibilityArea(std::shared_ptr<ChunkVisibilityAreaPacket> packet);
|
||||||
|
|
||||||
virtual void handleChunkVisibility(shared_ptr<ChunkVisibilityPacket> packet);
|
virtual void handleChunkVisibility(std::shared_ptr<ChunkVisibilityPacket> packet);
|
||||||
virtual void handleChunkTilesUpdate(shared_ptr<ChunkTilesUpdatePacket> packet);
|
virtual void handleChunkTilesUpdate(std::shared_ptr<ChunkTilesUpdatePacket> packet);
|
||||||
virtual void handleBlockRegionUpdate(shared_ptr<BlockRegionUpdatePacket> packet);
|
virtual void handleBlockRegionUpdate(std::shared_ptr<BlockRegionUpdatePacket> packet);
|
||||||
virtual void handleTileUpdate(shared_ptr<TileUpdatePacket> packet);
|
virtual void handleTileUpdate(std::shared_ptr<TileUpdatePacket> packet);
|
||||||
virtual void handleDisconnect(shared_ptr<DisconnectPacket> packet);
|
virtual void handleDisconnect(std::shared_ptr<DisconnectPacket> packet);
|
||||||
virtual void onDisconnect(DisconnectPacket::eDisconnectReason reason, void *reasonObjects);
|
virtual void onDisconnect(DisconnectPacket::eDisconnectReason reason, void *reasonObjects);
|
||||||
void sendAndDisconnect(shared_ptr<Packet> packet);
|
void sendAndDisconnect(std::shared_ptr<Packet> packet);
|
||||||
void send(shared_ptr<Packet> packet);
|
void send(std::shared_ptr<Packet> packet);
|
||||||
virtual void handleTakeItemEntity(shared_ptr<TakeItemEntityPacket> packet);
|
virtual void handleTakeItemEntity(std::shared_ptr<TakeItemEntityPacket> packet);
|
||||||
virtual void handleChat(shared_ptr<ChatPacket> packet);
|
virtual void handleChat(std::shared_ptr<ChatPacket> packet);
|
||||||
virtual void handleAnimate(shared_ptr<AnimatePacket> packet);
|
virtual void handleAnimate(std::shared_ptr<AnimatePacket> packet);
|
||||||
virtual void handleEntityActionAtPosition(shared_ptr<EntityActionAtPositionPacket> packet);
|
virtual void handleEntityActionAtPosition(std::shared_ptr<EntityActionAtPositionPacket> packet);
|
||||||
virtual void handlePreLogin(shared_ptr<PreLoginPacket> packet);
|
virtual void handlePreLogin(std::shared_ptr<PreLoginPacket> packet);
|
||||||
void close();
|
void close();
|
||||||
virtual void handleAddMob(shared_ptr<AddMobPacket> packet);
|
virtual void handleAddMob(std::shared_ptr<AddMobPacket> packet);
|
||||||
virtual void handleSetTime(shared_ptr<SetTimePacket> packet);
|
virtual void handleSetTime(std::shared_ptr<SetTimePacket> packet);
|
||||||
virtual void handleSetSpawn(shared_ptr<SetSpawnPositionPacket> packet);
|
virtual void handleSetSpawn(std::shared_ptr<SetSpawnPositionPacket> packet);
|
||||||
virtual void handleRidePacket(shared_ptr<SetRidingPacket> packet);
|
virtual void handleRidePacket(std::shared_ptr<SetRidingPacket> packet);
|
||||||
virtual void handleEntityEvent(shared_ptr<EntityEventPacket> packet);
|
virtual void handleEntityEvent(std::shared_ptr<EntityEventPacket> packet);
|
||||||
private:
|
private:
|
||||||
shared_ptr<Entity> getEntity(int entityId);
|
std::shared_ptr<Entity> getEntity(int entityId);
|
||||||
wstring GetDisplayNameByGamertag(wstring gamertag);
|
std::wstring GetDisplayNameByGamertag(std::wstring gamertag);
|
||||||
public:
|
public:
|
||||||
virtual void handleSetHealth(shared_ptr<SetHealthPacket> packet);
|
virtual void handleSetHealth(std::shared_ptr<SetHealthPacket> packet);
|
||||||
virtual void handleSetExperience(shared_ptr<SetExperiencePacket> packet);
|
virtual void handleSetExperience(std::shared_ptr<SetExperiencePacket> packet);
|
||||||
virtual void handleRespawn(shared_ptr<RespawnPacket> packet);
|
virtual void handleRespawn(std::shared_ptr<RespawnPacket> packet);
|
||||||
virtual void handleExplosion(shared_ptr<ExplodePacket> packet);
|
virtual void handleExplosion(std::shared_ptr<ExplodePacket> packet);
|
||||||
virtual void handleContainerOpen(shared_ptr<ContainerOpenPacket> packet);
|
virtual void handleContainerOpen(std::shared_ptr<ContainerOpenPacket> packet);
|
||||||
virtual void handleContainerSetSlot(shared_ptr<ContainerSetSlotPacket> packet);
|
virtual void handleContainerSetSlot(std::shared_ptr<ContainerSetSlotPacket> packet);
|
||||||
virtual void handleContainerAck(shared_ptr<ContainerAckPacket> packet);
|
virtual void handleContainerAck(std::shared_ptr<ContainerAckPacket> packet);
|
||||||
virtual void handleContainerContent(shared_ptr<ContainerSetContentPacket> packet);
|
virtual void handleContainerContent(std::shared_ptr<ContainerSetContentPacket> packet);
|
||||||
virtual void handleSignUpdate(shared_ptr<SignUpdatePacket> packet);
|
virtual void handleSignUpdate(std::shared_ptr<SignUpdatePacket> packet);
|
||||||
virtual void handleTileEntityData(shared_ptr<TileEntityDataPacket> packet);
|
virtual void handleTileEntityData(std::shared_ptr<TileEntityDataPacket> packet);
|
||||||
virtual void handleContainerSetData(shared_ptr<ContainerSetDataPacket> packet);
|
virtual void handleContainerSetData(std::shared_ptr<ContainerSetDataPacket> packet);
|
||||||
virtual void handleSetEquippedItem(shared_ptr<SetEquippedItemPacket> packet);
|
virtual void handleSetEquippedItem(std::shared_ptr<SetEquippedItemPacket> packet);
|
||||||
virtual void handleContainerClose(shared_ptr<ContainerClosePacket> packet);
|
virtual void handleContainerClose(std::shared_ptr<ContainerClosePacket> packet);
|
||||||
virtual void handleTileEvent(shared_ptr<TileEventPacket> packet);
|
virtual void handleTileEvent(std::shared_ptr<TileEventPacket> packet);
|
||||||
virtual void handleTileDestruction(shared_ptr<TileDestructionPacket> packet);
|
virtual void handleTileDestruction(std::shared_ptr<TileDestructionPacket> packet);
|
||||||
virtual bool canHandleAsyncPackets();
|
virtual bool canHandleAsyncPackets();
|
||||||
virtual void handleGameEvent(shared_ptr<GameEventPacket> gameEventPacket);
|
virtual void handleGameEvent(std::shared_ptr<GameEventPacket> gameEventPacket);
|
||||||
virtual void handleComplexItemData(shared_ptr<ComplexItemDataPacket> packet);
|
virtual void handleComplexItemData(std::shared_ptr<ComplexItemDataPacket> packet);
|
||||||
virtual void handleLevelEvent(shared_ptr<LevelEventPacket> packet);
|
virtual void handleLevelEvent(std::shared_ptr<LevelEventPacket> packet);
|
||||||
virtual void handleAwardStat(shared_ptr<AwardStatPacket> packet);
|
virtual void handleAwardStat(std::shared_ptr<AwardStatPacket> packet);
|
||||||
virtual void handleUpdateMobEffect(shared_ptr<UpdateMobEffectPacket> packet);
|
virtual void handleUpdateMobEffect(std::shared_ptr<UpdateMobEffectPacket> packet);
|
||||||
virtual void handleRemoveMobEffect(shared_ptr<RemoveMobEffectPacket> packet);
|
virtual void handleRemoveMobEffect(std::shared_ptr<RemoveMobEffectPacket> packet);
|
||||||
virtual bool isServerPacketListener();
|
virtual bool isServerPacketListener();
|
||||||
virtual void handlePlayerInfo(shared_ptr<PlayerInfoPacket> packet);
|
virtual void handlePlayerInfo(std::shared_ptr<PlayerInfoPacket> packet);
|
||||||
virtual void handleKeepAlive(shared_ptr<KeepAlivePacket> packet);
|
virtual void handleKeepAlive(std::shared_ptr<KeepAlivePacket> packet);
|
||||||
virtual void handlePlayerAbilities(shared_ptr<PlayerAbilitiesPacket> playerAbilitiesPacket);
|
virtual void handlePlayerAbilities(std::shared_ptr<PlayerAbilitiesPacket> playerAbilitiesPacket);
|
||||||
virtual void handleSoundEvent(shared_ptr<LevelSoundPacket> packet);
|
virtual void handleSoundEvent(std::shared_ptr<LevelSoundPacket> packet);
|
||||||
virtual void handleCustomPayload(shared_ptr<CustomPayloadPacket> customPayloadPacket);
|
virtual void handleCustomPayload(std::shared_ptr<CustomPayloadPacket> customPayloadPacket);
|
||||||
virtual Connection *getConnection();
|
virtual Connection *getConnection();
|
||||||
|
|
||||||
// 4J Added
|
// 4J Added
|
||||||
virtual void handleServerSettingsChanged(shared_ptr<ServerSettingsChangedPacket> packet);
|
virtual void handleServerSettingsChanged(std::shared_ptr<ServerSettingsChangedPacket> packet);
|
||||||
virtual void handleTexture(shared_ptr<TexturePacket> packet);
|
virtual void handleTexture(std::shared_ptr<TexturePacket> packet);
|
||||||
virtual void handleTextureAndGeometry(shared_ptr<TextureAndGeometryPacket> packet);
|
virtual void handleTextureAndGeometry(std::shared_ptr<TextureAndGeometryPacket> packet);
|
||||||
virtual void handleUpdateProgress(shared_ptr<UpdateProgressPacket> packet);
|
virtual void handleUpdateProgress(std::shared_ptr<UpdateProgressPacket> packet);
|
||||||
|
|
||||||
// 4J Added
|
// 4J Added
|
||||||
static int HostDisconnectReturned(void *pParam,int iPad,C4JStorage::EMessageResult result);
|
static int HostDisconnectReturned(void *pParam,int iPad,C4JStorage::EMessageResult result);
|
||||||
static int ExitGameAndSaveReturned(void *pParam,int iPad,C4JStorage::EMessageResult result);
|
static int ExitGameAndSaveReturned(void *pParam,int iPad,C4JStorage::EMessageResult result);
|
||||||
virtual void handleTextureChange(shared_ptr<TextureChangePacket> packet);
|
virtual void handleTextureChange(std::shared_ptr<TextureChangePacket> packet);
|
||||||
virtual void handleTextureAndGeometryChange(shared_ptr<TextureAndGeometryChangePacket> packet);
|
virtual void handleTextureAndGeometryChange(std::shared_ptr<TextureAndGeometryChangePacket> packet);
|
||||||
virtual void handleUpdateGameRuleProgressPacket(shared_ptr<UpdateGameRuleProgressPacket> packet);
|
virtual void handleUpdateGameRuleProgressPacket(std::shared_ptr<UpdateGameRuleProgressPacket> packet);
|
||||||
virtual void handleXZ(shared_ptr<XZPacket> packet);
|
virtual void handleXZ(std::shared_ptr<XZPacket> packet);
|
||||||
|
|
||||||
void displayPrivilegeChanges(shared_ptr<MultiplayerLocalPlayer> player, unsigned int oldPrivileges);
|
void displayPrivilegeChanges(std::shared_ptr<MultiplayerLocalPlayer> player, unsigned int oldPrivileges);
|
||||||
};
|
};
|
||||||
@@ -275,17 +275,17 @@ void MultiPlayerChunkCache::postProcess(ChunkSource *parent, int x, int z)
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
vector<Biome::MobSpawnerData *> *MultiPlayerChunkCache::getMobsAt(MobCategory *mobCategory, int x, int y, int z)
|
std::vector<Biome::MobSpawnerData *> *MultiPlayerChunkCache::getMobsAt(MobCategory *mobCategory, int x, int y, int z)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
TilePos *MultiPlayerChunkCache::findNearestMapFeature(Level *level, const wstring &featureName, int x, int y, int z)
|
TilePos *MultiPlayerChunkCache::findNearestMapFeature(Level *level, const std::wstring &featureName, int x, int y, int z)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
wstring MultiPlayerChunkCache::gatherStats()
|
std::wstring MultiPlayerChunkCache::gatherStats()
|
||||||
{
|
{
|
||||||
EnterCriticalSection(&m_csLoadCreate);
|
EnterCriticalSection(&m_csLoadCreate);
|
||||||
int size = (int)loadedChunkList.size();
|
int size = (int)loadedChunkList.size();
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
#include "../../Minecraft.World/Headers/net.minecraft.world.level.chunk.h"
|
#include "../../Minecraft.World/Headers/net.minecraft.world.level.chunk.h"
|
||||||
#include "../../Minecraft.World/Level/RandomLevelSource.h"
|
#include "../../Minecraft.World/Level/RandomLevelSource.h"
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
class ServerChunkCache;
|
class ServerChunkCache;
|
||||||
|
|
||||||
// 4J - various alterations here to make this thread safe, and operate as a fixed sized cache
|
// 4J - various alterations here to make this thread safe, and operate as a fixed sized cache
|
||||||
@@ -14,7 +14,7 @@ private:
|
|||||||
LevelChunk *emptyChunk;
|
LevelChunk *emptyChunk;
|
||||||
LevelChunk *waterChunk;
|
LevelChunk *waterChunk;
|
||||||
|
|
||||||
vector<LevelChunk *> loadedChunkList;
|
std::vector<LevelChunk *> loadedChunkList;
|
||||||
|
|
||||||
LevelChunk **cache;
|
LevelChunk **cache;
|
||||||
// 4J - added for multithreaded support
|
// 4J - added for multithreaded support
|
||||||
@@ -38,9 +38,9 @@ public:
|
|||||||
virtual bool tick();
|
virtual bool tick();
|
||||||
virtual bool shouldSave();
|
virtual bool shouldSave();
|
||||||
virtual void postProcess(ChunkSource *parent, int x, int z);
|
virtual void postProcess(ChunkSource *parent, int x, int z);
|
||||||
virtual wstring gatherStats();
|
virtual std::wstring gatherStats();
|
||||||
virtual vector<Biome::MobSpawnerData *> *getMobsAt(MobCategory *mobCategory, int x, int y, int z);
|
virtual std::vector<Biome::MobSpawnerData *> *getMobsAt(MobCategory *mobCategory, int x, int y, int z);
|
||||||
virtual TilePos *findNearestMapFeature(Level *level, const wstring &featureName, int x, int y, int z);
|
virtual TilePos *findNearestMapFeature(Level *level, const std::wstring &featureName, int x, int y, int z);
|
||||||
virtual void dataReceived(int x, int z); // 4J added
|
virtual void dataReceived(int x, int z); // 4J added
|
||||||
|
|
||||||
virtual LevelChunk **getCache() { return cache; } // 4J added
|
virtual LevelChunk **getCache() { return cache; } // 4J added
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
|
|
||||||
Random *PendingConnection::random = new Random();
|
Random *PendingConnection::random = new Random();
|
||||||
|
|
||||||
PendingConnection::PendingConnection(MinecraftServer *server, Socket *socket, const wstring& id)
|
PendingConnection::PendingConnection(MinecraftServer *server, Socket *socket, const std::wstring& id)
|
||||||
{
|
{
|
||||||
// 4J - added initialisers
|
// 4J - added initialisers
|
||||||
done = false;
|
done = false;
|
||||||
@@ -62,7 +62,7 @@ void PendingConnection::disconnect(DisconnectPacket::eDisconnectReason reason)
|
|||||||
// logger.info("Disconnecting " + getName() + ": " + reason);
|
// logger.info("Disconnecting " + getName() + ": " + reason);
|
||||||
fprintf(stderr, "[PENDING] disconnect called with reason=%d at tick=%d\n", reason, _tick);
|
fprintf(stderr, "[PENDING] disconnect called with reason=%d at tick=%d\n", reason, _tick);
|
||||||
app.DebugPrintf("Pending connection disconnect: %d\n", reason );
|
app.DebugPrintf("Pending connection disconnect: %d\n", reason );
|
||||||
connection->send( shared_ptr<DisconnectPacket>( new DisconnectPacket(reason) ) );
|
connection->send( std::shared_ptr<DisconnectPacket>( new DisconnectPacket(reason) ) );
|
||||||
connection->sendAndQuit();
|
connection->sendAndQuit();
|
||||||
done = true;
|
done = true;
|
||||||
// } catch (Exception e) {
|
// } catch (Exception e) {
|
||||||
@@ -70,7 +70,7 @@ void PendingConnection::disconnect(DisconnectPacket::eDisconnectReason reason)
|
|||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
void PendingConnection::handlePreLogin(shared_ptr<PreLoginPacket> packet)
|
void PendingConnection::handlePreLogin(std::shared_ptr<PreLoginPacket> packet)
|
||||||
{
|
{
|
||||||
if (packet->m_netcodeVersion != MINECRAFT_NET_VERSION)
|
if (packet->m_netcodeVersion != MINECRAFT_NET_VERSION)
|
||||||
{
|
{
|
||||||
@@ -104,7 +104,7 @@ void PendingConnection::sendPreLoginResponse()
|
|||||||
PlayerList *playerList = MinecraftServer::getInstance()->getPlayers();
|
PlayerList *playerList = MinecraftServer::getInstance()->getPlayers();
|
||||||
for(AUTO_VAR(it, playerList->players.begin()); it != playerList->players.end(); ++it)
|
for(AUTO_VAR(it, playerList->players.begin()); it != playerList->players.end(); ++it)
|
||||||
{
|
{
|
||||||
shared_ptr<ServerPlayer> player = *it;
|
std::shared_ptr<ServerPlayer> player = *it;
|
||||||
// If the offline Xuid is invalid but the online one is not then that's guest which we should ignore
|
// If the offline Xuid is invalid but the online one is not then that's guest which we should ignore
|
||||||
// If the online Xuid is invalid but the offline one is not then we are definitely an offline game so dont care about UGC
|
// If the online Xuid is invalid but the offline one is not then we are definitely an offline game so dont care about UGC
|
||||||
|
|
||||||
@@ -129,16 +129,16 @@ void PendingConnection::sendPreLoginResponse()
|
|||||||
if (false)// server->onlineMode) // 4J - removed
|
if (false)// server->onlineMode) // 4J - removed
|
||||||
{
|
{
|
||||||
loginKey = L"TOIMPLEMENT"; // 4J - todo Long.toHexString(random.nextLong());
|
loginKey = L"TOIMPLEMENT"; // 4J - todo Long.toHexString(random.nextLong());
|
||||||
connection->send( shared_ptr<PreLoginPacket>( new PreLoginPacket(loginKey, ugcXuids, ugcXuidCount, ugcFriendsOnlyBits, server->m_ugcPlayersVersion, szUniqueMapName,app.GetGameHostOption(eGameHostOption_All),hostIndex) ) );
|
connection->send( std::shared_ptr<PreLoginPacket>( new PreLoginPacket(loginKey, ugcXuids, ugcXuidCount, ugcFriendsOnlyBits, server->m_ugcPlayersVersion, szUniqueMapName,app.GetGameHostOption(eGameHostOption_All),hostIndex) ) );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
connection->send( shared_ptr<PreLoginPacket>( new PreLoginPacket(L"-", ugcXuids, ugcXuidCount, ugcFriendsOnlyBits, server->m_ugcPlayersVersion,szUniqueMapName,app.GetGameHostOption(eGameHostOption_All),hostIndex, server->m_texturePackId) ) );
|
connection->send( std::shared_ptr<PreLoginPacket>( new PreLoginPacket(L"-", ugcXuids, ugcXuidCount, ugcFriendsOnlyBits, server->m_ugcPlayersVersion,szUniqueMapName,app.GetGameHostOption(eGameHostOption_All),hostIndex, server->m_texturePackId) ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PendingConnection::handleLogin(shared_ptr<LoginPacket> packet)
|
void PendingConnection::handleLogin(std::shared_ptr<LoginPacket> packet)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "[LOGIN-SRV] handleLogin called! clientVersion=%d\n", packet->clientVersion);
|
fprintf(stderr, "[LOGIN-SRV] handleLogin called! clientVersion=%d\n", packet->clientVersion);
|
||||||
//name = packet->userName;
|
//name = packet->userName;
|
||||||
@@ -199,7 +199,7 @@ void PendingConnection::handleLogin(shared_ptr<LoginPacket> packet)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PendingConnection::handleAcceptedLogin(shared_ptr<LoginPacket> packet)
|
void PendingConnection::handleAcceptedLogin(std::shared_ptr<LoginPacket> packet)
|
||||||
{
|
{
|
||||||
if(packet->m_ugcPlayersVersion != server->m_ugcPlayersVersion)
|
if(packet->m_ugcPlayersVersion != server->m_ugcPlayersVersion)
|
||||||
{
|
{
|
||||||
@@ -212,7 +212,7 @@ void PendingConnection::handleAcceptedLogin(shared_ptr<LoginPacket> packet)
|
|||||||
PlayerUID playerXuid = packet->m_offlineXuid;
|
PlayerUID playerXuid = packet->m_offlineXuid;
|
||||||
if(playerXuid == INVALID_XUID) playerXuid = packet->m_onlineXuid;
|
if(playerXuid == INVALID_XUID) playerXuid = packet->m_onlineXuid;
|
||||||
|
|
||||||
shared_ptr<ServerPlayer> playerEntity = server->getPlayers()->getPlayerForLogin(this, name, playerXuid,packet->m_onlineXuid);
|
std::shared_ptr<ServerPlayer> playerEntity = server->getPlayers()->getPlayerForLogin(this, name, playerXuid,packet->m_onlineXuid);
|
||||||
if (playerEntity != NULL)
|
if (playerEntity != NULL)
|
||||||
{
|
{
|
||||||
server->getPlayers()->placeNewPlayer(connection, playerEntity, packet);
|
server->getPlayers()->placeNewPlayer(connection, playerEntity, packet);
|
||||||
@@ -228,12 +228,12 @@ void PendingConnection::onDisconnect(DisconnectPacket::eDisconnectReason reason,
|
|||||||
done = true;
|
done = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PendingConnection::handleGetInfo(shared_ptr<GetInfoPacket> packet)
|
void PendingConnection::handleGetInfo(std::shared_ptr<GetInfoPacket> packet)
|
||||||
{
|
{
|
||||||
//try {
|
//try {
|
||||||
//String message = server->motd + "§" + server->players->getPlayerCount() + "§" + server->players->getMaxPlayers();
|
//String message = server->motd + "§" + server->players->getPlayerCount() + "§" + server->players->getMaxPlayers();
|
||||||
//connection->send(new DisconnectPacket(message));
|
//connection->send(new DisconnectPacket(message));
|
||||||
connection->send(shared_ptr<DisconnectPacket>(new DisconnectPacket(DisconnectPacket::eDisconnect_ServerFull) ) );
|
connection->send(std::shared_ptr<DisconnectPacket>(new DisconnectPacket(DisconnectPacket::eDisconnect_ServerFull) ) );
|
||||||
connection->sendAndQuit();
|
connection->sendAndQuit();
|
||||||
server->connection->removeSpamProtection(connection->getSocket());
|
server->connection->removeSpamProtection(connection->getSocket());
|
||||||
done = true;
|
done = true;
|
||||||
@@ -242,22 +242,22 @@ void PendingConnection::handleGetInfo(shared_ptr<GetInfoPacket> packet)
|
|||||||
//}
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PendingConnection::handleKeepAlive(shared_ptr<KeepAlivePacket> packet)
|
void PendingConnection::handleKeepAlive(std::shared_ptr<KeepAlivePacket> packet)
|
||||||
{
|
{
|
||||||
// Ignore
|
// Ignore
|
||||||
}
|
}
|
||||||
|
|
||||||
void PendingConnection::onUnhandledPacket(shared_ptr<Packet> packet)
|
void PendingConnection::onUnhandledPacket(std::shared_ptr<Packet> packet)
|
||||||
{
|
{
|
||||||
disconnect(DisconnectPacket::eDisconnect_UnexpectedPacket);
|
disconnect(DisconnectPacket::eDisconnect_UnexpectedPacket);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PendingConnection::send(shared_ptr<Packet> packet)
|
void PendingConnection::send(std::shared_ptr<Packet> packet)
|
||||||
{
|
{
|
||||||
connection->send(packet);
|
connection->send(packet);
|
||||||
}
|
}
|
||||||
|
|
||||||
wstring PendingConnection::getName()
|
std::wstring PendingConnection::getName()
|
||||||
{
|
{
|
||||||
return L"Unimplemented";
|
return L"Unimplemented";
|
||||||
// if (name != null) return name + " [" + connection.getRemoteAddress().toString() + "]";
|
// if (name != null) return name + " [" + connection.getRemoteAddress().toString() + "]";
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ class Socket;
|
|||||||
class LoginPacket;
|
class LoginPacket;
|
||||||
class Connection;
|
class Connection;
|
||||||
class Random;
|
class Random;
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
class PendingConnection : public PacketListener
|
class PendingConnection : public PacketListener
|
||||||
{
|
{
|
||||||
@@ -23,24 +23,24 @@ public:
|
|||||||
private:
|
private:
|
||||||
MinecraftServer *server;
|
MinecraftServer *server;
|
||||||
int _tick;
|
int _tick;
|
||||||
wstring name;
|
std::wstring name;
|
||||||
shared_ptr<LoginPacket> acceptedLogin;
|
std::shared_ptr<LoginPacket> acceptedLogin;
|
||||||
wstring loginKey;
|
std::wstring loginKey;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PendingConnection(MinecraftServer *server, Socket *socket, const wstring& id);
|
PendingConnection(MinecraftServer *server, Socket *socket, const std::wstring& id);
|
||||||
~PendingConnection();
|
~PendingConnection();
|
||||||
void tick();
|
void tick();
|
||||||
void disconnect(DisconnectPacket::eDisconnectReason reason);
|
void disconnect(DisconnectPacket::eDisconnectReason reason);
|
||||||
virtual void handlePreLogin(shared_ptr<PreLoginPacket> packet);
|
virtual void handlePreLogin(std::shared_ptr<PreLoginPacket> packet);
|
||||||
virtual void handleLogin(shared_ptr<LoginPacket> packet);
|
virtual void handleLogin(std::shared_ptr<LoginPacket> packet);
|
||||||
virtual void handleAcceptedLogin(shared_ptr<LoginPacket> packet);
|
virtual void handleAcceptedLogin(std::shared_ptr<LoginPacket> packet);
|
||||||
virtual void onDisconnect(DisconnectPacket::eDisconnectReason reason, void *reasonObjects);
|
virtual void onDisconnect(DisconnectPacket::eDisconnectReason reason, void *reasonObjects);
|
||||||
virtual void handleGetInfo(shared_ptr<GetInfoPacket> packet);
|
virtual void handleGetInfo(std::shared_ptr<GetInfoPacket> packet);
|
||||||
virtual void handleKeepAlive(shared_ptr<KeepAlivePacket> packet);
|
virtual void handleKeepAlive(std::shared_ptr<KeepAlivePacket> packet);
|
||||||
virtual void onUnhandledPacket(shared_ptr<Packet> packet);
|
virtual void onUnhandledPacket(std::shared_ptr<Packet> packet);
|
||||||
void send(shared_ptr<Packet> packet);
|
void send(std::shared_ptr<Packet> packet);
|
||||||
wstring getName();
|
std::wstring getName();
|
||||||
virtual bool isServerPacketListener();
|
virtual bool isServerPacketListener();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -44,12 +44,12 @@ void PlayerChunkMap::flagEntitiesToBeRemoved(unsigned int *flags, bool *flagToBe
|
|||||||
{
|
{
|
||||||
for(AUTO_VAR(it,players.begin()); it != players.end(); it++)
|
for(AUTO_VAR(it,players.begin()); it != players.end(); it++)
|
||||||
{
|
{
|
||||||
shared_ptr<ServerPlayer> serverPlayer = *it;
|
std::shared_ptr<ServerPlayer> serverPlayer = *it;
|
||||||
serverPlayer->flagEntitiesToBeRemoved(flags, flagToBeRemoved);
|
serverPlayer->flagEntitiesToBeRemoved(flags, flagToBeRemoved);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerChunkMap::PlayerChunk::add(shared_ptr<ServerPlayer> player, bool sendPacket /*= true*/)
|
void PlayerChunkMap::PlayerChunk::add(std::shared_ptr<ServerPlayer> player, bool sendPacket /*= true*/)
|
||||||
{
|
{
|
||||||
//app.DebugPrintf("--- Adding player to chunk x=%d\tz=%d\n",x, z);
|
//app.DebugPrintf("--- Adding player to chunk x=%d\tz=%d\n",x, z);
|
||||||
if (find(players.begin(),players.end(),player) != players.end())
|
if (find(players.begin(),players.end(),player) != players.end())
|
||||||
@@ -66,7 +66,7 @@ void PlayerChunkMap::PlayerChunk::add(shared_ptr<ServerPlayer> player, bool send
|
|||||||
player->seenChunks.insert(pos);
|
player->seenChunks.insert(pos);
|
||||||
|
|
||||||
// 4J Added the sendPacket check. See PlayerChunkMap::add for the usage
|
// 4J Added the sendPacket check. See PlayerChunkMap::add for the usage
|
||||||
if( sendPacket ) player->connection->send( shared_ptr<ChunkVisibilityPacket>( new ChunkVisibilityPacket(pos.x, pos.z, true) ) );
|
if( sendPacket ) player->connection->send( std::shared_ptr<ChunkVisibilityPacket>( new ChunkVisibilityPacket(pos.x, pos.z, true) ) );
|
||||||
|
|
||||||
players.push_back(player);
|
players.push_back(player);
|
||||||
|
|
||||||
@@ -77,7 +77,7 @@ void PlayerChunkMap::PlayerChunk::add(shared_ptr<ServerPlayer> player, bool send
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerChunkMap::PlayerChunk::remove(shared_ptr<ServerPlayer> player)
|
void PlayerChunkMap::PlayerChunk::remove(std::shared_ptr<ServerPlayer> player)
|
||||||
{
|
{
|
||||||
PlayerChunkMap::PlayerChunk *toDelete = NULL;
|
PlayerChunkMap::PlayerChunk *toDelete = NULL;
|
||||||
|
|
||||||
@@ -121,7 +121,7 @@ void PlayerChunkMap::PlayerChunk::remove(shared_ptr<ServerPlayer> player)
|
|||||||
{
|
{
|
||||||
for( AUTO_VAR(it, players.begin()); it < players.end(); ++it )
|
for( AUTO_VAR(it, players.begin()); it < players.end(); ++it )
|
||||||
{
|
{
|
||||||
shared_ptr<ServerPlayer> currPlayer = *it;
|
std::shared_ptr<ServerPlayer> currPlayer = *it;
|
||||||
INetworkPlayer *currNetPlayer = currPlayer->connection->getNetworkPlayer();
|
INetworkPlayer *currNetPlayer = currPlayer->connection->getNetworkPlayer();
|
||||||
if( currNetPlayer != NULL && currNetPlayer->IsSameSystem( thisNetPlayer ) && currPlayer->seenChunks.find(pos) != currPlayer->seenChunks.end() )
|
if( currNetPlayer != NULL && currNetPlayer->IsSameSystem( thisNetPlayer ) && currPlayer->seenChunks.find(pos) != currPlayer->seenChunks.end() )
|
||||||
{
|
{
|
||||||
@@ -132,7 +132,7 @@ void PlayerChunkMap::PlayerChunk::remove(shared_ptr<ServerPlayer> player)
|
|||||||
if(noOtherPlayersFound)
|
if(noOtherPlayersFound)
|
||||||
{
|
{
|
||||||
//wprintf(L"Sending ChunkVisiblity packet false for chunk (%d,%d) to player %ls\n", x, z, player->name.c_str() );
|
//wprintf(L"Sending ChunkVisiblity packet false for chunk (%d,%d) to player %ls\n", x, z, player->name.c_str() );
|
||||||
player->connection->send( shared_ptr<ChunkVisibilityPacket>( new ChunkVisibilityPacket(pos.x, pos.z, false) ) );
|
player->connection->send( std::shared_ptr<ChunkVisibilityPacket>( new ChunkVisibilityPacket(pos.x, pos.z, false) ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -181,12 +181,12 @@ void PlayerChunkMap::PlayerChunk::prioritiseTileChanges()
|
|||||||
prioritised = true;
|
prioritised = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerChunkMap::PlayerChunk::broadcast(shared_ptr<Packet> packet)
|
void PlayerChunkMap::PlayerChunk::broadcast(std::shared_ptr<Packet> packet)
|
||||||
{
|
{
|
||||||
vector< shared_ptr<ServerPlayer> > sentTo;
|
std::vector< std::shared_ptr<ServerPlayer> > sentTo;
|
||||||
for (unsigned int i = 0; i < players.size(); i++)
|
for (unsigned int i = 0; i < players.size(); i++)
|
||||||
{
|
{
|
||||||
shared_ptr<ServerPlayer> player = players[i];
|
std::shared_ptr<ServerPlayer> player = players[i];
|
||||||
|
|
||||||
// 4J - don't send to a player we've already sent this data to that shares the same machine. TileUpdatePacket,
|
// 4J - don't send to a player we've already sent this data to that shares the same machine. TileUpdatePacket,
|
||||||
// ChunkTilesUpdatePacket and SignUpdatePacket all used to limit themselves to sending once to each machine
|
// ChunkTilesUpdatePacket and SignUpdatePacket all used to limit themselves to sending once to each machine
|
||||||
@@ -205,7 +205,7 @@ void PlayerChunkMap::PlayerChunk::broadcast(shared_ptr<Packet> packet)
|
|||||||
{
|
{
|
||||||
for(unsigned int j = 0; j < sentTo.size(); j++ )
|
for(unsigned int j = 0; j < sentTo.size(); j++ )
|
||||||
{
|
{
|
||||||
shared_ptr<ServerPlayer> player2 = sentTo[j];
|
std::shared_ptr<ServerPlayer> player2 = sentTo[j];
|
||||||
INetworkPlayer *otherPlayer = player2->connection->getNetworkPlayer();
|
INetworkPlayer *otherPlayer = player2->connection->getNetworkPlayer();
|
||||||
if( otherPlayer != NULL && thisPlayer->IsSameSystem(otherPlayer) )
|
if( otherPlayer != NULL && thisPlayer->IsSameSystem(otherPlayer) )
|
||||||
{
|
{
|
||||||
@@ -244,7 +244,7 @@ void PlayerChunkMap::PlayerChunk::broadcast(shared_ptr<Packet> packet)
|
|||||||
|
|
||||||
for( int i = 0; i < parent->level->getServer()->getPlayers()->players.size(); i++ )
|
for( int i = 0; i < parent->level->getServer()->getPlayers()->players.size(); i++ )
|
||||||
{
|
{
|
||||||
shared_ptr<ServerPlayer> player = parent->level->getServer()->getPlayers()->players[i];
|
std::shared_ptr<ServerPlayer> player = parent->level->getServer()->getPlayers()->players[i];
|
||||||
// Don't worry about local players, they get all their updates through sharing level with the server anyway
|
// Don't worry about local players, they get all their updates through sharing level with the server anyway
|
||||||
if ( player->connection == NULL ) continue;
|
if ( player->connection == NULL ) continue;
|
||||||
if( player->connection->isLocal() ) continue;
|
if( player->connection->isLocal() ) continue;
|
||||||
@@ -267,7 +267,7 @@ void PlayerChunkMap::PlayerChunk::broadcast(shared_ptr<Packet> packet)
|
|||||||
{
|
{
|
||||||
for(unsigned int j = 0; j < sentTo.size(); j++ )
|
for(unsigned int j = 0; j < sentTo.size(); j++ )
|
||||||
{
|
{
|
||||||
shared_ptr<ServerPlayer> player2 = sentTo[j];
|
std::shared_ptr<ServerPlayer> player2 = sentTo[j];
|
||||||
INetworkPlayer *otherPlayer = player2->connection->getNetworkPlayer();
|
INetworkPlayer *otherPlayer = player2->connection->getNetworkPlayer();
|
||||||
if( otherPlayer != NULL && thisPlayer->IsSameSystem(otherPlayer) )
|
if( otherPlayer != NULL && thisPlayer->IsSameSystem(otherPlayer) )
|
||||||
{
|
{
|
||||||
@@ -299,7 +299,7 @@ bool PlayerChunkMap::PlayerChunk::broadcastChanges(bool allowRegionUpdate)
|
|||||||
int x = pos.x * 16 + xChangeMin;
|
int x = pos.x * 16 + xChangeMin;
|
||||||
int y = yChangeMin;
|
int y = yChangeMin;
|
||||||
int z = pos.z * 16 + zChangeMin;
|
int z = pos.z * 16 + zChangeMin;
|
||||||
broadcast( shared_ptr<TileUpdatePacket>( new TileUpdatePacket(x, y, z, level) ) );
|
broadcast( std::shared_ptr<TileUpdatePacket>( new TileUpdatePacket(x, y, z, level) ) );
|
||||||
if (level->isEntityTile(x, y, z))
|
if (level->isEntityTile(x, y, z))
|
||||||
{
|
{
|
||||||
broadcast(level->getTileEntity(x, y, z));
|
broadcast(level->getTileEntity(x, y, z));
|
||||||
@@ -329,8 +329,8 @@ bool PlayerChunkMap::PlayerChunk::broadcastChanges(bool allowRegionUpdate)
|
|||||||
// Block region update packets can only encode ys in a range of 1 - 256
|
// Block region update packets can only encode ys in a range of 1 - 256
|
||||||
if( ys > 256 ) ys = 256;
|
if( ys > 256 ) ys = 256;
|
||||||
|
|
||||||
broadcast( shared_ptr<BlockRegionUpdatePacket>( new BlockRegionUpdatePacket(xp, yp, zp, xs, ys, zs, level) ) );
|
broadcast( std::shared_ptr<BlockRegionUpdatePacket>( new BlockRegionUpdatePacket(xp, yp, zp, xs, ys, zs, level) ) );
|
||||||
vector<shared_ptr<TileEntity> > *tes = level->getTileEntitiesInRegion(xp, yp, zp, xp + xs, yp + ys, zp + zs);
|
std::vector<std::shared_ptr<TileEntity> > *tes = level->getTileEntitiesInRegion(xp, yp, zp, xp + xs, yp + ys, zp + zs);
|
||||||
for (unsigned int i = 0; i < tes->size(); i++)
|
for (unsigned int i = 0; i < tes->size(); i++)
|
||||||
{
|
{
|
||||||
broadcast(tes->at(i));
|
broadcast(tes->at(i));
|
||||||
@@ -342,7 +342,7 @@ bool PlayerChunkMap::PlayerChunk::broadcastChanges(bool allowRegionUpdate)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// 4J As we only get here if changes is less than MAX_CHANGES_BEFORE_RESEND (10) we only need to send a byte value in the packet
|
// 4J As we only get here if changes is less than MAX_CHANGES_BEFORE_RESEND (10) we only need to send a byte value in the packet
|
||||||
broadcast( shared_ptr<ChunkTilesUpdatePacket>( new ChunkTilesUpdatePacket(pos.x, pos.z, changedTiles, (uint8_t)changes, level) ) );
|
broadcast( std::shared_ptr<ChunkTilesUpdatePacket>( new ChunkTilesUpdatePacket(pos.x, pos.z, changedTiles, (uint8_t)changes, level) ) );
|
||||||
for (int i = 0; i < changes; i++)
|
for (int i = 0; i < changes; i++)
|
||||||
{
|
{
|
||||||
int x = pos.x * 16 + ((changedTiles[i] >> 12) & 15);
|
int x = pos.x * 16 + ((changedTiles[i] >> 12) & 15);
|
||||||
@@ -361,11 +361,11 @@ bool PlayerChunkMap::PlayerChunk::broadcastChanges(bool allowRegionUpdate)
|
|||||||
return didRegionUpdate;
|
return didRegionUpdate;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerChunkMap::PlayerChunk::broadcast(shared_ptr<TileEntity> te)
|
void PlayerChunkMap::PlayerChunk::broadcast(std::shared_ptr<TileEntity> te)
|
||||||
{
|
{
|
||||||
if (te != NULL)
|
if (te != NULL)
|
||||||
{
|
{
|
||||||
shared_ptr<Packet> p = te->getUpdatePacket();
|
std::shared_ptr<Packet> p = te->getUpdatePacket();
|
||||||
if (p != NULL)
|
if (p != NULL)
|
||||||
{
|
{
|
||||||
broadcast(p);
|
broadcast(p);
|
||||||
@@ -458,7 +458,7 @@ PlayerChunkMap::PlayerChunk *PlayerChunkMap::getChunk(int x, int z, bool create)
|
|||||||
|
|
||||||
// 4J - added. If a chunk exists, add a player to it straight away. If it doesn't exist,
|
// 4J - added. If a chunk exists, add a player to it straight away. If it doesn't exist,
|
||||||
// queue a request for it to be created.
|
// queue a request for it to be created.
|
||||||
void PlayerChunkMap::getChunkAndAddPlayer(int x, int z, shared_ptr<ServerPlayer> player)
|
void PlayerChunkMap::getChunkAndAddPlayer(int x, int z, std::shared_ptr<ServerPlayer> player)
|
||||||
{
|
{
|
||||||
__int64 id = (x + 0x7fffffffLL) | ((z + 0x7fffffffLL) << 32);
|
__int64 id = (x + 0x7fffffffLL) | ((z + 0x7fffffffLL) << 32);
|
||||||
AUTO_VAR(it, chunks.find(id));
|
AUTO_VAR(it, chunks.find(id));
|
||||||
@@ -475,7 +475,7 @@ void PlayerChunkMap::getChunkAndAddPlayer(int x, int z, shared_ptr<ServerPlayer>
|
|||||||
|
|
||||||
// 4J - added. If the chunk and player are in the queue to be added, remove from there. Otherwise
|
// 4J - added. If the chunk and player are in the queue to be added, remove from there. Otherwise
|
||||||
// attempt to remove from main chunk map.
|
// attempt to remove from main chunk map.
|
||||||
void PlayerChunkMap::getChunkAndRemovePlayer(int x, int z, shared_ptr<ServerPlayer> player)
|
void PlayerChunkMap::getChunkAndRemovePlayer(int x, int z, std::shared_ptr<ServerPlayer> player)
|
||||||
{
|
{
|
||||||
for( AUTO_VAR(it, addRequests.begin()); it != addRequests.end(); it++ )
|
for( AUTO_VAR(it, addRequests.begin()); it != addRequests.end(); it++ )
|
||||||
{
|
{
|
||||||
@@ -497,7 +497,7 @@ 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.
|
// 4J - added - actually create & add player to a playerchunk, if there is one queued for this player.
|
||||||
void PlayerChunkMap::tickAddRequests(shared_ptr<ServerPlayer> player)
|
void PlayerChunkMap::tickAddRequests(std::shared_ptr<ServerPlayer> player)
|
||||||
{
|
{
|
||||||
if( addRequests.size() )
|
if( addRequests.size() )
|
||||||
{
|
{
|
||||||
@@ -533,7 +533,7 @@ void PlayerChunkMap::tickAddRequests(shared_ptr<ServerPlayer> player)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerChunkMap::broadcastTileUpdate(shared_ptr<Packet> packet, int x, int y, int z)
|
void PlayerChunkMap::broadcastTileUpdate(std::shared_ptr<Packet> packet, int x, int y, int z)
|
||||||
{
|
{
|
||||||
int xc = x >> 4;
|
int xc = x >> 4;
|
||||||
int zc = z >> 4;
|
int zc = z >> 4;
|
||||||
@@ -576,7 +576,7 @@ void PlayerChunkMap::prioritiseTileChanges(int x, int y, int z)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerChunkMap::add(shared_ptr<ServerPlayer> player)
|
void PlayerChunkMap::add(std::shared_ptr<ServerPlayer> player)
|
||||||
{
|
{
|
||||||
static int direction[4][2] = { { 1, 0 }, { 0, 1 }, { -1, 0 }, {0, -1} };
|
static int direction[4][2] = { { 1, 0 }, { 0, 1 }, { -1, 0 }, {0, -1} };
|
||||||
|
|
||||||
@@ -649,7 +649,7 @@ void PlayerChunkMap::add(shared_ptr<ServerPlayer> player)
|
|||||||
}
|
}
|
||||||
// CraftBukkit end
|
// CraftBukkit end
|
||||||
|
|
||||||
player->connection->send( shared_ptr<ChunkVisibilityAreaPacket>( new ChunkVisibilityAreaPacket(minX, maxX, minZ, maxZ) ) );
|
player->connection->send( std::shared_ptr<ChunkVisibilityAreaPacket>( new ChunkVisibilityAreaPacket(minX, maxX, minZ, maxZ) ) );
|
||||||
|
|
||||||
#ifdef _LARGE_WORLDS
|
#ifdef _LARGE_WORLDS
|
||||||
getLevel()->cache->dontDrop(xc,zc);
|
getLevel()->cache->dontDrop(xc,zc);
|
||||||
@@ -659,7 +659,7 @@ void PlayerChunkMap::add(shared_ptr<ServerPlayer> player)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerChunkMap::remove(shared_ptr<ServerPlayer> player)
|
void PlayerChunkMap::remove(std::shared_ptr<ServerPlayer> player)
|
||||||
{
|
{
|
||||||
int xc = ((int) player->lastMoveX) >> 4;
|
int xc = ((int) player->lastMoveX) >> 4;
|
||||||
int zc = ((int) player->lastMoveZ) >> 4;
|
int zc = ((int) player->lastMoveZ) >> 4;
|
||||||
@@ -702,7 +702,7 @@ bool PlayerChunkMap::chunkInRange(int x, int z, int xc, int zc)
|
|||||||
|
|
||||||
// 4J - have changed this so that we queue requests to add the player to chunks if they
|
// 4J - have changed this so that we queue requests to add the player to chunks if they
|
||||||
// need to be created, so that we aren't creating potentially 20 chunks per player per tick
|
// need to be created, so that we aren't creating potentially 20 chunks per player per tick
|
||||||
void PlayerChunkMap::move(shared_ptr<ServerPlayer> player)
|
void PlayerChunkMap::move(std::shared_ptr<ServerPlayer> player)
|
||||||
{
|
{
|
||||||
int xc = ((int) player->x) >> 4;
|
int xc = ((int) player->x) >> 4;
|
||||||
int zc = ((int) player->z) >> 4;
|
int zc = ((int) player->z) >> 4;
|
||||||
@@ -744,7 +744,7 @@ int PlayerChunkMap::getMaxRange()
|
|||||||
return radius * 16 - 16;
|
return radius * 16 - 16;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PlayerChunkMap::isPlayerIn(shared_ptr<ServerPlayer> player, int xChunk, int zChunk)
|
bool PlayerChunkMap::isPlayerIn(std::shared_ptr<ServerPlayer> player, int xChunk, int zChunk)
|
||||||
{
|
{
|
||||||
PlayerChunk *chunk = getChunk(xChunk, zChunk, false);
|
PlayerChunk *chunk = getChunk(xChunk, zChunk, false);
|
||||||
|
|
||||||
@@ -775,7 +775,7 @@ void PlayerChunkMap::setRadius(int newRadius)
|
|||||||
PlayerList* players = level->getServer()->getPlayerList();
|
PlayerList* players = level->getServer()->getPlayerList();
|
||||||
for( int i = 0;i < players->players.size();i += 1 )
|
for( int i = 0;i < players->players.size();i += 1 )
|
||||||
{
|
{
|
||||||
shared_ptr<ServerPlayer> player = players->players[i];
|
std::shared_ptr<ServerPlayer> player = players->players[i];
|
||||||
if( player->level == level )
|
if( player->level == level )
|
||||||
{
|
{
|
||||||
int xc = ((int) player->x) >> 4;
|
int xc = ((int) player->x) >> 4;
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ class ServerLevel;
|
|||||||
class MinecraftServer;
|
class MinecraftServer;
|
||||||
class Packet;
|
class Packet;
|
||||||
class TileEntity;
|
class TileEntity;
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
class PlayerChunkMap
|
class PlayerChunkMap
|
||||||
{
|
{
|
||||||
@@ -25,8 +25,8 @@ public:
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
int x,z;
|
int x,z;
|
||||||
shared_ptr<ServerPlayer> player;
|
std::shared_ptr<ServerPlayer> player;
|
||||||
PlayerChunkAddRequest(int x, int z, shared_ptr<ServerPlayer> player ) : x(x), z(z), player(player) {}
|
PlayerChunkAddRequest(int x, int z, std::shared_ptr<ServerPlayer> player ) : x(x), z(z), player(player) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
class PlayerChunk
|
class PlayerChunk
|
||||||
@@ -34,7 +34,7 @@ public:
|
|||||||
friend class PlayerChunkMap;
|
friend class PlayerChunkMap;
|
||||||
private:
|
private:
|
||||||
PlayerChunkMap *parent; // 4J added
|
PlayerChunkMap *parent; // 4J added
|
||||||
vector<shared_ptr<ServerPlayer> > players;
|
std::vector<std::shared_ptr<ServerPlayer> > players;
|
||||||
//int x, z;
|
//int x, z;
|
||||||
ChunkPos pos;
|
ChunkPos pos;
|
||||||
|
|
||||||
@@ -51,25 +51,25 @@ public:
|
|||||||
~PlayerChunk();
|
~PlayerChunk();
|
||||||
|
|
||||||
// 4J Added sendPacket param so we can aggregate the initial send into one much smaller packet
|
// 4J Added sendPacket param so we can aggregate the initial send into one much smaller packet
|
||||||
void add(shared_ptr<ServerPlayer> player, bool sendPacket = true);
|
void add(std::shared_ptr<ServerPlayer> player, bool sendPacket = true);
|
||||||
void remove(shared_ptr<ServerPlayer> player);
|
void remove(std::shared_ptr<ServerPlayer> player);
|
||||||
void tileChanged(int x, int y, int z);
|
void tileChanged(int x, int y, int z);
|
||||||
void prioritiseTileChanges(); // 4J added
|
void prioritiseTileChanges(); // 4J added
|
||||||
void broadcast(shared_ptr<Packet> packet);
|
void broadcast(std::shared_ptr<Packet> packet);
|
||||||
bool broadcastChanges(bool allowRegionUpdate); // 4J - added parm
|
bool broadcastChanges(bool allowRegionUpdate); // 4J - added parm
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void broadcast(shared_ptr<TileEntity> te);
|
void broadcast(std::shared_ptr<TileEntity> te);
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
vector<shared_ptr<ServerPlayer> > players;
|
std::vector<std::shared_ptr<ServerPlayer> > players;
|
||||||
void flagEntitiesToBeRemoved(unsigned int *flags, bool *removedFound); // 4J added
|
void flagEntitiesToBeRemoved(unsigned int *flags, bool *removedFound); // 4J added
|
||||||
private:
|
private:
|
||||||
unordered_map<__int64,PlayerChunk *,LongKeyHash,LongKeyEq> chunks; // 4J - was LongHashMap
|
std::unordered_map<__int64,PlayerChunk *,LongKeyHash,LongKeyEq> chunks; // 4J - was LongHashMap
|
||||||
vector<PlayerChunk *> changedChunks;
|
std::vector<PlayerChunk *> changedChunks;
|
||||||
vector<PlayerChunkAddRequest> addRequests; // 4J added
|
std::vector<PlayerChunkAddRequest> addRequests; // 4J added
|
||||||
void tickAddRequests(shared_ptr<ServerPlayer> player); // 4J added
|
void tickAddRequests(std::shared_ptr<ServerPlayer> player); // 4J added
|
||||||
|
|
||||||
ServerLevel *level;
|
ServerLevel *level;
|
||||||
int radius;
|
int radius;
|
||||||
@@ -83,21 +83,21 @@ public:
|
|||||||
bool hasChunk(int x, int z);
|
bool hasChunk(int x, int z);
|
||||||
private:
|
private:
|
||||||
PlayerChunk *getChunk(int x, int z, bool create);
|
PlayerChunk *getChunk(int x, int z, bool create);
|
||||||
void getChunkAndAddPlayer(int x, int z, shared_ptr<ServerPlayer> player); // 4J added
|
void getChunkAndAddPlayer(int x, int z, std::shared_ptr<ServerPlayer> player); // 4J added
|
||||||
void getChunkAndRemovePlayer(int x, int z, shared_ptr<ServerPlayer> player); // 4J added
|
void getChunkAndRemovePlayer(int x, int z, std::shared_ptr<ServerPlayer> player); // 4J added
|
||||||
public:
|
public:
|
||||||
void broadcastTileUpdate(shared_ptr<Packet> packet, int x, int y, int z);
|
void broadcastTileUpdate(std::shared_ptr<Packet> packet, int x, int y, int z);
|
||||||
void tileChanged(int x, int y, int z);
|
void tileChanged(int x, int y, int z);
|
||||||
bool isTrackingTile(int x, int y, int z); // 4J added
|
bool isTrackingTile(int x, int y, int z); // 4J added
|
||||||
void prioritiseTileChanges(int x, int y, int z); // 4J added
|
void prioritiseTileChanges(int x, int y, int z); // 4J added
|
||||||
void add(shared_ptr<ServerPlayer> player);
|
void add(std::shared_ptr<ServerPlayer> player);
|
||||||
void remove(shared_ptr<ServerPlayer> player);
|
void remove(std::shared_ptr<ServerPlayer> player);
|
||||||
private:
|
private:
|
||||||
bool chunkInRange(int x, int z, int xc, int zc);
|
bool chunkInRange(int x, int z, int xc, int zc);
|
||||||
public:
|
public:
|
||||||
void move(shared_ptr<ServerPlayer> player);
|
void move(std::shared_ptr<ServerPlayer> player);
|
||||||
int getMaxRange();
|
int getMaxRange();
|
||||||
bool isPlayerIn(shared_ptr<ServerPlayer> player, int xChunk, int zChunk);
|
bool isPlayerIn(std::shared_ptr<ServerPlayer> player, int xChunk, int zChunk);
|
||||||
static int convertChunkRangeToBlock(int radius);
|
static int convertChunkRangeToBlock(int radius);
|
||||||
|
|
||||||
// AP added for Vita
|
// AP added for Vita
|
||||||
|
|||||||
@@ -34,7 +34,7 @@
|
|||||||
|
|
||||||
Random PlayerConnection::random;
|
Random PlayerConnection::random;
|
||||||
|
|
||||||
PlayerConnection::PlayerConnection(MinecraftServer *server, Connection *connection, shared_ptr<ServerPlayer> player)
|
PlayerConnection::PlayerConnection(MinecraftServer *server, Connection *connection, std::shared_ptr<ServerPlayer> player)
|
||||||
{
|
{
|
||||||
// 4J - added initialisers
|
// 4J - added initialisers
|
||||||
done = false;
|
done = false;
|
||||||
@@ -93,7 +93,7 @@ void PlayerConnection::tick()
|
|||||||
lastKeepAliveTick = tickCount;
|
lastKeepAliveTick = tickCount;
|
||||||
lastKeepAliveTime = System::nanoTime() / 1000000;
|
lastKeepAliveTime = System::nanoTime() / 1000000;
|
||||||
lastKeepAliveId = random.nextInt();
|
lastKeepAliveId = random.nextInt();
|
||||||
send( shared_ptr<KeepAlivePacket>( new KeepAlivePacket(lastKeepAliveId) ) );
|
send( std::shared_ptr<KeepAlivePacket>( new KeepAlivePacket(lastKeepAliveId) ) );
|
||||||
}
|
}
|
||||||
// if (!didTick) {
|
// if (!didTick) {
|
||||||
// player->doTick(false);
|
// player->doTick(false);
|
||||||
@@ -123,17 +123,17 @@ void PlayerConnection::disconnect(DisconnectPacket::eDisconnectReason reason)
|
|||||||
|
|
||||||
// 4J Stu - Need to remove the player from the receiving list before their socket is NULLed so that we can find another player on their system
|
// 4J Stu - Need to remove the player from the receiving list before their socket is NULLed so that we can find another player on their system
|
||||||
server->getPlayers()->removePlayerFromReceiving( player );
|
server->getPlayers()->removePlayerFromReceiving( player );
|
||||||
send( shared_ptr<DisconnectPacket>( new DisconnectPacket(reason) ));
|
send( std::shared_ptr<DisconnectPacket>( new DisconnectPacket(reason) ));
|
||||||
connection->sendAndQuit();
|
connection->sendAndQuit();
|
||||||
// 4J-PB - removed, since it needs to be localised in the language the client is in
|
// 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.") ) );
|
//server->players->broadcastAll( std::shared_ptr<ChatPacket>( new ChatPacket(L"§e" + player->name + L" left the game.") ) );
|
||||||
if(getWasKicked())
|
if(getWasKicked())
|
||||||
{
|
{
|
||||||
server->getPlayers()->broadcastAll( shared_ptr<ChatPacket>( new ChatPacket(player->name, ChatPacket::e_ChatPlayerKickedFromGame) ) );
|
server->getPlayers()->broadcastAll( std::shared_ptr<ChatPacket>( new ChatPacket(player->name, ChatPacket::e_ChatPlayerKickedFromGame) ) );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
server->getPlayers()->broadcastAll( shared_ptr<ChatPacket>( new ChatPacket(player->name, ChatPacket::e_ChatPlayerLeftGame) ) );
|
server->getPlayers()->broadcastAll( std::shared_ptr<ChatPacket>( new ChatPacket(player->name, ChatPacket::e_ChatPlayerLeftGame) ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
server->getPlayers()->remove(player);
|
server->getPlayers()->remove(player);
|
||||||
@@ -141,12 +141,12 @@ void PlayerConnection::disconnect(DisconnectPacket::eDisconnectReason reason)
|
|||||||
LeaveCriticalSection(&done_cs);
|
LeaveCriticalSection(&done_cs);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerConnection::handlePlayerInput(shared_ptr<PlayerInputPacket> packet)
|
void PlayerConnection::handlePlayerInput(std::shared_ptr<PlayerInputPacket> packet)
|
||||||
{
|
{
|
||||||
player->setPlayerInput(packet->getXa(), packet->getYa(), packet->isJumping(), packet->isSneaking(), packet->getXRot(), packet->getYRot());
|
player->setPlayerInput(packet->getXa(), packet->getYa(), packet->isJumping(), packet->isSneaking(), packet->getXRot(), packet->getYRot());
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerConnection::handleMovePlayer(shared_ptr<MovePlayerPacket> packet)
|
void PlayerConnection::handleMovePlayer(std::shared_ptr<MovePlayerPacket> packet)
|
||||||
{
|
{
|
||||||
ServerLevel *level = server->getLevel(player->dimension);
|
ServerLevel *level = server->getLevel(player->dimension);
|
||||||
|
|
||||||
@@ -391,10 +391,10 @@ void PlayerConnection::teleport(double x, double y, double z, float yRot, float
|
|||||||
player->absMoveTo(x, y, z, yRot, xRot);
|
player->absMoveTo(x, y, z, yRot, xRot);
|
||||||
// 4J - note that 1.62 is added to the height here as the client connection that receives this will presume it represents y + heightOffset at that end
|
// 4J - note that 1.62 is added to the height here as the client connection that receives this will presume it represents y + heightOffset at that end
|
||||||
// This is different to the way that height is sent back to the server, where it represents the bottom of the player bounding volume
|
// This is different to the way that height is sent back to the server, where it represents the bottom of the player bounding volume
|
||||||
if(sendPacket) player->connection->send( shared_ptr<MovePlayerPacket>( new MovePlayerPacket::PosRot(x, y + 1.62f, y, z, yRot, xRot, false, false) ) );
|
if(sendPacket) player->connection->send( std::shared_ptr<MovePlayerPacket>( new MovePlayerPacket::PosRot(x, y + 1.62f, y, z, yRot, xRot, false, false) ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerConnection::handlePlayerAction(shared_ptr<PlayerActionPacket> packet)
|
void PlayerConnection::handlePlayerAction(std::shared_ptr<PlayerActionPacket> packet)
|
||||||
{
|
{
|
||||||
ServerLevel *level = server->getLevel(player->dimension);
|
ServerLevel *level = server->getLevel(player->dimension);
|
||||||
|
|
||||||
@@ -442,19 +442,19 @@ void PlayerConnection::handlePlayerAction(shared_ptr<PlayerActionPacket> packet)
|
|||||||
if (packet->action == PlayerActionPacket::START_DESTROY_BLOCK)
|
if (packet->action == PlayerActionPacket::START_DESTROY_BLOCK)
|
||||||
{
|
{
|
||||||
if (zd > 16 || canEditSpawn) player->gameMode->startDestroyBlock(x, y, z, packet->face);
|
if (zd > 16 || canEditSpawn) player->gameMode->startDestroyBlock(x, y, z, packet->face);
|
||||||
else player->connection->send( shared_ptr<TileUpdatePacket>( new TileUpdatePacket(x, y, z, level) ) );
|
else player->connection->send( std::shared_ptr<TileUpdatePacket>( new TileUpdatePacket(x, y, z, level) ) );
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (packet->action == PlayerActionPacket::STOP_DESTROY_BLOCK)
|
else if (packet->action == PlayerActionPacket::STOP_DESTROY_BLOCK)
|
||||||
{
|
{
|
||||||
player->gameMode->stopDestroyBlock(x, y, z);
|
player->gameMode->stopDestroyBlock(x, y, z);
|
||||||
server->getPlayers()->prioritiseTileChanges(x, y, z, level->dimension->id); // 4J added - make sure that the update packets for this get prioritised over other general world updates
|
server->getPlayers()->prioritiseTileChanges(x, y, z, level->dimension->id); // 4J added - make sure that the update packets for this get prioritised over other general world updates
|
||||||
if (level->getTile(x, y, z) != 0) player->connection->send( shared_ptr<TileUpdatePacket>( new TileUpdatePacket(x, y, z, level) ) );
|
if (level->getTile(x, y, z) != 0) player->connection->send( std::shared_ptr<TileUpdatePacket>( new TileUpdatePacket(x, y, z, level) ) );
|
||||||
}
|
}
|
||||||
else if (packet->action == PlayerActionPacket::ABORT_DESTROY_BLOCK)
|
else if (packet->action == PlayerActionPacket::ABORT_DESTROY_BLOCK)
|
||||||
{
|
{
|
||||||
player->gameMode->abortDestroyBlock(x, y, z);
|
player->gameMode->abortDestroyBlock(x, y, z);
|
||||||
if (level->getTile(x, y, z) != 0) player->connection->send(shared_ptr<TileUpdatePacket>( new TileUpdatePacket(x, y, z, level)));
|
if (level->getTile(x, y, z) != 0) player->connection->send(std::shared_ptr<TileUpdatePacket>( new TileUpdatePacket(x, y, z, level)));
|
||||||
}
|
}
|
||||||
else if (packet->action == PlayerActionPacket::GET_UPDATED_BLOCK)
|
else if (packet->action == PlayerActionPacket::GET_UPDATED_BLOCK)
|
||||||
{
|
{
|
||||||
@@ -464,7 +464,7 @@ void PlayerConnection::handlePlayerAction(shared_ptr<PlayerActionPacket> packet)
|
|||||||
double dist = xDist * xDist + yDist * yDist + zDist * zDist;
|
double dist = xDist * xDist + yDist * yDist + zDist * zDist;
|
||||||
if (dist < 16 * 16)
|
if (dist < 16 * 16)
|
||||||
{
|
{
|
||||||
player->connection->send( shared_ptr<TileUpdatePacket>( new TileUpdatePacket(x, y, z, level) ) );
|
player->connection->send( std::shared_ptr<TileUpdatePacket>( new TileUpdatePacket(x, y, z, level) ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -473,10 +473,10 @@ void PlayerConnection::handlePlayerAction(shared_ptr<PlayerActionPacket> packet)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerConnection::handleUseItem(shared_ptr<UseItemPacket> packet)
|
void PlayerConnection::handleUseItem(std::shared_ptr<UseItemPacket> packet)
|
||||||
{
|
{
|
||||||
ServerLevel *level = server->getLevel(player->dimension);
|
ServerLevel *level = server->getLevel(player->dimension);
|
||||||
shared_ptr<ItemInstance> item = player->inventory->getSelected();
|
std::shared_ptr<ItemInstance> item = player->inventory->getSelected();
|
||||||
bool informClient = false;
|
bool informClient = false;
|
||||||
int x = packet->getX();
|
int x = packet->getX();
|
||||||
int y = packet->getY();
|
int y = packet->getY();
|
||||||
@@ -509,14 +509,14 @@ void PlayerConnection::handleUseItem(shared_ptr<UseItemPacket> packet)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//player->connection->send(shared_ptr<ChatPacket>(new ChatPacket("\u00A77Height limit for building is " + server->maxBuildHeight)));
|
//player->connection->send(std::shared_ptr<ChatPacket>(new ChatPacket("\u00A77Height limit for building is " + server->maxBuildHeight)));
|
||||||
informClient = true;
|
informClient = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (informClient)
|
if (informClient)
|
||||||
{
|
{
|
||||||
|
|
||||||
player->connection->send( shared_ptr<TileUpdatePacket>( new TileUpdatePacket(x, y, z, level) ) );
|
player->connection->send( std::shared_ptr<TileUpdatePacket>( new TileUpdatePacket(x, y, z, level) ) );
|
||||||
|
|
||||||
if (face == 0) y--;
|
if (face == 0) y--;
|
||||||
if (face == 1) y++;
|
if (face == 1) y++;
|
||||||
@@ -532,7 +532,7 @@ void PlayerConnection::handleUseItem(shared_ptr<UseItemPacket> packet)
|
|||||||
// isn't what it is expecting.
|
// isn't what it is expecting.
|
||||||
if( level->getTile(x,y,z) != Tile::pistonMovingPiece_Id )
|
if( level->getTile(x,y,z) != Tile::pistonMovingPiece_Id )
|
||||||
{
|
{
|
||||||
player->connection->send( shared_ptr<TileUpdatePacket>( new TileUpdatePacket(x, y, z, level) ) );
|
player->connection->send( std::shared_ptr<TileUpdatePacket>( new TileUpdatePacket(x, y, z, level) ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -554,7 +554,7 @@ void PlayerConnection::handleUseItem(shared_ptr<UseItemPacket> packet)
|
|||||||
|
|
||||||
if (!ItemInstance::matches(player->inventory->getSelected(), packet->getItem()))
|
if (!ItemInstance::matches(player->inventory->getSelected(), packet->getItem()))
|
||||||
{
|
{
|
||||||
send( shared_ptr<ContainerSetSlotPacket>( new ContainerSetSlotPacket(player->containerMenu->containerId, s->index, player->inventory->getSelected()) ) );
|
send( std::shared_ptr<ContainerSetSlotPacket>( new ContainerSetSlotPacket(player->containerMenu->containerId, s->index, player->inventory->getSelected()) ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -569,27 +569,27 @@ void PlayerConnection::onDisconnect(DisconnectPacket::eDisconnectReason reason,
|
|||||||
if( done ) return;
|
if( done ) return;
|
||||||
// logger.info(player.name + " lost connection: " + reason);
|
// logger.info(player.name + " lost connection: " + reason);
|
||||||
// 4J-PB - removed, since it needs to be localised in the language the client is in
|
// 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.") ) );
|
//server->players->broadcastAll( std::shared_ptr<ChatPacket>( new ChatPacket(L"§e" + player->name + L" left the game.") ) );
|
||||||
if(getWasKicked())
|
if(getWasKicked())
|
||||||
{
|
{
|
||||||
server->getPlayers()->broadcastAll( shared_ptr<ChatPacket>( new ChatPacket(player->name, ChatPacket::e_ChatPlayerKickedFromGame) ) );
|
server->getPlayers()->broadcastAll( std::shared_ptr<ChatPacket>( new ChatPacket(player->name, ChatPacket::e_ChatPlayerKickedFromGame) ) );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
server->getPlayers()->broadcastAll( shared_ptr<ChatPacket>( new ChatPacket(player->name, ChatPacket::e_ChatPlayerLeftGame) ) );
|
server->getPlayers()->broadcastAll( std::shared_ptr<ChatPacket>( new ChatPacket(player->name, ChatPacket::e_ChatPlayerLeftGame) ) );
|
||||||
}
|
}
|
||||||
server->getPlayers()->remove(player);
|
server->getPlayers()->remove(player);
|
||||||
done = true;
|
done = true;
|
||||||
LeaveCriticalSection(&done_cs);
|
LeaveCriticalSection(&done_cs);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerConnection::onUnhandledPacket(shared_ptr<Packet> packet)
|
void PlayerConnection::onUnhandledPacket(std::shared_ptr<Packet> packet)
|
||||||
{
|
{
|
||||||
// logger.warning(getClass() + " wasn't prepared to deal with a " + packet.getClass());
|
// logger.warning(getClass() + " wasn't prepared to deal with a " + packet.getClass());
|
||||||
disconnect(DisconnectPacket::eDisconnect_UnexpectedPacket);
|
disconnect(DisconnectPacket::eDisconnect_UnexpectedPacket);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerConnection::send(shared_ptr<Packet> packet)
|
void PlayerConnection::send(std::shared_ptr<Packet> packet)
|
||||||
{
|
{
|
||||||
if( connection->getSocket() != NULL )
|
if( connection->getSocket() != NULL )
|
||||||
{
|
{
|
||||||
@@ -607,7 +607,7 @@ void PlayerConnection::send(shared_ptr<Packet> packet)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 4J Added
|
// 4J Added
|
||||||
void PlayerConnection::queueSend(shared_ptr<Packet> packet)
|
void PlayerConnection::queueSend(std::shared_ptr<Packet> packet)
|
||||||
{
|
{
|
||||||
if( connection->getSocket() != NULL )
|
if( connection->getSocket() != NULL )
|
||||||
{
|
{
|
||||||
@@ -624,7 +624,7 @@ void PlayerConnection::queueSend(shared_ptr<Packet> packet)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerConnection::handleSetCarriedItem(shared_ptr<SetCarriedItemPacket> packet)
|
void PlayerConnection::handleSetCarriedItem(std::shared_ptr<SetCarriedItemPacket> packet)
|
||||||
{
|
{
|
||||||
if (packet->slot < 0 || packet->slot >= Inventory::getSelectionSize())
|
if (packet->slot < 0 || packet->slot >= Inventory::getSelectionSize())
|
||||||
{
|
{
|
||||||
@@ -634,11 +634,11 @@ void PlayerConnection::handleSetCarriedItem(shared_ptr<SetCarriedItemPacket> pac
|
|||||||
player->inventory->selected = packet->slot;
|
player->inventory->selected = packet->slot;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerConnection::handleChat(shared_ptr<ChatPacket> packet)
|
void PlayerConnection::handleChat(std::shared_ptr<ChatPacket> packet)
|
||||||
{
|
{
|
||||||
// 4J - TODO
|
// 4J - TODO
|
||||||
#if 0
|
#if 0
|
||||||
wstring message = packet->message;
|
std::wstring message = packet->message;
|
||||||
if (message.length() > SharedConstants::maxChatLength)
|
if (message.length() > SharedConstants::maxChatLength)
|
||||||
{
|
{
|
||||||
disconnect(L"Chat message too long");
|
disconnect(L"Chat message too long");
|
||||||
@@ -670,7 +670,7 @@ void PlayerConnection::handleChat(shared_ptr<ChatPacket> packet)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerConnection::handleCommand(const wstring& message)
|
void PlayerConnection::handleCommand(const std::wstring& message)
|
||||||
{
|
{
|
||||||
// 4J - TODO
|
// 4J - TODO
|
||||||
#if 0
|
#if 0
|
||||||
@@ -678,7 +678,7 @@ void PlayerConnection::handleCommand(const wstring& message)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerConnection::handleAnimate(shared_ptr<AnimatePacket> packet)
|
void PlayerConnection::handleAnimate(std::shared_ptr<AnimatePacket> packet)
|
||||||
{
|
{
|
||||||
if (packet->action == AnimatePacket::SWING)
|
if (packet->action == AnimatePacket::SWING)
|
||||||
{
|
{
|
||||||
@@ -686,7 +686,7 @@ void PlayerConnection::handleAnimate(shared_ptr<AnimatePacket> packet)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerConnection::handlePlayerCommand(shared_ptr<PlayerCommandPacket> packet)
|
void PlayerConnection::handlePlayerCommand(std::shared_ptr<PlayerCommandPacket> packet)
|
||||||
{
|
{
|
||||||
if (packet->action == PlayerCommandPacket::START_SNEAKING)
|
if (packet->action == PlayerCommandPacket::START_SNEAKING)
|
||||||
{
|
{
|
||||||
@@ -725,7 +725,7 @@ void PlayerConnection::setShowOnMaps(bool bVal)
|
|||||||
player->setShowOnMaps(bVal);
|
player->setShowOnMaps(bVal);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerConnection::handleDisconnect(shared_ptr<DisconnectPacket> packet)
|
void PlayerConnection::handleDisconnect(std::shared_ptr<DisconnectPacket> packet)
|
||||||
{
|
{
|
||||||
// 4J Stu - Need to remove the player from the receiving list before their socket is NULLed so that we can find another player on their system
|
// 4J Stu - Need to remove the player from the receiving list before their socket is NULLed so that we can find another player on their system
|
||||||
server->getPlayers()->removePlayerFromReceiving( player );
|
server->getPlayers()->removePlayerFromReceiving( player );
|
||||||
@@ -737,27 +737,27 @@ int PlayerConnection::countDelayedPackets()
|
|||||||
return connection->countDelayedPackets();
|
return connection->countDelayedPackets();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerConnection::info(const wstring& string)
|
void PlayerConnection::info(const std::wstring& string)
|
||||||
{
|
{
|
||||||
// 4J-PB - removed, since it needs to be localised in the language the client is in
|
// 4J-PB - removed, since it needs to be localised in the language the client is in
|
||||||
//send( shared_ptr<ChatPacket>( new ChatPacket(L"§7" + string) ) );
|
//send( std::shared_ptr<ChatPacket>( new ChatPacket(L"§7" + string) ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerConnection::warn(const wstring& string)
|
void PlayerConnection::warn(const std::wstring& string)
|
||||||
{
|
{
|
||||||
// 4J-PB - removed, since it needs to be localised in the language the client is in
|
// 4J-PB - removed, since it needs to be localised in the language the client is in
|
||||||
//send( shared_ptr<ChatPacket>( new ChatPacket(L"§9" + string) ) );
|
//send( std::shared_ptr<ChatPacket>( new ChatPacket(L"§9" + string) ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
wstring PlayerConnection::getConsoleName()
|
std::wstring PlayerConnection::getConsoleName()
|
||||||
{
|
{
|
||||||
return player->name;
|
return player->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerConnection::handleInteract(shared_ptr<InteractPacket> packet)
|
void PlayerConnection::handleInteract(std::shared_ptr<InteractPacket> packet)
|
||||||
{
|
{
|
||||||
ServerLevel *level = server->getLevel(player->dimension);
|
ServerLevel *level = server->getLevel(player->dimension);
|
||||||
shared_ptr<Entity> target = level->getEntity(packet->target);
|
std::shared_ptr<Entity> target = level->getEntity(packet->target);
|
||||||
|
|
||||||
// Fix for #8218 - Gameplay: Attacking zombies from a different level often results in no hits being registered
|
// Fix for #8218 - Gameplay: Attacking zombies from a different level often results in no hits being registered
|
||||||
// 4J Stu - If the client says that we hit something, then agree with it. The canSee can fail here as it checks
|
// 4J Stu - If the client says that we hit something, then agree with it. The canSee can fail here as it checks
|
||||||
@@ -792,7 +792,7 @@ bool PlayerConnection::canHandleAsyncPackets()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerConnection::handleTexture(shared_ptr<TexturePacket> packet)
|
void PlayerConnection::handleTexture(std::shared_ptr<TexturePacket> packet)
|
||||||
{
|
{
|
||||||
// Both PlayerConnection and ClientConnection should handle this mostly the same way
|
// Both PlayerConnection and ClientConnection should handle this mostly the same way
|
||||||
|
|
||||||
@@ -808,7 +808,7 @@ void PlayerConnection::handleTexture(shared_ptr<TexturePacket> packet)
|
|||||||
|
|
||||||
if(dwBytes!=0)
|
if(dwBytes!=0)
|
||||||
{
|
{
|
||||||
send( shared_ptr<TexturePacket>( new TexturePacket(packet->textureName,pbData,dwBytes) ) );
|
send( std::shared_ptr<TexturePacket>( new TexturePacket(packet->textureName,pbData,dwBytes) ) );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -826,7 +826,7 @@ void PlayerConnection::handleTexture(shared_ptr<TexturePacket> packet)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerConnection::handleTextureAndGeometry(shared_ptr<TextureAndGeometryPacket> packet)
|
void PlayerConnection::handleTextureAndGeometry(std::shared_ptr<TextureAndGeometryPacket> packet)
|
||||||
{
|
{
|
||||||
// Both PlayerConnection and ClientConnection should handle this mostly the same way
|
// Both PlayerConnection and ClientConnection should handle this mostly the same way
|
||||||
|
|
||||||
@@ -848,20 +848,20 @@ void PlayerConnection::handleTextureAndGeometry(shared_ptr<TextureAndGeometryPac
|
|||||||
{
|
{
|
||||||
if(pDLCSkinFile->getAdditionalBoxesCount()!=0)
|
if(pDLCSkinFile->getAdditionalBoxesCount()!=0)
|
||||||
{
|
{
|
||||||
send( shared_ptr<TextureAndGeometryPacket>( new TextureAndGeometryPacket(packet->textureName,pbData,dwTextureBytes,pDLCSkinFile) ) );
|
send( std::shared_ptr<TextureAndGeometryPacket>( new TextureAndGeometryPacket(packet->textureName,pbData,dwTextureBytes,pDLCSkinFile) ) );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
send( shared_ptr<TextureAndGeometryPacket>( new TextureAndGeometryPacket(packet->textureName,pbData,dwTextureBytes) ) );
|
send( std::shared_ptr<TextureAndGeometryPacket>( new TextureAndGeometryPacket(packet->textureName,pbData,dwTextureBytes) ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// we don't have the dlc skin, so retrieve the data from the app store
|
// we don't have the dlc skin, so retrieve the data from the app store
|
||||||
vector<SKIN_BOX *> *pvSkinBoxes = app.GetAdditionalSkinBoxes(packet->dwSkinID);
|
std::vector<SKIN_BOX *> *pvSkinBoxes = app.GetAdditionalSkinBoxes(packet->dwSkinID);
|
||||||
unsigned int uiAnimOverrideBitmask= app.GetAnimOverrideBitmask(packet->dwSkinID);
|
unsigned int uiAnimOverrideBitmask= app.GetAnimOverrideBitmask(packet->dwSkinID);
|
||||||
|
|
||||||
send( shared_ptr<TextureAndGeometryPacket>( new TextureAndGeometryPacket(packet->textureName,pbData,dwTextureBytes,pvSkinBoxes,uiAnimOverrideBitmask) ) );
|
send( std::shared_ptr<TextureAndGeometryPacket>( new TextureAndGeometryPacket(packet->textureName,pbData,dwTextureBytes,pvSkinBoxes,uiAnimOverrideBitmask) ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -894,7 +894,7 @@ void PlayerConnection::handleTextureAndGeometry(shared_ptr<TextureAndGeometryPac
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerConnection::handleTextureReceived(const wstring &textureName)
|
void PlayerConnection::handleTextureReceived(const std::wstring &textureName)
|
||||||
{
|
{
|
||||||
// This sends the server received texture out to any other players waiting for the data
|
// This sends the server received texture out to any other players waiting for the data
|
||||||
AUTO_VAR(it, find( m_texturesRequested.begin(), m_texturesRequested.end(), textureName ));
|
AUTO_VAR(it, find( m_texturesRequested.begin(), m_texturesRequested.end(), textureName ));
|
||||||
@@ -906,13 +906,13 @@ void PlayerConnection::handleTextureReceived(const wstring &textureName)
|
|||||||
|
|
||||||
if(dwBytes!=0)
|
if(dwBytes!=0)
|
||||||
{
|
{
|
||||||
send( shared_ptr<TexturePacket>( new TexturePacket(textureName,pbData,dwBytes) ) );
|
send( std::shared_ptr<TexturePacket>( new TexturePacket(textureName,pbData,dwBytes) ) );
|
||||||
m_texturesRequested.erase(it);
|
m_texturesRequested.erase(it);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerConnection::handleTextureAndGeometryReceived(const wstring &textureName)
|
void PlayerConnection::handleTextureAndGeometryReceived(const std::wstring &textureName)
|
||||||
{
|
{
|
||||||
// This sends the server received texture out to any other players waiting for the data
|
// This sends the server received texture out to any other players waiting for the data
|
||||||
AUTO_VAR(it, find( m_texturesRequested.begin(), m_texturesRequested.end(), textureName ));
|
AUTO_VAR(it, find( m_texturesRequested.begin(), m_texturesRequested.end(), textureName ));
|
||||||
@@ -927,23 +927,23 @@ void PlayerConnection::handleTextureAndGeometryReceived(const wstring &textureNa
|
|||||||
{
|
{
|
||||||
if(pDLCSkinFile && (pDLCSkinFile->getAdditionalBoxesCount()!=0))
|
if(pDLCSkinFile && (pDLCSkinFile->getAdditionalBoxesCount()!=0))
|
||||||
{
|
{
|
||||||
send( shared_ptr<TextureAndGeometryPacket>( new TextureAndGeometryPacket(textureName,pbData,dwTextureBytes,pDLCSkinFile) ) );
|
send( std::shared_ptr<TextureAndGeometryPacket>( new TextureAndGeometryPacket(textureName,pbData,dwTextureBytes,pDLCSkinFile) ) );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// get the data from the app
|
// get the data from the app
|
||||||
DWORD dwSkinID = app.getSkinIdFromPath(textureName);
|
DWORD dwSkinID = app.getSkinIdFromPath(textureName);
|
||||||
vector<SKIN_BOX *> *pvSkinBoxes = app.GetAdditionalSkinBoxes(dwSkinID);
|
std::vector<SKIN_BOX *> *pvSkinBoxes = app.GetAdditionalSkinBoxes(dwSkinID);
|
||||||
unsigned int uiAnimOverrideBitmask= app.GetAnimOverrideBitmask(dwSkinID);
|
unsigned int uiAnimOverrideBitmask= app.GetAnimOverrideBitmask(dwSkinID);
|
||||||
|
|
||||||
send( shared_ptr<TextureAndGeometryPacket>( new TextureAndGeometryPacket(textureName,pbData,dwTextureBytes, pvSkinBoxes, uiAnimOverrideBitmask) ) );
|
send( std::shared_ptr<TextureAndGeometryPacket>( new TextureAndGeometryPacket(textureName,pbData,dwTextureBytes, pvSkinBoxes, uiAnimOverrideBitmask) ) );
|
||||||
}
|
}
|
||||||
m_texturesRequested.erase(it);
|
m_texturesRequested.erase(it);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerConnection::handleTextureChange(shared_ptr<TextureChangePacket> packet)
|
void PlayerConnection::handleTextureChange(std::shared_ptr<TextureChangePacket> packet)
|
||||||
{
|
{
|
||||||
switch(packet->action)
|
switch(packet->action)
|
||||||
{
|
{
|
||||||
@@ -968,7 +968,7 @@ void PlayerConnection::handleTextureChange(shared_ptr<TextureChangePacket> packe
|
|||||||
#ifndef _CONTENT_PACKAGE
|
#ifndef _CONTENT_PACKAGE
|
||||||
wprintf(L"Sending texture packet to get custom skin %ls from player %ls\n",packet->path.c_str(), player->name.c_str());
|
wprintf(L"Sending texture packet to get custom skin %ls from player %ls\n",packet->path.c_str(), player->name.c_str());
|
||||||
#endif
|
#endif
|
||||||
send(shared_ptr<TexturePacket>( new TexturePacket(packet->path,NULL,0) ) );
|
send(std::shared_ptr<TexturePacket>( new TexturePacket(packet->path,NULL,0) ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(!packet->path.empty() && app.IsFileInMemoryTextures(packet->path))
|
else if(!packet->path.empty() && app.IsFileInMemoryTextures(packet->path))
|
||||||
@@ -976,10 +976,10 @@ void PlayerConnection::handleTextureChange(shared_ptr<TextureChangePacket> packe
|
|||||||
// Update the ref count on the memory texture data
|
// Update the ref count on the memory texture data
|
||||||
app.AddMemoryTextureFile(packet->path,NULL,0);
|
app.AddMemoryTextureFile(packet->path,NULL,0);
|
||||||
}
|
}
|
||||||
server->getPlayers()->broadcastAll( shared_ptr<TextureChangePacket>( new TextureChangePacket(player,packet->action,packet->path) ), player->dimension );
|
server->getPlayers()->broadcastAll( std::shared_ptr<TextureChangePacket>( new TextureChangePacket(player,packet->action,packet->path) ), player->dimension );
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerConnection::handleTextureAndGeometryChange(shared_ptr<TextureAndGeometryChangePacket> packet)
|
void PlayerConnection::handleTextureAndGeometryChange(std::shared_ptr<TextureAndGeometryChangePacket> packet)
|
||||||
{
|
{
|
||||||
|
|
||||||
player->setCustomSkin( app.getSkinIdFromPath( packet->path ) );
|
player->setCustomSkin( app.getSkinIdFromPath( packet->path ) );
|
||||||
@@ -995,7 +995,7 @@ void PlayerConnection::handleTextureAndGeometryChange(shared_ptr<TextureAndGeome
|
|||||||
#ifndef _CONTENT_PACKAGE
|
#ifndef _CONTENT_PACKAGE
|
||||||
wprintf(L"Sending texture packet to get custom skin %ls from player %ls\n",packet->path.c_str(), player->name.c_str());
|
wprintf(L"Sending texture packet to get custom skin %ls from player %ls\n",packet->path.c_str(), player->name.c_str());
|
||||||
#endif
|
#endif
|
||||||
send(shared_ptr<TextureAndGeometryPacket>( new TextureAndGeometryPacket(packet->path,NULL,0) ) );
|
send(std::shared_ptr<TextureAndGeometryPacket>( new TextureAndGeometryPacket(packet->path,NULL,0) ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(!packet->path.empty() && app.IsFileInMemoryTextures(packet->path))
|
else if(!packet->path.empty() && app.IsFileInMemoryTextures(packet->path))
|
||||||
@@ -1009,10 +1009,10 @@ void PlayerConnection::handleTextureAndGeometryChange(shared_ptr<TextureAndGeome
|
|||||||
//app.SetAdditionalSkinBoxes(packet->dwSkinID,)
|
//app.SetAdditionalSkinBoxes(packet->dwSkinID,)
|
||||||
//DebugBreak();
|
//DebugBreak();
|
||||||
}
|
}
|
||||||
server->getPlayers()->broadcastAll( shared_ptr<TextureAndGeometryChangePacket>( new TextureAndGeometryChangePacket(player,packet->path) ), player->dimension );
|
server->getPlayers()->broadcastAll( std::shared_ptr<TextureAndGeometryChangePacket>( new TextureAndGeometryChangePacket(player,packet->path) ), player->dimension );
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerConnection::handleServerSettingsChanged(shared_ptr<ServerSettingsChangedPacket> packet)
|
void PlayerConnection::handleServerSettingsChanged(std::shared_ptr<ServerSettingsChangedPacket> packet)
|
||||||
{
|
{
|
||||||
if(packet->action==ServerSettingsChangedPacket::HOST_IN_GAME_SETTINGS)
|
if(packet->action==ServerSettingsChangedPacket::HOST_IN_GAME_SETTINGS)
|
||||||
{
|
{
|
||||||
@@ -1024,7 +1024,7 @@ void PlayerConnection::handleServerSettingsChanged(shared_ptr<ServerSettingsChan
|
|||||||
app.SetGameHostOption(eGameHostOption_FireSpreads, app.GetGameHostOption(packet->data,eGameHostOption_FireSpreads));
|
app.SetGameHostOption(eGameHostOption_FireSpreads, app.GetGameHostOption(packet->data,eGameHostOption_FireSpreads));
|
||||||
app.SetGameHostOption(eGameHostOption_TNT, app.GetGameHostOption(packet->data,eGameHostOption_TNT));
|
app.SetGameHostOption(eGameHostOption_TNT, app.GetGameHostOption(packet->data,eGameHostOption_TNT));
|
||||||
|
|
||||||
server->getPlayers()->broadcastAll( shared_ptr<ServerSettingsChangedPacket>( new ServerSettingsChangedPacket( ServerSettingsChangedPacket::HOST_IN_GAME_SETTINGS,app.GetGameHostOption(eGameHostOption_All) ) ) );
|
server->getPlayers()->broadcastAll( std::shared_ptr<ServerSettingsChangedPacket>( new ServerSettingsChangedPacket( ServerSettingsChangedPacket::HOST_IN_GAME_SETTINGS,app.GetGameHostOption(eGameHostOption_All) ) ) );
|
||||||
|
|
||||||
// Update the QoS data
|
// Update the QoS data
|
||||||
g_NetworkManager.UpdateAndSetGameSessionData();
|
g_NetworkManager.UpdateAndSetGameSessionData();
|
||||||
@@ -1032,7 +1032,7 @@ void PlayerConnection::handleServerSettingsChanged(shared_ptr<ServerSettingsChan
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerConnection::handleKickPlayer(shared_ptr<KickPlayerPacket> packet)
|
void PlayerConnection::handleKickPlayer(std::shared_ptr<KickPlayerPacket> packet)
|
||||||
{
|
{
|
||||||
INetworkPlayer *networkPlayer = getNetworkPlayer();
|
INetworkPlayer *networkPlayer = getNetworkPlayer();
|
||||||
if( (networkPlayer != NULL && networkPlayer->IsHost()) || player->isModerator())
|
if( (networkPlayer != NULL && networkPlayer->IsHost()) || player->isModerator())
|
||||||
@@ -1041,12 +1041,12 @@ void PlayerConnection::handleKickPlayer(shared_ptr<KickPlayerPacket> packet)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerConnection::handleGameCommand(shared_ptr<GameCommandPacket> packet)
|
void PlayerConnection::handleGameCommand(std::shared_ptr<GameCommandPacket> packet)
|
||||||
{
|
{
|
||||||
MinecraftServer::getInstance()->getCommandDispatcher()->performCommand(player, packet->command, packet->data);
|
MinecraftServer::getInstance()->getCommandDispatcher()->performCommand(player, packet->command, packet->data);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerConnection::handleClientCommand(shared_ptr<ClientCommandPacket> packet)
|
void PlayerConnection::handleClientCommand(std::shared_ptr<ClientCommandPacket> packet)
|
||||||
{
|
{
|
||||||
if (packet->action == ClientCommandPacket::PERFORM_RESPAWN)
|
if (packet->action == ClientCommandPacket::PERFORM_RESPAWN)
|
||||||
{
|
{
|
||||||
@@ -1078,17 +1078,17 @@ void PlayerConnection::handleClientCommand(shared_ptr<ClientCommandPacket> packe
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerConnection::handleRespawn(shared_ptr<RespawnPacket> packet)
|
void PlayerConnection::handleRespawn(std::shared_ptr<RespawnPacket> packet)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerConnection::handleContainerClose(shared_ptr<ContainerClosePacket> packet)
|
void PlayerConnection::handleContainerClose(std::shared_ptr<ContainerClosePacket> packet)
|
||||||
{
|
{
|
||||||
player->doCloseContainer();
|
player->doCloseContainer();
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef _CONTENT_PACKAGE
|
#ifndef _CONTENT_PACKAGE
|
||||||
void PlayerConnection::handleContainerSetSlot(shared_ptr<ContainerSetSlotPacket> packet)
|
void PlayerConnection::handleContainerSetSlot(std::shared_ptr<ContainerSetSlotPacket> packet)
|
||||||
{
|
{
|
||||||
if (packet->containerId == AbstractContainerMenu::CONTAINER_ID_CARRIED )
|
if (packet->containerId == AbstractContainerMenu::CONTAINER_ID_CARRIED )
|
||||||
{
|
{
|
||||||
@@ -1098,7 +1098,7 @@ void PlayerConnection::handleContainerSetSlot(shared_ptr<ContainerSetSlotPacket>
|
|||||||
{
|
{
|
||||||
if (packet->containerId == AbstractContainerMenu::CONTAINER_ID_INVENTORY && packet->slot >= 36 && packet->slot < 36 + 9)
|
if (packet->containerId == AbstractContainerMenu::CONTAINER_ID_INVENTORY && packet->slot >= 36 && packet->slot < 36 + 9)
|
||||||
{
|
{
|
||||||
shared_ptr<ItemInstance> lastItem = player->inventoryMenu->getSlot(packet->slot)->getItem();
|
std::shared_ptr<ItemInstance> lastItem = player->inventoryMenu->getSlot(packet->slot)->getItem();
|
||||||
if (packet->item != NULL)
|
if (packet->item != NULL)
|
||||||
{
|
{
|
||||||
if (lastItem == NULL || lastItem->count < packet->item->count)
|
if (lastItem == NULL || lastItem->count < packet->item->count)
|
||||||
@@ -1124,16 +1124,16 @@ void PlayerConnection::handleContainerSetSlot(shared_ptr<ContainerSetSlotPacket>
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void PlayerConnection::handleContainerClick(shared_ptr<ContainerClickPacket> packet)
|
void PlayerConnection::handleContainerClick(std::shared_ptr<ContainerClickPacket> packet)
|
||||||
{
|
{
|
||||||
if (player->containerMenu->containerId == packet->containerId && player->containerMenu->isSynched(player))
|
if (player->containerMenu->containerId == packet->containerId && player->containerMenu->isSynched(player))
|
||||||
{
|
{
|
||||||
shared_ptr<ItemInstance> clicked = player->containerMenu->clicked(packet->slotNum, packet->buttonNum, packet->quickKey?AbstractContainerMenu::CLICK_QUICK_MOVE:AbstractContainerMenu::CLICK_PICKUP, player);
|
std::shared_ptr<ItemInstance> clicked = player->containerMenu->clicked(packet->slotNum, packet->buttonNum, packet->quickKey?AbstractContainerMenu::CLICK_QUICK_MOVE:AbstractContainerMenu::CLICK_PICKUP, player);
|
||||||
|
|
||||||
if (ItemInstance::matches(packet->item, clicked))
|
if (ItemInstance::matches(packet->item, clicked))
|
||||||
{
|
{
|
||||||
// Yep, you sure did click what you claimed to click!
|
// Yep, you sure did click what you claimed to click!
|
||||||
player->connection->send( shared_ptr<ContainerAckPacket>( new ContainerAckPacket(packet->containerId, packet->uid, true) ) );
|
player->connection->send( std::shared_ptr<ContainerAckPacket>( new ContainerAckPacket(packet->containerId, packet->uid, true) ) );
|
||||||
player->ignoreSlotUpdateHack = true;
|
player->ignoreSlotUpdateHack = true;
|
||||||
player->containerMenu->broadcastChanges();
|
player->containerMenu->broadcastChanges();
|
||||||
player->broadcastCarriedItem();
|
player->broadcastCarriedItem();
|
||||||
@@ -1143,10 +1143,10 @@ void PlayerConnection::handleContainerClick(shared_ptr<ContainerClickPacket> pac
|
|||||||
{
|
{
|
||||||
// No, you clicked the wrong thing!
|
// No, you clicked the wrong thing!
|
||||||
expectedAcks[player->containerMenu->containerId] = packet->uid;
|
expectedAcks[player->containerMenu->containerId] = packet->uid;
|
||||||
player->connection->send( shared_ptr<ContainerAckPacket>( new ContainerAckPacket(packet->containerId, packet->uid, false) ) );
|
player->connection->send( std::shared_ptr<ContainerAckPacket>( new ContainerAckPacket(packet->containerId, packet->uid, false) ) );
|
||||||
player->containerMenu->setSynched(player, false);
|
player->containerMenu->setSynched(player, false);
|
||||||
|
|
||||||
vector<shared_ptr<ItemInstance> > items;
|
std::vector<std::shared_ptr<ItemInstance> > items;
|
||||||
for (unsigned int i = 0; i < player->containerMenu->slots->size(); i++)
|
for (unsigned int i = 0; i < player->containerMenu->slots->size(); i++)
|
||||||
{
|
{
|
||||||
items.push_back(player->containerMenu->slots->at(i)->getItem());
|
items.push_back(player->containerMenu->slots->at(i)->getItem());
|
||||||
@@ -1159,7 +1159,7 @@ void PlayerConnection::handleContainerClick(shared_ptr<ContainerClickPacket> pac
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerConnection::handleContainerButtonClick(shared_ptr<ContainerButtonClickPacket> packet)
|
void PlayerConnection::handleContainerButtonClick(std::shared_ptr<ContainerButtonClickPacket> packet)
|
||||||
{
|
{
|
||||||
if (player->containerMenu->containerId == packet->containerId && player->containerMenu->isSynched(player))
|
if (player->containerMenu->containerId == packet->containerId && player->containerMenu->isSynched(player))
|
||||||
{
|
{
|
||||||
@@ -1168,12 +1168,12 @@ void PlayerConnection::handleContainerButtonClick(shared_ptr<ContainerButtonClic
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerConnection::handleSetCreativeModeSlot(shared_ptr<SetCreativeModeSlotPacket> packet)
|
void PlayerConnection::handleSetCreativeModeSlot(std::shared_ptr<SetCreativeModeSlotPacket> packet)
|
||||||
{
|
{
|
||||||
if (player->gameMode->isCreative())
|
if (player->gameMode->isCreative())
|
||||||
{
|
{
|
||||||
bool drop = packet->slotNum < 0;
|
bool drop = packet->slotNum < 0;
|
||||||
shared_ptr<ItemInstance> item = packet->item;
|
std::shared_ptr<ItemInstance> item = packet->item;
|
||||||
|
|
||||||
if(item != NULL && item->id == Item::map_Id)
|
if(item != NULL && item->id == Item::map_Id)
|
||||||
{
|
{
|
||||||
@@ -1189,17 +1189,17 @@ void PlayerConnection::handleSetCreativeModeSlot(shared_ptr<SetCreativeModeSlotP
|
|||||||
#endif
|
#endif
|
||||||
item->setAuxValue( player->level->getAuxValueForMap(player->getXuid(), player->dimension, centreXC, centreZC, mapScale) );
|
item->setAuxValue( player->level->getAuxValueForMap(player->getXuid(), player->dimension, centreXC, centreZC, mapScale) );
|
||||||
|
|
||||||
shared_ptr<MapItemSavedData> data = MapItem::getSavedData(item->getAuxValue(), player->level);
|
std::shared_ptr<MapItemSavedData> data = MapItem::getSavedData(item->getAuxValue(), player->level);
|
||||||
// 4J Stu - We only have one map per player per dimension, so don't reset the one that they have
|
// 4J Stu - We only have one map per player per dimension, so don't reset the one that they have
|
||||||
// when a new one is created
|
// when a new one is created
|
||||||
wchar_t buf[64];
|
wchar_t buf[64];
|
||||||
swprintf(buf,64,L"map_%d", item->getAuxValue());
|
swprintf(buf,64,L"map_%d", item->getAuxValue());
|
||||||
std::wstring id = wstring(buf);
|
std::wstring id = std::wstring(buf);
|
||||||
if( data == NULL )
|
if( data == NULL )
|
||||||
{
|
{
|
||||||
data = shared_ptr<MapItemSavedData>( new MapItemSavedData(id) );
|
data = std::shared_ptr<MapItemSavedData>( new MapItemSavedData(id) );
|
||||||
}
|
}
|
||||||
player->level->setSavedData(id, (shared_ptr<SavedData> ) data);
|
player->level->setSavedData(id, (std::shared_ptr<SavedData> ) data);
|
||||||
|
|
||||||
data->scale = mapScale;
|
data->scale = mapScale;
|
||||||
// 4J-PB - for Xbox maps, we'll centre them on the origin of the world, since we can fit the whole world in our map
|
// 4J-PB - for Xbox maps, we'll centre them on the origin of the world, since we can fit the whole world in our map
|
||||||
@@ -1232,7 +1232,7 @@ void PlayerConnection::handleSetCreativeModeSlot(shared_ptr<SetCreativeModeSlotP
|
|||||||
{
|
{
|
||||||
dropSpamTickCount += SharedConstants::TICKS_PER_SECOND;
|
dropSpamTickCount += SharedConstants::TICKS_PER_SECOND;
|
||||||
// drop item
|
// drop item
|
||||||
shared_ptr<ItemEntity> dropped = player->drop(item);
|
std::shared_ptr<ItemEntity> dropped = player->drop(item);
|
||||||
if (dropped != NULL)
|
if (dropped != NULL)
|
||||||
{
|
{
|
||||||
dropped->setShortLifeTime();
|
dropped->setShortLifeTime();
|
||||||
@@ -1244,7 +1244,7 @@ void PlayerConnection::handleSetCreativeModeSlot(shared_ptr<SetCreativeModeSlotP
|
|||||||
{
|
{
|
||||||
// 4J Stu - Maps need to have their aux value update, so the client should always be assumed to be wrong
|
// 4J Stu - Maps need to have their aux value update, so the client should always be assumed to be wrong
|
||||||
// This is how the Java works, as the client also incorrectly predicts the auxvalue of the mapItem
|
// This is how the Java works, as the client also incorrectly predicts the auxvalue of the mapItem
|
||||||
vector<shared_ptr<ItemInstance> > items;
|
std::vector<std::shared_ptr<ItemInstance> > items;
|
||||||
for (unsigned int i = 0; i < player->inventoryMenu->slots->size(); i++)
|
for (unsigned int i = 0; i < player->inventoryMenu->slots->size(); i++)
|
||||||
{
|
{
|
||||||
items.push_back(player->inventoryMenu->slots->at(i)->getItem());
|
items.push_back(player->inventoryMenu->slots->at(i)->getItem());
|
||||||
@@ -1254,7 +1254,7 @@ void PlayerConnection::handleSetCreativeModeSlot(shared_ptr<SetCreativeModeSlotP
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerConnection::handleContainerAck(shared_ptr<ContainerAckPacket> packet)
|
void PlayerConnection::handleContainerAck(std::shared_ptr<ContainerAckPacket> packet)
|
||||||
{
|
{
|
||||||
AUTO_VAR(it, expectedAcks.find(player->containerMenu->containerId));
|
AUTO_VAR(it, expectedAcks.find(player->containerMenu->containerId));
|
||||||
|
|
||||||
@@ -1264,18 +1264,18 @@ void PlayerConnection::handleContainerAck(shared_ptr<ContainerAckPacket> packet)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerConnection::handleSignUpdate(shared_ptr<SignUpdatePacket> packet)
|
void PlayerConnection::handleSignUpdate(std::shared_ptr<SignUpdatePacket> packet)
|
||||||
{
|
{
|
||||||
app.DebugPrintf("PlayerConnection::handleSignUpdate\n");
|
app.DebugPrintf("PlayerConnection::handleSignUpdate\n");
|
||||||
|
|
||||||
ServerLevel *level = server->getLevel(player->dimension);
|
ServerLevel *level = server->getLevel(player->dimension);
|
||||||
if (level->hasChunkAt(packet->x, packet->y, packet->z))
|
if (level->hasChunkAt(packet->x, packet->y, packet->z))
|
||||||
{
|
{
|
||||||
shared_ptr<TileEntity> te = level->getTileEntity(packet->x, packet->y, packet->z);
|
std::shared_ptr<TileEntity> te = level->getTileEntity(packet->x, packet->y, packet->z);
|
||||||
|
|
||||||
if (dynamic_pointer_cast<SignTileEntity>(te) != NULL)
|
if (dynamic_pointer_cast<SignTileEntity>(te) != NULL)
|
||||||
{
|
{
|
||||||
shared_ptr<SignTileEntity> ste = dynamic_pointer_cast<SignTileEntity>(te);
|
std::shared_ptr<SignTileEntity> ste = dynamic_pointer_cast<SignTileEntity>(te);
|
||||||
if (!ste->isEditable())
|
if (!ste->isEditable())
|
||||||
{
|
{
|
||||||
server->warn(L"Player " + player->name + L" just tried to change non-editable sign");
|
server->warn(L"Player " + player->name + L" just tried to change non-editable sign");
|
||||||
@@ -1289,10 +1289,10 @@ void PlayerConnection::handleSignUpdate(shared_ptr<SignUpdatePacket> packet)
|
|||||||
int x = packet->x;
|
int x = packet->x;
|
||||||
int y = packet->y;
|
int y = packet->y;
|
||||||
int z = packet->z;
|
int z = packet->z;
|
||||||
shared_ptr<SignTileEntity> ste = dynamic_pointer_cast<SignTileEntity>(te);
|
std::shared_ptr<SignTileEntity> ste = dynamic_pointer_cast<SignTileEntity>(te);
|
||||||
for (int i = 0; i < 4; i++)
|
for (int i = 0; i < 4; i++)
|
||||||
{
|
{
|
||||||
wstring lineText = packet->lines[i].substr(0,15);
|
std::wstring lineText = packet->lines[i].substr(0,15);
|
||||||
ste->SetMessage( i, lineText );
|
ste->SetMessage( i, lineText );
|
||||||
}
|
}
|
||||||
ste->SetVerified(false);
|
ste->SetVerified(false);
|
||||||
@@ -1303,7 +1303,7 @@ void PlayerConnection::handleSignUpdate(shared_ptr<SignUpdatePacket> packet)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerConnection::handleKeepAlive(shared_ptr<KeepAlivePacket> packet)
|
void PlayerConnection::handleKeepAlive(std::shared_ptr<KeepAlivePacket> packet)
|
||||||
{
|
{
|
||||||
if (packet->id == lastKeepAliveId)
|
if (packet->id == lastKeepAliveId)
|
||||||
{
|
{
|
||||||
@@ -1312,18 +1312,18 @@ void PlayerConnection::handleKeepAlive(shared_ptr<KeepAlivePacket> packet)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerConnection::handlePlayerInfo(shared_ptr<PlayerInfoPacket> packet)
|
void PlayerConnection::handlePlayerInfo(std::shared_ptr<PlayerInfoPacket> packet)
|
||||||
{
|
{
|
||||||
// Need to check that this player has permission to change each individual setting?
|
// Need to check that this player has permission to change each individual setting?
|
||||||
|
|
||||||
INetworkPlayer *networkPlayer = getNetworkPlayer();
|
INetworkPlayer *networkPlayer = getNetworkPlayer();
|
||||||
if( (networkPlayer != NULL && networkPlayer->IsHost()) || player->isModerator() )
|
if( (networkPlayer != NULL && networkPlayer->IsHost()) || player->isModerator() )
|
||||||
{
|
{
|
||||||
shared_ptr<ServerPlayer> serverPlayer;
|
std::shared_ptr<ServerPlayer> serverPlayer;
|
||||||
// Find the player being edited
|
// Find the player being edited
|
||||||
for(AUTO_VAR(it, server->getPlayers()->players.begin()); it != server->getPlayers()->players.end(); ++it)
|
for(AUTO_VAR(it, server->getPlayers()->players.begin()); it != server->getPlayers()->players.end(); ++it)
|
||||||
{
|
{
|
||||||
shared_ptr<ServerPlayer> checkingPlayer = *it;
|
std::shared_ptr<ServerPlayer> checkingPlayer = *it;
|
||||||
if(checkingPlayer->connection->getNetworkPlayer() != NULL && checkingPlayer->connection->getNetworkPlayer()->GetSmallId() == packet->m_networkSmallId)
|
if(checkingPlayer->connection->getNetworkPlayer() != NULL && checkingPlayer->connection->getNetworkPlayer()->GetSmallId() == packet->m_networkSmallId)
|
||||||
{
|
{
|
||||||
serverPlayer = checkingPlayer;
|
serverPlayer = checkingPlayer;
|
||||||
@@ -1348,7 +1348,7 @@ void PlayerConnection::handlePlayerInfo(shared_ptr<PlayerInfoPacket> packet)
|
|||||||
#endif
|
#endif
|
||||||
serverPlayer->setPlayerGamePrivilege(Player::ePlayerGamePrivilege_CreativeMode,Player::getPlayerGamePrivilege(packet->m_playerPrivileges,Player::ePlayerGamePrivilege_CreativeMode) );
|
serverPlayer->setPlayerGamePrivilege(Player::ePlayerGamePrivilege_CreativeMode,Player::getPlayerGamePrivilege(packet->m_playerPrivileges,Player::ePlayerGamePrivilege_CreativeMode) );
|
||||||
serverPlayer->gameMode->setGameModeForPlayer(gameType);
|
serverPlayer->gameMode->setGameModeForPlayer(gameType);
|
||||||
serverPlayer->connection->send( shared_ptr<GameEventPacket>( new GameEventPacket(GameEventPacket::CHANGE_GAME_MODE, gameType->getId()) ));
|
serverPlayer->connection->send( std::shared_ptr<GameEventPacket>( new GameEventPacket(GameEventPacket::CHANGE_GAME_MODE, gameType->getId()) ));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -1400,7 +1400,7 @@ void PlayerConnection::handlePlayerInfo(shared_ptr<PlayerInfoPacket> packet)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
server->getPlayers()->broadcastAll( shared_ptr<PlayerInfoPacket>( new PlayerInfoPacket( serverPlayer ) ) );
|
server->getPlayers()->broadcastAll( std::shared_ptr<PlayerInfoPacket>( new PlayerInfoPacket( serverPlayer ) ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1410,7 +1410,7 @@ bool PlayerConnection::isServerPacketListener()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerConnection::handlePlayerAbilities(shared_ptr<PlayerAbilitiesPacket> playerAbilitiesPacket)
|
void PlayerConnection::handlePlayerAbilities(std::shared_ptr<PlayerAbilitiesPacket> playerAbilitiesPacket)
|
||||||
{
|
{
|
||||||
player->abilities.flying = playerAbilitiesPacket->isFlying() && player->abilities.mayfly;
|
player->abilities.flying = playerAbilitiesPacket->isFlying() && player->abilities.mayfly;
|
||||||
}
|
}
|
||||||
@@ -1427,19 +1427,19 @@ void PlayerConnection::handlePlayerAbilities(shared_ptr<PlayerAbilitiesPacket> p
|
|||||||
// player.connection.send(new ChatAutoCompletePacket(result.toString()));
|
// player.connection.send(new ChatAutoCompletePacket(result.toString()));
|
||||||
//}
|
//}
|
||||||
|
|
||||||
//void handleClientInformation(shared_ptr<ClientInformationPacket> packet)
|
//void handleClientInformation(std::shared_ptr<ClientInformationPacket> packet)
|
||||||
//{
|
//{
|
||||||
// player->updateOptions(packet);
|
// player->updateOptions(packet);
|
||||||
//}
|
//}
|
||||||
|
|
||||||
void PlayerConnection::handleCustomPayload(shared_ptr<CustomPayloadPacket> customPayloadPacket)
|
void PlayerConnection::handleCustomPayload(std::shared_ptr<CustomPayloadPacket> customPayloadPacket)
|
||||||
{
|
{
|
||||||
#if 0
|
#if 0
|
||||||
if (CustomPayloadPacket.CUSTOM_BOOK_PACKET.equals(customPayloadPacket.identifier))
|
if (CustomPayloadPacket.CUSTOM_BOOK_PACKET.equals(customPayloadPacket.identifier))
|
||||||
{
|
{
|
||||||
ByteArrayInputStream bais(customPayloadPacket->data);
|
ByteArrayInputStream bais(customPayloadPacket->data);
|
||||||
DataInputStream input(&bais);
|
DataInputStream input(&bais);
|
||||||
shared_ptr<ItemInstance> sentItem = Packet::readItem(input);
|
std::shared_ptr<ItemInstance> sentItem = Packet::readItem(input);
|
||||||
|
|
||||||
if (!WritingBookItem.makeSureTagIsValid(sentItem.getTag()))
|
if (!WritingBookItem.makeSureTagIsValid(sentItem.getTag()))
|
||||||
{
|
{
|
||||||
@@ -1498,7 +1498,7 @@ void PlayerConnection::handleCustomPayload(shared_ptr<CustomPayloadPacket> custo
|
|||||||
{
|
{
|
||||||
ByteArrayInputStream bais(customPayloadPacket->data);
|
ByteArrayInputStream bais(customPayloadPacket->data);
|
||||||
DataInputStream dis(&bais);
|
DataInputStream dis(&bais);
|
||||||
wstring name = dis.readUTF();
|
std::wstring name = dis.readUTF();
|
||||||
if (name.length() <= 30)
|
if (name.length() <= 30)
|
||||||
{
|
{
|
||||||
menu->setItemName(name);
|
menu->setItemName(name);
|
||||||
@@ -1510,13 +1510,13 @@ void PlayerConnection::handleCustomPayload(shared_ptr<CustomPayloadPacket> custo
|
|||||||
|
|
||||||
// 4J Added
|
// 4J Added
|
||||||
|
|
||||||
void PlayerConnection::handleDebugOptions(shared_ptr<DebugOptionsPacket> packet)
|
void PlayerConnection::handleDebugOptions(std::shared_ptr<DebugOptionsPacket> packet)
|
||||||
{
|
{
|
||||||
//Player player = dynamic_pointer_cast<Player>( player->shared_from_this() );
|
//Player player = dynamic_pointer_cast<Player>( player->shared_from_this() );
|
||||||
player->SetDebugOptions(packet->m_uiVal);
|
player->SetDebugOptions(packet->m_uiVal);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerConnection::handleCraftItem(shared_ptr<CraftItemPacket> packet)
|
void PlayerConnection::handleCraftItem(std::shared_ptr<CraftItemPacket> packet)
|
||||||
{
|
{
|
||||||
int iRecipe = packet->recipe;
|
int iRecipe = packet->recipe;
|
||||||
|
|
||||||
@@ -1524,7 +1524,7 @@ void PlayerConnection::handleCraftItem(shared_ptr<CraftItemPacket> packet)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
Recipy::INGREDIENTS_REQUIRED *pRecipeIngredientsRequired=Recipes::getInstance()->getRecipeIngredientsArray();
|
Recipy::INGREDIENTS_REQUIRED *pRecipeIngredientsRequired=Recipes::getInstance()->getRecipeIngredientsArray();
|
||||||
shared_ptr<ItemInstance> pTempItemInst=pRecipeIngredientsRequired[iRecipe].pRecipy->assemble(nullptr);
|
std::shared_ptr<ItemInstance> pTempItemInst=pRecipeIngredientsRequired[iRecipe].pRecipy->assemble(nullptr);
|
||||||
|
|
||||||
if(app.DebugSettingsOn() && (player->GetDebugOptions()&(1L<<eDebugSetting_CraftAnything)))
|
if(app.DebugSettingsOn() && (player->GetDebugOptions()&(1L<<eDebugSetting_CraftAnything)))
|
||||||
{
|
{
|
||||||
@@ -1549,7 +1549,7 @@ void PlayerConnection::handleCraftItem(shared_ptr<CraftItemPacket> packet)
|
|||||||
{
|
{
|
||||||
for(int j=0;j<pRecipeIngredientsRequired[iRecipe].iIngValA[i];j++)
|
for(int j=0;j<pRecipeIngredientsRequired[iRecipe].iIngValA[i];j++)
|
||||||
{
|
{
|
||||||
shared_ptr<ItemInstance> ingItemInst = nullptr;
|
std::shared_ptr<ItemInstance> ingItemInst = nullptr;
|
||||||
// do we need to remove a specific aux value?
|
// do we need to remove a specific aux value?
|
||||||
if(pRecipeIngredientsRequired[iRecipe].iIngAuxValA[i]!=Recipes::ANY_AUX_VALUE)
|
if(pRecipeIngredientsRequired[iRecipe].iIngAuxValA[i]!=Recipes::ANY_AUX_VALUE)
|
||||||
{
|
{
|
||||||
@@ -1568,7 +1568,7 @@ void PlayerConnection::handleCraftItem(shared_ptr<CraftItemPacket> packet)
|
|||||||
if (ingItemInst->getItem()->hasCraftingRemainingItem())
|
if (ingItemInst->getItem()->hasCraftingRemainingItem())
|
||||||
{
|
{
|
||||||
// replace item with remaining result
|
// replace item with remaining result
|
||||||
player->inventory->add( shared_ptr<ItemInstance>( new ItemInstance(ingItemInst->getItem()->getCraftingRemainingItem()) ) );
|
player->inventory->add( std::shared_ptr<ItemInstance>( new ItemInstance(ingItemInst->getItem()->getCraftingRemainingItem()) ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1586,7 +1586,7 @@ void PlayerConnection::handleCraftItem(shared_ptr<CraftItemPacket> packet)
|
|||||||
{
|
{
|
||||||
// 4J Stu - Maps need to have their aux value update, so the client should always be assumed to be wrong
|
// 4J Stu - Maps need to have their aux value update, so the client should always be assumed to be wrong
|
||||||
// This is how the Java works, as the client also incorrectly predicts the auxvalue of the mapItem
|
// This is how the Java works, as the client also incorrectly predicts the auxvalue of the mapItem
|
||||||
vector<shared_ptr<ItemInstance> > items;
|
std::vector<std::shared_ptr<ItemInstance> > items;
|
||||||
for (unsigned int i = 0; i < player->containerMenu->slots->size(); i++)
|
for (unsigned int i = 0; i < player->containerMenu->slots->size(); i++)
|
||||||
{
|
{
|
||||||
items.push_back(player->containerMenu->slots->at(i)->getItem());
|
items.push_back(player->containerMenu->slots->at(i)->getItem());
|
||||||
@@ -1625,7 +1625,7 @@ void PlayerConnection::handleCraftItem(shared_ptr<CraftItemPacket> packet)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PlayerConnection::handleTradeItem(shared_ptr<TradeItemPacket> packet)
|
void PlayerConnection::handleTradeItem(std::shared_ptr<TradeItemPacket> packet)
|
||||||
{
|
{
|
||||||
if (player->containerMenu->containerId == packet->containerId)
|
if (player->containerMenu->containerId == packet->containerId)
|
||||||
{
|
{
|
||||||
@@ -1642,8 +1642,8 @@ void PlayerConnection::handleTradeItem(shared_ptr<TradeItemPacket> packet)
|
|||||||
if(!activeRecipe->isDeprecated())
|
if(!activeRecipe->isDeprecated())
|
||||||
{
|
{
|
||||||
// Do we have the ingredients?
|
// Do we have the ingredients?
|
||||||
shared_ptr<ItemInstance> buyAItem = activeRecipe->getBuyAItem();
|
std::shared_ptr<ItemInstance> buyAItem = activeRecipe->getBuyAItem();
|
||||||
shared_ptr<ItemInstance> buyBItem = activeRecipe->getBuyBItem();
|
std::shared_ptr<ItemInstance> buyBItem = activeRecipe->getBuyBItem();
|
||||||
|
|
||||||
int buyAMatches = player->inventory->countMatches(buyAItem);
|
int buyAMatches = player->inventory->countMatches(buyAItem);
|
||||||
int buyBMatches = player->inventory->countMatches(buyBItem);
|
int buyBMatches = player->inventory->countMatches(buyBItem);
|
||||||
@@ -1656,7 +1656,7 @@ void PlayerConnection::handleTradeItem(shared_ptr<TradeItemPacket> packet)
|
|||||||
player->inventory->removeResources(buyBItem);
|
player->inventory->removeResources(buyBItem);
|
||||||
|
|
||||||
// Add the item we have purchased
|
// Add the item we have purchased
|
||||||
shared_ptr<ItemInstance> result = activeRecipe->getSellItem()->copy();
|
std::shared_ptr<ItemInstance> result = activeRecipe->getSellItem()->copy();
|
||||||
|
|
||||||
// 4J JEV - Award itemsBought stat.
|
// 4J JEV - Award itemsBought stat.
|
||||||
player->awardStat(
|
player->awardStat(
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ class Connection;
|
|||||||
class ServerPlayer;
|
class ServerPlayer;
|
||||||
class INetworkPlayer;
|
class INetworkPlayer;
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
class PlayerConnection : public PacketListener, public ConsoleInputSource
|
class PlayerConnection : public PacketListener, public ConsoleInputSource
|
||||||
{
|
{
|
||||||
@@ -25,7 +25,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
MinecraftServer *server;
|
MinecraftServer *server;
|
||||||
shared_ptr<ServerPlayer> player;
|
std::shared_ptr<ServerPlayer> player;
|
||||||
int tickCount;
|
int tickCount;
|
||||||
int aboveGroundTickCount;
|
int aboveGroundTickCount;
|
||||||
|
|
||||||
@@ -40,7 +40,7 @@ private:
|
|||||||
bool m_bHasClientTickedOnce;
|
bool m_bHasClientTickedOnce;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PlayerConnection(MinecraftServer *server, Connection *connection, shared_ptr<ServerPlayer> player);
|
PlayerConnection(MinecraftServer *server, Connection *connection, std::shared_ptr<ServerPlayer> player);
|
||||||
~PlayerConnection();
|
~PlayerConnection();
|
||||||
void tick();
|
void tick();
|
||||||
void disconnect(DisconnectPacket::eDisconnectReason reason);
|
void disconnect(DisconnectPacket::eDisconnectReason reason);
|
||||||
@@ -50,78 +50,78 @@ private:
|
|||||||
bool synched;
|
bool synched;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual void handlePlayerInput(shared_ptr<PlayerInputPacket> packet);
|
virtual void handlePlayerInput(std::shared_ptr<PlayerInputPacket> packet);
|
||||||
virtual void handleMovePlayer(shared_ptr<MovePlayerPacket> packet);
|
virtual void handleMovePlayer(std::shared_ptr<MovePlayerPacket> packet);
|
||||||
void teleport(double x, double y, double z, float yRot, float xRot, bool sendPacket = true); // 4J Added sendPacket param
|
void teleport(double x, double y, double z, float yRot, float xRot, bool sendPacket = true); // 4J Added sendPacket param
|
||||||
virtual void handlePlayerAction(shared_ptr<PlayerActionPacket> packet);
|
virtual void handlePlayerAction(std::shared_ptr<PlayerActionPacket> packet);
|
||||||
virtual void handleUseItem(shared_ptr<UseItemPacket> packet);
|
virtual void handleUseItem(std::shared_ptr<UseItemPacket> packet);
|
||||||
virtual void onDisconnect(DisconnectPacket::eDisconnectReason reason, void *reasonObjects);
|
virtual void onDisconnect(DisconnectPacket::eDisconnectReason reason, void *reasonObjects);
|
||||||
virtual void onUnhandledPacket(shared_ptr<Packet> packet);
|
virtual void onUnhandledPacket(std::shared_ptr<Packet> packet);
|
||||||
void send(shared_ptr<Packet> packet);
|
void send(std::shared_ptr<Packet> packet);
|
||||||
void queueSend(shared_ptr<Packet> packet); // 4J Added
|
void queueSend(std::shared_ptr<Packet> packet); // 4J Added
|
||||||
virtual void handleSetCarriedItem(shared_ptr<SetCarriedItemPacket> packet);
|
virtual void handleSetCarriedItem(std::shared_ptr<SetCarriedItemPacket> packet);
|
||||||
virtual void handleChat(shared_ptr<ChatPacket> packet);
|
virtual void handleChat(std::shared_ptr<ChatPacket> packet);
|
||||||
private:
|
private:
|
||||||
void handleCommand(const wstring& message);
|
void handleCommand(const std::wstring& message);
|
||||||
public:
|
public:
|
||||||
virtual void handleAnimate(shared_ptr<AnimatePacket> packet);
|
virtual void handleAnimate(std::shared_ptr<AnimatePacket> packet);
|
||||||
virtual void handlePlayerCommand(shared_ptr<PlayerCommandPacket> packet);
|
virtual void handlePlayerCommand(std::shared_ptr<PlayerCommandPacket> packet);
|
||||||
virtual void handleDisconnect(shared_ptr<DisconnectPacket> packet);
|
virtual void handleDisconnect(std::shared_ptr<DisconnectPacket> packet);
|
||||||
int countDelayedPackets();
|
int countDelayedPackets();
|
||||||
virtual void info(const wstring& string);
|
virtual void info(const std::wstring& string);
|
||||||
virtual void warn(const wstring& string);
|
virtual void warn(const std::wstring& string);
|
||||||
virtual wstring getConsoleName();
|
virtual std::wstring getConsoleName();
|
||||||
virtual void handleInteract(shared_ptr<InteractPacket> packet);
|
virtual void handleInteract(std::shared_ptr<InteractPacket> packet);
|
||||||
bool canHandleAsyncPackets();
|
bool canHandleAsyncPackets();
|
||||||
virtual void handleClientCommand(shared_ptr<ClientCommandPacket> packet);
|
virtual void handleClientCommand(std::shared_ptr<ClientCommandPacket> packet);
|
||||||
virtual void handleRespawn(shared_ptr<RespawnPacket> packet);
|
virtual void handleRespawn(std::shared_ptr<RespawnPacket> packet);
|
||||||
virtual void handleContainerClose(shared_ptr<ContainerClosePacket> packet);
|
virtual void handleContainerClose(std::shared_ptr<ContainerClosePacket> packet);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
unordered_map<int, short, IntKeyHash, IntKeyEq> expectedAcks;
|
std::unordered_map<int, short, IntKeyHash, IntKeyEq> expectedAcks;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// 4J Stu - Handlers only valid in debug mode
|
// 4J Stu - Handlers only valid in debug mode
|
||||||
#ifndef _CONTENT_PACKAGE
|
#ifndef _CONTENT_PACKAGE
|
||||||
virtual void handleContainerSetSlot(shared_ptr<ContainerSetSlotPacket> packet);
|
virtual void handleContainerSetSlot(std::shared_ptr<ContainerSetSlotPacket> packet);
|
||||||
#endif
|
#endif
|
||||||
virtual void handleContainerClick(shared_ptr<ContainerClickPacket> packet);
|
virtual void handleContainerClick(std::shared_ptr<ContainerClickPacket> packet);
|
||||||
virtual void handleContainerButtonClick(shared_ptr<ContainerButtonClickPacket> packet);
|
virtual void handleContainerButtonClick(std::shared_ptr<ContainerButtonClickPacket> packet);
|
||||||
virtual void handleSetCreativeModeSlot(shared_ptr<SetCreativeModeSlotPacket> packet);
|
virtual void handleSetCreativeModeSlot(std::shared_ptr<SetCreativeModeSlotPacket> packet);
|
||||||
virtual void handleContainerAck(shared_ptr<ContainerAckPacket> packet);
|
virtual void handleContainerAck(std::shared_ptr<ContainerAckPacket> packet);
|
||||||
virtual void handleSignUpdate(shared_ptr<SignUpdatePacket> packet);
|
virtual void handleSignUpdate(std::shared_ptr<SignUpdatePacket> packet);
|
||||||
virtual void handleKeepAlive(shared_ptr<KeepAlivePacket> packet);
|
virtual void handleKeepAlive(std::shared_ptr<KeepAlivePacket> packet);
|
||||||
virtual void handlePlayerInfo(shared_ptr<PlayerInfoPacket> packet); // 4J Added
|
virtual void handlePlayerInfo(std::shared_ptr<PlayerInfoPacket> packet); // 4J Added
|
||||||
virtual bool isServerPacketListener();
|
virtual bool isServerPacketListener();
|
||||||
virtual void handlePlayerAbilities(shared_ptr<PlayerAbilitiesPacket> playerAbilitiesPacket);
|
virtual void handlePlayerAbilities(std::shared_ptr<PlayerAbilitiesPacket> playerAbilitiesPacket);
|
||||||
virtual void handleCustomPayload(shared_ptr<CustomPayloadPacket> customPayloadPacket);
|
virtual void handleCustomPayload(std::shared_ptr<CustomPayloadPacket> customPayloadPacket);
|
||||||
|
|
||||||
// 4J Added
|
// 4J Added
|
||||||
virtual void handleCraftItem(shared_ptr<CraftItemPacket> packet);
|
virtual void handleCraftItem(std::shared_ptr<CraftItemPacket> packet);
|
||||||
virtual void handleTradeItem(shared_ptr<TradeItemPacket> packet);
|
virtual void handleTradeItem(std::shared_ptr<TradeItemPacket> packet);
|
||||||
virtual void handleDebugOptions(shared_ptr<DebugOptionsPacket> packet);
|
virtual void handleDebugOptions(std::shared_ptr<DebugOptionsPacket> packet);
|
||||||
virtual void handleTexture(shared_ptr<TexturePacket> packet);
|
virtual void handleTexture(std::shared_ptr<TexturePacket> packet);
|
||||||
virtual void handleTextureAndGeometry(shared_ptr<TextureAndGeometryPacket> packet);
|
virtual void handleTextureAndGeometry(std::shared_ptr<TextureAndGeometryPacket> packet);
|
||||||
virtual void handleTextureChange(shared_ptr<TextureChangePacket> packet);
|
virtual void handleTextureChange(std::shared_ptr<TextureChangePacket> packet);
|
||||||
virtual void handleTextureAndGeometryChange(shared_ptr<TextureAndGeometryChangePacket> packet);
|
virtual void handleTextureAndGeometryChange(std::shared_ptr<TextureAndGeometryChangePacket> packet);
|
||||||
virtual void handleServerSettingsChanged(shared_ptr<ServerSettingsChangedPacket> packet);
|
virtual void handleServerSettingsChanged(std::shared_ptr<ServerSettingsChangedPacket> packet);
|
||||||
virtual void handleKickPlayer(shared_ptr<KickPlayerPacket> packet);
|
virtual void handleKickPlayer(std::shared_ptr<KickPlayerPacket> packet);
|
||||||
virtual void handleGameCommand(shared_ptr<GameCommandPacket> packet);
|
virtual void handleGameCommand(std::shared_ptr<GameCommandPacket> packet);
|
||||||
|
|
||||||
INetworkPlayer *getNetworkPlayer();
|
INetworkPlayer *getNetworkPlayer();
|
||||||
bool isLocal();
|
bool isLocal();
|
||||||
bool isGuest();
|
bool isGuest();
|
||||||
|
|
||||||
// 4J Added as we need to set this from outside sometimes
|
// 4J Added as we need to set this from outside sometimes
|
||||||
void setPlayer(shared_ptr<ServerPlayer> player) { this->player = player; }
|
void setPlayer(std::shared_ptr<ServerPlayer> player) { this->player = player; }
|
||||||
shared_ptr<ServerPlayer> getPlayer() { return player; }
|
std::shared_ptr<ServerPlayer> getPlayer() { return player; }
|
||||||
|
|
||||||
// 4J Added to signal a disconnect from another thread
|
// 4J Added to signal a disconnect from another thread
|
||||||
void closeOnTick() { m_bCloseOnTick = true; }
|
void closeOnTick() { m_bCloseOnTick = true; }
|
||||||
|
|
||||||
// 4J Added so that we can send on textures that get received after this connection requested them
|
// 4J Added so that we can send on textures that get received after this connection requested them
|
||||||
void handleTextureReceived(const wstring &textureName);
|
void handleTextureReceived(const std::wstring &textureName);
|
||||||
void handleTextureAndGeometryReceived(const wstring &textureName);
|
void handleTextureAndGeometryReceived(const std::wstring &textureName);
|
||||||
|
|
||||||
void setShowOnMaps(bool bVal);
|
void setShowOnMaps(bool bVal);
|
||||||
|
|
||||||
@@ -133,7 +133,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
bool m_bCloseOnTick;
|
bool m_bCloseOnTick;
|
||||||
vector<wstring> m_texturesRequested;
|
std::vector<std::wstring> m_texturesRequested;
|
||||||
|
|
||||||
bool m_bWasKicked;
|
bool m_bWasKicked;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
class PlayerInfo
|
class PlayerInfo
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
wstring name;
|
std::wstring name;
|
||||||
int latency;
|
int latency;
|
||||||
|
|
||||||
PlayerInfo(const wstring &name)
|
PlayerInfo(const std::wstring &name)
|
||||||
{
|
{
|
||||||
this->name = name;
|
this->name = name;
|
||||||
latency = 0;
|
latency = 0;
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ PlayerList::~PlayerList()
|
|||||||
DeleteCriticalSection(&m_closePlayersCS);
|
DeleteCriticalSection(&m_closePlayersCS);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerList::placeNewPlayer(Connection *connection, shared_ptr<ServerPlayer> player, shared_ptr<LoginPacket> packet)
|
void PlayerList::placeNewPlayer(Connection *connection, std::shared_ptr<ServerPlayer> player, std::shared_ptr<LoginPacket> packet)
|
||||||
{
|
{
|
||||||
bool newPlayer = load(player);
|
bool newPlayer = load(player);
|
||||||
player->setLevel(server->getLevel(player->dimension));
|
player->setLevel(server->getLevel(player->dimension));
|
||||||
@@ -127,8 +127,8 @@ void PlayerList::placeNewPlayer(Connection *connection, shared_ptr<ServerPlayer>
|
|||||||
player->setCustomCape( packet->m_playerCapeId );
|
player->setCustomCape( packet->m_playerCapeId );
|
||||||
|
|
||||||
// 4J-JEV: Moved this here so we can send player-model texture and geometry data.
|
// 4J-JEV: Moved this here so we can send player-model texture and geometry data.
|
||||||
shared_ptr<PlayerConnection> playerConnection = shared_ptr<PlayerConnection>(new PlayerConnection(server, connection, player));
|
std::shared_ptr<PlayerConnection> playerConnection = std::shared_ptr<PlayerConnection>(new PlayerConnection(server, connection, player));
|
||||||
//player->connection = playerConnection; // Used to be assigned in PlayerConnection ctor but moved out so we can use shared_ptr
|
//player->connection = playerConnection; // Used to be assigned in PlayerConnection ctor but moved out so we can use std::shared_ptr
|
||||||
|
|
||||||
if(newPlayer)
|
if(newPlayer)
|
||||||
{
|
{
|
||||||
@@ -143,7 +143,7 @@ void PlayerList::placeNewPlayer(Connection *connection, shared_ptr<ServerPlayer>
|
|||||||
int centreZC = 0;
|
int centreZC = 0;
|
||||||
#endif
|
#endif
|
||||||
// 4J Added - Give every player a map the first time they join a server
|
// 4J Added - Give every player a map the first time they join a server
|
||||||
player->inventory->setItem( 9, shared_ptr<ItemInstance>( new ItemInstance(Item::map_Id, 1, level->getAuxValueForMap(player->getXuid(),0,centreXC, centreZC, mapScale ) ) ) );
|
player->inventory->setItem( 9, std::shared_ptr<ItemInstance>( new ItemInstance(Item::map_Id, 1, level->getAuxValueForMap(player->getXuid(),0,centreXC, centreZC, mapScale ) ) ) );
|
||||||
if(app.getGameRuleDefinitions() != NULL)
|
if(app.getGameRuleDefinitions() != NULL)
|
||||||
{
|
{
|
||||||
app.getGameRuleDefinitions()->postProcessPlayer(player);
|
app.getGameRuleDefinitions()->postProcessPlayer(player);
|
||||||
@@ -157,7 +157,7 @@ void PlayerList::placeNewPlayer(Connection *connection, shared_ptr<ServerPlayer>
|
|||||||
#ifndef _CONTENT_PACKAGE
|
#ifndef _CONTENT_PACKAGE
|
||||||
wprintf(L"Sending texture packet to get custom skin %ls from player %ls\n",player->customTextureUrl.c_str(), player->name.c_str());
|
wprintf(L"Sending texture packet to get custom skin %ls from player %ls\n",player->customTextureUrl.c_str(), player->name.c_str());
|
||||||
#endif
|
#endif
|
||||||
playerConnection->send(shared_ptr<TextureAndGeometryPacket>( new TextureAndGeometryPacket(player->customTextureUrl,NULL,0) ) );
|
playerConnection->send(std::shared_ptr<TextureAndGeometryPacket>( new TextureAndGeometryPacket(player->customTextureUrl,NULL,0) ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(!player->customTextureUrl.empty() && app.IsFileInMemoryTextures(player->customTextureUrl))
|
else if(!player->customTextureUrl.empty() && app.IsFileInMemoryTextures(player->customTextureUrl))
|
||||||
@@ -173,7 +173,7 @@ void PlayerList::placeNewPlayer(Connection *connection, shared_ptr<ServerPlayer>
|
|||||||
#ifndef _CONTENT_PACKAGE
|
#ifndef _CONTENT_PACKAGE
|
||||||
wprintf(L"Sending texture packet to get custom skin %ls from player %ls\n",player->customTextureUrl2.c_str(), player->name.c_str());
|
wprintf(L"Sending texture packet to get custom skin %ls from player %ls\n",player->customTextureUrl2.c_str(), player->name.c_str());
|
||||||
#endif
|
#endif
|
||||||
playerConnection->send(shared_ptr<TexturePacket>( new TexturePacket(player->customTextureUrl2,NULL,0) ) );
|
playerConnection->send(std::shared_ptr<TexturePacket>( new TexturePacket(player->customTextureUrl2,NULL,0) ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(!player->customTextureUrl2.empty() && app.IsFileInMemoryTextures(player->customTextureUrl2))
|
else if(!player->customTextureUrl2.empty() && app.IsFileInMemoryTextures(player->customTextureUrl2))
|
||||||
@@ -196,8 +196,8 @@ void PlayerList::placeNewPlayer(Connection *connection, shared_ptr<ServerPlayer>
|
|||||||
player->setPlayerGamePrivilege(Player::ePlayerGamePrivilege_CreativeMode,player->gameMode->getGameModeForPlayer()->getId() );
|
player->setPlayerGamePrivilege(Player::ePlayerGamePrivilege_CreativeMode,player->gameMode->getGameModeForPlayer()->getId() );
|
||||||
}
|
}
|
||||||
|
|
||||||
//shared_ptr<PlayerConnection> playerConnection = shared_ptr<PlayerConnection>(new PlayerConnection(server, connection, player));
|
//std::shared_ptr<PlayerConnection> playerConnection = std::shared_ptr<PlayerConnection>(new PlayerConnection(server, connection, player));
|
||||||
player->connection = playerConnection; // Used to be assigned in PlayerConnection ctor but moved out so we can use shared_ptr
|
player->connection = playerConnection; // Used to be assigned in PlayerConnection ctor but moved out so we can use std::shared_ptr
|
||||||
|
|
||||||
// 4J Added to store UGC settings
|
// 4J Added to store UGC settings
|
||||||
playerConnection->m_friendsOnlyUGC = packet->m_friendsOnlyUGC;
|
playerConnection->m_friendsOnlyUGC = packet->m_friendsOnlyUGC;
|
||||||
@@ -209,19 +209,19 @@ void PlayerList::placeNewPlayer(Connection *connection, shared_ptr<ServerPlayer>
|
|||||||
|
|
||||||
addPlayerToReceiving( player );
|
addPlayerToReceiving( player );
|
||||||
|
|
||||||
playerConnection->send( shared_ptr<LoginPacket>( new LoginPacket(L"", player->entityId, level->getLevelData()->getGenerator(), level->getSeed(), player->gameMode->getGameModeForPlayer()->getId(),
|
playerConnection->send( std::shared_ptr<LoginPacket>( new LoginPacket(L"", player->entityId, level->getLevelData()->getGenerator(), level->getSeed(), player->gameMode->getGameModeForPlayer()->getId(),
|
||||||
(uint8_t) level->dimension->id, (uint8_t) level->getMaxBuildHeight(), (uint8_t) getMaxPlayers(),
|
(uint8_t) level->dimension->id, (uint8_t) level->getMaxBuildHeight(), (uint8_t) getMaxPlayers(),
|
||||||
level->difficulty, TelemetryManager->GetMultiplayerInstanceID(), (BYTE)playerIndex, level->useNewSeaLevel(), player->getAllPlayerGamePrivileges(),
|
level->difficulty, TelemetryManager->GetMultiplayerInstanceID(), (BYTE)playerIndex, level->useNewSeaLevel(), player->getAllPlayerGamePrivileges(),
|
||||||
level->getLevelData()->getXZSize(), level->getLevelData()->getHellScale() ) ) );
|
level->getLevelData()->getXZSize(), level->getLevelData()->getHellScale() ) ) );
|
||||||
playerConnection->send( shared_ptr<SetSpawnPositionPacket>( new SetSpawnPositionPacket(spawnPos->x, spawnPos->y, spawnPos->z) ) );
|
playerConnection->send( std::shared_ptr<SetSpawnPositionPacket>( new SetSpawnPositionPacket(spawnPos->x, spawnPos->y, spawnPos->z) ) );
|
||||||
playerConnection->send( shared_ptr<PlayerAbilitiesPacket>( new PlayerAbilitiesPacket(&player->abilities)) );
|
playerConnection->send( std::shared_ptr<PlayerAbilitiesPacket>( new PlayerAbilitiesPacket(&player->abilities)) );
|
||||||
delete spawnPos;
|
delete spawnPos;
|
||||||
|
|
||||||
sendLevelInfo(player, level);
|
sendLevelInfo(player, level);
|
||||||
|
|
||||||
// 4J-PB - removed, since it needs to be localised in the language the client is in
|
// 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" + playerEntity->name + L" joined the game.") ) );
|
//server->players->broadcastAll( std::shared_ptr<ChatPacket>( new ChatPacket(L"§e" + playerEntity->name + L" joined the game.") ) );
|
||||||
broadcastAll( shared_ptr<ChatPacket>( new ChatPacket(player->name, ChatPacket::e_ChatPlayerJoinedGame) ) );
|
broadcastAll( std::shared_ptr<ChatPacket>( new ChatPacket(player->name, ChatPacket::e_ChatPlayerJoinedGame) ) );
|
||||||
|
|
||||||
MemSect(14);
|
MemSect(14);
|
||||||
add(player);
|
add(player);
|
||||||
@@ -231,13 +231,13 @@ void PlayerList::placeNewPlayer(Connection *connection, shared_ptr<ServerPlayer>
|
|||||||
playerConnection->teleport(player->x, player->y, player->z, player->yRot, player->xRot);
|
playerConnection->teleport(player->x, player->y, player->z, player->yRot, player->xRot);
|
||||||
|
|
||||||
server->getConnection()->addPlayerConnection(playerConnection);
|
server->getConnection()->addPlayerConnection(playerConnection);
|
||||||
playerConnection->send( shared_ptr<SetTimePacket>( new SetTimePacket(level->getTime()) ) );
|
playerConnection->send( std::shared_ptr<SetTimePacket>( new SetTimePacket(level->getTime()) ) );
|
||||||
|
|
||||||
AUTO_VAR(activeEffects, player->getActiveEffects());
|
AUTO_VAR(activeEffects, player->getActiveEffects());
|
||||||
for(AUTO_VAR(it, activeEffects->begin()); it != activeEffects->end(); ++it)
|
for(AUTO_VAR(it, activeEffects->begin()); it != activeEffects->end(); ++it)
|
||||||
{
|
{
|
||||||
MobEffectInstance *effect = *it;
|
MobEffectInstance *effect = *it;
|
||||||
playerConnection->send(shared_ptr<UpdateMobEffectPacket>( new UpdateMobEffectPacket(player->entityId, effect) ) );
|
playerConnection->send(std::shared_ptr<UpdateMobEffectPacket>( new UpdateMobEffectPacket(player->entityId, effect) ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
player->initMenu();
|
player->initMenu();
|
||||||
@@ -249,7 +249,7 @@ void PlayerList::placeNewPlayer(Connection *connection, shared_ptr<ServerPlayer>
|
|||||||
{
|
{
|
||||||
for(AUTO_VAR(it, players.begin()); it != players.end(); ++it)
|
for(AUTO_VAR(it, players.begin()); it != players.end(); ++it)
|
||||||
{
|
{
|
||||||
shared_ptr<ServerPlayer> servPlayer = *it;
|
std::shared_ptr<ServerPlayer> servPlayer = *it;
|
||||||
INetworkPlayer *checkPlayer = servPlayer->connection->getNetworkPlayer();
|
INetworkPlayer *checkPlayer = servPlayer->connection->getNetworkPlayer();
|
||||||
if(thisPlayer != checkPlayer && checkPlayer != NULL && thisPlayer->IsSameSystem( checkPlayer ) && servPlayer->wonGame )
|
if(thisPlayer != checkPlayer && checkPlayer != NULL && thisPlayer->IsSameSystem( checkPlayer ) && servPlayer->wonGame )
|
||||||
{
|
{
|
||||||
@@ -265,7 +265,7 @@ void PlayerList::setLevel(ServerLevelArray levels)
|
|||||||
playerIo = levels[0]->getLevelStorage()->getPlayerIO();
|
playerIo = levels[0]->getLevelStorage()->getPlayerIO();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerList::changeDimension(shared_ptr<ServerPlayer> player, ServerLevel *from)
|
void PlayerList::changeDimension(std::shared_ptr<ServerPlayer> player, ServerLevel *from)
|
||||||
{
|
{
|
||||||
ServerLevel *to = player->getLevel();
|
ServerLevel *to = player->getLevel();
|
||||||
|
|
||||||
@@ -281,12 +281,12 @@ int PlayerList::getMaxRange()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 4J Changed return val to bool to check if new player or loaded player
|
// 4J Changed return val to bool to check if new player or loaded player
|
||||||
bool PlayerList::load(shared_ptr<ServerPlayer> player)
|
bool PlayerList::load(std::shared_ptr<ServerPlayer> player)
|
||||||
{
|
{
|
||||||
return playerIo->load(player);
|
return playerIo->load(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerList::save(shared_ptr<ServerPlayer> player)
|
void PlayerList::save(std::shared_ptr<ServerPlayer> player)
|
||||||
{
|
{
|
||||||
playerIo->save(player);
|
playerIo->save(player);
|
||||||
}
|
}
|
||||||
@@ -295,7 +295,7 @@ void PlayerList::save(shared_ptr<ServerPlayer> player)
|
|||||||
// Add this function to take some of the code from the PlayerList::add function with the fixes
|
// Add this function to take some of the code from the PlayerList::add function with the fixes
|
||||||
// for checking spawn area, especially in the nether. These needed to be done in a different order from before
|
// for checking spawn area, especially in the nether. These needed to be done in a different order from before
|
||||||
// Fix for #13150 - When a player loads/joins a game after saving/leaving in the nether, sometimes they are spawned on top of the nether and cannot mine down
|
// Fix for #13150 - When a player loads/joins a game after saving/leaving in the nether, sometimes they are spawned on top of the nether and cannot mine down
|
||||||
void PlayerList::validatePlayerSpawnPosition(shared_ptr<ServerPlayer> player)
|
void PlayerList::validatePlayerSpawnPosition(std::shared_ptr<ServerPlayer> player)
|
||||||
{
|
{
|
||||||
// 4J Stu - Some adjustments to make sure the current players position is correct
|
// 4J Stu - Some adjustments to make sure the current players position is correct
|
||||||
// Make sure that the player is on the ground, and in the centre x/z of the current column
|
// Make sure that the player is on the ground, and in the centre x/z of the current column
|
||||||
@@ -359,12 +359,12 @@ void PlayerList::validatePlayerSpawnPosition(shared_ptr<ServerPlayer> player)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerList::add(shared_ptr<ServerPlayer> player)
|
void PlayerList::add(std::shared_ptr<ServerPlayer> player)
|
||||||
{
|
{
|
||||||
//broadcastAll(shared_ptr<PlayerInfoPacket>( new PlayerInfoPacket(player->name, true, 1000) ) );
|
//broadcastAll(std::shared_ptr<PlayerInfoPacket>( new PlayerInfoPacket(player->name, true, 1000) ) );
|
||||||
if( player->connection->getNetworkPlayer() )
|
if( player->connection->getNetworkPlayer() )
|
||||||
{
|
{
|
||||||
broadcastAll(shared_ptr<PlayerInfoPacket>( new PlayerInfoPacket( player ) ) );
|
broadcastAll(std::shared_ptr<PlayerInfoPacket>( new PlayerInfoPacket( player ) ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
players.push_back(player);
|
players.push_back(player);
|
||||||
@@ -386,36 +386,36 @@ void PlayerList::add(shared_ptr<ServerPlayer> player)
|
|||||||
|
|
||||||
for (int i = 0; i < players.size(); i++)
|
for (int i = 0; i < players.size(); i++)
|
||||||
{
|
{
|
||||||
shared_ptr<ServerPlayer> op = players.at(i);
|
std::shared_ptr<ServerPlayer> op = players.at(i);
|
||||||
//player->connection->send(shared_ptr<PlayerInfoPacket>( new PlayerInfoPacket(op->name, true, op->latency) ) );
|
//player->connection->send(std::shared_ptr<PlayerInfoPacket>( new PlayerInfoPacket(op->name, true, op->latency) ) );
|
||||||
if( op->connection->getNetworkPlayer() )
|
if( op->connection->getNetworkPlayer() )
|
||||||
{
|
{
|
||||||
player->connection->send(shared_ptr<PlayerInfoPacket>( new PlayerInfoPacket( op ) ) );
|
player->connection->send(std::shared_ptr<PlayerInfoPacket>( new PlayerInfoPacket( op ) ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(level->isAtLeastOnePlayerSleeping())
|
if(level->isAtLeastOnePlayerSleeping())
|
||||||
{
|
{
|
||||||
shared_ptr<ServerPlayer> firstSleepingPlayer = nullptr;
|
std::shared_ptr<ServerPlayer> firstSleepingPlayer = nullptr;
|
||||||
for (unsigned int i = 0; i < players.size(); i++)
|
for (unsigned int i = 0; i < players.size(); i++)
|
||||||
{
|
{
|
||||||
shared_ptr<ServerPlayer> thisPlayer = players[i];
|
std::shared_ptr<ServerPlayer> thisPlayer = players[i];
|
||||||
if(thisPlayer->isSleeping())
|
if(thisPlayer->isSleeping())
|
||||||
{
|
{
|
||||||
if(firstSleepingPlayer == NULL) firstSleepingPlayer = thisPlayer;
|
if(firstSleepingPlayer == NULL) firstSleepingPlayer = thisPlayer;
|
||||||
thisPlayer->connection->send(shared_ptr<ChatPacket>( new ChatPacket(thisPlayer->name, ChatPacket::e_ChatBedMeSleep)));
|
thisPlayer->connection->send(std::shared_ptr<ChatPacket>( new ChatPacket(thisPlayer->name, ChatPacket::e_ChatBedMeSleep)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
player->connection->send(shared_ptr<ChatPacket>( new ChatPacket(firstSleepingPlayer->name, ChatPacket::e_ChatBedPlayerSleep)));
|
player->connection->send(std::shared_ptr<ChatPacket>( new ChatPacket(firstSleepingPlayer->name, ChatPacket::e_ChatBedPlayerSleep)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerList::move(shared_ptr<ServerPlayer> player)
|
void PlayerList::move(std::shared_ptr<ServerPlayer> player)
|
||||||
{
|
{
|
||||||
player->getLevel()->getChunkMap()->move(player);
|
player->getLevel()->getChunkMap()->move(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerList::remove(shared_ptr<ServerPlayer> player)
|
void PlayerList::remove(std::shared_ptr<ServerPlayer> player)
|
||||||
{
|
{
|
||||||
save(player);
|
save(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
|
//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
|
||||||
@@ -428,7 +428,7 @@ void PlayerList::remove(shared_ptr<ServerPlayer> player)
|
|||||||
{
|
{
|
||||||
players.erase(it);
|
players.erase(it);
|
||||||
}
|
}
|
||||||
//broadcastAll(shared_ptr<PlayerInfoPacket>( new PlayerInfoPacket(player->name, false, 9999) ) );
|
//broadcastAll(std::shared_ptr<PlayerInfoPacket>( new PlayerInfoPacket(player->name, false, 9999) ) );
|
||||||
|
|
||||||
removePlayerFromReceiving(player);
|
removePlayerFromReceiving(player);
|
||||||
player->connection = nullptr; // Must remove reference to connection, or else there is a circular dependency
|
player->connection = nullptr; // Must remove reference to connection, or else there is a circular dependency
|
||||||
@@ -439,15 +439,15 @@ void PlayerList::remove(shared_ptr<ServerPlayer> player)
|
|||||||
saveAll(NULL,false);
|
saveAll(NULL,false);
|
||||||
}
|
}
|
||||||
|
|
||||||
shared_ptr<ServerPlayer> PlayerList::getPlayerForLogin(PendingConnection *pendingConnection, const wstring& userName, PlayerUID xuid, PlayerUID onlineXuid)
|
std::shared_ptr<ServerPlayer> PlayerList::getPlayerForLogin(PendingConnection *pendingConnection, const std::wstring& userName, PlayerUID xuid, PlayerUID onlineXuid)
|
||||||
{
|
{
|
||||||
if (players.size() >= maxPlayers)
|
if (players.size() >= maxPlayers)
|
||||||
{
|
{
|
||||||
pendingConnection->disconnect(DisconnectPacket::eDisconnect_ServerFull);
|
pendingConnection->disconnect(DisconnectPacket::eDisconnect_ServerFull);
|
||||||
return shared_ptr<ServerPlayer>();
|
return std::shared_ptr<ServerPlayer>();
|
||||||
}
|
}
|
||||||
|
|
||||||
shared_ptr<ServerPlayer> player = shared_ptr<ServerPlayer>(new ServerPlayer(server, server->getLevel(0), userName, new ServerPlayerGameMode(server->getLevel(0)) ));
|
std::shared_ptr<ServerPlayer> player = std::shared_ptr<ServerPlayer>(new ServerPlayer(server, server->getLevel(0), userName, new ServerPlayerGameMode(server->getLevel(0)) ));
|
||||||
player->gameMode->player = player; // 4J added as had to remove this assignment from ServerPlayer ctor
|
player->gameMode->player = player; // 4J added as had to remove this assignment from ServerPlayer ctor
|
||||||
player->setXuid( xuid ); // 4J Added
|
player->setXuid( xuid ); // 4J Added
|
||||||
player->setOnlineXuid( onlineXuid ); // 4J Added
|
player->setOnlineXuid( onlineXuid ); // 4J Added
|
||||||
@@ -469,7 +469,7 @@ shared_ptr<ServerPlayer> PlayerList::getPlayerForLogin(PendingConnection *pendin
|
|||||||
return player;
|
return player;
|
||||||
}
|
}
|
||||||
|
|
||||||
shared_ptr<ServerPlayer> PlayerList::respawn(shared_ptr<ServerPlayer> serverPlayer, int targetDimension, bool keepAllPlayerData)
|
std::shared_ptr<ServerPlayer> PlayerList::respawn(std::shared_ptr<ServerPlayer> serverPlayer, int targetDimension, bool keepAllPlayerData)
|
||||||
{
|
{
|
||||||
// How we handle the entity tracker depends on whether we are the primary player currently, and whether there will be any player in the same system in the same dimension once we finish respawning.
|
// How we handle the entity tracker depends on whether we are the primary player currently, and whether there will be any player in the same system in the same dimension once we finish respawning.
|
||||||
bool isPrimary = canReceiveAllPackets(serverPlayer); // Is this the primary player in its current dimension?
|
bool isPrimary = canReceiveAllPackets(serverPlayer); // Is this the primary player in its current dimension?
|
||||||
@@ -483,7 +483,7 @@ shared_ptr<ServerPlayer> PlayerList::respawn(shared_ptr<ServerPlayer> serverPlay
|
|||||||
|
|
||||||
for( unsigned int i = 0; i < players.size(); i++ )
|
for( unsigned int i = 0; i < players.size(); i++ )
|
||||||
{
|
{
|
||||||
shared_ptr<ServerPlayer> ep = players[i];
|
std::shared_ptr<ServerPlayer> ep = players[i];
|
||||||
if( ep == serverPlayer ) continue;
|
if( ep == serverPlayer ) continue;
|
||||||
if( ep->dimension != oldDimension ) continue;
|
if( ep->dimension != oldDimension ) continue;
|
||||||
|
|
||||||
@@ -540,7 +540,7 @@ shared_ptr<ServerPlayer> PlayerList::respawn(shared_ptr<ServerPlayer> serverPlay
|
|||||||
PlayerUID playerXuid = serverPlayer->getXuid();
|
PlayerUID playerXuid = serverPlayer->getXuid();
|
||||||
PlayerUID playerOnlineXuid = serverPlayer->getOnlineXuid();
|
PlayerUID playerOnlineXuid = serverPlayer->getOnlineXuid();
|
||||||
|
|
||||||
shared_ptr<ServerPlayer> player = shared_ptr<ServerPlayer>(new ServerPlayer(server, server->getLevel(serverPlayer->dimension), serverPlayer->name, new ServerPlayerGameMode(server->getLevel(serverPlayer->dimension))));
|
std::shared_ptr<ServerPlayer> player = std::shared_ptr<ServerPlayer>(new ServerPlayer(server, server->getLevel(serverPlayer->dimension), serverPlayer->name, new ServerPlayerGameMode(server->getLevel(serverPlayer->dimension))));
|
||||||
player->restoreFrom(serverPlayer, keepAllPlayerData);
|
player->restoreFrom(serverPlayer, keepAllPlayerData);
|
||||||
if (keepAllPlayerData)
|
if (keepAllPlayerData)
|
||||||
{
|
{
|
||||||
@@ -598,7 +598,7 @@ shared_ptr<ServerPlayer> PlayerList::respawn(shared_ptr<ServerPlayer> serverPlay
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
player->connection->send( shared_ptr<GameEventPacket>( new GameEventPacket(GameEventPacket::NO_RESPAWN_BED_AVAILABLE, 0) ) );
|
player->connection->send( std::shared_ptr<GameEventPacket>( new GameEventPacket(GameEventPacket::NO_RESPAWN_BED_AVAILABLE, 0) ) );
|
||||||
}
|
}
|
||||||
delete bedPosition;
|
delete bedPosition;
|
||||||
}
|
}
|
||||||
@@ -611,19 +611,19 @@ shared_ptr<ServerPlayer> PlayerList::respawn(shared_ptr<ServerPlayer> serverPlay
|
|||||||
player->setPos(player->x, player->y + 1, player->z);
|
player->setPos(player->x, player->y + 1, player->z);
|
||||||
}
|
}
|
||||||
|
|
||||||
player->connection->send( shared_ptr<RespawnPacket>( new RespawnPacket((char) player->dimension, player->level->getSeed(), player->level->getMaxBuildHeight(),
|
player->connection->send( std::shared_ptr<RespawnPacket>( new RespawnPacket((char) player->dimension, player->level->getSeed(), player->level->getMaxBuildHeight(),
|
||||||
player->gameMode->getGameModeForPlayer(), level->difficulty, level->getLevelData()->getGenerator(),
|
player->gameMode->getGameModeForPlayer(), level->difficulty, level->getLevelData()->getGenerator(),
|
||||||
player->level->useNewSeaLevel(), player->entityId, level->getLevelData()->getXZSize(), level->getLevelData()->getHellScale()) ) );
|
player->level->useNewSeaLevel(), player->entityId, level->getLevelData()->getXZSize(), level->getLevelData()->getHellScale()) ) );
|
||||||
player->connection->teleport(player->x, player->y, player->z, player->yRot, player->xRot);
|
player->connection->teleport(player->x, player->y, player->z, player->yRot, player->xRot);
|
||||||
|
|
||||||
if(keepAllPlayerData)
|
if(keepAllPlayerData)
|
||||||
{
|
{
|
||||||
vector<MobEffectInstance *> *activeEffects = player->getActiveEffects();
|
std::vector<MobEffectInstance *> *activeEffects = player->getActiveEffects();
|
||||||
for(AUTO_VAR(it, activeEffects->begin()); it != activeEffects->end(); ++it)
|
for(AUTO_VAR(it, activeEffects->begin()); it != activeEffects->end(); ++it)
|
||||||
{
|
{
|
||||||
MobEffectInstance *effect = *it;
|
MobEffectInstance *effect = *it;
|
||||||
|
|
||||||
player->connection->send(shared_ptr<UpdateMobEffectPacket>( new UpdateMobEffectPacket(player->entityId, effect) ) );
|
player->connection->send(std::shared_ptr<UpdateMobEffectPacket>( new UpdateMobEffectPacket(player->entityId, effect) ) );
|
||||||
}
|
}
|
||||||
delete activeEffects;
|
delete activeEffects;
|
||||||
player->getEntityData()->markDirty(Mob::DATA_EFFECT_COLOR_ID);
|
player->getEntityData()->markDirty(Mob::DATA_EFFECT_COLOR_ID);
|
||||||
@@ -654,7 +654,7 @@ shared_ptr<ServerPlayer> PlayerList::respawn(shared_ptr<ServerPlayer> serverPlay
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerList::toggleDimension(shared_ptr<ServerPlayer> player, int targetDimension)
|
void PlayerList::toggleDimension(std::shared_ptr<ServerPlayer> player, int targetDimension)
|
||||||
{
|
{
|
||||||
int lastDimension = player->dimension;
|
int lastDimension = player->dimension;
|
||||||
// How we handle the entity tracker depends on whether we are the primary player currently, and whether there will be any player in the same system in the same dimension once we finish respawning.
|
// How we handle the entity tracker depends on whether we are the primary player currently, and whether there will be any player in the same system in the same dimension once we finish respawning.
|
||||||
@@ -666,7 +666,7 @@ void PlayerList::toggleDimension(shared_ptr<ServerPlayer> player, int targetDime
|
|||||||
|
|
||||||
for( unsigned int i = 0; i < players.size(); i++ )
|
for( unsigned int i = 0; i < players.size(); i++ )
|
||||||
{
|
{
|
||||||
shared_ptr<ServerPlayer> ep = players[i];
|
std::shared_ptr<ServerPlayer> ep = players[i];
|
||||||
if( ep == player ) continue;
|
if( ep == player ) continue;
|
||||||
if( ep->dimension != lastDimension ) continue;
|
if( ep->dimension != lastDimension ) continue;
|
||||||
|
|
||||||
@@ -728,7 +728,7 @@ void PlayerList::toggleDimension(shared_ptr<ServerPlayer> player, int targetDime
|
|||||||
// 4J Stu Added so that we remove entities from the correct level, after the respawn packet we will be in the wrong level
|
// 4J Stu Added so that we remove entities from the correct level, after the respawn packet we will be in the wrong level
|
||||||
player->flushEntitiesToRemove();
|
player->flushEntitiesToRemove();
|
||||||
|
|
||||||
player->connection->send( shared_ptr<RespawnPacket>( new RespawnPacket((char) player->dimension, newLevel->getSeed(), newLevel->getMaxBuildHeight(),
|
player->connection->send( std::shared_ptr<RespawnPacket>( new RespawnPacket((char) player->dimension, newLevel->getSeed(), newLevel->getMaxBuildHeight(),
|
||||||
player->gameMode->getGameModeForPlayer(), newLevel->difficulty, newLevel->getLevelData()->getGenerator(),
|
player->gameMode->getGameModeForPlayer(), newLevel->difficulty, newLevel->getLevelData()->getGenerator(),
|
||||||
newLevel->useNewSeaLevel(), player->entityId, newLevel->getLevelData()->getXZSize(), newLevel->getLevelData()->getHellScale()) ) );
|
newLevel->useNewSeaLevel(), player->entityId, newLevel->getLevelData()->getXZSize(), newLevel->getLevelData()->getHellScale()) ) );
|
||||||
|
|
||||||
@@ -811,12 +811,12 @@ void PlayerList::toggleDimension(shared_ptr<ServerPlayer> player, int targetDime
|
|||||||
player->connection->teleport(player->x, player->y, player->z, player->yRot, player->xRot);
|
player->connection->teleport(player->x, player->y, player->z, player->yRot, player->xRot);
|
||||||
|
|
||||||
// 4J Stu - Fix for #64683 - Customer Encountered: TU7: Content: Gameplay: Potion effects are removed after using the Nether Portal
|
// 4J Stu - Fix for #64683 - Customer Encountered: TU7: Content: Gameplay: Potion effects are removed after using the Nether Portal
|
||||||
vector<MobEffectInstance *> *activeEffects = player->getActiveEffects();
|
std::vector<MobEffectInstance *> *activeEffects = player->getActiveEffects();
|
||||||
for(AUTO_VAR(it, activeEffects->begin()); it != activeEffects->end(); ++it)
|
for(AUTO_VAR(it, activeEffects->begin()); it != activeEffects->end(); ++it)
|
||||||
{
|
{
|
||||||
MobEffectInstance *effect = *it;
|
MobEffectInstance *effect = *it;
|
||||||
|
|
||||||
player->connection->send(shared_ptr<UpdateMobEffectPacket>( new UpdateMobEffectPacket(player->entityId, effect) ) );
|
player->connection->send(std::shared_ptr<UpdateMobEffectPacket>( new UpdateMobEffectPacket(player->entityId, effect) ) );
|
||||||
}
|
}
|
||||||
delete activeEffects;
|
delete activeEffects;
|
||||||
player->getEntityData()->markDirty(Mob::DATA_EFFECT_COLOR_ID);
|
player->getEntityData()->markDirty(Mob::DATA_EFFECT_COLOR_ID);
|
||||||
@@ -835,11 +835,11 @@ void PlayerList::tick()
|
|||||||
|
|
||||||
if (sendAllPlayerInfoIn < players.size())
|
if (sendAllPlayerInfoIn < players.size())
|
||||||
{
|
{
|
||||||
shared_ptr<ServerPlayer> op = players[sendAllPlayerInfoIn];
|
std::shared_ptr<ServerPlayer> op = players[sendAllPlayerInfoIn];
|
||||||
//broadcastAll(shared_ptr<PlayerInfoPacket>( new PlayerInfoPacket(op->name, true, op->latency) ) );
|
//broadcastAll(std::shared_ptr<PlayerInfoPacket>( new PlayerInfoPacket(op->name, true, op->latency) ) );
|
||||||
if( op->connection->getNetworkPlayer() )
|
if( op->connection->getNetworkPlayer() )
|
||||||
{
|
{
|
||||||
broadcastAll(shared_ptr<PlayerInfoPacket>( new PlayerInfoPacket( op ) ) );
|
broadcastAll(std::shared_ptr<PlayerInfoPacket>( new PlayerInfoPacket( op ) ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -849,11 +849,11 @@ void PlayerList::tick()
|
|||||||
BYTE smallId = m_smallIdsToClose.front();
|
BYTE smallId = m_smallIdsToClose.front();
|
||||||
m_smallIdsToClose.pop_front();
|
m_smallIdsToClose.pop_front();
|
||||||
|
|
||||||
shared_ptr<ServerPlayer> player = nullptr;
|
std::shared_ptr<ServerPlayer> player = nullptr;
|
||||||
|
|
||||||
for(unsigned int i = 0; i < players.size(); i++)
|
for(unsigned int i = 0; i < players.size(); i++)
|
||||||
{
|
{
|
||||||
shared_ptr<ServerPlayer> p = players.at(i);
|
std::shared_ptr<ServerPlayer> p = players.at(i);
|
||||||
// 4J Stu - May be being a bit overprotective with all the NULL checks, but adding late in TU7 so want to be safe
|
// 4J Stu - May be being a bit overprotective with all the NULL checks, but adding late in TU7 so want to be safe
|
||||||
if (p != NULL && p->connection != NULL && p->connection->connection != NULL && p->connection->connection->getSocket() != NULL && p->connection->connection->getSocket()->getSmallId() == smallId )
|
if (p != NULL && p->connection != NULL && p->connection->connection != NULL && p->connection->connection->getSocket() != NULL && p->connection->connection->getSocket()->getSmallId() == smallId )
|
||||||
{
|
{
|
||||||
@@ -882,11 +882,11 @@ void PlayerList::tick()
|
|||||||
//#ifdef _XBOX
|
//#ifdef _XBOX
|
||||||
PlayerUID xuid = selectedPlayer->GetUID();
|
PlayerUID xuid = selectedPlayer->GetUID();
|
||||||
// Kick this player from the game
|
// Kick this player from the game
|
||||||
shared_ptr<ServerPlayer> player = nullptr;
|
std::shared_ptr<ServerPlayer> player = nullptr;
|
||||||
|
|
||||||
for(unsigned int i = 0; i < players.size(); i++)
|
for(unsigned int i = 0; i < players.size(); i++)
|
||||||
{
|
{
|
||||||
shared_ptr<ServerPlayer> p = players.at(i);
|
std::shared_ptr<ServerPlayer> p = players.at(i);
|
||||||
PlayerUID playersXuid = p->getOnlineXuid();
|
PlayerUID playersXuid = p->getOnlineXuid();
|
||||||
if (p != NULL && ProfileManager.AreXUIDSEqual(playersXuid, xuid ) )
|
if (p != NULL && ProfileManager.AreXUIDSEqual(playersXuid, xuid ) )
|
||||||
{
|
{
|
||||||
@@ -901,7 +901,7 @@ void PlayerList::tick()
|
|||||||
// 4J Stu - If we have kicked a player, make sure that they have no privileges if they later try to join the world when trust players is off
|
// 4J Stu - If we have kicked a player, make sure that they have no privileges if they later try to join the world when trust players is off
|
||||||
player->enableAllPlayerPrivileges( false );
|
player->enableAllPlayerPrivileges( false );
|
||||||
player->connection->setWasKicked();
|
player->connection->setWasKicked();
|
||||||
player->connection->send( shared_ptr<DisconnectPacket>( new DisconnectPacket(DisconnectPacket::eDisconnect_Kicked) ));
|
player->connection->send( std::shared_ptr<DisconnectPacket>( new DisconnectPacket(DisconnectPacket::eDisconnect_Kicked) ));
|
||||||
}
|
}
|
||||||
//#endif
|
//#endif
|
||||||
}
|
}
|
||||||
@@ -914,10 +914,10 @@ void PlayerList::tick()
|
|||||||
{
|
{
|
||||||
for(unsigned int i = 0; i < receiveAllPlayers[dim].size(); ++i)
|
for(unsigned int i = 0; i < receiveAllPlayers[dim].size(); ++i)
|
||||||
{
|
{
|
||||||
shared_ptr<ServerPlayer> currentPlayer = receiveAllPlayers[dim][i];
|
std::shared_ptr<ServerPlayer> currentPlayer = receiveAllPlayers[dim][i];
|
||||||
if(currentPlayer->removed)
|
if(currentPlayer->removed)
|
||||||
{
|
{
|
||||||
shared_ptr<ServerPlayer> newPlayer = findAlivePlayerOnSystem(currentPlayer);
|
std::shared_ptr<ServerPlayer> newPlayer = findAlivePlayerOnSystem(currentPlayer);
|
||||||
if(newPlayer != NULL)
|
if(newPlayer != NULL)
|
||||||
{
|
{
|
||||||
receiveAllPlayers[dim][i] = newPlayer;
|
receiveAllPlayers[dim][i] = newPlayer;
|
||||||
@@ -939,27 +939,27 @@ void PlayerList::prioritiseTileChanges(int x, int y, int z, int dimension)
|
|||||||
server->getLevel(dimension)->getChunkMap()->prioritiseTileChanges(x, y, z);
|
server->getLevel(dimension)->getChunkMap()->prioritiseTileChanges(x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerList::broadcastAll(shared_ptr<Packet> packet)
|
void PlayerList::broadcastAll(std::shared_ptr<Packet> packet)
|
||||||
{
|
{
|
||||||
for (unsigned int i = 0; i < players.size(); i++)
|
for (unsigned int i = 0; i < players.size(); i++)
|
||||||
{
|
{
|
||||||
shared_ptr<ServerPlayer> player = players[i];
|
std::shared_ptr<ServerPlayer> player = players[i];
|
||||||
player->connection->send(packet);
|
player->connection->send(packet);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerList::broadcastAll(shared_ptr<Packet> packet, int dimension)
|
void PlayerList::broadcastAll(std::shared_ptr<Packet> packet, int dimension)
|
||||||
{
|
{
|
||||||
for (unsigned int i = 0; i < players.size(); i++)
|
for (unsigned int i = 0; i < players.size(); i++)
|
||||||
{
|
{
|
||||||
shared_ptr<ServerPlayer> player = players[i];
|
std::shared_ptr<ServerPlayer> player = players[i];
|
||||||
if (player->dimension == dimension) player->connection->send(packet);
|
if (player->dimension == dimension) player->connection->send(packet);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
wstring PlayerList::getPlayerNames()
|
std::wstring PlayerList::getPlayerNames()
|
||||||
{
|
{
|
||||||
wstring msg;
|
std::wstring msg;
|
||||||
for (unsigned int i = 0; i < players.size(); i++)
|
for (unsigned int i = 0; i < players.size(); i++)
|
||||||
{
|
{
|
||||||
if (i > 0) msg += L", ";
|
if (i > 0) msg += L", ";
|
||||||
@@ -968,17 +968,17 @@ wstring PlayerList::getPlayerNames()
|
|||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PlayerList::isWhiteListed(const wstring& name)
|
bool PlayerList::isWhiteListed(const std::wstring& name)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PlayerList::isOp(const wstring& name)
|
bool PlayerList::isOp(const std::wstring& name)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PlayerList::isOp(shared_ptr<ServerPlayer> player)
|
bool PlayerList::isOp(std::shared_ptr<ServerPlayer> player)
|
||||||
{
|
{
|
||||||
bool cheatsEnabled = app.GetGameHostOption(eGameHostOption_CheatsEnabled);
|
bool cheatsEnabled = app.GetGameHostOption(eGameHostOption_CheatsEnabled);
|
||||||
#ifdef _DEBUG_MENUS_ENABLED
|
#ifdef _DEBUG_MENUS_ENABLED
|
||||||
@@ -989,11 +989,11 @@ bool PlayerList::isOp(shared_ptr<ServerPlayer> player)
|
|||||||
return isOp;
|
return isOp;
|
||||||
}
|
}
|
||||||
|
|
||||||
shared_ptr<ServerPlayer> PlayerList::getPlayer(const wstring& name)
|
std::shared_ptr<ServerPlayer> PlayerList::getPlayer(const std::wstring& name)
|
||||||
{
|
{
|
||||||
for (unsigned int i = 0; i < players.size(); i++)
|
for (unsigned int i = 0; i < players.size(); i++)
|
||||||
{
|
{
|
||||||
shared_ptr<ServerPlayer> p = players[i];
|
std::shared_ptr<ServerPlayer> p = players[i];
|
||||||
if (p->name == name) // 4J - used to be case insensitive (using equalsIgnoreCase) - imagine we'll be shifting to XUIDs anyway
|
if (p->name == name) // 4J - used to be case insensitive (using equalsIgnoreCase) - imagine we'll be shifting to XUIDs anyway
|
||||||
{
|
{
|
||||||
return p;
|
return p;
|
||||||
@@ -1003,11 +1003,11 @@ shared_ptr<ServerPlayer> PlayerList::getPlayer(const wstring& name)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 4J Added
|
// 4J Added
|
||||||
shared_ptr<ServerPlayer> PlayerList::getPlayer(PlayerUID uid)
|
std::shared_ptr<ServerPlayer> PlayerList::getPlayer(PlayerUID uid)
|
||||||
{
|
{
|
||||||
for (unsigned int i = 0; i < players.size(); i++)
|
for (unsigned int i = 0; i < players.size(); i++)
|
||||||
{
|
{
|
||||||
shared_ptr<ServerPlayer> p = players[i];
|
std::shared_ptr<ServerPlayer> p = players[i];
|
||||||
if (p->getXuid() == uid || p->getOnlineXuid() == uid) // 4J - used to be case insensitive (using equalsIgnoreCase) - imagine we'll be shifting to XUIDs anyway
|
if (p->getXuid() == uid || p->getOnlineXuid() == uid) // 4J - used to be case insensitive (using equalsIgnoreCase) - imagine we'll be shifting to XUIDs anyway
|
||||||
{
|
{
|
||||||
return p;
|
return p;
|
||||||
@@ -1016,25 +1016,25 @@ shared_ptr<ServerPlayer> PlayerList::getPlayer(PlayerUID uid)
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerList::sendMessage(const wstring& name, const wstring& message)
|
void PlayerList::sendMessage(const std::wstring& name, const std::wstring& message)
|
||||||
{
|
{
|
||||||
shared_ptr<ServerPlayer> player = getPlayer(name);
|
std::shared_ptr<ServerPlayer> player = getPlayer(name);
|
||||||
if (player != NULL)
|
if (player != NULL)
|
||||||
{
|
{
|
||||||
player->connection->send( shared_ptr<ChatPacket>( new ChatPacket(message) ) );
|
player->connection->send( std::shared_ptr<ChatPacket>( new ChatPacket(message) ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerList::broadcast(double x, double y, double z, double range, int dimension, shared_ptr<Packet> packet)
|
void PlayerList::broadcast(double x, double y, double z, double range, int dimension, std::shared_ptr<Packet> packet)
|
||||||
{
|
{
|
||||||
broadcast(nullptr, x, y, z, range, dimension, packet);
|
broadcast(nullptr, x, y, z, range, dimension, packet);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerList::broadcast(shared_ptr<Player> except, double x, double y, double z, double range, int dimension, shared_ptr<Packet> packet)
|
void PlayerList::broadcast(std::shared_ptr<Player> except, double x, double y, double z, double range, int dimension, std::shared_ptr<Packet> packet)
|
||||||
{
|
{
|
||||||
// 4J - altered so that we don't send to the same machine more than once. Add the source player to the machines we have "sent" to as it doesn't need to go to that
|
// 4J - altered so that we don't send to the same machine more than once. Add the source player to the machines we have "sent" to as it doesn't need to go to that
|
||||||
// machine either
|
// machine either
|
||||||
vector< shared_ptr<ServerPlayer> > sentTo;
|
std::vector< std::shared_ptr<ServerPlayer> > sentTo;
|
||||||
if( except != NULL )
|
if( except != NULL )
|
||||||
{
|
{
|
||||||
sentTo.push_back(dynamic_pointer_cast<ServerPlayer>(except));
|
sentTo.push_back(dynamic_pointer_cast<ServerPlayer>(except));
|
||||||
@@ -1042,7 +1042,7 @@ void PlayerList::broadcast(shared_ptr<Player> except, double x, double y, double
|
|||||||
|
|
||||||
for (unsigned int i = 0; i < players.size(); i++)
|
for (unsigned int i = 0; i < players.size(); i++)
|
||||||
{
|
{
|
||||||
shared_ptr<ServerPlayer> p = players[i];
|
std::shared_ptr<ServerPlayer> p = players[i];
|
||||||
if (p == except) continue;
|
if (p == except) continue;
|
||||||
if (p->dimension != dimension) continue;
|
if (p->dimension != dimension) continue;
|
||||||
|
|
||||||
@@ -1059,7 +1059,7 @@ void PlayerList::broadcast(shared_ptr<Player> except, double x, double y, double
|
|||||||
{
|
{
|
||||||
for(unsigned int j = 0; j < sentTo.size(); j++ )
|
for(unsigned int j = 0; j < sentTo.size(); j++ )
|
||||||
{
|
{
|
||||||
shared_ptr<ServerPlayer> player2 = sentTo[j];
|
std::shared_ptr<ServerPlayer> player2 = sentTo[j];
|
||||||
INetworkPlayer *otherPlayer = player2->connection->getNetworkPlayer();
|
INetworkPlayer *otherPlayer = player2->connection->getNetworkPlayer();
|
||||||
if( otherPlayer != NULL && thisPlayer->IsSameSystem(otherPlayer) )
|
if( otherPlayer != NULL && thisPlayer->IsSameSystem(otherPlayer) )
|
||||||
{
|
{
|
||||||
@@ -1080,7 +1080,7 @@ void PlayerList::broadcast(shared_ptr<Player> except, double x, double y, double
|
|||||||
if (xd * xd + yd * yd + zd * zd < range * range)
|
if (xd * xd + yd * yd + zd * zd < range * range)
|
||||||
{
|
{
|
||||||
#if 0 // _DEBUG
|
#if 0 // _DEBUG
|
||||||
shared_ptr<LevelSoundPacket> SoundPacket= dynamic_pointer_cast<LevelSoundPacket>(packet);
|
std::shared_ptr<LevelSoundPacket> SoundPacket= dynamic_pointer_cast<LevelSoundPacket>(packet);
|
||||||
|
|
||||||
if(SoundPacket)
|
if(SoundPacket)
|
||||||
{
|
{
|
||||||
@@ -1097,12 +1097,12 @@ void PlayerList::broadcast(shared_ptr<Player> except, double x, double y, double
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerList::broadcastToAllOps(const wstring& message)
|
void PlayerList::broadcastToAllOps(const std::wstring& message)
|
||||||
{
|
{
|
||||||
shared_ptr<Packet> chatPacket = shared_ptr<ChatPacket>( new ChatPacket(message) );
|
std::shared_ptr<Packet> chatPacket = std::shared_ptr<ChatPacket>( new ChatPacket(message) );
|
||||||
for (unsigned int i = 0; i < players.size(); i++)
|
for (unsigned int i = 0; i < players.size(); i++)
|
||||||
{
|
{
|
||||||
shared_ptr<ServerPlayer> p = players[i];
|
std::shared_ptr<ServerPlayer> p = players[i];
|
||||||
if (isOp(p->name))
|
if (isOp(p->name))
|
||||||
{
|
{
|
||||||
p->connection->send(chatPacket);
|
p->connection->send(chatPacket);
|
||||||
@@ -1110,9 +1110,9 @@ void PlayerList::broadcastToAllOps(const wstring& message)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PlayerList::sendTo(const wstring& name, shared_ptr<Packet> packet)
|
bool PlayerList::sendTo(const std::wstring& name, std::shared_ptr<Packet> packet)
|
||||||
{
|
{
|
||||||
shared_ptr<ServerPlayer> player = getPlayer(name);
|
std::shared_ptr<ServerPlayer> player = getPlayer(name);
|
||||||
if (player != NULL)
|
if (player != NULL)
|
||||||
{
|
{
|
||||||
player->connection->send(packet);
|
player->connection->send(packet);
|
||||||
@@ -1142,11 +1142,11 @@ void PlayerList::saveAll(ProgressListener *progressListener, bool bDeleteGuestMa
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerList::whiteList(const wstring& playerName)
|
void PlayerList::whiteList(const std::wstring& playerName)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerList::blackList(const wstring& playerName)
|
void PlayerList::blackList(const std::wstring& playerName)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1154,28 +1154,28 @@ void PlayerList::reloadWhitelist()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerList::sendLevelInfo(shared_ptr<ServerPlayer> player, ServerLevel *level)
|
void PlayerList::sendLevelInfo(std::shared_ptr<ServerPlayer> player, ServerLevel *level)
|
||||||
{
|
{
|
||||||
player->connection->send( shared_ptr<SetTimePacket>( new SetTimePacket(level->getTime()) ) );
|
player->connection->send( std::shared_ptr<SetTimePacket>( new SetTimePacket(level->getTime()) ) );
|
||||||
if (level->isRaining())
|
if (level->isRaining())
|
||||||
{
|
{
|
||||||
player->connection->send( shared_ptr<GameEventPacket>( new GameEventPacket(GameEventPacket::START_RAINING, 0) ) );
|
player->connection->send( std::shared_ptr<GameEventPacket>( new GameEventPacket(GameEventPacket::START_RAINING, 0) ) );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// 4J Stu - Fix for #44836 - Customer Encountered: Out of Sync Weather [A-10]
|
// 4J Stu - Fix for #44836 - Customer Encountered: Out of Sync Weather [A-10]
|
||||||
// If it was raining when the player left the level, and is now not raining we need to make sure that state is updated
|
// If it was raining when the player left the level, and is now not raining we need to make sure that state is updated
|
||||||
player->connection->send( shared_ptr<GameEventPacket>( new GameEventPacket(GameEventPacket::STOP_RAINING, 0) ) );
|
player->connection->send( std::shared_ptr<GameEventPacket>( new GameEventPacket(GameEventPacket::STOP_RAINING, 0) ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
// send the stronghold position if there is one
|
// send the stronghold position if there is one
|
||||||
if((level->dimension->id==0) && level->getLevelData()->getHasStronghold())
|
if((level->dimension->id==0) && level->getLevelData()->getHasStronghold())
|
||||||
{
|
{
|
||||||
player->connection->send( shared_ptr<XZPacket>( new XZPacket(XZPacket::STRONGHOLD,level->getLevelData()->getXStronghold(),level->getLevelData()->getZStronghold()) ) );
|
player->connection->send( std::shared_ptr<XZPacket>( new XZPacket(XZPacket::STRONGHOLD,level->getLevelData()->getXStronghold(),level->getLevelData()->getZStronghold()) ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerList::sendAllPlayerInfo(shared_ptr<ServerPlayer> player)
|
void PlayerList::sendAllPlayerInfo(std::shared_ptr<ServerPlayer> player)
|
||||||
{
|
{
|
||||||
player->refreshContainer(player->inventoryMenu);
|
player->refreshContainer(player->inventoryMenu);
|
||||||
player->resetSentInfo();
|
player->resetSentInfo();
|
||||||
@@ -1218,7 +1218,7 @@ void PlayerList::setOverrideGameMode(GameType *gameMode)
|
|||||||
this->overrideGameMode = gameMode;
|
this->overrideGameMode = gameMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerList::updatePlayerGameMode(shared_ptr<ServerPlayer> newPlayer, shared_ptr<ServerPlayer> oldPlayer, Level *level)
|
void PlayerList::updatePlayerGameMode(std::shared_ptr<ServerPlayer> newPlayer, std::shared_ptr<ServerPlayer> oldPlayer, Level *level)
|
||||||
{
|
{
|
||||||
|
|
||||||
// reset the player's game mode (first pick from old, then copy level if
|
// reset the player's game mode (first pick from old, then copy level if
|
||||||
@@ -1239,7 +1239,7 @@ void PlayerList::setAllowCheatsForAllPlayers(bool allowCommands)
|
|||||||
this->allowCheatsForAllPlayers = allowCommands;
|
this->allowCheatsForAllPlayers = allowCommands;
|
||||||
}
|
}
|
||||||
|
|
||||||
shared_ptr<ServerPlayer> PlayerList::findAlivePlayerOnSystem(shared_ptr<ServerPlayer> player)
|
std::shared_ptr<ServerPlayer> PlayerList::findAlivePlayerOnSystem(std::shared_ptr<ServerPlayer> player)
|
||||||
{
|
{
|
||||||
int dimIndex, playerDim;
|
int dimIndex, playerDim;
|
||||||
dimIndex = playerDim = player->dimension;
|
dimIndex = playerDim = player->dimension;
|
||||||
@@ -1251,7 +1251,7 @@ shared_ptr<ServerPlayer> PlayerList::findAlivePlayerOnSystem(shared_ptr<ServerPl
|
|||||||
{
|
{
|
||||||
for(AUTO_VAR(itP, players.begin()); itP != players.end(); ++itP)
|
for(AUTO_VAR(itP, players.begin()); itP != players.end(); ++itP)
|
||||||
{
|
{
|
||||||
shared_ptr<ServerPlayer> newPlayer = *itP;
|
std::shared_ptr<ServerPlayer> newPlayer = *itP;
|
||||||
|
|
||||||
INetworkPlayer *otherPlayer = newPlayer->connection->getNetworkPlayer();
|
INetworkPlayer *otherPlayer = newPlayer->connection->getNetworkPlayer();
|
||||||
|
|
||||||
@@ -1270,7 +1270,7 @@ shared_ptr<ServerPlayer> PlayerList::findAlivePlayerOnSystem(shared_ptr<ServerPl
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerList::removePlayerFromReceiving(shared_ptr<ServerPlayer> player, bool usePlayerDimension /*= true*/, int dimension /*= 0*/)
|
void PlayerList::removePlayerFromReceiving(std::shared_ptr<ServerPlayer> player, bool usePlayerDimension /*= true*/, int dimension /*= 0*/)
|
||||||
{
|
{
|
||||||
int dimIndex, playerDim;
|
int dimIndex, playerDim;
|
||||||
dimIndex = playerDim = usePlayerDimension ? player->dimension : dimension;
|
dimIndex = playerDim = usePlayerDimension ? player->dimension : dimension;
|
||||||
@@ -1297,7 +1297,7 @@ void PlayerList::removePlayerFromReceiving(shared_ptr<ServerPlayer> player, bool
|
|||||||
{
|
{
|
||||||
for(AUTO_VAR(itP, players.begin()); itP != players.end(); ++itP)
|
for(AUTO_VAR(itP, players.begin()); itP != players.end(); ++itP)
|
||||||
{
|
{
|
||||||
shared_ptr<ServerPlayer> newPlayer = *itP;
|
std::shared_ptr<ServerPlayer> newPlayer = *itP;
|
||||||
|
|
||||||
INetworkPlayer *otherPlayer = newPlayer->connection->getNetworkPlayer();
|
INetworkPlayer *otherPlayer = newPlayer->connection->getNetworkPlayer();
|
||||||
|
|
||||||
@@ -1324,7 +1324,7 @@ void PlayerList::removePlayerFromReceiving(shared_ptr<ServerPlayer> player, bool
|
|||||||
// Re-check all active players and make sure they have someone on their system to receive all packets
|
// Re-check all active players and make sure they have someone on their system to receive all packets
|
||||||
for(AUTO_VAR(itP, players.begin()); itP != players.end(); ++itP)
|
for(AUTO_VAR(itP, players.begin()); itP != players.end(); ++itP)
|
||||||
{
|
{
|
||||||
shared_ptr<ServerPlayer> newPlayer = *itP;
|
std::shared_ptr<ServerPlayer> newPlayer = *itP;
|
||||||
INetworkPlayer *checkingPlayer = newPlayer->connection->getNetworkPlayer();
|
INetworkPlayer *checkingPlayer = newPlayer->connection->getNetworkPlayer();
|
||||||
|
|
||||||
if( checkingPlayer != NULL )
|
if( checkingPlayer != NULL )
|
||||||
@@ -1335,7 +1335,7 @@ void PlayerList::removePlayerFromReceiving(shared_ptr<ServerPlayer> player, bool
|
|||||||
bool foundPrimary = false;
|
bool foundPrimary = false;
|
||||||
for(AUTO_VAR(it, receiveAllPlayers[newPlayerDim].begin()); it != receiveAllPlayers[newPlayerDim].end(); ++it)
|
for(AUTO_VAR(it, receiveAllPlayers[newPlayerDim].begin()); it != receiveAllPlayers[newPlayerDim].end(); ++it)
|
||||||
{
|
{
|
||||||
shared_ptr<ServerPlayer> primaryPlayer = *it;
|
std::shared_ptr<ServerPlayer> primaryPlayer = *it;
|
||||||
INetworkPlayer *primPlayer = primaryPlayer->connection->getNetworkPlayer();
|
INetworkPlayer *primPlayer = primaryPlayer->connection->getNetworkPlayer();
|
||||||
if(primPlayer != NULL && checkingPlayer->IsSameSystem( primPlayer ) )
|
if(primPlayer != NULL && checkingPlayer->IsSameSystem( primPlayer ) )
|
||||||
{
|
{
|
||||||
@@ -1355,7 +1355,7 @@ void PlayerList::removePlayerFromReceiving(shared_ptr<ServerPlayer> player, bool
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerList::addPlayerToReceiving(shared_ptr<ServerPlayer> player)
|
void PlayerList::addPlayerToReceiving(std::shared_ptr<ServerPlayer> player)
|
||||||
{
|
{
|
||||||
int playerDim = 0;
|
int playerDim = 0;
|
||||||
if( player->dimension == -1 ) playerDim = 1;
|
if( player->dimension == -1 ) playerDim = 1;
|
||||||
@@ -1380,7 +1380,7 @@ void PlayerList::addPlayerToReceiving(shared_ptr<ServerPlayer> player)
|
|||||||
{
|
{
|
||||||
for(AUTO_VAR(it, receiveAllPlayers[playerDim].begin()); it != receiveAllPlayers[playerDim].end(); ++it)
|
for(AUTO_VAR(it, receiveAllPlayers[playerDim].begin()); it != receiveAllPlayers[playerDim].end(); ++it)
|
||||||
{
|
{
|
||||||
shared_ptr<ServerPlayer> oldPlayer = *it;
|
std::shared_ptr<ServerPlayer> oldPlayer = *it;
|
||||||
INetworkPlayer *checkingPlayer = oldPlayer->connection->getNetworkPlayer();
|
INetworkPlayer *checkingPlayer = oldPlayer->connection->getNetworkPlayer();
|
||||||
if(checkingPlayer != NULL && checkingPlayer->IsSameSystem( thisPlayer ) )
|
if(checkingPlayer != NULL && checkingPlayer->IsSameSystem( thisPlayer ) )
|
||||||
{
|
{
|
||||||
@@ -1399,14 +1399,14 @@ void PlayerList::addPlayerToReceiving(shared_ptr<ServerPlayer> player)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PlayerList::canReceiveAllPackets(shared_ptr<ServerPlayer> player)
|
bool PlayerList::canReceiveAllPackets(std::shared_ptr<ServerPlayer> player)
|
||||||
{
|
{
|
||||||
int playerDim = 0;
|
int playerDim = 0;
|
||||||
if( player->dimension == -1 ) playerDim = 1;
|
if( player->dimension == -1 ) playerDim = 1;
|
||||||
else if( player->dimension == 1) playerDim = 2;
|
else if( player->dimension == 1) playerDim = 2;
|
||||||
for(AUTO_VAR(it, receiveAllPlayers[playerDim].begin()); it != receiveAllPlayers[playerDim].end(); ++it)
|
for(AUTO_VAR(it, receiveAllPlayers[playerDim].begin()); it != receiveAllPlayers[playerDim].end(); ++it)
|
||||||
{
|
{
|
||||||
shared_ptr<ServerPlayer> newPlayer = *it;
|
std::shared_ptr<ServerPlayer> newPlayer = *it;
|
||||||
if(newPlayer == player)
|
if(newPlayer == player)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ class ProgressListener;
|
|||||||
class GameType;
|
class GameType;
|
||||||
class LoginPacket;
|
class LoginPacket;
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
class PlayerList
|
class PlayerList
|
||||||
{
|
{
|
||||||
@@ -22,14 +22,14 @@ private:
|
|||||||
static const int SEND_PLAYER_INFO_INTERVAL = 20 * 10; // 4J - brought forward from 1.2.3
|
static const int SEND_PLAYER_INFO_INTERVAL = 20 * 10; // 4J - brought forward from 1.2.3
|
||||||
// public static Logger logger = Logger.getLogger("Minecraft");
|
// public static Logger logger = Logger.getLogger("Minecraft");
|
||||||
public:
|
public:
|
||||||
vector<shared_ptr<ServerPlayer> > players;
|
std::vector<std::shared_ptr<ServerPlayer> > players;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
MinecraftServer *server;
|
MinecraftServer *server;
|
||||||
unsigned int maxPlayers;
|
unsigned int maxPlayers;
|
||||||
|
|
||||||
// 4J Added
|
// 4J Added
|
||||||
vector<PlayerUID> m_bannedXuids;
|
std::vector<PlayerUID> m_bannedXuids;
|
||||||
deque<BYTE> m_smallIdsToKick;
|
deque<BYTE> m_smallIdsToKick;
|
||||||
CRITICAL_SECTION m_kickPlayersCS;
|
CRITICAL_SECTION m_kickPlayersCS;
|
||||||
deque<BYTE> m_smallIdsToClose;
|
deque<BYTE> m_smallIdsToClose;
|
||||||
@@ -51,60 +51,60 @@ private:
|
|||||||
int sendAllPlayerInfoIn;
|
int sendAllPlayerInfoIn;
|
||||||
|
|
||||||
// 4J Added to maintain which players in which dimensions can receive all packet types
|
// 4J Added to maintain which players in which dimensions can receive all packet types
|
||||||
vector<shared_ptr<ServerPlayer> > receiveAllPlayers[3];
|
std::vector<std::shared_ptr<ServerPlayer> > receiveAllPlayers[3];
|
||||||
private:
|
private:
|
||||||
shared_ptr<ServerPlayer> findAlivePlayerOnSystem(shared_ptr<ServerPlayer> currentPlayer);
|
std::shared_ptr<ServerPlayer> findAlivePlayerOnSystem(std::shared_ptr<ServerPlayer> currentPlayer);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void removePlayerFromReceiving(shared_ptr<ServerPlayer> player, bool usePlayerDimension = true, int dimension = 0);
|
void removePlayerFromReceiving(std::shared_ptr<ServerPlayer> player, bool usePlayerDimension = true, int dimension = 0);
|
||||||
void addPlayerToReceiving(shared_ptr<ServerPlayer> player);
|
void addPlayerToReceiving(std::shared_ptr<ServerPlayer> player);
|
||||||
bool canReceiveAllPackets(shared_ptr<ServerPlayer> player);
|
bool canReceiveAllPackets(std::shared_ptr<ServerPlayer> player);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PlayerList(MinecraftServer *server);
|
PlayerList(MinecraftServer *server);
|
||||||
~PlayerList();
|
~PlayerList();
|
||||||
void placeNewPlayer(Connection *connection, shared_ptr<ServerPlayer> player, shared_ptr<LoginPacket> packet);
|
void placeNewPlayer(Connection *connection, std::shared_ptr<ServerPlayer> player, std::shared_ptr<LoginPacket> packet);
|
||||||
void setLevel(ServerLevelArray levels);
|
void setLevel(ServerLevelArray levels);
|
||||||
void changeDimension(shared_ptr<ServerPlayer> player, ServerLevel *from);
|
void changeDimension(std::shared_ptr<ServerPlayer> player, ServerLevel *from);
|
||||||
int getMaxRange();
|
int getMaxRange();
|
||||||
bool load(shared_ptr<ServerPlayer> player); // 4J Changed return val to bool to check if new player or loaded player
|
bool load(std::shared_ptr<ServerPlayer> player); // 4J Changed return val to bool to check if new player or loaded player
|
||||||
protected:
|
protected:
|
||||||
void save(shared_ptr<ServerPlayer> player);
|
void save(std::shared_ptr<ServerPlayer> player);
|
||||||
public:
|
public:
|
||||||
void validatePlayerSpawnPosition(shared_ptr<ServerPlayer> player); // 4J Added
|
void validatePlayerSpawnPosition(std::shared_ptr<ServerPlayer> player); // 4J Added
|
||||||
void add(shared_ptr<ServerPlayer> player);
|
void add(std::shared_ptr<ServerPlayer> player);
|
||||||
void move(shared_ptr<ServerPlayer> player);
|
void move(std::shared_ptr<ServerPlayer> player);
|
||||||
void remove(shared_ptr<ServerPlayer> player);
|
void remove(std::shared_ptr<ServerPlayer> player);
|
||||||
shared_ptr<ServerPlayer> getPlayerForLogin(PendingConnection *pendingConnection, const wstring& userName, PlayerUID xuid, PlayerUID OnlineXuid);
|
std::shared_ptr<ServerPlayer> getPlayerForLogin(PendingConnection *pendingConnection, const std::wstring& userName, PlayerUID xuid, PlayerUID OnlineXuid);
|
||||||
shared_ptr<ServerPlayer> respawn(shared_ptr<ServerPlayer> serverPlayer, int targetDimension, bool keepAllPlayerData);
|
std::shared_ptr<ServerPlayer> respawn(std::shared_ptr<ServerPlayer> serverPlayer, int targetDimension, bool keepAllPlayerData);
|
||||||
void toggleDimension(shared_ptr<ServerPlayer> player, int targetDimension);
|
void toggleDimension(std::shared_ptr<ServerPlayer> player, int targetDimension);
|
||||||
void tick();
|
void tick();
|
||||||
bool isTrackingTile(int x, int y, int z, int dimension); // 4J added
|
bool isTrackingTile(int x, int y, int z, int dimension); // 4J added
|
||||||
void prioritiseTileChanges(int x, int y, int z, int dimension); // 4J added
|
void prioritiseTileChanges(int x, int y, int z, int dimension); // 4J added
|
||||||
void broadcastAll(shared_ptr<Packet> packet);
|
void broadcastAll(std::shared_ptr<Packet> packet);
|
||||||
void broadcastAll(shared_ptr<Packet> packet, int dimension);
|
void broadcastAll(std::shared_ptr<Packet> packet, int dimension);
|
||||||
|
|
||||||
wstring getPlayerNames();
|
std::wstring getPlayerNames();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
bool isWhiteListed(const wstring& name);
|
bool isWhiteListed(const std::wstring& name);
|
||||||
bool isOp(const wstring& name);
|
bool isOp(const std::wstring& name);
|
||||||
bool isOp(shared_ptr<ServerPlayer> player); // 4J Added
|
bool isOp(std::shared_ptr<ServerPlayer> player); // 4J Added
|
||||||
shared_ptr<ServerPlayer> getPlayer(const wstring& name);
|
std::shared_ptr<ServerPlayer> getPlayer(const std::wstring& name);
|
||||||
shared_ptr<ServerPlayer> getPlayer(PlayerUID uid);
|
std::shared_ptr<ServerPlayer> getPlayer(PlayerUID uid);
|
||||||
void sendMessage(const wstring& name, const wstring& message);
|
void sendMessage(const std::wstring& name, const std::wstring& message);
|
||||||
void broadcast(double x, double y, double z, double range, int dimension, shared_ptr<Packet> packet);
|
void broadcast(double x, double y, double z, double range, int dimension, std::shared_ptr<Packet> packet);
|
||||||
void broadcast(shared_ptr<Player> except, double x, double y, double z, double range, int dimension, shared_ptr<Packet> packet);
|
void broadcast(std::shared_ptr<Player> except, double x, double y, double z, double range, int dimension, std::shared_ptr<Packet> packet);
|
||||||
void broadcastToAllOps(const wstring& message);
|
void broadcastToAllOps(const std::wstring& message);
|
||||||
bool sendTo(const wstring& name, shared_ptr<Packet> packet);
|
bool sendTo(const std::wstring& name, std::shared_ptr<Packet> packet);
|
||||||
// 4J Added ProgressListener *progressListener param and bDeleteGuestMaps param
|
// 4J Added ProgressListener *progressListener param and bDeleteGuestMaps param
|
||||||
void saveAll(ProgressListener *progressListener, bool bDeleteGuestMaps = false);
|
void saveAll(ProgressListener *progressListener, bool bDeleteGuestMaps = false);
|
||||||
void whiteList(const wstring& playerName);
|
void whiteList(const std::wstring& playerName);
|
||||||
void blackList(const wstring& playerName);
|
void blackList(const std::wstring& playerName);
|
||||||
// Set<String> getWhiteList(); / 4J removed
|
// Set<String> getWhiteList(); / 4J removed
|
||||||
void reloadWhitelist();
|
void reloadWhitelist();
|
||||||
void sendLevelInfo(shared_ptr<ServerPlayer> player, ServerLevel *level);
|
void sendLevelInfo(std::shared_ptr<ServerPlayer> player, ServerLevel *level);
|
||||||
void sendAllPlayerInfo(shared_ptr<ServerPlayer> player);
|
void sendAllPlayerInfo(std::shared_ptr<ServerPlayer> player);
|
||||||
int getPlayerCount();
|
int getPlayerCount();
|
||||||
int getPlayerCount(ServerLevel *level); // 4J Added
|
int getPlayerCount(ServerLevel *level); // 4J Added
|
||||||
int getMaxPlayers();
|
int getMaxPlayers();
|
||||||
@@ -113,7 +113,7 @@ public:
|
|||||||
void setOverrideGameMode(GameType *gameMode);
|
void setOverrideGameMode(GameType *gameMode);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void updatePlayerGameMode(shared_ptr<ServerPlayer> newPlayer, shared_ptr<ServerPlayer> oldPlayer, Level *level);
|
void updatePlayerGameMode(std::shared_ptr<ServerPlayer> newPlayer, std::shared_ptr<ServerPlayer> oldPlayer, Level *level);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void setAllowCheatsForAllPlayers(bool allowCommands);
|
void setAllowCheatsForAllPlayers(bool allowCommands);
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ bool ServerChunkCache::hasChunk(int x, int z)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
vector<LevelChunk *> *ServerChunkCache::getLoadedChunkList()
|
std::vector<LevelChunk *> *ServerChunkCache::getLoadedChunkList()
|
||||||
{
|
{
|
||||||
return &m_loadedChunkList;
|
return &m_loadedChunkList;
|
||||||
}
|
}
|
||||||
@@ -608,7 +608,7 @@ bool ServerChunkCache::save(bool force, ProgressListener *progressListener)
|
|||||||
// Created a roughly sorted list to match the order that the files were created in McRegionChunkStorage::McRegionChunkStorage.
|
// Created a roughly sorted list to match the order that the files were created in McRegionChunkStorage::McRegionChunkStorage.
|
||||||
// This is to minimise the amount of data that needs to be moved round when creating a new level.
|
// This is to minimise the amount of data that needs to be moved round when creating a new level.
|
||||||
|
|
||||||
vector<LevelChunk *> sortedChunkList;
|
std::vector<LevelChunk *> sortedChunkList;
|
||||||
|
|
||||||
for( int i = 0; i < m_loadedChunkList.size(); i++ )
|
for( int i = 0; i < m_loadedChunkList.size(); i++ )
|
||||||
{
|
{
|
||||||
@@ -693,7 +693,7 @@ bool ServerChunkCache::save(bool force, ProgressListener *progressListener)
|
|||||||
// Created a roughly sorted list to match the order that the files were created in McRegionChunkStorage::McRegionChunkStorage.
|
// Created a roughly sorted list to match the order that the files were created in McRegionChunkStorage::McRegionChunkStorage.
|
||||||
// This is to minimise the amount of data that needs to be moved round when creating a new level.
|
// This is to minimise the amount of data that needs to be moved round when creating a new level.
|
||||||
|
|
||||||
vector<LevelChunk *> sortedChunkList;
|
std::vector<LevelChunk *> sortedChunkList;
|
||||||
|
|
||||||
for( int i = 0; i < m_loadedChunkList.size(); i++ )
|
for( int i = 0; i < m_loadedChunkList.size(); i++ )
|
||||||
{
|
{
|
||||||
@@ -897,17 +897,17 @@ bool ServerChunkCache::shouldSave()
|
|||||||
return !level->noSave;
|
return !level->noSave;
|
||||||
}
|
}
|
||||||
|
|
||||||
wstring ServerChunkCache::gatherStats()
|
std::wstring ServerChunkCache::gatherStats()
|
||||||
{
|
{
|
||||||
return L"ServerChunkCache: ";// + _toString<int>(loadedChunks.size()) + L" Drop: " + _toString<int>(toDrop.size());
|
return L"ServerChunkCache: ";// + _toString<int>(loadedChunks.size()) + L" Drop: " + _toString<int>(toDrop.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
vector<Biome::MobSpawnerData *> *ServerChunkCache::getMobsAt(MobCategory *mobCategory, int x, int y, int z)
|
std::vector<Biome::MobSpawnerData *> *ServerChunkCache::getMobsAt(MobCategory *mobCategory, int x, int y, int z)
|
||||||
{
|
{
|
||||||
return source->getMobsAt(mobCategory, x, y, z);
|
return source->getMobsAt(mobCategory, x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
TilePos *ServerChunkCache::findNearestMapFeature(Level *level, const wstring &featureName, int x, int y, int z)
|
TilePos *ServerChunkCache::findNearestMapFeature(Level *level, const std::wstring &featureName, int x, int y, int z)
|
||||||
{
|
{
|
||||||
return source->findNearestMapFeature(level, featureName, x, y, z);
|
return source->findNearestMapFeature(level, featureName, x, y, z);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,14 +5,14 @@
|
|||||||
#include "../../Minecraft.World/Util/JavaIntHash.h"
|
#include "../../Minecraft.World/Util/JavaIntHash.h"
|
||||||
#include "../../Minecraft.World/Level/RandomLevelSource.h"
|
#include "../../Minecraft.World/Level/RandomLevelSource.h"
|
||||||
#include "../../Minecraft.World/Util/C4JThread.h"
|
#include "../../Minecraft.World/Util/C4JThread.h"
|
||||||
using namespace std;
|
|
||||||
class ServerLevel;
|
class ServerLevel;
|
||||||
|
|
||||||
class ServerChunkCache : public ChunkSource
|
class ServerChunkCache : public ChunkSource
|
||||||
{
|
{
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// unordered_set<int,IntKeyHash, IntKeyEq> toDrop;
|
// std::unordered_set<int,IntKeyHash, IntKeyEq> toDrop;
|
||||||
private:
|
private:
|
||||||
LevelChunk *emptyChunk;
|
LevelChunk *emptyChunk;
|
||||||
ChunkSource *source;
|
ChunkSource *source;
|
||||||
@@ -21,7 +21,7 @@ public:
|
|||||||
bool autoCreate;
|
bool autoCreate;
|
||||||
private:
|
private:
|
||||||
LevelChunk **cache;
|
LevelChunk **cache;
|
||||||
vector<LevelChunk *> m_loadedChunkList;
|
std::vector<LevelChunk *> m_loadedChunkList;
|
||||||
ServerLevel *level;
|
ServerLevel *level;
|
||||||
|
|
||||||
#ifdef _LARGE_WORLDS
|
#ifdef _LARGE_WORLDS
|
||||||
@@ -39,7 +39,7 @@ public:
|
|||||||
ServerChunkCache(ServerLevel *level, ChunkStorage *storage, ChunkSource *source);
|
ServerChunkCache(ServerLevel *level, ChunkStorage *storage, ChunkSource *source);
|
||||||
virtual ~ServerChunkCache();
|
virtual ~ServerChunkCache();
|
||||||
virtual bool hasChunk(int x, int z);
|
virtual bool hasChunk(int x, int z);
|
||||||
vector<LevelChunk *> *getLoadedChunkList();
|
std::vector<LevelChunk *> *getLoadedChunkList();
|
||||||
void drop(int x, int z);
|
void drop(int x, int z);
|
||||||
void dropAll();
|
void dropAll();
|
||||||
virtual LevelChunk *create(int x, int z);
|
virtual LevelChunk *create(int x, int z);
|
||||||
@@ -80,10 +80,10 @@ public:
|
|||||||
virtual bool save(bool force, ProgressListener *progressListener);
|
virtual bool save(bool force, ProgressListener *progressListener);
|
||||||
virtual bool tick();
|
virtual bool tick();
|
||||||
virtual bool shouldSave();
|
virtual bool shouldSave();
|
||||||
virtual wstring gatherStats();
|
virtual std::wstring gatherStats();
|
||||||
|
|
||||||
virtual vector<Biome::MobSpawnerData *> *getMobsAt(MobCategory *mobCategory, int x, int y, int z);
|
virtual std::vector<Biome::MobSpawnerData *> *getMobsAt(MobCategory *mobCategory, int x, int y, int z);
|
||||||
virtual TilePos *findNearestMapFeature(Level *level, const wstring &featureName, int x, int y, int z);
|
virtual TilePos *findNearestMapFeature(Level *level, const std::wstring &featureName, int x, int y, int z);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef struct _SaveThreadData
|
typedef struct _SaveThreadData
|
||||||
|
|||||||
@@ -52,13 +52,13 @@ ServerCommandDispatcher::ServerCommandDispatcher()
|
|||||||
Command::setLogger(this);
|
Command::setLogger(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerCommandDispatcher::logAdminCommand(shared_ptr<CommandSender> source, int type, ChatPacket::EChatPacketMessage messageType, const wstring& message, int customData, const wstring& additionalMessage)
|
void ServerCommandDispatcher::logAdminCommand(std::shared_ptr<CommandSender> source, int type, ChatPacket::EChatPacketMessage messageType, const std::wstring& message, int customData, const std::wstring& additionalMessage)
|
||||||
{
|
{
|
||||||
PlayerList *playerList = MinecraftServer::getInstance()->getPlayers();
|
PlayerList *playerList = MinecraftServer::getInstance()->getPlayers();
|
||||||
//for (Player player : MinecraftServer.getInstance().getPlayers().players)
|
//for (Player player : MinecraftServer.getInstance().getPlayers().players)
|
||||||
for(AUTO_VAR(it, playerList->players.begin()); it != playerList->players.end(); ++it)
|
for(AUTO_VAR(it, playerList->players.begin()); it != playerList->players.end(); ++it)
|
||||||
{
|
{
|
||||||
shared_ptr<ServerPlayer> player = *it;
|
std::shared_ptr<ServerPlayer> player = *it;
|
||||||
if (player != source && playerList->isOp(player))
|
if (player != source && playerList->isOp(player))
|
||||||
{
|
{
|
||||||
// TODO: Change chat packet to be able to send more bits of data
|
// TODO: Change chat packet to be able to send more bits of data
|
||||||
|
|||||||
@@ -7,5 +7,5 @@ class ServerCommandDispatcher : public CommandDispatcher, public AdminLogCommand
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ServerCommandDispatcher();
|
ServerCommandDispatcher();
|
||||||
void logAdminCommand(shared_ptr<CommandSender> source, int type, ChatPacket::EChatPacketMessage messageType, const wstring& message = L"", int customData = -1, const wstring& additionalMessage = L"");
|
void logAdminCommand(std::shared_ptr<CommandSender> source, int type, ChatPacket::EChatPacketMessage messageType, const std::wstring& message = L"", int customData = -1, const std::wstring& additionalMessage = L"");
|
||||||
};
|
};
|
||||||
@@ -26,16 +26,16 @@ ServerConnection::~ServerConnection()
|
|||||||
// 4J - added to handle incoming connections, to replace thread that original used to have
|
// 4J - added to handle incoming connections, to replace thread that original used to have
|
||||||
void ServerConnection::NewIncomingSocket(Socket *socket)
|
void ServerConnection::NewIncomingSocket(Socket *socket)
|
||||||
{
|
{
|
||||||
shared_ptr<PendingConnection> unconnectedClient = shared_ptr<PendingConnection>(new PendingConnection(server, socket, L"Connection #" + _toString<int>(connectionCounter++)));
|
std::shared_ptr<PendingConnection> unconnectedClient = std::shared_ptr<PendingConnection>(new PendingConnection(server, socket, L"Connection #" + _toString<int>(connectionCounter++)));
|
||||||
handleConnection(unconnectedClient);
|
handleConnection(unconnectedClient);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerConnection::addPlayerConnection(shared_ptr<PlayerConnection> uc)
|
void ServerConnection::addPlayerConnection(std::shared_ptr<PlayerConnection> uc)
|
||||||
{
|
{
|
||||||
players.push_back(uc);
|
players.push_back(uc);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerConnection::handleConnection(shared_ptr<PendingConnection> uc)
|
void ServerConnection::handleConnection(std::shared_ptr<PendingConnection> uc)
|
||||||
{
|
{
|
||||||
EnterCriticalSection(&pending_cs);
|
EnterCriticalSection(&pending_cs);
|
||||||
pending.push_back(uc);
|
pending.push_back(uc);
|
||||||
@@ -47,14 +47,14 @@ void ServerConnection::stop()
|
|||||||
EnterCriticalSection(&pending_cs);
|
EnterCriticalSection(&pending_cs);
|
||||||
for (unsigned int i = 0; i < pending.size(); i++)
|
for (unsigned int i = 0; i < pending.size(); i++)
|
||||||
{
|
{
|
||||||
shared_ptr<PendingConnection> uc = pending[i];
|
std::shared_ptr<PendingConnection> uc = pending[i];
|
||||||
uc->connection->close(DisconnectPacket::eDisconnect_Closed);
|
uc->connection->close(DisconnectPacket::eDisconnect_Closed);
|
||||||
}
|
}
|
||||||
LeaveCriticalSection(&pending_cs);
|
LeaveCriticalSection(&pending_cs);
|
||||||
|
|
||||||
for (unsigned int i = 0; i < players.size(); i++)
|
for (unsigned int i = 0; i < players.size(); i++)
|
||||||
{
|
{
|
||||||
shared_ptr<PlayerConnection> player = players[i];
|
std::shared_ptr<PlayerConnection> player = players[i];
|
||||||
player->connection->close(DisconnectPacket::eDisconnect_Closed);
|
player->connection->close(DisconnectPacket::eDisconnect_Closed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -64,12 +64,12 @@ void ServerConnection::tick()
|
|||||||
{
|
{
|
||||||
// MGH - changed this so that the the CS lock doesn't cover the tick (was causing a lockup when 2 players tried to join)
|
// MGH - changed this so that the the CS lock doesn't cover the tick (was causing a lockup when 2 players tried to join)
|
||||||
EnterCriticalSection(&pending_cs);
|
EnterCriticalSection(&pending_cs);
|
||||||
vector< shared_ptr<PendingConnection> > tempPending = pending;
|
std::vector< std::shared_ptr<PendingConnection> > tempPending = pending;
|
||||||
LeaveCriticalSection(&pending_cs);
|
LeaveCriticalSection(&pending_cs);
|
||||||
|
|
||||||
for (unsigned int i = 0; i < tempPending.size(); i++)
|
for (unsigned int i = 0; i < tempPending.size(); i++)
|
||||||
{
|
{
|
||||||
shared_ptr<PendingConnection> uc = tempPending[i];
|
std::shared_ptr<PendingConnection> uc = tempPending[i];
|
||||||
// try { // 4J - removed try/catch
|
// try { // 4J - removed try/catch
|
||||||
uc->tick();
|
uc->tick();
|
||||||
// } catch (Exception e) {
|
// } catch (Exception e) {
|
||||||
@@ -92,8 +92,8 @@ void ServerConnection::tick()
|
|||||||
|
|
||||||
for (unsigned int i = 0; i < players.size(); i++)
|
for (unsigned int i = 0; i < players.size(); i++)
|
||||||
{
|
{
|
||||||
shared_ptr<PlayerConnection> player = players[i];
|
std::shared_ptr<PlayerConnection> player = players[i];
|
||||||
shared_ptr<ServerPlayer> serverPlayer = player->getPlayer();
|
std::shared_ptr<ServerPlayer> serverPlayer = player->getPlayer();
|
||||||
if( serverPlayer )
|
if( serverPlayer )
|
||||||
{
|
{
|
||||||
serverPlayer->doChunkSendingTick(false);
|
serverPlayer->doChunkSendingTick(false);
|
||||||
@@ -114,7 +114,7 @@ void ServerConnection::tick()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ServerConnection::addPendingTextureRequest(const wstring &textureName)
|
bool ServerConnection::addPendingTextureRequest(const std::wstring &textureName)
|
||||||
{
|
{
|
||||||
AUTO_VAR(it, find( m_pendingTextureRequests.begin(), m_pendingTextureRequests.end(), textureName));
|
AUTO_VAR(it, find( m_pendingTextureRequests.begin(), m_pendingTextureRequests.end(), textureName));
|
||||||
if( it == m_pendingTextureRequests.end() )
|
if( it == m_pendingTextureRequests.end() )
|
||||||
@@ -129,7 +129,7 @@ bool ServerConnection::addPendingTextureRequest(const wstring &textureName)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerConnection::handleTextureReceived(const wstring &textureName)
|
void ServerConnection::handleTextureReceived(const std::wstring &textureName)
|
||||||
{
|
{
|
||||||
AUTO_VAR(it, find( m_pendingTextureRequests.begin(), m_pendingTextureRequests.end(), textureName));
|
AUTO_VAR(it, find( m_pendingTextureRequests.begin(), m_pendingTextureRequests.end(), textureName));
|
||||||
if( it != m_pendingTextureRequests.end() )
|
if( it != m_pendingTextureRequests.end() )
|
||||||
@@ -138,7 +138,7 @@ void ServerConnection::handleTextureReceived(const wstring &textureName)
|
|||||||
}
|
}
|
||||||
for (unsigned int i = 0; i < players.size(); i++)
|
for (unsigned int i = 0; i < players.size(); i++)
|
||||||
{
|
{
|
||||||
shared_ptr<PlayerConnection> player = players[i];
|
std::shared_ptr<PlayerConnection> player = players[i];
|
||||||
if (!player->done)
|
if (!player->done)
|
||||||
{
|
{
|
||||||
player->handleTextureReceived(textureName);
|
player->handleTextureReceived(textureName);
|
||||||
@@ -146,7 +146,7 @@ void ServerConnection::handleTextureReceived(const wstring &textureName)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerConnection::handleTextureAndGeometryReceived(const wstring &textureName)
|
void ServerConnection::handleTextureAndGeometryReceived(const std::wstring &textureName)
|
||||||
{
|
{
|
||||||
AUTO_VAR(it, find( m_pendingTextureRequests.begin(), m_pendingTextureRequests.end(), textureName));
|
AUTO_VAR(it, find( m_pendingTextureRequests.begin(), m_pendingTextureRequests.end(), textureName));
|
||||||
if( it != m_pendingTextureRequests.end() )
|
if( it != m_pendingTextureRequests.end() )
|
||||||
@@ -155,7 +155,7 @@ void ServerConnection::handleTextureAndGeometryReceived(const wstring &textureNa
|
|||||||
}
|
}
|
||||||
for (unsigned int i = 0; i < players.size(); i++)
|
for (unsigned int i = 0; i < players.size(); i++)
|
||||||
{
|
{
|
||||||
shared_ptr<PlayerConnection> player = players[i];
|
std::shared_ptr<PlayerConnection> player = players[i];
|
||||||
if (!player->done)
|
if (!player->done)
|
||||||
{
|
{
|
||||||
player->handleTextureAndGeometryReceived(textureName);
|
player->handleTextureAndGeometryReceived(textureName);
|
||||||
@@ -163,7 +163,7 @@ void ServerConnection::handleTextureAndGeometryReceived(const wstring &textureNa
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerConnection::handleServerSettingsChanged(shared_ptr<ServerSettingsChangedPacket> packet)
|
void ServerConnection::handleServerSettingsChanged(std::shared_ptr<ServerSettingsChangedPacket> packet)
|
||||||
{
|
{
|
||||||
Minecraft *pMinecraft = Minecraft::GetInstance();
|
Minecraft *pMinecraft = Minecraft::GetInstance();
|
||||||
|
|
||||||
@@ -197,7 +197,7 @@ void ServerConnection::handleServerSettingsChanged(shared_ptr<ServerSettingsChan
|
|||||||
//
|
//
|
||||||
// for (unsigned int i = 0; i < players.size(); i++)
|
// for (unsigned int i = 0; i < players.size(); i++)
|
||||||
// {
|
// {
|
||||||
// shared_ptr<PlayerConnection> playerconnection = players[i];
|
// std::shared_ptr<PlayerConnection> playerconnection = players[i];
|
||||||
// playerconnection->setShowOnMaps(pMinecraft->options->GetGamertagSetting());
|
// playerconnection->setShowOnMaps(pMinecraft->options->GetGamertagSetting());
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ class MinecraftServer;
|
|||||||
class Socket;
|
class Socket;
|
||||||
class ServerSettingsChangedPacket;
|
class ServerSettingsChangedPacket;
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
class ServerConnection
|
class ServerConnection
|
||||||
{
|
{
|
||||||
@@ -20,11 +20,11 @@ private:
|
|||||||
int connectionCounter;
|
int connectionCounter;
|
||||||
private:
|
private:
|
||||||
CRITICAL_SECTION pending_cs; // 4J added
|
CRITICAL_SECTION pending_cs; // 4J added
|
||||||
vector< shared_ptr<PendingConnection> > pending;
|
std::vector< std::shared_ptr<PendingConnection> > pending;
|
||||||
vector< shared_ptr<PlayerConnection> > players;
|
std::vector< std::shared_ptr<PlayerConnection> > players;
|
||||||
|
|
||||||
// 4J - When the server requests a texture, it should add it to here while we are waiting for it
|
// 4J - When the server requests a texture, it should add it to here while we are waiting for it
|
||||||
vector<wstring> m_pendingTextureRequests;
|
std::vector<std::wstring> m_pendingTextureRequests;
|
||||||
public:
|
public:
|
||||||
MinecraftServer *server;
|
MinecraftServer *server;
|
||||||
|
|
||||||
@@ -34,16 +34,16 @@ public:
|
|||||||
void NewIncomingSocket(Socket *socket); // 4J - added
|
void NewIncomingSocket(Socket *socket); // 4J - added
|
||||||
|
|
||||||
void removeSpamProtection(Socket *socket) { }// 4J Stu - Not implemented as not required
|
void removeSpamProtection(Socket *socket) { }// 4J Stu - Not implemented as not required
|
||||||
void addPlayerConnection(shared_ptr<PlayerConnection> uc);
|
void addPlayerConnection(std::shared_ptr<PlayerConnection> uc);
|
||||||
private:
|
private:
|
||||||
void handleConnection(shared_ptr<PendingConnection> uc);
|
void handleConnection(std::shared_ptr<PendingConnection> uc);
|
||||||
public:
|
public:
|
||||||
void stop();
|
void stop();
|
||||||
void tick();
|
void tick();
|
||||||
|
|
||||||
// 4J Added
|
// 4J Added
|
||||||
bool addPendingTextureRequest(const wstring &textureName);
|
bool addPendingTextureRequest(const std::wstring &textureName);
|
||||||
void handleTextureReceived(const wstring &textureName);
|
void handleTextureReceived(const std::wstring &textureName);
|
||||||
void handleTextureAndGeometryReceived(const wstring &textureName);
|
void handleTextureAndGeometryReceived(const std::wstring &textureName);
|
||||||
void handleServerSettingsChanged(shared_ptr<ServerSettingsChangedPacket> packet);
|
void handleServerSettingsChanged(std::shared_ptr<ServerSettingsChangedPacket> packet);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,29 +1,29 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
class ServerInterface
|
class ServerInterface
|
||||||
{
|
{
|
||||||
virtual int getConfigInt(const wstring &name, int defaultValue) = 0;
|
virtual int getConfigInt(const std::wstring &name, int defaultValue) = 0;
|
||||||
virtual wstring getConfigString(const wstring &name, const wstring &defaultValue) = 0;
|
virtual std::wstring getConfigString(const std::wstring &name, const std::wstring &defaultValue) = 0;
|
||||||
virtual bool getConfigBoolean(const wstring &name, bool defaultValue) = 0;
|
virtual bool getConfigBoolean(const std::wstring &name, bool defaultValue) = 0;
|
||||||
virtual void setProperty(wstring &propertyName, void *value) = 0;
|
virtual void setProperty(std::wstring &propertyName, void *value) = 0;
|
||||||
virtual void configSave() = 0;
|
virtual void configSave() = 0;
|
||||||
virtual wstring getConfigPath() = 0;
|
virtual std::wstring getConfigPath() = 0;
|
||||||
virtual wstring getServerIp() = 0;
|
virtual std::wstring getServerIp() = 0;
|
||||||
virtual int getServerPort() = 0;
|
virtual int getServerPort() = 0;
|
||||||
virtual wstring getServerName() = 0;
|
virtual std::wstring getServerName() = 0;
|
||||||
virtual wstring getServerVersion() = 0;
|
virtual std::wstring getServerVersion() = 0;
|
||||||
virtual int getPlayerCount() = 0;
|
virtual int getPlayerCount() = 0;
|
||||||
virtual int getMaxPlayers() = 0;
|
virtual int getMaxPlayers() = 0;
|
||||||
virtual wstring[] getPlayerNames() = 0;
|
virtual std::wstring[] getPlayerNames() = 0;
|
||||||
virtual wstring getWorldName() = 0;
|
virtual std::wstring getWorldName() = 0;
|
||||||
virtual wstring getPluginNames() = 0;
|
virtual std::wstring getPluginNames() = 0;
|
||||||
virtual void disablePlugin() = 0;
|
virtual void disablePlugin() = 0;
|
||||||
virtual wstring runCommand(const wstring &command) = 0;
|
virtual std::wstring runCommand(const std::wstring &command) = 0;
|
||||||
virtual bool isDebugging() = 0;
|
virtual bool isDebugging() = 0;
|
||||||
// Logging
|
// Logging
|
||||||
virtual void info(const wstring &string) = 0;
|
virtual void info(const std::wstring &string) = 0;
|
||||||
virtual void warn(const wstring &string) = 0;
|
virtual void warn(const std::wstring &string) = 0;
|
||||||
virtual void error(const wstring &string) = 0;
|
virtual void error(const std::wstring &string) = 0;
|
||||||
virtual void debug(const wstring &string) = 0;
|
virtual void debug(const std::wstring &string) = 0;
|
||||||
};
|
};
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
#define MAX_DISPLAYNAME_LENGTH 128 // SCE_SAVE_DATA_SUBTITLE_MAXSIZE on PS4
|
#define MAX_DISPLAYNAME_LENGTH 128 // SCE_SAVE_DATA_SUBTITLE_MAXSIZE on PS4
|
||||||
#define MAX_SAVEFILENAME_LENGTH 32 // SCE_SAVE_DATA_DIRNAME_DATA_MAXSIZE
|
#define MAX_SAVEFILENAME_LENGTH 32 // SCE_SAVE_DATA_DIRNAME_DATA_MAXSIZE
|
||||||
@@ -474,7 +474,7 @@ public:
|
|||||||
eTitleStorageState TMSPP_ReadFile(int iQuadrant,C4JStorage::eGlobalStorage eStorageFacility,C4JStorage::eTMS_FILETYPEVAL eFileTypeVal,LPWSTR wszFilename,int( *Func)(LPVOID,int,int,LPVOID, WCHAR *),LPVOID lpParam, int iUserData);
|
eTitleStorageState TMSPP_ReadFile(int iQuadrant,C4JStorage::eGlobalStorage eStorageFacility,C4JStorage::eTMS_FILETYPEVAL eFileTypeVal,LPWSTR wszFilename,int( *Func)(LPVOID,int,int,LPVOID, WCHAR *),LPVOID lpParam, int iUserData);
|
||||||
eTitleStorageState TMSPP_DeleteFile(int iQuadrant,C4JStorage::eGlobalStorage eStorageFacility,C4JStorage::eTMS_FILETYPEVAL eFileTypeVal,LPWSTR wszFilename,int( *Func)(LPVOID,int,int),LPVOID lpParam, int iUserData);
|
eTitleStorageState TMSPP_DeleteFile(int iQuadrant,C4JStorage::eGlobalStorage eStorageFacility,C4JStorage::eTMS_FILETYPEVAL eFileTypeVal,LPWSTR wszFilename,int( *Func)(LPVOID,int,int),LPVOID lpParam, int iUserData);
|
||||||
eTitleStorageState TMSPP_ReadFileList(int iPad,C4JStorage::eGlobalStorage eStorageFacility,int( *Func)(LPVOID,int,int,LPVOID,WCHAR *)=NULL,LPVOID lpParam=NULL, int iUserData=0);
|
eTitleStorageState TMSPP_ReadFileList(int iPad,C4JStorage::eGlobalStorage eStorageFacility,int( *Func)(LPVOID,int,int,LPVOID,WCHAR *)=NULL,LPVOID lpParam=NULL, int iUserData=0);
|
||||||
bool TMSPP_InFileList(eGlobalStorage eStorageFacility, int iPad,const wstring &Filename);
|
bool TMSPP_InFileList(eGlobalStorage eStorageFacility, int iPad,const std::wstring &Filename);
|
||||||
|
|
||||||
eTitleStorageState TMSPP_GetTitleStorageState(int iPad);
|
eTitleStorageState TMSPP_GetTitleStorageState(int iPad);
|
||||||
void TMSPP_ClearTitleStorageState(int iPad);
|
void TMSPP_ClearTitleStorageState(int iPad);
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ XALLOC_ATTRIBUTES ExpandAllocAttributes( _In_ LONGLONG dwAttributes )
|
|||||||
}
|
}
|
||||||
|
|
||||||
SIZE_T totalTracked = 0;
|
SIZE_T totalTracked = 0;
|
||||||
unordered_map<uintptr_t, SIZE_T> tracker;
|
std::unordered_map<uintptr_t, SIZE_T> tracker;
|
||||||
static volatile bool memDump = false;
|
static volatile bool memDump = false;
|
||||||
static volatile bool memReset = false;
|
static volatile bool memReset = false;
|
||||||
static bool memDumpInit = false;
|
static bool memDumpInit = false;
|
||||||
|
|||||||
@@ -169,7 +169,7 @@ void CConsoleMinecraftApp::FreeLocalTMSFiles(eTMSFileType eType)
|
|||||||
|
|
||||||
int CConsoleMinecraftApp::LoadLocalDLCImages()
|
int CConsoleMinecraftApp::LoadLocalDLCImages()
|
||||||
{
|
{
|
||||||
unordered_map<wstring,DLC_INFO * > *pDLCInfoA=app.GetDLCInfo();
|
std::unordered_map<std::wstring,DLC_INFO * > *pDLCInfoA=app.GetDLCInfo();
|
||||||
// 4J-PB - Any local graphic files for the Minecraft Store?
|
// 4J-PB - Any local graphic files for the Minecraft Store?
|
||||||
for( AUTO_VAR(it, pDLCInfoA->begin()); it != pDLCInfoA->end(); it++ )
|
for( AUTO_VAR(it, pDLCInfoA->begin()); it != pDLCInfoA->end(); it++ )
|
||||||
{
|
{
|
||||||
@@ -183,7 +183,7 @@ int CConsoleMinecraftApp::LoadLocalDLCImages()
|
|||||||
void CConsoleMinecraftApp::FreeLocalDLCImages()
|
void CConsoleMinecraftApp::FreeLocalDLCImages()
|
||||||
{
|
{
|
||||||
// 4J-PB - Any local graphic files for the Minecraft Store?
|
// 4J-PB - Any local graphic files for the Minecraft Store?
|
||||||
unordered_map<wstring,DLC_INFO * > *pDLCInfoA=app.GetDLCInfo();
|
std::unordered_map<std::wstring,DLC_INFO * > *pDLCInfoA=app.GetDLCInfo();
|
||||||
|
|
||||||
for( AUTO_VAR(it, pDLCInfoA->begin()); it != pDLCInfoA->end(); it++ )
|
for( AUTO_VAR(it, pDLCInfoA->begin()); it != pDLCInfoA->end(); it++ )
|
||||||
{
|
{
|
||||||
@@ -263,7 +263,7 @@ void CConsoleMinecraftApp::TemporaryCreateGameStart()
|
|||||||
////////////////////////////////////////////////////////////////////////////////////////////// From CScene_MultiGameCreate::CreateGame
|
////////////////////////////////////////////////////////////////////////////////////////////// From CScene_MultiGameCreate::CreateGame
|
||||||
|
|
||||||
app.ClearTerrainFeaturePosition();
|
app.ClearTerrainFeaturePosition();
|
||||||
wstring wWorldName = L"TestWorld";
|
std::wstring wWorldName = L"TestWorld";
|
||||||
|
|
||||||
StorageManager.ResetSaveData();
|
StorageManager.ResetSaveData();
|
||||||
StorageManager.SetSaveTitle(wWorldName.c_str());
|
StorageManager.SetSaveTitle(wWorldName.c_str());
|
||||||
@@ -559,7 +559,7 @@ int CConsoleMinecraftApp::Callback_TMSPPRetrieveFileList(void *pParam,int iPad,
|
|||||||
app.DebugPrintf("CConsoleMinecraftApp::Callback_TMSPPRetrieveFileList\n");
|
app.DebugPrintf("CConsoleMinecraftApp::Callback_TMSPPRetrieveFileList\n");
|
||||||
if(lpvData!=NULL)
|
if(lpvData!=NULL)
|
||||||
{
|
{
|
||||||
vector<C4JStorage::PTMSPP_FILE_DETAILS> *pvTmsFileDetails=(vector<C4JStorage::PTMSPP_FILE_DETAILS> *)lpvData;
|
std::vector<C4JStorage::PTMSPP_FILE_DETAILS> *pvTmsFileDetails=(std::vector<C4JStorage::PTMSPP_FILE_DETAILS> *)lpvData;
|
||||||
|
|
||||||
if(pvTmsFileDetails->size()>0)
|
if(pvTmsFileDetails->size()>0)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -984,7 +984,7 @@ void oldWinMainTick()
|
|||||||
#ifdef MEMORY_TRACKING
|
#ifdef MEMORY_TRACKING
|
||||||
|
|
||||||
int totalAllocGen = 0;
|
int totalAllocGen = 0;
|
||||||
unordered_map<int,int> allocCounts;
|
std::unordered_map<int,int> allocCounts;
|
||||||
bool trackEnable = false;
|
bool trackEnable = false;
|
||||||
bool trackStarted = false;
|
bool trackStarted = false;
|
||||||
volatile size_t sizeCheckMin = 1160;
|
volatile size_t sizeCheckMin = 1160;
|
||||||
|
|||||||
@@ -408,7 +408,7 @@ void DurangoLeaderboardManager::runLeaderboardRequest(WF::IAsyncOperation<MXSL::
|
|||||||
// Build stat names
|
// Build stat names
|
||||||
m_statNames = ref new PC::Vector<P::String^>();
|
m_statNames = ref new PC::Vector<P::String^>();
|
||||||
m_statNames->Clear();
|
m_statNames->Clear();
|
||||||
for(wstring name : m_leaderboardStatNames[difficulty][type])
|
for(std::wstring name : m_leaderboardStatNames[difficulty][type])
|
||||||
{
|
{
|
||||||
m_statNames->Append(ref new P::String(name.c_str()));
|
m_statNames->Append(ref new P::String(name.c_str()));
|
||||||
}
|
}
|
||||||
@@ -490,7 +490,7 @@ void DurangoLeaderboardManager::runLeaderboardRequest(WF::IAsyncOperation<MXSL::
|
|||||||
|
|
||||||
if(m_readCount > 0)
|
if(m_readCount > 0)
|
||||||
{
|
{
|
||||||
vector<PlayerUID> xuids = vector<PlayerUID>();
|
std::vector<PlayerUID> xuids = std::vector<PlayerUID>();
|
||||||
for(int i = 0; i < lastResult->Rows->Size; i++)
|
for(int i = 0; i < lastResult->Rows->Size; i++)
|
||||||
{
|
{
|
||||||
xuids.push_back(PlayerUID(lastResult->Rows->GetAt(i)->XboxUserId->Data()));
|
xuids.push_back(PlayerUID(lastResult->Rows->GetAt(i)->XboxUserId->Data()));
|
||||||
@@ -548,7 +548,7 @@ void DurangoLeaderboardManager::updateStatsInfo(int userIndex, int difficulty, E
|
|||||||
}
|
}
|
||||||
|
|
||||||
int statIndex = 0, sumScores = 0;
|
int statIndex = 0, sumScores = 0;
|
||||||
for(wstring statName : m_leaderboardStatNames[difficulty][type])
|
for(std::wstring statName : m_leaderboardStatNames[difficulty][type])
|
||||||
{
|
{
|
||||||
bool found = false;
|
bool found = false;
|
||||||
for(auto result : statsResult)
|
for(auto result : statsResult)
|
||||||
@@ -585,7 +585,7 @@ void DurangoLeaderboardManager::GetProfilesCallback(LPVOID param, std::vector<Mi
|
|||||||
|
|
||||||
if (profiles.size() > 0)
|
if (profiles.size() > 0)
|
||||||
{
|
{
|
||||||
dlm->m_displayNames = vector<wstring>();
|
dlm->m_displayNames = std::vector<std::wstring>();
|
||||||
for (int i = 0; i < profiles.size(); i++)
|
for (int i = 0; i < profiles.size(); i++)
|
||||||
{
|
{
|
||||||
dlm->m_displayNames.push_back(profiles[i]->GameDisplayName->Data());
|
dlm->m_displayNames.push_back(profiles[i]->GameDisplayName->Data());
|
||||||
@@ -699,7 +699,7 @@ void DurangoLeaderboardManager::setState(EStatsState newState)
|
|||||||
LeaveCriticalSection(&m_csStatsState);
|
LeaveCriticalSection(&m_csStatsState);
|
||||||
}
|
}
|
||||||
|
|
||||||
wstring DurangoLeaderboardManager::stateToString(EStatsState eState)
|
std::wstring DurangoLeaderboardManager::stateToString(EStatsState eState)
|
||||||
{
|
{
|
||||||
switch (eState)
|
switch (eState)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -35,12 +35,12 @@ private:
|
|||||||
unsigned int m_maxRank;
|
unsigned int m_maxRank;
|
||||||
|
|
||||||
MXS::XboxLiveContext^ m_xboxLiveContext;
|
MXS::XboxLiveContext^ m_xboxLiveContext;
|
||||||
wstring m_leaderboardNames[4][eStatsType_MAX];
|
std::wstring m_leaderboardNames[4][eStatsType_MAX];
|
||||||
wstring m_socialLeaderboardNames[4][eStatsType_MAX];
|
std::wstring m_socialLeaderboardNames[4][eStatsType_MAX];
|
||||||
std::vector<wstring> m_leaderboardStatNames[4][eStatsType_MAX];
|
std::vector<std::wstring> m_leaderboardStatNames[4][eStatsType_MAX];
|
||||||
|
|
||||||
// Display names for the current scores
|
// Display names for the current scores
|
||||||
std::vector<wstring> m_displayNames;
|
std::vector<std::wstring> m_displayNames;
|
||||||
bool m_waitingForProfiles;
|
bool m_waitingForProfiles;
|
||||||
|
|
||||||
int m_difficulty;
|
int m_difficulty;
|
||||||
@@ -90,5 +90,5 @@ private:
|
|||||||
|
|
||||||
EStatsState getState();
|
EStatsState getState();
|
||||||
void setState(EStatsState newState);
|
void setState(EStatsState newState);
|
||||||
wstring stateToString(EStatsState eState);
|
std::wstring stateToString(EStatsState eState);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -16,14 +16,14 @@
|
|||||||
namespace WFC = Windows::Foundation::Collections;
|
namespace WFC = Windows::Foundation::Collections;
|
||||||
namespace CC = concurrency;
|
namespace CC = concurrency;
|
||||||
|
|
||||||
StatParam::StatParam(const wstring &base)
|
StatParam::StatParam(const std::wstring &base)
|
||||||
{
|
{
|
||||||
m_base = base;
|
m_base = base;
|
||||||
//m_numArgs = numArgs;
|
//m_numArgs = numArgs;
|
||||||
m_args = vector<int>();
|
m_args = std::vector<int>();
|
||||||
|
|
||||||
unsigned int count=0;
|
unsigned int count=0;
|
||||||
wstring::size_type pos =base.find(L"*");
|
std::wstring::size_type pos =base.find(L"*");
|
||||||
while(pos!=string::npos)
|
while(pos!=string::npos)
|
||||||
{
|
{
|
||||||
count++;
|
count++;
|
||||||
@@ -46,14 +46,14 @@ void StatParam::addArgs(int v1, ...)
|
|||||||
va_end(argptr);
|
va_end(argptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
vector<wstring> *StatParam::getStats()
|
std::vector<std::wstring> *StatParam::getStats()
|
||||||
{
|
{
|
||||||
vector<wstring> *out = new vector<wstring>();
|
std::vector<std::wstring> *out = new std::vector<std::wstring>();
|
||||||
|
|
||||||
static const int MAXSIZE = 256;
|
static const int MAXSIZE = 256;
|
||||||
static const wstring SUBSTR = L"*";
|
static const std::wstring SUBSTR = L"*";
|
||||||
|
|
||||||
wstring wstr_itr, wstr_num;
|
std::wstring wstr_itr, wstr_num;
|
||||||
|
|
||||||
if (m_args.size() <= 0 || m_numArgs <= 0)
|
if (m_args.size() <= 0 || m_numArgs <= 0)
|
||||||
{
|
{
|
||||||
@@ -69,10 +69,10 @@ vector<wstring> *StatParam::getStats()
|
|||||||
{
|
{
|
||||||
for (int j=0; j<m_numArgs; j++)
|
for (int j=0; j<m_numArgs; j++)
|
||||||
{
|
{
|
||||||
wstr_num = to_wstring(m_args.at(i+j));
|
wstr_num = to_std::wstring(m_args.at(i+j));
|
||||||
size_t sz = wstr_itr.find(SUBSTR);
|
size_t sz = wstr_itr.find(SUBSTR);
|
||||||
|
|
||||||
if (sz != wstring::npos)
|
if (sz != std::wstring::npos)
|
||||||
wstr_itr.replace(sz, SUBSTR.length(), wstr_num);
|
wstr_itr.replace(sz, SUBSTR.length(), wstr_num);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -91,13 +91,13 @@ DurangoStatsDebugger::DurangoStatsDebugger()
|
|||||||
InitializeCriticalSection(&m_retrievedStatsLock);
|
InitializeCriticalSection(&m_retrievedStatsLock);
|
||||||
}
|
}
|
||||||
|
|
||||||
vector<wstring> *DurangoStatsDebugger::getStats()
|
std::vector<std::wstring> *DurangoStatsDebugger::getStats()
|
||||||
{
|
{
|
||||||
vector<wstring> *out = new vector<wstring>();
|
std::vector<std::wstring> *out = new std::vector<std::wstring>();
|
||||||
|
|
||||||
for (auto it = m_stats.begin(); it!=m_stats.end(); it++)
|
for (auto it = m_stats.begin(); it!=m_stats.end(); it++)
|
||||||
{
|
{
|
||||||
vector<wstring> *sublist = (*it)->getStats();
|
std::vector<std::wstring> *sublist = (*it)->getStats();
|
||||||
out->insert(out->end(), sublist->begin(), sublist->end());
|
out->insert(out->end(), sublist->begin(), sublist->end());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -322,11 +322,11 @@ void DurangoStatsDebugger::PrintStats(int iPad)
|
|||||||
{
|
{
|
||||||
if (instance == NULL) instance = Initialize();
|
if (instance == NULL) instance = Initialize();
|
||||||
|
|
||||||
vector<wstring> *tmp = instance->getStats();
|
std::vector<std::wstring> *tmp = instance->getStats();
|
||||||
instance->m_printQueue.insert(instance->m_printQueue.end(), tmp->begin(), tmp->end());
|
instance->m_printQueue.insert(instance->m_printQueue.end(), tmp->begin(), tmp->end());
|
||||||
|
|
||||||
// app.DebugPrintf("[DEBUG] START\n");
|
// app.DebugPrintf("[DEBUG] START\n");
|
||||||
// for (wstring t : *tmp) app.DebugPrintf("[DEBUG] %s\n", wstringtofilename(t));
|
// for (std::wstring t : *tmp) app.DebugPrintf("[DEBUG] %s\n", wstringtofilename(t));
|
||||||
// app.DebugPrintf("[DEBUG] END\n");
|
// app.DebugPrintf("[DEBUG] END\n");
|
||||||
|
|
||||||
instance->retrieveStats(iPad);
|
instance->retrieveStats(iPad);
|
||||||
@@ -407,7 +407,7 @@ void DurangoStatsDebugger::retrieveStats(int iPad)
|
|||||||
// Create Stat retrieval threads until there is no long any stats to start retrieving.
|
// Create Stat retrieval threads until there is no long any stats to start retrieving.
|
||||||
while ( !instance->m_printQueue.empty() )
|
while ( !instance->m_printQueue.empty() )
|
||||||
{
|
{
|
||||||
vector<wstring> *printing = new vector<wstring>();
|
std::vector<std::wstring> *printing = new std::vector<std::wstring>();
|
||||||
|
|
||||||
if (m_printQueue.size() > R_SIZE)
|
if (m_printQueue.size() > R_SIZE)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -11,17 +11,17 @@ namespace MXSL = Microsoft::Xbox::Services::Leaderboard;
|
|||||||
class StatParam
|
class StatParam
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
wstring m_base;
|
std::wstring m_base;
|
||||||
int m_numArgs;
|
int m_numArgs;
|
||||||
|
|
||||||
vector<int> m_args;
|
std::vector<int> m_args;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
StatParam(const wstring &base);
|
StatParam(const std::wstring &base);
|
||||||
|
|
||||||
void addArgs(int v1, ...);
|
void addArgs(int v1, ...);
|
||||||
|
|
||||||
vector<wstring> *getStats();
|
std::vector<std::wstring> *getStats();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -65,9 +65,9 @@ protected:
|
|||||||
|
|
||||||
DurangoStatsDebugger();
|
DurangoStatsDebugger();
|
||||||
|
|
||||||
vector<StatParam *> m_stats;
|
std::vector<StatParam *> m_stats;
|
||||||
|
|
||||||
vector<wstring> *getStats();
|
std::vector<std::wstring> *getStats();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static DurangoStatsDebugger *Initialize();
|
static DurangoStatsDebugger *Initialize();
|
||||||
@@ -75,20 +75,20 @@ public:
|
|||||||
static void PrintStats(int iPad);
|
static void PrintStats(int iPad);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
vector<wstring> m_printQueue;
|
std::vector<std::wstring> m_printQueue;
|
||||||
|
|
||||||
void retrieveStats(int iPad);
|
void retrieveStats(int iPad);
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
int m_iPad;
|
int m_iPad;
|
||||||
wstring m_statName;
|
std::wstring m_statName;
|
||||||
wstring m_score;
|
std::wstring m_score;
|
||||||
} StatResult;
|
} StatResult;
|
||||||
|
|
||||||
CRITICAL_SECTION m_retrievedStatsLock;
|
CRITICAL_SECTION m_retrievedStatsLock;
|
||||||
|
|
||||||
vector<StatResult> m_retrievedStats;
|
std::vector<StatResult> m_retrievedStats;
|
||||||
|
|
||||||
void addRetrievedStat(StatResult result);
|
void addRetrievedStat(StatResult result);
|
||||||
};
|
};
|
||||||
@@ -51,7 +51,7 @@ public:
|
|||||||
void RemoveLocalUser( __in Windows::Xbox::System::IUser^ user );
|
void RemoveLocalUser( __in Windows::Xbox::System::IUser^ user );
|
||||||
void EvaluateDevicesForUser(__in Windows::Xbox::System::IUser^ user );
|
void EvaluateDevicesForUser(__in Windows::Xbox::System::IUser^ user );
|
||||||
|
|
||||||
vector<AddedUser *> m_addedUsers;
|
std::vector<AddedUser *> m_addedUsers;
|
||||||
CRITICAL_SECTION m_csAddedUsers;
|
CRITICAL_SECTION m_csAddedUsers;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -22,14 +22,14 @@ DQRNetworkManager::ePartyProcessType DQRNetworkManager::m_partyProcess = DQRNetw
|
|||||||
|
|
||||||
bool DQRNetworkManager::m_inviteReceived = false;
|
bool DQRNetworkManager::m_inviteReceived = false;
|
||||||
int DQRNetworkManager::m_bootUserIndex;
|
int DQRNetworkManager::m_bootUserIndex;
|
||||||
wstring DQRNetworkManager::m_bootSessionName;
|
std::wstring DQRNetworkManager::m_bootSessionName;
|
||||||
wstring DQRNetworkManager::m_bootServiceConfig;
|
std::wstring DQRNetworkManager::m_bootServiceConfig;
|
||||||
wstring DQRNetworkManager::m_bootSessionTemplate;
|
std::wstring DQRNetworkManager::m_bootSessionTemplate;
|
||||||
DQRNetworkManager * DQRNetworkManager::s_pDQRManager = NULL;
|
DQRNetworkManager * DQRNetworkManager::s_pDQRManager = NULL;
|
||||||
|
|
||||||
//using namespace Windows::Xbox::Networking;
|
//using namespace Windows::Xbox::Networking;
|
||||||
|
|
||||||
DQRNetworkManager::SessionInfo::SessionInfo(wstring& sessionName, wstring& serviceConfig, wstring& sessionTemplate)
|
DQRNetworkManager::SessionInfo::SessionInfo(std::wstring& sessionName, std::wstring& serviceConfig, std::wstring& sessionTemplate)
|
||||||
{
|
{
|
||||||
m_detailsValid = true;
|
m_detailsValid = true;
|
||||||
m_sessionName = sessionName;
|
m_sessionName = sessionName;
|
||||||
@@ -782,7 +782,7 @@ DQRNetworkPlayer *DQRNetworkManager::GetPlayerByXuid(PlayerUID xuid)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Retrieve player display name by gamertag
|
// Retrieve player display name by gamertag
|
||||||
wstring DQRNetworkManager::GetDisplayNameByGamertag(wstring gamertag)
|
std::wstring DQRNetworkManager::GetDisplayNameByGamertag(std::wstring gamertag)
|
||||||
{
|
{
|
||||||
if (m_displayNames.find(gamertag) != m_displayNames.end())
|
if (m_displayNames.find(gamertag) != m_displayNames.end())
|
||||||
{
|
{
|
||||||
@@ -1440,8 +1440,8 @@ MXSM::MultiplayerSessionReference^ DQRNetworkManager::ConvertToMicrosoftXboxServ
|
|||||||
// this method is able to work out who has been added or removed from the game session, and notify the game of these events.
|
// this method is able to work out who has been added or removed from the game session, and notify the game of these events.
|
||||||
void DQRNetworkManager::UpdateRoomSyncPlayers(RoomSyncData *pNewSyncData)
|
void DQRNetworkManager::UpdateRoomSyncPlayers(RoomSyncData *pNewSyncData)
|
||||||
{
|
{
|
||||||
vector<DQRNetworkPlayer *> tempPlayers;
|
std::vector<DQRNetworkPlayer *> tempPlayers;
|
||||||
vector<DQRNetworkPlayer *> newPlayers;
|
std::vector<DQRNetworkPlayer *> newPlayers;
|
||||||
|
|
||||||
EnterCriticalSection(&m_csRoomSyncData);
|
EnterCriticalSection(&m_csRoomSyncData);
|
||||||
|
|
||||||
@@ -1574,7 +1574,7 @@ bool DQRNetworkManager::AddRoomSyncPlayer(DQRNetworkPlayer *pPlayer, unsigned in
|
|||||||
void DQRNetworkManager::RemoveRoomSyncPlayersWithSessionAddress(unsigned int sessionAddress)
|
void DQRNetworkManager::RemoveRoomSyncPlayersWithSessionAddress(unsigned int sessionAddress)
|
||||||
{
|
{
|
||||||
EnterCriticalSection(&m_csRoomSyncData);
|
EnterCriticalSection(&m_csRoomSyncData);
|
||||||
vector<DQRNetworkPlayer *> removedPlayers;
|
std::vector<DQRNetworkPlayer *> removedPlayers;
|
||||||
int iWriteIdx = 0;
|
int iWriteIdx = 0;
|
||||||
for( int i = 0; i < m_roomSyncData.playerCount; i++ )
|
for( int i = 0; i < m_roomSyncData.playerCount; i++ )
|
||||||
{
|
{
|
||||||
@@ -1605,7 +1605,7 @@ void DQRNetworkManager::RemoveRoomSyncPlayersWithSessionAddress(unsigned int ses
|
|||||||
// This is called from the host a remove player from the room sync data that is sent out to the clients.
|
// This is called from the host a remove player from the room sync data that is sent out to the clients.
|
||||||
void DQRNetworkManager::RemoveRoomSyncPlayer(DQRNetworkPlayer *pPlayer)
|
void DQRNetworkManager::RemoveRoomSyncPlayer(DQRNetworkPlayer *pPlayer)
|
||||||
{
|
{
|
||||||
vector<DQRNetworkPlayer *> removedPlayers;
|
std::vector<DQRNetworkPlayer *> removedPlayers;
|
||||||
int iWriteIdx = 0;
|
int iWriteIdx = 0;
|
||||||
for( int i = 0; i < m_roomSyncData.playerCount; i++ )
|
for( int i = 0; i < m_roomSyncData.playerCount; i++ )
|
||||||
{
|
{
|
||||||
@@ -2184,7 +2184,7 @@ int DQRNetworkManager::HostGameThreadProc()
|
|||||||
if( m_currentUserMask & ( 1 << i ) && ProfileManager.IsSignedIn(i))
|
if( m_currentUserMask & ( 1 << i ) && ProfileManager.IsSignedIn(i))
|
||||||
{
|
{
|
||||||
auto user = ProfileManager.GetUser(i);
|
auto user = ProfileManager.GetUser(i);
|
||||||
wstring displayName = ProfileManager.GetDisplayName(i);
|
std::wstring displayName = ProfileManager.GetDisplayName(i);
|
||||||
|
|
||||||
DQRNetworkPlayer* pPlayer = new DQRNetworkPlayer(this, ( ( smallId == m_hostSmallId ) ? DQRNetworkPlayer::DNP_TYPE_HOST : DQRNetworkPlayer::DNP_TYPE_LOCAL ), true, i, localSessionAddress);
|
DQRNetworkPlayer* pPlayer = new DQRNetworkPlayer(this, ( ( smallId == m_hostSmallId ) ? DQRNetworkPlayer::DNP_TYPE_HOST : DQRNetworkPlayer::DNP_TYPE_LOCAL ), true, i, localSessionAddress);
|
||||||
pPlayer->SetSmallId(smallId);
|
pPlayer->SetSmallId(smallId);
|
||||||
@@ -3031,7 +3031,7 @@ void DQRNetworkManager::GetProfileCallback(LPVOID pParam, Microsoft::Xbox::Servi
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set player display name
|
// Set player display name
|
||||||
void DQRNetworkManager::SetDisplayName(PlayerUID xuid, wstring displayName)
|
void DQRNetworkManager::SetDisplayName(PlayerUID xuid, std::wstring displayName)
|
||||||
{
|
{
|
||||||
EnterCriticalSection(&m_csRoomSyncData);
|
EnterCriticalSection(&m_csRoomSyncData);
|
||||||
for (int i = 0; i < m_roomSyncData.playerCount; i++)
|
for (int i = 0; i < m_roomSyncData.playerCount; i++)
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ namespace WFC = Windows::Foundation::Collections;
|
|||||||
#define MATCH_SESSION_TEMPLATE_NAME L"PeerToHostTemplate"
|
#define MATCH_SESSION_TEMPLATE_NAME L"PeerToHostTemplate"
|
||||||
#define MAX_PLAYERS_IN_TEMPLATE 8
|
#define MAX_PLAYERS_IN_TEMPLATE 8
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
ref class DQRNetworkManagerEventHandlers sealed
|
ref class DQRNetworkManagerEventHandlers sealed
|
||||||
{
|
{
|
||||||
@@ -119,12 +119,12 @@ public:
|
|||||||
class SessionInfo
|
class SessionInfo
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SessionInfo(wstring& sessionName, wstring& serviceConfig, wstring& sessionTemplate);
|
SessionInfo(std::wstring& sessionName, std::wstring& serviceConfig, std::wstring& sessionTemplate);
|
||||||
SessionInfo();
|
SessionInfo();
|
||||||
bool m_detailsValid;
|
bool m_detailsValid;
|
||||||
wstring m_sessionName;
|
std::wstring m_sessionName;
|
||||||
wstring m_serviceConfig;
|
std::wstring m_serviceConfig;
|
||||||
wstring m_sessionTemplate;
|
std::wstring m_sessionTemplate;
|
||||||
};
|
};
|
||||||
|
|
||||||
static const int MAX_LOCAL_PLAYER_COUNT = 4;
|
static const int MAX_LOCAL_PLAYER_COUNT = 4;
|
||||||
@@ -153,7 +153,7 @@ public:
|
|||||||
{
|
{
|
||||||
public:;
|
public:;
|
||||||
DQRNetworkPlayer* m_pPlayer;
|
DQRNetworkPlayer* m_pPlayer;
|
||||||
wstring m_name;
|
std::wstring m_name;
|
||||||
unsigned int m_sessionAddress;
|
unsigned int m_sessionAddress;
|
||||||
int m_channel;
|
int m_channel;
|
||||||
bool m_sync;
|
bool m_sync;
|
||||||
@@ -181,7 +181,7 @@ public:
|
|||||||
DQRNetworkPlayer *GetPlayerByIndex(int idx);
|
DQRNetworkPlayer *GetPlayerByIndex(int idx);
|
||||||
DQRNetworkPlayer *GetPlayerBySmallId(int idx);
|
DQRNetworkPlayer *GetPlayerBySmallId(int idx);
|
||||||
DQRNetworkPlayer *GetPlayerByXuid(PlayerUID xuid);
|
DQRNetworkPlayer *GetPlayerByXuid(PlayerUID xuid);
|
||||||
wstring GetDisplayNameByGamertag(wstring gamertag);
|
std::wstring GetDisplayNameByGamertag(std::wstring gamertag);
|
||||||
DQRNetworkPlayer *GetLocalPlayerByUserIndex(int idx);
|
DQRNetworkPlayer *GetLocalPlayerByUserIndex(int idx);
|
||||||
DQRNetworkPlayer *GetHostPlayer();
|
DQRNetworkPlayer *GetHostPlayer();
|
||||||
int GetSessionIndex(DQRNetworkPlayer *player);
|
int GetSessionIndex(DQRNetworkPlayer *player);
|
||||||
@@ -223,16 +223,16 @@ public:
|
|||||||
public:
|
public:
|
||||||
SessionSearchResult() { m_extData = NULL; }
|
SessionSearchResult() { m_extData = NULL; }
|
||||||
~SessionSearchResult() { free(m_extData); }
|
~SessionSearchResult() { free(m_extData); }
|
||||||
wstring m_partyId;
|
std::wstring m_partyId;
|
||||||
wstring m_sessionName;
|
std::wstring m_sessionName;
|
||||||
|
|
||||||
// These names/xuids reflect the server controlled list of who is actually in the game
|
// These names/xuids reflect the server controlled list of who is actually in the game
|
||||||
wstring m_playerNames[MAX_ONLINE_PLAYER_COUNT];
|
std::wstring m_playerNames[MAX_ONLINE_PLAYER_COUNT];
|
||||||
PlayerUID m_playerXuids[MAX_ONLINE_PLAYER_COUNT];
|
PlayerUID m_playerXuids[MAX_ONLINE_PLAYER_COUNT];
|
||||||
int m_playerCount;
|
int m_playerCount;
|
||||||
|
|
||||||
// This count & set of xuids reflects the session document list of who is in the game
|
// This count & set of xuids reflects the session document list of who is in the game
|
||||||
wstring m_sessionXuids[MAX_ONLINE_PLAYER_COUNT];
|
std::wstring m_sessionXuids[MAX_ONLINE_PLAYER_COUNT];
|
||||||
int m_usedSlotCount;
|
int m_usedSlotCount;
|
||||||
|
|
||||||
void *m_extData;
|
void *m_extData;
|
||||||
@@ -397,7 +397,7 @@ private:
|
|||||||
|
|
||||||
bool m_notifyForFullParty;
|
bool m_notifyForFullParty;
|
||||||
|
|
||||||
unordered_map<unsigned int,DQRConnectionInfo *> m_sessionAddressToConnectionInfoMapHost; // For host - there may be more than one remote session attached to this listening session
|
std::unordered_map<unsigned int,DQRConnectionInfo *> m_sessionAddressToConnectionInfoMapHost; // For host - there may be more than one remote session attached to this listening session
|
||||||
unsigned int m_sessionAddressFromSmallId[256]; // For host - for mapping back from small Id, to session address
|
unsigned int m_sessionAddressFromSmallId[256]; // For host - for mapping back from small Id, to session address
|
||||||
unsigned char m_channelFromSmallId[256]; // For host and client, for mapping back from small Id, to channel
|
unsigned char m_channelFromSmallId[256]; // For host and client, for mapping back from small Id, to channel
|
||||||
DQRConnectionInfo m_connectionInfoClient; // For client
|
DQRConnectionInfo m_connectionInfoClient; // For client
|
||||||
@@ -461,7 +461,7 @@ private:
|
|||||||
int RTSDoWorkThread();
|
int RTSDoWorkThread();
|
||||||
|
|
||||||
CRITICAL_SECTION m_csVecChatPlayers;
|
CRITICAL_SECTION m_csVecChatPlayers;
|
||||||
vector<int> m_vecChatPlayersJoined;
|
std::vector<int> m_vecChatPlayersJoined;
|
||||||
public:
|
public:
|
||||||
void HandleNewPartyFoundForPlayer();
|
void HandleNewPartyFoundForPlayer();
|
||||||
void HandlePlayerRemovedFromParty(int playerMask);
|
void HandlePlayerRemovedFromParty(int playerMask);
|
||||||
@@ -488,7 +488,7 @@ public:
|
|||||||
bool JoinPartyFromSearchResult(SessionSearchResult *searchResult, int playerMask);
|
bool JoinPartyFromSearchResult(SessionSearchResult *searchResult, int playerMask);
|
||||||
void CancelJoinPartyFromSearchResult();
|
void CancelJoinPartyFromSearchResult();
|
||||||
void RequestDisplayName(DQRNetworkPlayer *player);
|
void RequestDisplayName(DQRNetworkPlayer *player);
|
||||||
void SetDisplayName(PlayerUID xuid, wstring displayName);
|
void SetDisplayName(PlayerUID xuid, std::wstring displayName);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
__int64 m_playersLeftPartyTime;
|
__int64 m_playersLeftPartyTime;
|
||||||
@@ -509,7 +509,7 @@ private:
|
|||||||
int m_sessionResultCount;
|
int m_sessionResultCount;
|
||||||
bool m_cancelJoinFromSearchResult;
|
bool m_cancelJoinFromSearchResult;
|
||||||
|
|
||||||
map<wstring, wstring> m_displayNames; // Player display names by gamertag
|
map<std::wstring, std::wstring> m_displayNames; // Player display names by gamertag
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -521,9 +521,9 @@ private:
|
|||||||
} ePartyProcessType;
|
} ePartyProcessType;
|
||||||
static int m_bootUserIndex;
|
static int m_bootUserIndex;
|
||||||
static ePartyProcessType m_partyProcess;
|
static ePartyProcessType m_partyProcess;
|
||||||
static wstring m_bootSessionName;
|
static std::wstring m_bootSessionName;
|
||||||
static wstring m_bootServiceConfig;
|
static std::wstring m_bootServiceConfig;
|
||||||
static wstring m_bootSessionTemplate;
|
static std::wstring m_bootSessionTemplate;
|
||||||
static bool m_inviteReceived;
|
static bool m_inviteReceived;
|
||||||
|
|
||||||
static DQRNetworkManager *s_pDQRManager;
|
static DQRNetworkManager *s_pDQRManager;
|
||||||
|
|||||||
@@ -169,10 +169,10 @@ int DQRNetworkManager::GetFriendsThreadProc()
|
|||||||
|
|
||||||
// Get party views for each of the user party associations that we have. These seem to be able to (individually) raise errors, so
|
// Get party views for each of the user party associations that we have. These seem to be able to (individually) raise errors, so
|
||||||
// accumulate results into 2 matched vectors declared below so that we can ignore any broken UserPartyAssociations from now
|
// accumulate results into 2 matched vectors declared below so that we can ignore any broken UserPartyAssociations from now
|
||||||
vector<WXM::PartyView^> partyViewVector;
|
std::vector<WXM::PartyView^> partyViewVector;
|
||||||
vector<WXM::UserPartyAssociation^> partyResultsVector;
|
std::vector<WXM::UserPartyAssociation^> partyResultsVector;
|
||||||
|
|
||||||
vector<task<void>> taskVector;
|
std::vector<task<void>> taskVector;
|
||||||
for each(WXM::UserPartyAssociation^ remoteParty in partyResults)
|
for each(WXM::UserPartyAssociation^ remoteParty in partyResults)
|
||||||
{
|
{
|
||||||
auto asyncOp = WXM::Party::GetPartyViewByPartyIdAsync( primaryUser, remoteParty->PartyId );
|
auto asyncOp = WXM::Party::GetPartyViewByPartyIdAsync( primaryUser, remoteParty->PartyId );
|
||||||
@@ -210,8 +210,8 @@ int DQRNetworkManager::GetFriendsThreadProc()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Filter the party view, and party results vector (partyResultsVector) this is matched to, to remove any that don't have game sessions - or game sessions that aren't this game
|
// Filter the party view, and party results vector (partyResultsVector) this is matched to, to remove any that don't have game sessions - or game sessions that aren't this game
|
||||||
vector<WXM::PartyView^> partyViewVectorFiltered;
|
std::vector<WXM::PartyView^> partyViewVectorFiltered;
|
||||||
vector<WXM::UserPartyAssociation^> partyResultsFiltered;
|
std::vector<WXM::UserPartyAssociation^> partyResultsFiltered;
|
||||||
|
|
||||||
for( int i = 0; i < partyViewVector.size(); i++ )
|
for( int i = 0; i < partyViewVector.size(); i++ )
|
||||||
{
|
{
|
||||||
@@ -237,9 +237,9 @@ int DQRNetworkManager::GetFriendsThreadProc()
|
|||||||
//
|
//
|
||||||
// and, from the party views, we can now attempt to get game sessions
|
// and, from the party views, we can now attempt to get game sessions
|
||||||
|
|
||||||
vector<MXSM::MultiplayerSession^> sessionVector;
|
std::vector<MXSM::MultiplayerSession^> sessionVector;
|
||||||
vector<WXM::PartyView^> partyViewVectorValid;
|
std::vector<WXM::PartyView^> partyViewVectorValid;
|
||||||
vector<WXM::UserPartyAssociation^> partyResultsValid;
|
std::vector<WXM::UserPartyAssociation^> partyResultsValid;
|
||||||
|
|
||||||
for( int i = 0; i < partyViewVectorFiltered.size(); i++ )
|
for( int i = 0; i < partyViewVectorFiltered.size(); i++ )
|
||||||
{
|
{
|
||||||
@@ -284,10 +284,10 @@ int DQRNetworkManager::GetFriendsThreadProc()
|
|||||||
// a session won't have any XUIDs to resolve, which would make GetUserProfilesAsync unhappy, so we'll only be creating a task
|
// a session won't have any XUIDs to resolve, which would make GetUserProfilesAsync unhappy, so we'll only be creating a task
|
||||||
// when there are members. Creating new matching arrays for party results and sessions, to match the results (we don't care about the party view anymore)
|
// when there are members. Creating new matching arrays for party results and sessions, to match the results (we don't care about the party view anymore)
|
||||||
|
|
||||||
vector<task<IVectorView<MXSS::XboxUserProfile^>^>> nameResolveTaskVector;
|
std::vector<task<IVectorView<MXSS::XboxUserProfile^>^>> nameResolveTaskVector;
|
||||||
vector<IVectorView<MXSS::XboxUserProfile^>^> nameResolveVector;
|
std::vector<IVectorView<MXSS::XboxUserProfile^>^> nameResolveVector;
|
||||||
vector<MXSM::MultiplayerSession^> newSessionVector;
|
std::vector<MXSM::MultiplayerSession^> newSessionVector;
|
||||||
vector<WXM::UserPartyAssociation^> newPartyVector;
|
std::vector<WXM::UserPartyAssociation^> newPartyVector;
|
||||||
|
|
||||||
for( int j = 0; j < sessionVector.size(); j++ )
|
for( int j = 0; j < sessionVector.size(); j++ )
|
||||||
{
|
{
|
||||||
@@ -383,7 +383,7 @@ int DQRNetworkManager::GetFriendsThreadProc()
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
auto joinTask = when_all(begin(nameResolveTaskVector), end(nameResolveTaskVector) ).then([this, &nameResolveVector](vector<IVectorView<MXSS::XboxUserProfile^>^> results)
|
auto joinTask = when_all(begin(nameResolveTaskVector), end(nameResolveTaskVector) ).then([this, &nameResolveVector](std::vector<IVectorView<MXSS::XboxUserProfile^>^> results)
|
||||||
{
|
{
|
||||||
nameResolveVector = results;
|
nameResolveVector = results;
|
||||||
})
|
})
|
||||||
@@ -421,7 +421,7 @@ int DQRNetworkManager::GetFriendsThreadProc()
|
|||||||
}
|
}
|
||||||
for( int j = 0; j < m_sessionSearchResults[i].m_usedSlotCount; j++ )
|
for( int j = 0; j < m_sessionSearchResults[i].m_usedSlotCount; j++ )
|
||||||
{
|
{
|
||||||
m_sessionSearchResults[i].m_sessionXuids[j] = wstring( newSessionVector[i]->Members->GetAt(j)->XboxUserId->Data() );
|
m_sessionSearchResults[i].m_sessionXuids[j] = std::wstring( newSessionVector[i]->Members->GetAt(j)->XboxUserId->Data() );
|
||||||
}
|
}
|
||||||
|
|
||||||
m_sessionSearchResults[i].m_extData = malloc( sizeof(GameSessionData) );
|
m_sessionSearchResults[i].m_extData = malloc( sizeof(GameSessionData) );
|
||||||
|
|||||||
@@ -192,13 +192,13 @@ void DQRNetworkPlayer::SetName(const wchar_t *name)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Return display name (if display name is not set, return name instead)
|
// Return display name (if display name is not set, return name instead)
|
||||||
wstring DQRNetworkPlayer::GetDisplayName()
|
std::wstring DQRNetworkPlayer::GetDisplayName()
|
||||||
{
|
{
|
||||||
return (m_displayName == L"") ? m_name : m_displayName;
|
return (m_displayName == L"") ? m_name : m_displayName;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set display name
|
// Set display name
|
||||||
void DQRNetworkPlayer::SetDisplayName(wstring displayName)
|
void DQRNetworkPlayer::SetDisplayName(std::wstring displayName)
|
||||||
{
|
{
|
||||||
m_displayName = displayName;
|
m_displayName = displayName;
|
||||||
}
|
}
|
||||||
@@ -97,7 +97,7 @@ const wchar_t *NetworkPlayerDurango::GetOnlineName()
|
|||||||
return m_dqrPlayer->GetName();
|
return m_dqrPlayer->GetName();
|
||||||
}
|
}
|
||||||
|
|
||||||
wstring NetworkPlayerDurango::GetDisplayName()
|
std::wstring NetworkPlayerDurango::GetDisplayName()
|
||||||
{
|
{
|
||||||
return m_dqrPlayer->GetDisplayName();
|
return m_dqrPlayer->GetDisplayName();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ public:
|
|||||||
virtual void SetSocket(Socket *pSocket);
|
virtual void SetSocket(Socket *pSocket);
|
||||||
virtual Socket *GetSocket();
|
virtual Socket *GetSocket();
|
||||||
virtual const wchar_t *GetOnlineName();
|
virtual const wchar_t *GetOnlineName();
|
||||||
virtual wstring GetDisplayName();
|
virtual std::wstring GetDisplayName();
|
||||||
virtual PlayerUID GetUID();
|
virtual PlayerUID GetUID();
|
||||||
|
|
||||||
void SetUID(PlayerUID UID);
|
void SetUID(PlayerUID UID);
|
||||||
|
|||||||
@@ -781,7 +781,7 @@ void PartyController::OnGameSessionReady( GameSessionReadyEventArgs^ eventArgs )
|
|||||||
Microsoft::Xbox::Services::Multiplayer::MultiplayerSessionReference^ sessionRef =
|
Microsoft::Xbox::Services::Multiplayer::MultiplayerSessionReference^ sessionRef =
|
||||||
m_pDQRNet->ConvertToMicrosoftXboxServicesMultiplayerSessionReference(eventArgs->GameSession);
|
m_pDQRNet->ConvertToMicrosoftXboxServicesMultiplayerSessionReference(eventArgs->GameSession);
|
||||||
|
|
||||||
vector<Platform::String^> localAdhocAdditions;
|
std::vector<Platform::String^> localAdhocAdditions;
|
||||||
|
|
||||||
// Use context from any user at all for this, since this might happen before we are in a game and won't have anything set up in the network manager itself. We are only
|
// Use context from any user at all for this, since this might happen before we are in a game and won't have anything set up in the network manager itself. We are only
|
||||||
// using it to read the session so there shouldn't be any requirements to use a particular live context
|
// using it to read the session so there shouldn't be any requirements to use a particular live context
|
||||||
|
|||||||
@@ -744,12 +744,12 @@ bool CPlatformNetworkManagerDurango::SystemFlagGet(INetworkPlayer *pNetworkPlaye
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
wstring CPlatformNetworkManagerDurango::GatherStats()
|
std::wstring CPlatformNetworkManagerDurango::GatherStats()
|
||||||
{
|
{
|
||||||
return L"";
|
return L"";
|
||||||
}
|
}
|
||||||
|
|
||||||
wstring CPlatformNetworkManagerDurango::GatherRTTStats()
|
std::wstring CPlatformNetworkManagerDurango::GatherRTTStats()
|
||||||
{
|
{
|
||||||
return L"";
|
return L"";
|
||||||
}
|
}
|
||||||
@@ -790,9 +790,9 @@ void CPlatformNetworkManagerDurango::TickSearch()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
vector<FriendSessionInfo *> *CPlatformNetworkManagerDurango::GetSessionList(int iPad, int localPlayers, bool partyOnly)
|
std::vector<FriendSessionInfo *> *CPlatformNetworkManagerDurango::GetSessionList(int iPad, int localPlayers, bool partyOnly)
|
||||||
{
|
{
|
||||||
vector<FriendSessionInfo *> *filteredList = new vector<FriendSessionInfo *>();
|
std::vector<FriendSessionInfo *> *filteredList = new std::vector<FriendSessionInfo *>();
|
||||||
for( int i = 0; i < m_searchResultsCount; i++ )
|
for( int i = 0; i < m_searchResultsCount; i++ )
|
||||||
{
|
{
|
||||||
GameSessionData *gameSessionData = (GameSessionData *)m_pSearchResults[i].m_extData;
|
GameSessionData *gameSessionData = (GameSessionData *)m_pSearchResults[i].m_extData;
|
||||||
@@ -883,7 +883,7 @@ INetworkPlayer * CPlatformNetworkManagerDurango::GetPlayerBySmallId(unsigned cha
|
|||||||
return getNetworkPlayer(m_pDQRNet->GetPlayerBySmallId(smallId));
|
return getNetworkPlayer(m_pDQRNet->GetPlayerBySmallId(smallId));
|
||||||
}
|
}
|
||||||
|
|
||||||
wstring CPlatformNetworkManagerDurango::GetDisplayNameByGamertag(wstring gamertag)
|
std::wstring CPlatformNetworkManagerDurango::GetDisplayNameByGamertag(std::wstring gamertag)
|
||||||
{
|
{
|
||||||
return m_pDQRNet->GetDisplayNameByGamertag(gamertag);
|
return m_pDQRNet->GetDisplayNameByGamertag(gamertag);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
using namespace std;
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include "../../../../Minecraft.World/Util/C4JThread.h"
|
#include "../../../../Minecraft.World/Util/C4JThread.h"
|
||||||
#include "../../../Build/Common/Network/NetworkPlayerInterface.h"
|
#include "../../../Build/Common/Network/NetworkPlayerInterface.h"
|
||||||
@@ -28,7 +28,7 @@ public:
|
|||||||
virtual INetworkPlayer *GetPlayerByIndex(int playerIndex);
|
virtual INetworkPlayer *GetPlayerByIndex(int playerIndex);
|
||||||
virtual INetworkPlayer * GetPlayerByXuid(PlayerUID xuid);
|
virtual INetworkPlayer * GetPlayerByXuid(PlayerUID xuid);
|
||||||
virtual INetworkPlayer * GetPlayerBySmallId(unsigned char smallId);
|
virtual INetworkPlayer * GetPlayerBySmallId(unsigned char smallId);
|
||||||
virtual wstring GetDisplayNameByGamertag(wstring gamertag);
|
virtual std::wstring GetDisplayNameByGamertag(std::wstring gamertag);
|
||||||
virtual bool ShouldMessageForFullSession();
|
virtual bool ShouldMessageForFullSession();
|
||||||
|
|
||||||
virtual INetworkPlayer *GetHostPlayer();
|
virtual INetworkPlayer *GetHostPlayer();
|
||||||
@@ -71,7 +71,7 @@ private:
|
|||||||
|
|
||||||
HANDLE m_notificationListener;
|
HANDLE m_notificationListener;
|
||||||
|
|
||||||
vector<DQRNetworkPlayer *> m_machineDQRPrimaryPlayers; // collection of players that we deem to be the main one for that system
|
std::vector<DQRNetworkPlayer *> m_machineDQRPrimaryPlayers; // collection of players that we deem to be the main one for that system
|
||||||
|
|
||||||
bool m_bLeavingGame;
|
bool m_bLeavingGame;
|
||||||
bool m_bLeaveGameOnTick;
|
bool m_bLeaveGameOnTick;
|
||||||
@@ -107,7 +107,7 @@ private:
|
|||||||
PlayerFlags(INetworkPlayer *pNetworkPlayer, unsigned int count);
|
PlayerFlags(INetworkPlayer *pNetworkPlayer, unsigned int count);
|
||||||
~PlayerFlags();
|
~PlayerFlags();
|
||||||
};
|
};
|
||||||
vector<PlayerFlags *> m_playerFlags;
|
std::vector<PlayerFlags *> m_playerFlags;
|
||||||
void SystemFlagAddPlayer(INetworkPlayer *pNetworkPlayer);
|
void SystemFlagAddPlayer(INetworkPlayer *pNetworkPlayer);
|
||||||
void SystemFlagRemovePlayer(INetworkPlayer *pNetworkPlayer);
|
void SystemFlagRemovePlayer(INetworkPlayer *pNetworkPlayer);
|
||||||
void SystemFlagReset();
|
void SystemFlagReset();
|
||||||
@@ -120,11 +120,11 @@ private:
|
|||||||
float m_lastPlayerEventTimeStart;
|
float m_lastPlayerEventTimeStart;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
wstring GatherStats();
|
std::wstring GatherStats();
|
||||||
wstring GatherRTTStats();
|
std::wstring GatherRTTStats();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
vector<FriendSessionInfo *> friendsSessions[XUSER_MAX_COUNT];
|
std::vector<FriendSessionInfo *> friendsSessions[XUSER_MAX_COUNT];
|
||||||
int m_searchResultsCount;
|
int m_searchResultsCount;
|
||||||
int m_lastSearchStartTime;
|
int m_lastSearchStartTime;
|
||||||
|
|
||||||
@@ -139,7 +139,7 @@ private:
|
|||||||
|
|
||||||
void TickSearch();
|
void TickSearch();
|
||||||
|
|
||||||
vector<INetworkPlayer *>currentNetworkPlayers;
|
std::vector<INetworkPlayer *>currentNetworkPlayers;
|
||||||
INetworkPlayer *addNetworkPlayer(DQRNetworkPlayer *pDQRPlayer);
|
INetworkPlayer *addNetworkPlayer(DQRNetworkPlayer *pDQRPlayer);
|
||||||
void removeNetworkPlayer(DQRNetworkPlayer *pDQRPlayer);
|
void removeNetworkPlayer(DQRNetworkPlayer *pDQRPlayer);
|
||||||
static INetworkPlayer *getNetworkPlayer(DQRNetworkPlayer *pDQRPlayer);
|
static INetworkPlayer *getNetworkPlayer(DQRNetworkPlayer *pDQRPlayer);
|
||||||
@@ -149,7 +149,7 @@ private:
|
|||||||
virtual void Notify(int ID, ULONG_PTR Param);
|
virtual void Notify(int ID, ULONG_PTR Param);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual vector<FriendSessionInfo *> *GetSessionList(int iPad, int localPlayers, bool partyOnly);
|
virtual std::vector<FriendSessionInfo *> *GetSessionList(int iPad, int localPlayers, bool partyOnly);
|
||||||
virtual bool GetGameSessionInfo(int iPad, SessionID sessionId,FriendSessionInfo *foundSession);
|
virtual bool GetGameSessionInfo(int iPad, SessionID sessionId,FriendSessionInfo *foundSession);
|
||||||
virtual void SetSessionsUpdatedCallback( void (*SessionsUpdatedCallback)(LPVOID pParam), LPVOID pSearchParam );
|
virtual void SetSessionsUpdatedCallback( void (*SessionsUpdatedCallback)(LPVOID pParam), LPVOID pSearchParam );
|
||||||
virtual void GetFullFriendSessionInfo( FriendSessionInfo *foundSession, void (* FriendSessionUpdatedFn)(bool success, void *pParam), void *pParam );
|
virtual void GetFullFriendSessionInfo( FriendSessionInfo *foundSession, void (* FriendSessionUpdatedFn)(bool success, void *pParam), void *pParam );
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ bool CDurangoTelemetryManager::RecordPlayerSessionStart(int iPad)
|
|||||||
|
|
||||||
bool CDurangoTelemetryManager::RecordPlayerSessionExit(int iPad, int exitStatus)
|
bool CDurangoTelemetryManager::RecordPlayerSessionExit(int iPad, int exitStatus)
|
||||||
{
|
{
|
||||||
PlayerUID puid; shared_ptr<Player> plr;
|
PlayerUID puid; std::shared_ptr<Player> plr;
|
||||||
ProfileManager.GetXUID(iPad, &puid, true);
|
ProfileManager.GetXUID(iPad, &puid, true);
|
||||||
plr = Minecraft::GetInstance()->localplayers[iPad];
|
plr = Minecraft::GetInstance()->localplayers[iPad];
|
||||||
|
|
||||||
@@ -127,7 +127,7 @@ bool CDurangoTelemetryManager::RecordLevelStart(int iPad, ESen_FriendOrMatch fri
|
|||||||
ULONG hr = 0;
|
ULONG hr = 0;
|
||||||
|
|
||||||
// Grab player info.
|
// Grab player info.
|
||||||
PlayerUID puid; shared_ptr<Player> plr;
|
PlayerUID puid; std::shared_ptr<Player> plr;
|
||||||
ProfileManager.GetXUID(iPad, &puid, true);
|
ProfileManager.GetXUID(iPad, &puid, true);
|
||||||
plr = Minecraft::GetInstance()->localplayers[iPad];
|
plr = Minecraft::GetInstance()->localplayers[iPad];
|
||||||
|
|
||||||
@@ -971,9 +971,9 @@ DurangoStats *CDurangoTelemetryManager::durangoStats()
|
|||||||
return (DurangoStats*) GenericStats::getInstance();
|
return (DurangoStats*) GenericStats::getInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
wstring CDurangoTelemetryManager::guid2str(LPCGUID guid)
|
std::wstring CDurangoTelemetryManager::guid2str(LPCGUID guid)
|
||||||
{
|
{
|
||||||
wstring out = L"GUID<";
|
std::wstring out = L"GUID<";
|
||||||
out += _toString<unsigned long>(guid->Data1);
|
out += _toString<unsigned long>(guid->Data1);
|
||||||
out += L":";
|
out += L":";
|
||||||
out += _toString<unsigned short>(guid->Data2);
|
out += _toString<unsigned short>(guid->Data2);
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ class CDurangoTelemetryManager : public CTelemetryManager
|
|||||||
public:
|
public:
|
||||||
static GUID ZERO_GUID;
|
static GUID ZERO_GUID;
|
||||||
|
|
||||||
unordered_map<wstring, float> m_multiplayerRoundStartTimes;
|
std::unordered_map<std::wstring, float> m_multiplayerRoundStartTimes;
|
||||||
|
|
||||||
CDurangoTelemetryManager();
|
CDurangoTelemetryManager();
|
||||||
|
|
||||||
@@ -46,5 +46,5 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
DurangoStats *durangoStats();
|
DurangoStats *durangoStats();
|
||||||
|
|
||||||
wstring guid2str(LPCGUID guid);
|
std::wstring guid2str(LPCGUID guid);
|
||||||
};
|
};
|
||||||
@@ -71,7 +71,7 @@ void CConsoleMinecraftApp::TemporaryCreateGameStart()
|
|||||||
////////////////////////////////////////////////////////////////////////////////////////////// From CScene_MultiGameCreate::CreateGame
|
////////////////////////////////////////////////////////////////////////////////////////////// From CScene_MultiGameCreate::CreateGame
|
||||||
|
|
||||||
app.ClearTerrainFeaturePosition();
|
app.ClearTerrainFeaturePosition();
|
||||||
wstring wWorldName = L"TestWorld";
|
std::wstring wWorldName = L"TestWorld";
|
||||||
|
|
||||||
StorageManager.ResetSaveData();
|
StorageManager.ResetSaveData();
|
||||||
StorageManager.SetSaveTitle(wWorldName.c_str());
|
StorageManager.SetSaveTitle(wWorldName.c_str());
|
||||||
|
|||||||
@@ -568,7 +568,7 @@ int StartMinecraftThreadProc( void* lpParameter )
|
|||||||
AABB::UseDefaultThreadStorage();
|
AABB::UseDefaultThreadStorage();
|
||||||
Tesselator::CreateNewThreadStorage(1024*1024);
|
Tesselator::CreateNewThreadStorage(1024*1024);
|
||||||
RenderManager.InitialiseContext();
|
RenderManager.InitialiseContext();
|
||||||
Minecraft::start(wstring(),wstring());
|
Minecraft::start(std::wstring(),std::wstring());
|
||||||
delete Tesselator::getInstance();
|
delete Tesselator::getInstance();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -989,9 +989,9 @@ Vec3::resetPool();
|
|||||||
// g_pd3dDevice->Release();
|
// g_pd3dDevice->Release();
|
||||||
|
|
||||||
|
|
||||||
vector<uint8_t *> vRichPresenceStrings;
|
std::vector<uint8_t *> vRichPresenceStrings;
|
||||||
|
|
||||||
// convert wstring to UTF-8 string
|
// convert std::wstring to UTF-8 string
|
||||||
std::string wstring_to_utf8 (const std::wstring& str)
|
std::string wstring_to_utf8 (const std::wstring& str)
|
||||||
{
|
{
|
||||||
std::wstring_convert<std::codecvt_utf8<wchar_t>> myconv;
|
std::wstring_convert<std::codecvt_utf8<wchar_t>> myconv;
|
||||||
@@ -1038,7 +1038,7 @@ void FreeRichPresenceStrings()
|
|||||||
#ifdef MEMORY_TRACKING
|
#ifdef MEMORY_TRACKING
|
||||||
|
|
||||||
int totalAllocGen = 0;
|
int totalAllocGen = 0;
|
||||||
unordered_map<int,int> allocCounts;
|
std::unordered_map<int,int> allocCounts;
|
||||||
bool trackEnable = false;
|
bool trackEnable = false;
|
||||||
bool trackStarted = false;
|
bool trackStarted = false;
|
||||||
volatile size_t sizeCheckMin = 1160;
|
volatile size_t sizeCheckMin = 1160;
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ public:
|
|||||||
int GetPrimaryPad();
|
int GetPrimaryPad();
|
||||||
void SetPrimaryPad(int iPad);
|
void SetPrimaryPad(int iPad);
|
||||||
char* GetGamertag(int iPad);
|
char* GetGamertag(int iPad);
|
||||||
wstring GetDisplayName(int iPad);
|
std::wstring GetDisplayName(int iPad);
|
||||||
bool IsFullVersion();
|
bool IsFullVersion();
|
||||||
void SetFullVersion(bool bFull);
|
void SetFullVersion(bool bFull);
|
||||||
void SetSignInChangeCallback(void ( *Func)(LPVOID, bool, unsigned int),LPVOID lpParam);
|
void SetSignInChangeCallback(void ( *Func)(LPVOID, bool, unsigned int),LPVOID lpParam);
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
#include <save_data.h>
|
#include <save_data.h>
|
||||||
|
|
||||||
@@ -405,7 +405,7 @@ public:
|
|||||||
void SetDLCProductCode(const char* szProductCode);
|
void SetDLCProductCode(const char* szProductCode);
|
||||||
void SetProductUpgradeKey(const char* szKey);
|
void SetProductUpgradeKey(const char* szKey);
|
||||||
bool CheckForTrialUpgradeKey(void( *Func)(LPVOID, bool),LPVOID lpParam);
|
bool CheckForTrialUpgradeKey(void( *Func)(LPVOID, bool),LPVOID lpParam);
|
||||||
void SetDLCInfoMap(unordered_map<wstring, SONYDLC *>* pSONYDLCMap);
|
void SetDLCInfoMap(std::unordered_map<std::wstring, SONYDLC *>* pSONYDLCMap);
|
||||||
};
|
};
|
||||||
|
|
||||||
extern C4JStorage StorageManager;
|
extern C4JStorage StorageManager;
|
||||||
|
|||||||
@@ -1005,8 +1005,8 @@ void OrbisLeaderboardManager::initReadScoreStruct(ReadScore &out, SceNpScoreRank
|
|||||||
out.m_uid.setOnlineID( rankData.npId.handle, true );
|
out.m_uid.setOnlineID( rankData.npId.handle, true );
|
||||||
out.m_rank = rankData.rank;
|
out.m_rank = rankData.rank;
|
||||||
|
|
||||||
// Convert to wstring and copy name.
|
// Convert to std::wstring and copy name.
|
||||||
wstring wstrName = convStringToWstring( string(rankData.npId.handle.data) ).c_str();
|
std::wstring wstrName = convStringToWstring( string(rankData.npId.handle.data) ).c_str();
|
||||||
//memcpy(&out.m_name, wstrName.c_str(), XUSER_NAME_SIZE);
|
//memcpy(&out.m_name, wstrName.c_str(), XUSER_NAME_SIZE);
|
||||||
out.m_name=wstrName;
|
out.m_name=wstrName;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -717,7 +717,7 @@ bool SQRNetworkManager_Orbis::FriendRoomManagerSearch2()
|
|||||||
if( m_aFriendSearchResults.size() > 0 )
|
if( m_aFriendSearchResults.size() > 0 )
|
||||||
{
|
{
|
||||||
// If we have some results, then we also want to make sure that we don't have any duplicate rooms here if more than one friend is playing in the same room.
|
// If we have some results, then we also want to make sure that we don't have any duplicate rooms here if more than one friend is playing in the same room.
|
||||||
unordered_set<SceNpMatching2RoomId> uniqueRooms;
|
std::unordered_set<SceNpMatching2RoomId> uniqueRooms;
|
||||||
for( unsigned int i = 0; i < m_aFriendSearchResults.size(); i++ )
|
for( unsigned int i = 0; i < m_aFriendSearchResults.size(); i++ )
|
||||||
{
|
{
|
||||||
if(m_aFriendSearchResults[i].m_RoomFound)
|
if(m_aFriendSearchResults[i].m_RoomFound)
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ bool CConsoleMinecraftApp::IsAmericanSKU()
|
|||||||
|
|
||||||
SONYDLC *CConsoleMinecraftApp::GetSONYDLCInfo(char *pchTitle)
|
SONYDLC *CConsoleMinecraftApp::GetSONYDLCInfo(char *pchTitle)
|
||||||
{
|
{
|
||||||
wstring wstrTemp=convStringToWstring(pchTitle);
|
std::wstring wstrTemp=convStringToWstring(pchTitle);
|
||||||
|
|
||||||
AUTO_VAR(it, m_SONYDLCMap.find(wstrTemp));
|
AUTO_VAR(it, m_SONYDLCMap.find(wstrTemp));
|
||||||
if(it == m_SONYDLCMap.end())
|
if(it == m_SONYDLCMap.end())
|
||||||
@@ -191,7 +191,7 @@ BOOL CConsoleMinecraftApp::ReadProductCodes()
|
|||||||
|
|
||||||
// push this into a vector
|
// push this into a vector
|
||||||
|
|
||||||
wstring wstrTemp=convStringToWstring(chDLCTitle);
|
std::wstring wstrTemp=convStringToWstring(chDLCTitle);
|
||||||
m_SONYDLCMap[wstrTemp]=pDLCInfo;
|
m_SONYDLCMap[wstrTemp]=pDLCInfo;
|
||||||
}
|
}
|
||||||
CloseHandle(file);
|
CloseHandle(file);
|
||||||
@@ -288,7 +288,7 @@ int CConsoleMinecraftApp::GetLocalTMSFileIndex(WCHAR *wchTMSFile,bool bFilenameI
|
|||||||
int CConsoleMinecraftApp::LoadLocalDLCImages()
|
int CConsoleMinecraftApp::LoadLocalDLCImages()
|
||||||
{
|
{
|
||||||
// 4J-PB - Any local graphic files for the Minecraft Store?
|
// 4J-PB - Any local graphic files for the Minecraft Store?
|
||||||
unordered_map<wstring, SONYDLC *>*pDLCInfoA=app.GetSonyDLCMap();
|
std::unordered_map<std::wstring, SONYDLC *>*pDLCInfoA=app.GetSonyDLCMap();
|
||||||
for( AUTO_VAR(it, pDLCInfoA->begin()); it != pDLCInfoA->end(); it++ )
|
for( AUTO_VAR(it, pDLCInfoA->begin()); it != pDLCInfoA->end(); it++ )
|
||||||
{
|
{
|
||||||
SONYDLC * pDLCInfo=(*it).second;
|
SONYDLC * pDLCInfo=(*it).second;
|
||||||
@@ -301,7 +301,7 @@ int CConsoleMinecraftApp::LoadLocalDLCImages()
|
|||||||
void CConsoleMinecraftApp::FreeLocalDLCImages()
|
void CConsoleMinecraftApp::FreeLocalDLCImages()
|
||||||
{
|
{
|
||||||
// 4J-PB - Any local graphic files for the Minecraft Store?
|
// 4J-PB - Any local graphic files for the Minecraft Store?
|
||||||
unordered_map<wstring, SONYDLC *>*pDLCInfoA=app.GetSonyDLCMap();
|
std::unordered_map<std::wstring, SONYDLC *>*pDLCInfoA=app.GetSonyDLCMap();
|
||||||
for( AUTO_VAR(it, pDLCInfoA->begin()); it != pDLCInfoA->end(); it++ )
|
for( AUTO_VAR(it, pDLCInfoA->begin()); it != pDLCInfoA->end(); it++ )
|
||||||
{
|
{
|
||||||
SONYDLC * pDLCInfo=(*it).second;
|
SONYDLC * pDLCInfo=(*it).second;
|
||||||
@@ -394,7 +394,7 @@ void CConsoleMinecraftApp::TemporaryCreateGameStart()
|
|||||||
////////////////////////////////////////////////////////////////////////////////////////////// From CScene_MultiGameCreate::CreateGame
|
////////////////////////////////////////////////////////////////////////////////////////////// From CScene_MultiGameCreate::CreateGame
|
||||||
|
|
||||||
app.ClearTerrainFeaturePosition();
|
app.ClearTerrainFeaturePosition();
|
||||||
wstring wWorldName = L"TestWorld";
|
std::wstring wWorldName = L"TestWorld";
|
||||||
|
|
||||||
StorageManager.ResetSaveData();
|
StorageManager.ResetSaveData();
|
||||||
StorageManager.SetSaveTitle(wWorldName.c_str());
|
StorageManager.SetSaveTitle(wWorldName.c_str());
|
||||||
|
|||||||
@@ -161,7 +161,7 @@ public:
|
|||||||
bool DLCAlreadyPurchased(char *pchTitle);
|
bool DLCAlreadyPurchased(char *pchTitle);
|
||||||
char *GetSkuIDFromProductList();
|
char *GetSkuIDFromProductList();
|
||||||
void GetDLCSkuIDFromProductList(char *,char *);
|
void GetDLCSkuIDFromProductList(char *,char *);
|
||||||
unordered_map<wstring, SONYDLC *>* GetSonyDLCMap() { return &m_SONYDLCMap; }
|
std::unordered_map<std::wstring, SONYDLC *>* GetSonyDLCMap() { return &m_SONYDLCMap; }
|
||||||
static void CommerceInitCallback(LPVOID lpParam,int err);
|
static void CommerceInitCallback(LPVOID lpParam,int err);
|
||||||
static void CommerceGetCategoriesCallback(LPVOID lpParam,int err);
|
static void CommerceGetCategoriesCallback(LPVOID lpParam,int err);
|
||||||
static void CommerceGetProductListCallback(LPVOID lpParam,int err);
|
static void CommerceGetProductListCallback(LPVOID lpParam,int err);
|
||||||
@@ -210,7 +210,7 @@ private:
|
|||||||
// SonyCommerce::ProductInfoDetailed m_ProductInfoDetailed;
|
// SonyCommerce::ProductInfoDetailed m_ProductInfoDetailed;
|
||||||
|
|
||||||
PRODUCTCODES ProductCodes;
|
PRODUCTCODES ProductCodes;
|
||||||
unordered_map<wstring, SONYDLC *> m_SONYDLCMap;
|
std::unordered_map<std::wstring, SONYDLC *> m_SONYDLCMap;
|
||||||
|
|
||||||
|
|
||||||
bool m_bVoiceChatAndUGCRestricted;
|
bool m_bVoiceChatAndUGCRestricted;
|
||||||
|
|||||||
@@ -757,7 +757,7 @@ int StartMinecraftThreadProc( void* lpParameter )
|
|||||||
AABB::UseDefaultThreadStorage();
|
AABB::UseDefaultThreadStorage();
|
||||||
Tesselator::CreateNewThreadStorage(1024*1024);
|
Tesselator::CreateNewThreadStorage(1024*1024);
|
||||||
RenderManager.InitialiseContext();
|
RenderManager.InitialiseContext();
|
||||||
Minecraft::start(wstring(),wstring());
|
Minecraft::start(std::wstring(),std::wstring());
|
||||||
delete Tesselator::getInstance();
|
delete Tesselator::getInstance();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -1460,10 +1460,10 @@ int main(int argc, const char *argv[] )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
vector<uint8_t *> vRichPresenceStrings;
|
std::vector<uint8_t *> vRichPresenceStrings;
|
||||||
|
|
||||||
// convert wstring to UTF-8 string
|
// convert std::wstring to UTF-8 string
|
||||||
std::string wstring_to_utf8 (const std::wstring& str)
|
std::string std::wstring_to_utf8 (const std::wstring& str)
|
||||||
{
|
{
|
||||||
std::wstring_convert<std::codecvt_utf8<wchar_t>> myconv;
|
std::wstring_convert<std::codecvt_utf8<wchar_t>> myconv;
|
||||||
return myconv.to_bytes(str);
|
return myconv.to_bytes(str);
|
||||||
@@ -1475,7 +1475,7 @@ uint8_t *mallocAndCreateUTF8ArrayFromString(int iID)
|
|||||||
LPCWSTR wchString=app.GetString(iID);
|
LPCWSTR wchString=app.GetString(iID);
|
||||||
|
|
||||||
std::wstring srcString = wchString;
|
std::wstring srcString = wchString;
|
||||||
std::string dstString = wstring_to_utf8(srcString);
|
std::string dstString = std::wstring_to_utf8(srcString);
|
||||||
|
|
||||||
int dst_len = dstString.size()+1;
|
int dst_len = dstString.size()+1;
|
||||||
uint8_t *strUtf8=(uint8_t *)malloc(dst_len);
|
uint8_t *strUtf8=(uint8_t *)malloc(dst_len);
|
||||||
@@ -1509,7 +1509,7 @@ void FreeRichPresenceStrings()
|
|||||||
#ifdef MEMORY_TRACKING
|
#ifdef MEMORY_TRACKING
|
||||||
|
|
||||||
int totalAllocGen = 0;
|
int totalAllocGen = 0;
|
||||||
unordered_map<int,int> allocCounts;
|
std::unordered_map<int,int> allocCounts;
|
||||||
bool trackEnable = false;
|
bool trackEnable = false;
|
||||||
bool trackStarted = false;
|
bool trackStarted = false;
|
||||||
volatile size_t sizeCheckMin = 1160;
|
volatile size_t sizeCheckMin = 1160;
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ PlayerUID::PlayerUID(SceUserServiceUserId userID, SceNpOnlineId& onlineID, bool
|
|||||||
setOnlineID(onlineID, bSignedInPSN);
|
setOnlineID(onlineID, bSignedInPSN);
|
||||||
}
|
}
|
||||||
|
|
||||||
PlayerUID::PlayerUID(wstring fromString)
|
PlayerUID::PlayerUID(std::wstring fromString)
|
||||||
{
|
{
|
||||||
// create for the format P_5e7ff8372ea9_00000004_Mark_4J
|
// create for the format P_5e7ff8372ea9_00000004_Mark_4J
|
||||||
|
|
||||||
@@ -53,14 +53,14 @@ PlayerUID::PlayerUID(wstring fromString)
|
|||||||
// parse the mac address next
|
// parse the mac address next
|
||||||
for(int i=0;i<6;i++)
|
for(int i=0;i<6;i++)
|
||||||
{
|
{
|
||||||
wstring macDigit = fromString.substr(2+(i*2),2);
|
std::wstring macDigit = fromString.substr(2+(i*2),2);
|
||||||
m_macAddress[i] = _fromHEXString<int>(macDigit);
|
m_macAddress[i] = _fromHEXString<int>(macDigit);
|
||||||
}
|
}
|
||||||
|
|
||||||
int userIdLen = 0;
|
int userIdLen = 0;
|
||||||
|
|
||||||
// parse the userID
|
// parse the userID
|
||||||
wstring userIDDigits = L"";
|
std::wstring userIDDigits = L"";
|
||||||
|
|
||||||
while(fromString.at(15 + userIdLen) != L'_')
|
while(fromString.at(15 + userIdLen) != L'_')
|
||||||
{
|
{
|
||||||
@@ -71,7 +71,7 @@ PlayerUID::PlayerUID(wstring fromString)
|
|||||||
m_userID = _fromString<int>(userIDDigits);
|
m_userID = _fromString<int>(userIDDigits);
|
||||||
|
|
||||||
// finally, the onlineID, if there is one
|
// finally, the onlineID, if there is one
|
||||||
wstring onlineID = fromString.substr(15 + userIdLen + 1);
|
std::wstring onlineID = fromString.substr(15 + userIdLen + 1);
|
||||||
if(onlineID.size() > 0)
|
if(onlineID.size() > 0)
|
||||||
{
|
{
|
||||||
wcstombs(m_onlineID, onlineID.c_str(), 16);
|
wcstombs(m_onlineID, onlineID.c_str(), 16);
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ public:
|
|||||||
int GetPrimaryPad();
|
int GetPrimaryPad();
|
||||||
void SetPrimaryPad(int iPad);
|
void SetPrimaryPad(int iPad);
|
||||||
char* GetGamertag(int iPad);
|
char* GetGamertag(int iPad);
|
||||||
wstring GetDisplayName(int iPad);
|
std::wstring GetDisplayName(int iPad);
|
||||||
bool IsFullVersion();
|
bool IsFullVersion();
|
||||||
void SetFullVersion(bool bFull);
|
void SetFullVersion(bool bFull);
|
||||||
void SetSignInChangeCallback(void ( *Func)(LPVOID, bool, unsigned int),LPVOID lpParam);
|
void SetSignInChangeCallback(void ( *Func)(LPVOID, bool, unsigned int),LPVOID lpParam);
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
using namespace std;
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <sysutil\sysutil_savedata.h>
|
#include <sysutil\sysutil_savedata.h>
|
||||||
#include <cell/cell_fs.h>
|
#include <cell/cell_fs.h>
|
||||||
|
|||||||
@@ -990,8 +990,8 @@ void PS3LeaderboardManager::initReadScoreStruct(ReadScore &out, SceNpScoreRankDa
|
|||||||
out.m_uid.setOnlineID( rankData.npId.handle, true );
|
out.m_uid.setOnlineID( rankData.npId.handle, true );
|
||||||
out.m_rank = rankData.rank;
|
out.m_rank = rankData.rank;
|
||||||
|
|
||||||
// Convert to wstring and copy name.
|
// Convert to std::wstring and copy name.
|
||||||
wstring wstrName = convStringToWstring( string(rankData.onlineName.data) ).c_str();
|
std::wstring wstrName = convStringToWstring( string(rankData.onlineName.data) ).c_str();
|
||||||
//memcpy(&out.m_name, wstrName.c_str(), XUSER_NAME_SIZE);
|
//memcpy(&out.m_name, wstrName.c_str(), XUSER_NAME_SIZE);
|
||||||
out.m_name=wstrName;
|
out.m_name=wstrName;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
#include "../Passphrase/ps3__np_conf.h"
|
#include "../Passphrase/ps3__np_conf.h"
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
class PS3LeaderboardManager : public LeaderboardManager
|
class PS3LeaderboardManager : public LeaderboardManager
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -592,7 +592,7 @@ bool SQRNetworkManager_PS3::FriendRoomManagerSearch2()
|
|||||||
if( m_searchResultCount )
|
if( m_searchResultCount )
|
||||||
{
|
{
|
||||||
// If we have some results, then we also want to make sure that we don't have any duplicate rooms here if more than one friend is playing in the same room.
|
// If we have some results, then we also want to make sure that we don't have any duplicate rooms here if more than one friend is playing in the same room.
|
||||||
unordered_set<SceNpMatching2RoomId> uniqueRooms;
|
std::unordered_set<SceNpMatching2RoomId> uniqueRooms;
|
||||||
for( unsigned int i = 0; i < m_searchResultCount; i++ )
|
for( unsigned int i = 0; i < m_searchResultCount; i++ )
|
||||||
{
|
{
|
||||||
if(m_aSearchResultRoomFound[ i ])
|
if(m_aSearchResultRoomFound[ i ])
|
||||||
|
|||||||
@@ -205,7 +205,7 @@ private:
|
|||||||
unsigned int m_searchResultCount;
|
unsigned int m_searchResultCount;
|
||||||
|
|
||||||
// Rudp management and local players
|
// Rudp management and local players
|
||||||
unordered_map<int,SQRNetworkPlayer *> m_RudpCtxToPlayerMap;
|
std::unordered_map<int,SQRNetworkPlayer *> m_RudpCtxToPlayerMap;
|
||||||
bool CreateRudpConnections(SceNpMatching2RoomId roomId, SceNpMatching2RoomMemberId peerMemberId, int playerMask, SceNpMatching2RoomMemberId playersPeerMemberId);
|
bool CreateRudpConnections(SceNpMatching2RoomId roomId, SceNpMatching2RoomMemberId peerMemberId, int playerMask, SceNpMatching2RoomMemberId playersPeerMemberId);
|
||||||
SQRNetworkPlayer *GetPlayerFromRudpCtx(int rudpCtx);
|
SQRNetworkPlayer *GetPlayerFromRudpCtx(int rudpCtx);
|
||||||
SQRNetworkPlayer *GetPlayerFromRoomMemberAndLocalIdx(int roomMember, int localIdx);
|
SQRNetworkPlayer *GetPlayerFromRoomMemberAndLocalIdx(int roomMember, int localIdx);
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user