- cppcheck round #2 cleanup

This commit is contained in:
Mark Vejvoda 2012-09-22 20:37:42 +00:00
parent 1c211e4ce6
commit e0bf4df646
10 changed files with 26 additions and 26 deletions

View File

@ -1324,8 +1324,8 @@ void MainWindow::loadParticle(string path) {
else { else {
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] unit XML NOT FOUND [%s] using default position values\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,unitXML.c_str()); if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] unit XML NOT FOUND [%s] using default position values\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,unitXML.c_str());
int size = 1; size = 1;
int height= 1; height= 1;
} }
std::map<string,vector<pair<string, string> > > loadedFileList; std::map<string,vector<pair<string, string> > > loadedFileList;

View File

@ -220,7 +220,7 @@ void Renderer::init() {
if(glActiveTexture == NULL) { if(glActiveTexture == NULL) {
char szBuf[8096]=""; char szBuf[8096]="";
sprintf(szBuf,"Error: glActiveTexture == NULL\nglActiveTexture is only supported if the GL version is 1.3 or greater,\nor if the ARB_multitexture extension is supported!",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); sprintf(szBuf,"Error: glActiveTexture == NULL\nglActiveTexture is only supported if the GL version is 1.3 or greater,\nor if the ARB_multitexture extension is supported!");
throw megaglest_runtime_error(szBuf); throw megaglest_runtime_error(szBuf);
} }

View File

@ -220,7 +220,7 @@ TravelState PathFinder::findPath(Unit *unit, const Vec2i &finalPos, bool *wasStu
maxNodeCount= PathFinder::pathFindNodesAbsoluteMax; maxNodeCount= PathFinder::pathFindNodesAbsoluteMax;
} }
int unitFactionIndex = unit->getFactionIndex(); //int unitFactionIndex = unit->getFactionIndex();
bool minorDebugPathfinderPerformance = false; bool minorDebugPathfinderPerformance = false;
Chrono chrono; Chrono chrono;
@ -449,7 +449,7 @@ TravelState PathFinder::aStarFast(Unit *unit, Vec2i finalPos, bool inBailout, in
} }
if(maxNodeCount >= 1 && unit->getPathfindFailedConsecutiveFrameCount() >= 3) { if(maxNodeCount >= 1 && unit->getPathfindFailedConsecutiveFrameCount() >= 3) {
int orgmaxNodeCount = maxNodeCount; //int orgmaxNodeCount = maxNodeCount;
maxNodeCount = 200; maxNodeCount = 200;
//printf("AStar maxpath cut for unit [%d - %s] to %d [orig: %d] [unit->getPathfindFailedConsecutiveFrameCount(): %d]\n",unit->getId(),unit->getFullName().c_str(), maxNodeCount,orgmaxNodeCount,unit->getPathfindFailedConsecutiveFrameCount()); //printf("AStar maxpath cut for unit [%d - %s] to %d [orig: %d] [unit->getPathfindFailedConsecutiveFrameCount(): %d]\n",unit->getId(),unit->getFullName().c_str(), maxNodeCount,orgmaxNodeCount,unit->getPathfindFailedConsecutiveFrameCount());
} }
@ -1300,7 +1300,7 @@ TravelState PathFinder::aStar(Unit *unit, const Vec2i &targetPos, bool inBailout
} }
if(maxNodeCount >= 1 && unit->getPathfindFailedConsecutiveFrameCount() >= 3) { if(maxNodeCount >= 1 && unit->getPathfindFailedConsecutiveFrameCount() >= 3) {
int orgmaxNodeCount = maxNodeCount; //int orgmaxNodeCount = maxNodeCount;
maxNodeCount = 200; maxNodeCount = 200;
//printf("AStar maxpath cut for unit [%d - %s] to %d [orig: %d] [unit->getPathfindFailedConsecutiveFrameCount(): %d]\n",unit->getId(),unit->getFullName().c_str(), maxNodeCount,orgmaxNodeCount,unit->getPathfindFailedConsecutiveFrameCount()); //printf("AStar maxpath cut for unit [%d - %s] to %d [orig: %d] [unit->getPathfindFailedConsecutiveFrameCount(): %d]\n",unit->getId(),unit->getFullName().c_str(), maxNodeCount,orgmaxNodeCount,unit->getPathfindFailedConsecutiveFrameCount());
} }

View File

