Further refactored, Reverted Minecart change
Other small changes.
This commit is contained in:
parent
80b97fd9dd
commit
aef2c8ec62
@ -186,53 +186,31 @@ void cClientHandle::GenerateOfflineUUID(void)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
AString cClientHandle::FormatChatPrefix(bool ShouldAppendChatPrefixes, AString a_ChatPrefixS, AString m_Color1, AString m_Color2)
|
||||||
|
{
|
||||||
|
if (ShouldAppendChatPrefixes)
|
||||||
|
return Printf("%s%s %s", m_Color1.c_str(), a_ChatPrefixS.c_str(), m_Color2.c_str());
|
||||||
|
else
|
||||||
|
return Printf("%s", m_Color1.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
AString cClientHandle::FormatMessageType(bool ShouldAppendChatPrefixes, eMessageType a_ChatPrefix, const AString &a_AdditionalData)
|
AString cClientHandle::FormatMessageType(bool ShouldAppendChatPrefixes, eMessageType a_ChatPrefix, const AString &a_AdditionalData)
|
||||||
{
|
{
|
||||||
switch (a_ChatPrefix)
|
switch (a_ChatPrefix)
|
||||||
{
|
{
|
||||||
case mtCustom: return AString();
|
case mtCustom: return AString();
|
||||||
case mtFailure:
|
case mtFailure: return FormatChatPrefix(ShouldAppendChatPrefixes, "[INFO]", cChatColor::Rose, cChatColor::White);
|
||||||
{
|
case mtInformation: return FormatChatPrefix(ShouldAppendChatPrefixes, "[INFO]", cChatColor::Yellow, cChatColor::White);
|
||||||
if (ShouldAppendChatPrefixes)
|
case mtSuccess: return FormatChatPrefix(ShouldAppendChatPrefixes, "[INFO]", cChatColor::Green, cChatColor::White);
|
||||||
return Printf("%s[INFO] %s", cChatColor::Rose.c_str(), cChatColor::White.c_str());
|
case mtWarning: return FormatChatPrefix(ShouldAppendChatPrefixes, "[WARN]", cChatColor::Rose, cChatColor::White);
|
||||||
else
|
case mtFatal: return FormatChatPrefix(ShouldAppendChatPrefixes, "[FATAL]", cChatColor::Red, cChatColor::White);
|
||||||
return Printf("%s", cChatColor::Rose.c_str());
|
case mtDeath: return FormatChatPrefix(ShouldAppendChatPrefixes, "[DEATH]", cChatColor::Gray, cChatColor::White);
|
||||||
}
|
case mtJoin: return FormatChatPrefix(ShouldAppendChatPrefixes, "[JOIN]", cChatColor::Yellow, cChatColor::White);
|
||||||
case mtInformation:
|
case mtLeave: return FormatChatPrefix(ShouldAppendChatPrefixes, "[LEAVE]", cChatColor::Yellow, cChatColor::White);
|
||||||
{
|
|
||||||
if (ShouldAppendChatPrefixes)
|
|
||||||
return Printf("%s[INFO] %s", cChatColor::Yellow.c_str(), cChatColor::White.c_str());
|
|
||||||
else
|
|
||||||
return Printf("%s", cChatColor::Yellow.c_str());
|
|
||||||
}
|
|
||||||
case mtSuccess:
|
|
||||||
{
|
|
||||||
if (ShouldAppendChatPrefixes)
|
|
||||||
return Printf("%s[INFO] %s", cChatColor::Green.c_str(), cChatColor::White.c_str());
|
|
||||||
else
|
|
||||||
return Printf("%s", cChatColor::Green.c_str());
|
|
||||||
}
|
|
||||||
case mtWarning:
|
|
||||||
{
|
|
||||||
if (ShouldAppendChatPrefixes)
|
|
||||||
return Printf("%s[WARN] %s", cChatColor::Rose.c_str(), cChatColor::White.c_str());
|
|
||||||
else
|
|
||||||
return Printf("%s", cChatColor::Rose.c_str());
|
|
||||||
}
|
|
||||||
case mtFatal:
|
|
||||||
{
|
|
||||||
if (ShouldAppendChatPrefixes)
|
|
||||||
return Printf("%s[FATAL] %s", cChatColor::Red.c_str(), cChatColor::White.c_str());
|
|
||||||
else
|
|
||||||
return Printf("%s", cChatColor::Red.c_str());
|
|
||||||
}
|
|
||||||
case mtDeath:
|
|
||||||
{
|
|
||||||
if (ShouldAppendChatPrefixes)
|
|
||||||
return Printf("%s[DEATH] %s", cChatColor::Gray.c_str(), cChatColor::White.c_str());
|
|
||||||
else
|
|
||||||
return Printf("%s", cChatColor::Gray.c_str());
|
|
||||||
}
|
|
||||||
case mtPrivateMessage:
|
case mtPrivateMessage:
|
||||||
{
|
{
|
||||||
if (ShouldAppendChatPrefixes)
|
if (ShouldAppendChatPrefixes)
|
||||||
@ -240,20 +218,6 @@ AString cClientHandle::FormatMessageType(bool ShouldAppendChatPrefixes, eMessage
|
|||||||
else
|
else
|
||||||
return Printf("%s: %s", a_AdditionalData.c_str(), cChatColor::LightBlue.c_str());
|
return Printf("%s: %s", a_AdditionalData.c_str(), cChatColor::LightBlue.c_str());
|
||||||
}
|
}
|
||||||
case mtJoin:
|
|
||||||
{
|
|
||||||
if (ShouldAppendChatPrefixes)
|
|
||||||
return Printf("%s[JOIN] %s", cChatColor::Yellow.c_str(), cChatColor::White.c_str());
|
|
||||||
else
|
|
||||||
return Printf("%s", cChatColor::Yellow.c_str());
|
|
||||||
}
|
|
||||||
case mtLeave:
|
|
||||||
{
|
|
||||||
if (ShouldAppendChatPrefixes)
|
|
||||||
return Printf("%s[LEAVE] %s", cChatColor::Yellow.c_str(), cChatColor::White.c_str());
|
|
||||||
else
|
|
||||||
return Printf("%s", cChatColor::Yellow.c_str());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
ASSERT(!"Unhandled chat prefix type!");
|
ASSERT(!"Unhandled chat prefix type!");
|
||||||
}
|
}
|
||||||
|
@ -78,9 +78,11 @@ public:
|
|||||||
Each username generates a unique and constant UUID, so that when the player reconnects with the same name, their UUID is the same. */
|
Each username generates a unique and constant UUID, so that when the player reconnects with the same name, their UUID is the same. */
|
||||||
static AString GenerateOfflineUUID(const AString & a_Username); // tolua_export
|
static AString GenerateOfflineUUID(const AString & a_Username); // tolua_export
|
||||||
|
|
||||||
// Formats the type of message with the proper color and prefix for sending to the client.
|
/** Formats the type of message with the proper color and prefix for sending to the client. **/
|
||||||
AString FormatMessageType(bool ShouldAppendChatPrefixes, eMessageType a_ChatPrefix, const AString & a_AdditionalData);
|
AString FormatMessageType(bool ShouldAppendChatPrefixes, eMessageType a_ChatPrefix, const AString & a_AdditionalData);
|
||||||
|
|
||||||
|
AString FormatChatPrefix(bool ShouldAppendChatPrefixes, AString a_ChatPrefixS, AString m_Color1, AString m_Color2);
|
||||||
|
|
||||||
void Kick(const AString & a_Reason); // tolua_export
|
void Kick(const AString & a_Reason); // tolua_export
|
||||||
void Authenticate(const AString & a_Name, const AString & a_UUID); // Called by cAuthenticator when the user passes authentication
|
void Authenticate(const AString & a_Name, const AString & a_UUID); // Called by cAuthenticator when the user passes authentication
|
||||||
|
|
||||||
|
@ -411,7 +411,7 @@ bool cEntity::ArmorCoversAgainst(eDamageType a_DamageType)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ASSERT("Invalid damage type!");
|
ASSERT(!"Invalid damage type!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -270,7 +270,7 @@ public:
|
|||||||
/// Returns the hitpoints that this pawn can deal to a_Receiver using its equipped items
|
/// Returns the hitpoints that this pawn can deal to a_Receiver using its equipped items
|
||||||
virtual int GetRawDamageAgainst(const cEntity & a_Receiver);
|
virtual int GetRawDamageAgainst(const cEntity & a_Receiver);
|
||||||
|
|
||||||
// Returns whether armor will protect against the passed damage type
|
/** Returns whether armor will protect against the passed damage type **/
|
||||||
virtual bool ArmorCoversAgainst(eDamageType a_DamageType);
|
virtual bool ArmorCoversAgainst(eDamageType a_DamageType);
|
||||||
|
|
||||||
/// Returns the hitpoints out of a_RawDamage that the currently equipped armor would cover
|
/// Returns the hitpoints out of a_RawDamage that the currently equipped armor would cover
|
||||||
|
@ -88,7 +88,7 @@ void cFallingBlock::Tick(float a_Dt, cChunk & a_Chunk)
|
|||||||
AddPosition(GetSpeed() * MilliDt);
|
AddPosition(GetSpeed() * MilliDt);
|
||||||
|
|
||||||
//If not static (One billionth precision) broadcast movement.
|
//If not static (One billionth precision) broadcast movement.
|
||||||
float epsilon = 0.000000001;
|
static const float epsilon = 0.000000001;
|
||||||
if ((fabs(GetSpeedX()) > epsilon) || (fabs(GetSpeedZ()) > epsilon))
|
if ((fabs(GetSpeedX()) > epsilon) || (fabs(GetSpeedZ()) > epsilon))
|
||||||
{
|
{
|
||||||
BroadcastMovementUpdate();
|
BroadcastMovementUpdate();
|
||||||
|
@ -234,15 +234,18 @@ void cMinecart::HandleRailPhysics(NIBBLETYPE a_RailMeta, float a_Dt)
|
|||||||
bool BlckCol = TestBlockCollision(a_RailMeta), EntCol = TestEntityCollision(a_RailMeta);
|
bool BlckCol = TestBlockCollision(a_RailMeta), EntCol = TestEntityCollision(a_RailMeta);
|
||||||
if (EntCol || BlckCol) return;
|
if (EntCol || BlckCol) return;
|
||||||
|
|
||||||
if (GetSpeedZ() > 0)
|
if (GetSpeedZ() != 0) // Don't do anything if cart is stationary
|
||||||
{
|
{
|
||||||
// Going SOUTH, slow down
|
if (GetSpeedZ() > 0)
|
||||||
AddSpeedZ(-0.1);
|
{
|
||||||
}
|
// Going SOUTH, slow down
|
||||||
else if (GetSpeedZ() < 0)
|
AddSpeedZ(-0.1);
|
||||||
{
|
}
|
||||||
// Going NORTH, slow down
|
else
|
||||||
AddSpeedZ(0.1);
|
{
|
||||||
|
// Going NORTH, slow down
|
||||||
|
AddSpeedZ(0.1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -256,13 +259,16 @@ void cMinecart::HandleRailPhysics(NIBBLETYPE a_RailMeta, float a_Dt)
|
|||||||
bool BlckCol = TestBlockCollision(a_RailMeta), EntCol = TestEntityCollision(a_RailMeta);
|
bool BlckCol = TestBlockCollision(a_RailMeta), EntCol = TestEntityCollision(a_RailMeta);
|
||||||
if (EntCol || BlckCol) return;
|
if (EntCol || BlckCol) return;
|
||||||
|
|
||||||
if (GetSpeedX() > 0)
|
if (GetSpeedX() != 0)
|
||||||
{
|
{
|
||||||
AddSpeedX(-0.1);
|
if (GetSpeedX() > 0)
|
||||||
}
|
{
|
||||||
else if (GetSpeedX() < 0)
|
AddSpeedX(-0.1);
|
||||||
{
|
}
|
||||||
AddSpeedX(0.1);
|
else
|
||||||
|
{
|
||||||
|
AddSpeedX(0.1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,7 @@ cMCLogger * cMCLogger::GetInstance(void)
|
|||||||
|
|
||||||
|
|
||||||
cMCLogger::cMCLogger(void):
|
cMCLogger::cMCLogger(void):
|
||||||
g_ShouldColorOutput(false)
|
m_ShouldColorOutput(false)
|
||||||
{
|
{
|
||||||
AString FileName;
|
AString FileName;
|
||||||
Printf(FileName, "LOG_%d.txt", (int)time(NULL));
|
Printf(FileName, "LOG_%d.txt", (int)time(NULL));
|
||||||
@ -76,15 +76,15 @@ void cMCLogger::InitLog(const AString & a_FileName)
|
|||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
// See whether we are writing to a console the default console attrib:
|
// See whether we are writing to a console the default console attrib:
|
||||||
g_ShouldColorOutput = (_isatty(_fileno(stdin)) != 0);
|
m_ShouldColorOutput = (_isatty(_fileno(stdin)) != 0);
|
||||||
if (g_ShouldColorOutput)
|
if (m_ShouldColorOutput)
|
||||||
{
|
{
|
||||||
CONSOLE_SCREEN_BUFFER_INFO sbi;
|
CONSOLE_SCREEN_BUFFER_INFO sbi;
|
||||||
GetConsoleScreenBufferInfo(g_Console, &sbi);
|
GetConsoleScreenBufferInfo(g_Console, &sbi);
|
||||||
g_DefaultConsoleAttrib = sbi.wAttributes;
|
m_DefaultConsoleAttrib = sbi.wAttributes;
|
||||||
}
|
}
|
||||||
#elif defined (__linux) && !defined(ANDROID_NDK)
|
#elif defined (__linux) && !defined(ANDROID_NDK)
|
||||||
g_ShouldColorOutput = isatty(fileno(stdout));
|
m_ShouldColorOutput = isatty(fileno(stdout));
|
||||||
// TODO: Check if the terminal supports colors, somehow?
|
// TODO: Check if the terminal supports colors, somehow?
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -178,7 +178,7 @@ void cMCLogger::Error(const char * a_Format, va_list a_ArgList)
|
|||||||
|
|
||||||
void cMCLogger::SetColor(eColorScheme a_Scheme)
|
void cMCLogger::SetColor(eColorScheme a_Scheme)
|
||||||
{
|
{
|
||||||
if (!g_ShouldColorOutput)
|
if (!m_ShouldColorOutput)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -211,7 +211,7 @@ void cMCLogger::SetColor(eColorScheme a_Scheme)
|
|||||||
|
|
||||||
void cMCLogger::ResetColor(void)
|
void cMCLogger::ResetColor(void)
|
||||||
{
|
{
|
||||||
if (!g_ShouldColorOutput)
|
if (!m_ShouldColorOutput)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -52,7 +52,7 @@ private:
|
|||||||
cCriticalSection m_CriticalSection;
|
cCriticalSection m_CriticalSection;
|
||||||
cLog * m_Log;
|
cLog * m_Log;
|
||||||
static cMCLogger * s_MCLogger;
|
static cMCLogger * s_MCLogger;
|
||||||
bool g_ShouldColorOutput;
|
bool m_ShouldColorOutput;
|
||||||
|
|
||||||
|
|
||||||
/// Sets the specified color scheme in the terminal (TODO: if coloring available)
|
/// Sets the specified color scheme in the terminal (TODO: if coloring available)
|
||||||
|
@ -109,12 +109,12 @@ void cAggressiveMonster::Attack(float a_Dt)
|
|||||||
bool cAggressiveMonster::IsMovingToTargetPosition()
|
bool cAggressiveMonster::IsMovingToTargetPosition()
|
||||||
{
|
{
|
||||||
float epsilon = 0.000000000001;
|
float epsilon = 0.000000000001;
|
||||||
//Difference between destination x and target x is negligable (to 10^-12 precision)
|
// Difference between destination x and target x is negligible (to 10^-12 precision)
|
||||||
if (fabsf((float)m_FinalDestination.x - (float)m_Target->GetPosX()) < epsilon)
|
if (fabsf((float)m_FinalDestination.x - (float)m_Target->GetPosX()) < epsilon)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
//Difference between destination z and target z is negligable (to 10^-12 precision)
|
// Difference between destination z and target z is negligible (to 10^-12 precision)
|
||||||
else if (fabsf(m_FinalDestination.z - (float)m_Target->GetPosZ()) > epsilon)
|
else if (fabsf(m_FinalDestination.z - (float)m_Target->GetPosZ()) > epsilon)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
@ -23,7 +23,7 @@ public:
|
|||||||
virtual void Attack(float a_Dt);
|
virtual void Attack(float a_Dt);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/* Whether this mob's destination is the same as its target's position. */
|
/** Whether this mob's destination is the same as its target's position. */
|
||||||
bool IsMovingToTargetPosition();
|
bool IsMovingToTargetPosition();
|
||||||
|
|
||||||
} ;
|
} ;
|
||||||
|
@ -621,10 +621,10 @@ void cNBTChunkSerializer::AddHangingEntity(cHangingEntity * a_Hanging)
|
|||||||
m_Writer.AddInt("TileZ", a_Hanging->GetTileZ());
|
m_Writer.AddInt("TileZ", a_Hanging->GetTileZ());
|
||||||
switch (a_Hanging->GetDirection())
|
switch (a_Hanging->GetDirection())
|
||||||
{
|
{
|
||||||
case BLOCK_FACE_YM: m_Writer.AddByte("Dir", (unsigned char)2); break;
|
case BLOCK_FACE_YM: m_Writer.AddByte("Dir", (unsigned char)2); break;
|
||||||
case BLOCK_FACE_YP: m_Writer.AddByte("Dir", (unsigned char)1); break;
|
case BLOCK_FACE_YP: m_Writer.AddByte("Dir", (unsigned char)1); break;
|
||||||
case BLOCK_FACE_ZM: m_Writer.AddByte("Dir", (unsigned char)0); break;
|
case BLOCK_FACE_ZM: m_Writer.AddByte("Dir", (unsigned char)0); break;
|
||||||
case BLOCK_FACE_ZP: m_Writer.AddByte("Dir", (unsigned char)3); break;
|
case BLOCK_FACE_ZP: m_Writer.AddByte("Dir", (unsigned char)3); break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user