Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Protocol 28 / Minecraft 1.2.2 compatible chunk packets (not perfect) …

…and login request packet.
  • Loading branch information...
commit dbad6f11f2e3cd16e0b35183a89afe1aa1551d4b 1 parent 5d74e97
@fador authored
View
2  src/constants.cpp
@@ -36,7 +36,7 @@ const unsigned int SERVER_CONSOLE_UID = -1;
const std::string VERSION = "0.1.16 (Alpha)";
-const int PROTOCOL_VERSION = 23;
+const int PROTOCOL_VERSION = 28;
const char COMMENTPREFIX = '#';
View
38 src/map.cpp
@@ -1634,8 +1634,8 @@ void Map::sendToUser(User* user, int x, int z, bool login)
return;
}
- uint8_t* data4 = new uint8_t[18 + 81920];
- uint8_t* mapdata = new uint8_t[81920];
+ uint8_t* data4 = new uint8_t[18 + 98304];
+ uint8_t* mapdata = new uint8_t[98304];
int32_t mapposx = x;
int32_t mapposz = z;
@@ -1646,23 +1646,45 @@ void Map::sendToUser(User* user, int x, int z, bool login)
chunk->lightRegen = false;
}
-
+
// Chunk
- (*p) << (int8_t)PACKET_MAP_CHUNK << (int32_t)(mapposx * 16) << (int16_t)0 << (int32_t)(mapposz * 16)
- << (int8_t)15 << (int8_t)127 << (int8_t)15;
+ (*p) << (int8_t)PACKET_MAP_CHUNK << (int32_t)(mapposx) << (int32_t)(mapposz)
+ << (int8_t)0 /* Biome Data bool */ << (int16_t)0x00ff /* Enabled chunks */
+ << (int16_t)0x00ff /* Enabled additional data? in the enabled chunks */;
+ /*
memcpy(&mapdata[0], chunk->blocks, 32768);
memcpy(&mapdata[32768], chunk->data, 16384);
memcpy(&mapdata[32768 + 16384], chunk->blocklight, 16384);
memcpy(&mapdata[32768 + 16384 + 16384], chunk->skylight, 16384);
+ */
+ memset(&mapdata[32768 + 16384 + 16384+16384], 0, 16384);
+
+
+ for(int x = 0; x < 16; x++)
+ {
+ for(int z = 0; z < 16; z++)
+ {
+ for(int y = 0; y < 128; y++)
+ {
+ int index = y + (z << 7) + (x << 11);
+ int index2 = x + (z << 4) + (y << 8);
+ mapdata[index2] = chunk->blocks[index];
+ mapdata[32768+(index2>>1)] = chunk->data[index>>1];
+ mapdata[32768+16384+(index2>>1)] = chunk->blocklight[index>>1];
+ mapdata[32768+16384+16384+(index2>>1)] = chunk->skylight[index>>1];
+ //mapdata[32768+16384+16384+16384+(x+16*z+16*16*y)>>1] = 0;
+ }
+ }
+ }
- uLongf written = 81920;
+ uLongf written = 98304;
uint8_t* buffer = new uint8_t[written];
// Compress data with zlib deflate
- compress(buffer, &written, &mapdata[0], 81920);
+ compress(buffer, &written, &mapdata[0], 98304);
- (*p) << (int32_t)written;
+ (*p) << (int32_t)written << (int32_t)0 /* ??? */;
(*p).addToWrite(buffer, written);
//Push sign data to player
View
7 src/packets.cpp
@@ -305,12 +305,13 @@ int PacketHandler::login_request(User* user)
int32_t version;
std::string player, passwd;
- int64_t mapseed;
- int8_t dimension;
+ //int64_t mapseed;
+ uint32_t param_1, param_2;
+ int8_t dimension, param_3, param_4;
// As of version 1.5, the password is no longer sent (at least for non-authenticated mode)
//user->buffer >> version >> player >> passwd >> mapseed >> dimension;
- user->buffer >> version >> player >> mapseed >> dimension;
+ user->buffer >> version >> player >> passwd /*>> mapseed*/ >> param_1 >> param_2 >> dimension >> param_3 >> param_4;
if (!user->buffer)
{
View
4 src/protocol.h
@@ -129,8 +129,8 @@ class Protocol
static Packet loginResponse(int eid)
{
Packet ret;
- ret << (int8_t)PACKET_LOGIN_RESPONSE << (int32_t)eid << std::string("") << (int64_t)0
- << std::string("DEFAULT") << (int32_t)0 << (int8_t)0 << (int8_t)2 << (int8_t)128 << (int8_t)64;
+ ret << (int8_t)PACKET_LOGIN_RESPONSE << (int32_t)eid << std::string("") /*<< (int64_t)0 */
+ << std::string("DEFAULT") << (int32_t)0 << (int32_t)0 << (int8_t)2 << (int8_t)128 << (int8_t)64;
return ret;
}
View
13 src/user.cpp
@@ -198,9 +198,10 @@ User::~User()
bool User::sendLoginInfo()
{
+
// Load user data
loadData();
-
+
// Login OK package
buffer << Protocol::loginResponse(UID);
spawnOthers();
@@ -1181,10 +1182,10 @@ bool User::teleport(double x, double y, double z, size_t map)
{
map = pos.map;
}
- if (y > 127.0)
+ if (y > 255.0)
{
- y = 127.0;
- LOGLF("Player Attempted to teleport with y > 127.0");
+ y = 255.0;
+ LOGLF("Player Attempted to teleport with y > 255.0");
}
if (map == pos.map)
{
@@ -1234,7 +1235,7 @@ void User::checkEnvironmentDamage()
{
const double yVal = std::floor(pos.y - 0.5);
- if (yVal > 127.0)
+ if (yVal > 255.0)
{
return;
}
@@ -1298,7 +1299,7 @@ void User::checkEnvironmentDamage()
}
}
- if(std::floor(pos.y + 1.5) > 127)
+ if(std::floor(pos.y + 1.5) > 255)
{
sethealth(std::max(0, health - d));
return;
Please sign in to comment.
Something went wrong with that request. Please try again.