@ -822,10 +822,10 @@ void Commander::giveNetworkCommand(NetworkCommand* networkCommand) const {
NetworkManager &networkManager= NetworkManager::getInstance(); NetworkManager &networkManager= NetworkManager::getInstance();
NetworkRole role = networkManager.getNetworkRole(); NetworkRole role = networkManager.getNetworkRole();
GameSettings *settings = world->getGameSettingsPtr(); //GameSettings *settings = world->getGameSettingsPtr();
if(role == nrServer) { if(role == nrServer) {
int factionIndex = networkCommand->getUnitId(); //int factionIndex = networkCommand->getUnitId();
int playerIndex = networkCommand->getCommandTypeId(); int playerIndex = networkCommand->getCommandTypeId();
GameNetworkInterface *gameNetworkInterface= NetworkManager::getInstance().getGameNetworkInterface(); GameNetworkInterface *gameNetworkInterface= NetworkManager::getInstance().getGameNetworkInterface();

View File

@ -1742,7 +1742,7 @@ void Game::updateNetworkMarkedCells() {
if(gameNetworkInterface != NULL && if(gameNetworkInterface != NULL &&
gameNetworkInterface->getMarkedCellList(false).empty() == false) { gameNetworkInterface->getMarkedCellList(false).empty() == false) {
Lang &lang= Lang::getInstance(); //Lang &lang= Lang::getInstance();
std::vector<MarkedCell> chatList = gameNetworkInterface->getMarkedCellList(true); std::vector<MarkedCell> chatList = gameNetworkInterface->getMarkedCellList(true);
for(int idx = 0; idx < chatList.size(); idx++) { for(int idx = 0; idx < chatList.size(); idx++) {
@ -1769,7 +1769,7 @@ void Game::updateNetworkUnMarkedCells() {
if(gameNetworkInterface != NULL && if(gameNetworkInterface != NULL &&
gameNetworkInterface->getUnMarkedCellList(false).empty() == false) { gameNetworkInterface->getUnMarkedCellList(false).empty() == false) {
Lang &lang= Lang::getInstance(); //Lang &lang= Lang::getInstance();
std::vector<UnMarkedCell> chatList = gameNetworkInterface->getUnMarkedCellList(true); std::vector<UnMarkedCell> chatList = gameNetworkInterface->getUnMarkedCellList(true);
for(int idx = 0; idx < chatList.size(); idx++) { for(int idx = 0; idx < chatList.size(); idx++) {
@ -1805,7 +1805,7 @@ void Game::updateNetworkHighligtedCells() {
if(gameNetworkInterface != NULL && if(gameNetworkInterface != NULL &&
gameNetworkInterface->getHighlightedCellList(false).empty() == false) { gameNetworkInterface->getHighlightedCellList(false).empty() == false) {
Lang &lang= Lang::getInstance(); //Lang &lang= Lang::getInstance();
std::vector<MarkedCell> highlighList = gameNetworkInterface->getHighlightedCellList(true); std::vector<MarkedCell> highlighList = gameNetworkInterface->getHighlightedCellList(true);
for(int idx = 0; idx < highlighList.size(); idx++) { for(int idx = 0; idx < highlighList.size(); idx++) {
MarkedCell mc = highlighList[idx]; // I want a copy here MarkedCell mc = highlighList[idx]; // I want a copy here

View File

@ -389,7 +389,7 @@ void Renderer::init() {
if(glActiveTexture == NULL) { if(glActiveTexture == NULL) {
char szBuf[8096]=""; char szBuf[8096]="";
sprintf(szBuf,"Error: glActiveTexture == NULL\nglActiveTexture is only supported if the GL version is 1.3 or greater,\nor if the ARB_multitexture extension is supported!",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); sprintf(szBuf,"Error: glActiveTexture == NULL\nglActiveTexture is only supported if the GL version is 1.3 or greater,\nor if the ARB_multitexture extension is supported!");
throw megaglest_runtime_error(szBuf); throw megaglest_runtime_error(szBuf);
} }
@ -1024,7 +1024,7 @@ void Renderer::setupLightingForRotatedModel() {
} }
const World *world= game->getWorld(); const World *world= game->getWorld();
const GameCamera *gameCamera= game->getGameCamera(); //const GameCamera *gameCamera= game->getGameCamera();
const TimeFlow *timeFlow= world->getTimeFlow(); const TimeFlow *timeFlow= world->getTimeFlow();
float time= timeFlow->getTime(); float time= timeFlow->getTime();
@ -4842,7 +4842,7 @@ void Renderer::renderGhostModel(const UnitType *building, const Vec2i pos,Cardin
//const UnitType *building= gui->getBuilding(); //const UnitType *building= gui->getBuilding();
//const Vec2i &pos= gui->getPosObjWorld(); //const Vec2i &pos= gui->getPosObjWorld();
const Gui *gui= game->getGui(); //const Gui *gui= game->getGui();
//const Mouse3d *mouse3d= gui->getMouse3d(); //const Mouse3d *mouse3d= gui->getMouse3d();
const Map *map= game->getWorld()->getMap(); const Map *map= game->getWorld()->getMap();
if(map == NULL) { if(map == NULL) {
@ -5897,7 +5897,7 @@ void Renderer::renderHighlightedCellsOnMinimap() {
// Draw marked cells // Draw marked cells
const std::vector<MarkedCell> *highlightedCells = game->getHighlightedCells(); const std::vector<MarkedCell> *highlightedCells = game->getHighlightedCells();
if(highlightedCells->empty() == false) { if(highlightedCells->empty() == false) {
const Map *map= game->getWorld()->getMap(); //const Map *map= game->getWorld()->getMap();
const World *world= game->getWorld(); const World *world= game->getWorld();
const Minimap *minimap= world->getMinimap(); const Minimap *minimap= world->getMinimap();
int pointersize=10; int pointersize=10;
@ -5905,12 +5905,12 @@ void Renderer::renderHighlightedCellsOnMinimap() {
return; return;
} }
const GameCamera *gameCamera= game->getGameCamera(); //const GameCamera *gameCamera= game->getGameCamera();
const Pixmap2D *pixmap= minimap->getTexture()->getPixmapConst(); const Pixmap2D *pixmap= minimap->getTexture()->getPixmapConst();
const Metrics &metrics= Metrics::getInstance(); const Metrics &metrics= Metrics::getInstance();
int mx= metrics.getMinimapX(); //int mx= metrics.getMinimapX();
int my= metrics.getMinimapY(); int my= metrics.getMinimapY();
int mw= metrics.getMinimapW(); int mw= metrics.getMinimapW();
int mh= metrics.getMinimapH(); int mh= metrics.getMinimapH();
@ -5938,7 +5938,7 @@ void Renderer::renderMarkedCellsOnMinimap() {
// Draw marked cells // Draw marked cells
std::map<Vec2i, MarkedCell> markedCells = game->getMapMarkedCellList(); std::map<Vec2i, MarkedCell> markedCells = game->getMapMarkedCellList();
if(markedCells.empty() == false) { if(markedCells.empty() == false) {
const Map *map= game->getWorld()->getMap(); //const Map *map= game->getWorld()->getMap();
const World *world= game->getWorld(); const World *world= game->getWorld();
const Minimap *minimap= world->getMinimap(); const Minimap *minimap= world->getMinimap();
@ -5946,10 +5946,10 @@ void Renderer::renderMarkedCellsOnMinimap() {
return; return;
} }
const GameCamera *gameCamera= game->getGameCamera(); //const GameCamera *gameCamera= game->getGameCamera();
const Pixmap2D *pixmap= minimap->getTexture()->getPixmapConst(); const Pixmap2D *pixmap= minimap->getTexture()->getPixmapConst();
const Metrics &metrics= Metrics::getInstance(); const Metrics &metrics= Metrics::getInstance();
const WaterEffects *attackEffects= world->getAttackEffects(); //const WaterEffects *attackEffects= world->getAttackEffects();
int mx= metrics.getMinimapX(); int mx= metrics.getMinimapX();
int my= metrics.getMinimapY(); int my= metrics.getMinimapY();

View File

@ -3804,7 +3804,7 @@ void MenuStateConnectedGame::setupUIFromGameSettings(GameSettings *gameSettings,
//printf("currentFactionName_factionPreview [%s] random [%s] observer [%s] factionVideoUrl [%s]\n",currentFactionName_factionPreview.c_str(),GameConstants::RANDOMFACTION_SLOTNAME,GameConstants::OBSERVER_SLOTNAME,factionVideoUrl.c_str()); //printf("currentFactionName_factionPreview [%s] random [%s] observer [%s] factionVideoUrl [%s]\n",currentFactionName_factionPreview.c_str(),GameConstants::RANDOMFACTION_SLOTNAME,GameConstants::OBSERVER_SLOTNAME,factionVideoUrl.c_str());
if(factionVideoUrl != "") { if(factionVideoUrl != "") {
SoundRenderer &soundRenderer= SoundRenderer::getInstance(); //SoundRenderer &soundRenderer= SoundRenderer::getInstance();
if(CoreData::getInstance().getMenuMusic()->getVolume() != 0) { if(CoreData::getInstance().getMenuMusic()->getVolume() != 0) {
CoreData::getInstance().getMenuMusic()->setVolume(0); CoreData::getInstance().getMenuMusic()->setVolume(0);
factionVideoSwitchedOffVolume=true; factionVideoSwitchedOffVolume=true;
@ -3844,7 +3844,7 @@ void MenuStateConnectedGame::setupUIFromGameSettings(GameSettings *gameSettings,
} }
} }
else { else {
SoundRenderer &soundRenderer= SoundRenderer::getInstance(); //SoundRenderer &soundRenderer= SoundRenderer::getInstance();
//switch on music again!! //switch on music again!!
Config &config = Config::getInstance(); Config &config = Config::getInstance();
float configVolume = (config.getInt("SoundVolumeMusic") / 100.f); float configVolume = (config.getInt("SoundVolumeMusic") / 100.f);

View File

@ -2663,7 +2663,7 @@ void MenuStateCustomGame::update() {
//printf("currentFactionName_factionPreview [%s] random [%s] observer [%s] factionVideoUrl [%s]\n",currentFactionName_factionPreview.c_str(),GameConstants::RANDOMFACTION_SLOTNAME,GameConstants::OBSERVER_SLOTNAME,factionVideoUrl.c_str()); //printf("currentFactionName_factionPreview [%s] random [%s] observer [%s] factionVideoUrl [%s]\n",currentFactionName_factionPreview.c_str(),GameConstants::RANDOMFACTION_SLOTNAME,GameConstants::OBSERVER_SLOTNAME,factionVideoUrl.c_str());
if(factionVideoUrl != "") { if(factionVideoUrl != "") {
SoundRenderer &soundRenderer= SoundRenderer::getInstance(); //SoundRenderer &soundRenderer= SoundRenderer::getInstance();
if(CoreData::getInstance().getMenuMusic()->getVolume() != 0) { if(CoreData::getInstance().getMenuMusic()->getVolume() != 0) {
CoreData::getInstance().getMenuMusic()->setVolume(0); CoreData::getInstance().getMenuMusic()->setVolume(0);
factionVideoSwitchedOffVolume=true; factionVideoSwitchedOffVolume=true;
@ -2703,7 +2703,7 @@ void MenuStateCustomGame::update() {
} }
} }
else { else {
SoundRenderer &soundRenderer= SoundRenderer::getInstance(); //SoundRenderer &soundRenderer= SoundRenderer::getInstance();
//switch on music again!! //switch on music again!!
Config &config = Config::getInstance(); Config &config = Config::getInstance();
float configVolume = (config.getInt("SoundVolumeMusic") / 100.f); float configVolume = (config.getInt("SoundVolumeMusic") / 100.f);

View File

@ -2181,7 +2181,7 @@ void ServerInterface::validateGameSettings(GameSettings *serverGameSettings) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s]\n",__FILE__,__FUNCTION__); if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s]\n",__FILE__,__FUNCTION__);
string mapFile = serverGameSettings->getMap(); string mapFile = serverGameSettings->getMap();
bool useNext=false; //bool useNext=false;
printf("Trying to set map to [%s]. Current map is [%s]\n",serverGameSettings->getMap().c_str(),gameSettings.getMap().c_str()); printf("Trying to set map to [%s]. Current map is [%s]\n",serverGameSettings->getMap().c_str(),gameSettings.getMap().c_str());
if(find(mapFiles.begin(),mapFiles.end(),mapFile) == mapFiles.end()) { if(find(mapFiles.begin(),mapFiles.end(),mapFile) == mapFiles.end()) {
printf("map not found on this server\n"); printf("map not found on this server\n");

View File

@ -128,7 +128,7 @@ float FontMetrics::getTextWidth(const string &str) {
else { else {
vector<string> lineTokens; vector<string> lineTokens;
Tokenize(str,lineTokens,"\n"); Tokenize(str,lineTokens,"\n");
if(lineTokens.size() > 0) { if(lineTokens.empty() == false) {
for(unsigned int i = 0; i < lineTokens.size(); ++i) { for(unsigned int i = 0; i < lineTokens.size(); ++i) {
string currentStr = lineTokens[i]; string currentStr = lineTokens[i];
if(currentStr.length() > longestLine.length()) { if(currentStr.length() > longestLine.length()) {