1
0

Style: Normalized spaces after if, for and while.

This commit is contained in:
madmaxoft 2014-07-20 23:10:31 +02:00
parent 8593d48579
commit 6be79575fd
28 changed files with 137 additions and 135 deletions

View File

@ -656,12 +656,12 @@ template<
static int tolua_ForEach(lua_State * tolua_S)
{
int NumArgs = lua_gettop(tolua_S) - 1; /* This includes 'self' */
if( NumArgs != 1 && NumArgs != 2)
if ((NumArgs != 1) && (NumArgs != 2))
{
return lua_do_error(tolua_S, "Error in function call '#funcname#': Requires 1 or 2 arguments, got %i", NumArgs);
}
Ty1 * self = (Ty1 *) tolua_tousertype(tolua_S, 1, NULL);
Ty1 * self = (Ty1 *)tolua_tousertype(tolua_S, 1, NULL);
if (self == NULL)
{
return lua_do_error(tolua_S, "Error in function call '#funcname#': Not called on an object instance");
@ -1360,7 +1360,7 @@ static int tolua_cPluginManager_AddHook(lua_State * tolua_S)
static int tolua_cPluginManager_ForEachCommand(lua_State * tolua_S)
{
int NumArgs = lua_gettop(tolua_S) - 1; /* This includes 'self' */
if( NumArgs != 1)
if (NumArgs != 1)
{
LOGWARN("Error in function call 'ForEachCommand': Requires 1 argument, got %i", NumArgs);
return 0;
@ -1437,7 +1437,7 @@ static int tolua_cPluginManager_ForEachCommand(lua_State * tolua_S)
static int tolua_cPluginManager_ForEachConsoleCommand(lua_State * tolua_S)
{
int NumArgs = lua_gettop(tolua_S) - 1; /* This includes 'self' */
if( NumArgs != 1)
if (NumArgs != 1)
{
LOGWARN("Error in function call 'ForEachConsoleCommand': Requires 1 argument, got %i", NumArgs);
return 0;
@ -1938,16 +1938,16 @@ static int tolua_cPluginLua_AddWebTab(lua_State * tolua_S)
return tolua_do_error(tolua_S, "#ferror calling function '#funcname#'", &tolua_err);
}
if( Reference != LUA_REFNIL )
if (Reference != LUA_REFNIL)
{
if( !self->AddWebTab( Title.c_str(), tolua_S, Reference ) )
if (!self->AddWebTab(Title.c_str(), tolua_S, Reference))
{
luaL_unref( tolua_S, LUA_REGISTRYINDEX, Reference );
luaL_unref(tolua_S, LUA_REGISTRYINDEX, Reference);
}
}
else
{
LOGERROR("ERROR: cPluginLua:AddWebTab invalid function reference in 2nd argument (Title: \"%s\")", Title.c_str() );
LOGWARNING("cPluginLua:AddWebTab: invalid function reference in 2nd argument (Title: \"%s\")", Title.c_str());
}
return 0;
@ -2016,7 +2016,7 @@ static int tolua_push_StringStringMap(lua_State* tolua_S, std::map< std::string,
lua_newtable(tolua_S);
int top = lua_gettop(tolua_S);
for( std::map< std::string, std::string >::iterator it = a_StringStringMap.begin(); it != a_StringStringMap.end(); ++it )
for (std::map<std::string, std::string>::iterator it = a_StringStringMap.begin(); it != a_StringStringMap.end(); ++it)
{
const char* key = it->first.c_str();
const char* value = it->second.c_str();
@ -2060,7 +2060,7 @@ static int tolua_get_HTTPRequest_FormData(lua_State* tolua_S)
lua_newtable(tolua_S);
int top = lua_gettop(tolua_S);
for( std::map< std::string, HTTPFormData >::iterator it = FormData.begin(); it != FormData.end(); ++it )
for (std::map<std::string, HTTPFormData>::iterator it = FormData.begin(); it != FormData.end(); ++it)
{
lua_pushstring(tolua_S, it->first.c_str() );
tolua_pushusertype(tolua_S, &(it->second), "HTTPFormData" );
@ -2109,7 +2109,7 @@ static int tolua_cWebPlugin_GetTabNames(lua_State * tolua_S)
lua_newtable(tolua_S);
int index = 1;
cWebPlugin::TabNameList::const_iterator iter = TabNames.begin();
while(iter != TabNames.end())
while (iter != TabNames.end())
{
const AString & FancyName = iter->first;
const AString & WebName = iter->second;

View File

@ -1434,7 +1434,7 @@ cPluginManager::CommandResult cPluginManager::HandleCommand(cPlayer * a_Player,
cPlugin * cPluginManager::GetPlugin( const AString & a_Plugin ) const
{
for( PluginMap::const_iterator itr = m_Plugins.begin(); itr != m_Plugins.end(); ++itr )
for (PluginMap::const_iterator itr = m_Plugins.begin(); itr != m_Plugins.end(); ++itr)
{
if (itr->second == NULL ) continue;
if (itr->second->GetName().compare(a_Plugin) == 0)

View File

@ -45,7 +45,7 @@ cWebPlugin::~cWebPlugin()
std::list<std::pair<AString, AString> > cWebPlugin::GetTabNames(void)
{
std::list< std::pair< AString, AString > > NameList;
for( TabList::iterator itr = GetTabs().begin(); itr != GetTabs().end(); ++itr )
for (TabList::iterator itr = GetTabs().begin(); itr != GetTabs().end(); ++itr )
{
std::pair< AString, AString > StringPair;
StringPair.first = (*itr)->Title;
@ -69,7 +69,7 @@ std::pair< AString, AString > cWebPlugin::GetTabNameForRequest(const HTTPRequest
sWebPluginTab * Tab = NULL;
if (Split.size() > 2) // If we got the tab name, show that page
{
for( TabList::iterator itr = GetTabs().begin(); itr != GetTabs().end(); ++itr )
for (TabList::iterator itr = GetTabs().begin(); itr != GetTabs().end(); ++itr )
{
if ((*itr)->SafeTitle.compare(Split[2]) == 0) // This is the one!
{
@ -80,7 +80,7 @@ std::pair< AString, AString > cWebPlugin::GetTabNameForRequest(const HTTPRequest
}
else // Otherwise show the first tab
{
if( GetTabs().size() > 0 )
if (GetTabs().size() > 0 )
Tab = *GetTabs().begin();
}
@ -100,10 +100,10 @@ std::pair< AString, AString > cWebPlugin::GetTabNameForRequest(const HTTPRequest
AString cWebPlugin::SafeString(const AString & a_String)
{
AString RetVal;
for( unsigned int i = 0; i < a_String.size(); ++i )
for (unsigned int i = 0; i < a_String.size(); ++i )
{
char c = a_String[i];
if( c == ' ' )
if (c == ' ' )
{
c = '_';
}

View File

@ -99,7 +99,7 @@ public:
static bool CanBePlacedOn(BLOCKTYPE a_BlockType, eBlockFace a_BlockFace)
{
if ( !cBlockInfo::FullyOccupiesVoxel(a_BlockType) )
if (!cBlockInfo::FullyOccupiesVoxel(a_BlockType) )
{
return (a_BlockFace == BLOCK_FACE_TOP); // Allow placement only when torch upright (for glass, etc.); exceptions won't even be sent by client, no need to handle
}
@ -119,7 +119,8 @@ public:
AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, Face, true);
BLOCKTYPE BlockInQuestion = a_ChunkInterface.GetBlock(a_BlockX, a_BlockY, a_BlockZ);
if ( // If on a block that can only hold a torch if torch is standing on it, return that face
// If on a block that can only hold a torch if torch is standing on it, return that face
if (
((BlockInQuestion == E_BLOCK_GLASS) ||
(BlockInQuestion == E_BLOCK_FENCE) ||
(BlockInQuestion == E_BLOCK_NETHER_BRICK_FENCE) ||
@ -167,7 +168,7 @@ public:
// No need to check for upright orientation, it was done when the torch was placed
return true;
}
else if ( !cBlockInfo::FullyOccupiesVoxel(BlockInQuestion) )
else if (!cBlockInfo::FullyOccupiesVoxel(BlockInQuestion) )
{
return false;
}

View File

@ -1530,11 +1530,12 @@ void cChunk::FastSetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockT
m_ChunkData.SetBlock(a_RelX, a_RelY, a_RelZ, a_BlockType);
if ( // Queue block to be sent only if ...
// Queue block to be sent only if ...
if (
a_SendToClients && // ... we are told to do so AND ...
(
(OldBlockMeta != a_BlockMeta) || // ... the meta value is different OR ...
!( // ... the old and new blocktypes AREN'T liquids (because client doesn't need to distinguish betwixt them); see below for specifics:
!( // ... the old and new blocktypes AREN'T liquids (because client doesn't need to distinguish betwixt them):
((OldBlockType == E_BLOCK_STATIONARY_WATER) && (a_BlockType == E_BLOCK_WATER)) || // Replacing stationary water with water
((OldBlockType == E_BLOCK_WATER) && (a_BlockType == E_BLOCK_STATIONARY_WATER)) || // Replacing water with stationary water
((OldBlockType == E_BLOCK_STATIONARY_LAVA) && (a_BlockType == E_BLOCK_LAVA)) || // Replacing stationary water with water

View File

@ -582,7 +582,7 @@ cCraftingRecipes::cRecipe * cCraftingRecipes::FindRecipe(const cItem * a_Craftin
// Get the real bounds of the crafting grid:
int GridLeft = MAX_GRID_WIDTH, GridTop = MAX_GRID_HEIGHT;
int GridRight = 0, GridBottom = 0;
for (int y = 0; y < a_GridHeight; y++ ) for(int x = 0; x < a_GridWidth; x++)
for (int y = 0; y < a_GridHeight; y++ ) for (int x = 0; x < a_GridWidth; x++)
{
if (!a_CraftingGrid[x + y * a_GridWidth].IsEmpty())
{

View File

@ -717,7 +717,7 @@ namespace ItemCategory
inline bool BlockRequiresSpecialTool(BLOCKTYPE a_BlockType)
{
if(!IsValidBlock(a_BlockType)) return false;
if (!IsValidBlock(a_BlockType)) return false;
return cBlockInfo::RequiresSpecialTool(a_BlockType);
}

View File

@ -286,13 +286,13 @@ void cPlayer::Tick(float a_Dt, cChunk & a_Chunk)
short cPlayer::CalcLevelFromXp(short a_XpTotal)
{
// level 0 to 15
if(a_XpTotal <= XP_TO_LEVEL15)
if (a_XpTotal <= XP_TO_LEVEL15)
{
return a_XpTotal / XP_PER_LEVEL_TO15;
}
// level 30+
if(a_XpTotal > XP_TO_LEVEL30)
if (a_XpTotal > XP_TO_LEVEL30)
{
return (short) (151.5 + sqrt( 22952.25 - (14 * (2220 - a_XpTotal)))) / 7;
}
@ -308,13 +308,13 @@ short cPlayer::CalcLevelFromXp(short a_XpTotal)
short cPlayer::XpForLevel(short a_Level)
{
// level 0 to 15
if(a_Level <= 15)
if (a_Level <= 15)
{
return a_Level * XP_PER_LEVEL_TO15;
}
// level 30+
if(a_Level >= 31)
if (a_Level >= 31)
{
return (short) ( (3.5 * a_Level * a_Level) - (151.5 * a_Level) + 2220 );
}
@ -351,7 +351,7 @@ float cPlayer::GetXpPercentage()
bool cPlayer::SetCurrentExperience(short int a_CurrentXp)
{
if(!(a_CurrentXp >= 0) || (a_CurrentXp > (SHRT_MAX - m_LifetimeTotalXp)))
if (!(a_CurrentXp >= 0) || (a_CurrentXp > (SHRT_MAX - m_LifetimeTotalXp)))
{
LOGWARNING("Tried to update experiece with an invalid Xp value: %d", a_CurrentXp);
return false; // oops, they gave us a dodgey number
@ -1370,9 +1370,9 @@ void cPlayer::AddToGroup( const AString & a_GroupName )
void cPlayer::RemoveFromGroup( const AString & a_GroupName )
{
bool bRemoved = false;
for( GroupList::iterator itr = m_Groups.begin(); itr != m_Groups.end(); ++itr )
for (GroupList::iterator itr = m_Groups.begin(); itr != m_Groups.end(); ++itr )
{
if( (*itr)->GetName().compare(a_GroupName ) == 0 )
if ((*itr)->GetName().compare(a_GroupName ) == 0 )
{
m_Groups.erase( itr );
bRemoved = true;
@ -1380,7 +1380,7 @@ void cPlayer::RemoveFromGroup( const AString & a_GroupName )
}
}
if( bRemoved )
if (bRemoved )
{
LOGD("Removed %s from group %s", GetName().c_str(), a_GroupName.c_str() );
ResolveGroups();
@ -1407,24 +1407,24 @@ bool cPlayer::HasPermission(const AString & a_Permission)
AStringVector Split = StringSplit( a_Permission, "." );
PermissionMap Possibilities = m_ResolvedPermissions;
// Now search the namespaces
while( Possibilities.begin() != Possibilities.end() )
while (Possibilities.begin() != Possibilities.end() )
{
PermissionMap::iterator itr = Possibilities.begin();
if( itr->second )
if (itr->second )
{
AStringVector OtherSplit = StringSplit( itr->first, "." );
if( OtherSplit.size() <= Split.size() )
if (OtherSplit.size() <= Split.size() )
{
unsigned int i;
for( i = 0; i < OtherSplit.size(); ++i )
for (i = 0; i < OtherSplit.size(); ++i )
{
if( OtherSplit[i].compare( Split[i] ) != 0 )
if (OtherSplit[i].compare( Split[i] ) != 0 )
{
if( OtherSplit[i].compare("*") == 0 ) return true; // WildCard man!! WildCard!
if (OtherSplit[i].compare("*") == 0 ) return true; // WildCard man!! WildCard!
break;
}
}
if( i == Split.size() ) return true;
if (i == Split.size() ) return true;
}
}
Possibilities.erase( itr );
@ -1440,9 +1440,9 @@ bool cPlayer::HasPermission(const AString & a_Permission)
bool cPlayer::IsInGroup( const AString & a_Group )
{
for( GroupList::iterator itr = m_ResolvedGroups.begin(); itr != m_ResolvedGroups.end(); ++itr )
for (GroupList::iterator itr = m_ResolvedGroups.begin(); itr != m_ResolvedGroups.end(); ++itr )
{
if( a_Group.compare( (*itr)->GetName().c_str() ) == 0 )
if (a_Group.compare( (*itr)->GetName().c_str() ) == 0 )
return true;
}
return false;
@ -1457,15 +1457,15 @@ void cPlayer::ResolvePermissions()
m_ResolvedPermissions.clear(); // Start with an empty map
// Copy all player specific permissions into the resolved permissions map
for( PermissionMap::iterator itr = m_Permissions.begin(); itr != m_Permissions.end(); ++itr )
for (PermissionMap::iterator itr = m_Permissions.begin(); itr != m_Permissions.end(); ++itr )
{
m_ResolvedPermissions[ itr->first ] = itr->second;
}
for( GroupList::iterator GroupItr = m_ResolvedGroups.begin(); GroupItr != m_ResolvedGroups.end(); ++GroupItr )
for (GroupList::iterator GroupItr = m_ResolvedGroups.begin(); GroupItr != m_ResolvedGroups.end(); ++GroupItr )
{
const cGroup::PermissionMap & Permissions = (*GroupItr)->GetPermissions();
for( cGroup::PermissionMap::const_iterator itr = Permissions.begin(); itr != Permissions.end(); ++itr )
for (cGroup::PermissionMap::const_iterator itr = Permissions.begin(); itr != Permissions.end(); ++itr )
{
m_ResolvedPermissions[ itr->first ] = itr->second;
}
@ -1484,14 +1484,14 @@ void cPlayer::ResolveGroups()
// Get a complete resolved list of all groups the player is in
std::map< cGroup*, bool > AllGroups; // Use a map, because it's faster than iterating through a list to find duplicates
GroupList ToIterate;
for( GroupList::iterator GroupItr = m_Groups.begin(); GroupItr != m_Groups.end(); ++GroupItr )
for (GroupList::iterator GroupItr = m_Groups.begin(); GroupItr != m_Groups.end(); ++GroupItr )
{
ToIterate.push_back( *GroupItr );
}
while( ToIterate.begin() != ToIterate.end() )
while (ToIterate.begin() != ToIterate.end() )
{
cGroup* CurrentGroup = *ToIterate.begin();
if( AllGroups.find( CurrentGroup ) != AllGroups.end() )
if (AllGroups.find( CurrentGroup ) != AllGroups.end() )
{
LOGWARNING("ERROR: Player \"%s\" is in the group multiple times (\"%s\"). Please fix your settings in users.ini!",
GetName().c_str(), CurrentGroup->GetName().c_str()
@ -1502,9 +1502,9 @@ void cPlayer::ResolveGroups()
AllGroups[ CurrentGroup ] = true;
m_ResolvedGroups.push_back( CurrentGroup ); // Add group to resolved list
const cGroup::GroupList & Inherits = CurrentGroup->GetInherits();
for( cGroup::GroupList::const_iterator itr = Inherits.begin(); itr != Inherits.end(); ++itr )
for (cGroup::GroupList::const_iterator itr = Inherits.begin(); itr != Inherits.end(); ++itr )
{
if( AllGroups.find( *itr ) != AllGroups.end() )
if (AllGroups.find( *itr ) != AllGroups.end() )
{
LOGERROR("ERROR: Player %s is in the same group multiple times due to inheritance (%s). FIX IT!", GetName().c_str(), (*itr)->GetName().c_str() );
continue;
@ -1522,12 +1522,12 @@ void cPlayer::ResolveGroups()
AString cPlayer::GetColor(void) const
{
if ( m_Color != '-' )
if (m_Color != '-' )
{
return cChatColor::Delimiter + m_Color;
}
if ( m_Groups.size() < 1 )
if (m_Groups.size() < 1 )
{
return cChatColor::White;
}
@ -1914,7 +1914,7 @@ cPlayer::StringList cPlayer::GetResolvedPermissions()
StringList Permissions;
const PermissionMap& ResolvedPermissions = m_ResolvedPermissions;
for( PermissionMap::const_iterator itr = ResolvedPermissions.begin(); itr != ResolvedPermissions.end(); ++itr )
for (PermissionMap::const_iterator itr = ResolvedPermissions.begin(); itr != ResolvedPermissions.end(); ++itr )
{
if (itr->second)
{

View File

@ -309,7 +309,7 @@ void inline LOGERROR(const char* a_Format, ...)
}
#endif
#define ASSERT(x) do { if (!(x)) { throw cAssertFailure();} } while (0)
#define testassert(x) do { if(!(x)) { REPORT_ERROR("Test failure: %s, file %s, line %d\n", #x, __FILE__, __LINE__); exit(1); } } while (0)
#define testassert(x) do { if (!(x)) { REPORT_ERROR("Test failure: %s, file %s, line %d\n", #x, __FILE__, __LINE__); exit(1); } } while (0)
#define CheckAsserts(x) do { try {x} catch (cAssertFailure) { break; } REPORT_ERROR("Test failure: assert didn't fire for %s, file %s, line %d\n", #x, __FILE__, __LINE__); exit(1); } while (0)
#else

View File

@ -27,7 +27,7 @@ struct cGroupManager::sGroupManagerState
cGroupManager::~cGroupManager()
{
for( GroupMap::iterator itr = m_pState->Groups.begin(); itr != m_pState->Groups.end(); ++itr )
for (GroupMap::iterator itr = m_pState->Groups.begin(); itr != m_pState->Groups.end(); ++itr )
{
delete itr->second;
itr->second = NULL;
@ -211,7 +211,7 @@ bool cGroupManager::ExistsGroup( const AString & a_Name )
cGroup* cGroupManager::GetGroup( const AString & a_Name )
{
GroupMap::iterator itr = m_pState->Groups.find( a_Name );
if( itr != m_pState->Groups.end() )
if (itr != m_pState->Groups.end() )
{
return itr->second;
}

View File

@ -500,15 +500,15 @@ int cInventory::ArmorSlotNumToEntityEquipmentID(short a_ArmorSlotNum)
bool cInventory::AddToBar( cItem & a_Item, const int a_Offset, const int a_Size, bool* a_bChangedSlots, int a_Mode /* = 0 */ )
{
// Fill already present stacks
if( a_Mode < 2 )
if (a_Mode < 2 )
{
int MaxStackSize = cItemHandler::GetItemHandler(a_Item.m_ItemType)->GetMaxStackSize();
for(int i = 0; i < a_Size; i++)
for (int i = 0; i < a_Size; i++)
{
if( m_Slots[i + a_Offset].m_ItemType == a_Item.m_ItemType && m_Slots[i + a_Offset].m_ItemCount < MaxStackSize && m_Slots[i + a_Offset].m_ItemDamage == a_Item.m_ItemDamage )
if (m_Slots[i + a_Offset].m_ItemType == a_Item.m_ItemType && m_Slots[i + a_Offset].m_ItemCount < MaxStackSize && m_Slots[i + a_Offset].m_ItemDamage == a_Item.m_ItemDamage )
{
int NumFree = MaxStackSize - m_Slots[i + a_Offset].m_ItemCount;
if( NumFree >= a_Item.m_ItemCount )
if (NumFree >= a_Item.m_ItemCount )
{
// printf("1. Adding %i items ( free: %i )\n", a_Item.m_ItemCount, NumFree );
@ -528,12 +528,12 @@ bool cInventory::AddToBar( cItem & a_Item, const int a_Offset, const int a_Size,
}
}
if( a_Mode > 0 )
if (a_Mode > 0 )
{
// If we got more left, find first empty slot
for(int i = 0; i < a_Size && a_Item.m_ItemCount > 0; i++)
for (int i = 0; i < a_Size && a_Item.m_ItemCount > 0; i++)
{
if( m_Slots[i + a_Offset].m_ItemType == -1 )
if (m_Slots[i + a_Offset].m_ItemType == -1 )
{
m_Slots[i + a_Offset] = a_Item;
a_Item.m_ItemCount = 0;

View File

@ -263,7 +263,7 @@ cItemHandler *cItemHandler::CreateItemHandler(int a_ItemType)
void cItemHandler::Deinit()
{
for(int i = 0; i < 2267; i++)
for (int i = 0; i < 2267; i++)
{
delete m_ItemHandler[i];
m_ItemHandler[i] = NULL;

View File

@ -59,7 +59,7 @@ cLog * cLog::GetInstance()
void cLog::CloseLog()
{
if( m_File )
if (m_File )
fclose (m_File);
m_File = 0;
}
@ -70,7 +70,7 @@ void cLog::CloseLog()
void cLog::OpenLog( const char* a_FileName )
{
if(m_File) fclose (m_File);
if (m_File) fclose (m_File);
#ifdef _MSC_VER
fopen_s( &m_File, a_FileName, "a+" );
#else
@ -85,11 +85,11 @@ void cLog::OpenLog( const char* a_FileName )
void cLog::ClearLog()
{
#ifdef _MSC_VER
if( fopen_s( &m_File, "log.txt", "w" ) == 0)
if (fopen_s( &m_File, "log.txt", "w" ) == 0)
fclose (m_File);
#else
m_File = fopen("log.txt", "w" );
if( m_File )
if (m_File )
fclose (m_File);
#endif
m_File = NULL;

View File

@ -34,7 +34,7 @@ void cMobProximityCounter::CollectMob(cEntity& a_Monster, cChunk& a_Chunk, doubl
void cMobProximityCounter::convertMaps()
{
for(tMonsterToDistance::const_iterator itr = m_MonsterToDistance.begin(); itr != m_MonsterToDistance.end(); ++itr)
for (tMonsterToDistance::const_iterator itr = m_MonsterToDistance.begin(); itr != m_MonsterToDistance.end(); ++itr)
{
m_DistanceToMonster.insert(tDistanceToMonster::value_type(itr->second.m_Distance, sMonsterAndChunk(*itr->first, *itr->second.m_Chunk)));
}
@ -55,7 +55,7 @@ cMobProximityCounter::sIterablePair cMobProximityCounter::getMobWithinThosesDist
convertMaps();
}
for(tDistanceToMonster::const_iterator itr = m_DistanceToMonster.begin(); itr != m_DistanceToMonster.end(); ++itr)
for (tDistanceToMonster::const_iterator itr = m_DistanceToMonster.begin(); itr != m_DistanceToMonster.end(); ++itr)
{
if (toReturn.m_Begin == m_DistanceToMonster.end())
{

View File

@ -208,7 +208,7 @@ bool cMobSpawner::CanSpawnHere(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_R
bool HasFloor = false;
for (int x = 0; x < 2; ++x)
{
for(int z = 0; z < 2; ++z)
for (int z = 0; z < 2; ++z)
{
CanSpawn = a_Chunk->UnboundedRelGetBlockType(a_RelX + x, a_RelY, a_RelZ + z, TargetBlock);
CanSpawn = CanSpawn && (TargetBlock == E_BLOCK_AIR);

View File

@ -281,7 +281,7 @@ void cMonster::Tick(float a_Dt, cChunk & a_Chunk)
}
Vector3f Distance = m_Destination - GetPosition();
if(!ReachedDestination() && !ReachedFinalDestination()) // If we haven't reached any sort of destination, move
if (!ReachedDestination() && !ReachedFinalDestination()) // If we haven't reached any sort of destination, move
{
Distance.y = 0;
Distance.Normalize();

View File

@ -25,7 +25,7 @@ AString GetOSErrorString( int a_ErrNo )
#if !defined(__APPLE__) && ( _GNU_SOURCE ) && !defined(ANDROID_NDK) // GNU version of strerror_r()
char * res = strerror_r( errno, buffer, ARRAYCOUNT(buffer) );
if( res != NULL )
if (res != NULL )
{
Printf(Out, "%d: %s", a_ErrNo, res);
return Out;
@ -34,7 +34,7 @@ AString GetOSErrorString( int a_ErrNo )
#else // XSI version of strerror_r():
int res = strerror_r( errno, buffer, ARRAYCOUNT(buffer) );
if( res == 0 )
if (res == 0 )
{
Printf(Out, "%d: %s", a_ErrNo, buffer);
return Out;

View File

@ -22,13 +22,13 @@ cSemaphore::cSemaphore( unsigned int a_MaxCount, unsigned int a_InitialCount /*
AString Name;
Printf(Name, "cSemaphore%p", this );
m_Handle = sem_open(Name.c_str(), O_CREAT, 777, a_InitialCount);
if( m_Handle == SEM_FAILED )
if (m_Handle == SEM_FAILED )
{
LOG("ERROR: Could not create Semaphore. (%i)", errno );
}
else
{
if( sem_unlink(Name.c_str()) != 0 )
if (sem_unlink(Name.c_str()) != 0 )
{
LOG("ERROR: Could not unlink cSemaphore. (%i)", errno);
}
@ -53,9 +53,9 @@ cSemaphore::~cSemaphore()
#ifdef _WIN32
CloseHandle( m_Handle );
#else
if( m_bNamed )
if (m_bNamed )
{
if( sem_close( (sem_t*)m_Handle ) != 0 )
if (sem_close( (sem_t*)m_Handle ) != 0 )
{
LOG("ERROR: Could not close cSemaphore. (%i)", errno);
}
@ -77,7 +77,7 @@ cSemaphore::~cSemaphore()
void cSemaphore::Wait()
{
#ifndef _WIN32
if( sem_wait( (sem_t*)m_Handle ) != 0)
if (sem_wait( (sem_t*)m_Handle ) != 0)
{
LOG("ERROR: Could not wait for cSemaphore. (%i)", errno);
}
@ -93,7 +93,7 @@ void cSemaphore::Wait()
void cSemaphore::Signal()
{
#ifndef _WIN32
if( sem_post( (sem_t*)m_Handle ) != 0 )
if (sem_post( (sem_t*)m_Handle ) != 0 )
{
LOG("ERROR: Could not signal cSemaphore. (%i)", errno);
}

View File

@ -53,7 +53,7 @@ cThread::cThread( ThreadFunc a_ThreadFunction, void* a_Param, const char* a_Thre
, m_Event( new cEvent() )
, m_StopEvent( 0 )
{
if( a_ThreadName )
if (a_ThreadName )
{
m_ThreadName.assign(a_ThreadName);
}
@ -68,7 +68,7 @@ cThread::~cThread()
delete m_Event;
m_Event = NULL;
if( m_StopEvent )
if (m_StopEvent )
{
m_StopEvent->Wait();
delete m_StopEvent;
@ -82,12 +82,12 @@ cThread::~cThread()
void cThread::Start( bool a_bWaitOnDelete /* = true */ )
{
if( a_bWaitOnDelete )
if (a_bWaitOnDelete )
m_StopEvent = new cEvent();
#ifndef _WIN32
pthread_t SndThread;
if( pthread_create( &SndThread, NULL, MyThread, this) )
if (pthread_create( &SndThread, NULL, MyThread, this) )
LOGERROR("ERROR: Could not create thread!");
#else
DWORD ThreadID = 0;
@ -132,6 +132,6 @@ void *cThread::MyThread( void *a_Param )
ThreadFunction( ThreadParam );
if( StopEvent ) StopEvent->Set();
if (StopEvent ) StopEvent->Set();
return 0;
}

View File

@ -1587,7 +1587,7 @@ void cProtocol172::AddReceivedData(const char * a_Data, size_t a_Size)
ASSERT(!"Read wrong number of bytes!");
m_Client->PacketError(PacketType);
}
} // for(ever)
} // for (ever)
// Log any leftover bytes into the logfile:
if (g_ShouldLogCommIn && (m_ReceivedData.GetReadableSpace() > 0))

View File

@ -359,7 +359,7 @@ void cRoot::StopWorlds(void)
void cRoot::UnloadWorlds(void)
{
m_pDefaultWorld = NULL;
for( WorldMap::iterator itr = m_WorldsByName.begin(); itr != m_WorldsByName.end(); ++itr )
for (WorldMap::iterator itr = m_WorldsByName.begin(); itr != m_WorldsByName.end(); ++itr )
{
delete itr->second;
}
@ -382,7 +382,7 @@ cWorld* cRoot::GetDefaultWorld()
cWorld* cRoot::GetWorld( const AString & a_WorldName )
{
WorldMap::iterator itr = m_WorldsByName.find( a_WorldName );
if( itr != m_WorldsByName.end() )
if (itr != m_WorldsByName.end() )
return itr->second;
return 0;
}
@ -509,7 +509,7 @@ void cRoot::AuthenticateUser(int a_ClientID, const AString & a_Name, const AStri
int cRoot::GetTotalChunkCount(void)
{
int res = 0;
for ( WorldMap::iterator itr = m_WorldsByName.begin(); itr != m_WorldsByName.end(); ++itr )
for (WorldMap::iterator itr = m_WorldsByName.begin(); itr != m_WorldsByName.end(); ++itr )
{
res += itr->second->GetNumChunks();
}

View File

@ -631,7 +631,7 @@ void cServer::Shutdown(void)
cRoot::Get()->SaveAllChunks();
cCSLock Lock(m_CSClients);
for( ClientList::iterator itr = m_Clients.begin(); itr != m_Clients.end(); ++itr )
for (ClientList::iterator itr = m_Clients.begin(); itr != m_Clients.end(); ++itr )
{
(*itr)->Destroy();
delete *itr;

View File

@ -140,7 +140,7 @@ void cFireSimulator::SimulateChunk(float a_Dt, int a_ChunkX, int a_ChunkZ, cChun
continue;
}
if((itr->y > 0) && (!DoesBurnForever(a_Chunk->GetBlock(itr->x, itr->y - 1, itr->z))))
if ((itr->y > 0) && (!DoesBurnForever(a_Chunk->GetBlock(itr->x, itr->y - 1, itr->z))))
{
a_Chunk->SetMeta(x, y, z, BlockMeta + 1);
}

View File

@ -159,18 +159,18 @@ Direction cFluidSimulator::GetFlowingDirection(int a_X, int a_Y, int a_Z, bool a
{
Vector3i *Pos = (*it);
char BlockID = m_World.GetBlock(Pos->x, Pos->y, Pos->z);
if(IsAllowedBlock(BlockID))
if (IsAllowedBlock(BlockID))
{
char Meta = m_World.GetBlockMeta(Pos->x, Pos->y, Pos->z);
if(Meta > LowestPoint)
if (Meta > LowestPoint)
{
LowestPoint = Meta;
X = Pos->x;
Z = Pos->z;
}
}
else if(BlockID == E_BLOCK_AIR)
else if (BlockID == E_BLOCK_AIR)
{
LowestPoint = 9; // This always dominates
X = Pos->x;

View File

@ -59,7 +59,7 @@ void cTracer::SetValues(const Vector3f & a_Start, const Vector3f & a_Direction)
step.z = (int) SigNum(dir.z);
// normalize the direction vector
if( dir.SqrLength() > 0.f ) dir.Normalize();
if (dir.SqrLength() > 0.f ) dir.Normalize();
// how far we must move in the ray direction before
// we encounter a new voxel in x-direction
@ -192,7 +192,7 @@ bool cTracer::Trace( const Vector3f & a_Start, const Vector3f & a_Direction, int
if (step.y > 0.0f)
{
if(pos.y >= end1.y)
if (pos.y >= end1.y)
{
reachedY = true;
}
@ -313,7 +313,7 @@ int cTracer::GetHitNormal(const Vector3f & start, const Vector3f & end, const Ve
Vector3i SmallBlockPos = a_BlockPos;
char BlockID = m_World->GetBlock( a_BlockPos.x, a_BlockPos.y, a_BlockPos.z );
if( BlockID == E_BLOCK_AIR || IsBlockWater(BlockID))
if (BlockID == E_BLOCK_AIR || IsBlockWater(BlockID))
{
return 0;
}
@ -328,10 +328,10 @@ int cTracer::GetHitNormal(const Vector3f & start, const Vector3f & end, const Ve
if (dot < 0)
{
int Lines = LinesCross( start.x, start.y, end.x, end.y, BlockPos.x, BlockPos.y, BlockPos.x, BlockPos.y + 1 );
if(Lines == 1)
if (Lines == 1)
{
Lines = LinesCross( start.x, start.z, end.x, end.z, BlockPos.x, BlockPos.z, BlockPos.x, BlockPos.z + 1 );
if(Lines == 1)
if (Lines == 1)
{
intersect3D_SegmentPlane( start, end, BlockPos, Vector3f(-1, 0, 0) );
return 1;
@ -339,13 +339,13 @@ int cTracer::GetHitNormal(const Vector3f & start, const Vector3f & end, const Ve
}
}
dot = Look.Dot( Vector3f(0, 0, -1) ); // second face normal is z -1
if(dot < 0)
if (dot < 0)
{
int Lines = LinesCross( start.z, start.y, end.z, end.y, BlockPos.z, BlockPos.y, BlockPos.z, BlockPos.y + 1 );
if(Lines == 1)
if (Lines == 1)
{
Lines = LinesCross( start.z, start.x, end.z, end.x, BlockPos.z, BlockPos.x, BlockPos.z, BlockPos.x + 1 );
if(Lines == 1)
if (Lines == 1)
{
intersect3D_SegmentPlane( start, end, BlockPos, Vector3f(0, 0, -1) );
return 2;
@ -353,13 +353,13 @@ int cTracer::GetHitNormal(const Vector3f & start, const Vector3f & end, const Ve
}
}
dot = Look.Dot( Vector3f(1, 0, 0) ); // third face normal is x 1
if(dot < 0)
if (dot < 0)
{
int Lines = LinesCross( start.x, start.y, end.x, end.y, BlockPos.x + 1, BlockPos.y, BlockPos.x + 1, BlockPos.y + 1 );
if(Lines == 1)
if (Lines == 1)
{
Lines = LinesCross( start.x, start.z, end.x, end.z, BlockPos.x + 1, BlockPos.z, BlockPos.x + 1, BlockPos.z + 1 );
if(Lines == 1)
if (Lines == 1)
{
intersect3D_SegmentPlane( start, end, BlockPos + Vector3f(1, 0, 0), Vector3f(1, 0, 0) );
return 3;
@ -367,13 +367,13 @@ int cTracer::GetHitNormal(const Vector3f & start, const Vector3f & end, const Ve
}
}
dot = Look.Dot( Vector3f(0, 0, 1) ); // fourth face normal is z 1
if(dot < 0)
if (dot < 0)
{
int Lines = LinesCross( start.z, start.y, end.z, end.y, BlockPos.z + 1, BlockPos.y, BlockPos.z + 1, BlockPos.y + 1 );
if(Lines == 1)
if (Lines == 1)
{
Lines = LinesCross( start.z, start.x, end.z, end.x, BlockPos.z + 1, BlockPos.x, BlockPos.z + 1, BlockPos.x + 1 );
if(Lines == 1)
if (Lines == 1)
{
intersect3D_SegmentPlane( start, end, BlockPos + Vector3f(0, 0, 1), Vector3f(0, 0, 1) );
return 4;
@ -381,13 +381,13 @@ int cTracer::GetHitNormal(const Vector3f & start, const Vector3f & end, const Ve
}
}
dot = Look.Dot( Vector3f(0, 1, 0) ); // fifth face normal is y 1
if(dot < 0)
if (dot < 0)
{
int Lines = LinesCross( start.y, start.x, end.y, end.x, BlockPos.y + 1, BlockPos.x, BlockPos.y + 1, BlockPos.x + 1 );
if(Lines == 1)
if (Lines == 1)
{
Lines = LinesCross( start.y, start.z, end.y, end.z, BlockPos.y + 1, BlockPos.z, BlockPos.y + 1, BlockPos.z + 1 );
if(Lines == 1)
if (Lines == 1)
{
intersect3D_SegmentPlane( start, end, BlockPos + Vector3f(0, 1, 0), Vector3f(0, 1, 0) );
return 5;
@ -395,13 +395,13 @@ int cTracer::GetHitNormal(const Vector3f & start, const Vector3f & end, const Ve
}
}
dot = Look.Dot( Vector3f(0, -1, 0) ); // sixth face normal is y -1
if(dot < 0)
if (dot < 0)
{
int Lines = LinesCross( start.y, start.x, end.y, end.x, BlockPos.y, BlockPos.x, BlockPos.y, BlockPos.x + 1 );
if(Lines == 1)
if (Lines == 1)
{
Lines = LinesCross( start.y, start.z, end.y, end.z, BlockPos.y, BlockPos.z, BlockPos.y, BlockPos.z + 1 );
if(Lines == 1)
if (Lines == 1)
{
intersect3D_SegmentPlane( start, end, BlockPos, Vector3f(0, -1, 0) );
return 6;

View File

@ -392,7 +392,7 @@ AString cWebAdmin::GetDefaultPage(void)
cPlayerAccum PlayerAccum;
cWorld * World = cRoot::Get()->GetDefaultWorld(); // TODO - Create a list of worlds and players
if( World != NULL )
if (World != NULL )
{
World->ForEachPlayer(PlayerAccum);
Content.append(PlayerAccum.m_Contents);

View File

@ -865,14 +865,14 @@ void cWorld::TickMobs(float a_Dt)
// move close mobs
cMobProximityCounter::sIterablePair allCloseEnoughToMoveMobs = MobCensus.GetProximityCounter().getMobWithinThosesDistances(-1, 64 * 16);// MG TODO : deal with this magic number (the 16 is the size of a block)
for(cMobProximityCounter::tDistanceToMonster::const_iterator itr = allCloseEnoughToMoveMobs.m_Begin; itr != allCloseEnoughToMoveMobs.m_End; ++itr)
for (cMobProximityCounter::tDistanceToMonster::const_iterator itr = allCloseEnoughToMoveMobs.m_Begin; itr != allCloseEnoughToMoveMobs.m_End; ++itr)
{
itr->second.m_Monster.Tick(a_Dt, itr->second.m_Chunk);
}
// remove too far mobs
cMobProximityCounter::sIterablePair allTooFarMobs = MobCensus.GetProximityCounter().getMobWithinThosesDistances(128 * 16, -1);// MG TODO : deal with this magic number (the 16 is the size of a block)
for(cMobProximityCounter::tDistanceToMonster::const_iterator itr = allTooFarMobs.m_Begin; itr != allTooFarMobs.m_End; ++itr)
for (cMobProximityCounter::tDistanceToMonster::const_iterator itr = allTooFarMobs.m_Begin; itr != allTooFarMobs.m_End; ++itr)
{
itr->second.m_Monster.Destroy(true);
}
@ -2469,7 +2469,7 @@ cPlayer * cWorld::FindClosestPlayer(const Vector3d & a_Pos, float a_SightLimit,
{
if (a_CheckLineOfSight)
{
if(!LineOfSight.Trace(a_Pos, (Pos - a_Pos), (int)(Pos - a_Pos).Length()))
if (!LineOfSight.Trace(a_Pos, (Pos - a_Pos), (int)(Pos - a_Pos).Length()))
{
ClosestDistance = Distance;
ClosestPlayer = *itr;

View File

@ -486,12 +486,12 @@ cWSSCompact::cPAKFile::cPAKFile(const AString & a_FileName, int a_LayerX, int a_
return;
}
if( m_ChunkVersion == 1 ) // Convert chunks to version 2
if (m_ChunkVersion == 1 ) // Convert chunks to version 2
{
UpdateChunk1To2();
}
#if AXIS_ORDER == AXIS_ORDER_XZY
if( m_ChunkVersion == 2 ) // Convert chunks to version 3
if (m_ChunkVersion == 2 ) // Convert chunks to version 3
{
UpdateChunk2To3();
}
@ -574,7 +574,7 @@ void cWSSCompact::cPAKFile::UpdateChunk1To2()
{
sChunkHeader * Header = *itr;
if( ChunksConverted % 32 == 0 )
if (ChunksConverted % 32 == 0 )
{
LOGINFO("Updating \"%s\" version 1 to version 2: " SIZE_T_FMT " %%", m_FileName.c_str(), (ChunksConverted * 100) / m_ChunkHeaders.size() );
}
@ -627,9 +627,9 @@ void cWSSCompact::cPAKFile::UpdateChunk1To2()
char ConvertedData[cChunkDef::BlockDataSize];
int Index = 0;
unsigned int InChunkOffset = 0;
for( int x = 0; x < 16; ++x ) for( int z = 0; z < 16; ++z )
for (int x = 0; x < 16; ++x ) for (int z = 0; z < 16; ++z )
{
for( int y = 0; y < 128; ++y )
for (int y = 0; y < 128; ++y )
{
ConvertedData[Index++] = UncompressedData[y + z * 128 + x * 128 * 16 + InChunkOffset];
}
@ -638,9 +638,9 @@ void cWSSCompact::cPAKFile::UpdateChunk1To2()
Index += 128;
}
InChunkOffset += (16 * 128 * 16);
for( int x = 0; x < 16; ++x ) for( int z = 0; z < 16; ++z ) // Metadata
for (int x = 0; x < 16; ++x ) for (int z = 0; z < 16; ++z ) // Metadata
{
for( int y = 0; y < 64; ++y )
for (int y = 0; y < 64; ++y )
{
ConvertedData[Index++] = UncompressedData[y + z * 64 + x * 64 * 16 + InChunkOffset];
}
@ -648,9 +648,9 @@ void cWSSCompact::cPAKFile::UpdateChunk1To2()
Index += 64;
}
InChunkOffset += (16 * 128 * 16) / 2;
for( int x = 0; x < 16; ++x ) for( int z = 0; z < 16; ++z ) // Block light
for (int x = 0; x < 16; ++x ) for (int z = 0; z < 16; ++z ) // Block light
{
for( int y = 0; y < 64; ++y )
for (int y = 0; y < 64; ++y )
{
ConvertedData[Index++] = UncompressedData[y + z * 64 + x * 64 * 16 + InChunkOffset];
}
@ -658,9 +658,9 @@ void cWSSCompact::cPAKFile::UpdateChunk1To2()
Index += 64;
}
InChunkOffset += (16*128*16)/2;
for( int x = 0; x < 16; ++x ) for( int z = 0; z < 16; ++z ) // Sky light
for (int x = 0; x < 16; ++x ) for (int z = 0; z < 16; ++z ) // Sky light
{
for( int y = 0; y < 64; ++y )
for (int y = 0; y < 64; ++y )
{
ConvertedData[Index++] = UncompressedData[y + z * 64 + x * 64 * 16 + InChunkOffset];
}
@ -718,7 +718,7 @@ void cWSSCompact::cPAKFile::UpdateChunk2To3()
{
sChunkHeader * Header = *itr;
if( ChunksConverted % 32 == 0 )
if (ChunksConverted % 32 == 0 )
{
LOGINFO("Updating \"%s\" version 2 to version 3: " SIZE_T_FMT " %%", m_FileName.c_str(), (ChunksConverted * 100) / m_ChunkHeaders.size() );
}
@ -774,7 +774,7 @@ void cWSSCompact::cPAKFile::UpdateChunk2To3()
#define MAKE_3_INDEX( x, y, z ) ( x + (z * 16) + (y * 16 * 16) )
unsigned int InChunkOffset = 0;
for( int x = 0; x < 16; ++x ) for( int z = 0; z < 16; ++z ) for( int y = 0; y < 256; ++y ) // YZX Loop order is important, in 1.1 Y was first then Z then X
for (int x = 0; x < 16; ++x ) for (int z = 0; z < 16; ++z ) for (int y = 0; y < 256; ++y ) // YZX Loop order is important, in 1.1 Y was first then Z then X
{
ConvertedData[ MAKE_3_INDEX(x, y, z) ] = UncompressedData[InChunkOffset];
++InChunkOffset;
@ -782,7 +782,7 @@ void cWSSCompact::cPAKFile::UpdateChunk2To3()
unsigned int index2 = 0;
for( int x = 0; x < 16; ++x ) for( int z = 0; z < 16; ++z ) for( int y = 0; y < 256; ++y )
for (int x = 0; x < 16; ++x ) for (int z = 0; z < 16; ++z ) for (int y = 0; y < 256; ++y )
{
ConvertedData[ InChunkOffset + MAKE_3_INDEX(x, y, z)/2 ] |= ( (UncompressedData[ InChunkOffset + index2/2 ] >> ((index2&1)*4) ) & 0x0f ) << ((x&1)*4);
++index2;
@ -790,7 +790,7 @@ void cWSSCompact::cPAKFile::UpdateChunk2To3()
InChunkOffset += index2 / 2;
index2 = 0;
for( int x = 0; x < 16; ++x ) for( int z = 0; z < 16; ++z ) for( int y = 0; y < 256; ++y )
for (int x = 0; x < 16; ++x ) for (int z = 0; z < 16; ++z ) for (int y = 0; y < 256; ++y )
{
ConvertedData[ InChunkOffset + MAKE_3_INDEX(x, y, z)/2 ] |= ( (UncompressedData[ InChunkOffset + index2/2 ] >> ((index2&1)*4) ) & 0x0f ) << ((x&1)*4);
++index2;
@ -798,7 +798,7 @@ void cWSSCompact::cPAKFile::UpdateChunk2To3()
InChunkOffset += index2 / 2;
index2 = 0;
for( int x = 0; x < 16; ++x ) for( int z = 0; z < 16; ++z ) for( int y = 0; y < 256; ++y )
for (int x = 0; x < 16; ++x ) for (int z = 0; z < 16; ++z ) for (int y = 0; y < 256; ++y )
{
ConvertedData[ InChunkOffset + MAKE_3_INDEX(x, y, z)/2 ] |= ( (UncompressedData[ InChunkOffset + index2/2 ] >> ((index2&1)*4) ) & 0x0f ) << ((x&1)*4);
++index2;
@ -887,7 +887,7 @@ bool cWSSCompact::LoadChunkFromData(const cChunkCoords & a_Chunk, int a_Uncompre
{
Json::Value root; // will contain the root value after parsing.
Json::Reader reader;
if ( !reader.parse( UncompressedData.data() + cChunkDef::BlockDataSize, root, false ) )
if (!reader.parse( UncompressedData.data() + cChunkDef::BlockDataSize, root, false ) )
{
LOGERROR("Failed to parse trailing JSON in chunk [%d, %d]!",
a_Chunk.m_ChunkX, a_Chunk.m_ChunkZ
@ -970,7 +970,7 @@ bool cWSSCompact::cPAKFile::SaveChunkToData(const cChunkCoords & a_Chunk, cWorld
// Compress the data:
AString CompressedData;
int errorcode = CompressString(Data.data(), Data.size(), CompressedData, m_CompressionFactor);
if ( errorcode != Z_OK )
if (errorcode != Z_OK )
{
LOGERROR("Error %i compressing data for chunk [%d, %d, %d]", errorcode, a_Chunk.m_ChunkX, a_Chunk.m_ChunkY, a_Chunk.m_ChunkZ);
return false;