Skip to content

Commit

Permalink
Bulk clearing of whitespace
Browse files Browse the repository at this point in the history
  • Loading branch information
LogicParrot authored and LogicParrot committed Feb 5, 2016
1 parent 87a31e3 commit ca6ef58
Show file tree
Hide file tree
Showing 406 changed files with 4,497 additions and 4,497 deletions.
20 changes: 10 additions & 10 deletions src/AllocationPool.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,23 @@ class cAllocationPool
{
public:
virtual ~cStarvationCallbacks() {}

/** Is called when the reserve buffer starts to be used */
virtual void OnStartUsingReserve() = 0;

/** Is called once the reserve buffer has returned to normal size */
virtual void OnEndUsingReserve() = 0;

/** Is called when the allocation pool is unable to allocate memory. Will be repeatedly
called if it does not free sufficient memory */
virtual void OnOutOfReserve() = 0;
};

virtual ~cAllocationPool() {}

/** Allocates a pointer to T */
virtual T * Allocate() = 0;

/** Frees the pointer passed in a_ptr, invalidating it */
virtual void Free(T * a_ptr) = 0;
};
Expand All @@ -47,7 +47,7 @@ class cListAllocationPool:
public cAllocationPool<T>
{
public:

cListAllocationPool(std::unique_ptr<typename cAllocationPool<T>::cStarvationCallbacks> a_Callbacks):
m_Callbacks(std::move(a_Callbacks))
{
Expand All @@ -62,7 +62,7 @@ class cListAllocationPool:
m_FreeList.push_front(space);
}
}


virtual ~cListAllocationPool()
{
Expand All @@ -72,7 +72,7 @@ class cListAllocationPool:
m_FreeList.pop_front();
}
}


virtual T * Allocate() override
{
Expand Down Expand Up @@ -115,7 +115,7 @@ class cListAllocationPool:
m_Callbacks->OnEndUsingReserve();
}
}

private:
std::list<void *> m_FreeList;
std::unique_ptr<typename cAllocationPool<T>::cStarvationCallbacks> m_Callbacks;
Expand Down
22 changes: 11 additions & 11 deletions src/Bindings/LuaChunkStay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ bool cLuaChunkStay::AddChunks(int a_ChunkCoordTableStackPos)
{
// This function is expected to be called just once, with all the coords in a table
ASSERT(m_Chunks.empty());

cPluginLua::cOperation Op(m_Plugin);
cLuaState & L = Op();

// Check that we got a table:
if (!lua_istable(L, a_ChunkCoordTableStackPos))
{
Expand All @@ -38,7 +38,7 @@ bool cLuaChunkStay::AddChunks(int a_ChunkCoordTableStackPos)
L.LogStackTrace();
return false;
}

// Add each set of coords:
int NumChunks = luaL_getn(L, a_ChunkCoordTableStackPos);
m_Chunks.reserve(static_cast<size_t>(NumChunks));
Expand All @@ -58,15 +58,15 @@ bool cLuaChunkStay::AddChunks(int a_ChunkCoordTableStackPos)
AddChunkCoord(L, idx);
lua_pop(L, 1);
}

// If there are no chunks, log a warning and return failure:
if (m_Chunks.empty())
{
LOGWARNING("%s: Zero chunks to stay.", __FUNCTION__);
L.LogStackTrace();
return false;
}

// All ok
return true;
}
Expand All @@ -86,14 +86,14 @@ void cLuaChunkStay::AddChunkCoord(cLuaState & L, int a_Index)
);
return;
}

// Read the two coords from the element:
lua_rawgeti(L, -1, 1);
lua_rawgeti(L, -2, 2);
int ChunkX = luaL_checkint(L, -2);
int ChunkZ = luaL_checkint(L, -1);
lua_pop(L, 2);

// Check that a coord is not yet present:
for (cChunkCoordsVector::iterator itr = m_Chunks.begin(), end = m_Chunks.end(); itr != end; ++itr)
{
Expand All @@ -105,7 +105,7 @@ void cLuaChunkStay::AddChunkCoord(cLuaState & L, int a_Index)
return;
}
} // for itr - m_Chunks[]

m_Chunks.push_back(cChunkCoords(ChunkX, ChunkZ));
}

Expand All @@ -119,7 +119,7 @@ void cLuaChunkStay::Enable(cChunkMap & a_ChunkMap, int a_OnChunkAvailableStackPo
m_LuaState = &m_Plugin.GetLuaState();
m_OnChunkAvailable.RefStack(*m_LuaState, a_OnChunkAvailableStackPos);
m_OnAllChunksAvailable.RefStack(*m_LuaState, a_OnAllChunksAvailableStackPos);

// Enable the ChunkStay:
super::Enable(a_ChunkMap);
}
Expand Down Expand Up @@ -148,12 +148,12 @@ bool cLuaChunkStay::OnAllChunksAvailable(void)
// Call the callback:
cPluginLua::cOperation Op(m_Plugin);
Op().Call(static_cast<int>(m_OnAllChunksAvailable));

// Remove the callback references - they won't be needed anymore
m_OnChunkAvailable.UnRef();
m_OnAllChunksAvailable.UnRef();
}

// Disable the ChunkStay by returning true
return true;
}
Expand Down
20 changes: 10 additions & 10 deletions src/Bindings/LuaChunkStay.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,38 +28,38 @@ class cLuaChunkStay
: public cChunkStay
{
typedef cChunkStay super;

public:
cLuaChunkStay(cPluginLua & a_Plugin);

~cLuaChunkStay() { }

/** Adds chunks in the specified on-stack Lua table.
Returns true if any chunk added, false (plus log warning) if none. */
bool AddChunks(int a_ChunkCoordTableStackPos);

/** Enables the ChunkStay for the specified chunkmap, with the specified Lua callbacks. */
void Enable(cChunkMap & a_ChunkMap, int a_OnChunkAvailableStackPos, int a_OnAllChunksAvailableStackPos);

protected:
/** The plugin which has created the ChunkStay, via cWorld:ChunkStay() binding method. */
cPluginLua & m_Plugin;

/** The Lua state associated with the callbacks. Only valid when enabled. */
cLuaState * m_LuaState;

/** The Lua function to call in OnChunkAvailable. Only valid when enabled. */
cLuaState::cRef m_OnChunkAvailable;

/** The Lua function to call in OnAllChunksAvailable. Only valid when enabled. */
cLuaState::cRef m_OnAllChunksAvailable;


// cChunkStay overrides:
virtual void OnChunkAvailable(int a_ChunkX, int a_ChunkZ) override;
virtual bool OnAllChunksAvailable(void) override;
virtual void OnDisabled(void) override;

/** Adds a single chunk coord from the table at the top of the Lua stack.
Expects the top element to be a table, checks that it contains two numbers.
Uses those two numbers as chunk coords appended to m_Chunks.
Expand Down
Loading

0 comments on commit ca6ef58

Please sign in to comment.