- bugfixes found from cppcheck

This commit is contained in:
Mark Vejvoda 2011-08-31 20:04:50 +00:00
parent 3af608151e
commit 93cc49a89a
3 changed files with 18 additions and 14 deletions

View File

@ -6076,26 +6076,28 @@ void Renderer::renderUnitTitles3D(Font3D *font, Vec3f color) {
for(int idx = 0; idx < visibleFrameUnitList.size(); idx++) {
const Unit *unit = visibleFrameUnitList[idx];
if(unit != NULL && unit->getVisible() == true) {
if(unit != NULL && unit->getCurrentUnitTitle() != "") {
//get the screen coordinates
Vec3f screenPos = unit->getScreenPos();
if(unit != NULL) {
if(unit->getVisible() == true) {
if(unit != NULL && unit->getCurrentUnitTitle() != "") {
//get the screen coordinates
Vec3f screenPos = unit->getScreenPos();
#ifdef USE_STREFLOP
renderText3D(unit->getCurrentUnitTitle(), font, color, streflop::fabs(screenPos.x) + 5, streflop::fabs(screenPos.y) + 5, false);
renderText3D(unit->getCurrentUnitTitle(), font, color, streflop::fabs(screenPos.x) + 5, streflop::fabs(screenPos.y) + 5, false);
#else
renderText3D(unit->getCurrentUnitTitle(), font, color, fabs(screenPos.x) + 5, fabs(screenPos.y) + 5, false);
renderText3D(unit->getCurrentUnitTitle(), font, color, fabs(screenPos.x) + 5, fabs(screenPos.y) + 5, false);
#endif
unitRenderedList[unit->getId()] = true;
}
else {
string str = unit->getFullName() + " - " + intToStr(unit->getId()) + " [" + unit->getPos().getString() + "]";
Vec3f screenPos = unit->getScreenPos();
unitRenderedList[unit->getId()] = true;
}
else {
string str = unit->getFullName() + " - " + intToStr(unit->getId()) + " [" + unit->getPos().getString() + "]";
Vec3f screenPos = unit->getScreenPos();
#ifdef USE_STREFLOP
renderText3D(str, font, color, streflop::fabs(screenPos.x) + 5, streflop::fabs(screenPos.y) + 5, false);
renderText3D(str, font, color, streflop::fabs(screenPos.x) + 5, streflop::fabs(screenPos.y) + 5, false);
#else
renderText3D(str, font, color, fabs(screenPos.x) + 5, fabs(screenPos.y) + 5, false);
renderText3D(str, font, color, fabs(screenPos.x) + 5, fabs(screenPos.y) + 5, false);
#endif
}
}
}
}

View File

@ -1100,7 +1100,7 @@ void MenuStateConnectedGame::update() {
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] pingCount = %d, clientInterface->getLastPingLag() = %f, GameConstants::networkPingInterval = %d\n",__FILE__,__FUNCTION__,__LINE__,pingCount, clientInterface->getLastPingLag(),GameConstants::networkPingInterval);
// Starting checking timeout after sending at least 3 pings to server
if(clientInterface != NULL && clientInterface->isConnected() &&
if(clientInterface->isConnected() &&
pingCount >= 3 && clientInterface->getLastPingLag() >= (GameConstants::networkPingInterval * 3)) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);

View File

@ -308,6 +308,8 @@ Checksum Map::load(const string &path, TechTree *techTree, Tileset *tileset) {
}
}
else{
if(f) fclose(f);
throw runtime_error("Can't open file");
}
fclose(f);