Fixed the formatting issues in player cpp files
This commit is contained in:
parent
e6c33b0256
commit
9a6442a206
|
@ -40,8 +40,8 @@ cPlayer::cPlayer(cClientHandle* a_Client, const AString & a_PlayerName)
|
||||||
, m_IP("")
|
, m_IP("")
|
||||||
, m_LastBlockActionTime( 0 )
|
, m_LastBlockActionTime( 0 )
|
||||||
, m_LastBlockActionCnt( 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_LastGroundHeight( 0 )
|
||||||
, m_bTouchGround( false )
|
, m_bTouchGround( false )
|
||||||
|
@ -181,8 +181,8 @@ void cPlayer::Tick(float a_Dt, cChunk & a_Chunk)
|
||||||
|
|
||||||
super::Tick(a_Dt, a_Chunk);
|
super::Tick(a_Dt, a_Chunk);
|
||||||
|
|
||||||
//handle air drowning stuff
|
//handle air drowning stuff
|
||||||
HandleAir(a_Chunk);
|
HandleAir(a_Chunk);
|
||||||
|
|
||||||
if (m_bDirtyPosition)
|
if (m_bDirtyPosition)
|
||||||
{
|
{
|
||||||
|
@ -1252,7 +1252,7 @@ bool cPlayer::SaveToDisk()
|
||||||
root["rotation"] = JSON_PlayerRotation;
|
root["rotation"] = JSON_PlayerRotation;
|
||||||
root["inventory"] = JSON_Inventory;
|
root["inventory"] = JSON_Inventory;
|
||||||
root["health"] = m_Health;
|
root["health"] = m_Health;
|
||||||
root["air"] = m_AirLevel;
|
root["air"] = m_AirLevel;
|
||||||
root["food"] = m_FoodLevel;
|
root["food"] = m_FoodLevel;
|
||||||
root["foodSaturation"] = m_FoodSaturationLevel;
|
root["foodSaturation"] = m_FoodSaturationLevel;
|
||||||
root["foodTickTimer"] = m_FoodTickTimer;
|
root["foodTickTimer"] = m_FoodTickTimer;
|
||||||
|
@ -1322,10 +1322,9 @@ void cPlayer::UseEquippedItem()
|
||||||
|
|
||||||
void cPlayer::HandleAir(cChunk & a_Chunk)
|
void cPlayer::HandleAir(cChunk & a_Chunk)
|
||||||
{
|
{
|
||||||
//Ref.: http://www.minecraftwiki.net/wiki/Chunk_format
|
//Ref.: http://www.minecraftwiki.net/wiki/Chunk_format
|
||||||
|
//see if the player is /submerged/ water (block above is water)
|
||||||
//see if the player is /submerged/ water (block above is water)
|
// Get the type of block the player's standing in:
|
||||||
// Get the type of block the player's standing in:
|
|
||||||
BLOCKTYPE BlockIn;
|
BLOCKTYPE BlockIn;
|
||||||
int RelX = (int)floor(m_LastPosX) - a_Chunk.GetPosX() * cChunkDef::Width;
|
int RelX = (int)floor(m_LastPosX) - a_Chunk.GetPosX() * cChunkDef::Width;
|
||||||
int RelY = (int)floor(m_LastPosY + 1.1);
|
int RelY = (int)floor(m_LastPosY + 1.1);
|
||||||
|
@ -1333,29 +1332,29 @@ void cPlayer::HandleAir(cChunk & a_Chunk)
|
||||||
// Use Unbounded, because we're being called *after* processing super::Tick(), which could have changed our chunk
|
// Use Unbounded, because we're being called *after* processing super::Tick(), which could have changed our chunk
|
||||||
VERIFY(a_Chunk.UnboundedRelGetBlockType(RelX, RelY, RelZ, BlockIn));
|
VERIFY(a_Chunk.UnboundedRelGetBlockType(RelX, RelY, RelZ, BlockIn));
|
||||||
|
|
||||||
if (IsBlockWater(BlockIn))
|
if (IsBlockWater(BlockIn))
|
||||||
{
|
{
|
||||||
//either reduce air level or damage player
|
//either reduce air level or damage player
|
||||||
if(m_AirLevel < 1)
|
if(m_AirLevel < 1)
|
||||||
{
|
{
|
||||||
if(m_AirTickTimer < 1)
|
if(m_AirTickTimer < 1)
|
||||||
{
|
{
|
||||||
//damage player
|
//damage player
|
||||||
TakeDamage(dtDrowning, NULL, 1, 1, 0);
|
TakeDamage(dtDrowning, NULL, 1, 1, 0);
|
||||||
//reset timer
|
//reset timer
|
||||||
m_AirTickTimer = DROWNING_TICKS;
|
m_AirTickTimer = DROWNING_TICKS;
|
||||||
}else{
|
}else{
|
||||||
m_AirTickTimer -= 1;
|
m_AirTickTimer -= 1;
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
//reduce air supply
|
//reduce air supply
|
||||||
m_AirLevel -= 1;
|
m_AirLevel -= 1;
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
//set the air back to maximum
|
//set the air back to maximum
|
||||||
m_AirLevel = MAX_AIR_LEVEL;
|
m_AirLevel = MAX_AIR_LEVEL;
|
||||||
m_AirTickTimer = DROWNING_TICKS;
|
m_AirTickTimer = DROWNING_TICKS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -29,8 +29,8 @@ public:
|
||||||
MAX_HEALTH = 20,
|
MAX_HEALTH = 20,
|
||||||
MAX_FOOD_LEVEL = 20,
|
MAX_FOOD_LEVEL = 20,
|
||||||
EATING_TICKS = 30, ///< Number of ticks it takes to eat an item
|
EATING_TICKS = 30, ///< Number of ticks it takes to eat an item
|
||||||
MAX_AIR_LEVEL = 300,
|
MAX_AIR_LEVEL = 300,
|
||||||
DROWNING_TICKS = 10, //number of ticks per heart of damage
|
DROWNING_TICKS = 10, //number of ticks per heart of damage
|
||||||
} ;
|
} ;
|
||||||
// tolua_end
|
// tolua_end
|
||||||
|
|
||||||
|
@ -271,10 +271,10 @@ protected:
|
||||||
std::string m_PlayerName;
|
std::string m_PlayerName;
|
||||||
std::string m_LoadedWorldName;
|
std::string m_LoadedWorldName;
|
||||||
|
|
||||||
//Player's air level (for swimming)
|
//Player's air level (for swimming)
|
||||||
int m_AirLevel;
|
int m_AirLevel;
|
||||||
//used to time ticks between damage taken via drowning/suffocation
|
//used to time ticks between damage taken via drowning/suffocation
|
||||||
int m_AirTickTimer;
|
int m_AirTickTimer;
|
||||||
|
|
||||||
bool m_bVisible;
|
bool m_bVisible;
|
||||||
|
|
||||||
|
@ -346,8 +346,8 @@ protected:
|
||||||
/// Called in each tick to handle food-related processing
|
/// Called in each tick to handle food-related processing
|
||||||
void HandleFood(void);
|
void HandleFood(void);
|
||||||
|
|
||||||
/// Called in each tick to handle air-related processing i.e. drowning
|
/// Called in each tick to handle air-related processing i.e. drowning
|
||||||
void HandleAir(cChunk & a_Chunk);
|
void HandleAir(cChunk & a_Chunk);
|
||||||
|
|
||||||
/// Adds food exhaustion based on the difference between Pos and LastPos, sprinting status and swimming (in water block)
|
/// Adds food exhaustion based on the difference between Pos and LastPos, sprinting status and swimming (in water block)
|
||||||
void ApplyFoodExhaustionFromMovement(cChunk & a_Chunk);
|
void ApplyFoodExhaustionFromMovement(cChunk & a_Chunk);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user