Skip to content

Commit

Permalink
1.5 updates (Open Window 0x64 packet changed and moved to protocol.h)
Browse files Browse the repository at this point in the history
  • Loading branch information
fador committed Mar 14, 2013
1 parent df027bf commit 1a7f98e
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 32 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Custom Minecraft server software written in C++.

You can find the core team from #mineserver @ irc.freenode.net Also mail to developers@mineserver.be will reach us.

Copyright (c) 2010-2012, The Mineserver Project
Copyright (c) 2010-2013, The Mineserver Project

**NOTICE:** Server still lacks features compared to original minecraft server.

Expand All @@ -25,7 +25,7 @@ C++ compiler. MS Visual C++ 10 and GCC 4.4 should be sufficient. The build syste

### Supported Minecraft version

* Working with 1.4.6 client (protocol 51)
* Working with 1.5.0 client (protocol 60)

### Features

Expand All @@ -39,7 +39,7 @@ C++ compiler. MS Visual C++ 10 and GCC 4.4 should be sufficient. The build syste
* Flatland and terrain map generation (Also biomegen!)
* Working chests, furnaces & signs
* User validation from minecraft.net
* Protocol Encryption (NEW)
* Protocol Encryption

### Configuration Notes

Expand Down
2 changes: 1 addition & 1 deletion include/packets.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (c) 2012, The Mineserver Project
Copyright (c) 2013, The Mineserver Project
All rights reserved.
Redistribution and use in source and binary forms, with or without
Expand Down
7 changes: 7 additions & 0 deletions include/protocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,13 @@ class Protocol
}
#endif

static Packet openWindow(int8_t windowId, int8_t type, std::string title, int8_t slots, int8_t useCustomTitle = 0)
{
Packet ret;
ret << (int8_t)PACKET_OPEN_WINDOW << windowId << type << title << slots << useCustomTitle;
return ret;
}

