Author SHA1 Message Date
Tropical 77ac64d9e1 chore: remove boost from .gitignore 2026-03-06 12:29:19 -06:00
Tropical c79904f326 Merge branch 'dev' into refactor/no-std-wildcard 2026-03-06 12:25:36 -06:00
Tropical bc7d4ff1d8 refactor: byebye using namespace std
shoo
2026-03-06 12:16:41 -06:00
Tropical 2ed4b1fe9e refactor: unglob std::type_info 2026-03-06 12:14:56 -06:00
Tropical 0855e6ddf4 refactor: unglob std::unordered_set 2026-03-06 12:13:01 -06:00
Tropical 49d02788c0 refactor: unglob std::enable_shared_from_this 2026-03-06 12:04:16 -06:00
Tropical f3ac01c76e refactor: unglob std::(w)ostream 2026-03-06 12:02:08 -06:00
Tropical b9d67d14af refactor: unglob std::endl 2026-03-06 11:59:50 -06:00
Tropical 7c95bfc0bd refactor: begin unglobbing std::vector 2026-03-06 11:58:11 -06:00
Tropical ac9f3cbca3 chore: resolve some void* memset cast warnings 2026-03-06 11:55:28 -06:00
Tropical cdc08700e4 refactor: unglob std::wstring 2026-03-06 11:50:22 -06:00
Tropical 41db813a6d Merge branch 'dev' into refactor/no-std-wildcard 2026-03-06 11:42:05 -06:00
JuiceyDevandGitHub dc57bf5634 Merge pull request #62 from 4jcraft/fix/byte-typealias
fix: remove `byte` type alias
2026-03-06 18:40:36 +01:00
JuiceyDevandGitHub a875a6ef98 Merge pull request #69 from 4jcraft/refactor/optional-llvm-toolchain
refactor(build): make `lld` optional and recommend clang/llvm in README
2026-03-06 18:35:19 +01:00
Tropical ecf7fc7f61 refactor: unglob std::unordered_map 2026-03-06 11:29:36 -06:00
Tropical 67ceccf2d4 refactor: unglob std::shared_ptr 2026-03-06 11:20:45 -06:00
Tropical 79404297d1 docs: remove mention of discord server unavailability 2026-03-06 11:07:07 -06:00
Tropical 6778dc7f92 refactor(build): make lld optional and recommend clang/llvm in README 2026-03-06 10:26:49 -06:00
JuiceyDevandGitHub 14aeba8992 Merge pull request #67 from zukrmn/add-devcontainer-and-fix-deps
docs: add devcontainer and missing libpng-dev dependency
2026-03-06 16:46:27 +01:00
zukrmn ff7276be18 docs: add devcontainer and missing libpng-dev dependency 2026-03-06 15:30:21 +00:00
ThePixelMoon a0c92dacc6 4J.Render: use stb_image 2026-03-06 14:54:55 +02:00
1493 changed files with 16938 additions and 8927 deletions
+36
View File
@@ -0,0 +1,36 @@
FROM mcr.microsoft.com/devcontainers/cpp:1-ubuntu-24.04
ENV DEBIAN_FRONTEND=noninteractive
# Dependencies
RUN apt-get update \
&& apt-get install -y software-properties-common \
&& add-apt-repository -y ppa:ubuntu-toolchain-r/test \
&& apt-get update \
&& apt-get install -y \
build-essential \
cmake \
libglfw3-dev \
libgl-dev \
libglu1-mesa-dev \
libopenal-dev \
libvorbis-dev \
libpng-dev \
libpthread-stubs0-dev \
lld \
meson \
ninja-build \
gcc-15 \
g++-15 \
# Clean up lol
&& apt-get autoremove -y \
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/*
# Set GCC 15 as default
RUN update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-15 100 \
&& update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-15 100 \
&& update-alternatives --install /usr/bin/cc cc /usr/bin/gcc 100 \
&& update-alternatives --install /usr/bin/c++ c++ /usr/bin/g++ 100
ENV DEBIAN_FRONTEND=dialog
+17
View File
@@ -0,0 +1,17 @@
{
"name": "4JCraft Dev Container",
"build": {
"dockerfile": "Dockerfile"
},
"customizations": {
"vscode": {
"settings": {},
"extensions": [
"ms-vscode.cpptools",
"ms-vscode.cpptools-extension-pack",
"mesonbuild.mesonbuild"
]
}
},
"remoteUser": "vscode"
}
+1 -1
View File
@@ -51,7 +51,7 @@ void C_4JProfile::SetPrimaryPad(int iPad) {}
static char s_gamertag[64] = "Player";
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; }
void C_4JProfile::SetSignInChangeCallback(void(*Func)(LPVOID, bool, unsigned int), LPVOID lpParam) {}
void C_4JProfile::SetNotificationsCallback(void(*Func)(LPVOID, DWORD, unsigned int), LPVOID lpParam) {}
+1 -1
View File
@@ -76,7 +76,7 @@ public:
int GetPrimaryPad();
void SetPrimaryPad(int iPad);
char* GetGamertag(int iPad);
wstring GetDisplayName(int iPad);
std::wstring GetDisplayName(int iPad);
bool IsFullVersion();
void SetSignInChangeCallback(void ( *Func)(LPVOID, bool, unsigned int),LPVOID lpParam);
void SetNotificationsCallback(void ( *Func)(LPVOID, DWORD, unsigned int),LPVOID lpParam);
+34 -75
View File
@@ -11,6 +11,9 @@
#include <cmath>
#include <pthread.h>
#define STB_IMAGE_IMPLEMENTATION
#include "stb_image.h"
C4JRender RenderManager;
static GLFWwindow *s_window = nullptr;
@@ -495,106 +498,62 @@ void C4JRender::TextureDynamicUpdateEnd() {}
void C4JRender::Tick() {}
void C4JRender::UpdateGamma(unsigned short) {}
// really don't know if this is nessesary but didn't find any other functions to load images properly as a png..
// im sorry.
#ifdef __linux__
#include <png.h>
#include <stdio.h>
#include <string.h>
static HRESULT LoadPNGFromRows(png_structp png, png_infop info, D3DXIMAGE_INFO *pSrcInfo, int **ppDataOut)
// This sucks, but at least better than libpng
static HRESULT LoadFromSTB(unsigned char* data, int width, int height, D3DXIMAGE_INFO* pSrcInfo, int** ppDataOut)
{
int width = png_get_image_width(png, info);
int height = png_get_image_height(png, info);
png_byte color_type = png_get_color_type(png, info);
png_byte bit_depth = png_get_bit_depth(png, info);
int pixelCount = width * height;
int* pixels = new int[pixelCount];
if (bit_depth == 16) png_set_strip_16(png);
if (color_type == PNG_COLOR_TYPE_PALETTE) png_set_palette_to_rgb(png);
if (color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8) png_set_expand_gray_1_2_4_to_8(png);
if (png_get_valid(png, info, PNG_INFO_tRNS)) png_set_tRNS_to_alpha(png);
if (color_type == PNG_COLOR_TYPE_RGB || color_type == PNG_COLOR_TYPE_GRAY || color_type == PNG_COLOR_TYPE_PALETTE)
png_set_filler(png, 0xFF, PNG_FILLER_AFTER);
if (color_type == PNG_COLOR_TYPE_GRAY || color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
png_set_gray_to_rgb(png);
png_read_update_info(png, info);
unsigned char *buf = new unsigned char[width * height * 4];
png_bytep *rows = new png_bytep[height];
for (int y = 0; y < height; y++)
rows[y] = buf + y * width * 4;
png_read_image(png, rows);
delete[] rows;
// considering i worked on previous projects with raw pngs,,,,,
int *pixels = new int[width * height];
for (int i = 0; i < width * height; i++)
for (int i = 0; i < pixelCount; i++)
{
unsigned char r = buf[i * 4 + 0];
unsigned char g = buf[i * 4 + 1];
unsigned char b = buf[i * 4 + 2];
unsigned char a = buf[i * 4 + 3];
unsigned char r = data[i * 4 + 0];
unsigned char g = data[i * 4 + 1];
unsigned char b = data[i * 4 + 2];
unsigned char a = data[i * 4 + 3];
//pixels[i] = (a << 24) | (b << 16) | (g << 8) | r;
pixels[i] = (a << 24) | (r << 16) | (g << 8) | b;
}
delete[] buf;
pSrcInfo->Width = width;
pSrcInfo->Height = height;
if (pSrcInfo)
{
pSrcInfo->Width = width;
pSrcInfo->Height = height;
}
*ppDataOut = pixels;
return S_OK;
}
HRESULT C4JRender::LoadTextureData(const char *szFilename, D3DXIMAGE_INFO *pSrcInfo, int **ppDataOut)
HRESULT C4JRender::LoadTextureData(const char* szFilename, D3DXIMAGE_INFO* pSrcInfo, int** ppDataOut)
{
FILE *fp = fopen(szFilename, "rb");
if (!fp) return E_FAIL;
int width, height, channels;
png_structp png = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
if (!png) { fclose(fp); return E_FAIL; }
png_infop info = png_create_info_struct(png);
if (!info) { png_destroy_read_struct(&png, NULL, NULL); fclose(fp); return E_FAIL; }
if (setjmp(png_jmpbuf(png))) { png_destroy_read_struct(&png, &info, NULL); fclose(fp); return E_FAIL; }
unsigned char* data = stbi_load(szFilename, &width, &height, &channels, 4);
if (!data)
return E_FAIL;
png_init_io(png, fp);
png_read_info(png, info);
HRESULT hr = LoadFromSTB(data, width, height, pSrcInfo, ppDataOut);
HRESULT hr = LoadPNGFromRows(png, info, pSrcInfo, ppDataOut);
png_destroy_read_struct(&png, &info, NULL);
fclose(fp);
stbi_image_free(data);
return hr;
}
struct PNGMemReader { const unsigned char *data; png_size_t pos; png_size_t size; };
static void png_mem_read(png_structp png, png_bytep out, png_size_t len)
HRESULT C4JRender::LoadTextureData(BYTE* pbData, DWORD dwBytes, D3DXIMAGE_INFO* pSrcInfo, int** ppDataOut)
{
PNGMemReader *r = (PNGMemReader *)png_get_io_ptr(png);
if (r->pos + len > r->size) len = r->size - r->pos;
memcpy(out, r->data + r->pos, len);
r->pos += len;
}
int width, height, channels;
HRESULT C4JRender::LoadTextureData(BYTE *pbData, DWORD dwBytes, D3DXIMAGE_INFO *pSrcInfo, int **ppDataOut)
{
png_structp png = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
if (!png) return E_FAIL;
png_infop info = png_create_info_struct(png);
if (!info) { png_destroy_read_struct(&png, NULL, NULL); return E_FAIL; }
if (setjmp(png_jmpbuf(png))) { png_destroy_read_struct(&png, &info, NULL); return E_FAIL; }
unsigned char* data = stbi_load_from_memory(pbData, dwBytes, &width, &height, &channels, 4);
if (!data)
return E_FAIL;
PNGMemReader reader = { pbData, 0, dwBytes };
png_set_read_fn(png, &reader, png_mem_read);
png_read_info(png, info);
HRESULT hr = LoadFromSTB(data, width, height, pSrcInfo, ppDataOut);
HRESULT hr = LoadPNGFromRows(png, info, pSrcInfo, ppDataOut);
png_destroy_read_struct(&png, &info, NULL);
stbi_image_free(data);
return hr;
}
#else
HRESULT C4JRender::LoadTextureData(const char *szFilename, D3DXIMAGE_INFO *pSrcInfo, int **ppDataOut) { return S_OK; }
HRESULT C4JRender::LoadTextureData(BYTE *pbData, DWORD dwBytes, D3DXIMAGE_INFO *pSrcInfo, int **ppDataOut) { return S_OK; }
#endif
HRESULT C4JRender::SaveTextureData(const char *szFilename, D3DXIMAGE_INFO *pSrcInfo, int *ppDataOut) { return S_OK; }
HRESULT C4JRender::SaveTextureDataToMemory(void *pOutput, int outputCapacity, int *outputLength, int width, int height, int *ppDataIn) { return S_OK; }
void C4JRender::TextureGetStats() {}
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -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_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);
// 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);
// enum eXBLWS
+1 -1
View File
@@ -265,7 +265,7 @@ typedef struct _LaunchMoreOptionsMenuInitData
_LaunchMoreOptionsMenuInitData()
{
memset(this,0,sizeof(_LaunchMoreOptionsMenuInitData));
memset((void*)this,0,sizeof(_LaunchMoreOptionsMenuInitData));
bOnlineGame = TRUE;
bAllowFriendsOfFriends = TRUE;
bPVP = TRUE;
+1 -1
View File
@@ -500,7 +500,7 @@ void SetFakeGamertag(char *name){ strcpy_s(fakeGamerTag, name); }
char* C_4JProfile::GetGamertag(int iPad){ return fakeGamerTag; }
#else
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
bool C_4JProfile::IsFullVersion() { return s_bProfileIsFullVersion; }
void C_4JProfile::SetSignInChangeCallback(void ( *Func)(LPVOID, bool, unsigned int),LPVOID lpParam) {}
+2 -2
View File
@@ -229,7 +229,7 @@ class ZipFile
public:
ZipFile(File *file) {}
InputStream *getInputStream(ZipEntry *entry) { return NULL; }
ZipEntry *getEntry(const wstring& name) {return NULL;}
ZipEntry *getEntry(const std::wstring& name) {return NULL;}
void close() {}
};
@@ -245,7 +245,7 @@ public:
static void create() {}
static void destroy() {}
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 const int KEY_A = 0;
static const int KEY_B = 1;
+1 -1
View File
@@ -1,4 +1,4 @@
#include "Build/stdafx.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;
+2 -2
View File
@@ -1,5 +1,5 @@
#pragma once
using namespace std;
class ClientConstants
{
@@ -12,7 +12,7 @@ class ClientConstants
// INTERNAL DEVELOPMENT SETTINGS
public:
static const wstring VERSION_STRING;
static const std::wstring VERSION_STRING;
static const bool DEADMAU5_CAMERA_CHEATS = false;
static const bool IS_DEMO_VERSION = false;
@@ -14,7 +14,7 @@ EGameCommand TeleportCommand::getId()
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);
DataInputStream dis(&bais);
@@ -26,8 +26,8 @@ void TeleportCommand::execute(shared_ptr<CommandSender> source, byteArray comman
PlayerList *players = MinecraftServer::getInstance()->getPlayerList();
shared_ptr<ServerPlayer> subject = players->getPlayer(subjectID);
shared_ptr<ServerPlayer> destination = players->getPlayer(destinationID);
std::shared_ptr<ServerPlayer> subject = players->getPlayer(subjectID);
std::shared_ptr<ServerPlayer> destination = players->getPlayer(destinationID);
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;
DataOutputStream dos(&baos);
@@ -86,5 +86,5 @@ shared_ptr<GameCommandPacket> TeleportCommand::preparePacket(PlayerUID subject,
dos.writePlayerUID(subject);
dos.writePlayerUID(destination);
return shared_ptr<GameCommandPacket>( new GameCommandPacket(eGameCommand_Teleport, baos.toByteArray() ));
return std::shared_ptr<GameCommandPacket>( new GameCommandPacket(eGameCommand_Teleport, baos.toByteArray() ));
}
+2 -2
View File
@@ -6,7 +6,7 @@ class TeleportCommand : public Command
{
public:
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);
};
+5 -5
View File
@@ -21,7 +21,7 @@ void CreativeMode::init()
// initPlayer();
}
void CreativeMode::enableCreativeForPlayer(shared_ptr<Player> player)
void CreativeMode::enableCreativeForPlayer(std::shared_ptr<Player> player)
{
// please check ServerPlayerGameMode.java if you change these
player->abilities.mayfly = true;
@@ -29,7 +29,7 @@ void CreativeMode::enableCreativeForPlayer(shared_ptr<Player> player)
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.flying = false;
@@ -37,7 +37,7 @@ void CreativeMode::disableCreativeForPlayer(shared_ptr<Player> player)
player->abilities.invulnerable = false;
}
void CreativeMode::adjustPlayer(shared_ptr<Player> player)
void CreativeMode::adjustPlayer(std::shared_ptr<Player> player)
{
enableCreativeForPlayer(player);
@@ -45,7 +45,7 @@ void CreativeMode::adjustPlayer(shared_ptr<Player> player)
{
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
{
@@ -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);
if (t > 0)
+4 -4
View File
@@ -9,11 +9,11 @@ private:
public:
CreativeMode(Minecraft *minecraft);
virtual void init();
static void enableCreativeForPlayer(shared_ptr<Player> player);
static void disableCreativeForPlayer(shared_ptr<Player> player);
virtual void adjustPlayer(shared_ptr<Player> player);
static void enableCreativeForPlayer(std::shared_ptr<Player> player);
static void disableCreativeForPlayer(std::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);
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 continueDestroyBlock(int x, int y, int z, int face);
virtual void stopDestroyBlock();
+4 -4
View File
@@ -32,7 +32,7 @@ void DemoMode::tick()
else if (day == 1)
{
Options *options = minecraft->options;
wstring message;
std::wstring message;
if (time == 100) {
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);
}
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)
{
@@ -105,7 +105,7 @@ bool DemoMode::useItem(shared_ptr<Player> player, Level *level, shared_ptr<ItemI
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) {
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);
}
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)
{
+3 -3
View File
@@ -21,7 +21,7 @@ public:
virtual void startDestroyBlock(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 useItem(shared_ptr<Player> player, Level *level, 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 void attack(shared_ptr<Player> player, shared_ptr<Entity> entity);
virtual bool useItem(std::shared_ptr<Player> player, Level *level, std::shared_ptr<ItemInstance> item);
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(std::shared_ptr<Player> player, std::shared_ptr<Entity> entity);
};
+15 -15
View File
@@ -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
// 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);
}
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);
}
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;
}
void GameMode::handleCloseInventory(int containerId, shared_ptr<Player> player)
void GameMode::handleCloseInventory(int containerId, std::shared_ptr<Player> player)
{
player->containerMenu->removed(player);
delete player->containerMenu;
@@ -138,7 +138,7 @@ bool GameMode::isCutScene()
return false;
}
void GameMode::releaseUsingItem(shared_ptr<Player> player)
void GameMode::releaseUsingItem(std::shared_ptr<Player> player)
{
player->releaseUsingItem();
}
@@ -163,21 +163,21 @@ bool GameMode::hasFarPickRange()
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;
}
// 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);
}
+14 -14
View File
@@ -25,32 +25,32 @@ public:
virtual void stopDestroyBlock() = 0;
virtual void render(float a);
virtual float getPickRange() = 0;
virtual void initPlayer(shared_ptr<Player> player);
virtual void initPlayer(std::shared_ptr<Player> player);
virtual void tick();
virtual bool canHurtPlayer() = 0;
virtual void adjustPlayer(shared_ptr<Player> player);
virtual bool useItem(shared_ptr<Player> player, Level *level, 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 void adjustPlayer(std::shared_ptr<Player> player);
virtual bool useItem(std::shared_ptr<Player> player, Level *level, std::shared_ptr<ItemInstance> item, bool bTestUseOnly=false);
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 bool interact(shared_ptr<Player> player, shared_ptr<Entity> entity);
virtual void attack(shared_ptr<Player> player, shared_ptr<Entity> entity);
virtual shared_ptr<ItemInstance> handleInventoryMouseClick(int containerId, int slotNum, int buttonNum, bool quickKeyHeld, shared_ptr<Player> player);
virtual void handleCloseInventory(int containerId, shared_ptr<Player> player);
virtual std::shared_ptr<Player> createPlayer(Level *level);
virtual bool interact(std::shared_ptr<Player> player, std::shared_ptr<Entity> entity);
virtual void attack(std::shared_ptr<Player> player, std::shared_ptr<Entity> entity);
virtual std::shared_ptr<ItemInstance> handleInventoryMouseClick(int containerId, int slotNum, int buttonNum, bool quickKeyHeld, std::shared_ptr<Player> player);
virtual void handleCloseInventory(int containerId, std::shared_ptr<Player> player);
virtual void handleInventoryButtonClick(int containerId, int buttonId);
virtual bool isCutScene();
virtual void releaseUsingItem(shared_ptr<Player> player);
virtual void releaseUsingItem(std::shared_ptr<Player> player);
virtual bool hasExperience();
virtual bool hasMissTime();
virtual bool hasInfiniteItems();
virtual bool hasFarPickRange();
virtual void handleCreativeModeItemAdd(shared_ptr<ItemInstance> clicked, int i);
virtual void handleCreativeModeItemDrop(shared_ptr<ItemInstance> clicked);
virtual void handleCreativeModeItemAdd(std::shared_ptr<ItemInstance> clicked, int i);
virtual void handleCreativeModeItemDrop(std::shared_ptr<ItemInstance> clicked);
// 4J Stu - Added so we can send packets for this in the network game
virtual bool handleCraftItem(int recipe, shared_ptr<Player> player);
virtual void handleDebugOptions(unsigned int uiVal, shared_ptr<Player> player);
virtual bool handleCraftItem(int recipe, std::shared_ptr<Player> player);
virtual void handleDebugOptions(unsigned int uiVal, std::shared_ptr<Player> player);
// 4J Stu - Added for tutorial checks
virtual bool isInputAllowed(int mapping) { return true; }
+22 -22
View File
@@ -60,7 +60,7 @@ const Options::Option *Options::Option::getItem(int 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);
}
wstring Options::Option::getCaptionId() const
std::wstring Options::Option::getCaptionId() const
{
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"
};
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"
};
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"
};
const wstring Options::FRAMERATE_LIMITS[] =
const std::wstring Options::FRAMERATE_LIMITS[] =
{
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"
};
@@ -184,13 +184,13 @@ Options::Options()
init();
}
wstring Options::getKeyDescription(int i)
std::wstring Options::getKeyDescription(int i)
{
Language *language = Language::getInstance();
return language->getElement(keyMappings[i]->name);
}
wstring Options::getKeyMessage(int i)
std::wstring Options::getKeyMessage(int i)
{
int key = keyMappings[i]->key;
if (key < 0) {
@@ -307,12 +307,12 @@ bool Options::getBooleanValue(const Options::Option *item)
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();
wstring caption = language->getElement(item->getCaptionId()) + L": ";
std::wstring caption = language->getElement(item->getCaptionId()) + L": ";
if (item->isProgress())
{
@@ -411,14 +411,14 @@ void Options::load()
// 4J - was new BufferedReader(new FileReader(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?
{
// 4J - removed try/catch
// try {
wstring cmds[2];
std::wstring cmds[2];
int splitpos = (int)line.find(L":");
if( splitpos == wstring::npos )
if( splitpos == std::wstring::npos )
{
cmds[0] = line;
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"false") return 0;
@@ -488,20 +488,20 @@ void Options::save()
dos.writeChars(L"music:" + _toString<float>(music) + 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"fov:" + _toString<float>(fov));
dos.writeChars(L"gamma:" + _toString<float>(gamma));
dos.writeChars(L"viewDistance:" + _toString<int>(viewDistance));
dos.writeChars(L"guiScale:" + _toString<int>(guiScale));
dos.writeChars(L"particles:" + _toString<int>(particles));
dos.writeChars(L"bobView:" + wstring(bobView ? L"true" : L"false"));
dos.writeChars(L"anaglyph3d:" + wstring(anaglyph3d ? L"true" : L"false"));
dos.writeChars(L"advancedOpengl:" + wstring(advancedOpengl ? L"true" : L"false"));
dos.writeChars(L"bobView:" + std::wstring(bobView ? L"true" : L"false"));
dos.writeChars(L"anaglyph3d:" + std::wstring(anaglyph3d ? 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"difficulty:" + _toString<int>(difficulty));
dos.writeChars(L"fancyGraphics:" + wstring(fancyGraphics ? L"true" : L"false"));
dos.writeChars(L"ao:" + wstring(ambientOcclusion ? L"true" : L"false"));
dos.writeChars(L"fancyGraphics:" + std::wstring(fancyGraphics ? 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"skin:" + skin);
dos.writeChars(L"lastServer:" + lastMpIp);
+15 -15
View File
@@ -1,5 +1,5 @@
#pragma once
using namespace std;
class Minecraft;
class KeyMapping;
#include "../../Minecraft.World/IO/Files/File.h"
@@ -37,24 +37,24 @@ public:
private:
const bool _isProgress;
const bool _isBoolean;
const wstring captionId;
const std::wstring captionId;
public:
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 isBoolean() const;
int getId() const;
wstring getCaptionId() const;
std::wstring getCaptionId() const;
};
private:
static const wstring RENDER_DISTANCE_NAMES[];
static const wstring DIFFICULTY_NAMES[];
static const wstring GUI_SCALE[];
static const wstring FRAMERATE_LIMITS[];
static const wstring PARTICLES[];
static const std::wstring RENDER_DISTANCE_NAMES[];
static const std::wstring DIFFICULTY_NAMES[];
static const std::wstring GUI_SCALE[];
static const std::wstring FRAMERATE_LIMITS[];
static const std::wstring PARTICLES[];
public:
float music;
@@ -69,7 +69,7 @@ public:
bool fancyGraphics;
bool ambientOcclusion;
bool renderClouds;
wstring skin;
std::wstring skin;
KeyMapping *keyUp;
KeyMapping *keyLeft;
@@ -99,7 +99,7 @@ public:
bool hideGui;
bool thirdPersonView;
bool renderDebug;
wstring lastMpIp;
std::wstring lastMpIp;
bool isFlying;
bool smoothCamera;
@@ -114,17 +114,17 @@ public:
void init(); // 4J added
Options(Minecraft *minecraft, File workingDirectory);
Options();
wstring getKeyDescription(int i);
wstring getKeyMessage(int i);
std::wstring getKeyDescription(int i);
std::wstring getKeyMessage(int i);
void setKey(int i, int key);
void set(const Options::Option *item, float value);
void toggle(const Options::Option *option, int dir);
float getProgressValue(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();
private:
float readFloat(wstring string);
float readFloat(std::wstring string);
public:
void save();
+4 -4
View File
@@ -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())
{
@@ -25,7 +25,7 @@ wstring Settings::getString(const wstring& key, const wstring& defaultValue)
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())
{
@@ -35,7 +35,7 @@ int Settings::getInt(const wstring& key, int defaultValue)
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())
{
@@ -48,7 +48,7 @@ bool Settings::getBoolean(const wstring& key, bool defaultValue)
return retval;
}
void Settings::setBooleanAndSave(const wstring& key, bool value)
void Settings::setBooleanAndSave(const std::wstring& key, bool value)
{
properties[key] = _toString<bool>(value);
saveProperties();
+6 -6
View File
@@ -1,21 +1,21 @@
#pragma once
class File;
using namespace std;
class Settings
{
// public static Logger logger = Logger.getLogger("Minecraft");
// private Properties properties = new Properties();
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;
public:
Settings(File *file);
void generateNewProperties();
void saveProperties();
wstring getString(const wstring& key, const wstring& defaultValue);
int getInt(const wstring& key, int defaultValue);
bool getBoolean(const wstring& key, bool defaultValue);
void setBooleanAndSave(const wstring& key, bool value);
std::wstring getString(const std::wstring& key, const std::wstring& defaultValue);
int getInt(const std::wstring& key, int defaultValue);
bool getBoolean(const std::wstring& key, bool defaultValue);
void setBooleanAndSave(const std::wstring& key, bool value);
};
+8 -8
View File
@@ -22,7 +22,7 @@ Stat** StatsCounter::LARGE_STATS[] = {
&Stats::timePlayed
};
unordered_map<Stat*, int> StatsCounter::statBoards;
std::unordered_map<Stat*, int> StatsCounter::statBoards;
StatsCounter::StatsCounter()
{
@@ -64,7 +64,7 @@ void StatsCounter::award(Stat* stat, unsigned int difficulty, unsigned int count
requiresSave = true;
//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() )
{
app.DebugPrintf("[StatsCounter] award(): %X\n", leaderboardEntry->second << difficulty);
@@ -150,8 +150,8 @@ void StatsCounter::parse(void* data)
StatContainer newVal;
//For each stat
vector<Stat *>::iterator end = Stats::all->end();
for( vector<Stat *>::iterator iter = Stats::all->begin() ; iter != end ; ++iter )
std::vector<Stat *>::iterator end = Stats::all->end();
for( std::vector<Stat *>::iterator iter = Stats::all->begin() ; iter != end ; ++iter )
{
if( !(*iter)->isAchievement() )
{
@@ -230,8 +230,8 @@ void StatsCounter::save(int player, bool force)
//For each stat
StatsMap::iterator val;
vector<Stat *>::iterator end = Stats::all->end();
for( vector<Stat *>::iterator iter = Stats::all->begin() ; iter != end ; ++iter )
std::vector<Stat *>::iterator end = Stats::all->end();
for( std::vector<Stat *>::iterator iter = Stats::all->begin() ; iter != end ; ++iter )
{
//If the stat is in the map write out it's value
val = stats.find(*iter);
@@ -1283,8 +1283,8 @@ bool StatsCounter::isLargeStat(Stat* stat)
void StatsCounter::dumpStatsToTTY()
{
vector<Stat*>::iterator statsEnd = Stats::all->end();
for( vector<Stat*>::iterator statsIter = Stats::all->begin() ; statsIter!=statsEnd ; ++statsIter )
std::vector<Stat*>::iterator statsEnd = Stats::all->end();
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",
(*statsIter)->name.c_str(),
+3 -3
View File
@@ -3,7 +3,7 @@ class Stat;
class Achievement;
class StatsSyncher;
class User;
using namespace std;
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 LARGE_STATS_COUNT = 8;
@@ -69,7 +69,7 @@ private:
int saveCounter;
int modifiedBoards;
static unordered_map<Stat*, int> statBoards;
static std::unordered_map<Stat*, int> statBoards;
int flushCounter;
public:
+13 -13
View File
@@ -4,7 +4,7 @@ class StatsCounter;
class User;
class File;
class Stat;
using namespace std;
class StatsSyncher
{
@@ -14,8 +14,8 @@ private:
volatile bool busy;
volatile unordered_map<Stat *, int> *serverStats;
volatile unordered_map<Stat *, int> *failedSentStats;
volatile std::unordered_map<Stat *, int> *serverStats;
volatile std::unordered_map<Stat *, int> *failedSentStats;
StatsCounter *statsCounter;
File *unsentFile, *lastServerFile;
@@ -28,19 +28,19 @@ private:
public:
StatsSyncher(User *user, StatsCounter *statsCounter, File *dir);
private:
void attemptRename(File *dir, const wstring& name, File *to);
unordered_map<Stat *, int> *loadStatsFromDisk(File *file, File *tmp, File *old);
unordered_map<Stat *, int> *loadStatsFromDisk(File *file);
void doSend(unordered_map<Stat *, int> *stats);
void doSave(unordered_map<Stat *, int> *stats, File *file, File *tmp, File *old);
void attemptRename(File *dir, const std::wstring& name, File *to);
std::unordered_map<Stat *, int> *loadStatsFromDisk(File *file, File *tmp, File *old);
std::unordered_map<Stat *, int> *loadStatsFromDisk(File *file);
void doSend(std::unordered_map<Stat *, int> *stats);
void doSave(std::unordered_map<Stat *, int> *stats, File *file, File *tmp, File *old);
protected:
unordered_map<Stat *, int> *doGetStats();
std::unordered_map<Stat *, int> *doGetStats();
public:
void getStatsFromServer();
void saveUnsent(unordered_map<Stat *, int> *stats);
void sendUnsent(unordered_map<Stat *, int> *stats, unordered_map<Stat *, int> *fullStats);
void forceSendUnsent(unordered_map<Stat *, int> *stats);
void forceSaveUnsent(unordered_map<Stat *, int> *stats);
void saveUnsent(std::unordered_map<Stat *, int> *stats);
void sendUnsent(std::unordered_map<Stat *, int> *stats, std::unordered_map<Stat *, int> *fullStats);
void forceSendUnsent(std::unordered_map<Stat *, int> *stats);
void forceSaveUnsent(std::unordered_map<Stat *, int> *stats);
bool maySave();
bool maySend();
void tick();
+5 -5
View File
@@ -45,7 +45,7 @@ SurvivalMode::SurvivalMode(SurvivalMode *copy) : GameMode( copy->minecraft )
destroyDelay = copy->destroyDelay;
}
void SurvivalMode::initPlayer(shared_ptr<Player> player)
void SurvivalMode::initPlayer(std::shared_ptr<Player> player)
{
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);
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]);
if (item != NULL)
{
@@ -173,9 +173,9 @@ void SurvivalMode::initLevel(Level *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.hatchet_diamond));
// player.inventory.add(new ItemInstance(Tile.torch, 64));
@@ -191,7 +191,7 @@ void SurvivalMode::tick()
//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);
if (t > 0)
+3 -3
View File
@@ -15,7 +15,7 @@ private:
public:
SurvivalMode(Minecraft *minecraft);
SurvivalMode(SurvivalMode *copy);
virtual void initPlayer(shared_ptr<Player> player);
virtual void initPlayer(std::shared_ptr<Player> player);
virtual void init();
virtual bool canHurtPlayer();
virtual bool destroyBlock(int x, int y, int z, int face);
@@ -25,8 +25,8 @@ public:
virtual void render(float a);
virtual float getPickRange();
virtual void initLevel(Level *level);
virtual shared_ptr<Player> createPlayer(Level *level);
virtual std::shared_ptr<Player> createPlayer(Level *level);
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();
};
+1 -1
View File
@@ -1,7 +1,7 @@
#include "../Build/stdafx.h"
#include "ConsoleInput.h"
ConsoleInput::ConsoleInput(const wstring& msg, ConsoleInputSource *source)
ConsoleInput::ConsoleInput(const std::wstring& msg, ConsoleInputSource *source)
{
this->msg = msg;
this->source = source;
+3 -3
View File
@@ -1,12 +1,12 @@
#pragma once
#include "ConsoleInputSource.h"
using namespace std;
class ConsoleInput
{
public:
wstring msg;
std::wstring msg;
ConsoleInputSource *source;
ConsoleInput(const wstring& msg, ConsoleInputSource *source);
ConsoleInput(const std::wstring& msg, ConsoleInputSource *source);
};
+3 -3
View File
@@ -3,7 +3,7 @@
class ConsoleInputSource
{
public:
virtual void info(const wstring& string) = 0;
virtual void warn(const wstring& string) = 0;
virtual wstring getConsoleName() = 0;
virtual void info(const std::wstring& string) = 0;
virtual void warn(const std::wstring& string) = 0;
virtual std::wstring getConsoleName() = 0;
};
+1 -1
View File
@@ -1,7 +1,7 @@
#include "../Build/stdafx.h"
#include "KeyMapping.h"
KeyMapping::KeyMapping(const wstring& name, int key)
KeyMapping::KeyMapping(const std::wstring& name, int key)
{
this->name = name;
this->key = key;
+3 -3
View File
@@ -1,10 +1,10 @@
#pragma once
using namespace std;
// 4J Stu - Not updated to 1.8.2 as we don't use this
class KeyMapping
{
public:
wstring name;
std::wstring name;
int key;
KeyMapping(const wstring& name, int key);
KeyMapping(const std::wstring& name, int key);
};
+1 -1
View File
@@ -11,7 +11,7 @@ LevelSettings DemoLevel::DEMO_LEVEL_SETTINGS = LevelSettings(
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)
{
}
+1 -1
View File
@@ -10,7 +10,7 @@ private:
static const int DEMO_SPAWN_Z = -731;
static LevelSettings DEMO_LEVEL_SETTINGS;
public:
DemoLevel(shared_ptr<LevelStorage> levelStorage, const wstring& levelName);
DemoLevel(std::shared_ptr<LevelStorage> levelStorage, const std::wstring& levelName);
DemoLevel(Level *level, Dimension *dimension);
protected:
virtual void setInitialSpawn();
@@ -3,7 +3,7 @@
#include "../../Minecraft.World/Level/Storage/SavedDataStorage.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)
{
// 4J-PB - we're going to override the savedDataStorage, so we need to delete the current one
+1 -1
View File
@@ -4,7 +4,7 @@
class DerivedServerLevel : public ServerLevel
{
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();
protected:
+21 -21
View File
@@ -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)
: 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();
@@ -108,7 +108,7 @@ void MultiPlayerLevel::tick()
EnterCriticalSection(&m_entitiesCS);
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);
}
@@ -117,7 +117,7 @@ void MultiPlayerLevel::tick()
PIXBeginNamedEvent(0,"Connection ticking");
// 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 )
{
(*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);
forced.insert(e);
@@ -416,7 +416,7 @@ bool MultiPlayerLevel::addEntity(shared_ptr<Entity> e)
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,
// in particular the MultiPlayerLocalPlayer when they die
@@ -430,7 +430,7 @@ void MultiPlayerLevel::removeEntity(shared_ptr<Entity> e)
forced.erase(e);
}
void MultiPlayerLevel::entityAdded(shared_ptr<Entity> e)
void MultiPlayerLevel::entityAdded(std::shared_ptr<Entity> e)
{
Level::entityAdded(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);
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)
{
removeEntity(old);
@@ -467,16 +467,16 @@ void MultiPlayerLevel::putEntity(int id, shared_ptr<Entity> 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));
if( it == entitiesById.end() ) return nullptr;
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));
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
// 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)
{
shared_ptr<Entity> e = *it;
std::shared_ptr<Entity> e = *it;
AUTO_VAR(reIt, reEntries.find(e));
if (reIt!=reEntries.end())
@@ -609,7 +609,7 @@ void MultiPlayerLevel::disconnect(bool sendDisconnect /*= true*/)
{
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
@@ -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);
}
@@ -790,7 +790,7 @@ void MultiPlayerLevel::removeAllPendingEntityRemovals()
AUTO_VAR(endIt, entitiesToRemove.end());
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 zc = e->zChunk;
if (e->inChunk && hasChunk(xc, zc))
@@ -809,10 +809,10 @@ void MultiPlayerLevel::removeAllPendingEntityRemovals()
//for (int i = 0; i < entities.size(); i++)
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() )
{
shared_ptr<Entity> e = *it;//entities.at(i);
std::shared_ptr<Entity> e = *it;//entities.at(i);
if (e->riding != NULL)
{
@@ -853,7 +853,7 @@ void MultiPlayerLevel::removeClientConnection(ClientConnection *c, bool sendDisc
{
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 ));
@@ -886,7 +886,7 @@ void MultiPlayerLevel::removeUnusedTileEntitiesInRegion(int x0, int y0, int z0,
for (unsigned int i = 0; i < tileEntityList.size();)
{
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)
{
LevelChunk *lc = getChunk(te->x >> 4, te->z >> 4);
+17 -17
View File
@@ -1,5 +1,5 @@
#pragma once
using namespace std;
#include "../../Minecraft.World/Util/HashExtension.h"
#include "../../Minecraft.World/Headers/net.minecraft.world.level.h"
#include "../../Minecraft.World/Headers/net.minecraft.world.entity.h"
@@ -8,7 +8,7 @@ using namespace std;
class ClientConnection;
class MultiPlayerChunkCache;
using namespace std;
class MultiPlayerLevel : public Level
{
@@ -22,7 +22,7 @@ private:
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
public:
void unshareChunkAt(int x, int z); // 4J - added
@@ -34,7 +34,7 @@ private:
int unshareCheckZ; // 4J - added
int compressCheckX; // 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;
Minecraft *minecraft;
@@ -54,21 +54,21 @@ public:
void setChunkVisible(int x, int z, bool visible);
private:
unordered_map<int, shared_ptr<Entity>, IntKeyHash2, IntKeyEq> entitiesById; // 4J - was IntHashMap
unordered_set<shared_ptr<Entity> > forced;
unordered_set<shared_ptr<Entity> > reEntries;
std::unordered_map<int, std::shared_ptr<Entity>, IntKeyHash2, IntKeyEq> entitiesById; // 4J - was IntHashMap
std::unordered_set<std::shared_ptr<Entity> > forced;
std::unordered_set<std::shared_ptr<Entity> > reEntries;
public:
virtual bool addEntity(shared_ptr<Entity> e);
virtual void removeEntity(shared_ptr<Entity> e);
virtual bool addEntity(std::shared_ptr<Entity> e);
virtual void removeEntity(std::shared_ptr<Entity> e);
protected:
virtual void entityAdded(shared_ptr<Entity> e);
virtual void entityRemoved(shared_ptr<Entity> e);
virtual void entityAdded(std::shared_ptr<Entity> e);
virtual void entityRemoved(std::shared_ptr<Entity> e);
public:
void putEntity(int id, shared_ptr<Entity> e);
shared_ptr<Entity> getEntity(int id);
shared_ptr<Entity> removeEntity(int id);
virtual void removeEntities(vector<shared_ptr<Entity> > *list); // 4J Added override
void putEntity(int id, std::shared_ptr<Entity> e);
std::shared_ptr<Entity> getEntity(int id);
std::shared_ptr<Entity> removeEntity(int id);
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 setTileAndDataNoUpdate(int x, int y, int z, int tile, int data);
virtual bool setTileNoUpdate(int x, int y, int z, int tile);
@@ -82,12 +82,12 @@ protected:
public:
void animateTickDoWork(); // 4J added
unordered_set<int> chunksToAnimate; // 4J added
std::unordered_set<int> chunksToAnimate; // 4J added
public:
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);
+40 -40
View File
@@ -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_tickNextTickCS);
@@ -277,10 +277,10 @@ void ServerLevel::tick()
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;
return (Biome::MobSpawnerData *) WeighedRandom::getRandomItem(random, (vector<WeighedRandomItem *> *)mobList);
return (Biome::MobSpawnerData *) WeighedRandom::getRandomItem(random, (std::vector<WeighedRandomItem *> *)mobList);
}
void ServerLevel::updateSleepingPlayerList()
@@ -289,7 +289,7 @@ void ServerLevel::updateSleepingPlayerList()
m_bAtLeastOnePlayerSleeping = false;
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())
{
@@ -310,7 +310,7 @@ void ServerLevel::awakenAllPlayers()
m_bAtLeastOnePlayerSleeping = false;
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())
{
@@ -335,7 +335,7 @@ bool ServerLevel::allPlayersAreSleeping()
{
// all players are sleeping, but have they slept long enough?
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());
if (! (*it)->isSleepingLongEnough())
@@ -467,7 +467,7 @@ void ServerLevel::tickTiles()
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;
}
}
@@ -625,10 +625,10 @@ bool ServerLevel::tickPendingTicks(bool force)
return retval;
}
vector<TickNextTickData> *ServerLevel::fetchTicksInChunk(LevelChunk *chunk, bool remove)
std::vector<TickNextTickData> *ServerLevel::fetchTicksInChunk(LevelChunk *chunk, bool remove)
{
EnterCriticalSection(&m_tickNextTickCS);
vector<TickNextTickData> *results = new vector<TickNextTickData>;
std::vector<TickNextTickData> *results = new std::vector<TickNextTickData>;
ChunkPos *pos = chunk->getPos();
int west = pos->x << 4;
@@ -665,7 +665,7 @@ vector<TickNextTickData> *ServerLevel::fetchTicksInChunk(LevelChunk *chunk, bool
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)))
{
@@ -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);
}
@@ -693,12 +693,12 @@ ChunkSource *ServerLevel::createChunkSource()
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++)
{
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)
{
result->push_back(te);
@@ -707,7 +707,7 @@ vector<shared_ptr<TileEntity> > *ServerLevel::getTileEntitiesInRegion(int x0, in
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
// We'll need to do this in a future update
@@ -750,7 +750,7 @@ void ServerLevel::setInitialSpawn(LevelSettings *levelSettings)
isFindingSpawn = true;
BiomeSource *biomeSource = dimension->biomeSource;
vector<Biome *> playerSpawnBiomes = biomeSource->getPlayerSpawnBiomes();
std::vector<Biome *> playerSpawnBiomes = biomeSource->getPlayerSpawnBiomes();
Random random(getSeed());
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 )
{
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->isBonusChest )
@@ -896,7 +896,7 @@ void ServerLevel::save(bool force, ProgressListener *progressListener, bool bAut
{
// 4J Stu - This will come in a later change anyway
// clean cache
vector<LevelChunk *> *loadedChunkList = cache->getLoadedChunkList();
std::vector<LevelChunk *> *loadedChunkList = cache->getLoadedChunkList();
for (AUTO_VAR(it, loadedChunkList->begin()); it != loadedChunkList->end(); ++it)
{
LevelChunk *lc = *it;
@@ -948,11 +948,11 @@ void ServerLevel::saveLevelData()
savedDataStorage->save();
}
void ServerLevel::entityAdded(shared_ptr<Entity> e)
void ServerLevel::entityAdded(std::shared_ptr<Entity> e)
{
Level::entityAdded(e);
entitiesById[e->entityId] = e;
vector<shared_ptr<Entity> > *es = e->getSubEntities();
std::vector<std::shared_ptr<Entity> > *es = e->getSubEntities();
if (es != NULL)
{
//for (int i = 0; i < es.length; i++)
@@ -964,11 +964,11 @@ void ServerLevel::entityAdded(shared_ptr<Entity> e)
entityAddedExtra(e); // 4J added
}
void ServerLevel::entityRemoved(shared_ptr<Entity> e)
void ServerLevel::entityRemoved(std::shared_ptr<Entity> e)
{
Level::entityRemoved(e);
entitiesById.erase(e->entityId);
vector<shared_ptr<Entity> > *es = e->getSubEntities();
std::vector<std::shared_ptr<Entity> > *es = e->getSubEntities();
if (es != NULL)
{
//for (int i = 0; i < es.length; i++)
@@ -980,32 +980,32 @@ void ServerLevel::entityRemoved(shared_ptr<Entity> e)
entityRemovedExtra(e); // 4J added
}
shared_ptr<Entity> ServerLevel::getEntity(int id)
std::shared_ptr<Entity> ServerLevel::getEntity(int id)
{
return entitiesById[id];
}
bool ServerLevel::addGlobalEntity(shared_ptr<Entity> e)
bool ServerLevel::addGlobalEntity(std::shared_ptr<Entity> 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 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);
}
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
// 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->destroyBlocks = destroyBlocks;
explosion->explode();
@@ -1016,10 +1016,10 @@ shared_ptr<Explosion> ServerLevel::explode(shared_ptr<Entity> source, double x,
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)
{
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;
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++ )
{
shared_ptr<ServerPlayer> player2 = sentTo[j];
std::shared_ptr<ServerPlayer> player2 = sentTo[j];
INetworkPlayer *otherPlayer = player2->connection->getNetworkPlayer();
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);
//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
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 );
}
}
@@ -1088,7 +1088,7 @@ void ServerLevel::runTileEvents()
if (doTileEvent(&(*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();
@@ -1119,11 +1119,11 @@ void ServerLevel::tickWeather()
{
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
{
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();
// 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.
vector<TickNextTickData> temp;
std::vector<TickNextTickData> temp;
for(AUTO_VAR(it, tickNextTickList.begin()); it != tickNextTickList.end(); ++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
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( 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
void ServerLevel::entityAddedExtra(shared_ptr<Entity> e)
void ServerLevel::entityAddedExtra(std::shared_ptr<Entity> e)
{
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
void ServerLevel::entityRemovedExtra(shared_ptr<Entity> e)
void ServerLevel::entityRemovedExtra(std::shared_ptr<Entity> e)
{
if( dynamic_pointer_cast<ItemEntity>(e) != NULL )
{
+24 -24
View File
@@ -6,7 +6,7 @@ class MinecraftServer;
class Node;
class EntityTracker;
class PlayerChunkMap;
using namespace std;
class ServerLevel : public Level
{
@@ -19,9 +19,9 @@ private:
CRITICAL_SECTION m_tickNextTickCS; // 4J added
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;
protected:
@@ -37,11 +37,11 @@ private:
bool m_bAtLeastOnePlayerSleeping; // 4J Added
static WeighedTreasureArray RANDOM_BONUS_ITEMS; // 4J - brought forward from 1.3.2
vector<TileEventData> tileEvents[2];
std::vector<TileEventData> tileEvents[2];
int activeTileEventsList;
public:
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();
void tick();
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 tickEntities();
bool tickPendingTicks(bool force);
vector<TickNextTickData> *fetchTicksInChunk(LevelChunk *chunk, bool remove);
virtual void tick(shared_ptr<Entity> e, bool actual);
void forceTick(shared_ptr<Entity> e, bool actual);
std::vector<TickNextTickData> *fetchTicksInChunk(LevelChunk *chunk, bool remove);
virtual void tick(std::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 isAtLeastOnePlayerSleeping() { return m_bAtLeastOnePlayerSleeping;}
protected:
ChunkSource *createChunkSource(); // 4J - was virtual, but was called from parent ctor
public:
vector<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);
std::vector<std::shared_ptr<TileEntity> > *getTileEntitiesInRegion(int x0, int y0, int z0, int x1, int y1, int z1);
virtual bool mayInteract(std::shared_ptr<Player> player, int xt, int yt, int zt, int id);
protected:
virtual void initializeLevel(LevelSettings *settings);
virtual void setInitialSpawn(LevelSettings *settings);
@@ -90,16 +90,16 @@ public:
private:
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
protected:
virtual void entityAdded(shared_ptr<Entity> e);
virtual void entityRemoved(shared_ptr<Entity> e);
virtual void entityAdded(std::shared_ptr<Entity> e);
virtual void entityRemoved(std::shared_ptr<Entity> e);
public:
shared_ptr<Entity> getEntity(int id);
virtual bool addGlobalEntity(shared_ptr<Entity> e);
void broadcastEntityEvent(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);
std::shared_ptr<Entity> getEntity(int id);
virtual bool addGlobalEntity(std::shared_ptr<Entity> e);
void broadcastEntityEvent(std::shared_ptr<Entity> e, uint8_t event);
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);
private:
@@ -134,14 +134,14 @@ public:
int m_primedTntCount;
int m_fallingTileCount;
CRITICAL_SECTION m_limiterCS;
list< shared_ptr<Entity> > m_itemEntities;
list< shared_ptr<Entity> > m_hangingEntities;
list< shared_ptr<Entity> > m_arrowEntities;
list< shared_ptr<Entity> > m_experienceOrbEntities;
list< std::shared_ptr<Entity> > m_itemEntities;
list< std::shared_ptr<Entity> > m_hangingEntities;
list< std::shared_ptr<Entity> > m_arrowEntities;
list< std::shared_ptr<Entity> > m_experienceOrbEntities;
virtual bool addEntity(shared_ptr<Entity> e);
void entityAddedExtra(shared_ptr<Entity> e);
void entityRemovedExtra(shared_ptr<Entity> e);
virtual bool addEntity(std::shared_ptr<Entity> e);
void entityAddedExtra(std::shared_ptr<Entity> e);
void entityRemovedExtra(std::shared_ptr<Entity> e);
virtual bool newPrimedTntAllowed();
virtual bool newFallingTileAllowed();
+14 -14
View File
@@ -20,7 +20,7 @@ ServerLevelListener::ServerLevelListener(MinecraftServer *server, ServerLevel *l
// 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);
level->getTracker()->addEntity(entity);
MemSect(0);
}
void ServerLevelListener::entityRemoved(shared_ptr<Entity> entity)
void ServerLevelListener::entityRemoved(std::shared_ptr<Entity> entity)
{
level->getTracker()->removeEntity(entity);
}
// 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);
}
@@ -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.
// 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)
{
@@ -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.
// 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);
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)));
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, 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)
@@ -112,7 +112,7 @@ void ServerLevelListener::destroyTileProgress(int id, int x, int y, int z, int p
//for (ServerPlayer p : server->getPlayers()->players)
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;
double xd = (double) x - p->x;
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)
{
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)));
}
}
}
+7 -7
View File
@@ -15,19 +15,19 @@ private:
public:
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 allChanged();
virtual void entityAdded(shared_ptr<Entity> entity);
virtual void entityRemoved(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 entityAdded(std::shared_ptr<Entity> entity);
virtual void entityRemoved(std::shared_ptr<Entity> entity);
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(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 skyColorChanged();
virtual void tileChanged(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 levelEvent(shared_ptr<Player> source, int type, int x, int y, int z, int data);
virtual void playStreamingMusic(const std::wstring& name, int x, int y, int z);
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);
};
+74 -74
View File
@@ -236,7 +236,7 @@ void Minecraft::clearConnectionFailed()
app.SetDisconnectReason(DisconnectPacket::eDisconnect_None);
}
void Minecraft::connectTo(const wstring& server, int port)
void Minecraft::connectTo(const std::wstring& server, int port)
{
connectToIp = server;
connectToPort = port;
@@ -489,7 +489,7 @@ File Minecraft::getWorkingDirectory()
return workDir;
}
File Minecraft::getWorkingDirectory(const wstring& applicationName)
File Minecraft::getWorkingDirectory(const std::wstring& applicationName)
{
#if 0
// 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);
return workingDirectory;
#else
wstring userHome = L"home"; // 4J - TODO
std::wstring userHome = L"home"; // 4J - TODO
File workingDirectory(userHome, applicationName);
// 4J Removed
//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
}
@@ -977,7 +977,7 @@ bool Minecraft::addLocalPlayer(int idx)
if(success)
{
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;
updatePlayerViewportAssignments();
@@ -1025,7 +1025,7 @@ void Minecraft::addPendingLocalConnection(int idx, ClientConnection *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;
@@ -1037,7 +1037,7 @@ shared_ptr<MultiplayerLocalPlayer> Minecraft::createExtraLocalPlayer(int idx, co
// A temp player displaying a connecting screen
tempScreenSection = localplayers[idx]->m_iScreenSection;
}
wstring prevname = user->name;
std::wstring prevname = user->name;
user->name = name;
// Don't need this any more
@@ -1141,7 +1141,7 @@ void Minecraft::removeLocalPlayerIdx(int idx)
{
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);
delete mplp->connection;
mplp->connection = NULL;
@@ -1163,7 +1163,7 @@ void Minecraft::removeLocalPlayerIdx(int idx)
}
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];
m_pendingLocalConnections[idx] = NULL;
g_NetworkManager.RemoveLocalPlayerByUserIndex(idx);
@@ -1584,7 +1584,7 @@ void Minecraft::run_middle()
else
{
// create the localplayer
shared_ptr<Player> player = localplayers[i];
std::shared_ptr<Player> player = localplayers[i];
if( player == NULL)
{
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;
PIXBeginNamedEvent(0,"Sound engine update");
soundEngine->tick((shared_ptr<Mob> *)localplayers, timer->a);
soundEngine->tick((std::shared_ptr<Mob> *)localplayers, timer->a);
PIXEndNamedEvent();
PIXBeginNamedEvent(0,"Light update");
@@ -2345,7 +2345,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures)
else
{
// 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.
if (itemInstance)
@@ -2716,14 +2716,14 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures)
// is there an object in hand?
if(player->inventory->IsHeldItem())
{
shared_ptr<ItemInstance> heldItem=player->inventory->getSelected();
std::shared_ptr<ItemInstance> heldItem=player->inventory->getSelected();
int iID=heldItem->getItem()->id;
switch(iID)
{
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))
{
@@ -2740,7 +2740,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures)
// is there an object in hand?
if(player->inventory->IsHeldItem())
{
shared_ptr<ItemInstance> heldItem=player->inventory->getSelected();
std::shared_ptr<ItemInstance> heldItem=player->inventory->getSelected();
int iID=heldItem->getItem()->id;
// It's an item
@@ -2752,7 +2752,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures)
break;
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))
{
@@ -2769,7 +2769,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures)
{
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;
// It's an item
@@ -2783,13 +2783,13 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures)
case Item::shears_Id:
{
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;
}
break;
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))
{
@@ -2842,7 +2842,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures)
// is there an object in hand?
if(player->inventory->IsHeldItem())
{
shared_ptr<ItemInstance> heldItem=player->inventory->getSelected();
std::shared_ptr<ItemInstance> heldItem=player->inventory->getSelected();
int iID=heldItem->getItem()->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->inventory->IsHeldItem())
{
shared_ptr<ItemInstance> heldItem=player->inventory->getSelected();
std::shared_ptr<ItemInstance> heldItem=player->inventory->getSelected();
int iID=heldItem->getItem()->id;
switch(iID)
{
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)
int newColor = ClothTile::getTileDataForItemAuxValue(heldItem->getAuxValue());
@@ -2884,7 +2884,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures)
break;
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
if(!sheep->isSheared() )
@@ -2896,7 +2896,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures)
break;
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))
{
@@ -2926,7 +2926,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures)
{
if(player->inventory->IsHeldItem())
{
shared_ptr<ItemInstance> heldItem=player->inventory->getSelected();
std::shared_ptr<ItemInstance> heldItem=player->inventory->getSelected();
int iID=heldItem->getItem()->id;
switch(iID)
@@ -2936,7 +2936,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures)
break;
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))
{
@@ -2954,8 +2954,8 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures)
// can be tamed, fed, and made to sit/stand, or enter love mode
{
int iID=-1;
shared_ptr<ItemInstance> heldItem=nullptr;
shared_ptr<Wolf> wolf = dynamic_pointer_cast<Wolf>(hitResult->entity);
std::shared_ptr<ItemInstance> heldItem=nullptr;
std::shared_ptr<Wolf> wolf = dynamic_pointer_cast<Wolf>(hitResult->entity);
if(player->inventory->IsHeldItem())
{
@@ -3044,8 +3044,8 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures)
case eTYPE_OZELOT:
{
int iID=-1;
shared_ptr<ItemInstance> heldItem=nullptr;
shared_ptr<Ozelot> ocelot = dynamic_pointer_cast<Ozelot>(hitResult->entity);
std::shared_ptr<ItemInstance> heldItem=nullptr;
std::shared_ptr<Ozelot> ocelot = dynamic_pointer_cast<Ozelot>(hitResult->entity);
if(player->inventory->IsHeldItem())
{
@@ -3106,7 +3106,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures)
case eTYPE_PLAYER:
{
// 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
{
@@ -3119,7 +3119,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures)
break;
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?
if(itemFrame->getItem()!=NULL)
@@ -3141,7 +3141,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures)
break;
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())
{
*piUse=IDS_TOOLTIPS_TRADE;
@@ -3151,8 +3151,8 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures)
break;
case eTYPE_ZOMBIE:
{
shared_ptr<Zombie> zomb = dynamic_pointer_cast<Zombie>(hitResult->entity);
shared_ptr<ItemInstance> heldItem=nullptr;
std::shared_ptr<Zombie> zomb = dynamic_pointer_cast<Zombie>(hitResult->entity);
std::shared_ptr<ItemInstance> heldItem=nullptr;
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())
{
//shared_ptr<Mob> mob = dynamic_pointer_cast<Mob>(Creeper::_class->newInstance( level ));
//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>(Creeper::_class->newInstance( level ));
//std::shared_ptr<Mob> mob = dynamic_pointer_cast<Mob>(Wolf::_class->newInstance( 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);
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))
{
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);
app.LoadInventoryMenu(iPad,player);
}
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
// 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
if( selected || wheel != 0 || (player->ullButtonsPressed&(1LL<<MINECRAFT_ACTION_DROP)) )
{
wstring itemName = L"";
shared_ptr<ItemInstance> selectedItem = player->getSelectedItem();
std::wstring itemName = L"";
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
int iCount=0;
@@ -3708,7 +3708,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures)
setLocalPlayerIdx(idx);
gameRenderer->setupCamera(timer->a, i);
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 yOff = cameraEntity->yOld + (cameraEntity->y - cameraEntity->yOld) * timer->a;
double zOff = cameraEntity->zOld + (cameraEntity->z - cameraEntity->zOld) * timer->a;
@@ -3782,16 +3782,16 @@ bool Minecraft::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;
}
bool Minecraft::loadSlot(const wstring& userName, int slot)
bool Minecraft::loadSlot(const std::wstring& userName, int slot)
{
return false;
}
@@ -3834,8 +3834,8 @@ MultiPlayerLevel *Minecraft::getLevel(int dimension)
//}
// Also causing ambiguous call for some reason
// as it is matching shared_ptr<Player> from the func below with bool from this one
//void Minecraft::setLevel(Level *level, const wstring& message, bool doForceStatsSave /*= true*/)
// as it is matching std::shared_ptr<Player> from the func below with bool from this one
//void Minecraft::setLevel(Level *level, const std::wstring& message, bool doForceStatsSave /*= true*/)
//{
// setLevel(level, message, NULL, doForceStatsSave);
//}
@@ -3848,7 +3848,7 @@ void Minecraft::forceaddLevel(MultiPlayerLevel *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);
bool playerAdded = false;
@@ -3913,7 +3913,7 @@ void Minecraft::setLevel(MultiPlayerLevel *level, int message /*=-1*/, shared_pt
// Delete all the player objects
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 )
{
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"/");
wstring category = name.substr(0, p);
wstring name2 = name.substr(p + 1);
std::wstring category = name.substr(0, p);
std::wstring name2 = name.substr(p + 1);
toLower(category);
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 L"Time to autosave: " + _toString<unsigned int>( app.SecondsToAutosave() ) + L"s";
}
wstring Minecraft::gatherStats2()
std::wstring Minecraft::gatherStats2()
{
return g_NetworkManager.GatherStats();
//return levelRenderer->gatherStats2();
}
wstring Minecraft::gatherStats3()
std::wstring Minecraft::gatherStats3()
{
return g_NetworkManager.GatherRTTStats();
//return L"P: " + particleEngine->countParticles() + L". T: " + level->gatherStats();
}
wstring Minecraft::gatherStats4()
std::wstring Minecraft::gatherStats4()
{
return level->gatherChunkSourceStats();
}
@@ -4160,7 +4160,7 @@ wstring Minecraft::gatherStats4()
void Minecraft::respawnPlayer(int iPad, int dimension, int newEntityId)
{
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->removeAllPendingEntityRemovals();
@@ -4171,7 +4171,7 @@ void Minecraft::respawnPlayer(int iPad, int dimension, int newEntityId)
level->removeEntity(localPlayer);
}
shared_ptr<Player> oldPlayer = localPlayer;
std::shared_ptr<Player> oldPlayer = localPlayer;
cameraTargetPlayer = nullptr;
// 4J-PB - copy and set the players xbox pad
@@ -4260,15 +4260,15 @@ void Minecraft::respawnPlayer(int iPad, int dimension, int newEntityId)
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"");
}
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;
wstring userName = name;
std::wstring userName = name;
/* 4J - removed window handling things here
final Frame frame = new Frame("Minecraft");
@@ -4367,8 +4367,8 @@ int g_iMainThreadId;
void Minecraft::main()
{
wstring name;
wstring sessionId;
std::wstring name;
std::wstring sessionId;
//g_iMainThreadId = GetCurrentThreadId();
@@ -4452,7 +4452,7 @@ bool Minecraft::renderDebug()
return (m_instance != NULL && m_instance->options->renderDebug);
}
bool Minecraft::handleClientSideCommand(const wstring& chatMessage)
bool Minecraft::handleClientSideCommand(const std::wstring& chatMessage)
{
/* 4J - TODO
if (chatMessage.startsWith("/")) {
@@ -4559,7 +4559,7 @@ bool mayUse = true;
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();
@@ -4608,7 +4608,7 @@ gameMode->startDestroyBlock(x, y, z, hitResult->f);
}
else
{
shared_ptr<ItemInstance> item = player->inventory->getSelected();
std::shared_ptr<ItemInstance> item = player->inventory->getSelected();
int oldCount = item != NULL ? item->count : 0;
if (gameMode->useItemOn(player, level, item, x, y, z, face))
{
@@ -4634,7 +4634,7 @@ gameRenderer->itemInHandRenderer->itemPlaced();
if (mayUse && button == 1)
{
shared_ptr<ItemInstance> item = player->inventory->getSelected();
std::shared_ptr<ItemInstance> item = player->inventory->getSelected();
if (item != NULL)
{
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) )
{
// 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( pClass->level->isClientSide )
@@ -4731,7 +4731,7 @@ void Minecraft::inGameSignInCheckAllPrivilegesCallback(LPVOID lpParam, bool hasP
else
{
// 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)
{
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
{
// 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)
{
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();
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)
{
setLocalPlayerIdx(i);
@@ -4841,7 +4841,7 @@ void Minecraft::tickAllConnections()
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));
if( it == m_pendingTextureRequests.end() )
@@ -4852,7 +4852,7 @@ bool Minecraft::addPendingClientTextureRequest(const wstring &textureName)
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));
if( it != m_pendingTextureRequests.end() )
+31 -31
View File
@@ -46,7 +46,7 @@ class PsPlusUpsellWrapper;
#undef linux
#endif
using namespace std;
class Minecraft
{
@@ -56,7 +56,7 @@ private:
};
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);
void init();
@@ -94,11 +94,11 @@ public:
MultiPlayerLevel *level;
LevelRenderer *levelRenderer;
shared_ptr<MultiplayerLocalPlayer> player;
std::shared_ptr<MultiplayerLocalPlayer> player;
MultiPlayerLevelArray levels;
shared_ptr<MultiplayerLocalPlayer> localplayers[XUSER_MAX_COUNT];
std::shared_ptr<MultiplayerLocalPlayer> localplayers[XUSER_MAX_COUNT];
MultiPlayerGameMode *localgameModes[XUSER_MAX_COUNT];
int localPlayerIdx;
ItemInHandRenderer *localitemInHandRenderers[XUSER_MAX_COUNT];
@@ -114,7 +114,7 @@ public:
void addPendingLocalConnection(int idx, ClientConnection *connection);
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);
bool setLocalPlayerIdx(int idx);
int getLocalPlayerIdx();
@@ -123,10 +123,10 @@ public:
void updatePlayerViewportAssignments();
int unoccupiedQuadrant; // 4J - added
shared_ptr<Mob> cameraTargetPlayer;
std::shared_ptr<Mob> cameraTargetPlayer;
ParticleEngine *particleEngine;
User *user;
wstring serverDomain;
std::wstring serverDomain;
Canvas *parent;
bool appletMode;
@@ -181,12 +181,12 @@ public:
StatsCounter* stats[4];
private:
wstring connectToIp;
std::wstring connectToIp;
int connectToPort;
public:
void clearConnectionFailed();
void connectTo(const wstring& server, int port);
void connectTo(const std::wstring& server, int port);
private:
void renderLoadingScreen();
@@ -199,14 +199,14 @@ private:
public:
static File getWorkingDirectory();
static File getWorkingDirectory(const wstring& applicationName);
static File getWorkingDirectory(const std::wstring& applicationName);
private:
static OS getPlatform();
public:
LevelStorageSource *getLevelSource();
void setScreen(Screen *screen);
private:
void checkGlError(const wstring& string);
void checkGlError(const std::wstring& string);
#ifdef __ORBIS__
PsPlusUpsellWrapper *m_pPsPlusUpsell;
@@ -215,7 +215,7 @@ private:
public:
void destroy();
volatile bool running;
wstring fpsString;
std::wstring fpsString;
void run();
// 4J-PB - split the run into 3 parts so we can run it from our xbox game loop
static Minecraft *GetInstance();
@@ -269,36 +269,36 @@ private:
void reloadSound();
public:
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);
bool saveSlot(int slot, const wstring& name);
bool loadSlot(const wstring& userName, int slot);
bool saveSlot(int slot, const std::wstring& name);
bool loadSlot(const std::wstring& userName, int slot);
void releaseLevel(int message);
// 4J Stu - Added the doForceStatsSave param
//void setLevel(Level *level, bool doForceStatsSave = true);
//void setLevel(Level *level, const 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(Level *level, const std::wstring& message, bool doForceStatsSave = true);
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
void forceaddLevel(MultiPlayerLevel *level);
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
wstring gatherStats1();
wstring gatherStats2();
wstring gatherStats3();
wstring gatherStats4();
std::wstring gatherStats1();
std::wstring gatherStats2();
std::wstring gatherStats3();
std::wstring gatherStats4();
void respawnPlayer(int iPad,int dimension,int newEntityId);
static void start(const wstring& name, const wstring& sid);
static void startAndConnectTo(const wstring& name, const wstring& sid, const wstring& url);
static void start(const std::wstring& name, const std::wstring& sid);
static void startAndConnectTo(const std::wstring& name, const std::wstring& sid, const std::wstring& url);
ClientConnection *getConnection(int iPad); // 4J Stu added iPad param
static void main();
static bool renderNames();
static bool useFancyGraphics();
static bool useAmbientOcclusion();
static bool renderDebug();
bool handleClientSideCommand(const wstring& chatMessage);
bool handleClientSideCommand(const std::wstring& chatMessage);
static int maxSupportedTextureSize();
void delayTextureReload();
@@ -331,15 +331,15 @@ public:
Level *animateTickLevel; // 4J added
// 4J - When a client requests a texture, it should add it to here while we are waiting for it
vector<wstring> m_pendingTextureRequests;
vector<wstring> m_pendingGeometryRequests; // additional skin box geometry
std::vector<std::wstring> m_pendingTextureRequests;
std::vector<std::wstring> m_pendingGeometryRequests; // additional skin box geometry
// 4J Added
bool addPendingClientTextureRequest(const wstring &textureName);
void handleClientTextureReceived(const wstring &textureName);
bool addPendingClientTextureRequest(const std::wstring &textureName);
void handleClientTextureReceived(const std::wstring &textureName);
void clearPendingClientTextureRequests() { m_pendingTextureRequests.clear(); }
bool addPendingClientGeometryRequest(const wstring &textureName);
void handleClientGeometryReceived(const wstring &textureName);
bool addPendingClientGeometryRequest(const std::wstring &textureName);
void handleClientGeometryReceived(const std::wstring &textureName);
void clearPendingClientGeometryRequests() { m_pendingGeometryRequests.clear(); }
unsigned int getCurrentTexturePackId();
+33 -33
View File
@@ -64,7 +64,7 @@ int MinecraftServer::s_slowQueuePlayerIndex = 0;
int MinecraftServer::s_slowQueueLastTime = 0;
bool MinecraftServer::s_slowQueuePacketSent = false;
unordered_map<wstring, int> MinecraftServer::ironTimers;
std::unordered_map<std::wstring, int> MinecraftServer::ironTimers;
MinecraftServer::MinecraftServer()
{
@@ -77,7 +77,7 @@ MinecraftServer::MinecraftServer()
m_bLoaded = false;
stopped = false;
tickCount = 0;
wstring progressStatus;
std::wstring progressStatus;
progress = 0;
motd = L"";
@@ -203,8 +203,8 @@ bool MinecraftServer::initServer(__int64 seed, NetworkGameInitData *initData, DW
__int64 levelNanoTime = System::nanoTime();
wstring levelName = settings->getString(L"level-name", L"world");
wstring levelTypeString;
std::wstring levelName = settings->getString(L"level-name", L"world");
std::wstring levelTypeString;
bool gameRuleUseFlatWorld = false;
if(app.getLevelGenerationOptions() != NULL)
@@ -244,7 +244,7 @@ bool MinecraftServer::initServer(__int64 seed, NetworkGameInitData *initData, DW
//settings->setProperty(L"max-build-height", maxBuildHeight);
#if 0
wstring levelSeedString = settings->getString(L"level-seed", L"");
std::wstring levelSeedString = settings->getString(L"level-seed", L"");
__int64 levelSeed = (new Random())->nextLong();
if (levelSeedString.length() > 0)
{
@@ -378,7 +378,7 @@ void MinecraftServer::postProcessTerminate(ProgressRenderer *mcprogress)
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
// if (storageSource->requiresConversion(name))
@@ -398,7 +398,7 @@ bool MinecraftServer::loadLevel(LevelStorageSource *storageSource, const wstring
if( app.GetGameHostOption(eGameHostOption_BonusChest ) ) levelSettings->enableStartingBonusItems();
// 4J - temp - load existing level
shared_ptr<McRegionLevelStorage> storage = nullptr;
std::shared_ptr<McRegionLevelStorage> storage = nullptr;
bool levelChunksNeedConverted = false;
if( initData->saveData != NULL )
{
@@ -416,7 +416,7 @@ bool MinecraftServer::loadLevel(LevelStorageSource *storageSource, const wstring
levelChunksNeedConverted = true;
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
{
@@ -441,9 +441,9 @@ bool MinecraftServer::loadLevel(LevelStorageSource *storageSource, const wstring
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
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
}
@@ -750,7 +750,7 @@ bool MinecraftServer::loadLevel(LevelStorageSource *storageSource, const wstring
return true;
}
void MinecraftServer::setProgress(const wstring& status, int progress)
void MinecraftServer::setProgress(const std::wstring& status, int progress)
{
progressStatus = status;
this->progress = progress;
@@ -1258,7 +1258,7 @@ void MinecraftServer::run(__int64 seed, void *lpParameter)
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++)
{
@@ -1269,7 +1269,7 @@ void MinecraftServer::run(__int64 seed, void *lpParameter)
ServerLevel *level = levels[levels.length - 1 - j];
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 )
{
@@ -1282,16 +1282,16 @@ void MinecraftServer::run(__int64 seed, void *lpParameter)
case eXuiServerAction_DropItem:
// 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;
player->drop( shared_ptr<ItemInstance>( new ItemInstance(id, 1, 0 ) ) );
player->drop( std::shared_ptr<ItemInstance>( new ItemInstance(id, 1, 0 ) ) );
}
break;
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);
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->setDespawnProtected(); // 4J added, default to being protected against despawning (has to be done after initial position is set)
player->level->addEntity(mob);
@@ -1319,20 +1319,20 @@ void MinecraftServer::run(__int64 seed, void *lpParameter)
}
break;
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;
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;
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;
case eXuiServerAction_ExportSchematic:
#ifndef _CONTENT_PACKAGE
app.EnterSaveNotificationSection();
//players->broadcastAll( shared_ptr<UpdateProgressPacket>( new UpdateProgressPacket(20) ) );
//players->broadcastAll( std::shared_ptr<UpdateProgressPacket>( new UpdateProgressPacket(20) ) );
if( !s_bServerHalted )
{
@@ -1347,7 +1347,7 @@ void MinecraftServer::run(__int64 seed, void *lpParameter)
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));
File dataFile = File( targetFileDir, wstring(filename) );
File dataFile = File( targetFileDir, std::wstring(filename) );
if(dataFile.exists()) dataFile._delete();
FileOutputStream fos = FileOutputStream(dataFile);
DataOutputStream dos = DataOutputStream(&fos);
@@ -1370,7 +1370,7 @@ void MinecraftServer::run(__int64 seed, void *lpParameter)
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,
pos->m_yRot, pos->m_elev );
@@ -1427,20 +1427,20 @@ void MinecraftServer::run(__int64 seed, void *lpParameter)
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()
{
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()
{
vector<wstring> toRemove;
std::vector<std::wstring> toRemove;
for (AUTO_VAR(it, ironTimers.begin()); it != ironTimers.end(); it++ )
{
int t = it->second;
@@ -1469,7 +1469,7 @@ void MinecraftServer::tick()
/* if(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++)
@@ -1489,7 +1489,7 @@ void MinecraftServer::tick()
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__
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));
}
@@ -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);
}
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";
}
+18 -18
View File
@@ -24,8 +24,8 @@ typedef struct _LoadSaveDataThreadParam
{
LPVOID data;
__int64 fileSize;
const wstring saveName;
_LoadSaveDataThreadParam(LPVOID data, __int64 filesize, const wstring &saveName) : data( data ), fileSize( filesize ), saveName( saveName ) {}
const std::wstring saveName;
_LoadSaveDataThreadParam(LPVOID data, __int64 filesize, const std::wstring &saveName) : data( data ), fileSize( filesize ), saveName( saveName ) {}
} LoadSaveDataThreadParam;
typedef struct _NetworkGameInitData
@@ -54,24 +54,24 @@ typedef struct _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
class MinecraftServer : public ConsoleInputSource
{
public:
static const wstring VERSION;
static const std::wstring VERSION;
static const int TICK_STATS_SPAN = SharedConstants::TICKS_PER_SECOND * 5;
// static Logger logger = Logger.getLogger("Minecraft");
static unordered_map<wstring, int> ironTimers;
static std::unordered_map<std::wstring, int> ironTimers;
private:
static const int DEFAULT_MINECRAFT_PORT = 25565;
static const int MS_PER_TICK = 1000 / SharedConstants::TICKS_PER_SECOND;
// 4J Stu - Added 1.0.1, Not needed
//wstring localIp;
//std::wstring localIp;
//int port;
public:
ServerConnection *connection;
@@ -93,19 +93,19 @@ public:
int tickCount;
public:
wstring progressStatus;
std::wstring progressStatus;
int progress;
private:
// vector<Tickable *> tickables = new ArrayList<Tickable>(); // 4J - removed
// std::vector<Tickable *> tickables = new ArrayList<Tickable>(); // 4J - removed
CommandDispatcher *commandDispatcher;
vector<ConsoleInput *> consoleInput; // 4J - was synchronizedList - TODO - investigate
std::vector<ConsoleInput *> consoleInput; // 4J - was synchronizedList - TODO - investigate
public:
bool onlineMode;
bool animals;
bool npcs;
bool pvp;
bool allowFlight;
wstring motd;
std::wstring motd;
int maxBuildHeight;
private:
@@ -127,8 +127,8 @@ private:
// 4J Added - LoadSaveDataThreadParam
bool initServer(__int64 seed, NetworkGameInitData *initData, DWORD initSettings, bool findSeed);
void postProcessTerminate(ProgressRenderer *mcprogress);
bool loadLevel(LevelStorageSource *storageSource, const wstring& name, __int64 levelSeed, LevelType *pLevelType, NetworkGameInitData *initData);
void setProgress(const wstring& status, int progress);
bool loadLevel(LevelStorageSource *storageSource, const std::wstring& name, __int64 levelSeed, LevelType *pLevelType, NetworkGameInitData *initData);
void setProgress(const std::wstring& status, int progress);
void endProgress();
void saveAllChunks();
void saveGameRules();
@@ -162,16 +162,16 @@ public:
private:
void tick();
public:
void handleConsoleInput(const wstring& msg, ConsoleInputSource *source);
void handleConsoleInput(const std::wstring& msg, ConsoleInputSource *source);
void handleConsoleInputs();
// void addTickable(Tickable tickable); // 4J removed
static void main(__int64 seed, void *lpParameter);
static void HaltServer(bool bPrimaryPlayerSignedOut=false);
File *getFile(const wstring& name);
void info(const wstring& string);
void warn(const wstring& string);
wstring getConsoleName();
File *getFile(const std::wstring& name);
void info(const std::wstring& string);
void warn(const std::wstring& string);
std::wstring getConsoleName();
ServerLevel *getLevel(int dimension);
void setLevel(int dimension, ServerLevel *level); // 4J added
static MinecraftServer *getInstance() { return server; } // 4J added
@@ -204,7 +204,7 @@ private:
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;
public:
void addPostProcessRequest(ChunkSource *chunkSource, int x, int z);
File diff suppressed because it is too large Load Diff
+71 -71
View File
@@ -21,7 +21,7 @@ private:
bool done;
Connection *connection;
public:
wstring message;
std::wstring message;
bool createdOk; // 4J added
private:
Minecraft *minecraft;
@@ -44,97 +44,97 @@ private:
DWORD m_userIndex; // 4J Added
public:
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();
void tick();
INetworkPlayer *getNetworkPlayer();
virtual void handleLogin(shared_ptr<LoginPacket> packet);
virtual void handleAddEntity(shared_ptr<AddEntityPacket> packet);
virtual void handleAddExperienceOrb(shared_ptr<AddExperienceOrbPacket> packet);
virtual void handleAddGlobalEntity(shared_ptr<AddGlobalEntityPacket> packet);
virtual void handleAddPainting(shared_ptr<AddPaintingPacket> packet);
virtual void handleSetEntityMotion(shared_ptr<SetEntityMotionPacket> packet);
virtual void handleSetEntityData(shared_ptr<SetEntityDataPacket> packet);
virtual void handleAddPlayer(shared_ptr<AddPlayerPacket> packet);
virtual void handleTeleportEntity(shared_ptr<TeleportEntityPacket> packet);
virtual void handleMoveEntity(shared_ptr<MoveEntityPacket> packet);
virtual void handleRotateMob(shared_ptr<RotateHeadPacket> packet);
virtual void handleMoveEntitySmall(shared_ptr<MoveEntityPacketSmall> packet);
virtual void handleRemoveEntity(shared_ptr<RemoveEntitiesPacket> packet);
virtual void handleMovePlayer(shared_ptr<MovePlayerPacket> packet);
virtual void handleLogin(std::shared_ptr<LoginPacket> packet);
virtual void handleAddEntity(std::shared_ptr<AddEntityPacket> packet);
virtual void handleAddExperienceOrb(std::shared_ptr<AddExperienceOrbPacket> packet);
virtual void handleAddGlobalEntity(std::shared_ptr<AddGlobalEntityPacket> packet);
virtual void handleAddPainting(std::shared_ptr<AddPaintingPacket> packet);
virtual void handleSetEntityMotion(std::shared_ptr<SetEntityMotionPacket> packet);
virtual void handleSetEntityData(std::shared_ptr<SetEntityDataPacket> packet);
virtual void handleAddPlayer(std::shared_ptr<AddPlayerPacket> packet);
virtual void handleTeleportEntity(std::shared_ptr<TeleportEntityPacket> packet);
virtual void handleMoveEntity(std::shared_ptr<MoveEntityPacket> packet);
virtual void handleRotateMob(std::shared_ptr<RotateHeadPacket> packet);
virtual void handleMoveEntitySmall(std::shared_ptr<MoveEntityPacketSmall> packet);
virtual void handleRemoveEntity(std::shared_ptr<RemoveEntitiesPacket> packet);
virtual void handleMovePlayer(std::shared_ptr<MovePlayerPacket> packet);
Random *random;
// 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 handleChunkTilesUpdate(shared_ptr<ChunkTilesUpdatePacket> packet);
virtual void handleBlockRegionUpdate(shared_ptr<BlockRegionUpdatePacket> packet);
virtual void handleTileUpdate(shared_ptr<TileUpdatePacket> packet);
virtual void handleDisconnect(shared_ptr<DisconnectPacket> packet);
virtual void handleChunkVisibility(std::shared_ptr<ChunkVisibilityPacket> packet);
virtual void handleChunkTilesUpdate(std::shared_ptr<ChunkTilesUpdatePacket> packet);
virtual void handleBlockRegionUpdate(std::shared_ptr<BlockRegionUpdatePacket> packet);
virtual void handleTileUpdate(std::shared_ptr<TileUpdatePacket> packet);
virtual void handleDisconnect(std::shared_ptr<DisconnectPacket> packet);
virtual void onDisconnect(DisconnectPacket::eDisconnectReason reason, void *reasonObjects);
void sendAndDisconnect(shared_ptr<Packet> packet);
void send(shared_ptr<Packet> packet);
virtual void handleTakeItemEntity(shared_ptr<TakeItemEntityPacket> packet);
virtual void handleChat(shared_ptr<ChatPacket> packet);
virtual void handleAnimate(shared_ptr<AnimatePacket> packet);
virtual void handleEntityActionAtPosition(shared_ptr<EntityActionAtPositionPacket> packet);
virtual void handlePreLogin(shared_ptr<PreLoginPacket> packet);
void sendAndDisconnect(std::shared_ptr<Packet> packet);
void send(std::shared_ptr<Packet> packet);
virtual void handleTakeItemEntity(std::shared_ptr<TakeItemEntityPacket> packet);
virtual void handleChat(std::shared_ptr<ChatPacket> packet);
virtual void handleAnimate(std::shared_ptr<AnimatePacket> packet);
virtual void handleEntityActionAtPosition(std::shared_ptr<EntityActionAtPositionPacket> packet);
virtual void handlePreLogin(std::shared_ptr<PreLoginPacket> packet);
void close();
virtual void handleAddMob(shared_ptr<AddMobPacket> packet);
virtual void handleSetTime(shared_ptr<SetTimePacket> packet);
virtual void handleSetSpawn(shared_ptr<SetSpawnPositionPacket> packet);
virtual void handleRidePacket(shared_ptr<SetRidingPacket> packet);
virtual void handleEntityEvent(shared_ptr<EntityEventPacket> packet);
virtual void handleAddMob(std::shared_ptr<AddMobPacket> packet);
virtual void handleSetTime(std::shared_ptr<SetTimePacket> packet);
virtual void handleSetSpawn(std::shared_ptr<SetSpawnPositionPacket> packet);
virtual void handleRidePacket(std::shared_ptr<SetRidingPacket> packet);
virtual void handleEntityEvent(std::shared_ptr<EntityEventPacket> packet);
private:
shared_ptr<Entity> getEntity(int entityId);
wstring GetDisplayNameByGamertag(wstring gamertag);
std::shared_ptr<Entity> getEntity(int entityId);
std::wstring GetDisplayNameByGamertag(std::wstring gamertag);
public:
virtual void handleSetHealth(shared_ptr<SetHealthPacket> packet);
virtual void handleSetExperience(shared_ptr<SetExperiencePacket> packet);
virtual void handleRespawn(shared_ptr<RespawnPacket> packet);
virtual void handleExplosion(shared_ptr<ExplodePacket> packet);
virtual void handleContainerOpen(shared_ptr<ContainerOpenPacket> packet);
virtual void handleContainerSetSlot(shared_ptr<ContainerSetSlotPacket> packet);
virtual void handleContainerAck(shared_ptr<ContainerAckPacket> packet);
virtual void handleContainerContent(shared_ptr<ContainerSetContentPacket> packet);
virtual void handleSignUpdate(shared_ptr<SignUpdatePacket> packet);
virtual void handleTileEntityData(shared_ptr<TileEntityDataPacket> packet);
virtual void handleContainerSetData(shared_ptr<ContainerSetDataPacket> packet);
virtual void handleSetEquippedItem(shared_ptr<SetEquippedItemPacket> packet);
virtual void handleContainerClose(shared_ptr<ContainerClosePacket> packet);
virtual void handleTileEvent(shared_ptr<TileEventPacket> packet);
virtual void handleTileDestruction(shared_ptr<TileDestructionPacket> packet);
virtual void handleSetHealth(std::shared_ptr<SetHealthPacket> packet);
virtual void handleSetExperience(std::shared_ptr<SetExperiencePacket> packet);
virtual void handleRespawn(std::shared_ptr<RespawnPacket> packet);
virtual void handleExplosion(std::shared_ptr<ExplodePacket> packet);
virtual void handleContainerOpen(std::shared_ptr<ContainerOpenPacket> packet);
virtual void handleContainerSetSlot(std::shared_ptr<ContainerSetSlotPacket> packet);
virtual void handleContainerAck(std::shared_ptr<ContainerAckPacket> packet);
virtual void handleContainerContent(std::shared_ptr<ContainerSetContentPacket> packet);
virtual void handleSignUpdate(std::shared_ptr<SignUpdatePacket> packet);
virtual void handleTileEntityData(std::shared_ptr<TileEntityDataPacket> packet);
virtual void handleContainerSetData(std::shared_ptr<ContainerSetDataPacket> packet);
virtual void handleSetEquippedItem(std::shared_ptr<SetEquippedItemPacket> packet);
virtual void handleContainerClose(std::shared_ptr<ContainerClosePacket> packet);
virtual void handleTileEvent(std::shared_ptr<TileEventPacket> packet);
virtual void handleTileDestruction(std::shared_ptr<TileDestructionPacket> packet);
virtual bool canHandleAsyncPackets();
virtual void handleGameEvent(shared_ptr<GameEventPacket> gameEventPacket);
virtual void handleComplexItemData(shared_ptr<ComplexItemDataPacket> packet);
virtual void handleLevelEvent(shared_ptr<LevelEventPacket> packet);
virtual void handleAwardStat(shared_ptr<AwardStatPacket> packet);
virtual void handleUpdateMobEffect(shared_ptr<UpdateMobEffectPacket> packet);
virtual void handleRemoveMobEffect(shared_ptr<RemoveMobEffectPacket> packet);
virtual void handleGameEvent(std::shared_ptr<GameEventPacket> gameEventPacket);
virtual void handleComplexItemData(std::shared_ptr<ComplexItemDataPacket> packet);
virtual void handleLevelEvent(std::shared_ptr<LevelEventPacket> packet);
virtual void handleAwardStat(std::shared_ptr<AwardStatPacket> packet);
virtual void handleUpdateMobEffect(std::shared_ptr<UpdateMobEffectPacket> packet);
virtual void handleRemoveMobEffect(std::shared_ptr<RemoveMobEffectPacket> packet);
virtual bool isServerPacketListener();
virtual void handlePlayerInfo(shared_ptr<PlayerInfoPacket> packet);
virtual void handleKeepAlive(shared_ptr<KeepAlivePacket> packet);
virtual void handlePlayerAbilities(shared_ptr<PlayerAbilitiesPacket> playerAbilitiesPacket);
virtual void handleSoundEvent(shared_ptr<LevelSoundPacket> packet);
virtual void handleCustomPayload(shared_ptr<CustomPayloadPacket> customPayloadPacket);
virtual void handlePlayerInfo(std::shared_ptr<PlayerInfoPacket> packet);
virtual void handleKeepAlive(std::shared_ptr<KeepAlivePacket> packet);
virtual void handlePlayerAbilities(std::shared_ptr<PlayerAbilitiesPacket> playerAbilitiesPacket);
virtual void handleSoundEvent(std::shared_ptr<LevelSoundPacket> packet);
virtual void handleCustomPayload(std::shared_ptr<CustomPayloadPacket> customPayloadPacket);
virtual Connection *getConnection();
// 4J Added
virtual void handleServerSettingsChanged(shared_ptr<ServerSettingsChangedPacket> packet);
virtual void handleTexture(shared_ptr<TexturePacket> packet);
virtual void handleTextureAndGeometry(shared_ptr<TextureAndGeometryPacket> packet);
virtual void handleUpdateProgress(shared_ptr<UpdateProgressPacket> packet);
virtual void handleServerSettingsChanged(std::shared_ptr<ServerSettingsChangedPacket> packet);
virtual void handleTexture(std::shared_ptr<TexturePacket> packet);
virtual void handleTextureAndGeometry(std::shared_ptr<TextureAndGeometryPacket> packet);
virtual void handleUpdateProgress(std::shared_ptr<UpdateProgressPacket> packet);
// 4J Added
static int HostDisconnectReturned(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 handleTextureAndGeometryChange(shared_ptr<TextureAndGeometryChangePacket> packet);
virtual void handleUpdateGameRuleProgressPacket(shared_ptr<UpdateGameRuleProgressPacket> packet);
virtual void handleXZ(shared_ptr<XZPacket> packet);
virtual void handleTextureChange(std::shared_ptr<TextureChangePacket> packet);
virtual void handleTextureAndGeometryChange(std::shared_ptr<TextureAndGeometryChangePacket> packet);
virtual void handleUpdateGameRuleProgressPacket(std::shared_ptr<UpdateGameRuleProgressPacket> 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;
}
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;
}
wstring MultiPlayerChunkCache::gatherStats()
std::wstring MultiPlayerChunkCache::gatherStats()
{
EnterCriticalSection(&m_csLoadCreate);
int size = (int)loadedChunkList.size();
@@ -3,7 +3,7 @@
#include "../../Minecraft.World/Headers/net.minecraft.world.level.chunk.h"
#include "../../Minecraft.World/Level/RandomLevelSource.h"
using namespace std;
class ServerChunkCache;
// 4J - various alterations here to make this thread safe, and operate as a fixed sized cache
@@ -14,7 +14,7 @@ private:
LevelChunk *emptyChunk;
LevelChunk *waterChunk;
vector<LevelChunk *> loadedChunkList;
std::vector<LevelChunk *> loadedChunkList;
LevelChunk **cache;
// 4J - added for multithreaded support
@@ -38,9 +38,9 @@ public:
virtual bool tick();
virtual bool shouldSave();
virtual void postProcess(ChunkSource *parent, int x, int z);
virtual wstring gatherStats();
virtual 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 std::wstring gatherStats();
virtual std::vector<Biome::MobSpawnerData *> *getMobsAt(MobCategory *mobCategory, 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 LevelChunk **getCache() { return cache; } // 4J added
+15 -15
View File
@@ -20,7 +20,7 @@
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
done = false;
@@ -62,7 +62,7 @@ void PendingConnection::disconnect(DisconnectPacket::eDisconnectReason reason)
// logger.info("Disconnecting " + getName() + ": " + reason);
fprintf(stderr, "[PENDING] disconnect called with reason=%d at tick=%d\n", reason, _tick);
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();
done = true;
// } 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)
{
@@ -104,7 +104,7 @@ void PendingConnection::sendPreLoginResponse()
PlayerList *playerList = MinecraftServer::getInstance()->getPlayers();
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 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
{
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
#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);
//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)
{
@@ -212,7 +212,7 @@ void PendingConnection::handleAcceptedLogin(shared_ptr<LoginPacket> packet)
PlayerUID playerXuid = packet->m_offlineXuid;
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)
{
server->getPlayers()->placeNewPlayer(connection, playerEntity, packet);
@@ -228,12 +228,12 @@ void PendingConnection::onDisconnect(DisconnectPacket::eDisconnectReason reason,
done = true;
}
void PendingConnection::handleGetInfo(shared_ptr<GetInfoPacket> packet)
void PendingConnection::handleGetInfo(std::shared_ptr<GetInfoPacket> packet)
{
//try {
//String message = server->motd + "§" + server->players->getPlayerCount() + "§" + server->players->getMaxPlayers();
//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();
server->connection->removeSpamProtection(connection->getSocket());
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
}
void PendingConnection::onUnhandledPacket(shared_ptr<Packet> packet)
void PendingConnection::onUnhandledPacket(std::shared_ptr<Packet> packet)
{
disconnect(DisconnectPacket::eDisconnect_UnexpectedPacket);
}
void PendingConnection::send(shared_ptr<Packet> packet)
void PendingConnection::send(std::shared_ptr<Packet> packet)
{
connection->send(packet);
}
wstring PendingConnection::getName()
std::wstring PendingConnection::getName()
{
return L"Unimplemented";
// if (name != null) return name + " [" + connection.getRemoteAddress().toString() + "]";
+13 -13
View File
@@ -5,7 +5,7 @@ class Socket;
class LoginPacket;
class Connection;
class Random;
using namespace std;
class PendingConnection : public PacketListener
{
@@ -23,24 +23,24 @@ public:
private:
MinecraftServer *server;
int _tick;
wstring name;
shared_ptr<LoginPacket> acceptedLogin;
wstring loginKey;
std::wstring name;
std::shared_ptr<LoginPacket> acceptedLogin;
std::wstring loginKey;
public:
PendingConnection(MinecraftServer *server, Socket *socket, const wstring& id);
PendingConnection(MinecraftServer *server, Socket *socket, const std::wstring& id);
~PendingConnection();
void tick();
void disconnect(DisconnectPacket::eDisconnectReason reason);
virtual void handlePreLogin(shared_ptr<PreLoginPacket> packet);
virtual void handleLogin(shared_ptr<LoginPacket> packet);
virtual void handleAcceptedLogin(shared_ptr<LoginPacket> packet);
virtual void handlePreLogin(std::shared_ptr<PreLoginPacket> packet);
virtual void handleLogin(std::shared_ptr<LoginPacket> packet);
virtual void handleAcceptedLogin(std::shared_ptr<LoginPacket> packet);
virtual void onDisconnect(DisconnectPacket::eDisconnectReason reason, void *reasonObjects);
virtual void handleGetInfo(shared_ptr<GetInfoPacket> packet);
virtual void handleKeepAlive(shared_ptr<KeepAlivePacket> packet);
virtual void onUnhandledPacket(shared_ptr<Packet> packet);
void send(shared_ptr<Packet> packet);
wstring getName();
virtual void handleGetInfo(std::shared_ptr<GetInfoPacket> packet);
virtual void handleKeepAlive(std::shared_ptr<KeepAlivePacket> packet);
virtual void onUnhandledPacket(std::shared_ptr<Packet> packet);
void send(std::shared_ptr<Packet> packet);
std::wstring getName();
virtual bool isServerPacketListener();
private:
+28 -28
View File
@@ -44,12 +44,12 @@ void PlayerChunkMap::flagEntitiesToBeRemoved(unsigned int *flags, bool *flagToBe
{
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);
}
}
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);
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);
// 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);
@@ -77,7 +77,7 @@ void PlayerChunkMap::PlayerChunk::add(shared_ptr<ServerPlayer> player, bool send
#endif
}
void PlayerChunkMap::PlayerChunk::remove(shared_ptr<ServerPlayer> player)
void PlayerChunkMap::PlayerChunk::remove(std::shared_ptr<ServerPlayer> player)
{
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 )
{
shared_ptr<ServerPlayer> currPlayer = *it;
std::shared_ptr<ServerPlayer> currPlayer = *it;
INetworkPlayer *currNetPlayer = currPlayer->connection->getNetworkPlayer();
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)
{
//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
@@ -181,12 +181,12 @@ void PlayerChunkMap::PlayerChunk::prioritiseTileChanges()
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++)
{
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,
// 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++ )
{
shared_ptr<ServerPlayer> player2 = sentTo[j];
std::shared_ptr<ServerPlayer> player2 = sentTo[j];
INetworkPlayer *otherPlayer = player2->connection->getNetworkPlayer();
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++ )
{
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
if ( player->connection == NULL ) 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++ )
{
shared_ptr<ServerPlayer> player2 = sentTo[j];
std::shared_ptr<ServerPlayer> player2 = sentTo[j];
INetworkPlayer *otherPlayer = player2->connection->getNetworkPlayer();
if( otherPlayer != NULL && thisPlayer->IsSameSystem(otherPlayer) )
{
@@ -299,7 +299,7 @@ bool PlayerChunkMap::PlayerChunk::broadcastChanges(bool allowRegionUpdate)
int x = pos.x * 16 + xChangeMin;
int y = yChangeMin;
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))
{
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
if( ys > 256 ) ys = 256;
broadcast( 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);
broadcast( std::shared_ptr<BlockRegionUpdatePacket>( new BlockRegionUpdatePacket(xp, yp, zp, xs, ys, zs, level) ) );
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++)
{
broadcast(tes->at(i));
@@ -342,7 +342,7 @@ bool PlayerChunkMap::PlayerChunk::broadcastChanges(bool allowRegionUpdate)
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
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++)
{
int x = pos.x * 16 + ((changedTiles[i] >> 12) & 15);
@@ -361,11 +361,11 @@ bool PlayerChunkMap::PlayerChunk::broadcastChanges(bool allowRegionUpdate)
return didRegionUpdate;
}
void PlayerChunkMap::PlayerChunk::broadcast(shared_ptr<TileEntity> te)
void PlayerChunkMap::PlayerChunk::broadcast(std::shared_ptr<TileEntity> te)
{
if (te != NULL)
{
shared_ptr<Packet> p = te->getUpdatePacket();
std::shared_ptr<Packet> p = te->getUpdatePacket();
if (p != NULL)
{
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,
// 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);
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
// 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++ )
{
@@ -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.
void PlayerChunkMap::tickAddRequests(shared_ptr<ServerPlayer> player)
void PlayerChunkMap::tickAddRequests(std::shared_ptr<ServerPlayer> player)
{
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 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} };
@@ -649,7 +649,7 @@ void PlayerChunkMap::add(shared_ptr<ServerPlayer> player)
}
// 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
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 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
// 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 zc = ((int) player->z) >> 4;
@@ -744,7 +744,7 @@ int PlayerChunkMap::getMaxRange()
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);
@@ -775,7 +775,7 @@ void PlayerChunkMap::setRadius(int newRadius)
PlayerList* players = level->getServer()->getPlayerList();
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 )
{
int xc = ((int) player->x) >> 4;
+20 -20
View File
@@ -6,7 +6,7 @@ class ServerLevel;
class MinecraftServer;
class Packet;
class TileEntity;
using namespace std;
class PlayerChunkMap
{
@@ -25,8 +25,8 @@ public:
{
public:
int x,z;
shared_ptr<ServerPlayer> player;
PlayerChunkAddRequest(int x, int z, shared_ptr<ServerPlayer> player ) : x(x), z(z), player(player) {}
std::shared_ptr<ServerPlayer> player;
PlayerChunkAddRequest(int x, int z, std::shared_ptr<ServerPlayer> player ) : x(x), z(z), player(player) {}
};
class PlayerChunk
@@ -34,7 +34,7 @@ public:
friend class PlayerChunkMap;
private:
PlayerChunkMap *parent; // 4J added
vector<shared_ptr<ServerPlayer> > players;
std::vector<std::shared_ptr<ServerPlayer> > players;
//int x, z;
ChunkPos pos;
@@ -51,25 +51,25 @@ public:
~PlayerChunk();
// 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 remove(shared_ptr<ServerPlayer> player);
void add(std::shared_ptr<ServerPlayer> player, bool sendPacket = true);
void remove(std::shared_ptr<ServerPlayer> player);
void tileChanged(int x, int y, int z);
void prioritiseTileChanges(); // 4J added
void broadcast(shared_ptr<Packet> packet);
void broadcast(std::shared_ptr<Packet> packet);
bool broadcastChanges(bool allowRegionUpdate); // 4J - added parm
private:
void broadcast(shared_ptr<TileEntity> te);
void broadcast(std::shared_ptr<TileEntity> te);
};
public:
vector<shared_ptr<ServerPlayer> > players;
std::vector<std::shared_ptr<ServerPlayer> > players;
void flagEntitiesToBeRemoved(unsigned int *flags, bool *removedFound); // 4J added
private:
unordered_map<__int64,PlayerChunk *,LongKeyHash,LongKeyEq> chunks; // 4J - was LongHashMap
vector<PlayerChunk *> changedChunks;
vector<PlayerChunkAddRequest> addRequests; // 4J added
void tickAddRequests(shared_ptr<ServerPlayer> player); // 4J added
std::unordered_map<__int64,PlayerChunk *,LongKeyHash,LongKeyEq> chunks; // 4J - was LongHashMap
std::vector<PlayerChunk *> changedChunks;
std::vector<PlayerChunkAddRequest> addRequests; // 4J added
void tickAddRequests(std::shared_ptr<ServerPlayer> player); // 4J added
ServerLevel *level;
int radius;
@@ -83,21 +83,21 @@ public:
bool hasChunk(int x, int z);
private:
PlayerChunk *getChunk(int x, int z, bool create);
void getChunkAndAddPlayer(int x, int z, shared_ptr<ServerPlayer> player); // 4J added
void getChunkAndRemovePlayer(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, std::shared_ptr<ServerPlayer> player); // 4J added
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);
bool isTrackingTile(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 remove(shared_ptr<ServerPlayer> player);
void add(std::shared_ptr<ServerPlayer> player);
void remove(std::shared_ptr<ServerPlayer> player);
private:
bool chunkInRange(int x, int z, int xc, int zc);
public:
void move(shared_ptr<ServerPlayer> player);
void move(std::shared_ptr<ServerPlayer> player);
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);
// AP added for Vita
+109 -109
View File
@@ -34,7 +34,7 @@
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
done = false;
@@ -93,7 +93,7 @@ void PlayerConnection::tick()
lastKeepAliveTick = tickCount;
lastKeepAliveTime = System::nanoTime() / 1000000;
lastKeepAliveId = random.nextInt();
send( shared_ptr<KeepAlivePacket>( new KeepAlivePacket(lastKeepAliveId) ) );
send( std::shared_ptr<KeepAlivePacket>( new KeepAlivePacket(lastKeepAliveId) ) );
}
// if (!didTick) {
// 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
server->getPlayers()->removePlayerFromReceiving( player );
send( shared_ptr<DisconnectPacket>( new DisconnectPacket(reason) ));
send( std::shared_ptr<DisconnectPacket>( new DisconnectPacket(reason) ));
connection->sendAndQuit();
// 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())
{
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
{
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);
@@ -141,12 +141,12 @@ void PlayerConnection::disconnect(DisconnectPacket::eDisconnectReason reason)
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());
}
void PlayerConnection::handleMovePlayer(shared_ptr<MovePlayerPacket> packet)
void PlayerConnection::handleMovePlayer(std::shared_ptr<MovePlayerPacket> packet)
{
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);
// 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
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);
@@ -442,19 +442,19 @@ void PlayerConnection::handlePlayerAction(shared_ptr<PlayerActionPacket> packet)
if (packet->action == PlayerActionPacket::START_DESTROY_BLOCK)
{
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)
{
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
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)
{
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)
{
@@ -464,7 +464,7 @@ void PlayerConnection::handlePlayerAction(shared_ptr<PlayerActionPacket> packet)
double dist = xDist * xDist + yDist * yDist + zDist * zDist;
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);
shared_ptr<ItemInstance> item = player->inventory->getSelected();
std::shared_ptr<ItemInstance> item = player->inventory->getSelected();
bool informClient = false;
int x = packet->getX();
int y = packet->getY();
@@ -509,14 +509,14 @@ void PlayerConnection::handleUseItem(shared_ptr<UseItemPacket> packet)
}
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;
}
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 == 1) y++;
@@ -532,7 +532,7 @@ void PlayerConnection::handleUseItem(shared_ptr<UseItemPacket> packet)
// isn't what it is expecting.
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()))
{
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;
// logger.info(player.name + " lost connection: " + reason);
// 4J-PB - removed, since it needs to be localised in the language the client is in
//server->players->broadcastAll( shared_ptr<ChatPacket>( new ChatPacket(L"§e" + player->name + L" left the game.") ) );
//server->players->broadcastAll( std::shared_ptr<ChatPacket>( new ChatPacket(L"§e" + player->name + L" left the game.") ) );
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
{
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);
done = true;
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());
disconnect(DisconnectPacket::eDisconnect_UnexpectedPacket);
}
void PlayerConnection::send(shared_ptr<Packet> packet)
void PlayerConnection::send(std::shared_ptr<Packet> packet)
{
if( connection->getSocket() != NULL )
{
@@ -607,7 +607,7 @@ void PlayerConnection::send(shared_ptr<Packet> packet)
}
// 4J Added
void PlayerConnection::queueSend(shared_ptr<Packet> packet)
void PlayerConnection::queueSend(std::shared_ptr<Packet> packet)
{
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())
{
@@ -634,11 +634,11 @@ void PlayerConnection::handleSetCarriedItem(shared_ptr<SetCarriedItemPacket> pac
player->inventory->selected = packet->slot;
}
void PlayerConnection::handleChat(shared_ptr<ChatPacket> packet)
void PlayerConnection::handleChat(std::shared_ptr<ChatPacket> packet)
{
// 4J - TODO
#if 0
wstring message = packet->message;
std::wstring message = packet->message;
if (message.length() > SharedConstants::maxChatLength)
{
disconnect(L"Chat message too long");
@@ -670,7 +670,7 @@ void PlayerConnection::handleChat(shared_ptr<ChatPacket> packet)
#endif
}
void PlayerConnection::handleCommand(const wstring& message)
void PlayerConnection::handleCommand(const std::wstring& message)
{
// 4J - TODO
#if 0
@@ -678,7 +678,7 @@ void PlayerConnection::handleCommand(const wstring& message)
#endif
}
void PlayerConnection::handleAnimate(shared_ptr<AnimatePacket> packet)
void PlayerConnection::handleAnimate(std::shared_ptr<AnimatePacket> packet)
{
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)
{
@@ -725,7 +725,7 @@ void PlayerConnection::setShowOnMaps(bool 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
server->getPlayers()->removePlayerFromReceiving( player );
@@ -737,27 +737,27 @@ int PlayerConnection::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
//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
//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;
}
void PlayerConnection::handleInteract(shared_ptr<InteractPacket> packet)
void PlayerConnection::handleInteract(std::shared_ptr<InteractPacket> packet)
{
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
// 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;
}
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
@@ -808,7 +808,7 @@ void PlayerConnection::handleTexture(shared_ptr<TexturePacket> packet)
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
{
@@ -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
@@ -848,20 +848,20 @@ void PlayerConnection::handleTextureAndGeometry(shared_ptr<TextureAndGeometryPac
{
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
{
send( shared_ptr<TextureAndGeometryPacket>( new TextureAndGeometryPacket(packet->textureName,pbData,dwTextureBytes) ) );
send( std::shared_ptr<TextureAndGeometryPacket>( new TextureAndGeometryPacket(packet->textureName,pbData,dwTextureBytes) ) );
}
}
else
{
// 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);
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
@@ -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
AUTO_VAR(it, find( m_texturesRequested.begin(), m_texturesRequested.end(), textureName ));
@@ -906,13 +906,13 @@ void PlayerConnection::handleTextureReceived(const wstring &textureName)
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);
}
}
}
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
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))
{
send( shared_ptr<TextureAndGeometryPacket>( new TextureAndGeometryPacket(textureName,pbData,dwTextureBytes,pDLCSkinFile) ) );
send( std::shared_ptr<TextureAndGeometryPacket>( new TextureAndGeometryPacket(textureName,pbData,dwTextureBytes,pDLCSkinFile) ) );
}
else
{
// get the data from the app
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);
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);
}
}
}
void PlayerConnection::handleTextureChange(shared_ptr<TextureChangePacket> packet)
void PlayerConnection::handleTextureChange(std::shared_ptr<TextureChangePacket> packet)
{
switch(packet->action)
{
@@ -968,7 +968,7 @@ void PlayerConnection::handleTextureChange(shared_ptr<TextureChangePacket> packe
#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());
#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))
@@ -976,10 +976,10 @@ void PlayerConnection::handleTextureChange(shared_ptr<TextureChangePacket> packe
// Update the ref count on the memory texture data
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 ) );
@@ -995,7 +995,7 @@ void PlayerConnection::handleTextureAndGeometryChange(shared_ptr<TextureAndGeome
#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());
#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))
@@ -1009,10 +1009,10 @@ void PlayerConnection::handleTextureAndGeometryChange(shared_ptr<TextureAndGeome
//app.SetAdditionalSkinBoxes(packet->dwSkinID,)
//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)
{
@@ -1024,7 +1024,7 @@ void PlayerConnection::handleServerSettingsChanged(shared_ptr<ServerSettingsChan
app.SetGameHostOption(eGameHostOption_FireSpreads, app.GetGameHostOption(packet->data,eGameHostOption_FireSpreads));
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
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();
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);
}
void PlayerConnection::handleClientCommand(shared_ptr<ClientCommandPacket> packet)
void PlayerConnection::handleClientCommand(std::shared_ptr<ClientCommandPacket> packet)
{
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();
}
#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 )
{
@@ -1098,7 +1098,7 @@ void PlayerConnection::handleContainerSetSlot(shared_ptr<ContainerSetSlotPacket>
{
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 (lastItem == NULL || lastItem->count < packet->item->count)
@@ -1124,16 +1124,16 @@ void PlayerConnection::handleContainerSetSlot(shared_ptr<ContainerSetSlotPacket>
}
#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))
{
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))
{
// 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->containerMenu->broadcastChanges();
player->broadcastCarriedItem();
@@ -1143,10 +1143,10 @@ void PlayerConnection::handleContainerClick(shared_ptr<ContainerClickPacket> pac
{
// No, you clicked the wrong thing!
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);
vector<shared_ptr<ItemInstance> > items;
std::vector<std::shared_ptr<ItemInstance> > items;
for (unsigned int i = 0; i < player->containerMenu->slots->size(); i++)
{
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))
{
@@ -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())
{
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)
{
@@ -1189,17 +1189,17 @@ void PlayerConnection::handleSetCreativeModeSlot(shared_ptr<SetCreativeModeSlotP
#endif
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
// when a new one is created
wchar_t buf[64];
swprintf(buf,64,L"map_%d", item->getAuxValue());
std::wstring id = wstring(buf);
std::wstring id = std::wstring(buf);
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;
// 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;
// drop item
shared_ptr<ItemEntity> dropped = player->drop(item);
std::shared_ptr<ItemEntity> dropped = player->drop(item);
if (dropped != NULL)
{
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
// 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++)
{
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));
@@ -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");
ServerLevel *level = server->getLevel(player->dimension);
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)
{
shared_ptr<SignTileEntity> ste = dynamic_pointer_cast<SignTileEntity>(te);
std::shared_ptr<SignTileEntity> ste = dynamic_pointer_cast<SignTileEntity>(te);
if (!ste->isEditable())
{
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 y = packet->y;
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++)
{
wstring lineText = packet->lines[i].substr(0,15);
std::wstring lineText = packet->lines[i].substr(0,15);
ste->SetMessage( i, lineText );
}
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)
{
@@ -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?
INetworkPlayer *networkPlayer = getNetworkPlayer();
if( (networkPlayer != NULL && networkPlayer->IsHost()) || player->isModerator() )
{
shared_ptr<ServerPlayer> serverPlayer;
std::shared_ptr<ServerPlayer> serverPlayer;
// Find the player being edited
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)
{
serverPlayer = checkingPlayer;
@@ -1348,7 +1348,7 @@ void PlayerConnection::handlePlayerInfo(shared_ptr<PlayerInfoPacket> packet)
#endif
serverPlayer->setPlayerGamePrivilege(Player::ePlayerGamePrivilege_CreativeMode,Player::getPlayerGamePrivilege(packet->m_playerPrivileges,Player::ePlayerGamePrivilege_CreativeMode) );
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
{
@@ -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;
}
void PlayerConnection::handlePlayerAbilities(shared_ptr<PlayerAbilitiesPacket> playerAbilitiesPacket)
void PlayerConnection::handlePlayerAbilities(std::shared_ptr<PlayerAbilitiesPacket> playerAbilitiesPacket)
{
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()));
//}
//void handleClientInformation(shared_ptr<ClientInformationPacket> packet)
//void handleClientInformation(std::shared_ptr<ClientInformationPacket> packet)
//{
// player->updateOptions(packet);
//}
void PlayerConnection::handleCustomPayload(shared_ptr<CustomPayloadPacket> customPayloadPacket)
void PlayerConnection::handleCustomPayload(std::shared_ptr<CustomPayloadPacket> customPayloadPacket)
{
#if 0
if (CustomPayloadPacket.CUSTOM_BOOK_PACKET.equals(customPayloadPacket.identifier))
{
ByteArrayInputStream bais(customPayloadPacket->data);
DataInputStream input(&bais);
shared_ptr<ItemInstance> sentItem = Packet::readItem(input);
std::shared_ptr<ItemInstance> sentItem = Packet::readItem(input);
if (!WritingBookItem.makeSureTagIsValid(sentItem.getTag()))
{
@@ -1498,7 +1498,7 @@ void PlayerConnection::handleCustomPayload(shared_ptr<CustomPayloadPacket> custo
{
ByteArrayInputStream bais(customPayloadPacket->data);
DataInputStream dis(&bais);
wstring name = dis.readUTF();
std::wstring name = dis.readUTF();
if (name.length() <= 30)
{
menu->setItemName(name);
@@ -1510,13 +1510,13 @@ void PlayerConnection::handleCustomPayload(shared_ptr<CustomPayloadPacket> custo
// 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->SetDebugOptions(packet->m_uiVal);
}
void PlayerConnection::handleCraftItem(shared_ptr<CraftItemPacket> packet)
void PlayerConnection::handleCraftItem(std::shared_ptr<CraftItemPacket> packet)
{
int iRecipe = packet->recipe;
@@ -1524,7 +1524,7 @@ void PlayerConnection::handleCraftItem(shared_ptr<CraftItemPacket> packet)
return;
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)))
{
@@ -1549,7 +1549,7 @@ void PlayerConnection::handleCraftItem(shared_ptr<CraftItemPacket> packet)
{
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?
if(pRecipeIngredientsRequired[iRecipe].iIngAuxValA[i]!=Recipes::ANY_AUX_VALUE)
{
@@ -1568,7 +1568,7 @@ void PlayerConnection::handleCraftItem(shared_ptr<CraftItemPacket> packet)
if (ingItemInst->getItem()->hasCraftingRemainingItem())
{
// 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
// 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++)
{
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)
{
@@ -1642,8 +1642,8 @@ void PlayerConnection::handleTradeItem(shared_ptr<TradeItemPacket> packet)
if(!activeRecipe->isDeprecated())
{
// Do we have the ingredients?
shared_ptr<ItemInstance> buyAItem = activeRecipe->getBuyAItem();
shared_ptr<ItemInstance> buyBItem = activeRecipe->getBuyBItem();
std::shared_ptr<ItemInstance> buyAItem = activeRecipe->getBuyAItem();
std::shared_ptr<ItemInstance> buyBItem = activeRecipe->getBuyBItem();
int buyAMatches = player->inventory->countMatches(buyAItem);
int buyBMatches = player->inventory->countMatches(buyBItem);
@@ -1656,7 +1656,7 @@ void PlayerConnection::handleTradeItem(shared_ptr<TradeItemPacket> packet)
player->inventory->removeResources(buyBItem);
// 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.
player->awardStat(
+49 -49
View File
@@ -8,7 +8,7 @@ class Connection;
class ServerPlayer;
class INetworkPlayer;
using namespace std;
class PlayerConnection : public PacketListener, public ConsoleInputSource
{
@@ -25,7 +25,7 @@ public:
private:
MinecraftServer *server;
shared_ptr<ServerPlayer> player;
std::shared_ptr<ServerPlayer> player;
int tickCount;
int aboveGroundTickCount;
@@ -40,7 +40,7 @@ private:
bool m_bHasClientTickedOnce;
public:
PlayerConnection(MinecraftServer *server, Connection *connection, shared_ptr<ServerPlayer> player);
PlayerConnection(MinecraftServer *server, Connection *connection, std::shared_ptr<ServerPlayer> player);
~PlayerConnection();
void tick();
void disconnect(DisconnectPacket::eDisconnectReason reason);
@@ -50,78 +50,78 @@ private:
bool synched;
public:
virtual void handlePlayerInput(shared_ptr<PlayerInputPacket> packet);
virtual void handleMovePlayer(shared_ptr<MovePlayerPacket> packet);
virtual void handlePlayerInput(std::shared_ptr<PlayerInputPacket> 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
virtual void handlePlayerAction(shared_ptr<PlayerActionPacket> packet);
virtual void handleUseItem(shared_ptr<UseItemPacket> packet);
virtual void handlePlayerAction(std::shared_ptr<PlayerActionPacket> packet);
virtual void handleUseItem(std::shared_ptr<UseItemPacket> packet);
virtual void onDisconnect(DisconnectPacket::eDisconnectReason reason, void *reasonObjects);
virtual void onUnhandledPacket(shared_ptr<Packet> packet);
void send(shared_ptr<Packet> packet);
void queueSend(shared_ptr<Packet> packet); // 4J Added
virtual void handleSetCarriedItem(shared_ptr<SetCarriedItemPacket> packet);
virtual void handleChat(shared_ptr<ChatPacket> packet);
virtual void onUnhandledPacket(std::shared_ptr<Packet> packet);
void send(std::shared_ptr<Packet> packet);
void queueSend(std::shared_ptr<Packet> packet); // 4J Added
virtual void handleSetCarriedItem(std::shared_ptr<SetCarriedItemPacket> packet);
virtual void handleChat(std::shared_ptr<ChatPacket> packet);
private:
void handleCommand(const wstring& message);
void handleCommand(const std::wstring& message);
public:
virtual void handleAnimate(shared_ptr<AnimatePacket> packet);
virtual void handlePlayerCommand(shared_ptr<PlayerCommandPacket> packet);
virtual void handleDisconnect(shared_ptr<DisconnectPacket> packet);
virtual void handleAnimate(std::shared_ptr<AnimatePacket> packet);
virtual void handlePlayerCommand(std::shared_ptr<PlayerCommandPacket> packet);
virtual void handleDisconnect(std::shared_ptr<DisconnectPacket> packet);
int countDelayedPackets();
virtual void info(const wstring& string);
virtual void warn(const wstring& string);
virtual wstring getConsoleName();
virtual void handleInteract(shared_ptr<InteractPacket> packet);
virtual void info(const std::wstring& string);
virtual void warn(const std::wstring& string);
virtual std::wstring getConsoleName();
virtual void handleInteract(std::shared_ptr<InteractPacket> packet);
bool canHandleAsyncPackets();
virtual void handleClientCommand(shared_ptr<ClientCommandPacket> packet);
virtual void handleRespawn(shared_ptr<RespawnPacket> packet);
virtual void handleContainerClose(shared_ptr<ContainerClosePacket> packet);
virtual void handleClientCommand(std::shared_ptr<ClientCommandPacket> packet);
virtual void handleRespawn(std::shared_ptr<RespawnPacket> packet);
virtual void handleContainerClose(std::shared_ptr<ContainerClosePacket> packet);
private:
unordered_map<int, short, IntKeyHash, IntKeyEq> expectedAcks;
std::unordered_map<int, short, IntKeyHash, IntKeyEq> expectedAcks;
public:
// 4J Stu - Handlers only valid in debug mode
#ifndef _CONTENT_PACKAGE
virtual void handleContainerSetSlot(shared_ptr<ContainerSetSlotPacket> packet);
virtual void handleContainerSetSlot(std::shared_ptr<ContainerSetSlotPacket> packet);
#endif
virtual void handleContainerClick(shared_ptr<ContainerClickPacket> packet);
virtual void handleContainerButtonClick(shared_ptr<ContainerButtonClickPacket> packet);
virtual void handleSetCreativeModeSlot(shared_ptr<SetCreativeModeSlotPacket> packet);
virtual void handleContainerAck(shared_ptr<ContainerAckPacket> packet);
virtual void handleSignUpdate(shared_ptr<SignUpdatePacket> packet);
virtual void handleKeepAlive(shared_ptr<KeepAlivePacket> packet);
virtual void handlePlayerInfo(shared_ptr<PlayerInfoPacket> packet); // 4J Added
virtual void handleContainerClick(std::shared_ptr<ContainerClickPacket> packet);
virtual void handleContainerButtonClick(std::shared_ptr<ContainerButtonClickPacket> packet);
virtual void handleSetCreativeModeSlot(std::shared_ptr<SetCreativeModeSlotPacket> packet);
virtual void handleContainerAck(std::shared_ptr<ContainerAckPacket> packet);
virtual void handleSignUpdate(std::shared_ptr<SignUpdatePacket> packet);
virtual void handleKeepAlive(std::shared_ptr<KeepAlivePacket> packet);
virtual void handlePlayerInfo(std::shared_ptr<PlayerInfoPacket> packet); // 4J Added
virtual bool isServerPacketListener();
virtual void handlePlayerAbilities(shared_ptr<PlayerAbilitiesPacket> playerAbilitiesPacket);
virtual void handleCustomPayload(shared_ptr<CustomPayloadPacket> customPayloadPacket);
virtual void handlePlayerAbilities(std::shared_ptr<PlayerAbilitiesPacket> playerAbilitiesPacket);
virtual void handleCustomPayload(std::shared_ptr<CustomPayloadPacket> customPayloadPacket);
// 4J Added
virtual void handleCraftItem(shared_ptr<CraftItemPacket> packet);
virtual void handleTradeItem(shared_ptr<TradeItemPacket> packet);
virtual void handleDebugOptions(shared_ptr<DebugOptionsPacket> packet);
virtual void handleTexture(shared_ptr<TexturePacket> packet);
virtual void handleTextureAndGeometry(shared_ptr<TextureAndGeometryPacket> packet);
virtual void handleTextureChange(shared_ptr<TextureChangePacket> packet);
virtual void handleTextureAndGeometryChange(shared_ptr<TextureAndGeometryChangePacket> packet);
virtual void handleServerSettingsChanged(shared_ptr<ServerSettingsChangedPacket> packet);
virtual void handleKickPlayer(shared_ptr<KickPlayerPacket> packet);
virtual void handleGameCommand(shared_ptr<GameCommandPacket> packet);
virtual void handleCraftItem(std::shared_ptr<CraftItemPacket> packet);
virtual void handleTradeItem(std::shared_ptr<TradeItemPacket> packet);
virtual void handleDebugOptions(std::shared_ptr<DebugOptionsPacket> packet);
virtual void handleTexture(std::shared_ptr<TexturePacket> packet);
virtual void handleTextureAndGeometry(std::shared_ptr<TextureAndGeometryPacket> packet);
virtual void handleTextureChange(std::shared_ptr<TextureChangePacket> packet);
virtual void handleTextureAndGeometryChange(std::shared_ptr<TextureAndGeometryChangePacket> packet);
virtual void handleServerSettingsChanged(std::shared_ptr<ServerSettingsChangedPacket> packet);
virtual void handleKickPlayer(std::shared_ptr<KickPlayerPacket> packet);
virtual void handleGameCommand(std::shared_ptr<GameCommandPacket> packet);
INetworkPlayer *getNetworkPlayer();
bool isLocal();
bool isGuest();
// 4J Added as we need to set this from outside sometimes
void setPlayer(shared_ptr<ServerPlayer> player) { this->player = player; }
shared_ptr<ServerPlayer> getPlayer() { return player; }
void setPlayer(std::shared_ptr<ServerPlayer> player) { this->player = player; }
std::shared_ptr<ServerPlayer> getPlayer() { return player; }
// 4J Added to signal a disconnect from another thread
void closeOnTick() { m_bCloseOnTick = true; }
// 4J Added so that we can send on textures that get received after this connection requested them
void handleTextureReceived(const wstring &textureName);
void handleTextureAndGeometryReceived(const wstring &textureName);
void handleTextureReceived(const std::wstring &textureName);
void handleTextureAndGeometryReceived(const std::wstring &textureName);
void setShowOnMaps(bool bVal);
@@ -133,7 +133,7 @@ public:
private:
bool m_bCloseOnTick;
vector<wstring> m_texturesRequested;
std::vector<std::wstring> m_texturesRequested;
bool m_bWasKicked;
};
+3 -3
View File
@@ -1,13 +1,13 @@
#pragma once
using namespace std;
class PlayerInfo
{
public:
wstring name;
std::wstring name;
int latency;
PlayerInfo(const wstring &name)
PlayerInfo(const std::wstring &name)
{
this->name = name;
latency = 0;
+104 -104
View File
@@ -72,7 +72,7 @@ PlayerList::~PlayerList()
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);
player->setLevel(server->getLevel(player->dimension));
@@ -127,8 +127,8 @@ void PlayerList::placeNewPlayer(Connection *connection, shared_ptr<ServerPlayer>
player->setCustomCape( packet->m_playerCapeId );
// 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));
//player->connection = playerConnection; // Used to be assigned in PlayerConnection ctor but moved out so we can use shared_ptr
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 std::shared_ptr
if(newPlayer)
{
@@ -143,7 +143,7 @@ void PlayerList::placeNewPlayer(Connection *connection, shared_ptr<ServerPlayer>
int centreZC = 0;
#endif
// 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)
{
app.getGameRuleDefinitions()->postProcessPlayer(player);
@@ -157,7 +157,7 @@ void PlayerList::placeNewPlayer(Connection *connection, shared_ptr<ServerPlayer>
#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());
#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))
@@ -173,7 +173,7 @@ void PlayerList::placeNewPlayer(Connection *connection, shared_ptr<ServerPlayer>
#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());
#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))
@@ -196,8 +196,8 @@ void PlayerList::placeNewPlayer(Connection *connection, shared_ptr<ServerPlayer>
player->setPlayerGamePrivilege(Player::ePlayerGamePrivilege_CreativeMode,player->gameMode->getGameModeForPlayer()->getId() );
}
//shared_ptr<PlayerConnection> playerConnection = 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
//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 std::shared_ptr
// 4J Added to store UGC settings
playerConnection->m_friendsOnlyUGC = packet->m_friendsOnlyUGC;
@@ -209,19 +209,19 @@ void PlayerList::placeNewPlayer(Connection *connection, shared_ptr<ServerPlayer>
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(),
level->difficulty, TelemetryManager->GetMultiplayerInstanceID(), (BYTE)playerIndex, level->useNewSeaLevel(), player->getAllPlayerGamePrivileges(),
level->getLevelData()->getXZSize(), level->getLevelData()->getHellScale() ) ) );
playerConnection->send( 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<SetSpawnPositionPacket>( new SetSpawnPositionPacket(spawnPos->x, spawnPos->y, spawnPos->z) ) );
playerConnection->send( std::shared_ptr<PlayerAbilitiesPacket>( new PlayerAbilitiesPacket(&player->abilities)) );
delete spawnPos;
sendLevelInfo(player, level);
// 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.") ) );
broadcastAll( shared_ptr<ChatPacket>( new ChatPacket(player->name, ChatPacket::e_ChatPlayerJoinedGame) ) );
//server->players->broadcastAll( std::shared_ptr<ChatPacket>( new ChatPacket(L"§e" + playerEntity->name + L" joined the game.") ) );
broadcastAll( std::shared_ptr<ChatPacket>( new ChatPacket(player->name, ChatPacket::e_ChatPlayerJoinedGame) ) );
MemSect(14);
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);
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());
for(AUTO_VAR(it, activeEffects->begin()); it != activeEffects->end(); ++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();
@@ -249,7 +249,7 @@ void PlayerList::placeNewPlayer(Connection *connection, shared_ptr<ServerPlayer>
{
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();
if(thisPlayer != checkPlayer && checkPlayer != NULL && thisPlayer->IsSameSystem( checkPlayer ) && servPlayer->wonGame )
{
@@ -265,7 +265,7 @@ void PlayerList::setLevel(ServerLevelArray levels)
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();
@@ -281,12 +281,12 @@ int PlayerList::getMaxRange()
}
// 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);
}
void PlayerList::save(shared_ptr<ServerPlayer> player)
void PlayerList::save(std::shared_ptr<ServerPlayer> 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
// 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
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
// 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() )
{
broadcastAll(shared_ptr<PlayerInfoPacket>( new PlayerInfoPacket( player ) ) );
broadcastAll(std::shared_ptr<PlayerInfoPacket>( new PlayerInfoPacket( player ) ) );
}
players.push_back(player);
@@ -386,36 +386,36 @@ void PlayerList::add(shared_ptr<ServerPlayer> player)
for (int i = 0; i < players.size(); i++)
{
shared_ptr<ServerPlayer> op = players.at(i);
//player->connection->send(shared_ptr<PlayerInfoPacket>( new PlayerInfoPacket(op->name, true, op->latency) ) );
std::shared_ptr<ServerPlayer> op = players.at(i);
//player->connection->send(std::shared_ptr<PlayerInfoPacket>( new PlayerInfoPacket(op->name, true, op->latency) ) );
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())
{
shared_ptr<ServerPlayer> firstSleepingPlayer = nullptr;
std::shared_ptr<ServerPlayer> firstSleepingPlayer = nullptr;
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(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);
}
void PlayerList::remove(shared_ptr<ServerPlayer> player)
void PlayerList::remove(std::shared_ptr<ServerPlayer> 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
@@ -428,7 +428,7 @@ void PlayerList::remove(shared_ptr<ServerPlayer> player)
{
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);
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);
}
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)
{
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->setXuid( xuid ); // 4J Added
player->setOnlineXuid( onlineXuid ); // 4J Added
@@ -469,7 +469,7 @@ shared_ptr<ServerPlayer> PlayerList::getPlayerForLogin(PendingConnection *pendin
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.
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++ )
{
shared_ptr<ServerPlayer> ep = players[i];
std::shared_ptr<ServerPlayer> ep = players[i];
if( ep == serverPlayer ) continue;
if( ep->dimension != oldDimension ) continue;
@@ -540,7 +540,7 @@ shared_ptr<ServerPlayer> PlayerList::respawn(shared_ptr<ServerPlayer> serverPlay
PlayerUID playerXuid = serverPlayer->getXuid();
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);
if (keepAllPlayerData)
{
@@ -598,7 +598,7 @@ shared_ptr<ServerPlayer> PlayerList::respawn(shared_ptr<ServerPlayer> serverPlay
}
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;
}
@@ -611,19 +611,19 @@ shared_ptr<ServerPlayer> PlayerList::respawn(shared_ptr<ServerPlayer> serverPlay
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->level->useNewSeaLevel(), player->entityId, level->getLevelData()->getXZSize(), level->getLevelData()->getHellScale()) ) );
player->connection->teleport(player->x, player->y, player->z, player->yRot, player->xRot);
if(keepAllPlayerData)
{
vector<MobEffectInstance *> *activeEffects = player->getActiveEffects();
std::vector<MobEffectInstance *> *activeEffects = player->getActiveEffects();
for(AUTO_VAR(it, activeEffects->begin()); it != activeEffects->end(); ++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;
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;
// 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++ )
{
shared_ptr<ServerPlayer> ep = players[i];
std::shared_ptr<ServerPlayer> ep = players[i];
if( ep == player ) 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
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(),
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);
// 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)
{
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;
player->getEntityData()->markDirty(Mob::DATA_EFFECT_COLOR_ID);
@@ -835,11 +835,11 @@ void PlayerList::tick()
if (sendAllPlayerInfoIn < players.size())
{
shared_ptr<ServerPlayer> op = players[sendAllPlayerInfoIn];
//broadcastAll(shared_ptr<PlayerInfoPacket>( new PlayerInfoPacket(op->name, true, op->latency) ) );
std::shared_ptr<ServerPlayer> op = players[sendAllPlayerInfoIn];
//broadcastAll(std::shared_ptr<PlayerInfoPacket>( new PlayerInfoPacket(op->name, true, op->latency) ) );
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();
m_smallIdsToClose.pop_front();
shared_ptr<ServerPlayer> player = nullptr;
std::shared_ptr<ServerPlayer> player = nullptr;
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
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
PlayerUID xuid = selectedPlayer->GetUID();
// 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++)
{
shared_ptr<ServerPlayer> p = players.at(i);
std::shared_ptr<ServerPlayer> p = players.at(i);
PlayerUID playersXuid = p->getOnlineXuid();
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
player->enableAllPlayerPrivileges( false );
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
}
@@ -914,10 +914,10 @@ void PlayerList::tick()
{
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)
{
shared_ptr<ServerPlayer> newPlayer = findAlivePlayerOnSystem(currentPlayer);
std::shared_ptr<ServerPlayer> newPlayer = findAlivePlayerOnSystem(currentPlayer);
if(newPlayer != NULL)
{
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);
}
void PlayerList::broadcastAll(shared_ptr<Packet> packet)
void PlayerList::broadcastAll(std::shared_ptr<Packet> packet)
{
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);
}
}
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++)
{
shared_ptr<ServerPlayer> player = players[i];
std::shared_ptr<ServerPlayer> player = players[i];
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++)
{
if (i > 0) msg += L", ";
@@ -968,17 +968,17 @@ wstring PlayerList::getPlayerNames()
return msg;
}
bool PlayerList::isWhiteListed(const wstring& name)
bool PlayerList::isWhiteListed(const std::wstring& name)
{
return true;
}
bool PlayerList::isOp(const wstring& name)
bool PlayerList::isOp(const std::wstring& name)
{
return false;
}
bool PlayerList::isOp(shared_ptr<ServerPlayer> player)
bool PlayerList::isOp(std::shared_ptr<ServerPlayer> player)
{
bool cheatsEnabled = app.GetGameHostOption(eGameHostOption_CheatsEnabled);
#ifdef _DEBUG_MENUS_ENABLED
@@ -989,11 +989,11 @@ bool PlayerList::isOp(shared_ptr<ServerPlayer> player)
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++)
{
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
{
return p;
@@ -1003,11 +1003,11 @@ shared_ptr<ServerPlayer> PlayerList::getPlayer(const wstring& name)
}
// 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++)
{
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
{
return p;
@@ -1016,25 +1016,25 @@ shared_ptr<ServerPlayer> PlayerList::getPlayer(PlayerUID uid)
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)
{
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);
}
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
// machine either
vector< shared_ptr<ServerPlayer> > sentTo;
std::vector< std::shared_ptr<ServerPlayer> > sentTo;
if( except != NULL )
{
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++)
{
shared_ptr<ServerPlayer> p = players[i];
std::shared_ptr<ServerPlayer> p = players[i];
if (p == except) 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++ )
{
shared_ptr<ServerPlayer> player2 = sentTo[j];
std::shared_ptr<ServerPlayer> player2 = sentTo[j];
INetworkPlayer *otherPlayer = player2->connection->getNetworkPlayer();
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 0 // _DEBUG
shared_ptr<LevelSoundPacket> SoundPacket= dynamic_pointer_cast<LevelSoundPacket>(packet);
std::shared_ptr<LevelSoundPacket> SoundPacket= dynamic_pointer_cast<LevelSoundPacket>(packet);
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++)
{
shared_ptr<ServerPlayer> p = players[i];
std::shared_ptr<ServerPlayer> p = players[i];
if (isOp(p->name))
{
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)
{
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())
{
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
{
// 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
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
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->resetSentInfo();
@@ -1218,7 +1218,7 @@ void PlayerList::setOverrideGameMode(GameType *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
@@ -1239,7 +1239,7 @@ void PlayerList::setAllowCheatsForAllPlayers(bool 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;
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)
{
shared_ptr<ServerPlayer> newPlayer = *itP;
std::shared_ptr<ServerPlayer> newPlayer = *itP;
INetworkPlayer *otherPlayer = newPlayer->connection->getNetworkPlayer();
@@ -1270,7 +1270,7 @@ shared_ptr<ServerPlayer> PlayerList::findAlivePlayerOnSystem(shared_ptr<ServerPl
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;
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)
{
shared_ptr<ServerPlayer> newPlayer = *itP;
std::shared_ptr<ServerPlayer> newPlayer = *itP;
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
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();
if( checkingPlayer != NULL )
@@ -1335,7 +1335,7 @@ void PlayerList::removePlayerFromReceiving(shared_ptr<ServerPlayer> player, bool
bool foundPrimary = false;
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();
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;
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)
{
shared_ptr<ServerPlayer> oldPlayer = *it;
std::shared_ptr<ServerPlayer> oldPlayer = *it;
INetworkPlayer *checkingPlayer = oldPlayer->connection->getNetworkPlayer();
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;
if( player->dimension == -1 ) playerDim = 1;
else if( player->dimension == 1) playerDim = 2;
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)
{
return true;
+37 -37
View File
@@ -14,7 +14,7 @@ class ProgressListener;
class GameType;
class LoginPacket;
using namespace std;
class PlayerList
{
@@ -22,14 +22,14 @@ private:
static const int SEND_PLAYER_INFO_INTERVAL = 20 * 10; // 4J - brought forward from 1.2.3
// public static Logger logger = Logger.getLogger("Minecraft");
public:
vector<shared_ptr<ServerPlayer> > players;
std::vector<std::shared_ptr<ServerPlayer> > players;
private:
MinecraftServer *server;
unsigned int maxPlayers;
// 4J Added
vector<PlayerUID> m_bannedXuids;
std::vector<PlayerUID> m_bannedXuids;
deque<BYTE> m_smallIdsToKick;
CRITICAL_SECTION m_kickPlayersCS;
deque<BYTE> m_smallIdsToClose;
@@ -51,60 +51,60 @@ private:
int sendAllPlayerInfoIn;
// 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:
shared_ptr<ServerPlayer> findAlivePlayerOnSystem(shared_ptr<ServerPlayer> currentPlayer);
std::shared_ptr<ServerPlayer> findAlivePlayerOnSystem(std::shared_ptr<ServerPlayer> currentPlayer);
public:
void removePlayerFromReceiving(shared_ptr<ServerPlayer> player, bool usePlayerDimension = true, int dimension = 0);
void addPlayerToReceiving(shared_ptr<ServerPlayer> player);
bool canReceiveAllPackets(shared_ptr<ServerPlayer> player);
void removePlayerFromReceiving(std::shared_ptr<ServerPlayer> player, bool usePlayerDimension = true, int dimension = 0);
void addPlayerToReceiving(std::shared_ptr<ServerPlayer> player);
bool canReceiveAllPackets(std::shared_ptr<ServerPlayer> player);
public:
PlayerList(MinecraftServer *server);
~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 changeDimension(shared_ptr<ServerPlayer> player, ServerLevel *from);
void changeDimension(std::shared_ptr<ServerPlayer> player, ServerLevel *from);
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:
void save(shared_ptr<ServerPlayer> player);
void save(std::shared_ptr<ServerPlayer> player);
public:
void validatePlayerSpawnPosition(shared_ptr<ServerPlayer> player); // 4J Added
void add(shared_ptr<ServerPlayer> player);
void move(shared_ptr<ServerPlayer> player);
void remove(shared_ptr<ServerPlayer> player);
shared_ptr<ServerPlayer> getPlayerForLogin(PendingConnection *pendingConnection, const wstring& userName, PlayerUID xuid, PlayerUID OnlineXuid);
shared_ptr<ServerPlayer> respawn(shared_ptr<ServerPlayer> serverPlayer, int targetDimension, bool keepAllPlayerData);
void toggleDimension(shared_ptr<ServerPlayer> player, int targetDimension);
void validatePlayerSpawnPosition(std::shared_ptr<ServerPlayer> player); // 4J Added
void add(std::shared_ptr<ServerPlayer> player);
void move(std::shared_ptr<ServerPlayer> player);
void remove(std::shared_ptr<ServerPlayer> player);
std::shared_ptr<ServerPlayer> getPlayerForLogin(PendingConnection *pendingConnection, const std::wstring& userName, PlayerUID xuid, PlayerUID OnlineXuid);
std::shared_ptr<ServerPlayer> respawn(std::shared_ptr<ServerPlayer> serverPlayer, int targetDimension, bool keepAllPlayerData);
void toggleDimension(std::shared_ptr<ServerPlayer> player, int targetDimension);
void tick();
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 broadcastAll(shared_ptr<Packet> packet);
void broadcastAll(shared_ptr<Packet> packet, int dimension);
void broadcastAll(std::shared_ptr<Packet> packet);
void broadcastAll(std::shared_ptr<Packet> packet, int dimension);
wstring getPlayerNames();
std::wstring getPlayerNames();
public:
bool isWhiteListed(const wstring& name);
bool isOp(const wstring& name);
bool isOp(shared_ptr<ServerPlayer> player); // 4J Added
shared_ptr<ServerPlayer> getPlayer(const wstring& name);
shared_ptr<ServerPlayer> getPlayer(PlayerUID uid);
void sendMessage(const wstring& name, const wstring& message);
void broadcast(double x, double y, double z, double range, int dimension, 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 broadcastToAllOps(const wstring& message);
bool sendTo(const wstring& name, shared_ptr<Packet> packet);
bool isWhiteListed(const std::wstring& name);
bool isOp(const std::wstring& name);
bool isOp(std::shared_ptr<ServerPlayer> player); // 4J Added
std::shared_ptr<ServerPlayer> getPlayer(const std::wstring& name);
std::shared_ptr<ServerPlayer> getPlayer(PlayerUID uid);
void sendMessage(const std::wstring& name, const std::wstring& message);
void broadcast(double x, double y, double z, double range, int dimension, std::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 std::wstring& message);
bool sendTo(const std::wstring& name, std::shared_ptr<Packet> packet);
// 4J Added ProgressListener *progressListener param and bDeleteGuestMaps param
void saveAll(ProgressListener *progressListener, bool bDeleteGuestMaps = false);
void whiteList(const wstring& playerName);
void blackList(const wstring& playerName);
void whiteList(const std::wstring& playerName);
void blackList(const std::wstring& playerName);
// Set<String> getWhiteList(); / 4J removed
void reloadWhitelist();
void sendLevelInfo(shared_ptr<ServerPlayer> player, ServerLevel *level);
void sendAllPlayerInfo(shared_ptr<ServerPlayer> player);
void sendLevelInfo(std::shared_ptr<ServerPlayer> player, ServerLevel *level);
void sendAllPlayerInfo(std::shared_ptr<ServerPlayer> player);
int getPlayerCount();
int getPlayerCount(ServerLevel *level); // 4J Added
int getMaxPlayers();
@@ -113,7 +113,7 @@ public:
void setOverrideGameMode(GameType *gameMode);
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:
void setAllowCheatsForAllPlayers(bool allowCommands);
@@ -74,7 +74,7 @@ bool ServerChunkCache::hasChunk(int x, int z)
return true;
}
vector<LevelChunk *> *ServerChunkCache::getLoadedChunkList()
std::vector<LevelChunk *> *ServerChunkCache::getLoadedChunkList()
{
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.
// 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++ )
{
@@ -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.
// 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++ )
{
@@ -897,17 +897,17 @@ bool ServerChunkCache::shouldSave()
return !level->noSave;
}
wstring ServerChunkCache::gatherStats()
std::wstring ServerChunkCache::gatherStats()
{
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);
}
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);
}
+7 -7
View File
@@ -5,14 +5,14 @@
#include "../../Minecraft.World/Util/JavaIntHash.h"
#include "../../Minecraft.World/Level/RandomLevelSource.h"
#include "../../Minecraft.World/Util/C4JThread.h"
using namespace std;
class ServerLevel;
class ServerChunkCache : public ChunkSource
{
private:
// unordered_set<int,IntKeyHash, IntKeyEq> toDrop;
// std::unordered_set<int,IntKeyHash, IntKeyEq> toDrop;
private:
LevelChunk *emptyChunk;
ChunkSource *source;
@@ -21,7 +21,7 @@ public:
bool autoCreate;
private:
LevelChunk **cache;
vector<LevelChunk *> m_loadedChunkList;
std::vector<LevelChunk *> m_loadedChunkList;
ServerLevel *level;
#ifdef _LARGE_WORLDS
@@ -39,7 +39,7 @@ public:
ServerChunkCache(ServerLevel *level, ChunkStorage *storage, ChunkSource *source);
virtual ~ServerChunkCache();
virtual bool hasChunk(int x, int z);
vector<LevelChunk *> *getLoadedChunkList();
std::vector<LevelChunk *> *getLoadedChunkList();
void drop(int x, int z);
void dropAll();
virtual LevelChunk *create(int x, int z);
@@ -80,10 +80,10 @@ public:
virtual bool save(bool force, ProgressListener *progressListener);
virtual bool tick();
virtual bool shouldSave();
virtual wstring gatherStats();
virtual std::wstring gatherStats();
virtual 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 std::vector<Biome::MobSpawnerData *> *getMobsAt(MobCategory *mobCategory, int x, int y, int z);
virtual TilePos *findNearestMapFeature(Level *level, const std::wstring &featureName, int x, int y, int z);
private:
typedef struct _SaveThreadData
@@ -52,13 +52,13 @@ ServerCommandDispatcher::ServerCommandDispatcher()
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();
//for (Player player : MinecraftServer.getInstance().getPlayers().players)
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))
{
// TODO: Change chat packet to be able to send more bits of data
@@ -7,5 +7,5 @@ class ServerCommandDispatcher : public CommandDispatcher, public AdminLogCommand
{
public:
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"");
};
+16 -16
View File
@@ -26,16 +26,16 @@ ServerConnection::~ServerConnection()
// 4J - added to handle incoming connections, to replace thread that original used to have
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);
}
void ServerConnection::addPlayerConnection(shared_ptr<PlayerConnection> uc)
void ServerConnection::addPlayerConnection(std::shared_ptr<PlayerConnection> uc)
{
players.push_back(uc);
}
void ServerConnection::handleConnection(shared_ptr<PendingConnection> uc)
void ServerConnection::handleConnection(std::shared_ptr<PendingConnection> uc)
{
EnterCriticalSection(&pending_cs);
pending.push_back(uc);
@@ -47,14 +47,14 @@ void ServerConnection::stop()
EnterCriticalSection(&pending_cs);
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);
}
LeaveCriticalSection(&pending_cs);
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);
}
}
@@ -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)
EnterCriticalSection(&pending_cs);
vector< shared_ptr<PendingConnection> > tempPending = pending;
std::vector< std::shared_ptr<PendingConnection> > tempPending = pending;
LeaveCriticalSection(&pending_cs);
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
uc->tick();
// } catch (Exception e) {
@@ -92,8 +92,8 @@ void ServerConnection::tick()
for (unsigned int i = 0; i < players.size(); i++)
{
shared_ptr<PlayerConnection> player = players[i];
shared_ptr<ServerPlayer> serverPlayer = player->getPlayer();
std::shared_ptr<PlayerConnection> player = players[i];
std::shared_ptr<ServerPlayer> serverPlayer = player->getPlayer();
if( serverPlayer )
{
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));
if( it == m_pendingTextureRequests.end() )
@@ -129,7 +129,7 @@ bool ServerConnection::addPendingTextureRequest(const wstring &textureName)
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));
if( it != m_pendingTextureRequests.end() )
@@ -138,7 +138,7 @@ void ServerConnection::handleTextureReceived(const wstring &textureName)
}
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)
{
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));
if( it != m_pendingTextureRequests.end() )
@@ -155,7 +155,7 @@ void ServerConnection::handleTextureAndGeometryReceived(const wstring &textureNa
}
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)
{
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();
@@ -197,7 +197,7 @@ void ServerConnection::handleServerSettingsChanged(shared_ptr<ServerSettingsChan
//
// 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());
// }
// }
+10 -10
View File
@@ -5,7 +5,7 @@ class MinecraftServer;
class Socket;
class ServerSettingsChangedPacket;
using namespace std;
class ServerConnection
{
@@ -20,11 +20,11 @@ private:
int connectionCounter;
private:
CRITICAL_SECTION pending_cs; // 4J added
vector< shared_ptr<PendingConnection> > pending;
vector< shared_ptr<PlayerConnection> > players;
std::vector< std::shared_ptr<PendingConnection> > pending;
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
vector<wstring> m_pendingTextureRequests;
std::vector<std::wstring> m_pendingTextureRequests;
public:
MinecraftServer *server;
@@ -34,16 +34,16 @@ public:
void NewIncomingSocket(Socket *socket); // 4J - added
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:
void handleConnection(shared_ptr<PendingConnection> uc);
void handleConnection(std::shared_ptr<PendingConnection> uc);
public:
void stop();
void tick();
// 4J Added
bool addPendingTextureRequest(const wstring &textureName);
void handleTextureReceived(const wstring &textureName);
void handleTextureAndGeometryReceived(const wstring &textureName);
void handleServerSettingsChanged(shared_ptr<ServerSettingsChangedPacket> packet);
bool addPendingTextureRequest(const std::wstring &textureName);
void handleTextureReceived(const std::wstring &textureName);
void handleTextureAndGeometryReceived(const std::wstring &textureName);
void handleServerSettingsChanged(std::shared_ptr<ServerSettingsChangedPacket> packet);
};
+17 -17
View File
@@ -1,29 +1,29 @@
#pragma once
using namespace std;
class ServerInterface
{
virtual int getConfigInt(const wstring &name, int defaultValue) = 0;
virtual wstring getConfigString(const wstring &name, const wstring &defaultValue) = 0;
virtual bool getConfigBoolean(const wstring &name, bool defaultValue) = 0;
virtual void setProperty(wstring &propertyName, void *value) = 0;
virtual int getConfigInt(const std::wstring &name, int defaultValue) = 0;
virtual std::wstring getConfigString(const std::wstring &name, const std::wstring &defaultValue) = 0;
virtual bool getConfigBoolean(const std::wstring &name, bool defaultValue) = 0;
virtual void setProperty(std::wstring &propertyName, void *value) = 0;
virtual void configSave() = 0;
virtual wstring getConfigPath() = 0;
virtual wstring getServerIp() = 0;
virtual std::wstring getConfigPath() = 0;
virtual std::wstring getServerIp() = 0;
virtual int getServerPort() = 0;
virtual wstring getServerName() = 0;
virtual wstring getServerVersion() = 0;
virtual std::wstring getServerName() = 0;
virtual std::wstring getServerVersion() = 0;
virtual int getPlayerCount() = 0;
virtual int getMaxPlayers() = 0;
virtual wstring[] getPlayerNames() = 0;
virtual wstring getWorldName() = 0;
virtual wstring getPluginNames() = 0;
virtual std::wstring[] getPlayerNames() = 0;
virtual std::wstring getWorldName() = 0;
virtual std::wstring getPluginNames() = 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;
// Logging
virtual void info(const wstring &string) = 0;
virtual void warn(const wstring &string) = 0;
virtual void error(const wstring &string) = 0;
virtual void debug(const wstring &string) = 0;
virtual void info(const std::wstring &string) = 0;
virtual void warn(const std::wstring &string) = 0;
virtual void error(const std::wstring &string) = 0;
virtual void debug(const std::wstring &string) = 0;
};
@@ -1,5 +1,5 @@
#pragma once
using namespace std;
#define MAX_DISPLAYNAME_LENGTH 128 // SCE_SAVE_DATA_SUBTITLE_MAXSIZE on PS4
#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_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);
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);
void TMSPP_ClearTitleStorageState(int iPad);
@@ -27,7 +27,7 @@ XALLOC_ATTRIBUTES ExpandAllocAttributes( _In_ LONGLONG dwAttributes )
}
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 memReset = false;
static bool memDumpInit = false;
@@ -169,7 +169,7 @@ void CConsoleMinecraftApp::FreeLocalTMSFiles(eTMSFileType eType)
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?
for( AUTO_VAR(it, pDLCInfoA->begin()); it != pDLCInfoA->end(); it++ )
{
@@ -183,7 +183,7 @@ int CConsoleMinecraftApp::LoadLocalDLCImages()
void CConsoleMinecraftApp::FreeLocalDLCImages()
{
// 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++ )
{
@@ -263,7 +263,7 @@ void CConsoleMinecraftApp::TemporaryCreateGameStart()
////////////////////////////////////////////////////////////////////////////////////////////// From CScene_MultiGameCreate::CreateGame
app.ClearTerrainFeaturePosition();
wstring wWorldName = L"TestWorld";
std::wstring wWorldName = L"TestWorld";
StorageManager.ResetSaveData();
StorageManager.SetSaveTitle(wWorldName.c_str());
@@ -559,7 +559,7 @@ int CConsoleMinecraftApp::Callback_TMSPPRetrieveFileList(void *pParam,int iPad,
app.DebugPrintf("CConsoleMinecraftApp::Callback_TMSPPRetrieveFileList\n");
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)
{
@@ -984,7 +984,7 @@ void oldWinMainTick()
#ifdef MEMORY_TRACKING
int totalAllocGen = 0;
unordered_map<int,int> allocCounts;
std::unordered_map<int,int> allocCounts;
bool trackEnable = false;
bool trackStarted = false;
volatile size_t sizeCheckMin = 1160;
@@ -408,7 +408,7 @@ void DurangoLeaderboardManager::runLeaderboardRequest(WF::IAsyncOperation<MXSL::
// Build stat names
m_statNames = ref new PC::Vector<P::String^>();
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()));
}
@@ -490,7 +490,7 @@ void DurangoLeaderboardManager::runLeaderboardRequest(WF::IAsyncOperation<MXSL::
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++)
{
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;
for(wstring statName : m_leaderboardStatNames[difficulty][type])
for(std::wstring statName : m_leaderboardStatNames[difficulty][type])
{
bool found = false;
for(auto result : statsResult)
@@ -585,7 +585,7 @@ void DurangoLeaderboardManager::GetProfilesCallback(LPVOID param, std::vector<Mi
if (profiles.size() > 0)
{
dlm->m_displayNames = vector<wstring>();
dlm->m_displayNames = std::vector<std::wstring>();
for (int i = 0; i < profiles.size(); i++)
{
dlm->m_displayNames.push_back(profiles[i]->GameDisplayName->Data());
@@ -699,7 +699,7 @@ void DurangoLeaderboardManager::setState(EStatsState newState)
LeaveCriticalSection(&m_csStatsState);
}
wstring DurangoLeaderboardManager::stateToString(EStatsState eState)
std::wstring DurangoLeaderboardManager::stateToString(EStatsState eState)
{
switch (eState)
{
@@ -35,12 +35,12 @@ private:
unsigned int m_maxRank;
MXS::XboxLiveContext^ m_xboxLiveContext;
wstring m_leaderboardNames[4][eStatsType_MAX];
wstring m_socialLeaderboardNames[4][eStatsType_MAX];
std::vector<wstring> m_leaderboardStatNames[4][eStatsType_MAX];
std::wstring m_leaderboardNames[4][eStatsType_MAX];
std::wstring m_socialLeaderboardNames[4][eStatsType_MAX];
std::vector<std::wstring> m_leaderboardStatNames[4][eStatsType_MAX];
// Display names for the current scores
std::vector<wstring> m_displayNames;
std::vector<std::wstring> m_displayNames;
bool m_waitingForProfiles;
int m_difficulty;
@@ -90,5 +90,5 @@ private:
EStatsState getState();
void setState(EStatsState newState);
wstring stateToString(EStatsState eState);
std::wstring stateToString(EStatsState eState);
};
@@ -16,14 +16,14 @@
namespace WFC = Windows::Foundation::Collections;
namespace CC = concurrency;
StatParam::StatParam(const wstring &base)
StatParam::StatParam(const std::wstring &base)
{
m_base = base;
//m_numArgs = numArgs;
m_args = vector<int>();
m_args = std::vector<int>();
unsigned int count=0;
wstring::size_type pos =base.find(L"*");
std::wstring::size_type pos =base.find(L"*");
while(pos!=string::npos)
{
count++;
@@ -46,14 +46,14 @@ void StatParam::addArgs(int v1, ...)
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 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)
{
@@ -69,10 +69,10 @@ vector<wstring> *StatParam::getStats()
{
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);
if (sz != wstring::npos)
if (sz != std::wstring::npos)
wstr_itr.replace(sz, SUBSTR.length(), wstr_num);
}
}
@@ -91,13 +91,13 @@ DurangoStatsDebugger::DurangoStatsDebugger()
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++)
{
vector<wstring> *sublist = (*it)->getStats();
std::vector<std::wstring> *sublist = (*it)->getStats();
out->insert(out->end(), sublist->begin(), sublist->end());
}
@@ -322,11 +322,11 @@ void DurangoStatsDebugger::PrintStats(int iPad)
{
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());
// 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");
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.
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)
{
@@ -11,17 +11,17 @@ namespace MXSL = Microsoft::Xbox::Services::Leaderboard;
class StatParam
{
private:
wstring m_base;
std::wstring m_base;
int m_numArgs;
vector<int> m_args;
std::vector<int> m_args;
public:
StatParam(const wstring &base);
StatParam(const std::wstring &base);
void addArgs(int v1, ...);
vector<wstring> *getStats();
std::vector<std::wstring> *getStats();
};
@@ -65,9 +65,9 @@ protected:
DurangoStatsDebugger();
vector<StatParam *> m_stats;
std::vector<StatParam *> m_stats;
vector<wstring> *getStats();
std::vector<std::wstring> *getStats();
public:
static DurangoStatsDebugger *Initialize();
@@ -75,20 +75,20 @@ public:
static void PrintStats(int iPad);
private:
vector<wstring> m_printQueue;
std::vector<std::wstring> m_printQueue;
void retrieveStats(int iPad);
typedef struct
{
int m_iPad;
wstring m_statName;
wstring m_score;
std::wstring m_statName;
std::wstring m_score;
} StatResult;
CRITICAL_SECTION m_retrievedStatsLock;
vector<StatResult> m_retrievedStats;
std::vector<StatResult> m_retrievedStats;
void addRetrievedStat(StatResult result);
};
@@ -51,7 +51,7 @@ public:
void RemoveLocalUser( __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;
private:
@@ -22,14 +22,14 @@ DQRNetworkManager::ePartyProcessType DQRNetworkManager::m_partyProcess = DQRNetw
bool DQRNetworkManager::m_inviteReceived = false;
int DQRNetworkManager::m_bootUserIndex;
wstring DQRNetworkManager::m_bootSessionName;
wstring DQRNetworkManager::m_bootServiceConfig;
wstring DQRNetworkManager::m_bootSessionTemplate;
std::wstring DQRNetworkManager::m_bootSessionName;
std::wstring DQRNetworkManager::m_bootServiceConfig;
std::wstring DQRNetworkManager::m_bootSessionTemplate;
DQRNetworkManager * DQRNetworkManager::s_pDQRManager = NULL;
//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_sessionName = sessionName;
@@ -782,7 +782,7 @@ DQRNetworkPlayer *DQRNetworkManager::GetPlayerByXuid(PlayerUID xuid)
}
// 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())
{
@@ -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.
void DQRNetworkManager::UpdateRoomSyncPlayers(RoomSyncData *pNewSyncData)
{
vector<DQRNetworkPlayer *> tempPlayers;
vector<DQRNetworkPlayer *> newPlayers;
std::vector<DQRNetworkPlayer *> tempPlayers;
std::vector<DQRNetworkPlayer *> newPlayers;
EnterCriticalSection(&m_csRoomSyncData);
@@ -1574,7 +1574,7 @@ bool DQRNetworkManager::AddRoomSyncPlayer(DQRNetworkPlayer *pPlayer, unsigned in
void DQRNetworkManager::RemoveRoomSyncPlayersWithSessionAddress(unsigned int sessionAddress)
{
EnterCriticalSection(&m_csRoomSyncData);
vector<DQRNetworkPlayer *> removedPlayers;
std::vector<DQRNetworkPlayer *> removedPlayers;
int iWriteIdx = 0;
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.
void DQRNetworkManager::RemoveRoomSyncPlayer(DQRNetworkPlayer *pPlayer)
{
vector<DQRNetworkPlayer *> removedPlayers;
std::vector<DQRNetworkPlayer *> removedPlayers;
int iWriteIdx = 0;
for( int i = 0; i < m_roomSyncData.playerCount; i++ )
{
@@ -2184,7 +2184,7 @@ int DQRNetworkManager::HostGameThreadProc()
if( m_currentUserMask & ( 1 << i ) && ProfileManager.IsSignedIn(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);
pPlayer->SetSmallId(smallId);
@@ -3031,7 +3031,7 @@ void DQRNetworkManager::GetProfileCallback(LPVOID pParam, Microsoft::Xbox::Servi
}
// Set player display name
void DQRNetworkManager::SetDisplayName(PlayerUID xuid, wstring displayName)
void DQRNetworkManager::SetDisplayName(PlayerUID xuid, std::wstring displayName)
{
EnterCriticalSection(&m_csRoomSyncData);
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 MAX_PLAYERS_IN_TEMPLATE 8
using namespace std;
ref class DQRNetworkManagerEventHandlers sealed
{
@@ -119,12 +119,12 @@ public:
class SessionInfo
{
public:
SessionInfo(wstring& sessionName, wstring& serviceConfig, wstring& sessionTemplate);
SessionInfo(std::wstring& sessionName, std::wstring& serviceConfig, std::wstring& sessionTemplate);
SessionInfo();
bool m_detailsValid;
wstring m_sessionName;
wstring m_serviceConfig;
wstring m_sessionTemplate;
std::wstring m_sessionName;
std::wstring m_serviceConfig;
std::wstring m_sessionTemplate;
};
static const int MAX_LOCAL_PLAYER_COUNT = 4;
@@ -153,7 +153,7 @@ public:
{
public:;
DQRNetworkPlayer* m_pPlayer;
wstring m_name;
std::wstring m_name;
unsigned int m_sessionAddress;
int m_channel;
bool m_sync;
@@ -181,7 +181,7 @@ public:
DQRNetworkPlayer *GetPlayerByIndex(int idx);
DQRNetworkPlayer *GetPlayerBySmallId(int idx);
DQRNetworkPlayer *GetPlayerByXuid(PlayerUID xuid);
wstring GetDisplayNameByGamertag(wstring gamertag);
std::wstring GetDisplayNameByGamertag(std::wstring gamertag);
DQRNetworkPlayer *GetLocalPlayerByUserIndex(int idx);
DQRNetworkPlayer *GetHostPlayer();
int GetSessionIndex(DQRNetworkPlayer *player);
@@ -223,16 +223,16 @@ public:
public:
SessionSearchResult() { m_extData = NULL; }
~SessionSearchResult() { free(m_extData); }
wstring m_partyId;
wstring m_sessionName;
std::wstring m_partyId;
std::wstring m_sessionName;
// 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];
int m_playerCount;
// 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;
void *m_extData;
@@ -397,7 +397,7 @@ private:
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 char m_channelFromSmallId[256]; // For host and client, for mapping back from small Id, to channel
DQRConnectionInfo m_connectionInfoClient; // For client
@@ -461,7 +461,7 @@ private:
int RTSDoWorkThread();
CRITICAL_SECTION m_csVecChatPlayers;
vector<int> m_vecChatPlayersJoined;
std::vector<int> m_vecChatPlayersJoined;
public:
void HandleNewPartyFoundForPlayer();
void HandlePlayerRemovedFromParty(int playerMask);
@@ -488,7 +488,7 @@ public:
bool JoinPartyFromSearchResult(SessionSearchResult *searchResult, int playerMask);
void CancelJoinPartyFromSearchResult();
void RequestDisplayName(DQRNetworkPlayer *player);
void SetDisplayName(PlayerUID xuid, wstring displayName);
void SetDisplayName(PlayerUID xuid, std::wstring displayName);
private:
__int64 m_playersLeftPartyTime;
@@ -509,7 +509,7 @@ private:
int m_sessionResultCount;
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;
static int m_bootUserIndex;
static ePartyProcessType m_partyProcess;
static wstring m_bootSessionName;
static wstring m_bootServiceConfig;
static wstring m_bootSessionTemplate;
static std::wstring m_bootSessionName;
static std::wstring m_bootServiceConfig;
static std::wstring m_bootSessionTemplate;
static bool m_inviteReceived;
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
// accumulate results into 2 matched vectors declared below so that we can ignore any broken UserPartyAssociations from now
vector<WXM::PartyView^> partyViewVector;
vector<WXM::UserPartyAssociation^> partyResultsVector;
std::vector<WXM::PartyView^> partyViewVector;
std::vector<WXM::UserPartyAssociation^> partyResultsVector;
vector<task<void>> taskVector;
std::vector<task<void>> taskVector;
for each(WXM::UserPartyAssociation^ remoteParty in partyResults)
{
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
vector<WXM::PartyView^> partyViewVectorFiltered;
vector<WXM::UserPartyAssociation^> partyResultsFiltered;
std::vector<WXM::PartyView^> partyViewVectorFiltered;
std::vector<WXM::UserPartyAssociation^> partyResultsFiltered;
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
vector<MXSM::MultiplayerSession^> sessionVector;
vector<WXM::PartyView^> partyViewVectorValid;
vector<WXM::UserPartyAssociation^> partyResultsValid;
std::vector<MXSM::MultiplayerSession^> sessionVector;
std::vector<WXM::PartyView^> partyViewVectorValid;
std::vector<WXM::UserPartyAssociation^> partyResultsValid;
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
// 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;
vector<IVectorView<MXSS::XboxUserProfile^>^> nameResolveVector;
vector<MXSM::MultiplayerSession^> newSessionVector;
vector<WXM::UserPartyAssociation^> newPartyVector;
std::vector<task<IVectorView<MXSS::XboxUserProfile^>^>> nameResolveTaskVector;
std::vector<IVectorView<MXSS::XboxUserProfile^>^> nameResolveVector;
std::vector<MXSM::MultiplayerSession^> newSessionVector;
std::vector<WXM::UserPartyAssociation^> newPartyVector;
for( int j = 0; j < sessionVector.size(); j++ )
{
@@ -383,7 +383,7 @@ int DQRNetworkManager::GetFriendsThreadProc()
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;
})
@@ -421,7 +421,7 @@ int DQRNetworkManager::GetFriendsThreadProc()
}
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) );
@@ -192,13 +192,13 @@ void DQRNetworkPlayer::SetName(const wchar_t *name)
}
// 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;
}
// Set display name
void DQRNetworkPlayer::SetDisplayName(wstring displayName)
void DQRNetworkPlayer::SetDisplayName(std::wstring displayName)
{
m_displayName = displayName;
}
@@ -97,7 +97,7 @@ const wchar_t *NetworkPlayerDurango::GetOnlineName()
return m_dqrPlayer->GetName();
}
wstring NetworkPlayerDurango::GetDisplayName()
std::wstring NetworkPlayerDurango::GetDisplayName()
{
return m_dqrPlayer->GetDisplayName();
}
@@ -28,7 +28,7 @@ public:
virtual void SetSocket(Socket *pSocket);
virtual Socket *GetSocket();
virtual const wchar_t *GetOnlineName();
virtual wstring GetDisplayName();
virtual std::wstring GetDisplayName();
virtual PlayerUID GetUID();
void SetUID(PlayerUID UID);
@@ -781,7 +781,7 @@ void PartyController::OnGameSessionReady( GameSessionReadyEventArgs^ eventArgs )
Microsoft::Xbox::Services::Multiplayer::MultiplayerSessionReference^ sessionRef =
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
// 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;
}
wstring CPlatformNetworkManagerDurango::GatherStats()
std::wstring CPlatformNetworkManagerDurango::GatherStats()
{
return L"";
}
wstring CPlatformNetworkManagerDurango::GatherRTTStats()
std::wstring CPlatformNetworkManagerDurango::GatherRTTStats()
{
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++ )
{
GameSessionData *gameSessionData = (GameSessionData *)m_pSearchResults[i].m_extData;
@@ -883,7 +883,7 @@ INetworkPlayer * CPlatformNetworkManagerDurango::GetPlayerBySmallId(unsigned cha
return getNetworkPlayer(m_pDQRNet->GetPlayerBySmallId(smallId));
}
wstring CPlatformNetworkManagerDurango::GetDisplayNameByGamertag(wstring gamertag)
std::wstring CPlatformNetworkManagerDurango::GetDisplayNameByGamertag(std::wstring gamertag)
{
return m_pDQRNet->GetDisplayNameByGamertag(gamertag);
}
@@ -1,5 +1,5 @@
#pragma once
using namespace std;
#include <vector>
#include "../../../../Minecraft.World/Util/C4JThread.h"
#include "../../../Build/Common/Network/NetworkPlayerInterface.h"
@@ -28,7 +28,7 @@ public:
virtual INetworkPlayer *GetPlayerByIndex(int playerIndex);
virtual INetworkPlayer * GetPlayerByXuid(PlayerUID xuid);
virtual INetworkPlayer * GetPlayerBySmallId(unsigned char smallId);
virtual wstring GetDisplayNameByGamertag(wstring gamertag);
virtual std::wstring GetDisplayNameByGamertag(std::wstring gamertag);
virtual bool ShouldMessageForFullSession();
virtual INetworkPlayer *GetHostPlayer();
@@ -71,7 +71,7 @@ private:
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_bLeaveGameOnTick;
@@ -107,7 +107,7 @@ private:
PlayerFlags(INetworkPlayer *pNetworkPlayer, unsigned int count);
~PlayerFlags();
};
vector<PlayerFlags *> m_playerFlags;
std::vector<PlayerFlags *> m_playerFlags;
void SystemFlagAddPlayer(INetworkPlayer *pNetworkPlayer);
void SystemFlagRemovePlayer(INetworkPlayer *pNetworkPlayer);
void SystemFlagReset();
@@ -120,11 +120,11 @@ private:
float m_lastPlayerEventTimeStart;
public:
wstring GatherStats();
wstring GatherRTTStats();
std::wstring GatherStats();
std::wstring GatherRTTStats();
private:
vector<FriendSessionInfo *> friendsSessions[XUSER_MAX_COUNT];
std::vector<FriendSessionInfo *> friendsSessions[XUSER_MAX_COUNT];
int m_searchResultsCount;
int m_lastSearchStartTime;
@@ -139,7 +139,7 @@ private:
void TickSearch();
vector<INetworkPlayer *>currentNetworkPlayers;
std::vector<INetworkPlayer *>currentNetworkPlayers;
INetworkPlayer *addNetworkPlayer(DQRNetworkPlayer *pDQRPlayer);
void removeNetworkPlayer(DQRNetworkPlayer *pDQRPlayer);
static INetworkPlayer *getNetworkPlayer(DQRNetworkPlayer *pDQRPlayer);
@@ -149,7 +149,7 @@ private:
virtual void Notify(int ID, ULONG_PTR Param);
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 void SetSessionsUpdatedCallback( void (*SessionsUpdatedCallback)(LPVOID pParam), LPVOID pSearchParam );
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)
{
PlayerUID puid; shared_ptr<Player> plr;
PlayerUID puid; std::shared_ptr<Player> plr;
ProfileManager.GetXUID(iPad, &puid, true);
plr = Minecraft::GetInstance()->localplayers[iPad];
@@ -127,7 +127,7 @@ bool CDurangoTelemetryManager::RecordLevelStart(int iPad, ESen_FriendOrMatch fri
ULONG hr = 0;
// Grab player info.
PlayerUID puid; shared_ptr<Player> plr;
PlayerUID puid; std::shared_ptr<Player> plr;
ProfileManager.GetXUID(iPad, &puid, true);
plr = Minecraft::GetInstance()->localplayers[iPad];
@@ -971,9 +971,9 @@ DurangoStats *CDurangoTelemetryManager::durangoStats()
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 += L":";
out += _toString<unsigned short>(guid->Data2);
@@ -9,7 +9,7 @@ class CDurangoTelemetryManager : public CTelemetryManager
public:
static GUID ZERO_GUID;
unordered_map<wstring, float> m_multiplayerRoundStartTimes;
std::unordered_map<std::wstring, float> m_multiplayerRoundStartTimes;
CDurangoTelemetryManager();
@@ -46,5 +46,5 @@ public:
protected:
DurangoStats *durangoStats();
wstring guid2str(LPCGUID guid);
std::wstring guid2str(LPCGUID guid);
};
@@ -71,7 +71,7 @@ void CConsoleMinecraftApp::TemporaryCreateGameStart()
////////////////////////////////////////////////////////////////////////////////////////////// From CScene_MultiGameCreate::CreateGame
app.ClearTerrainFeaturePosition();
wstring wWorldName = L"TestWorld";
std::wstring wWorldName = L"TestWorld";
StorageManager.ResetSaveData();
StorageManager.SetSaveTitle(wWorldName.c_str());
@@ -568,7 +568,7 @@ int StartMinecraftThreadProc( void* lpParameter )
AABB::UseDefaultThreadStorage();
Tesselator::CreateNewThreadStorage(1024*1024);
RenderManager.InitialiseContext();
Minecraft::start(wstring(),wstring());
Minecraft::start(std::wstring(),std::wstring());
delete Tesselator::getInstance();
return 0;
}
@@ -989,9 +989,9 @@ Vec3::resetPool();
// 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::wstring_convert<std::codecvt_utf8<wchar_t>> myconv;
@@ -1038,7 +1038,7 @@ void FreeRichPresenceStrings()
#ifdef MEMORY_TRACKING
int totalAllocGen = 0;
unordered_map<int,int> allocCounts;
std::unordered_map<int,int> allocCounts;
bool trackEnable = false;
bool trackStarted = false;
volatile size_t sizeCheckMin = 1160;
@@ -88,7 +88,7 @@ public:
int GetPrimaryPad();
void SetPrimaryPad(int iPad);
char* GetGamertag(int iPad);
wstring GetDisplayName(int iPad);
std::wstring GetDisplayName(int iPad);
bool IsFullVersion();
void SetFullVersion(bool bFull);
void SetSignInChangeCallback(void ( *Func)(LPVOID, bool, unsigned int),LPVOID lpParam);
@@ -1,5 +1,5 @@
#pragma once
using namespace std;
#include <save_data.h>
@@ -405,7 +405,7 @@ public:
void SetDLCProductCode(const char* szProductCode);
void SetProductUpgradeKey(const char* szKey);
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;
@@ -1005,8 +1005,8 @@ void OrbisLeaderboardManager::initReadScoreStruct(ReadScore &out, SceNpScoreRank
out.m_uid.setOnlineID( rankData.npId.handle, true );
out.m_rank = rankData.rank;
// Convert to wstring and copy name.
wstring wstrName = convStringToWstring( string(rankData.npId.handle.data) ).c_str();
// Convert to std::wstring and copy name.
std::wstring wstrName = convStringToWstring( string(rankData.npId.handle.data) ).c_str();
//memcpy(&out.m_name, wstrName.c_str(), XUSER_NAME_SIZE);
out.m_name=wstrName;
}
@@ -717,7 +717,7 @@ bool SQRNetworkManager_Orbis::FriendRoomManagerSearch2()
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.
unordered_set<SceNpMatching2RoomId> uniqueRooms;
std::unordered_set<SceNpMatching2RoomId> uniqueRooms;
for( unsigned int i = 0; i < m_aFriendSearchResults.size(); i++ )
{
if(m_aFriendSearchResults[i].m_RoomFound)
@@ -99,7 +99,7 @@ bool CConsoleMinecraftApp::IsAmericanSKU()
SONYDLC *CConsoleMinecraftApp::GetSONYDLCInfo(char *pchTitle)
{
wstring wstrTemp=convStringToWstring(pchTitle);
std::wstring wstrTemp=convStringToWstring(pchTitle);
AUTO_VAR(it, m_SONYDLCMap.find(wstrTemp));
if(it == m_SONYDLCMap.end())
@@ -191,7 +191,7 @@ BOOL CConsoleMinecraftApp::ReadProductCodes()
// push this into a vector
wstring wstrTemp=convStringToWstring(chDLCTitle);
std::wstring wstrTemp=convStringToWstring(chDLCTitle);
m_SONYDLCMap[wstrTemp]=pDLCInfo;
}
CloseHandle(file);
@@ -288,7 +288,7 @@ int CConsoleMinecraftApp::GetLocalTMSFileIndex(WCHAR *wchTMSFile,bool bFilenameI
int CConsoleMinecraftApp::LoadLocalDLCImages()
{
// 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++ )
{
SONYDLC * pDLCInfo=(*it).second;
@@ -301,7 +301,7 @@ int CConsoleMinecraftApp::LoadLocalDLCImages()
void CConsoleMinecraftApp::FreeLocalDLCImages()
{
// 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++ )
{
SONYDLC * pDLCInfo=(*it).second;
@@ -394,7 +394,7 @@ void CConsoleMinecraftApp::TemporaryCreateGameStart()
////////////////////////////////////////////////////////////////////////////////////////////// From CScene_MultiGameCreate::CreateGame
app.ClearTerrainFeaturePosition();
wstring wWorldName = L"TestWorld";
std::wstring wWorldName = L"TestWorld";
StorageManager.ResetSaveData();
StorageManager.SetSaveTitle(wWorldName.c_str());
+2 -2
View File
@@ -161,7 +161,7 @@ public:
bool DLCAlreadyPurchased(char *pchTitle);
char *GetSkuIDFromProductList();
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 CommerceGetCategoriesCallback(LPVOID lpParam,int err);
static void CommerceGetProductListCallback(LPVOID lpParam,int err);
@@ -210,7 +210,7 @@ private:
// SonyCommerce::ProductInfoDetailed m_ProductInfoDetailed;
PRODUCTCODES ProductCodes;
unordered_map<wstring, SONYDLC *> m_SONYDLCMap;
std::unordered_map<std::wstring, SONYDLC *> m_SONYDLCMap;
bool m_bVoiceChatAndUGCRestricted;
@@ -757,7 +757,7 @@ int StartMinecraftThreadProc( void* lpParameter )
AABB::UseDefaultThreadStorage();
Tesselator::CreateNewThreadStorage(1024*1024);
RenderManager.InitialiseContext();
Minecraft::start(wstring(),wstring());
Minecraft::start(std::wstring(),std::wstring());
delete Tesselator::getInstance();
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
std::string wstring_to_utf8 (const std::wstring& str)
// convert std::wstring to UTF-8 string
std::string std::wstring_to_utf8 (const std::wstring& str)
{
std::wstring_convert<std::codecvt_utf8<wchar_t>> myconv;
return myconv.to_bytes(str);
@@ -1475,7 +1475,7 @@ uint8_t *mallocAndCreateUTF8ArrayFromString(int iID)
LPCWSTR wchString=app.GetString(iID);
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;
uint8_t *strUtf8=(uint8_t *)malloc(dst_len);
@@ -1509,7 +1509,7 @@ void FreeRichPresenceStrings()
#ifdef MEMORY_TRACKING
int totalAllocGen = 0;
unordered_map<int,int> allocCounts;
std::unordered_map<int,int> allocCounts;
bool trackEnable = false;
bool trackStarted = false;
volatile size_t sizeCheckMin = 1160;
@@ -41,7 +41,7 @@ PlayerUID::PlayerUID(SceUserServiceUserId userID, SceNpOnlineId& onlineID, bool
setOnlineID(onlineID, bSignedInPSN);
}
PlayerUID::PlayerUID(wstring fromString)
PlayerUID::PlayerUID(std::wstring fromString)
{
// create for the format P_5e7ff8372ea9_00000004_Mark_4J
@@ -53,14 +53,14 @@ PlayerUID::PlayerUID(wstring fromString)
// parse the mac address next
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);
}
int userIdLen = 0;
// parse the userID
wstring userIDDigits = L"";
std::wstring userIDDigits = L"";
while(fromString.at(15 + userIdLen) != L'_')
{
@@ -71,7 +71,7 @@ PlayerUID::PlayerUID(wstring fromString)
m_userID = _fromString<int>(userIDDigits);
// 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)
{
wcstombs(m_onlineID, onlineID.c_str(), 16);
@@ -78,7 +78,7 @@ public:
int GetPrimaryPad();
void SetPrimaryPad(int iPad);
char* GetGamertag(int iPad);
wstring GetDisplayName(int iPad);
std::wstring GetDisplayName(int iPad);
bool IsFullVersion();
void SetFullVersion(bool bFull);
void SetSignInChangeCallback(void ( *Func)(LPVOID, bool, unsigned int),LPVOID lpParam);
@@ -1,5 +1,5 @@
#pragma once
using namespace std;
#include <vector>
#include <sysutil\sysutil_savedata.h>
#include <cell/cell_fs.h>

Some files were not shown because too many files have changed in this diff Show More