forked from Kolyah35/minecraft-pe-0.6.1
eeee it doesnt work 😭
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
#include "../client/Minecraft.h"
|
||||
#include "../client/gamemode/GameMode.h"
|
||||
#include "world/item/ItemInstance.h"
|
||||
#include "world/level/LevelConstants.h"
|
||||
#ifndef STANDALONE_SERVER
|
||||
#include "../client/gui/screens/DisconnectionScreen.h"
|
||||
#endif
|
||||
@@ -99,6 +100,10 @@ void ClientSideNetworkHandler::onUnableToConnect()
|
||||
|
||||
void ClientSideNetworkHandler::onDisconnect(const RakNet::RakNetGUID& guid)
|
||||
{
|
||||
CHUNK_CACHE_WIDTH = 16;
|
||||
LEVEL_WIDTH = CHUNK_CACHE_WIDTH * CHUNK_WIDTH;
|
||||
LEVEL_DEPTH = CHUNK_CACHE_WIDTH * CHUNK_DEPTH;
|
||||
|
||||
// TODO: Good disconnecting
|
||||
LOGI("onDisconnect\n");
|
||||
if (level)
|
||||
@@ -155,6 +160,19 @@ void ClientSideNetworkHandler::handle(const RakNet::RakNetGUID& source, StartGam
|
||||
}
|
||||
#endif
|
||||
|
||||
// @todo @note i think its trash
|
||||
// we can put it directly to selectLevel?
|
||||
if (packet->chunkCacheWidth != 0) {
|
||||
printf("lol \n");
|
||||
CHUNK_CACHE_WIDTH = packet->chunkCacheWidth;
|
||||
LEVEL_WIDTH = CHUNK_CACHE_WIDTH * CHUNK_WIDTH;
|
||||
LEVEL_DEPTH = CHUNK_CACHE_WIDTH * CHUNK_DEPTH;
|
||||
|
||||
}
|
||||
NumRequestChunks = CHUNK_CACHE_WIDTH * CHUNK_CACHE_WIDTH;
|
||||
requestNextChunkIndexList.resize(NumRequestChunks);
|
||||
chunksLoaded.resize(NumRequestChunks);
|
||||
|
||||
const std::string& levelId = LevelStorageSource::TempLevelId;
|
||||
LevelStorageSource* storageSource = minecraft->getLevelSource();
|
||||
storageSource->deleteLevel(levelId);
|
||||
@@ -696,7 +714,7 @@ void ClientSideNetworkHandler::arrangeRequestChunkOrder() {
|
||||
}
|
||||
|
||||
_ChunkSorter sorter(cx, cz);
|
||||
std::sort(requestNextChunkIndexList, requestNextChunkIndexList + NumRequestChunks, sorter);
|
||||
std::sort(requestNextChunkIndexList.begin(), requestNextChunkIndexList.end(), sorter);
|
||||
}
|
||||
|
||||
void ClientSideNetworkHandler::levelGenerated(Level* level)
|
||||
|
||||
@@ -102,11 +102,11 @@ private:
|
||||
BlockUpdateList bufferedBlockUpdates;
|
||||
int requestNextChunkPosition;
|
||||
|
||||
static const int NumRequestChunks = CHUNK_CACHE_WIDTH * CHUNK_CACHE_WIDTH;
|
||||
int NumRequestChunks;
|
||||
|
||||
int requestNextChunkIndex;
|
||||
IntPair requestNextChunkIndexList[NumRequestChunks];
|
||||
bool chunksLoaded[NumRequestChunks];
|
||||
std::vector<IntPair> requestNextChunkIndexList;
|
||||
std::vector<bool> chunksLoaded;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include "util/Mth.h"
|
||||
#include "util/StringUtils.h"
|
||||
#include "world/item/ItemInstance.h"
|
||||
#include "world/level/LevelConstants.h"
|
||||
#include "world/level/storage/LevelStorage.h"
|
||||
#include "world/phys/Vec3.h"
|
||||
#include "world/item/crafting/Recipe.h"
|
||||
@@ -219,8 +220,8 @@ void ServerSideNetworkHandler::handle(const RakNet::RakNetGUID& source, LoginPac
|
||||
//
|
||||
bool oldClient = packet->clientNetworkVersion < SharedConstants::NetworkProtocolLowestSupportedVersion;
|
||||
bool oldServer = packet->clientNetworkLowestSupportedVersion > SharedConstants::NetworkProtocolVersion;
|
||||
if (oldClient || oldServer)
|
||||
loginStatus = oldClient? LoginStatus::Failed_ClientOld : LoginStatus::Failed_ServerOld;
|
||||
if (oldClient || oldServer || !packet->newProto)
|
||||
loginStatus = oldClient || !packet->newProto? LoginStatus::Failed_ClientOld : LoginStatus::Failed_ServerOld;
|
||||
|
||||
for (int i = 0; i < level->players.size(); i++) {
|
||||
ServerPlayer* player = (ServerPlayer*) level->players.at(i);
|
||||
@@ -272,15 +273,11 @@ void ServerSideNetworkHandler::handle(const RakNet::RakNetGUID& source, LoginPac
|
||||
level->getLevelData()->getGeneratorVersion(),
|
||||
gameType,
|
||||
newPlayer->entityId,
|
||||
newPlayer->x, newPlayer->y - newPlayer->heightOffset, newPlayer->z
|
||||
newPlayer->x, newPlayer->y - newPlayer->heightOffset, newPlayer->z,
|
||||
CHUNK_CACHE_WIDTH
|
||||
).write(&bitStream);
|
||||
|
||||
rakPeer->Send(&bitStream, HIGH_PRIORITY, RELIABLE_ORDERED, 0, source, false);
|
||||
|
||||
if (!packet->newProto) {
|
||||
MessagePacket packet("You're using outdated client. Some features disabled.");
|
||||
raknetInstance->send(packet);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#define NET_MINECRAFT_NETWORK_PACKET__StartGamePacket_H__
|
||||
|
||||
#include "../Packet.h"
|
||||
#include "world/level/LevelConstants.h"
|
||||
#include <cstdint>
|
||||
|
||||
class StartGamePacket : public Packet
|
||||
@@ -14,18 +15,20 @@ public:
|
||||
int entityId;
|
||||
float x, y, z;
|
||||
|
||||
int chunkCacheWidth = 0;
|
||||
StartGamePacket()
|
||||
{
|
||||
}
|
||||
|
||||
StartGamePacket(long seed, int levelGeneratorVersion, int gameType, int entityId, float x, float y, float z)
|
||||
StartGamePacket(long seed, int levelGeneratorVersion, int gameType, int entityId, float x, float y, float z, int chunkCacheWidth)
|
||||
: levelSeed((int32_t)seed),
|
||||
levelGeneratorVersion(levelGeneratorVersion),
|
||||
gameType(gameType),
|
||||
entityId(entityId),
|
||||
x(x),
|
||||
y(y),
|
||||
z(z)
|
||||
z(z),
|
||||
chunkCacheWidth(chunkCacheWidth)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -40,6 +43,7 @@ public:
|
||||
bitStream->Write(x);
|
||||
bitStream->Write(y);
|
||||
bitStream->Write(z);
|
||||
bitStream->Write(CHUNK_CACHE_WIDTH);
|
||||
}
|
||||
|
||||
void read(RakNet::BitStream* bitStream)
|
||||
@@ -51,6 +55,10 @@ public:
|
||||
bitStream->Read(x);
|
||||
bitStream->Read(y);
|
||||
bitStream->Read(z);
|
||||
|
||||
if (bitStream->GetNumberOfUnreadBits() > 0) {
|
||||
bitStream->Read(chunkCacheWidth);
|
||||
}
|
||||
}
|
||||
|
||||
void handle(const RakNet::RakNetGUID& source, NetEventCallback* callback)
|
||||
|
||||
Reference in New Issue
Block a user