static Packet animation(int eid, int aid)
{
Packet ret;
Expand Down
6 changes: 3 additions & 3 deletions src/constants.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ std::map<uint8_t, DropPtr> BLOCKDROPS;

const unsigned int SERVER_CONSOLE_UID = -1;

const std::string VERSION = "0.1.18 (Alpha)";
const std::string VERSION = "0.1.19 (Alpha)";

const int PROTOCOL_VERSION = 51;
const std::string MINECRAFT_VERSION = "1.4.6";
const int PROTOCOL_VERSION = 60;
const std::string MINECRAFT_VERSION = "1.5.0";

const char COMMENTPREFIX = '#';

Expand Down
23 changes: 11 additions & 12 deletions src/inventory.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (c) 2011, The Mineserver Project
Copyright (c) 2013, The Mineserver Project
All rights reserved.
Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -975,15 +975,17 @@ bool Inventory::windowOpen(User* user, int8_t type, int32_t x, int32_t y, int32_
}
if(_chestData == NULL)
break;

user->buffer << (int8_t)PACKET_OPEN_WINDOW << (int8_t)type << (int8_t)INVENTORYTYPE_CHEST;
std::string windowName;

if(_chestData->large())
{
user->buffer << std::string("Large chest");
} else {
user->buffer << std::string("Chest");
windowName = "Large chest";
}
else
{
windowName = "Chest";
}
user->buffer << (int8_t)(_chestData->size()); // size.. not a very good idea. lets just hope this will only return 27 or 54
user->buffer << Protocol::openWindow(type,INVENTORYTYPE_CHEST,windowName, _chestData->size());

for (size_t j = 0; j < _chestData->size(); j++)
{
Expand All @@ -999,8 +1001,7 @@ bool Inventory::windowOpen(User* user, int8_t type, int32_t x, int32_t y, int32_
break;

case WINDOW_WORKBENCH:
user->buffer << (int8_t)PACKET_OPEN_WINDOW << (int8_t)WINDOW_WORKBENCH << (int8_t)INVENTORYTYPE_WORKBENCH;
user->buffer << std::string("Workbench") << (int8_t)0;
user->buffer << Protocol::openWindow(WINDOW_WORKBENCH,INVENTORYTYPE_WORKBENCH,std::string("Workbench"), 0);

for (uint32_t i = 0; i < openWorkbenches.size(); i++)
{
Expand All @@ -1024,9 +1025,7 @@ bool Inventory::windowOpen(User* user, int8_t type, int32_t x, int32_t y, int32_
}
break;
case WINDOW_FURNACE:

user->buffer << (int8_t)PACKET_OPEN_WINDOW << (int8_t)WINDOW_FURNACE << (int8_t)INVENTORYTYPE_FURNACE;
user->buffer << std::string("Furnace") << (int8_t)0;
user->buffer << Protocol::openWindow(WINDOW_FURNACE,INVENTORYTYPE_FURNACE,std::string("Furnace"), 0);

for (uint32_t i = 0; i < chunk->furnaces.size(); i++)
{
Expand Down
23 changes: 10 additions & 13 deletions src/redstoneSimulation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,14 +204,14 @@ RedstoneSimulation::Power RedstoneSimulation::getPower(int32_t x, int16_t y, int
{
uint8_t block;
uint8_t meta = 0;
bool weak = false;

// Check block type
if (!ServerInstance->map(map)->getBlock(x + 1, y, z, &block, &meta))
{
return POWER_NONE;
}
if (!isBlockSolid(block)) {
if (!isBlockSolid(block))
{
return POWER_NONE;
}

Expand All @@ -232,7 +232,7 @@ RedstoneSimulation::Power RedstoneSimulation::getPower(int32_t x, int16_t y, int
else if (block == BLOCK_REDSTONE_WIRE && meta != 0)
{
// TODO: Check if wire ends here
weak = true;
return POWER_WEAK;
}

// South
Expand All @@ -247,7 +247,7 @@ RedstoneSimulation::Power RedstoneSimulation::getPower(int32_t x, int16_t y, int
}
else if (block == BLOCK_REDSTONE_WIRE && meta != 0)
{
weak = true;
return POWER_WEAK;
}

// East
Expand All @@ -262,7 +262,7 @@ RedstoneSimulation::Power RedstoneSimulation::getPower(int32_t x, int16_t y, int
}
else if (block == BLOCK_REDSTONE_WIRE && meta != 0)
{
weak = true;
return POWER_WEAK;
}

// West
Expand All @@ -277,16 +277,17 @@ RedstoneSimulation::Power RedstoneSimulation::getPower(int32_t x, int16_t y, int
}
else if (block == BLOCK_REDSTONE_WIRE && meta != 0)
{
weak = true;
return POWER_WEAK;
}

// Switch or pressure plate on top of the block

if (!ServerInstance->map(map)->getBlock(x, y + 1, z, &block, &meta))
{
return POWER_NONE;
}

if (block == BLOCK_WOODEN_PRESSURE_PLATE || block == BLOCK_STONE_PRESSURE_PLATE && (meta & 0x1) == 0x1)
// Switch or pressure plate on top of the block
if ((block == BLOCK_WOODEN_PRESSURE_PLATE || block == BLOCK_STONE_PRESSURE_PLATE) && (meta & 0x1) == 0x1)
{
return POWER_NORMAL;
}
Expand All @@ -298,7 +299,7 @@ RedstoneSimulation::Power RedstoneSimulation::getPower(int32_t x, int16_t y, int
// Wire on top of the block
else if (block == BLOCK_REDSTONE_WIRE && meta != 0)
{
weak = true;
return POWER_WEAK;
}

// Torch beneath the block
Expand All @@ -311,10 +312,6 @@ RedstoneSimulation::Power RedstoneSimulation::getPower(int32_t x, int16_t y, int
return POWER_NORMAL;
}

if (weak) {
return POWER_WEAK;
}

// No power
return POWER_NONE;
}
Expand Down

0 comments on commit 1a7f98e

Please sign in to comment.