mirror of
https://gitea.sffempire.ru/Kolyah35/minecraft-pe-0.6.1.git
synced 2026-03-20 06:53:30 +00:00
REMOVE: User class
This commit is contained in:
@@ -116,8 +116,7 @@ int Minecraft::customDebugId = Minecraft::CDI_NONE;
|
|||||||
|
|
||||||
bool Minecraft::useAmbientOcclusion = false;
|
bool Minecraft::useAmbientOcclusion = false;
|
||||||
|
|
||||||
Minecraft::Minecraft()
|
Minecraft::Minecraft() :
|
||||||
: user(NULL),
|
|
||||||
level(NULL),
|
level(NULL),
|
||||||
player(NULL),
|
player(NULL),
|
||||||
cameraTargetPlayer(NULL),
|
cameraTargetPlayer(NULL),
|
||||||
@@ -222,7 +221,6 @@ Minecraft::~Minecraft()
|
|||||||
}
|
}
|
||||||
|
|
||||||
//delete player;
|
//delete player;
|
||||||
delete user;
|
|
||||||
delete inputHolder;
|
delete inputHolder;
|
||||||
|
|
||||||
delete storageSource;
|
delete storageSource;
|
||||||
@@ -1145,10 +1143,8 @@ void Minecraft::init()
|
|||||||
checkGlError("Init complete");
|
checkGlError("Init complete");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
user = new User(options.getStringValue(OPTIONS_USERNAME), "");
|
|
||||||
setIsCreativeMode(false); // false means it's Survival Mode
|
setIsCreativeMode(false); // false means it's Survival Mode
|
||||||
reloadOptions();
|
reloadOptions();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Minecraft::setSize(int w, int h) {
|
void Minecraft::setSize(int w, int h) {
|
||||||
@@ -1334,9 +1330,9 @@ void Minecraft::hostMultiplayer(int port) {
|
|||||||
#if !defined(NO_NETWORK)
|
#if !defined(NO_NETWORK)
|
||||||
netCallback = new ServerSideNetworkHandler(this, raknetInstance);
|
netCallback = new ServerSideNetworkHandler(this, raknetInstance);
|
||||||
#ifdef STANDALONE_SERVER
|
#ifdef STANDALONE_SERVER
|
||||||
raknetInstance->host(user->name, port, 16);
|
raknetInstance->host(options.getStringValue(OPTIONS_USERNAME), port, 16);
|
||||||
#else
|
#else
|
||||||
raknetInstance->host(user->name, port);
|
raknetInstance->host(options.getStringValue(OPTIONS_USERNAME), port);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -1393,8 +1389,10 @@ void Minecraft::_levelGenerated()
|
|||||||
|
|
||||||
this->cameraTargetPlayer = player;
|
this->cameraTargetPlayer = player;
|
||||||
|
|
||||||
|
std::string serverName = options.getStringValue(OPTIONS_USERNAME) + " - " + level->getLevelData()->levelName;
|
||||||
|
|
||||||
if (raknetInstance->isServer())
|
if (raknetInstance->isServer())
|
||||||
raknetInstance->announceServer(user->name);
|
raknetInstance->announceServer(serverName);
|
||||||
|
|
||||||
if (netCallback) {
|
if (netCallback) {
|
||||||
netCallback->levelGenerated(level);
|
netCallback->levelGenerated(level);
|
||||||
|
|||||||
@@ -13,7 +13,6 @@
|
|||||||
//#include "../network/RakNetInstance.h"
|
//#include "../network/RakNetInstance.h"
|
||||||
#include "../world/phys/HitResult.h"
|
#include "../world/phys/HitResult.h"
|
||||||
|
|
||||||
class User;
|
|
||||||
class Level;
|
class Level;
|
||||||
class LocalPlayer;
|
class LocalPlayer;
|
||||||
class IInputHolder;
|
class IInputHolder;
|
||||||
@@ -165,7 +164,6 @@ public:
|
|||||||
int lastTickTime;
|
int lastTickTime;
|
||||||
float ticksSinceLastUpdate;
|
float ticksSinceLastUpdate;
|
||||||
|
|
||||||
User* user;
|
|
||||||
Level* level;
|
Level* level;
|
||||||
|
|
||||||
LocalPlayer* player;
|
LocalPlayer* player;
|
||||||
|
|||||||
@@ -1,62 +0,0 @@
|
|||||||
#ifndef NET_MINECRAFT_CLIENT__User_H__
|
|
||||||
#define NET_MINECRAFT_CLIENT__User_H__
|
|
||||||
|
|
||||||
//package net.minecraft.client;
|
|
||||||
|
|
||||||
#include "../world/level/tile/Tile.h"
|
|
||||||
|
|
||||||
class User
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
//static List<Tile> allowedTiles = /*new*/ ArrayList<Tile>();
|
|
||||||
|
|
||||||
//static {
|
|
||||||
// allowedTiles.push_back(Tile::rock);
|
|
||||||
// allowedTiles.push_back(Tile::stoneBrick);
|
|
||||||
// allowedTiles.push_back(Tile::redBrick);
|
|
||||||
// allowedTiles.push_back(Tile::dirt);
|
|
||||||
// allowedTiles.push_back(Tile::wood);
|
|
||||||
// allowedTiles.push_back(Tile::treeTrunk);
|
|
||||||
// allowedTiles.push_back(Tile::leaves);
|
|
||||||
// allowedTiles.push_back(Tile::torch);
|
|
||||||
// allowedTiles.push_back(Tile::stoneSlabHalf);
|
|
||||||
|
|
||||||
// allowedTiles.push_back(Tile::glass);
|
|
||||||
// allowedTiles.push_back(Tile::mossStone);
|
|
||||||
// allowedTiles.push_back(Tile::sapling);
|
|
||||||
// allowedTiles.push_back(Tile::flower);
|
|
||||||
// allowedTiles.push_back(Tile::rose);
|
|
||||||
// allowedTiles.push_back(Tile::mushroom1);
|
|
||||||
// allowedTiles.push_back(Tile::mushroom2);
|
|
||||||
// allowedTiles.push_back(Tile::sand);
|
|
||||||
// allowedTiles.push_back(Tile::gravel);
|
|
||||||
// allowedTiles.push_back(Tile::sponge);
|
|
||||||
|
|
||||||
// allowedTiles.push_back(Tile::cloth);
|
|
||||||
// allowedTiles.push_back(Tile::coalOre);
|
|
||||||
// allowedTiles.push_back(Tile::ironOre);
|
|
||||||
// allowedTiles.push_back(Tile::goldOre);
|
|
||||||
// allowedTiles.push_back(Tile::ironBlock);
|
|
||||||
// allowedTiles.push_back(Tile::goldBlock);
|
|
||||||
// allowedTiles.push_back(Tile::bookshelf);
|
|
||||||
// allowedTiles.push_back(Tile::tnt);
|
|
||||||
// allowedTiles.push_back(Tile::obsidian);
|
|
||||||
|
|
||||||
// // System.out.println(allowedTiles.size());
|
|
||||||
//}
|
|
||||||
|
|
||||||
static bool isTileAllowed(const Tile& tile) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string name;
|
|
||||||
std::string sessionId;
|
|
||||||
//std::string mpPassword;
|
|
||||||
|
|
||||||
User(const std::string& name, const std::string& sessionId) {
|
|
||||||
this->name = name;
|
|
||||||
this->sessionId = sessionId;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif /*NET_MINECRAFT_CLIENT__User_H__*/
|
|
||||||
@@ -5,6 +5,7 @@
|
|||||||
#include "../../world/level/Level.h"
|
#include "../../world/level/Level.h"
|
||||||
#include "../../world/item/ItemInstance.h"
|
#include "../../world/item/ItemInstance.h"
|
||||||
#include "../player/LocalPlayer.h"
|
#include "../player/LocalPlayer.h"
|
||||||
|
#include "client/Options.h"
|
||||||
#ifndef STANDALONE_SERVER
|
#ifndef STANDALONE_SERVER
|
||||||
#include "../sound/SoundEngine.h"
|
#include "../sound/SoundEngine.h"
|
||||||
#include "../particle/ParticleEngine.h"
|
#include "../particle/ParticleEngine.h"
|
||||||
@@ -27,7 +28,7 @@ GameMode::GameMode( Minecraft* minecraft)
|
|||||||
|
|
||||||
/*virtual*/
|
/*virtual*/
|
||||||
Player* GameMode::createPlayer(Level* level) {
|
Player* GameMode::createPlayer(Level* level) {
|
||||||
return new LocalPlayer(minecraft, level, minecraft->user, level->dimension->id, isCreativeType());
|
return new LocalPlayer(minecraft, level, minecraft->options.getStringValue(OPTIONS_USERNAME), level->dimension->id, isCreativeType());
|
||||||
}
|
}
|
||||||
|
|
||||||
/*virtual*/
|
/*virtual*/
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
#include "UsernameScreen.h"
|
#include "UsernameScreen.h"
|
||||||
#include "StartMenuScreen.h"
|
#include "StartMenuScreen.h"
|
||||||
#include "../../Minecraft.h"
|
#include "../../Minecraft.h"
|
||||||
#include "../../User.h"
|
|
||||||
#include "../Font.h"
|
#include "../Font.h"
|
||||||
#include "../components/Button.h"
|
#include "../components/Button.h"
|
||||||
#include "../../../platform/input/Keyboard.h"
|
#include "../../../platform/input/Keyboard.h"
|
||||||
@@ -75,7 +74,6 @@ void UsernameScreen::buttonClicked(Button* button)
|
|||||||
if (button == &_btnDone && !tUsername.text.empty()) {
|
if (button == &_btnDone && !tUsername.text.empty()) {
|
||||||
minecraft->options.set(OPTIONS_USERNAME, tUsername.text);
|
minecraft->options.set(OPTIONS_USERNAME, tUsername.text);
|
||||||
minecraft->options.save();
|
minecraft->options.save();
|
||||||
minecraft->user->name = tUsername.text;
|
|
||||||
minecraft->setScreen(NULL); // goes to StartMenuScreen
|
minecraft->setScreen(NULL); // goes to StartMenuScreen
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -242,11 +242,12 @@ static void* fetchSkinForPlayer(void* param) {
|
|||||||
fwrite(skinData.data(), 1, skinData.size(), fp);
|
fwrite(skinData.data(), 1, skinData.size(), fp);
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
LOGI("[Skin] cached skin to %s\n", cacheFile.c_str());
|
LOGI("[Skin] cached skin to %s\n", cacheFile.c_str());
|
||||||
|
|
||||||
|
player->setTextureName("skins/" + player->name + ".png");
|
||||||
} else {
|
} else {
|
||||||
LOGW("[Skin] failed to write skin cache %s\n", cacheFile.c_str());
|
LOGW("[Skin] failed to write skin cache %s\n", cacheFile.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
player->setTextureName("skins/" + player->name + ".png");
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -287,11 +288,12 @@ static void* fetchCapeForPlayer(void* param) {
|
|||||||
fwrite(capeData.data(), 1, capeData.size(), fp);
|
fwrite(capeData.data(), 1, capeData.size(), fp);
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
LOGI("[Cape] cached cape to %s\n", cacheFile.c_str());
|
LOGI("[Cape] cached cape to %s\n", cacheFile.c_str());
|
||||||
|
|
||||||
|
player->setCapeTextureName("capes/" + player->name + ".png");
|
||||||
} else {
|
} else {
|
||||||
LOGW("[Cape] failed to write cape cache %s\n", cacheFile.c_str());
|
LOGW("[Cape] failed to write cape cache %s\n", cacheFile.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
player->setCapeTextureName("capes/" + player->name + ".png");
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -310,7 +312,7 @@ static bool isJumpable(int tileId) {
|
|||||||
|
|
||||||
} // anonymous namespace
|
} // anonymous namespace
|
||||||
|
|
||||||
LocalPlayer::LocalPlayer(Minecraft* minecraft, Level* level, User* user, int dimension, bool isCreative)
|
LocalPlayer::LocalPlayer(Minecraft* minecraft, Level* level, const std::string& username, int dimension, bool isCreative)
|
||||||
: Player(level, isCreative),
|
: Player(level, isCreative),
|
||||||
minecraft(minecraft),
|
minecraft(minecraft),
|
||||||
input(NULL),
|
input(NULL),
|
||||||
@@ -326,9 +328,10 @@ LocalPlayer::LocalPlayer(Minecraft* minecraft, Level* level, User* user, int dim
|
|||||||
_init();
|
_init();
|
||||||
|
|
||||||
#ifndef STANDALONE_SERVER
|
#ifndef STANDALONE_SERVER
|
||||||
if (user != NULL && !user->name.empty()) {
|
if (!name.empty()) {
|
||||||
this->name = user->name;
|
this->name = name;
|
||||||
// Fetch user skin and cape from Mojang servers in the background (avoids blocking the main thread)
|
// Fetch user skin and cape from Mojang servers in the background (avoids blocking the main thread)
|
||||||
|
// TODO: Fix this memory leak
|
||||||
new CThread(fetchSkinForPlayer, this);
|
new CThread(fetchSkinForPlayer, this);
|
||||||
new CThread(fetchCapeForPlayer, this);
|
new CThread(fetchCapeForPlayer, this);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,8 +4,6 @@
|
|||||||
//package net.minecraft.client.player;
|
//package net.minecraft.client.player;
|
||||||
|
|
||||||
#include "input/IMoveInput.h"
|
#include "input/IMoveInput.h"
|
||||||
#include "../User.h"
|
|
||||||
#include "../../platform/input/Keyboard.h"
|
|
||||||
#include "../../util/SmoothFloat.h"
|
#include "../../util/SmoothFloat.h"
|
||||||
#include "../../world/entity/player/Player.h"
|
#include "../../world/entity/player/Player.h"
|
||||||
|
|
||||||
@@ -17,7 +15,7 @@ class LocalPlayer: public Player
|
|||||||
{
|
{
|
||||||
typedef Player super;
|
typedef Player super;
|
||||||
public:
|
public:
|
||||||
LocalPlayer(Minecraft* minecraft, Level* level, User* user, int dimension, bool isCreative);
|
LocalPlayer(Minecraft* minecraft, Level* level, const std::string& username, int dimension, bool isCreative);
|
||||||
~LocalPlayer();
|
~LocalPlayer();
|
||||||
|
|
||||||
void _init();
|
void _init();
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
|
|
||||||
#include "ClientSideNetworkHandler.h"
|
#include "ClientSideNetworkHandler.h"
|
||||||
|
#include "client/Options.h"
|
||||||
#include "packet/PacketInclude.h"
|
#include "packet/PacketInclude.h"
|
||||||
#include "RakNetInstance.h"
|
#include "RakNetInstance.h"
|
||||||
#include "../world/level/chunk/ChunkSource.h"
|
#include "../world/level/chunk/ChunkSource.h"
|
||||||
@@ -85,7 +86,7 @@ void ClientSideNetworkHandler::onConnect(const RakNet::RakNetGUID& hostGuid)
|
|||||||
serverGuid = hostGuid;
|
serverGuid = hostGuid;
|
||||||
|
|
||||||
clearChunksLoaded();
|
clearChunksLoaded();
|
||||||
LoginPacket packet(minecraft->user->name.c_str(), SharedConstants::NetworkProtocolVersion);
|
LoginPacket packet(minecraft->options.getStringValue(OPTIONS_USERNAME).c_str(), SharedConstants::NetworkProtocolVersion);
|
||||||
raknetInstance->send(packet);
|
raknetInstance->send(packet);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -157,7 +158,7 @@ void ClientSideNetworkHandler::handle(const RakNet::RakNetGUID& source, StartGam
|
|||||||
level->isClientSide = true;
|
level->isClientSide = true;
|
||||||
|
|
||||||
bool isCreative = (packet->gameType == GameType::Creative);
|
bool isCreative = (packet->gameType == GameType::Creative);
|
||||||
LocalPlayer* player = new LocalPlayer(minecraft, level, minecraft->user, level->dimension->id, isCreative);
|
LocalPlayer* player = new LocalPlayer(minecraft, level, minecraft->options.getStringValue(OPTIONS_USERNAME), level->dimension->id, isCreative);
|
||||||
player->owner = rakPeer->GetMyGUID();
|
player->owner = rakPeer->GetMyGUID();
|
||||||
player->entityId = packet->entityId;
|
player->entityId = packet->entityId;
|
||||||
player->moveTo(packet->x, packet->y, packet->z, player->yRot, player->xRot);
|
player->moveTo(packet->x, packet->y, packet->z, player->yRot, player->xRot);
|
||||||
|
|||||||
@@ -25,38 +25,38 @@ public:
|
|||||||
static const int C_RIGHT_HINGE_MASK = 16;
|
static const int C_RIGHT_HINGE_MASK = 16;
|
||||||
|
|
||||||
DoorTile(int id, const Material* material);
|
DoorTile(int id, const Material* material);
|
||||||
int getTexture(LevelSource* level, int x, int y, int z, int face);
|
int getTexture(LevelSource* level, int x, int y, int z, int face) override;
|
||||||
|
|
||||||
bool blocksLight();
|
bool blocksLight();
|
||||||
bool isSolidRender();
|
bool isSolidRender() override;
|
||||||
bool isCubeShaped();
|
bool isCubeShaped() override;
|
||||||
int getRenderShape();
|
int getRenderShape() override;
|
||||||
int getRenderLayer();
|
int getRenderLayer() override;
|
||||||
|
|
||||||
AABB getTileAABB(Level* level, int x, int y, int z);
|
AABB getTileAABB(Level* level, int x, int y, int z) override;
|
||||||
AABB* getAABB(Level* level, int x, int y, int z);
|
AABB* getAABB(Level* level, int x, int y, int z) override;
|
||||||
|
|
||||||
void updateShape(LevelSource* level, int x, int y, int z);
|
void updateShape(LevelSource* level, int x, int y, int z) override;
|
||||||
void setShape(int compositeData);
|
void setShape(int compositeData);
|
||||||
|
|
||||||
void attack(Level* level, int x, int y, int z, Player* player);
|
void attack(Level* level, int x, int y, int z, Player* player) override;
|
||||||
bool use(Level* level, int x, int y, int z, Player* player);
|
bool use(Level* level, int x, int y, int z, Player* player) override;
|
||||||
|
|
||||||
void setOpen(Level* level, int x, int y, int z, bool shouldOpen);
|
void setOpen(Level* level, int x, int y, int z, bool shouldOpen);
|
||||||
static bool isOpen(LevelSource* level, int x, int y, int z);
|
static bool isOpen(LevelSource* level, int x, int y, int z);
|
||||||
|
|
||||||
void neighborChanged(Level* level, int x, int y, int z, int type);
|
void neighborChanged(Level* level, int x, int y, int z, int type) override;
|
||||||
|
|
||||||
int getResource(int data, Random* random);
|
int getResource(int data, Random* random) override;
|
||||||
|
|
||||||
// override to avoid duplicate drops when upper half is mined directly
|
// override to avoid duplicate drops when upper half is mined directly
|
||||||
void playerDestroy(Level* level, Player* player, int x, int y, int z, int data) override;
|
void playerDestroy(Level* level, Player* player, int x, int y, int z, int data) override;
|
||||||
|
|
||||||
HitResult clip(Level* level, int xt, int yt, int zt, const Vec3& a, const Vec3& b);
|
HitResult clip(Level* level, int xt, int yt, int zt, const Vec3& a, const Vec3& b) override;
|
||||||
|
|
||||||
int getDir(LevelSource* level, int x, int y, int z);
|
int getDir(LevelSource* level, int x, int y, int z);
|
||||||
|
|
||||||
bool mayPlace(Level* level, int x, int y, int z, unsigned char face);
|
bool mayPlace(Level* level, int x, int y, int z, unsigned char face) override;
|
||||||
|
|
||||||
static int getCompositeData(LevelSource* level, int x, int y, int z);
|
static int getCompositeData(LevelSource* level, int x, int y, int z);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user