Permalink
Browse files

delintify some

Conflicts:
	rts/Map/SMF/SMFGroundDrawer.cpp
	rts/Rendering/GlobalRendering.cpp
	rts/Rendering/UnitDrawer.cpp
  • Loading branch information...
rt
rt committed Dec 1, 2018
1 parent 25a21e8 commit 45379cf70b9ee8e9b05482705bd1587e9fe92158
@@ -390,9 +390,11 @@ float GuiTraceRay(
if (u == exclude)
continue;
#if 0
// test this bit only in synced traces, rely on noSelect here
if (false && !u->HasCollidableStateBit(CSolidObject::CSTATE_BIT_QUADMAPRAYS)) // NOLINT{readability-simplify-boolean-expr}
if (!u->HasCollidableStateBit(CSolidObject::CSTATE_BIT_QUADMAPRAYS))
continue;
#endif
if (u->noSelect)
continue;
if (!unitVisible)
@@ -432,9 +434,11 @@ float GuiTraceRay(
for (const CFeature* f: quad.features) {
if (!gu->spectatingFullView && !f->IsInLosForAllyTeam(gu->myAllyTeam))
continue;
#if 0
// test this bit only in synced traces, rely on noSelect here
if (false && !f->HasCollidableStateBit(CSolidObject::CSTATE_BIT_QUADMAPRAYS)) // NOLINT{misc-static-assert}
if (!f->HasCollidableStateBit(CSolidObject::CSTATE_BIT_QUADMAPRAYS))
continue;
#endif
if (f->noSelect)
continue;
@@ -1285,14 +1285,24 @@ int LuaUnsyncedRead::GetWaterMode(lua_State* L)
int LuaUnsyncedRead::GetMapDrawMode(lua_State* L)
{
std::string mode = infoTextureHandler->GetMode();
if (mode == "") { mode = "normal"; } else // NOLINT
if (mode == "path") { mode = "pathTraversability"; } else
if (mode == "heat") { mode = "pathHeat"; } else
if (mode == "flow") { mode = "pathFlow"; } else
if (mode == "pathcost") { mode = "pathCost"; }
lua_pushsstring(L, mode); // NOLINT{readability-misleading-indentation}
using P = std::pair<const char*, const char*>;
constexpr std::array<P, 5> modes = {
P( "", "normal" ),
P( "path", "pathTraversability"),
P( "heat", "pathHeat" ),
P( "flow", "pathFlow" ),
P("pathcost", "pathCost" ),
};
const auto& mode = infoTextureHandler->GetMode();
const auto iter = std::find_if(modes.begin(), modes.end(), [&mode](const P& p) { return (strcmp(p.first, mode.c_str()) == 0); });
if (iter != modes.end()) {
lua_pushstring(L, iter->second);
} else {
lua_pushstring(L, mode.c_str());
}
return 1;
}
@@ -582,32 +582,35 @@ template <typename T>
int PackType(lua_State* L)
{
std::vector<T> vals;
std::vector<char> buf;
if (lua_istable(L, 1)) {
vals.reserve(lua_objlen(L, 1));
for (int i = 1; lua_rawgeti(L, 1, i), lua_isnumber(L, -1); lua_pop(L, 1), i++) {
vals.push_back((T)lua_tonumber(L, -1));
vals.push_back(static_cast<T>(lua_tonumber(L, -1)));
}
} else {
const int args = lua_gettop(L);
for (int i = 1; i <= args; i++) {
if (!lua_isnumber(L, i))
vals.resize(lua_gettop(L));
for (size_t i = 0; i < vals.size(); i++) {
if (!lua_isnumber(L, i + 1))
break;
vals.push_back((T)lua_tonumber(L, i));
vals[i] = static_cast<T>(lua_tonumber(L, i + 1));
}
}
if (vals.empty())
return 0;
const int bufSize = sizeof(T) * vals.size();
char* buf = new char[bufSize];
for (int i = 0; i < (int)vals.size(); i++) {
memcpy(buf + (i * sizeof(T)), &vals[i], sizeof(T));
buf.resize(sizeof(T) * vals.size(), 0);
for (size_t i = 0; i < vals.size(); i++) {
memcpy(buf.data() + (i * sizeof(T)), &vals[i], sizeof(T));
}
lua_pushlstring(L, buf, bufSize);
delete[] buf;
lua_pushlstring(L, buf.data(), buf.size());
return 1;
}
@@ -539,7 +539,9 @@ void DefaultPathDrawer::Draw(const CPathEstimator* pe) const {
}
#if (PE_EXTRA_DEBUG_OVERLAYS == 1)
if ((drawLowResPE || drawMedResPE) && false) { // NOLINT{readability-simplify-boolean-expr}
if (drawLowResPE || drawMedResPE) {
return; // TMI
const PathNodeBuffer& openBlockBuffer = pe->openBlockBuffer;
char blockCostsStr[32];
@@ -325,44 +325,28 @@ void LocalModel::UpdateBoundingVolume()
if (!piece->HasGeometryData())
continue;
#if 0
const unsigned int vcount = piece->GetVertexCount();
if (vcount >= 8) {
#endif
// transform only the corners of the piece's bounding-box
const float3 pMins = piece->mins; // NOLINT{readability-misleading-indentation}
const float3 pMaxs = piece->maxs;
const float3 verts[8] = {
// bottom
float3(pMins.x, pMins.y, pMins.z),
float3(pMaxs.x, pMins.y, pMins.z),
float3(pMaxs.x, pMins.y, pMaxs.z),
float3(pMins.x, pMins.y, pMaxs.z),
// top
float3(pMins.x, pMaxs.y, pMins.z),
float3(pMaxs.x, pMaxs.y, pMins.z),
float3(pMaxs.x, pMaxs.y, pMaxs.z),
float3(pMins.x, pMaxs.y, pMaxs.z),
};
for (const float3& v: verts) {
const float3 vertex = matrix * v;
bbMins = float3::min(bbMins, vertex);
bbMaxs = float3::max(bbMaxs, vertex);
}
#if 0
} else {
// note: not as efficient because of branching and virtual calls
for (unsigned int k = 0; k < vcount; k++) {
const float3 vertex = matrix * piece->GetVertexPos(k);
bbMins = float3::min(bbMins, vertex);
bbMaxs = float3::max(bbMaxs, vertex);
}
// transform only the corners of the piece's bounding-box
const float3 pMins = piece->mins;
const float3 pMaxs = piece->maxs;
const float3 verts[8] = {
// bottom
float3(pMins.x, pMins.y, pMins.z),
float3(pMaxs.x, pMins.y, pMins.z),
float3(pMaxs.x, pMins.y, pMaxs.z),
float3(pMins.x, pMins.y, pMaxs.z),
// top
float3(pMins.x, pMaxs.y, pMins.z),
float3(pMaxs.x, pMaxs.y, pMins.z),
float3(pMaxs.x, pMaxs.y, pMaxs.z),
float3(pMins.x, pMaxs.y, pMaxs.z),
};
for (const float3& v: verts) {
const float3 vertex = matrix * v;
bbMins = float3::min(bbMins, vertex);
bbMaxs = float3::max(bbMaxs, vertex);
}
#endif
}
// note: offset is relative to object->pos
@@ -757,7 +757,7 @@ void CUnitDrawer::SetupAlphaDrawing(bool deferredPass)
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE * wireFrameMode + GL_FILL * (1 - wireFrameMode));
unitDrawerStates[DRAWER_STATE_SEL] = const_cast<IUnitDrawerState*>(GetWantedDrawerState(true));
unitDrawerStates[DRAWER_STATE_SEL]->Enable(this, deferredPass && false, true);
unitDrawerStates[DRAWER_STATE_SEL]->Enable(this, /*deferredPass*/ false, true);
glEnable(GL_TEXTURE_2D);
glEnable(GL_BLEND);
@@ -769,7 +769,7 @@ void CUnitDrawer::SetupAlphaDrawing(bool deferredPass)
void CUnitDrawer::ResetAlphaDrawing(bool deferredPass)
{
unitDrawerStates[DRAWER_STATE_SEL]->Disable(this, deferredPass && false);
unitDrawerStates[DRAWER_STATE_SEL]->Disable(this, /*deferredPass*/ false);
glPopAttrib();
}
@@ -278,15 +278,15 @@ void CLogOutput::LogConfigInfo()
void CLogOutput::LogSystemInfo()
{
LOG("============== <User System> ==============");
LOG(" Spring %s", SpringVersion::GetFull().c_str());
LOG(" Build Environment: %s", SpringVersion::GetBuildEnvironment().c_str());
LOG(" Compiler Version: %s", SpringVersion::GetCompiler().c_str());
LOG(" Operating System: %s", Platform::GetOSDisplayStr().c_str());
LOG(" Hardware Config: %s", Platform::GetHardwareStr().c_str());
LOG(" Binary Word Size: %s", Platform::GetWordSizeStr().c_str());
LOG(" Process Clock: %s", spring_clock::GetName());
LOG(" Physical CPU Cores: %d", Threading::GetPhysicalCpuCores());
LOG(" Logical CPU Cores: %d", Threading::GetLogicalCpuCores());
LOG(" Spring Engine Version: %s", SpringVersion::GetFull().c_str());
LOG(" Build Environment: %s", SpringVersion::GetBuildEnvironment().c_str());
LOG(" Compiler Version: %s", SpringVersion::GetCompiler().c_str());
LOG(" Operating System: %s", Platform::GetOSDisplayStr().c_str());
LOG(" Hardware Config: %s", Platform::GetHardwareStr().c_str());
LOG(" Binary Word Size: %s", Platform::GetWordSizeStr().c_str());
LOG(" Process Clock: %s", spring_clock::GetName());
LOG(" Physical CPU Cores: %d", Threading::GetPhysicalCpuCores());
LOG(" Logical CPU Cores: %d", Threading::GetLogicalCpuCores());
LOG("============== </User System> ==============\n");
}
@@ -38,9 +38,7 @@ namespace Threading {
THREAD_IDX_LAST = 5,
};
static bool cachedThreadIDs[THREAD_IDX_LAST] = {false, false, false, false, false};
static NativeThreadId nativeThreadIDs[THREAD_IDX_LAST] = {};
static Error threadError;
thread_local std::shared_ptr<Threading::ThreadControls> threadCtls;
@@ -315,10 +313,7 @@ namespace Threading {
// those two threads are joined and respawned when reloading, KISS here
// (while other threads never call Set*Thread more than once making the
// is-cached flags redundant anyway)
if (true || !cachedThreadIDs[threadIndex]) // NOLINT{readability-simplify-boolean-expr}
nativeThreadIDs[threadIndex] = Threading::GetCurrentThreadId();
cachedThreadIDs[threadIndex] = true;
nativeThreadIDs[threadIndex] = Threading::GetCurrentThreadId();
if (!setControls)
return;
@@ -400,7 +400,7 @@ namespace Watchdog
// start the watchdog thread
hangDetectorThread = std::move(spring::thread(&HangDetectorLoop));
LOG("[WatchDog%s] Installed (HangTimeout: %isec)", __func__, hangTimeoutSecs);
LOG("[WatchDog::%s] installed (hang-timeout: %is)", __func__, hangTimeoutSecs);
}
@@ -81,12 +81,12 @@ TdfParser::TdfSection::~TdfSection()
TdfParser::TdfParser(char const* buf, size_t size)
TdfParser::TdfParser(const char* buf, size_t size)
{
LoadBuffer(buf, size);
}
TdfParser::TdfParser(std::string const& filename)
TdfParser::TdfParser(const std::string& filename)
{
LoadFile(filename);
}
@@ -127,7 +127,7 @@ void TdfParser::ParseLuaTable(const LuaTable& table, TdfSection* currentSection)
}
void TdfParser::ParseBuffer(char const* buf, size_t size) {
void TdfParser::ParseBuffer(const char* buf, size_t size) {
CVFSHandler* oldHandler = vfsHandler;
CVFSHandler tmpHandler;
@@ -148,34 +148,34 @@ void TdfParser::ParseBuffer(char const* buf, size_t size) {
CVFSHandler::FreeLock();
}
void TdfParser::LoadBuffer(char const* buf, size_t size)
void TdfParser::LoadBuffer(const char* buf, size_t size)
{
this->filename = "buffer";
ParseBuffer(buf, size);
}
void TdfParser::LoadFile(std::string const& filename)
void TdfParser::LoadFile(const std::string& filename)
{
this->filename = filename;
CFileHandler file(filename);
if (!file.FileExists()) {
throw content_error("file " + filename + " not found");
}
CFileHandler file(this->filename = filename);
std::vector<unsigned char> fileBuf;
const size_t fileBuf_size = file.FileSize();
//char* fileBuf = new char[fileBuf_size];
std::vector<char> fileBuf(fileBuf_size);
if (!file.FileExists())
throw content_error("file " + filename + " not found");
file.Read(fileBuf.data(), file.FileSize());
ParseBuffer(fileBuf.data(), fileBuf_size);
if (!file.IsBuffered()) {
fileBuf.resize(file.FileSize(), 0);
file.Read(fileBuf.data(), fileBuf.size());
} else {
fileBuf = std::move(file.GetBuffer());
}
//delete[] fileBuf;
ParseBuffer(reinterpret_cast<const char*>(fileBuf.data()), fileBuf.size());
}
std::string TdfParser::SGetValueDef(std::string const& defaultValue, std::string const& location) const
std::string TdfParser::SGetValueDef(const std::string& defaultValue, const std::string& location) const
{
std::string lowerd = StringToLower(location);
std::string value;
@@ -186,7 +186,7 @@ std::string TdfParser::SGetValueDef(std::string const& defaultValue, std::string
return value;
}
bool TdfParser::SGetValue(std::string &value, std::string const& location) const
bool TdfParser::SGetValue(std::string& value, const std::string& location) const
{
std::string lowerd = StringToLower(location);
std::string searchpath; // for error-messages
@@ -238,7 +238,7 @@ bool TdfParser::GetValue(bool& val, const std::string& location) const
}
}
const TdfParser::valueMap_t& TdfParser::GetAllValues(std::string const& location) const
const TdfParser::valueMap_t& TdfParser::GetAllValues(const std::string& location) const
{
static valueMap_t emptymap;
std::string lowerd = StringToLower(location);
@@ -265,7 +265,7 @@ const TdfParser::valueMap_t& TdfParser::GetAllValues(std::string const& location
return sectionptr->values;
}
std::vector<std::string> TdfParser::GetSectionList(std::string const& location) const
std::vector<std::string> TdfParser::GetSectionList(const std::string& location) const
{
const std::string& lowerd = StringToLower(location);
const std::vector<std::string>& loclist = GetLocationVector(lowerd);
@@ -295,7 +295,7 @@ std::vector<std::string> TdfParser::GetSectionList(std::string const& location)
return returnvec;
}
bool TdfParser::SectionExist(std::string const& location) const
bool TdfParser::SectionExist(const std::string& location) const
{
const std::string& lowerd = StringToLower(location);
const std::vector<std::string>& loclist = GetLocationVector(lowerd);
@@ -316,7 +316,7 @@ bool TdfParser::SectionExist(std::string const& location) const
return true;
}
std::vector<std::string> TdfParser::GetLocationVector(std::string const& location) const
std::vector<std::string> TdfParser::GetLocationVector(const std::string& location) const
{
const std::string& lowerd = StringToLower(location);
@@ -333,12 +333,12 @@ std::vector<std::string> TdfParser::GetLocationVector(std::string const& locatio
return loclist;
}
float3 TdfParser::GetFloat3(float3 def, std::string const& location) const
float3 TdfParser::GetFloat3(float3 def, const std::string& location) const
{
std::string s = SGetValueDef("", location);
if (s.empty()) {
if (s.empty())
return def;
}
float3 ret;
ParseArray(s, &ret.x, 3);
return ret;

0 comments on commit 45379cf

Please sign in to comment.