Merge branch 'master' into cmake
This commit is contained in:
commit
779aca6051
1
MCServer/Plugins/APIDump/Static/.gitignore
vendored
Normal file
1
MCServer/Plugins/APIDump/Static/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
|
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
-- main.lua
|
-- main.lua
|
||||||
|
|
||||||
-- Implements the plugin entrypoint (in this case the entire plugin)
|
-- Implements the plugin entrypoint (in this case the entire plugin)
|
||||||
@ -232,6 +231,13 @@ end
|
|||||||
|
|
||||||
function DumpAPIHtml()
|
function DumpAPIHtml()
|
||||||
LOG("Dumping all available functions and constants to API subfolder...");
|
LOG("Dumping all available functions and constants to API subfolder...");
|
||||||
|
|
||||||
|
LOG("Moving static files..");
|
||||||
|
cFile:CreateFolder("API/Static");
|
||||||
|
local localFolder = g_Plugin:GetLocalFolder();
|
||||||
|
for k, v in cFile:GetFolderContents(localFolder .. "/Static") do
|
||||||
|
cFile:Copy(localFolder .. "/Static/" .. v, "API/Static/" .. v);
|
||||||
|
end
|
||||||
|
|
||||||
LOG("Creating API tables...");
|
LOG("Creating API tables...");
|
||||||
local API, Globals = CreateAPITables();
|
local API, Globals = CreateAPITables();
|
||||||
|
@ -1,17 +1,20 @@
|
|||||||
@echo off
|
@echo off
|
||||||
:: Nightbbuild2008.cmd
|
:: Nightbbuild2008.cmd
|
||||||
:: This script is run every night to produce a new version of MCServer, backup its PDB files and upload the packages to web.
|
:: This script is run every night to produce a new version of MCServer, backup its PDB files and upload the packages to web.
|
||||||
:: These sub-scripts are used:
|
|
||||||
:: - UploadVersion.ftp FTP command template for uploading the version to the web
|
|
||||||
:: When run without parameters, this script pauses at the end and waits for a keypress.
|
:: When run without parameters, this script pauses at the end and waits for a keypress.
|
||||||
:: To run in an automated scheduler, add any parameter to disable waiting for a keystroke
|
:: To run in an automated scheduler, add any parameter to disable waiting for a keystroke
|
||||||
::
|
::
|
||||||
|
:: The sript creates a symbol store (a database of PDB files) that can be used as a single entry in MSVC's symbol path,
|
||||||
|
:: then any executable / crashdump built by this script can be debugged and its symbols will be found automatically by MSVC,
|
||||||
|
:: without the users needing to specify the build version or anything.
|
||||||
|
:: In order to support pruning the symstore, a per-month store is created, so that old months can be removed when no longer needed.
|
||||||
|
::
|
||||||
:: This script expects a few tools on specific paths, you can pass the correct paths for your system as env vars "zip" and "vc"
|
:: This script expects a few tools on specific paths, you can pass the correct paths for your system as env vars "zip" and "vc"
|
||||||
:: This script assumes that "git", "symstore" and "touch" are available on PATH.
|
:: This script assumes that "git", "symstore" and "touch" are available on PATH.
|
||||||
:: git comes from msysgit
|
:: git comes from msysgit
|
||||||
:: symstore comes from Microsoft's Debugging Tools for Windows
|
:: symstore comes from Microsoft's Debugging Tools for Windows
|
||||||
:: touch comes from unxtools
|
:: touch comes from unxtools
|
||||||
:: This script is locale-dependent
|
:: This script is locale-dependent, because it parses the output of "time" and "date" shell commands
|
||||||
|
|
||||||
|
|
||||||
:: 7-zip executable (by default it should be on PATH):
|
:: 7-zip executable (by default it should be on PATH):
|
||||||
@ -45,9 +48,9 @@ echo Performing nightbuild of MC-Server
|
|||||||
set DONOTPAUSE=y
|
set DONOTPAUSE=y
|
||||||
|
|
||||||
:: Update the sources to the latest revision:
|
:: Update the sources to the latest revision:
|
||||||
del src\Bindings.cpp
|
del src\Bindings\Bindings.cpp
|
||||||
del src\Bindings.h
|
del src\Bindings\Bindings.h
|
||||||
git checkout -- src\Bindings.*
|
git checkout -- src\Bindings\Bindings.*
|
||||||
git pull
|
git pull
|
||||||
if errorlevel 1 goto haderror
|
if errorlevel 1 goto haderror
|
||||||
|
|
||||||
|
@ -131,7 +131,7 @@ static void MergeCombinatorLake(BLOCKTYPE & a_DstType, BLOCKTYPE a_SrcType, NIBB
|
|||||||
case E_BLOCK_STATIONARY_LAVA:
|
case E_BLOCK_STATIONARY_LAVA:
|
||||||
{
|
{
|
||||||
a_DstType = a_SrcType;
|
a_DstType = a_SrcType;
|
||||||
a_DstMeta = a_DstMeta;
|
a_DstMeta = a_SrcMeta;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -820,7 +820,6 @@ void cBlockArea::RelLine(int a_RelX1, int a_RelY1, int a_RelZ1, int a_RelX2, int
|
|||||||
int sx = (a_RelX1 < a_RelX2) ? 1 : -1;
|
int sx = (a_RelX1 < a_RelX2) ? 1 : -1;
|
||||||
int sy = (a_RelY1 < a_RelY2) ? 1 : -1;
|
int sy = (a_RelY1 < a_RelY2) ? 1 : -1;
|
||||||
int sz = (a_RelZ1 < a_RelZ2) ? 1 : -1;
|
int sz = (a_RelZ1 < a_RelZ2) ? 1 : -1;
|
||||||
int err = dx - dz;
|
|
||||||
|
|
||||||
if (dx >= std::max(dy, dz)) // x dominant
|
if (dx >= std::max(dy, dz)) // x dominant
|
||||||
{
|
{
|
||||||
|
@ -662,6 +662,7 @@ public:
|
|||||||
g_BlockTransparent[E_BLOCK_CROPS] = true;
|
g_BlockTransparent[E_BLOCK_CROPS] = true;
|
||||||
g_BlockTransparent[E_BLOCK_DANDELION] = true;
|
g_BlockTransparent[E_BLOCK_DANDELION] = true;
|
||||||
g_BlockTransparent[E_BLOCK_DETECTOR_RAIL] = true;
|
g_BlockTransparent[E_BLOCK_DETECTOR_RAIL] = true;
|
||||||
|
g_BlockTransparent[E_BLOCK_ENDER_CHEST] = true;
|
||||||
g_BlockTransparent[E_BLOCK_FENCE] = true;
|
g_BlockTransparent[E_BLOCK_FENCE] = true;
|
||||||
g_BlockTransparent[E_BLOCK_FENCE_GATE] = true;
|
g_BlockTransparent[E_BLOCK_FENCE_GATE] = true;
|
||||||
g_BlockTransparent[E_BLOCK_FIRE] = true;
|
g_BlockTransparent[E_BLOCK_FIRE] = true;
|
||||||
@ -691,12 +692,14 @@ public:
|
|||||||
g_BlockTransparent[E_BLOCK_STAINED_GLASS_PANE] = true;
|
g_BlockTransparent[E_BLOCK_STAINED_GLASS_PANE] = true;
|
||||||
g_BlockTransparent[E_BLOCK_STATIONARY_LAVA] = true;
|
g_BlockTransparent[E_BLOCK_STATIONARY_LAVA] = true;
|
||||||
g_BlockTransparent[E_BLOCK_STATIONARY_WATER] = true;
|
g_BlockTransparent[E_BLOCK_STATIONARY_WATER] = true;
|
||||||
|
g_BlockTransparent[E_BLOCK_STONE_BUTTON] = true;
|
||||||
g_BlockTransparent[E_BLOCK_STONE_PRESSURE_PLATE] = true;
|
g_BlockTransparent[E_BLOCK_STONE_PRESSURE_PLATE] = true;
|
||||||
g_BlockTransparent[E_BLOCK_TALL_GRASS] = true;
|
g_BlockTransparent[E_BLOCK_TALL_GRASS] = true;
|
||||||
g_BlockTransparent[E_BLOCK_TORCH] = true;
|
g_BlockTransparent[E_BLOCK_TORCH] = true;
|
||||||
g_BlockTransparent[E_BLOCK_VINES] = true;
|
g_BlockTransparent[E_BLOCK_VINES] = true;
|
||||||
g_BlockTransparent[E_BLOCK_WALLSIGN] = true;
|
g_BlockTransparent[E_BLOCK_WALLSIGN] = true;
|
||||||
g_BlockTransparent[E_BLOCK_WATER] = true;
|
g_BlockTransparent[E_BLOCK_WATER] = true;
|
||||||
|
g_BlockTransparent[E_BLOCK_WOODEN_BUTTON] = true;
|
||||||
g_BlockTransparent[E_BLOCK_WOODEN_DOOR] = true;
|
g_BlockTransparent[E_BLOCK_WOODEN_DOOR] = true;
|
||||||
g_BlockTransparent[E_BLOCK_WOODEN_PRESSURE_PLATE] = true;
|
g_BlockTransparent[E_BLOCK_WOODEN_PRESSURE_PLATE] = true;
|
||||||
|
|
||||||
|
@ -63,26 +63,27 @@ cChunk::cChunk(
|
|||||||
int a_ChunkX, int a_ChunkY, int a_ChunkZ,
|
int a_ChunkX, int a_ChunkY, int a_ChunkZ,
|
||||||
cChunkMap * a_ChunkMap, cWorld * a_World,
|
cChunkMap * a_ChunkMap, cWorld * a_World,
|
||||||
cChunk * a_NeighborXM, cChunk * a_NeighborXP, cChunk * a_NeighborZM, cChunk * a_NeighborZP
|
cChunk * a_NeighborXM, cChunk * a_NeighborXP, cChunk * a_NeighborZM, cChunk * a_NeighborZP
|
||||||
)
|
) :
|
||||||
: m_PosX( a_ChunkX )
|
m_IsValid(false),
|
||||||
, m_PosY( a_ChunkY )
|
m_IsLightValid(false),
|
||||||
, m_PosZ( a_ChunkZ )
|
m_IsDirty(false),
|
||||||
, m_BlockTickX( 0 )
|
m_IsSaving(false),
|
||||||
, m_BlockTickY( 0 )
|
m_HasLoadFailed(false),
|
||||||
, m_BlockTickZ( 0 )
|
m_StayCount(0),
|
||||||
, m_World( a_World )
|
m_PosX(a_ChunkX),
|
||||||
, m_ChunkMap(a_ChunkMap)
|
m_PosY(a_ChunkY),
|
||||||
, m_IsValid(false)
|
m_PosZ(a_ChunkZ),
|
||||||
, m_IsLightValid(false)
|
m_World(a_World),
|
||||||
, m_IsDirty(false)
|
m_ChunkMap(a_ChunkMap),
|
||||||
, m_IsSaving(false)
|
m_BlockTickX(0),
|
||||||
, m_StayCount(0)
|
m_BlockTickY(0),
|
||||||
, m_NeighborXM(a_NeighborXM)
|
m_BlockTickZ(0),
|
||||||
, m_NeighborXP(a_NeighborXP)
|
m_NeighborXM(a_NeighborXM),
|
||||||
, m_NeighborZM(a_NeighborZM)
|
m_NeighborXP(a_NeighborXP),
|
||||||
, m_NeighborZP(a_NeighborZP)
|
m_NeighborZM(a_NeighborZM),
|
||||||
, m_WaterSimulatorData(a_World->GetWaterSimulator()->CreateChunkData())
|
m_NeighborZP(a_NeighborZP),
|
||||||
, m_LavaSimulatorData (a_World->GetLavaSimulator ()->CreateChunkData())
|
m_WaterSimulatorData(a_World->GetWaterSimulator()->CreateChunkData()),
|
||||||
|
m_LavaSimulatorData (a_World->GetLavaSimulator ()->CreateChunkData())
|
||||||
{
|
{
|
||||||
if (a_NeighborXM != NULL)
|
if (a_NeighborXM != NULL)
|
||||||
{
|
{
|
||||||
|
@ -35,8 +35,8 @@ void cNotifyChunkSender::Call(int a_ChunkX, int a_ChunkZ)
|
|||||||
cChunkSender::cChunkSender(void) :
|
cChunkSender::cChunkSender(void) :
|
||||||
super("ChunkSender"),
|
super("ChunkSender"),
|
||||||
m_World(NULL),
|
m_World(NULL),
|
||||||
m_Notify(NULL),
|
m_RemoveCount(0),
|
||||||
m_RemoveCount(0)
|
m_Notify(NULL)
|
||||||
{
|
{
|
||||||
m_Notify.SetChunkSender(this);
|
m_Notify.SetChunkSender(this);
|
||||||
}
|
}
|
||||||
|
@ -77,27 +77,26 @@ int cClientHandle::s_ClientCount = 0;
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// cClientHandle:
|
// cClientHandle:
|
||||||
|
|
||||||
cClientHandle::cClientHandle(const cSocket * a_Socket, int a_ViewDistance)
|
cClientHandle::cClientHandle(const cSocket * a_Socket, int a_ViewDistance) :
|
||||||
: m_ViewDistance(a_ViewDistance)
|
m_ViewDistance(a_ViewDistance),
|
||||||
, m_IPString(a_Socket->GetIPString())
|
m_IPString(a_Socket->GetIPString()),
|
||||||
, m_OutgoingData(64 KiB)
|
m_OutgoingData(64 KiB),
|
||||||
, m_Player(NULL)
|
m_Player(NULL),
|
||||||
, m_HasSentDC(false)
|
m_HasSentDC(false),
|
||||||
, m_TimeSinceLastPacket(0)
|
m_LastStreamedChunkX(0x7fffffff), // bogus chunk coords to force streaming upon login
|
||||||
, m_bKeepThreadGoing(true)
|
m_LastStreamedChunkZ(0x7fffffff),
|
||||||
, m_Ping(1000)
|
m_TimeSinceLastPacket(0),
|
||||||
, m_PingID(1)
|
m_Ping(1000),
|
||||||
, m_TicksSinceDestruction(0)
|
m_PingID(1),
|
||||||
, m_State(csConnected)
|
m_BlockDigAnimStage(-1),
|
||||||
, m_LastStreamedChunkX(0x7fffffff) // bogus chunk coords to force streaming upon login
|
m_HasStartedDigging(false),
|
||||||
, m_LastStreamedChunkZ(0x7fffffff)
|
m_TicksSinceDestruction(0),
|
||||||
, m_ShouldCheckDownloaded(false)
|
m_State(csConnected),
|
||||||
, m_UniqueID(0)
|
m_ShouldCheckDownloaded(false),
|
||||||
, m_BlockDigAnimStage(-1)
|
m_CurrentExplosionTick(0),
|
||||||
, m_HasStartedDigging(false)
|
m_RunningSumExplosions(0),
|
||||||
, m_CurrentExplosionTick(0)
|
m_UniqueID(0),
|
||||||
, m_RunningSumExplosions(0)
|
m_HasSentPlayerChunk(false)
|
||||||
, m_HasSentPlayerChunk(false)
|
|
||||||
{
|
{
|
||||||
m_Protocol = new cProtocolRecognizer(this);
|
m_Protocol = new cProtocolRecognizer(this);
|
||||||
|
|
||||||
|
@ -42,12 +42,6 @@ class cClientHandle : // tolua_export
|
|||||||
public cSocketThreads::cCallback
|
public cSocketThreads::cCallback
|
||||||
{ // tolua_export
|
{ // tolua_export
|
||||||
public:
|
public:
|
||||||
enum ENUM_PRIORITY
|
|
||||||
{
|
|
||||||
E_PRIORITY_LOW,
|
|
||||||
E_PRIORITY_NORMAL
|
|
||||||
};
|
|
||||||
|
|
||||||
static const int MAXBLOCKCHANGEINTERACTIONS = 20; // 5 didn't help, 10 still doesn't work in Creative, 20 seems to have done the trick
|
static const int MAXBLOCKCHANGEINTERACTIONS = 20; // 5 didn't help, 10 still doesn't work in Creative, 20 seems to have done the trick
|
||||||
|
|
||||||
#if defined(ANDROID_NDK)
|
#if defined(ANDROID_NDK)
|
||||||
@ -219,7 +213,6 @@ private:
|
|||||||
|
|
||||||
AString m_IPString;
|
AString m_IPString;
|
||||||
|
|
||||||
int m_ProtocolVersion;
|
|
||||||
AString m_Username;
|
AString m_Username;
|
||||||
AString m_Password;
|
AString m_Password;
|
||||||
|
|
||||||
@ -291,8 +284,6 @@ private:
|
|||||||
/// m_State needs to be locked in the Destroy() function so that the destruction code doesn't run twice on two different threads
|
/// m_State needs to be locked in the Destroy() function so that the destruction code doesn't run twice on two different threads
|
||||||
cCriticalSection m_CSDestroyingState;
|
cCriticalSection m_CSDestroyingState;
|
||||||
|
|
||||||
bool m_bKeepThreadGoing;
|
|
||||||
|
|
||||||
/// If set to true during csDownloadingWorld, the tick thread calls CheckIfWorldDownloaded()
|
/// If set to true during csDownloadingWorld, the tick thread calls CheckIfWorldDownloaded()
|
||||||
bool m_ShouldCheckDownloaded;
|
bool m_ShouldCheckDownloaded;
|
||||||
|
|
||||||
|
@ -33,31 +33,31 @@ cEntity::cEntity(eEntityType a_EntityType, double a_X, double a_Y, double a_Z, d
|
|||||||
, m_Attachee(NULL)
|
, m_Attachee(NULL)
|
||||||
, m_Referencers(new cReferenceManager(cReferenceManager::RFMNGR_REFERENCERS))
|
, m_Referencers(new cReferenceManager(cReferenceManager::RFMNGR_REFERENCERS))
|
||||||
, m_References(new cReferenceManager(cReferenceManager::RFMNGR_REFERENCES))
|
, m_References(new cReferenceManager(cReferenceManager::RFMNGR_REFERENCES))
|
||||||
, m_HeadYaw( 0.0 )
|
|
||||||
, m_Rot(0.0, 0.0, 0.0)
|
|
||||||
, m_Pos(a_X, a_Y, a_Z)
|
|
||||||
, m_Mass (0.001) //Default 1g
|
|
||||||
, m_bDirtyHead(true)
|
, m_bDirtyHead(true)
|
||||||
, m_bDirtyOrientation(true)
|
, m_bDirtyOrientation(true)
|
||||||
, m_bDirtyPosition(true)
|
, m_bDirtyPosition(true)
|
||||||
, m_bDirtySpeed(true)
|
, m_bDirtySpeed(true)
|
||||||
, m_bOnGround( false )
|
, m_bOnGround( false )
|
||||||
, m_Gravity( -9.81f )
|
, m_Gravity( -9.81f )
|
||||||
, m_IsInitialized(false)
|
|
||||||
, m_LastPosX( 0.0 )
|
, m_LastPosX( 0.0 )
|
||||||
, m_LastPosY( 0.0 )
|
, m_LastPosY( 0.0 )
|
||||||
, m_LastPosZ( 0.0 )
|
, m_LastPosZ( 0.0 )
|
||||||
, m_TimeLastTeleportPacket(0)
|
, m_TimeLastTeleportPacket(0)
|
||||||
, m_TimeLastMoveReltPacket(0)
|
, m_TimeLastMoveReltPacket(0)
|
||||||
, m_TimeLastSpeedPacket(0)
|
, m_TimeLastSpeedPacket(0)
|
||||||
|
, m_IsInitialized(false)
|
||||||
, m_EntityType(a_EntityType)
|
, m_EntityType(a_EntityType)
|
||||||
, m_World(NULL)
|
, m_World(NULL)
|
||||||
, m_TicksSinceLastBurnDamage(0)
|
, m_TicksSinceLastBurnDamage(0)
|
||||||
, m_TicksSinceLastLavaDamage(0)
|
, m_TicksSinceLastLavaDamage(0)
|
||||||
, m_TicksSinceLastFireDamage(0)
|
, m_TicksSinceLastFireDamage(0)
|
||||||
, m_TicksSinceLastVoidDamage(0)
|
|
||||||
, m_TicksLeftBurning(0)
|
, m_TicksLeftBurning(0)
|
||||||
|
, m_TicksSinceLastVoidDamage(0)
|
||||||
|
, m_HeadYaw( 0.0 )
|
||||||
|
, m_Rot(0.0, 0.0, 0.0)
|
||||||
|
, m_Pos(a_X, a_Y, a_Z)
|
||||||
, m_WaterSpeed(0, 0, 0)
|
, m_WaterSpeed(0, 0, 0)
|
||||||
|
, m_Mass (0.001) // Default 1g
|
||||||
, m_Width(a_Width)
|
, m_Width(a_Width)
|
||||||
, m_Height(a_Height)
|
, m_Height(a_Height)
|
||||||
{
|
{
|
||||||
|
@ -387,7 +387,7 @@ protected:
|
|||||||
double m_LastPosX, m_LastPosY, m_LastPosZ;
|
double m_LastPosX, m_LastPosY, m_LastPosZ;
|
||||||
|
|
||||||
// This variables keep track of the last time a packet was sent
|
// This variables keep track of the last time a packet was sent
|
||||||
Int64 m_TimeLastTeleportPacket,m_TimeLastMoveReltPacket,m_TimeLastSpeedPacket; // In ticks
|
Int64 m_TimeLastTeleportPacket, m_TimeLastMoveReltPacket, m_TimeLastSpeedPacket; // In ticks
|
||||||
|
|
||||||
bool m_IsInitialized; // Is set to true when it's initialized, until it's destroyed (Initialize() till Destroy() )
|
bool m_IsInitialized; // Is set to true when it's initialized, until it's destroyed (Initialize() till Destroy() )
|
||||||
|
|
||||||
|
@ -1,14 +1,19 @@
|
|||||||
|
|
||||||
#include "Globals.h"
|
#include "Globals.h"
|
||||||
|
|
||||||
#include "Floater.h"
|
#include "Floater.h"
|
||||||
#include "Player.h"
|
#include "Player.h"
|
||||||
#include "../ClientHandle.h"
|
#include "../ClientHandle.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
cFloater::cFloater(double a_X, double a_Y, double a_Z, Vector3d a_Speed, int a_PlayerID) :
|
cFloater::cFloater(double a_X, double a_Y, double a_Z, Vector3d a_Speed, int a_PlayerID) :
|
||||||
cEntity(etFloater, a_X, a_Y, a_Z, 0.98, 0.98),
|
cEntity(etFloater, a_X, a_Y, a_Z, 0.98, 0.98),
|
||||||
|
m_PickupCountDown(0),
|
||||||
m_PlayerID(a_PlayerID),
|
m_PlayerID(a_PlayerID),
|
||||||
m_CanPickupItem(false),
|
m_CanPickupItem(false)
|
||||||
m_PickupCountDown(0)
|
|
||||||
{
|
{
|
||||||
SetSpeed(a_Speed);
|
SetSpeed(a_Speed);
|
||||||
}
|
}
|
||||||
@ -29,9 +34,9 @@ void cFloater::SpawnOn(cClientHandle & a_Client)
|
|||||||
void cFloater::Tick(float a_Dt, cChunk & a_Chunk)
|
void cFloater::Tick(float a_Dt, cChunk & a_Chunk)
|
||||||
{
|
{
|
||||||
HandlePhysics(a_Dt, a_Chunk);
|
HandlePhysics(a_Dt, a_Chunk);
|
||||||
if (IsBlockWater(m_World->GetBlock((int) GetPosX(), (int) GetPosY(), (int) GetPosZ())))
|
if (IsBlockWater(m_World->GetBlock((int) GetPosX(), (int) GetPosY(), (int) GetPosZ())) && m_World->GetBlockMeta((int) GetPosX(), (int) GetPosY(), (int) GetPosZ()) == 0)
|
||||||
{
|
{
|
||||||
if (m_World->GetTickRandomNumber(100) == 0)
|
if ((!m_CanPickupItem) && (m_World->GetTickRandomNumber(100) == 0))
|
||||||
{
|
{
|
||||||
SetPosY(GetPosY() - 1);
|
SetPosY(GetPosY() - 1);
|
||||||
m_CanPickupItem = true;
|
m_CanPickupItem = true;
|
||||||
@ -40,7 +45,7 @@ void cFloater::Tick(float a_Dt, cChunk & a_Chunk)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SetSpeedY(1);
|
SetSpeedY(0.7);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SetSpeedX(GetSpeedX() * 0.95);
|
SetSpeedX(GetSpeedX() * 0.95);
|
||||||
@ -55,4 +60,8 @@ void cFloater::Tick(float a_Dt, cChunk & a_Chunk)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
BroadcastMovementUpdate();
|
BroadcastMovementUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -36,43 +36,44 @@
|
|||||||
|
|
||||||
cPlayer::cPlayer(cClientHandle* a_Client, const AString & a_PlayerName)
|
cPlayer::cPlayer(cClientHandle* a_Client, const AString & a_PlayerName)
|
||||||
: super(etPlayer, 0.6, 1.8)
|
: super(etPlayer, 0.6, 1.8)
|
||||||
, m_GameMode(eGameMode_NotSet)
|
|
||||||
, m_IP("")
|
|
||||||
, m_LastBlockActionTime( 0 )
|
|
||||||
, m_LastBlockActionCnt( 0 )
|
|
||||||
, m_AirLevel( MAX_AIR_LEVEL )
|
, m_AirLevel( MAX_AIR_LEVEL )
|
||||||
, m_AirTickTimer( DROWNING_TICKS )
|
, m_AirTickTimer(DROWNING_TICKS)
|
||||||
, m_bVisible( true )
|
, m_bVisible(true)
|
||||||
, m_LastGroundHeight( 0 )
|
|
||||||
, m_bTouchGround( false )
|
|
||||||
, m_Stance( 0.0 )
|
|
||||||
, m_Inventory(*this)
|
|
||||||
, m_CurrentWindow(NULL)
|
|
||||||
, m_InventoryWindow(NULL)
|
|
||||||
, m_TimeLastPickupCheck( 0.f )
|
|
||||||
, m_Color('-')
|
|
||||||
, m_ClientHandle( a_Client )
|
|
||||||
, m_FoodLevel(MAX_FOOD_LEVEL)
|
, m_FoodLevel(MAX_FOOD_LEVEL)
|
||||||
, m_FoodSaturationLevel(5)
|
, m_FoodSaturationLevel(5)
|
||||||
, m_FoodTickTimer(0)
|
, m_FoodTickTimer(0)
|
||||||
, m_FoodExhaustionLevel(0)
|
, m_FoodExhaustionLevel(0)
|
||||||
, m_FoodPoisonedTicksRemaining(0)
|
, m_FoodPoisonedTicksRemaining(0)
|
||||||
|
, m_LastJumpHeight(0)
|
||||||
|
, m_LastGroundHeight(0)
|
||||||
|
, m_bTouchGround(false)
|
||||||
|
, m_Stance(0.0)
|
||||||
|
, m_Inventory(*this)
|
||||||
|
, m_CurrentWindow(NULL)
|
||||||
|
, m_InventoryWindow(NULL)
|
||||||
|
, m_TimeLastPickupCheck(0.f)
|
||||||
|
, m_Color('-')
|
||||||
|
, m_LastBlockActionTime(0)
|
||||||
|
, m_LastBlockActionCnt(0)
|
||||||
|
, m_GameMode(eGameMode_NotSet)
|
||||||
|
, m_IP("")
|
||||||
|
, m_ClientHandle(a_Client)
|
||||||
, m_NormalMaxSpeed(0.1)
|
, m_NormalMaxSpeed(0.1)
|
||||||
, m_SprintingMaxSpeed(0.13)
|
, m_SprintingMaxSpeed(0.13)
|
||||||
, m_IsCrouched(false)
|
, m_IsCrouched(false)
|
||||||
, m_IsSprinting(false)
|
, m_IsSprinting(false)
|
||||||
|
, m_IsFlying(false)
|
||||||
, m_IsSwimming(false)
|
, m_IsSwimming(false)
|
||||||
, m_IsSubmerged(false)
|
, m_IsSubmerged(false)
|
||||||
, m_IsFlying(false)
|
|
||||||
, m_CanFly(false)
|
|
||||||
, m_IsFishing(false)
|
, m_IsFishing(false)
|
||||||
, m_FloaterID(-1)
|
, m_CanFly(false)
|
||||||
, m_EatingFinishTick(-1)
|
, m_EatingFinishTick(-1)
|
||||||
|
, m_LifetimeTotalXp(0)
|
||||||
|
, m_CurrentXp(0)
|
||||||
|
, m_bDirtyExperience(false)
|
||||||
, m_IsChargingBow(false)
|
, m_IsChargingBow(false)
|
||||||
, m_BowCharge(0)
|
, m_BowCharge(0)
|
||||||
, m_CurrentXp(0)
|
, m_FloaterID(-1)
|
||||||
, m_LifetimeTotalXp(0)
|
|
||||||
, m_bDirtyExperience(false)
|
|
||||||
{
|
{
|
||||||
LOGD("Created a player object for \"%s\" @ \"%s\" at %p, ID %d",
|
LOGD("Created a player object for \"%s\" @ \"%s\" at %p, ID %d",
|
||||||
a_PlayerName.c_str(), a_Client->GetIPString().c_str(),
|
a_PlayerName.c_str(), a_Client->GetIPString().c_str(),
|
||||||
|
@ -407,9 +407,6 @@ protected:
|
|||||||
|
|
||||||
float m_TimeLastPickupCheck;
|
float m_TimeLastPickupCheck;
|
||||||
|
|
||||||
void ResolvePermissions();
|
|
||||||
|
|
||||||
void ResolveGroups();
|
|
||||||
char m_Color;
|
char m_Color;
|
||||||
|
|
||||||
float m_LastBlockActionTime;
|
float m_LastBlockActionTime;
|
||||||
@ -417,6 +414,7 @@ protected:
|
|||||||
eGameMode m_GameMode;
|
eGameMode m_GameMode;
|
||||||
std::string m_IP;
|
std::string m_IP;
|
||||||
|
|
||||||
|
/// The item being dragged by the cursor while in a UI window
|
||||||
cItem m_DraggingItem;
|
cItem m_DraggingItem;
|
||||||
|
|
||||||
long long m_LastPlayerListTime;
|
long long m_LastPlayerListTime;
|
||||||
@ -456,6 +454,11 @@ protected:
|
|||||||
|
|
||||||
int m_FloaterID;
|
int m_FloaterID;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void ResolvePermissions(void);
|
||||||
|
void ResolveGroups(void);
|
||||||
|
|
||||||
virtual void Destroyed(void);
|
virtual void Destroyed(void);
|
||||||
|
|
||||||
/// Filters out damage for creative mode
|
/// Filters out damage for creative mode
|
||||||
|
@ -396,9 +396,9 @@ cArrowEntity::cArrowEntity(cEntity * a_Creator, double a_X, double a_Y, double a
|
|||||||
m_DamageCoeff(2),
|
m_DamageCoeff(2),
|
||||||
m_IsCritical(false),
|
m_IsCritical(false),
|
||||||
m_Timer(0),
|
m_Timer(0),
|
||||||
|
m_HitGroundTimer(0),
|
||||||
m_bIsCollected(false),
|
m_bIsCollected(false),
|
||||||
m_HitBlockPos(Vector3i(0, 0, 0)),
|
m_HitBlockPos(Vector3i(0, 0, 0))
|
||||||
m_HitGroundTimer(0)
|
|
||||||
{
|
{
|
||||||
SetSpeed(a_Speed);
|
SetSpeed(a_Speed);
|
||||||
SetMass(0.1);
|
SetMass(0.1);
|
||||||
@ -420,9 +420,9 @@ cArrowEntity::cArrowEntity(cPlayer & a_Player, double a_Force) :
|
|||||||
m_DamageCoeff(2),
|
m_DamageCoeff(2),
|
||||||
m_IsCritical((a_Force >= 1)),
|
m_IsCritical((a_Force >= 1)),
|
||||||
m_Timer(0),
|
m_Timer(0),
|
||||||
|
m_HitGroundTimer(0),
|
||||||
m_bIsCollected(false),
|
m_bIsCollected(false),
|
||||||
m_HitBlockPos(0, 0, 0),
|
m_HitBlockPos(0, 0, 0)
|
||||||
m_HitGroundTimer(0)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,6 +29,11 @@ public:
|
|||||||
|
|
||||||
virtual bool OnItemUse(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Dir) override
|
virtual bool OnItemUse(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Dir) override
|
||||||
{
|
{
|
||||||
|
if (a_Dir != BLOCK_FACE_NONE)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (a_Player->IsFishing())
|
if (a_Player->IsFishing())
|
||||||
{
|
{
|
||||||
class cFloaterCallback :
|
class cFloaterCallback :
|
||||||
@ -63,13 +68,13 @@ public:
|
|||||||
Drops.Add(cItem(E_ITEM_RAW_FISH));
|
Drops.Add(cItem(E_ITEM_RAW_FISH));
|
||||||
Vector3d FloaterPos(Callbacks.GetPos());
|
Vector3d FloaterPos(Callbacks.GetPos());
|
||||||
Vector3d FlyDirection(a_Player->GetPosition() - FloaterPos);
|
Vector3d FlyDirection(a_Player->GetPosition() - FloaterPos);
|
||||||
a_World->SpawnItemPickups(Drops, FloaterPos.x, FloaterPos.y, FloaterPos.z, FlyDirection.x, FlyDirection.y, FlyDirection.z);
|
a_World->SpawnItemPickups(Drops, FloaterPos.x, FloaterPos.y, FloaterPos.z, FlyDirection.x, FlyDirection.Length() / (FlyDirection.y * 2), FlyDirection.z);
|
||||||
// TODO: More types of pickups.
|
// TODO: More types of pickups.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cFloater * Floater = new cFloater(a_Player->GetPosX(), a_Player->GetStance(), a_Player->GetPosZ(), a_Player->GetLookVector() * 7, a_Player->GetUniqueID());
|
cFloater * Floater = new cFloater(a_Player->GetPosX(), a_Player->GetStance(), a_Player->GetPosZ(), a_Player->GetLookVector() * 15, a_Player->GetUniqueID());
|
||||||
Floater->Initialize(a_World);
|
Floater->Initialize(a_World);
|
||||||
a_Player->SetIsFishing(true, Floater->GetUniqueID());
|
a_Player->SetIsFishing(true, Floater->GetUniqueID());
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,6 @@ void cMobCensus::CollectMob(cMonster & a_Monster, cChunk & a_Chunk, double a_Dis
|
|||||||
|
|
||||||
bool cMobCensus::IsCapped(cMonster::eFamily a_MobFamily)
|
bool cMobCensus::IsCapped(cMonster::eFamily a_MobFamily)
|
||||||
{
|
{
|
||||||
bool toReturn = true;
|
|
||||||
const int ratio = 319; // this should be 256 as we are only supposed to take account from chunks that are in 17x17 from a player
|
const int ratio = 319; // this should be 256 as we are only supposed to take account from chunks that are in 17x17 from a player
|
||||||
// but for now, we use all chunks loaded by players. that means 19 x 19 chunks. That's why we use 256 * (19*19) / (17*17) = 319
|
// but for now, we use all chunks loaded by players. that means 19 x 19 chunks. That's why we use 256 * (19*19) / (17*17) = 319
|
||||||
// MG TODO : code the correct count
|
// MG TODO : code the correct count
|
||||||
@ -42,9 +41,12 @@ int cMobCensus::GetCapMultiplier(cMonster::eFamily a_MobFamily)
|
|||||||
case cMonster::mfPassive: return 11;
|
case cMonster::mfPassive: return 11;
|
||||||
case cMonster::mfAmbient: return 16;
|
case cMonster::mfAmbient: return 16;
|
||||||
case cMonster::mfWater: return 5;
|
case cMonster::mfWater: return 5;
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
ASSERT(!"Unhandled mob family");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ASSERT(!"Unhandled mob family");
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -68,9 +68,12 @@ static const struct
|
|||||||
|
|
||||||
cMonster::cMonster(const AString & a_ConfigName, eType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height)
|
cMonster::cMonster(const AString & a_ConfigName, eType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height)
|
||||||
: super(etMonster, a_Width, a_Height)
|
: super(etMonster, a_Width, a_Height)
|
||||||
|
, m_EMState(IDLE)
|
||||||
|
, m_EMPersonality(AGGRESSIVE)
|
||||||
|
, m_SightDistance(25)
|
||||||
, m_Target(NULL)
|
, m_Target(NULL)
|
||||||
, m_AttackRate(3)
|
, m_AttackRate(3)
|
||||||
, idle_interval(0)
|
, m_IdleInterval(0)
|
||||||
, m_bMovingToDestination(false)
|
, m_bMovingToDestination(false)
|
||||||
, m_DestinationTime( 0 )
|
, m_DestinationTime( 0 )
|
||||||
, m_DestroyTimer( 0 )
|
, m_DestroyTimer( 0 )
|
||||||
@ -78,10 +81,7 @@ cMonster::cMonster(const AString & a_ConfigName, eType a_MobType, const AString
|
|||||||
, m_MobType(a_MobType)
|
, m_MobType(a_MobType)
|
||||||
, m_SoundHurt(a_SoundHurt)
|
, m_SoundHurt(a_SoundHurt)
|
||||||
, m_SoundDeath(a_SoundDeath)
|
, m_SoundDeath(a_SoundDeath)
|
||||||
, m_EMState(IDLE)
|
|
||||||
, m_SightDistance(25)
|
|
||||||
, m_SeePlayerInterval (0)
|
, m_SeePlayerInterval (0)
|
||||||
, m_EMPersonality(AGGRESSIVE)
|
|
||||||
, m_AttackDamage(1.0f)
|
, m_AttackDamage(1.0f)
|
||||||
, m_AttackRange(2.0f)
|
, m_AttackRange(2.0f)
|
||||||
, m_AttackInterval(0)
|
, m_AttackInterval(0)
|
||||||
@ -435,13 +435,13 @@ void cMonster::EventLosePlayer(void)
|
|||||||
// What to do if in Idle State
|
// What to do if in Idle State
|
||||||
void cMonster::InStateIdle(float a_Dt)
|
void cMonster::InStateIdle(float a_Dt)
|
||||||
{
|
{
|
||||||
idle_interval += a_Dt;
|
m_IdleInterval += a_Dt;
|
||||||
if (idle_interval > 1)
|
if (m_IdleInterval > 1)
|
||||||
{
|
{
|
||||||
// at this interval the results are predictable
|
// at this interval the results are predictable
|
||||||
int rem = m_World->GetTickRandomNumber(6) + 1;
|
int rem = m_World->GetTickRandomNumber(6) + 1;
|
||||||
// LOGD("Moving: int: %3.3f rem: %i",idle_interval,rem);
|
// LOGD("Moving: int: %3.3f rem: %i",idle_interval,rem);
|
||||||
idle_interval -= 1; // So nothing gets dropped when the server hangs for a few seconds
|
m_IdleInterval -= 1; // So nothing gets dropped when the server hangs for a few seconds
|
||||||
Vector3f Dist;
|
Vector3f Dist;
|
||||||
Dist.x = (float)(m_World->GetTickRandomNumber(10) - 5);
|
Dist.x = (float)(m_World->GetTickRandomNumber(10) - 5);
|
||||||
Dist.z = (float)(m_World->GetTickRandomNumber(10) - 5);
|
Dist.z = (float)(m_World->GetTickRandomNumber(10) - 5);
|
||||||
|
@ -161,7 +161,7 @@ protected:
|
|||||||
|
|
||||||
cEntity * m_Target;
|
cEntity * m_Target;
|
||||||
float m_AttackRate;
|
float m_AttackRate;
|
||||||
float idle_interval;
|
float m_IdleInterval;
|
||||||
|
|
||||||
Vector3f m_Destination;
|
Vector3f m_Destination;
|
||||||
bool m_bMovingToDestination;
|
bool m_bMovingToDestination;
|
||||||
|
@ -11,10 +11,10 @@
|
|||||||
|
|
||||||
cWolf::cWolf(void) :
|
cWolf::cWolf(void) :
|
||||||
super("Wolf", mtWolf, "mob.wolf.hurt", "mob.wolf.death", 0.6, 0.8),
|
super("Wolf", mtWolf, "mob.wolf.hurt", "mob.wolf.death", 0.6, 0.8),
|
||||||
m_IsAngry(false),
|
|
||||||
m_IsTame(false),
|
|
||||||
m_IsSitting(false),
|
m_IsSitting(false),
|
||||||
|
m_IsTame(false),
|
||||||
m_IsBegging(false),
|
m_IsBegging(false),
|
||||||
|
m_IsAngry(false),
|
||||||
m_OwnerName(""),
|
m_OwnerName(""),
|
||||||
m_CollarColor(14)
|
m_CollarColor(14)
|
||||||
{
|
{
|
||||||
|
@ -8,10 +8,11 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
cZombie::cZombie(bool IsVillagerZombie) :
|
|
||||||
|
cZombie::cZombie(bool a_IsVillagerZombie) :
|
||||||
super("Zombie", mtZombie, "mob.zombie.hurt", "mob.zombie.death", 0.6, 1.8),
|
super("Zombie", mtZombie, "mob.zombie.hurt", "mob.zombie.death", 0.6, 1.8),
|
||||||
m_bIsConverting(false),
|
m_IsVillagerZombie(a_IsVillagerZombie),
|
||||||
m_bIsVillagerZombie(IsVillagerZombie)
|
m_IsConverting(false)
|
||||||
{
|
{
|
||||||
SetBurnsInDaylight(true);
|
SetBurnsInDaylight(true);
|
||||||
}
|
}
|
||||||
@ -45,3 +46,5 @@ void cZombie::MoveToPosition(const Vector3f & a_Position)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -12,19 +12,20 @@ class cZombie :
|
|||||||
typedef cAggressiveMonster super;
|
typedef cAggressiveMonster super;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
cZombie(bool IsVillagerZombie);
|
cZombie(bool a_IsVillagerZombie);
|
||||||
|
|
||||||
CLASS_PROTODEF(cZombie);
|
CLASS_PROTODEF(cZombie);
|
||||||
|
|
||||||
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
|
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
|
||||||
virtual void MoveToPosition(const Vector3f & a_Position) override;
|
virtual void MoveToPosition(const Vector3f & a_Position) override;
|
||||||
|
|
||||||
bool IsVillagerZombie(void) const {return m_bIsVillagerZombie; }
|
bool IsVillagerZombie(void) const {return m_IsVillagerZombie; }
|
||||||
bool IsConverting(void) const {return m_bIsConverting; }
|
bool IsConverting (void) const {return m_IsConverting; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
bool m_bIsVillagerZombie, m_bIsConverting;
|
bool m_IsVillagerZombie;
|
||||||
|
bool m_IsConverting;
|
||||||
|
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
|
@ -51,8 +51,8 @@ static void SetThreadName( DWORD dwThreadID, LPCSTR szThreadName)
|
|||||||
// cIsThread:
|
// cIsThread:
|
||||||
|
|
||||||
cIsThread::cIsThread(const AString & iThreadName) :
|
cIsThread::cIsThread(const AString & iThreadName) :
|
||||||
m_ThreadName(iThreadName),
|
|
||||||
m_ShouldTerminate(false),
|
m_ShouldTerminate(false),
|
||||||
|
m_ThreadName(iThreadName),
|
||||||
m_Handle(NULL_HANDLE)
|
m_Handle(NULL_HANDLE)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -144,7 +144,7 @@ bool cIsThread::Wait(void)
|
|||||||
return (res == WAIT_OBJECT_0);
|
return (res == WAIT_OBJECT_0);
|
||||||
#else // _WIN32
|
#else // _WIN32
|
||||||
int res = pthread_join(m_Handle, NULL);
|
int res = pthread_join(m_Handle, NULL);
|
||||||
m_Handle = NULL;
|
m_Handle = NULL_HANDLE;
|
||||||
|
|
||||||
#ifdef LOGD // ProtoProxy doesn't have LOGD
|
#ifdef LOGD // ProtoProxy doesn't have LOGD
|
||||||
LOGD("Thread %s finished", m_ThreadName.c_str());
|
LOGD("Thread %s finished", m_ThreadName.c_str());
|
||||||
|
@ -188,7 +188,7 @@ void cProtocol132::DataReceived(const char * a_Data, int a_Size)
|
|||||||
byte Decrypted[512];
|
byte Decrypted[512];
|
||||||
while (a_Size > 0)
|
while (a_Size > 0)
|
||||||
{
|
{
|
||||||
int NumBytes = (a_Size > sizeof(Decrypted)) ? sizeof(Decrypted) : a_Size;
|
int NumBytes = (a_Size > (int)sizeof(Decrypted)) ? (int)sizeof(Decrypted) : a_Size;
|
||||||
m_Decryptor.ProcessData(Decrypted, (byte *)a_Data, NumBytes);
|
m_Decryptor.ProcessData(Decrypted, (byte *)a_Data, NumBytes);
|
||||||
super::DataReceived((const char *)Decrypted, NumBytes);
|
super::DataReceived((const char *)Decrypted, NumBytes);
|
||||||
a_Size -= NumBytes;
|
a_Size -= NumBytes;
|
||||||
@ -705,7 +705,7 @@ void cProtocol132::Flush(void)
|
|||||||
byte Encrypted[8192]; // Larger buffer, we may be sending lots of data (chunks)
|
byte Encrypted[8192]; // Larger buffer, we may be sending lots of data (chunks)
|
||||||
while (a_Size > 0)
|
while (a_Size > 0)
|
||||||
{
|
{
|
||||||
int NumBytes = (a_Size > sizeof(Encrypted)) ? sizeof(Encrypted) : a_Size;
|
int NumBytes = (a_Size > (int)sizeof(Encrypted)) ? (int)sizeof(Encrypted) : a_Size;
|
||||||
m_Encryptor.ProcessData(Encrypted, (byte *)a_Data, NumBytes);
|
m_Encryptor.ProcessData(Encrypted, (byte *)a_Data, NumBytes);
|
||||||
super::SendData((const char *)Encrypted, NumBytes);
|
super::SendData((const char *)Encrypted, NumBytes);
|
||||||
a_Size -= NumBytes;
|
a_Size -= NumBytes;
|
||||||
|
72
src/Root.cpp
72
src/Root.cpp
@ -39,19 +39,20 @@ cRoot* cRoot::s_Root = NULL;
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
cRoot::cRoot()
|
cRoot::cRoot(void) :
|
||||||
: m_Server( NULL )
|
m_PrimaryServerVersion(cProtocolRecognizer::PROTO_VERSION_LATEST),
|
||||||
, m_MonsterConfig( NULL )
|
m_pDefaultWorld(NULL),
|
||||||
, m_GroupManager( NULL )
|
m_InputThread(NULL),
|
||||||
, m_CraftingRecipes(NULL)
|
m_Server(NULL),
|
||||||
, m_FurnaceRecipe( NULL )
|
m_MonsterConfig(NULL),
|
||||||
, m_WebAdmin( NULL )
|
m_GroupManager(NULL),
|
||||||
, m_PluginManager( NULL )
|
m_CraftingRecipes(NULL),
|
||||||
, m_Log( NULL )
|
m_FurnaceRecipe(NULL),
|
||||||
, m_bStop( false )
|
m_WebAdmin(NULL),
|
||||||
, m_bRestart( false )
|
m_PluginManager(NULL),
|
||||||
, m_InputThread( NULL )
|
m_Log(NULL),
|
||||||
, m_pDefaultWorld( NULL )
|
m_bStop(false),
|
||||||
|
m_bRestart(false)
|
||||||
{
|
{
|
||||||
s_Root = this;
|
s_Root = this;
|
||||||
}
|
}
|
||||||
@ -552,22 +553,25 @@ bool cRoot::FindAndDoWithPlayer(const AString & a_PlayerName, cPlayerListCallbac
|
|||||||
{
|
{
|
||||||
class cCallback : public cPlayerListCallback
|
class cCallback : public cPlayerListCallback
|
||||||
{
|
{
|
||||||
unsigned int BestRating;
|
unsigned m_BestRating;
|
||||||
unsigned int NameLength;
|
unsigned m_NameLength;
|
||||||
const AString PlayerName;
|
const AString m_PlayerName;
|
||||||
|
|
||||||
cPlayerListCallback & m_Callback;
|
cPlayerListCallback & m_Callback;
|
||||||
virtual bool Item (cPlayer * a_pPlayer)
|
virtual bool Item (cPlayer * a_pPlayer)
|
||||||
{
|
{
|
||||||
unsigned int Rating = RateCompareString (PlayerName, a_pPlayer->GetName());
|
unsigned int Rating = RateCompareString (m_PlayerName, a_pPlayer->GetName());
|
||||||
if (Rating > 0 && Rating >= BestRating)
|
if ((Rating > 0) && (Rating >= m_BestRating))
|
||||||
{
|
{
|
||||||
BestMatch = a_pPlayer;
|
m_BestMatch = a_pPlayer;
|
||||||
if( Rating > BestRating ) NumMatches = 0;
|
if (Rating > m_BestRating)
|
||||||
BestRating = Rating;
|
{
|
||||||
++NumMatches;
|
m_NumMatches = 0;
|
||||||
|
}
|
||||||
|
m_BestRating = Rating;
|
||||||
|
++m_NumMatches;
|
||||||
}
|
}
|
||||||
if (Rating == NameLength) // Perfect match
|
if (Rating == m_NameLength) // Perfect match
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -575,23 +579,23 @@ bool cRoot::FindAndDoWithPlayer(const AString & a_PlayerName, cPlayerListCallbac
|
|||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
cCallback (const AString & a_PlayerName, cPlayerListCallback & a_Callback)
|
cCallback (const AString & a_PlayerName, cPlayerListCallback & a_Callback) :
|
||||||
: m_Callback( a_Callback )
|
m_Callback(a_Callback),
|
||||||
, BestMatch( NULL )
|
m_BestRating(0),
|
||||||
, BestRating( 0 )
|
m_NameLength(a_PlayerName.length()),
|
||||||
, NumMatches( 0 )
|
m_PlayerName(a_PlayerName),
|
||||||
, NameLength( a_PlayerName.length() )
|
m_BestMatch(NULL),
|
||||||
, PlayerName( a_PlayerName )
|
m_NumMatches(0)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
cPlayer * BestMatch;
|
cPlayer * m_BestMatch;
|
||||||
unsigned int NumMatches;
|
unsigned m_NumMatches;
|
||||||
} Callback (a_PlayerName, a_Callback);
|
} Callback (a_PlayerName, a_Callback);
|
||||||
ForEachPlayer( Callback );
|
ForEachPlayer( Callback );
|
||||||
|
|
||||||
if (Callback.NumMatches == 1)
|
if (Callback.m_NumMatches == 1)
|
||||||
{
|
{
|
||||||
return a_Callback.Item (Callback.BestMatch);
|
return a_Callback.Item(Callback.m_BestMatch);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -228,12 +228,13 @@ void cRedstoneSimulator::SimulateChunk(float a_Dt, int a_ChunkX, int a_ChunkZ, c
|
|||||||
int a_Z = BaseZ + dataitr->z;
|
int a_Z = BaseZ + dataitr->z;
|
||||||
switch (BlockType)
|
switch (BlockType)
|
||||||
{
|
{
|
||||||
case E_BLOCK_BLOCK_OF_REDSTONE: HandleRedstoneBlock(a_X, dataitr->y, a_Z); break;
|
case E_BLOCK_BLOCK_OF_REDSTONE: HandleRedstoneBlock(a_X, dataitr->y, a_Z); break;
|
||||||
case E_BLOCK_LEVER: HandleRedstoneLever(a_X, dataitr->y, a_Z); break;
|
case E_BLOCK_LEVER: HandleRedstoneLever(a_X, dataitr->y, a_Z); break;
|
||||||
case E_BLOCK_TNT: HandleTNT(a_X, dataitr->y, a_Z); break;
|
case E_BLOCK_TNT: HandleTNT(a_X, dataitr->y, a_Z); break;
|
||||||
case E_BLOCK_TRAPDOOR: HandleTrapdoor(a_X, dataitr->y, a_Z); break;
|
case E_BLOCK_TRAPDOOR: HandleTrapdoor(a_X, dataitr->y, a_Z); break;
|
||||||
case E_BLOCK_REDSTONE_WIRE: HandleRedstoneWire(a_X, dataitr->y, a_Z); break;
|
case E_BLOCK_REDSTONE_WIRE: HandleRedstoneWire(a_X, dataitr->y, a_Z); break;
|
||||||
case E_BLOCK_NOTE_BLOCK: HandleNoteBlock(a_X, dataitr->y, a_Z); break;
|
case E_BLOCK_NOTE_BLOCK: HandleNoteBlock(a_X, dataitr->y, a_Z); break;
|
||||||
|
case E_BLOCK_DAYLIGHT_SENSOR: HandleDaylightSensor(a_X, dataitr->y, a_Z); break;
|
||||||
|
|
||||||
case E_BLOCK_REDSTONE_TORCH_OFF:
|
case E_BLOCK_REDSTONE_TORCH_OFF:
|
||||||
case E_BLOCK_REDSTONE_TORCH_ON:
|
case E_BLOCK_REDSTONE_TORCH_ON:
|
||||||
@ -611,7 +612,10 @@ void cRedstoneSimulator::HandleRedstoneRepeater(int a_BlockX, int a_BlockY, int
|
|||||||
{
|
{
|
||||||
if (itr->ShouldPowerOn)
|
if (itr->ShouldPowerOn)
|
||||||
{
|
{
|
||||||
m_World.SetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_REDSTONE_REPEATER_ON, a_Meta);
|
if (!IsOn)
|
||||||
|
{
|
||||||
|
m_World.SetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_REDSTONE_REPEATER_ON, a_Meta); // For performance
|
||||||
|
}
|
||||||
|
|
||||||
switch (a_Meta & 0x3) // We only want the direction (bottom) bits
|
switch (a_Meta & 0x3) // We only want the direction (bottom) bits
|
||||||
{
|
{
|
||||||
@ -647,7 +651,10 @@ void cRedstoneSimulator::HandleRedstoneRepeater(int a_BlockX, int a_BlockY, int
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_World.SetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_REDSTONE_REPEATER_OFF, a_Meta);
|
if (IsOn)
|
||||||
|
{
|
||||||
|
m_World.SetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_REDSTONE_REPEATER_OFF, a_Meta);
|
||||||
|
}
|
||||||
m_RepeatersDelayList.erase(itr); // We can remove off repeaters which don't need further updating
|
m_RepeatersDelayList.erase(itr); // We can remove off repeaters which don't need further updating
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -814,6 +821,7 @@ void cRedstoneSimulator::HandleRail(int a_BlockX, int a_BlockY, int a_BlockZ, BL
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
default: LOGD("Unhandled type of rail in %s", __FUNCTION__);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -887,6 +895,18 @@ void cRedstoneSimulator::HandleNoteBlock(int a_BlockX, int a_BlockY, int a_Block
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void cRedstoneSimulator::HandleDaylightSensor(int a_BlockX, int a_BlockY, int a_BlockZ)
|
||||||
|
{
|
||||||
|
if (m_World.GetBlockSkyLight(a_BlockX, a_BlockY + 1, a_BlockZ) > 10)
|
||||||
|
{
|
||||||
|
SetAllDirsAsPowered(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_DAYLIGHT_SENSOR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool cRedstoneSimulator::AreCoordsDirectlyPowered(int a_BlockX, int a_BlockY, int a_BlockZ)
|
bool cRedstoneSimulator::AreCoordsDirectlyPowered(int a_BlockX, int a_BlockY, int a_BlockZ)
|
||||||
{
|
{
|
||||||
for (PoweredBlocksList::const_iterator itr = m_PoweredBlocks.begin(); itr != m_PoweredBlocks.end(); ++itr) // Check powered list
|
for (PoweredBlocksList::const_iterator itr = m_PoweredBlocks.begin(); itr != m_PoweredBlocks.end(); ++itr) // Check powered list
|
||||||
@ -1298,7 +1318,7 @@ void cRedstoneSimulator::QueueRepeaterPowerChange(int a_BlockX, int a_BlockY, in
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Already in here (normal to allow repeater to continue on powering and updating blocks in front) - just update info and quit
|
// Already in here (normal to allow repeater to continue on powering and updating blocks in front) - just update info and quit
|
||||||
itr->a_DelayTicks = ((a_Meta & 0xC) >> 0x2) + 1;
|
itr->a_DelayTicks = (((a_Meta & 0xC) >> 0x2) + 1) * 2; // See below for description
|
||||||
itr->a_ElapsedTicks = 0;
|
itr->a_ElapsedTicks = 0;
|
||||||
itr->ShouldPowerOn = ShouldPowerOn;
|
itr->ShouldPowerOn = ShouldPowerOn;
|
||||||
return;
|
return;
|
||||||
@ -1308,7 +1328,12 @@ void cRedstoneSimulator::QueueRepeaterPowerChange(int a_BlockX, int a_BlockY, in
|
|||||||
// Self not in list, add self to list
|
// Self not in list, add self to list
|
||||||
sRepeatersDelayList RC;
|
sRepeatersDelayList RC;
|
||||||
RC.a_BlockPos = Vector3i(a_BlockX, a_BlockY, a_BlockZ);
|
RC.a_BlockPos = Vector3i(a_BlockX, a_BlockY, a_BlockZ);
|
||||||
RC.a_DelayTicks = ((a_Meta & 0xC) >> 0x2) + 1; // Gets the top two bits (delay time), shifts them into the lower two bits, and adds one (meta 0 = 1 tick; 1 = 2 etc.)
|
|
||||||
|
// Gets the top two bits (delay time), shifts them into the lower two bits, and adds one (meta 0 = 1 tick; 1 = 2 etc.)
|
||||||
|
// * 2 because apparently, MCS ticks are way faster than vanilla ticks, so repeater aren't noticeably delayed
|
||||||
|
RC.a_DelayTicks = (((a_Meta & 0xC) >> 0x2) + 1) * 2;
|
||||||
|
|
||||||
|
|
||||||
RC.a_ElapsedTicks = 0;
|
RC.a_ElapsedTicks = 0;
|
||||||
RC.ShouldPowerOn = ShouldPowerOn;
|
RC.ShouldPowerOn = ShouldPowerOn;
|
||||||
m_RepeatersDelayList.push_back(RC);
|
m_RepeatersDelayList.push_back(RC);
|
||||||
|
@ -115,6 +115,8 @@ private:
|
|||||||
void HandleTrapdoor(int a_BlockX, int a_BlockY, int a_BlockZ);
|
void HandleTrapdoor(int a_BlockX, int a_BlockY, int a_BlockZ);
|
||||||
/// <summary>Handles noteblocks</summary>
|
/// <summary>Handles noteblocks</summary>
|
||||||
void HandleNoteBlock(int a_BlockX, int a_BlockY, int a_BlockZ);
|
void HandleNoteBlock(int a_BlockX, int a_BlockY, int a_BlockZ);
|
||||||
|
/// <summary>Handles noteblocks</summary>
|
||||||
|
void HandleDaylightSensor(int a_BlockX, int a_BlockY, int a_BlockZ);
|
||||||
/* ===================== */
|
/* ===================== */
|
||||||
|
|
||||||
/* ====== Helper functions ====== */
|
/* ====== Helper functions ====== */
|
||||||
@ -164,13 +166,11 @@ private:
|
|||||||
case E_BLOCK_STICKY_PISTON:
|
case E_BLOCK_STICKY_PISTON:
|
||||||
case E_BLOCK_REDSTONE_REPEATER_ON:
|
case E_BLOCK_REDSTONE_REPEATER_ON:
|
||||||
case E_BLOCK_REDSTONE_REPEATER_OFF:
|
case E_BLOCK_REDSTONE_REPEATER_OFF:
|
||||||
|
case E_BLOCK_DAYLIGHT_SENSOR:
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
default:
|
default: return true;
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -208,6 +208,7 @@ private:
|
|||||||
{
|
{
|
||||||
switch (Block)
|
switch (Block)
|
||||||
{
|
{
|
||||||
|
case E_BLOCK_DAYLIGHT_SENSOR:
|
||||||
case E_BLOCK_WOODEN_BUTTON:
|
case E_BLOCK_WOODEN_BUTTON:
|
||||||
case E_BLOCK_STONE_BUTTON:
|
case E_BLOCK_STONE_BUTTON:
|
||||||
case E_BLOCK_REDSTONE_WIRE:
|
case E_BLOCK_REDSTONE_WIRE:
|
||||||
|
@ -229,16 +229,16 @@ cWorld::cWorld(const AString & a_WorldName) :
|
|||||||
m_WorldName(a_WorldName),
|
m_WorldName(a_WorldName),
|
||||||
m_IniFileName(m_WorldName + "/world.ini"),
|
m_IniFileName(m_WorldName + "/world.ini"),
|
||||||
m_StorageSchema("Default"),
|
m_StorageSchema("Default"),
|
||||||
|
m_IsSpawnExplicitlySet(false),
|
||||||
m_WorldAgeSecs(0),
|
m_WorldAgeSecs(0),
|
||||||
m_TimeOfDaySecs(0),
|
m_TimeOfDaySecs(0),
|
||||||
m_WorldAge(0),
|
m_WorldAge(0),
|
||||||
m_TimeOfDay(0),
|
m_TimeOfDay(0),
|
||||||
m_LastTimeUpdate(0),
|
m_LastTimeUpdate(0),
|
||||||
|
m_SkyDarkness(0),
|
||||||
m_Weather(eWeather_Sunny),
|
m_Weather(eWeather_Sunny),
|
||||||
m_WeatherInterval(24000), // Guaranteed 1 day of sunshine at server start :)
|
m_WeatherInterval(24000), // Guaranteed 1 day of sunshine at server start :)
|
||||||
m_TickThread(*this),
|
m_TickThread(*this)
|
||||||
m_SkyDarkness(0),
|
|
||||||
m_bSpawnExplicitlySet(false)
|
|
||||||
{
|
{
|
||||||
LOGD("cWorld::cWorld(\"%s\")", a_WorldName.c_str());
|
LOGD("cWorld::cWorld(\"%s\")", a_WorldName.c_str());
|
||||||
|
|
||||||
@ -329,7 +329,7 @@ void cWorld::SetNextBlockTick(int a_BlockX, int a_BlockY, int a_BlockZ)
|
|||||||
|
|
||||||
void cWorld::InitializeSpawn(void)
|
void cWorld::InitializeSpawn(void)
|
||||||
{
|
{
|
||||||
if (!m_bSpawnExplicitlySet) // Check if spawn position was already explicitly set or not
|
if (!m_IsSpawnExplicitlySet) // Check if spawn position was already explicitly set or not
|
||||||
{
|
{
|
||||||
GenerateRandomSpawn(); // Generate random solid-land coordinate and then write it to the world configuration
|
GenerateRandomSpawn(); // Generate random solid-land coordinate and then write it to the world configuration
|
||||||
|
|
||||||
@ -487,7 +487,7 @@ void cWorld::Start(void)
|
|||||||
|
|
||||||
// Try to find the "SpawnPosition" key and coord values in the world configuration, set the flag if found
|
// Try to find the "SpawnPosition" key and coord values in the world configuration, set the flag if found
|
||||||
int KeyNum = IniFile.FindKey("SpawnPosition");
|
int KeyNum = IniFile.FindKey("SpawnPosition");
|
||||||
m_bSpawnExplicitlySet =
|
m_IsSpawnExplicitlySet =
|
||||||
(
|
(
|
||||||
(KeyNum >= 0) &&
|
(KeyNum >= 0) &&
|
||||||
(
|
(
|
||||||
@ -497,7 +497,7 @@ void cWorld::Start(void)
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (m_bSpawnExplicitlySet)
|
if (m_IsSpawnExplicitlySet)
|
||||||
{
|
{
|
||||||
LOGD("Spawnpoint explicitly set!");
|
LOGD("Spawnpoint explicitly set!");
|
||||||
m_SpawnX = IniFile.GetValueF("SpawnPosition", "X", m_SpawnX);
|
m_SpawnX = IniFile.GetValueF("SpawnPosition", "X", m_SpawnX);
|
||||||
|
@ -647,7 +647,7 @@ private:
|
|||||||
/// This random generator is to be used only in the Tick() method, and thus only in the World-Tick-thread (MTRand is not exactly thread-safe)
|
/// This random generator is to be used only in the Tick() method, and thus only in the World-Tick-thread (MTRand is not exactly thread-safe)
|
||||||
MTRand m_TickRand;
|
MTRand m_TickRand;
|
||||||
|
|
||||||
bool m_bSpawnExplicitlySet;
|
bool m_IsSpawnExplicitlySet;
|
||||||
double m_SpawnX;
|
double m_SpawnX;
|
||||||
double m_SpawnY;
|
double m_SpawnY;
|
||||||
double m_SpawnZ;
|
double m_SpawnZ;
|
||||||
|
Loading…
Reference in New Issue
Block a user