summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
m---------MCServer/Plugins/Core0
-rw-r--r--MCServer/crafting.txt40
-rw-r--r--MCServer/items.ini62
-rw-r--r--source/Items/ItemBow.h2
-rw-r--r--source/ManualBindings.cpp8
-rw-r--r--source/Mobs/Wolf.cpp57
-rw-r--r--source/Mobs/Wolf.h7
-rw-r--r--source/OSSupport/IsThread.cpp7
-rw-r--r--source/OSSupport/IsThread.h13
-rw-r--r--source/PluginManager.cpp4
-rw-r--r--source/Server.cpp55
-rw-r--r--source/Server.h3
12 files changed, 216 insertions, 42 deletions
diff --git a/MCServer/Plugins/Core b/MCServer/Plugins/Core
-Subproject de53a607f30c583e08c06b6e5eb936cd278ab8c
+Subproject 9ec55bcdcaf8b3eea8e98e3e502890295dda14d
diff --git a/MCServer/crafting.txt b/MCServer/crafting.txt
index 5132bf436..fe9a465d0 100644
--- a/MCServer/crafting.txt
+++ b/MCServer/crafting.txt
@@ -1,4 +1,3 @@
-
# This file describes the crafting recipes that MCServer knows.
# The syntax is as follows:
# <Line> = <Recipe>#<Comment>
@@ -380,8 +379,45 @@ GreenWool = Wool, * | GreenDye, *
RedWool = Wool, * | RedDye, *
BlackWool = Wool, * | BlackDye, *
+#******************************************************#
+# Stained Glass:
+#
+WhiteStainedGlass, 8 = Glass, 1:1, 1:2, 1:3, 2:1, 2:3, 3:1, 3:2, 3:3 | BoneMeal, 2:2
+OrangeStainedGlass, 8 = Glass, 1:1, 1:2, 1:3, 2:1, 2:3, 3:1, 3:2, 3:3 | OrangeDye, 2:2
+MagentaStainedGlass, 8 = Glass, 1:1, 1:2, 1:3, 2:1, 2:3, 3:1, 3:2, 3:3 | MagentaDye, 2:2
+LightBlueStainedGlass, 8 = Glass, 1:1, 1:2, 1:3, 2:1, 2:3, 3:1, 3:2, 3:3 | LightBlueDye, 2:2
+YellowStainedGlass, 8 = Glass, 1:1, 1:2, 1:3, 2:1, 2:3, 3:1, 3:2, 3:3 | YellowDye, 2:2
+LimeStainedGlass, 8 = Glass, 1:1, 1:2, 1:3, 2:1, 2:3, 3:1, 3:2, 3:3 | LimeDye, 2:2
+PinkStainedGlass, 8 = Glass, 1:1, 1:2, 1:3, 2:1, 2:3, 3:1, 3:2, 3:3 | PinkDye, 2:2
+GrayStainedGlass, 8 = Glass, 1:1, 1:2, 1:3, 2:1, 2:3, 3:1, 3:2, 3:3 | GrayDye, 2:2
+LightGrayStainedGlass, 8 = Glass, 1:1, 1:2, 1:3, 2:1, 2:3, 3:1, 3:2, 3:3 | LightGrayDye, 2:2
+CyanStainedGlass, 8 = Glass, 1:1, 1:2, 1:3, 2:1, 2:3, 3:1, 3:2, 3:3 | CyanDye, 2:2
+VioletStainedGlass, 8 = Glass, 1:1, 1:2, 1:3, 2:1, 2:3, 3:1, 3:2, 3:3 | VioletDye, 2:2
+BlueStainedGlass, 8 = Glass, 1:1, 1:2, 1:3, 2:1, 2:3, 3:1, 3:2, 3:3 | BlueDye, 2:2
+BrownStainedGlass, 8 = Glass, 1:1, 1:2, 1:3, 2:1, 2:3, 3:1, 3:2, 3:3 | BrownDye, 2:2
+GreenStainedGlass, 8 = Glass, 1:1, 1:2, 1:3, 2:1, 2:3, 3:1, 3:2, 3:3 | GreenDye, 2:2
+RedStainedGlass, 8 = Glass, 1:1, 1:2, 1:3, 2:1, 2:3, 3:1, 3:2, 3:3 | RedDye, 2:2
+BlackStainedGlass, 8 = Glass, 1:1, 1:2, 1:3, 2:1, 2:3, 3:1, 3:2, 3:3 | BlackDye, 2:2
-
+#******************************************************#
+# Stained Glass Pane:
+#
+WhiteStainedGlassPane, 16 = WhiteStainedGlass, 1:2, 1:3, 2:2, 2:3, 3:2, 3:3
+OrangeStainedGlassPane, 16 = OrangeStainedGlass, 1:2, 1:3, 2:2, 2:3, 3:2, 3:3
+MagentaStainedGlassPane, 16 = MagentaStainedGlass, 1:2, 1:3, 2:2, 2:3, 3:2, 3:3
+LightBlueStainedGlassPane, 16 = LightBlueStainedGlass, 1:2, 1:3, 2:2, 2:3, 3:2, 3:3
+YellowStainedGlassPane, 16 = YellowStainedGlass, 1:2, 1:3, 2:2, 2:3, 3:2, 3:3
+LimeStainedGlassPane, 16 = LimeStainedGlass, 1:2, 1:3, 2:2, 2:3, 3:2, 3:3
+PinkStainedGlassPane, 16 = PinkStainedGlass, 1:2, 1:3, 2:2, 2:3, 3:2, 3:3
+GrayStainedGlassPane, 16 = GrayStainedGlass, 1:2, 1:3, 2:2, 2:3, 3:2, 3:3
+LightGrayStainedGlassPane, 16 = LightGrayStainedGlass, 1:2, 1:3, 2:2, 2:3, 3:2, 3:3
+CyanStainedGlassPane, 16 = CyanStainedGlass, 1:2, 1:3, 2:2, 2:3, 3:2, 3:3
+VioletStainedGlassPane, 16 = VioletStainedGlass, 1:2, 1:3, 2:2, 2:3, 3:2, 3:3
+BlueStainedGlassPane, 16 = BlueStainedGlass, 1:2, 1:3, 2:2, 2:3, 3:2, 3:3
+BrownStainedGlassPane, 16 = BrownStainedGlass, 1:2, 1:3, 2:2, 2:3, 3:2, 3:3
+GreenStainedGlassPane, 16 = GreenStainedGlass, 1:2, 1:3, 2:2, 2:3, 3:2, 3:3
+RedStainedGlassPane, 16 = RedStainedGlass, 1:2, 1:3, 2:2, 2:3, 3:2, 3:3
+BlackStainedGlassPane , 16 = BlackStainedGlass, 1:2, 1:3, 2:2, 2:3, 3:2, 3:3
#******************************************************#
diff --git a/MCServer/items.ini b/MCServer/items.ini
index c4e2466d8..7eb8f56b4 100644
--- a/MCServer/items.ini
+++ b/MCServer/items.ini
@@ -117,8 +117,8 @@ darkgreenwool=35:13
dkgreenwool=35:13
redwool=35:14
blackwool=35:15
-flower=37
-rose=38
+dandelion=37
+flower=38
brownmushroom=39
redmushroom=40
gold=41
@@ -208,7 +208,22 @@ portal=90
jackolantern=91
jacko=91
cakeblock=92
-lockedchest=95
+whitestainedglass=95
+orangestainedglass=95:1
+magentastainedglass=95:2
+lightbluestainedglass=95:3
+yellowstainedglass=95:4
+limestainedglass=95:5
+pinkstainedglass=95:6
+graystainedglass=95:7
+lightgraystainedglass=95:8
+cyanstainedglass=95:9
+violetstainedglass=95:10
+bluestainedglass=95:11
+brownstainedglass=95:12
+greenstainedglass=95:13
+redstainedglass=95:14
+blackstainedglass=95:15
trapdoor=96
silverfishblock=97
stonebricks=98
@@ -281,6 +296,42 @@ pillarquartzblock=155:2
quartzstairs=156
activatorrail=157
dropper=158
+whitestainedclay=159
+orangestainedclay=159:1
+magentastainedclay=159:2
+lightbluestainedclay=159:3
+yellowstainedclay=159:4
+limestainedclay=159:5
+pinkstainedclay=159:6
+graystainedclay=159:7
+lightgraystainedclay=159:8
+cyanstainedclay=159:9
+violetstainedclay=159:10
+bluestainedclay=159:11
+brownstainedclay=159:12
+greenstainedclay=159:13
+redstainedclay=159:14
+blackstainedclay=159:15
+whitestainedglasspane=160
+orangestainedglasspane=160:1
+magentastainedglasspane=160:2
+lightbluestainedglasspane=160:3
+yellowstainedglasspane=160:4
+limestainedglasspane=160:5
+pinkstainedglasspane=160:6
+graystainedglasspane=160:7
+lightgraystainedglasspane=160:8
+cyanstainedglasspane=160:9
+violetstainedglasspane=160:10
+bluestainedglasspane=160:11
+brownstainedglasspane=160:12
+greenstainedglasspane=160:13
+redstainedglasspane=160:14
+blackstainedglasspane=160:15
+acaciawood=162
+darkoakwood=162:1
+acaciawoodenstairs=163
+darkoakwoodenstairs=164
haybale=170
carpet=171
ironshovel=256
@@ -530,7 +581,12 @@ netherbrickitem=405
netherquartz=406
tntminecart=407
hopperminecart=408
+ironhorsearmor=417
+goldhorsearmor=418
+diamondhorsearmor=419
lead=420
+nametag=421
+commandblockminecart=422
goldrecord=2256
greenrecord=2257
diff --git a/source/Items/ItemBow.h b/source/Items/ItemBow.h
index 79520c074..d533c21fd 100644
--- a/source/Items/ItemBow.h
+++ b/source/Items/ItemBow.h
@@ -72,7 +72,7 @@ public:
return;
}
a_Player->GetWorld()->BroadcastSpawnEntity(*Arrow);
- a_Player->GetWorld()->BroadcastSoundEffect("random.bow", (int)a_Player->GetPosX() * 8, (int)a_Player->GetPosY() * 8, (int)a_Player->GetPosZ() * 8, 0.5, Force);
+ a_Player->GetWorld()->BroadcastSoundEffect("random.bow", (int)a_Player->GetPosX() * 8, (int)a_Player->GetPosY() * 8, (int)a_Player->GetPosZ() * 8, 0.5, (float)Force);
if (!a_Player->IsGameModeCreative())
{
diff --git a/source/ManualBindings.cpp b/source/ManualBindings.cpp
index 37274e2af..f98e25880 100644
--- a/source/ManualBindings.cpp
+++ b/source/ManualBindings.cpp
@@ -1347,7 +1347,9 @@ static int tolua_cPluginManager_BindCommand(lua_State * L)
if (!self->BindCommand(Command, Plugin, Permission, HelpString))
{
- // Refused. Possibly already bound. Error message has been given, bail out silently.
+ // Refused. Possibly already bound. Error message has been given, display the callstack:
+ cLuaState LS(L);
+ LS.LogStackTrace();
return 0;
}
@@ -1409,7 +1411,9 @@ static int tolua_cPluginManager_BindConsoleCommand(lua_State * L)
if (!self->BindConsoleCommand(Command, Plugin, HelpString))
{
- // Refused. Possibly already bound. Error message has been given, bail out silently.
+ // Refused. Possibly already bound. Error message has been given, display the callstack:
+ cLuaState LS(L);
+ LS.LogStackTrace();
return 0;
}
diff --git a/source/Mobs/Wolf.cpp b/source/Mobs/Wolf.cpp
index b9db53c7f..c86250142 100644
--- a/source/Mobs/Wolf.cpp
+++ b/source/Mobs/Wolf.cpp
@@ -15,7 +15,7 @@ cWolf::cWolf(void) :
m_IsTame(false),
m_IsSitting(false),
m_IsBegging(false),
- m_Owner(""),
+ m_OwnerName(""),
m_CollarColor(14)
{
}
@@ -64,11 +64,11 @@ void cWolf::OnRightClicked(cPlayer & a_Player)
}
else if (IsTame())
{
- if (a_Player.GetName() == m_Owner) // Is the player the owner of the dog?
+ if (a_Player.GetName() == m_OwnerName) // Is the player the owner of the dog?
{
if (a_Player.GetEquippedItem().m_ItemType == E_ITEM_DYE)
{
- m_CollarColor = 15 - a_Player.GetEquippedItem().m_ItemDamage;
+ SetCollarColor(15 - a_Player.GetEquippedItem().m_ItemDamage);
if (!a_Player.IsGameModeCreative())
{
a_Player.GetInventory().RemoveOneEquippedItem();
@@ -141,38 +141,45 @@ void cWolf::Tick(float a_Dt, cChunk & a_Chunk)
}
}
}
-
+
+ if (IsTame())
+ {
+ TickFollowPlayer();
+ }
+}
+
+
+
+
+
+void cWolf::TickFollowPlayer()
+{
class cCallback :
public cPlayerListCallback
{
- virtual bool Item(cPlayer * Player) override
+ virtual bool Item(cPlayer * a_Player) override
{
- OwnerCoords = Player->GetPosition();
+ OwnerPos = a_Player->GetPosition();
return false;
}
public:
- Vector3f OwnerCoords;
+ Vector3f OwnerPos;
} Callback;
- m_World->DoWithPlayer(m_Owner, Callback);
- Vector3f OwnerCoords = Callback.OwnerCoords;
-
- if (IsTame())
+ if (m_World->DoWithPlayer(m_OwnerName, Callback))
{
- if (m_Owner != "")
+ // The player is present in the world, follow them:
+ double Distance = (Callback.OwnerPos - GetPosition()).Length();
+ if (Distance < 3)
{
- double Distance = (OwnerCoords - GetPosition()).Length();
- if (Distance < 3)
- {
- m_bMovingToDestination = false;
- }
- else if ((Distance > 30) && (!IsSitting()))
- {
- TeleportToCoords(OwnerCoords.x, OwnerCoords.y, OwnerCoords.z);
- }
- else
- {
- m_Destination = OwnerCoords;
- }
+ m_bMovingToDestination = false;
+ }
+ else if ((Distance > 30) && (!IsSitting()))
+ {
+ TeleportToCoords(Callback.OwnerPos.x, Callback.OwnerPos.y, Callback.OwnerPos.z);
+ }
+ else
+ {
+ m_Destination = Callback.OwnerPos;
}
}
}
diff --git a/source/Mobs/Wolf.h b/source/Mobs/Wolf.h
index d51d4e78a..040e2cf7a 100644
--- a/source/Mobs/Wolf.h
+++ b/source/Mobs/Wolf.h
@@ -21,13 +21,14 @@ public:
virtual void DoTakeDamage(TakeDamageInfo & a_TDI) override;
virtual void OnRightClicked(cPlayer & a_Player) override;
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
+ virtual void TickFollowPlayer();
// Get functions
bool IsSitting (void) const { return m_IsSitting; }
bool IsTame (void) const { return m_IsTame; }
bool IsBegging (void) const { return m_IsBegging; }
bool IsAngry (void) const { return m_IsAngry; }
- AString GetOwner (void) const { return m_Owner; }
+ AString GetOwner (void) const { return m_OwnerName; }
int GetCollarColor(void) const { return m_CollarColor; }
// Set functions
@@ -35,7 +36,7 @@ public:
void SetIsTame (bool a_IsTame) { m_IsTame = a_IsTame; }
void SetIsBegging (bool a_IsBegging) { m_IsBegging = a_IsBegging; }
void SetIsAngry (bool a_IsAngry) { m_IsAngry = a_IsAngry; }
- void SetOwner (AString a_NewOwner) { m_Owner = a_NewOwner; }
+ void SetOwner (AString a_NewOwner) { m_OwnerName = a_NewOwner; }
void SetCollarColor(int a_CollarColor) { m_CollarColor = a_CollarColor; }
protected:
@@ -44,7 +45,7 @@ protected:
bool m_IsTame;
bool m_IsBegging;
bool m_IsAngry;
- AString m_Owner;
+ AString m_OwnerName;
int m_CollarColor;
} ;
diff --git a/source/OSSupport/IsThread.cpp b/source/OSSupport/IsThread.cpp
index e1ef84c17..4da9f9949 100644
--- a/source/OSSupport/IsThread.cpp
+++ b/source/OSSupport/IsThread.cpp
@@ -53,7 +53,7 @@ static void SetThreadName( DWORD dwThreadID, LPCSTR szThreadName)
cIsThread::cIsThread(const AString & iThreadName) :
m_ThreadName(iThreadName),
m_ShouldTerminate(false),
- m_Handle(NULL)
+ m_Handle(NULL_HANDLE)
{
}
@@ -73,8 +73,7 @@ cIsThread::~cIsThread()
bool cIsThread::Start(void)
{
- ASSERT(m_Handle == NULL); // Has already started one thread?
-
+ ASSERT(m_Handle == NULL_HANDLE); // Has already started one thread?
#ifdef _WIN32
// Create the thread suspended, so that the mHandle variable is valid in the thread procedure
DWORD ThreadID = 0;
@@ -111,7 +110,7 @@ bool cIsThread::Start(void)
void cIsThread::Stop(void)
{
- if (m_Handle == NULL)
+ if (m_Handle == NULL_HANDLE)
{
return;
}
diff --git a/source/OSSupport/IsThread.h b/source/OSSupport/IsThread.h
index 2ea8bf6f9..b8784ea33 100644
--- a/source/OSSupport/IsThread.h
+++ b/source/OSSupport/IsThread.h
@@ -51,15 +51,28 @@ public:
protected:
AString m_ThreadName;
+ // Value used for "no handle":
+ #ifdef _WIN32
+ #define NULL_HANDLE NULL
+ #else
+ #define NULL_HANDLE 0
+ #endif
+
#ifdef _WIN32
HANDLE m_Handle;
static DWORD_PTR __stdcall thrExecute(LPVOID a_Param)
{
+ // Create a window so that the thread can be identified by 3rd party tools:
HWND IdentificationWnd = CreateWindow("STATIC", ((cIsThread *)a_Param)->m_ThreadName.c_str(), 0, 0, 0, 0, WS_OVERLAPPED, NULL, NULL, NULL, NULL);
+
+ // Run the thread:
((cIsThread *)a_Param)->Execute();
+
+ // Destroy the identification window:
DestroyWindow(IdentificationWnd);
+
return 0;
}
diff --git a/source/PluginManager.cpp b/source/PluginManager.cpp
index 3ac2366ca..c1f695163 100644
--- a/source/PluginManager.cpp
+++ b/source/PluginManager.cpp
@@ -1511,11 +1511,11 @@ bool cPluginManager::BindConsoleCommand(const AString & a_Command, cPlugin * a_P
{
if (cmd->second.m_Plugin == NULL)
{
- LOGWARNING("Console command \"%s\" is already bound internally by MCServer.", a_Command.c_str());
+ LOGWARNING("Console command \"%s\" is already bound internally by MCServer, cannot bind in plugin \"%s\".", a_Command.c_str(), a_Plugin->GetName().c_str());
}
else
{
- LOGWARNING("Console command \"%s\" is already bound to plugin \"%s\".", a_Command.c_str(), cmd->second.m_Plugin->GetName().c_str());
+ LOGWARNING("Console command \"%s\" is already bound to plugin \"%s\", cannot bind in plugin \"%s\".", a_Command.c_str(), cmd->second.m_Plugin->GetName().c_str(), a_Plugin->GetName().c_str());
}
return false;
}
diff --git a/source/Server.cpp b/source/Server.cpp
index 75ce35cb7..fe8076631 100644
--- a/source/Server.cpp
+++ b/source/Server.cpp
@@ -462,6 +462,18 @@ void cServer::ExecuteConsoleCommand(const AString & a_Cmd, cCommandOutputCallbac
return;
}
+ // "help" and "reload" are to be handled by MCS, so that they work no matter what
+ if (split[0] == "help")
+ {
+ PrintHelp(split, a_Output);
+ return;
+ }
+ if (split[0] == "reload")
+ {
+ cPluginManager::Get()->ReloadPlugins();
+ return;
+ }
+
// There is currently no way a plugin can do these (and probably won't ever be):
if (split[0].compare("chunkstats") == 0)
{
@@ -500,9 +512,52 @@ void cServer::ExecuteConsoleCommand(const AString & a_Cmd, cCommandOutputCallbac
+void cServer::PrintHelp(const AStringVector & a_Split, cCommandOutputCallback & a_Output)
+{
+ typedef std::pair<AString, AString> AStringPair;
+ typedef std::vector<AStringPair> AStringPairs;
+
+ class cCallback :
+ public cPluginManager::cCommandEnumCallback
+ {
+ public:
+ cCallback(void) : m_MaxLen(0) {}
+
+ virtual bool Command(const AString & a_Command, const cPlugin * a_Plugin, const AString & a_Permission, const AString & a_HelpString) override
+ {
+ if (!a_HelpString.empty())
+ {
+ m_Commands.push_back(AStringPair(a_Command, a_HelpString));
+ if (m_MaxLen < a_Command.length())
+ {
+ m_MaxLen = a_Command.length();
+ }
+ }
+ return false;
+ }
+
+ AStringPairs m_Commands;
+ size_t m_MaxLen;
+ } Callback;
+ cPluginManager::Get()->ForEachConsoleCommand(Callback);
+ std::sort(Callback.m_Commands.begin(), Callback.m_Commands.end());
+ for (AStringPairs::const_iterator itr = Callback.m_Commands.begin(), end = Callback.m_Commands.end(); itr != end; ++itr)
+ {
+ const AStringPair & cmd = *itr;
+ a_Output.Out(Printf("%-*s%s\n", Callback.m_MaxLen, cmd.first.c_str(), cmd.second.c_str()));
+ } // for itr - Callback.m_Commands[]
+ a_Output.Finished();
+}
+
+
+
+
+
void cServer::BindBuiltInConsoleCommands(void)
{
cPluginManager * PlgMgr = cPluginManager::Get();
+ PlgMgr->BindConsoleCommand("help", NULL, " - Shows the available commands");
+ PlgMgr->BindConsoleCommand("reload", NULL, " - Reloads all plugins");
PlgMgr->BindConsoleCommand("restart", NULL, " - Restarts the server cleanly");
PlgMgr->BindConsoleCommand("stop", NULL, " - Stops the server cleanly");
PlgMgr->BindConsoleCommand("chunkstats", NULL, " - Displays detailed chunk memory statistics");
diff --git a/source/Server.h b/source/Server.h
index 6742153ac..1b4848318 100644
--- a/source/Server.h
+++ b/source/Server.h
@@ -57,6 +57,9 @@ public: // tolua_export
/// Executes the console command, sends output through the specified callback
void ExecuteConsoleCommand(const AString & a_Cmd, cCommandOutputCallback & a_Output);
+
+ /// Lists all available console commands and their helpstrings
+ void PrintHelp(const AStringVector & a_Split, cCommandOutputCallback & a_Output);
/// Binds the built-in console commands with the plugin manager
static void BindBuiltInConsoleCommands(void);