- loads of code cleanup based on verbose output from the latest git version of cppcheck

This commit is contained in:
Mark Vejvoda 2012-10-06 07:06:40 +00:00
parent 2a80dd7c3c
commit 5e42c6dc03
37 changed files with 204 additions and 207 deletions

View File

@ -804,7 +804,7 @@ void MainWindow::onMouseMove(wxMouseEvent &event){
void MainWindow::onMenuFileLoad(wxCommandEvent &event){
try {
string fileName;
//string fileName;
fileDialog->SetWildcard(wxT("G3D files (*.g3d)|*.g3d;*.G3D"));
fileDialog->SetMessage(wxT("Selecting Glest Model for current view."));
@ -834,7 +834,7 @@ void MainWindow::onMenuFileLoad(wxCommandEvent &event){
void MainWindow::onMenuFileLoadParticleXML(wxCommandEvent &event){
try {
string fileName;
//string fileName;
fileDialog->SetWildcard(wxT("XML files (*.xml)|*.xml"));
if(isControlKeyPressed == true) {
@ -868,7 +868,7 @@ void MainWindow::onMenuFileLoadParticleXML(wxCommandEvent &event){
void MainWindow::onMenuFileLoadProjectileParticleXML(wxCommandEvent &event){
try {
string fileName;
//string fileName;
fileDialog->SetWildcard(wxT("XML files (*.xml)|*.xml"));
if(isControlKeyPressed == true) {
@ -902,7 +902,7 @@ void MainWindow::onMenuFileLoadProjectileParticleXML(wxCommandEvent &event){
void MainWindow::onMenuFileLoadSplashParticleXML(wxCommandEvent &event){
try {
string fileName;
//string fileName;
fileDialog->SetWildcard(wxT("XML files (*.xml)|*.xml"));
if(isControlKeyPressed == true) {
@ -1411,7 +1411,7 @@ void MainWindow::loadProjectileParticle(string path) {
int height = 1;
if(fileExists(unitXML) == true) {
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] loading [%s] idx = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,unitXML.c_str(),idx);
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] loading [%s] idx = %u\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,unitXML.c_str(),idx);
XmlTree xmlTree;
xmlTree.load(unitXML,Properties::getTagReplacementValues());
@ -1427,7 +1427,7 @@ void MainWindow::loadProjectileParticle(string path) {
string particleFile = dir + folderDelimiter + particlePath;
{
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] loading [%s] idx = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,particleFile.c_str(),idx);
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] loading [%s] idx = %u\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,particleFile.c_str(),idx);
XmlTree xmlTree;
xmlTree.load(particleFile,Properties::getTagReplacementValues());
//const XmlNode *particleSystemNode= xmlTree.getRootNode();
@ -1435,7 +1435,7 @@ void MainWindow::loadProjectileParticle(string path) {
// std::cout << "Loaded successfully, loading values..." << std::endl;
}
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] loading [%s] idx = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,particleFile.c_str(),idx);
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] loading [%s] idx = %u\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,particleFile.c_str(),idx);
std::map<string,vector<pair<string, string> > > loadedFileList;
ParticleSystemTypeProjectile *projectileParticleSystemType= new ParticleSystemTypeProjectile();
projectileParticleSystemType->load(NULL, dir, //### we don't know if there are overrides in the unit XML
@ -1466,7 +1466,7 @@ void MainWindow::loadProjectileParticle(string path) {
renderer->manageParticleSystem(ps);
}
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] loaded [%s] idx = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,particleFile.c_str(),idx);
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] loaded [%s] idx = %u\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,particleFile.c_str(),idx);
}
SetTitle(ToUnicode(titlestring));

View File

@ -729,9 +729,9 @@ void AiInterface::loadGame(const XmlNode *rootNode, Faction *faction) {
timer = aiInterfaceNode->getAttribute("timer")->getIntValue();
// int factionIndex;
factionIndex = aiInterfaceNode->getAttribute("factionIndex")->getIntValue();
//factionIndex = aiInterfaceNode->getAttribute("factionIndex")->getIntValue();
// int teamIndex;
teamIndex = aiInterfaceNode->getAttribute("teamIndex")->getIntValue();
//teamIndex = aiInterfaceNode->getAttribute("teamIndex")->getIntValue();
// //config
// bool redir;
redir = aiInterfaceNode->getAttribute("redir")->getIntValue() != 0;

View File

@ -921,8 +921,8 @@ void AiRuleProduce::produceSpecific(const ProduceTask *pt){
int currentProducerIndex = producers[i];
if(currentProducerIndex >= aiInterface->getMyUnitCount()) {
char szBuf[1024]="";
printf("In [%s::%s Line: %d] currentProducerIndex >= aiInterface->getMyUnitCount(), currentProducerIndex = %d, aiInterface->getMyUnitCount() = %d, i = %d,producers.size() = %lu\n",__FILE__,__FUNCTION__,__LINE__,currentProducerIndex,aiInterface->getMyUnitCount(),i,(unsigned long)producers.size());
sprintf(szBuf,"In [%s::%s Line: %d] currentProducerIndex >= aiInterface->getMyUnitCount(), currentProducerIndex = %d, aiInterface->getMyUnitCount() = %d, i = %d,producers.size() = %lu",__FILE__,__FUNCTION__,__LINE__,currentProducerIndex,aiInterface->getMyUnitCount(),i,(unsigned long)producers.size());
printf("In [%s::%s Line: %d] currentProducerIndex >= aiInterface->getMyUnitCount(), currentProducerIndex = %d, aiInterface->getMyUnitCount() = %d, i = %u,producers.size() = %lu\n",__FILE__,__FUNCTION__,__LINE__,currentProducerIndex,aiInterface->getMyUnitCount(),i,(unsigned long)producers.size());
sprintf(szBuf,"In [%s::%s Line: %d] currentProducerIndex >= aiInterface->getMyUnitCount(), currentProducerIndex = %d, aiInterface->getMyUnitCount() = %u, i = %u,producers.size() = %lu",__FILE__,__FUNCTION__,__LINE__,currentProducerIndex,aiInterface->getMyUnitCount(),i,(unsigned long)producers.size());
throw megaglest_runtime_error(szBuf);
}
@ -953,14 +953,14 @@ void AiRuleProduce::produceSpecific(const ProduceTask *pt){
if(currentProducerIndex >= aiInterface->getMyUnitCount()) {
char szBuf[1024]="";
printf("In [%s::%s Line: %d] currentProducerIndex >= aiInterface->getMyUnitCount(), currentProducerIndex = %d, aiInterface->getMyUnitCount() = %d, i = %d,producers.size() = %lu\n",__FILE__,__FUNCTION__,__LINE__,currentProducerIndex,aiInterface->getMyUnitCount(),i,(unsigned long)producers.size());
sprintf(szBuf,"In [%s::%s Line: %d] currentProducerIndex >= aiInterface->getMyUnitCount(), currentProducerIndex = %d, aiInterface->getMyUnitCount() = %d, i = %d,producers.size() = %lu",__FILE__,__FUNCTION__,__LINE__,currentProducerIndex,aiInterface->getMyUnitCount(),i,(unsigned long)producers.size());
printf("In [%s::%s Line: %d] currentProducerIndex >= aiInterface->getMyUnitCount(), currentProducerIndex = %d, aiInterface->getMyUnitCount() = %d, i = %u,producers.size() = %lu\n",__FILE__,__FUNCTION__,__LINE__,currentProducerIndex,aiInterface->getMyUnitCount(),i,(unsigned long)producers.size());
sprintf(szBuf,"In [%s::%s Line: %d] currentProducerIndex >= aiInterface->getMyUnitCount(), currentProducerIndex = %d, aiInterface->getMyUnitCount() = %u, i = %u,producers.size() = %lu",__FILE__,__FUNCTION__,__LINE__,currentProducerIndex,aiInterface->getMyUnitCount(),i,(unsigned long)producers.size());
throw megaglest_runtime_error(szBuf);
}
if(prIndex >= producers.size()) {
char szBuf[1024]="";
printf("In [%s::%s Line: %d] prIndex >= producers.size(), currentProducerIndex = %d, i = %d,producers.size() = %lu \n",__FILE__,__FUNCTION__,__LINE__,prIndex,i,(unsigned long)producers.size());
sprintf(szBuf,"In [%s::%s Line: %d] currentProducerIndex >= producers.size(), currentProducerIndex = %d, i = %d,producers.size() = %lu",__FILE__,__FUNCTION__,__LINE__,currentProducerIndex,i,(unsigned long)producers.size());
printf("In [%s::%s Line: %d] prIndex >= producers.size(), currentProducerIndex = %d, i = %u,producers.size() = %lu \n",__FILE__,__FUNCTION__,__LINE__,prIndex,i,(unsigned long)producers.size());
sprintf(szBuf,"In [%s::%s Line: %d] currentProducerIndex >= producers.size(), currentProducerIndex = %d, i = %u,producers.size() = %lu",__FILE__,__FUNCTION__,__LINE__,currentProducerIndex,i,(unsigned long)producers.size());
throw megaglest_runtime_error(szBuf);
}
@ -1019,14 +1019,14 @@ void AiRuleProduce::produceSpecific(const ProduceTask *pt){
if(currentProducerIndex >= aiInterface->getMyUnitCount()) {
char szBuf[1024]="";
printf("In [%s::%s Line: %d] currentProducerIndex >= aiInterface->getMyUnitCount(), currentProducerIndex = %d, aiInterface->getMyUnitCount() = %d, i = %d,backupProducers.size() = %lu\n",__FILE__,__FUNCTION__,__LINE__,currentProducerIndex,aiInterface->getMyUnitCount(),i,(unsigned long)backupProducers.size());
sprintf(szBuf,"In [%s::%s Line: %d] currentProducerIndex >= aiInterface->getMyUnitCount(), currentProducerIndex = %d, aiInterface->getMyUnitCount() = %d, i = %d,backupProducers.size() = %lu",__FILE__,__FUNCTION__,__LINE__,currentProducerIndex,aiInterface->getMyUnitCount(),i,(unsigned long)backupProducers.size());
printf("In [%s::%s Line: %d] currentProducerIndex >= aiInterface->getMyUnitCount(), currentProducerIndex = %d, aiInterface->getMyUnitCount() = %d, i = %u,backupProducers.size() = %lu\n",__FILE__,__FUNCTION__,__LINE__,currentProducerIndex,aiInterface->getMyUnitCount(),i,(unsigned long)backupProducers.size());
sprintf(szBuf,"In [%s::%s Line: %d] currentProducerIndex >= aiInterface->getMyUnitCount(), currentProducerIndex = %d, aiInterface->getMyUnitCount() = %d, i = %u,backupProducers.size() = %lu",__FILE__,__FUNCTION__,__LINE__,currentProducerIndex,aiInterface->getMyUnitCount(),i,(unsigned long)backupProducers.size());
throw megaglest_runtime_error(szBuf);
}
if(prIndex >= backupProducers.size()) {
char szBuf[1024]="";
printf("In [%s::%s Line: %d] prIndex >= backupProducers.size(), currentProducerIndex = %d, i = %d,backupProducers.size() = %lu \n",__FILE__,__FUNCTION__,__LINE__,prIndex,i,(unsigned long)backupProducers.size());
sprintf(szBuf,"In [%s::%s Line: %d] currentProducerIndex >= backupProducers.size(), currentProducerIndex = %d, i = %d,backupProducers.size() = %lu",__FILE__,__FUNCTION__,__LINE__,currentProducerIndex,i,(unsigned long)backupProducers.size());
printf("In [%s::%s Line: %d] prIndex >= backupProducers.size(), currentProducerIndex = %d, i = %u,backupProducers.size() = %lu \n",__FILE__,__FUNCTION__,__LINE__,prIndex,i,(unsigned long)backupProducers.size());
sprintf(szBuf,"In [%s::%s Line: %d] currentProducerIndex >= backupProducers.size(), currentProducerIndex = %d, i = %u,backupProducers.size() = %lu",__FILE__,__FUNCTION__,__LINE__,currentProducerIndex,i,(unsigned long)backupProducers.size());
throw megaglest_runtime_error(szBuf);
}
@ -1392,7 +1392,7 @@ void AiRuleBuild::buildSpecific(const BuildTask *bt) {
if(ai->getAiInterface()->isFreeCells(tryPos - Vec2i(spacing), bt->getUnitType()->getSize() + spacing * 2, fLand)) {
enemies.clear();
ai->getAiInterface()->getWorld()->getUnitUpdater()->findEnemiesForCell(tryPos,bt->getUnitType()->getSize(),enemySightDistanceToAvoid,ai->getAiInterface()->getMyFaction(),enemies,true);
if(enemies.size() <= 0) {
if(enemies.empty() == true) {
searchPos = tryPos;
}
}
@ -1408,7 +1408,7 @@ void AiRuleBuild::buildSpecific(const BuildTask *bt) {
if(ai->getAiInterface()->isFreeCells(tryPos - Vec2i(spacing), bt->getUnitType()->getSize() + spacing * 2, fLand)) {
enemies.clear();
ai->getAiInterface()->getWorld()->getUnitUpdater()->findEnemiesForCell(tryPos,bt->getUnitType()->getSize(),enemySightDistanceToAvoid,ai->getAiInterface()->getMyFaction(),enemies,true);
if(enemies.size() <= 0) {
if(enemies.empty() == true) {
searchPos = tryPos;
}
}

View File

@ -287,7 +287,7 @@ private:
//bool canUnitMoveSoon(const Unit *unit, const Vec2i &pos1, const Vec2i &pos2);
inline bool canUnitMoveSoon(const Unit *unit, const Vec2i &pos1, const Vec2i &pos2) {
bool result = true;
//bool result = true;
// std::map<int,std::map<Field,BadUnitNodeList> > &badCellList = factions[unit->getFactionIndex()].badCellList;
// if(badCellList.find(unit->getType()->getSize()) != badCellList.end()) {
@ -308,7 +308,7 @@ private:
// }
// }
result = map->aproxCanMoveSoon(unit, pos1, pos2);
bool result = map->aproxCanMoveSoon(unit, pos1, pos2);
return result;
}

View File

@ -42,12 +42,14 @@ string getCrashDumpFileName(){
}
string getPlatformNameString() {
static string platform = "";
static string platform;
if(platform == "") {
#if defined(WIN32)
platform = "Windows";
#if defined(__MINGW32__)
platform = "W-MINGW";
#else
platform = "Windows";
#endif
#elif defined(__FreeBSD__)
@ -55,9 +57,11 @@ string getPlatformNameString() {
#elif defined(__APPLE__)
platform = "MacOSX";
#elif defined(__GNUC__)
platform = "GNU";
#if defined(__MINGW32__)
platform = "L-MINGW";
#else
platform = "GNU";
#endif
#else

View File

@ -281,7 +281,7 @@ void Logger::renderLoadingScreen() {
void Logger::setCancelLoadingEnabled(bool value) {
Lang &lang= Lang::getInstance();
const Metrics &metrics= Metrics::getInstance();
string containerName = "logger";
//string containerName = "logger";
//buttonCancel.registerGraphicComponent(containerName,"buttonCancel");
buttonCancel.init((metrics.getVirtualW() / 2) - (125 / 2), 50 * metrics.getVirtualH() / 100, 125);
buttonCancel.setText(lang.get("Cancel"));

View File

@ -136,7 +136,7 @@ void ChatManager::keyDown(SDL_KeyboardEvent key) {
if(text.empty() == false) {
if(customCB == NULL) {
string playerName = gameNetworkInterface->getHumanPlayerName();
//string playerName = gameNetworkInterface->getHumanPlayerName();
int playerIndex = gameNetworkInterface->getHumanPlayerIndex();
if(this->manualPlayerNameOverride != "") {

View File

@ -768,7 +768,7 @@ vector<Texture2D *> Game::processTech(string techName) {
vector<Texture2D *> logoFiles;
bool enableFactionTexturePreview = Config::getInstance().getBool("FactionPreview","true");
if(enableFactionTexturePreview) {
string currentTechName_factionPreview = techName;
//string currentTechName_factionPreview = techName;
vector<string> factions;
vector<string> techPaths = Config::getInstance().getPathListForType(ptTechs);
@ -780,10 +780,9 @@ vector<Texture2D *> Game::processTech(string techName) {
if(factions.empty() == false) {
for(unsigned int factionIdx = 0; factionIdx < factions.size(); ++factionIdx) {
bool loadingImageUsed = false;
string factionLogo = "";
string currentFactionName_factionPreview = factions[factionIdx];
factionLogo = Game::extractFactionLogoFile(
string factionLogo = Game::extractFactionLogoFile(
loadingImageUsed,
currentFactionName_factionPreview,
"",
@ -1612,7 +1611,7 @@ void Game::update() {
bool keepFactions = world.getQueuedScenarioKeepFactions();
world.setQueuedScenario("",false);
vector<string> results;
//vector<string> results;
const vector<string> &dirList = Config::getInstance().getPathListForType(ptScenarios);
string scenarioFile = Scenario::getScenarioPath(dirList, name);
@ -2491,34 +2490,34 @@ void Game::mouseDownLeft(int x, int y) {
popupMenuSwitchTeams.setEnabled(false);
popupMenuSwitchTeams.setVisible(false);
bool isNetworkGame = this->gameSettings.isNetworkGame();
//bool isNetworkGame = this->gameSettings.isNetworkGame();
int teamIndex = switchTeamIndexMap[result.first];
switch(teamIndex) {
case CREATE_NEW_TEAM:
{
int newTeam = getFirstUnusedTeamNumber();
if(isNetworkGame == true) {
//if(isNetworkGame == true) {
const Faction *faction = world.getThisFaction();
commander.trySwitchTeam(faction,newTeam);
}
else {
const Faction *faction = world.getThisFaction();
commander.trySwitchTeam(faction,newTeam);
}
//}
//else {
// const Faction *faction = world.getThisFaction();
// commander.trySwitchTeam(faction,newTeam);
//}
}
break;
case CANCEL_SWITCH_TEAM:
break;
default:
if(isNetworkGame == true) {
//if(isNetworkGame == true) {
const Faction *faction = world.getThisFaction();
commander.trySwitchTeam(faction,teamIndex);
}
else {
const Faction *faction = world.getThisFaction();
commander.trySwitchTeam(faction,teamIndex);
}
//}
//else {
// const Faction *faction = world.getThisFaction();
// commander.trySwitchTeam(faction,teamIndex);
//}
break;
}
@ -2746,7 +2745,6 @@ void Game::mouseDownLeft(int x, int y) {
Vec2i surfaceCellPos = map->toSurfCoords(targetPos);
MarkedCell mc(targetPos,world.getThisFaction(),"placeholder for note",world.getThisFaction()->getStartLocationIndex());
cellMarkedData = mc;
//printf("#2 ADDED in marked list pos [%s] markedCells.size() = %lu\n",surfaceCellPos.getString().c_str(),mapMarkedCellList.size());
@ -3027,11 +3025,12 @@ void Game::mouseMove(int x, int y, const MouseState *ms) {
{
//float ymult = Config::getInstance().getCameraInvertYAxis() ? -0.2f : 0.2f;
//float xmult = Config::getInstance().getCameraInvertXAxis() ? -0.2f : 0.2f;
float ymult = 0.2f;
float xmult = 0.2f;
//if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
if(currentCameraFollowUnit==NULL){
float ymult = 0.2f;
float xmult = 0.2f;
gameCamera.transitionVH(-(y - lastMousePos.y) * ymult, (lastMousePos.x - x) * xmult);
}
mouseX=lastMousePos.x;

View File

@ -2063,7 +2063,6 @@ int ScriptManager::DisplayFormattedText(LuaHandle* luaHandle) {
//lua_lock(luaHandle);
//luaC_checkGC(luaHandle);
const int max_args_allowed = 8;
int args = lua_gettop(luaHandle);
if(lua_checkstack(luaHandle, args+1)) {
LuaArguments luaArguments(luaHandle);
@ -2073,6 +2072,7 @@ int ScriptManager::DisplayFormattedText(LuaHandle* luaHandle) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugLUA).enabled) SystemFlags::OutputDebug(SystemFlags::debugLUA,"DisplayFormattedText args = %d!\n",args);
const int max_args_allowed = 8;
if(args == 1) {
thisScriptManager->DisplayFormattedText(fmt.c_str());
}
@ -2171,7 +2171,6 @@ if(SystemFlags::getSystemSettingType(SystemFlags::debugLUA).enabled) SystemFlags
//lua_lock(luaHandle);
//luaC_checkGC(luaHandle);
const int max_args_allowed = 8;
int args = lua_gettop(luaHandle);
if(lua_checkstack(luaHandle, args+1)) {
LuaArguments luaArguments(luaHandle);
@ -2181,6 +2180,7 @@ if(SystemFlags::getSystemSettingType(SystemFlags::debugLUA).enabled) SystemFlags
if(SystemFlags::getSystemSettingType(SystemFlags::debugLUA).enabled) SystemFlags::OutputDebug(SystemFlags::debugLUA,"DisplayFormattedText args = %d!\n",args);
const int max_args_allowed = 8;
if(args == 1) {
thisScriptManager->addConsoleLangText(Lang::getInstance().getScenarioString(fmt).c_str());
}
@ -2252,7 +2252,6 @@ int ScriptManager::DisplayFormattedLangText(LuaHandle* luaHandle) {
//lua_lock(luaHandle);
//luaC_checkGC(luaHandle);
const int max_args_allowed = 8;
int args = lua_gettop(luaHandle);
if(lua_checkstack(luaHandle, args+1)) {
LuaArguments luaArguments(luaHandle);
@ -2262,6 +2261,7 @@ int ScriptManager::DisplayFormattedLangText(LuaHandle* luaHandle) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugLUA).enabled) SystemFlags::OutputDebug(SystemFlags::debugLUA,"DisplayFormattedText args = %d!\n",args);
const int max_args_allowed = 8;
if(args == 1) {
thisScriptManager->DisplayFormattedLangText(Lang::getInstance().getScenarioString(fmt).c_str());
}

View File

@ -18,7 +18,7 @@ namespace Glest{ namespace Game{
PlayerStats::PlayerStats() {
control = ctClosed;
resourceMultiplier=1.0f;
factionTypeName = "";
//factionTypeName = "";
personalityType = fpt_Normal;
teamIndex = 0;
victory = false;
@ -27,7 +27,7 @@ PlayerStats::PlayerStats() {
deaths = 0;
unitsProduced = 0;
resourcesHarvested = 0;
playerName = "";
//playerName = "";
playerLeftBeforeEnd = false;
timePlayerLeft = -1;
playerColor = Vec3f(0,0,0);
@ -108,7 +108,7 @@ string PlayerStats::getStats() const {
// class Stats
// =====================================================
void Stats::init(int factionCount, int thisFactionIndex, const string& description, const string techName) {
void Stats::init(int factionCount, int thisFactionIndex, const string& description, const string &techName) {
this->thisFactionIndex= thisFactionIndex;
this->factionCount= factionCount;
this->description= description;

View File

@ -78,7 +78,7 @@ private:
public:
Stats() {
description = "";
//description = "";
factionCount = 0;
thisFactionIndex = 0;
@ -89,11 +89,11 @@ public:
totalEndGameConcurrentUnitCount = 0;
isMasterserverMode = false;
timePlayed = 0;
techName = "";
//techName = "";
}
void init(int factionCount, int thisFactionIndex, const string &description,
const string techName);
const string &techName);
string getDescription() const {return description;}
int getThisFactionIndex() const {return thisFactionIndex;}

View File

@ -343,13 +343,15 @@ bool Lang::hasString(const string &s, string uselanguage, bool fallbackToDefault
if(otherLanguageStrings.find(uselanguage) == otherLanguageStrings.end()) {
loadStrings(uselanguage, otherLanguageStrings[uselanguage], false);
}
string result2 = otherLanguageStrings[uselanguage].getString(s);
//string result2 = otherLanguageStrings[uselanguage].getString(s);
otherLanguageStrings[uselanguage].getString(s);
//printf("#b result2 [%s]\n",result2.c_str());
result = true;
}
else {
string result2 = strings.getString(s);
//string result2 = strings.getString(s);
strings.getString(s);
result = true;
}
}

View File

@ -43,6 +43,11 @@ bool Renderer::renderText3DEnabled = true;
const float SKIP_INTERPOLATION_DISTANCE = 20.0f;
const string DEFAULT_CHAR_FOR_WIDTH_CALC = "V";
enum PROJECTION_TO_INFINITY {
pti_D_IS_ZERO,
pti_N_OVER_D_IS_OUTSIDE
};
// =====================================================
// class MeshCallbackTeamColor
// =====================================================
@ -1069,11 +1074,6 @@ void Renderer::loadCameraMatrix(const Camera *camera) {
glTranslatef(-position.x, -position.y, -position.z);
}
enum PROJECTION_TO_INFINITY {
D_IS_ZERO,
N_OVER_D_IS_OUTSIDE
};
static Vec2i _unprojectMap(const Vec2i& pt,const GLdouble* model,const GLdouble* projection,const GLint* viewport,const char* label=NULL) {
Vec3d a,b;
/* note viewport[3] is height of window in pixels */
@ -1139,11 +1139,11 @@ static Vec2i _unprojectMap(const Vec2i& pt,const GLdouble* model,const GLdouble*
#else
if(fabs(d) < 0.00001)
#endif
throw D_IS_ZERO;
throw pti_D_IS_ZERO;
const float nd = -(norm.x*w.x + norm.y*w.y + norm.z*w.z) / d;
if(nd < 0.0 || nd >= 1.0)
throw N_OVER_D_IS_OUTSIDE;
throw pti_N_OVER_D_IS_OUTSIDE;
const Vec3f i = start + u*nd;
//const Vec2i pos(i.x,i.z);
@ -1521,7 +1521,7 @@ void Renderer::computeVisibleQuad() {
visibleQuad.p[3].x,visibleQuad.p[3].y);
for(unsigned int i = 0; i < quadCache.frustumData.size(); ++i) {
printf("\nFrustrum #%d [%lu]: ",i,quadCache.frustumData.size());
printf("\nFrustrum #%u [%lu]: ",i,quadCache.frustumData.size());
vector<float> &frustumDataInner = quadCache.frustumData[i];
for(unsigned int j = 0; j < frustumDataInner.size(); ++j) {
printf("[%f]",quadCache.frustumData[i][j]);
@ -1704,14 +1704,12 @@ void Renderer::renderMouse2d(int x, int y, int anim, float fade) {
}
}
float color1 = 0.0, color2 = 0.0;
float fadeFactor = fade + 1.f;
anim= anim * 2 - maxMouse2dAnim;
color2= (abs(anim*(int)fadeFactor)/static_cast<float>(maxMouse2dAnim))/2.f+0.4f;
color1= (abs(anim*(int)fadeFactor)/static_cast<float>(maxMouse2dAnim))/2.f+0.8f;
float color2= (abs(anim*(int)fadeFactor)/static_cast<float>(maxMouse2dAnim))/2.f+0.4f;
float color1= (abs(anim*(int)fadeFactor)/static_cast<float>(maxMouse2dAnim))/2.f+0.8f;
glPushAttrib(GL_CURRENT_BIT | GL_COLOR_BUFFER_BIT | GL_LINE_BIT);
glEnable(GL_BLEND);
@ -4914,10 +4912,9 @@ void Renderer::renderUnits(const int renderFps) {
//}
}
bool modelRenderStarted = false;
VisibleQuadContainerCache &qCache = getQuadCache();
if(qCache.visibleQuadUnitList.empty() == false) {
bool modelRenderStarted = false;
for(int visibleUnitIndex = 0;
visibleUnitIndex < qCache.visibleQuadUnitList.size(); ++visibleUnitIndex) {
Unit *unit = qCache.visibleQuadUnitList[visibleUnitIndex];
@ -5861,8 +5858,8 @@ void Renderer::renderMinimap(){
glEnable(GL_BLEND);
int x1 = 0;
int y1 = 0;
int x1;
int y1;
#ifdef USE_STREFLOP
x1 = mx + x + static_cast<int>(20*streflop::sin(static_cast<streflop::Simple>(ang-pi/5)));
y1 = my + mh - (y-static_cast<int>(20*streflop::cos(static_cast<streflop::Simple>(ang-pi/5))));
@ -5871,8 +5868,8 @@ void Renderer::renderMinimap(){
y1 = my + mh - (y-static_cast<int>(20*cos(ang-pi/5)));
#endif
int x2 = 0;
int y2 = 0;
int x2;
int y2;
#ifdef USE_STREFLOP
x2 = mx + x + static_cast<int>(20*streflop::sin(static_cast<streflop::Simple>(ang+pi/5)));
y2 = my + mh - (y-static_cast<int>(20*streflop::cos(static_cast<streflop::Simple>(ang+pi/5))));
@ -7337,9 +7334,9 @@ vector<Unit *> Renderer::renderUnitsFast(bool renderingShadows, bool colorPickin
//assertGl();
bool modelRenderStarted = false;
VisibleQuadContainerCache &qCache = getQuadCache();
if(qCache.visibleQuadUnitList.empty() == false) {
bool modelRenderStarted = false;
for(int visibleUnitIndex = 0;
visibleUnitIndex < qCache.visibleQuadUnitList.size(); ++visibleUnitIndex) {
Unit *unit = qCache.visibleQuadUnitList[visibleUnitIndex];
@ -7467,10 +7464,9 @@ vector<Object *> Renderer::renderObjectsFast(bool renderingShadows, bool resour
assertGl();
bool modelRenderStarted = false;
VisibleQuadContainerCache &qCache = getQuadCache();
if(qCache.visibleObjectList.empty() == false) {
bool modelRenderStarted = false;
for(int visibleIndex = 0;
visibleIndex < qCache.visibleObjectList.size(); ++visibleIndex) {
Object *o = qCache.visibleObjectList[visibleIndex];
@ -8149,9 +8145,9 @@ void Renderer::renderProgressBar3D(int size, int x, int y, Font3D *font, int cus
currentSize = (int)((double)customWidth * ((double)size / 100.0));
}
maxSize = customWidth;
if(maxSize <= 0) {
maxSize = maxProgressBar;
}
//if(maxSize <= 0) {
// maxSize = maxProgressBar;
//}
}
if(prefixLabel != "") {
renderText = prefixLabel + renderText;
@ -8201,9 +8197,9 @@ void Renderer::renderProgressBar(int size, int x, int y, Font2D *font, int custo
currentSize = (int)((double)customWidth * ((double)size / 100.0));
}
maxSize = customWidth;
if(maxSize <= 0) {
maxSize = maxProgressBar;
}
//if(maxSize <= 0) {
// maxSize = maxProgressBar;
//}
}
if(prefixLabel != "") {
renderText = prefixLabel + renderText;
@ -8410,7 +8406,7 @@ void Renderer::renderUnitTitles3D(Font3D *font, Vec3f color) {
return;
}
std::map<int,bool> unitRenderedList;
//std::map<int,bool> unitRenderedList;
if(visibleFrameUnitList.empty() == false) {
//printf("Render Unit titles ON\n");
@ -8428,7 +8424,7 @@ void Renderer::renderUnitTitles3D(Font3D *font, Vec3f color) {
renderText3D(unit->getCurrentUnitTitle(), font, color, fabs(screenPos.x) + 5, fabs(screenPos.y) + 5, false);
#endif
unitRenderedList[unit->getId()] = true;
//unitRenderedList[unit->getId()] = true;
}
else {
string str = unit->getFullName() + " - " + intToStr(unit->getId()) + " [" + unit->getPos().getString() + "]";
@ -8473,7 +8469,7 @@ void Renderer::renderUnitTitles(Font2D *font, Vec3f color) {
return;
}
std::map<int,bool> unitRenderedList;
//std::map<int,bool> unitRenderedList;
if(visibleFrameUnitList.empty() == false) {
//printf("Render Unit titles ON\n");
@ -8490,7 +8486,7 @@ void Renderer::renderUnitTitles(Font2D *font, Vec3f color) {
renderText(unit->getCurrentUnitTitle(), font, color, fabs(screenPos.x) + 5, fabs(screenPos.y) + 5, false);
#endif
unitRenderedList[unit->getId()] = true;
//unitRenderedList[unit->getId()] = true;
}
else {
string str = unit->getFullName() + " - " + intToStr(unit->getId()) + " [" + unit->getPos().getString() + "]";
@ -9457,16 +9453,13 @@ void Renderer::renderVideoLoading(int progressPercent) {
static Chrono cycle(true);
static float anim = 0.0f;
static bool animCycleUp = true;
if(CoreData::getInstance().getMenuFontBig3D() != NULL) {
int renderX = 0;
int renderY = 0;
int w= metrics.getVirtualW();
renderX = (w / 2) - (CoreData::getInstance().getMenuFontBig3D()->getMetrics()->getTextWidth(textToRender) / 2);
int renderX = (w / 2) - (CoreData::getInstance().getMenuFontBig3D()->getMetrics()->getTextWidth(textToRender) / 2);
int h= metrics.getVirtualH();
renderY = (h / 2) + (CoreData::getInstance().getMenuFontBig3D()->getMetrics()->getHeight(textToRender) / 2);
int renderY = (h / 2) + (CoreData::getInstance().getMenuFontBig3D()->getMetrics()->getHeight(textToRender) / 2);
renderText3D(
textToRender,
@ -9484,6 +9477,7 @@ void Renderer::renderVideoLoading(int progressPercent) {
swapBuffers();
if(cycle.getCurMillis() % 50 == 0) {
static bool animCycleUp = true;
if(animCycleUp == true) {
anim += 0.1;
if(anim > 1.f) {

View File

@ -353,7 +353,7 @@ const string BattleEnd::getTimeString(int frames) {
int minutes=(int) framesleft / (float)GameConstants::updateFps / 60.0;
framesleft=framesleft-minutes*60*GameConstants::updateFps;
int seconds=(int) framesleft / (float)GameConstants::updateFps;
framesleft=framesleft-seconds*GameConstants::updateFps;
//framesleft=framesleft-seconds*GameConstants::updateFps;
string hourstr=intToStr(hours);
if(hours<10) hourstr="0"+hourstr;

View File

@ -216,7 +216,7 @@ Intro::Intro(Program *program):
}
}
if(models.size() == 0) {
if(models.empty() == true) {
introPath = data_path + "data/core/menu/main_model/intro*.g3d";
//vector<string> introModels;
findAll(introPath, introModels, false, false);

View File

@ -1278,7 +1278,7 @@ void setupLogging(Config &config, bool haveSpecialOutputCommandLineOption) {
void runTilesetValidationForPath(string tilesetPath, string tilesetName,
World &world, bool purgeUnusedFiles,bool purgeDuplicateFiles,
bool showDuplicateFiles, bool svnPurgeFiles,double &purgedMegaBytes) {
string file = tilesetPath + tilesetName + "/" + tilesetName + ".xml";
//string file = tilesetPath + tilesetName + "/" + tilesetName + ".xml";
Checksum checksum;
bool techtree_errors = false;
@ -1940,7 +1940,7 @@ void runTechValidationForPath(string techPath, string techName,
if(fileExt == "wav" || fileExt == "ogg") {
off_t fileSize = getFileSize(duplicateFile);
printf("#1 [%d / %lu] removing duplicate [%s]\n",idx,fileList.size(),duplicateFile.c_str());
printf("#1 [%u / %lu] removing duplicate [%s]\n",idx,fileList.size(),duplicateFile.c_str());
if(idx == 0) {
newCommonFileName = "$COMMONDATAPATH/sounds/" + extractFileFromDirectoryPath(duplicateFile);
@ -2166,6 +2166,7 @@ void runTechValidationReport(int argc, char** argv) {
// Did the user pass a specific scenario to validate?
if(hasCommandArgument(argc, argv,string(GAME_ARGS[GAME_ARG_VALIDATE_SCENARIO]) + string("=")) == true) {
int foundParamIndIndex = -1;
hasCommandArgument(argc, argv,string(GAME_ARGS[GAME_ARG_VALIDATE_SCENARIO]) + string("="),&foundParamIndIndex);
@ -2174,7 +2175,7 @@ void runTechValidationReport(int argc, char** argv) {
Tokenize(filterList,paramPartTokens,"=");
if(paramPartTokens.size() >= 2) {
vector<string> optionList;
//vector<string> optionList;
string validateScenarioName = paramPartTokens[1];
printf("Filtering scenario: %s\n",validateScenarioName.c_str());
@ -2191,7 +2192,7 @@ void runTechValidationReport(int argc, char** argv) {
bool scenarioFound = false;
World world;
double purgedMegaBytes=0;
//double purgedMegaBytes=0;
std::vector<string> filteredFactionList;
vector<string> scenarioPaths = config.getPathListForType(ptScenarios);
@ -2416,9 +2417,6 @@ void runTilesetValidationReport(int argc, char** argv) {
//disableBacktrace=true;
printf("====== Started Validation ======\n");
bool showDuplicateFiles = true;
bool purgeUnusedFiles = false;
//double purgedMegaBytes=0;
Config &config = Config::getInstance();
@ -2432,11 +2430,12 @@ void runTilesetValidationReport(int argc, char** argv) {
Tokenize(filterList,paramPartTokens,"=");
if(paramPartTokens.size() >= 2) {
vector<string> optionList;
//vector<string> optionList;
string validateTilesetName = paramPartTokens[1];
printf("Filtering tileset: %s\n",validateTilesetName.c_str());
bool purgeUnusedFiles = false;
if(paramPartTokens.size() >= 3) {
if(paramPartTokens[2] == "purgeunused") {
purgeUnusedFiles = true;
@ -2449,7 +2448,9 @@ void runTilesetValidationReport(int argc, char** argv) {
World world;
double purgedMegaBytes=0;
std::vector<string> filteredFactionList;
bool showDuplicateFiles = true;
//std::vector<string> filteredFactionList;
vector<string> tilesetPaths = config.getPathListForType(ptTilesets);
for(int idx = 0; idx < tilesetPaths.size(); idx++) {
@ -2622,7 +2623,7 @@ void CheckForDuplicateData() {
string duplicateWarnings="";
{
vector<string> results;
//vector<string> results;
string scenarioDir = "";
vector<string> pathList = config.getPathListForType(ptMaps,scenarioDir);
@ -3070,19 +3071,20 @@ int glestMain(int argc, char** argv) {
//# define STREFLOP_NO_DENORMALS
// streflop_init<streflop::Simple>();
const char *instruction_set = "[none]";
const char *denormals = "[denormals]";
#if defined(STREFLOP_SSE)
instruction_set = "[SSE]";
const char *instruction_set = "[SSE]";
#elif defined(STREFLOP_X87)
instruction_set = "[X87]";
const char *instruction_set = "[X87]";
#elif defined(STREFLOP_SOFT)
instruction_set = "[SOFTFLOAT]";
const char *instruction_set = "[SOFTFLOAT]";
#else
const char *instruction_set = "[none]";
#endif
#if defined(STREFLOP_NO_DENORMALS)
denormals = "[no-denormals]";
const char *denormals = "[no-denormals]";
#else
const char *denormals = "[denormals]";
#endif
printf(" - using STREFLOP %s - %s\n",instruction_set,denormals);
@ -4526,7 +4528,7 @@ int glestMain(int argc, char** argv) {
renderer.clearBuffers();
renderer.clearZBuffer();
renderer.reset2d();
sprintf(szTextBuf,"Please wait, converting models [%d of %lu] ...",i,(long int)models.size());
sprintf(szTextBuf,"Please wait, converting models [%u of %lu] ...",i,(long int)models.size());
if(CoreData::getInstance().getMenuFontBig3D() != NULL) {
renderer.renderText3D(
@ -4550,7 +4552,7 @@ int glestMain(int argc, char** argv) {
Model *model = renderer.newModel(rsGlobal);
try {
printf("About to load model [%s] [%d of %lu]\n",file.c_str(),i,(long int)models.size());
printf("About to load model [%s] [%u of %lu]\n",file.c_str(),i,(long int)models.size());
model->load(file);
modelLoadedOk = true;
}
@ -4695,8 +4697,9 @@ int glestMain(int argc, char** argv) {
#endif
{
bool skip = true;
#ifdef WIN32
bool skip = true;
DWORD nNumberOfCharsToRead = 1024;
DWORD nRead = 0;
INPUT_RECORD irInRec[1025];
@ -4717,7 +4720,7 @@ int glestMain(int argc, char** argv) {
}
}
#else
skip = false;
bool skip = false;
#endif
if(skip == false) {
getline(cin, command);

View File

@ -205,10 +205,8 @@ void Program::initNormal(WindowGl *window){
}
void Program::initSavedGame(WindowGl *window,bool masterserverMode, string saveGameFile) {
MainMenu* mainMenu= NULL;
init(window);
mainMenu= new MainMenu(this);
MainMenu *mainMenu= new MainMenu(this);
setState(mainMenu);
if(saveGameFile == "") {
@ -237,38 +235,30 @@ void Program::initSavedGame(WindowGl *window,bool masterserverMode, string saveG
void Program::initServer(WindowGl *window, bool autostart,bool openNetworkSlots,
bool masterserverMode) {
MainMenu* mainMenu= NULL;
//this->masterserverMode = masterserverMode;
init(window);
mainMenu= new MainMenu(this);
MainMenu *mainMenu= new MainMenu(this);
setState(mainMenu);
mainMenu->setState(new MenuStateCustomGame(this, mainMenu, openNetworkSlots, pNewGame, autostart, NULL, masterserverMode));
}
void Program::initServer(WindowGl *window, GameSettings *settings) {
MainMenu* mainMenu= NULL;
init(window);
mainMenu= new MainMenu(this);
MainMenu *mainMenu= new MainMenu(this);
setState(mainMenu);
mainMenu->setState(new MenuStateCustomGame(this, mainMenu, false, pNewGame, true, settings));
}
void Program::initClient(WindowGl *window, const Ip &serverIp, int portNumber) {
MainMenu* mainMenu= NULL;
init(window);
mainMenu= new MainMenu(this);
MainMenu *mainMenu= new MainMenu(this);
setState(mainMenu);
mainMenu->setState(new MenuStateJoinGame(this, mainMenu, true, serverIp,portNumber));
}
void Program::initClientAutoFindHost(WindowGl *window) {
MainMenu* mainMenu= NULL;
init(window);
mainMenu= new MainMenu(this);
MainMenu *mainMenu= new MainMenu(this);
setState(mainMenu);
bool autoFindHost = true;
mainMenu->setState(new MenuStateJoinGame(this, mainMenu, &autoFindHost));
@ -276,10 +266,8 @@ void Program::initClientAutoFindHost(WindowGl *window) {
}
void Program::initScenario(WindowGl *window, string autoloadScenarioName) {
MainMenu* mainMenu= NULL;
init(window);
mainMenu= new MainMenu(this);
MainMenu *mainMenu= new MainMenu(this);
setState(mainMenu);
mainMenu->setState(new MenuStateScenario(this, mainMenu, false,
Config::getInstance().getPathListForType(ptScenarios),autoloadScenarioName));

View File

@ -108,7 +108,7 @@ void MenuStateAbout::reloadUI() {
buttonReturn.setText(lang.get("Return"));
labelAdditionalCredits.setText(additionalCredits);
if(additionalCredits == "") {
//if(additionalCredits == "") {
for(int i= 0; i < aboutStringCount1; ++i){
labelAbout1[i].setText(getAboutString1(i));
}
@ -116,16 +116,16 @@ void MenuStateAbout::reloadUI() {
for(int i= 0; i < aboutStringCount2; ++i){
labelAbout2[i].setText(getAboutString2(i));
}
}
else {
for(int i= 0; i < aboutStringCount1; ++i){
labelAbout1[i].setText(getAboutString1(i));
}
//}
//else {
// for(int i= 0; i < aboutStringCount1; ++i){
// labelAbout1[i].setText(getAboutString1(i));
// }
for(int i= 0; i < aboutStringCount2; ++i){
labelAbout2[i].setText(getAboutString2(i));
}
}
// for(int i= 0; i < aboutStringCount2; ++i){
// labelAbout2[i].setText(getAboutString2(i));
// }
//}
for(int i= 0; i < teammateCount; ++i) {
labelTeammateName[i].setText(getTeammateName(i));

View File

@ -136,7 +136,7 @@ MenuStateConnectedGame::MenuStateConnectedGame(Program *program, MainMenu *mainM
int aHeadPos=240;
int aPos=aHeadPos-labelOffset;
int networkHeadPos=700;
int xoffset=0;
//int xoffset=0;
//state
labelStatus.registerGraphicComponent(containerName,"labelStatus");
@ -163,7 +163,7 @@ MenuStateConnectedGame::MenuStateConnectedGame(Program *program, MainMenu *mainM
// fog - o - war
// @350 ? 300 ?
xoffset=70;
int xoffset=70;
labelFogOfWar.registerGraphicComponent(containerName,"labelFogOfWar");
labelFogOfWar.init(xoffset+100, aHeadPos, 130);
labelFogOfWar.setText(lang.get("FogOfWar"));
@ -247,7 +247,7 @@ MenuStateConnectedGame::MenuStateConnectedGame(Program *program, MainMenu *mainM
listBoxPlayerStatus.setItems(playerStatuses);
// Network Frame Period
xoffset=0;
//xoffset=0;
xoffset=70;
//map listBox

View File

@ -554,7 +554,7 @@ MenuStateOptions::MenuStateOptions(Program *program, MainMenu *mainMenu):
checkBoxEnablePrivacy.registerGraphicComponent(containerName,"checkBoxEnablePrivacy");
checkBoxEnablePrivacy.init(currentColumnStart ,currentLine );
checkBoxEnablePrivacy.setValue(config.getBool("PrivacyPlease","false"));
currentLine-=lineOffset;
//currentLine-=lineOffset;
// end
// buttons

View File

@ -133,7 +133,8 @@ void MenuStateRoot::mouseClick(int x, int y, MouseButton mouseButton){
SoundRenderer &soundRenderer= SoundRenderer::getInstance();
if(popupMenu.mouseClick(x, y)) {
std::pair<int,string> result = popupMenu.mouseClickedMenuItem(x, y);
//std::pair<int,string> result = popupMenu.mouseClickedMenuItem(x, y);
popupMenu.mouseClickedMenuItem(x, y);
//printf("In popup callback menuItemSelected [%s] menuIndexSelected = %d\n",result.second.c_str(),result.first);
}
@ -267,7 +268,7 @@ void MenuStateRoot::render() {
logoMainW, logoMainH,
extraLogo, GraphicComponent::getFade());
currentX += extraLogo->getPixmap()->getW();
//currentX += extraLogo->getPixmap()->getW();
}
renderer.renderButton(&buttonNewGame);

View File

@ -122,12 +122,10 @@ ClientInterface::~ClientInterface() {
void ClientInterface::connect(const Ip &ip, int port) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] START\n",__FILE__,__FUNCTION__);
delete clientSocket;
clientSocket = NULL;
this->ip = ip;
this->port = port;
delete clientSocket;
clientSocket= new ClientSocket();
clientSocket->setBlock(false);
clientSocket->connect(ip, port);

View File

@ -1159,8 +1159,6 @@ void ConnectionSlot::update(bool checkForNewClients,int lockedSlotIndex) {
// just the 'wrong' amount of lag (but not enough to be horrible for a disconnect)
if(Config::getInstance().getBool("AutoClientLagCorrection","true") == true) {
double LAG_CHECK_GRACE_PERIOD = 15;
double maxFrameCountLagAllowed = 10;
double maxClientLagTimeAllowed = 8;
if(this->serverInterface->getGameStartTime() > 0 &&
difftime((long int)time(NULL),this->serverInterface->getGameStartTime()) >= LAG_CHECK_GRACE_PERIOD) {
@ -1169,6 +1167,9 @@ void ConnectionSlot::update(bool checkForNewClients,int lockedSlotIndex) {
double clientLagCount = (gameSettings.getNetworkFramePeriod() > 0 ? (clientLag / gameSettings.getNetworkFramePeriod()) : 0);
double clientLagTime = difftime((long int)time(NULL),this->getLastReceiveCommandListTime());
double maxFrameCountLagAllowed = 10;
double maxClientLagTimeAllowed = 8;
// New lag check
if((maxFrameCountLagAllowed > 0 && clientLagCount > maxFrameCountLagAllowed) ||
(maxClientLagTimeAllowed > 0 && clientLagTime > maxClientLagTimeAllowed)) {

View File

@ -38,14 +38,14 @@ bool CommandGroupUnitSorterId::operator()(const int l, const int r) {
printf("Error lUnit == NULL for id = %d factionIndex = %d\n",l,faction->getIndex());
for(unsigned int i = 0; i < faction->getUnitCount(); ++i) {
printf("%d / %d id = %d [%s]\n",i,faction->getUnitCount(),faction->getUnit(i)->getId(),faction->getUnit(i)->getType()->getName().c_str());
printf("%u / %d id = %d [%s]\n",i,faction->getUnitCount(),faction->getUnit(i)->getId(),faction->getUnit(i)->getType()->getName().c_str());
}
}
if(!rUnit) {
printf("Error rUnit == NULL for id = %d factionIndex = %d\n",r,faction->getIndex());
for(unsigned int i = 0; i < faction->getUnitCount(); ++i) {
printf("%d / %d id = %d [%s]\n",i,faction->getUnitCount(),faction->getUnit(i)->getId(),faction->getUnit(i)->getType()->getName().c_str());
printf("%u / %d id = %d [%s]\n",i,faction->getUnitCount(),faction->getUnit(i)->getId(),faction->getUnit(i)->getType()->getName().c_str());
}
}
@ -140,14 +140,14 @@ bool CommandGroupUnitSorter::compare(const Unit *l, const Unit *r) {
// }
else {
//Command *commandPeer = j.unit->getCurrrentCommandThreadSafe();
if( commandPeer != NULL && commandPeer->getCommandType() != NULL &&
(commandPeer->getCommandType()->getClass() != ccMove &&
commandPeer->getCommandType()->getClass() != ccAttack)) {
result = l->getId() < r->getId();
}
else {
//if( commandPeer != NULL && commandPeer->getCommandType() != NULL &&
// (commandPeer->getCommandType()->getClass() != ccMove &&
// commandPeer->getCommandType()->getClass() != ccAttack)) {
result = (l->getId() < r->getId());
}
//}
//else {
// result = (l->getId() < r->getId());
//}
}
//printf("Sorting, unit [%d - %s] cmd [%s] | unit2 [%d - %s] cmd [%s] result = %d\n",this->unit->getId(),this->unit->getFullName().c_str(),(this->unit->getCurrCommand() == NULL ? "NULL" : this->unit->getCurrCommand()->toString().c_str()),j.unit->getId(),j.unit->getFullName().c_str(),(j.unit->getCurrCommand() == NULL ? "NULL" : j.unit->getCurrCommand()->toString().c_str()),result);
@ -181,7 +181,7 @@ void Faction::sortUnitsByCommandGroups() {
printf("#1 Error unitId not found for id = %d [%s] factionIndex = %d\n",unitId,units[i]->getType()->getName().c_str(),this->getIndex());
for(unsigned int j = 0; j < units.size(); ++j) {
printf("%d / %d id = %d [%s]\n",j,(int)units.size(),units[j]->getId(),units[j]->getType()->getName().c_str());
printf("%u / %d id = %d [%s]\n",j,(int)units.size(),units[j]->getId(),units[j]->getType()->getName().c_str());
}
}
unitIds.push_back(unitId);
@ -198,7 +198,7 @@ void Faction::sortUnitsByCommandGroups() {
printf("#2 Error unitId not found for id = %d factionIndex = %d\n",unitId,this->getIndex());
for(unsigned int j = 0; j < units.size(); ++j) {
printf("%d / %d id = %d [%s]\n",j,(int)units.size(),units[j]->getId(),units[j]->getType()->getName().c_str());
printf("%u / %d id = %d [%s]\n",j,(int)units.size(),units[j]->getId(),units[j]->getType()->getName().c_str());
}
}
@ -389,6 +389,10 @@ void FactionThread::execute() {
// =====================================================
Faction::Faction() {
init();
}
void Faction::init() {
unitsMutex = new Mutex();
texture = NULL;
//lastResourceTargettListPurge = 0;
@ -1866,9 +1870,7 @@ string Faction::getCacheStats() {
}
std::string Faction::toString() const {
std::string result = "";
result = "FactionIndex = " + intToStr(this->index) + "\n";
std::string result = "FactionIndex = " + intToStr(this->index) + "\n";
result += "teamIndex = " + intToStr(this->teamIndex) + "\n";
result += "startLocationIndex = " + intToStr(this->startLocationIndex) + "\n";
result += "thisFaction = " + intToStr(this->thisFaction) + "\n";

View File

@ -157,6 +157,15 @@ public:
Faction();
~Faction();
Faction(const Faction& obj) {
init();
throw megaglest_runtime_error("class Faction is NOT safe to copy!");
}
Faction & operator=(const Faction& obj) {
init();
throw megaglest_runtime_error("class Faction is NOT safe to assign!");
}
inline const bool * aproxCanMoveSoonCached(int size, Field field, const Vec2i &pos1, const Vec2i &pos2) const {
const bool *result = NULL;
// std::map<int,std::map<Field, std::map<Vec2i,bool> > >::const_iterator iterFind1 = mapSharedPathFinderCache.find(size);
@ -319,6 +328,7 @@ public:
void loadGame(const XmlNode *rootNode, int factionIndex,GameSettings *settings,World *world);
private:
void init();
void resetResourceAmount(const ResourceType *rt);
};

View File

@ -192,8 +192,6 @@ bool Object::getWalkable() const{
void Object::setResource(const ResourceType *resourceType, const Vec2i &pos){
delete resource;
resource = NULL;
resource= new Resource();
resource->init(resourceType, pos);
initParticlesFromTypes(resourceType->getObjectParticleSystemTypes());

View File

@ -138,7 +138,7 @@ void UnitPathBasic::addToLastPathCache(const Vec2i &path) {
}
Vec2i UnitPathBasic::pop(bool removeFrontPos) {
if(pathQueue.size() <= 0) {
if(pathQueue.empty() == true) {
throw megaglest_runtime_error("pathQueue.size() = " + intToStr(pathQueue.size()));
}
Vec2i p= pathQueue.front();
@ -148,9 +148,7 @@ Vec2i UnitPathBasic::pop(bool removeFrontPos) {
return p;
}
std::string UnitPathBasic::toString() const {
std::string result = "";
result = "unit path blockCount = " + intToStr(blockCount) + " pathQueue size = " + intToStr(pathQueue.size());
std::string result = "unit path blockCount = " + intToStr(blockCount) + " pathQueue size = " + intToStr(pathQueue.size());
for(int idx = 0; idx < pathQueue.size(); ++idx) {
result += " index = " + intToStr(idx) + " " + pathQueue[idx].getString();
}
@ -200,9 +198,7 @@ void WaypointPath::condense() {
}
std::string UnitPath::toString() const {
std::string result = "";
result = "unit path blockCount = " + intToStr(blockCount) + " pathQueue size = " + intToStr(size());
std::string result = "unit path blockCount = " + intToStr(blockCount) + " pathQueue size = " + intToStr(size());
result += " path = ";
for (const_iterator it = begin(); it != end(); ++it) {
result += " [" + intToStr(it->x) + "," + intToStr(it->y) + "]";
@ -2084,7 +2080,7 @@ bool Unit::update() {
//printf("+ #2 APPLY ATTACK BOOST SELF PARTICLE to unit [%s - %d]\n",this->getType()->getName().c_str(),this->getId());
}
}
else if(currentAttackBoostOriginatorEffect.currentAttackBoostUnits.size() <= 0) {
else if(currentAttackBoostOriginatorEffect.currentAttackBoostUnits.empty() == true) {
if(currentAttackBoostOriginatorEffect.currentAppliedEffect != NULL) {
delete currentAttackBoostOriginatorEffect.currentAppliedEffect;
currentAttackBoostOriginatorEffect.currentAppliedEffect = NULL;

View File

@ -257,7 +257,7 @@ std::string UpgradeManager::toString() const {
}
void UpgradeManager::saveGame(XmlNode *rootNode) {
std::map<string,string> mapTagReplacements;
//std::map<string,string> mapTagReplacements;
XmlNode *upgrademanagerNode = rootNode->addChild("UpgradeManager");
for(unsigned int i = 0; i < upgrades.size(); ++i) {

View File

@ -850,9 +850,7 @@ bool FactionType::factionUsesResourceType(const ResourceType *rt) const {
}
std::string FactionType::toString() const {
std::string result = "";
result = "Faction Name: " + name + "\n";
std::string result = "Faction Name: " + name + "\n";
result += "Unit Type List count = " + intToStr(this->getUnitTypeCount()) + "\n";
for(int i=0; i<unitTypes.size();i++) {

View File

@ -1020,9 +1020,7 @@ string UnitType::getName(bool translatedValue) const {
}
std::string UnitType::toString() const {
std::string result = "";
result = "Unit Name: [" + name + "] id = " + intToStr(id);
std::string result = "Unit Name: [" + name + "] id = " + intToStr(id);
result += " maxHp = " + intToStr(maxHp);
result += " hpRegeneration = " + intToStr(hpRegeneration);
result += " maxEp = " + intToStr(maxEp);

View File

@ -611,7 +611,7 @@ void UpgradeType::load(const string &dir, const TechTree *techTree,
//resource requirements
int index = 0;
const XmlNode *resourceRequirementsNode= upgradeNode->getChild("resource-requirements");
hasDup = false;
costs.resize(resourceRequirementsNode->getChildCount());
for(int i = 0; i < costs.size(); ++i) {
const XmlNode *resourceNode= resourceRequirementsNode->getChild("resource", i);

View File

@ -857,7 +857,7 @@ bool Map::canMove(const Unit *unit, const Vec2i &pos1, const Vec2i &pos2, std::m
}
bool isBadHarvestPos = false;
if(unit != NULL) {
//if(unit != NULL) {
Command *command= unit->getCurrCommand();
if(command != NULL) {
const HarvestCommandType *hct = dynamic_cast<const HarvestCommandType*>(command->getCommandType());
@ -865,7 +865,7 @@ bool Map::canMove(const Unit *unit, const Vec2i &pos1, const Vec2i &pos2, std::m
isBadHarvestPos = true;
}
}
}
//}
if(unit == NULL || isBadHarvestPos == true) {
if(lookupCache != NULL) {
@ -952,7 +952,7 @@ bool Map::aproxCanMove(const Unit *unit, const Vec2i &pos1, const Vec2i &pos2, s
}
bool isBadHarvestPos = false;
if(unit != NULL) {
//if(unit != NULL) {
Command *command= unit->getCurrCommand();
if(command != NULL) {
const HarvestCommandType *hct = dynamic_cast<const HarvestCommandType*>(command->getCommandType());
@ -960,7 +960,7 @@ bool Map::aproxCanMove(const Unit *unit, const Vec2i &pos1, const Vec2i &pos2, s
isBadHarvestPos = true;
}
}
}
//}
if(unit == NULL || isBadHarvestPos == true) {
if(lookupCache != NULL) {

View File

@ -435,7 +435,7 @@ public:
}
bool isBadHarvestPos = false;
if(unit != NULL) {
//if(unit != NULL) {
Command *command= unit->getCurrCommand();
if(command != NULL) {
const HarvestCommandType *hct = dynamic_cast<const HarvestCommandType*>(command->getCommandType());
@ -443,7 +443,7 @@ public:
isBadHarvestPos = true;
}
}
}
//}
if(unit == NULL || isBadHarvestPos == true) {

View File

@ -192,7 +192,7 @@ void Scenario::loadScenarioInfo(string file, ScenarioInfo *scenarioInfo) {
for(int i= 0; i < GameConstants::maxPlayers; ++i) {
XmlNode* playerNode=NULL;
string factionTypeName="";
//string factionTypeName="";
ControlType factionControl;
if(playersNode->hasChildAtIndex("player",i)) {

View File

@ -1987,7 +1987,6 @@ void UnitUpdater::startAttackParticleSystem(Unit *unit){
Renderer &renderer= Renderer::getInstance();
ProjectileParticleSystem *psProj = 0;
SplashParticleSystem *psSplash;
const AttackSkillType *ast= static_cast<const AttackSkillType*>(unit->getCurrSkill());
ParticleSystemTypeProjectile *pstProj= ast->getProjParticleType();
@ -2020,8 +2019,8 @@ void UnitUpdater::startAttackParticleSystem(Unit *unit){
}
//splash
if(pstSplash!=NULL){
psSplash= pstSplash->create();
if(pstSplash != NULL) {
SplashParticleSystem *psSplash= pstSplash->create();
psSplash->setPos(endPos);
psSplash->setVisible(visible);
if(unit->getFaction()->getTexture()) {

View File

@ -1220,9 +1220,7 @@ void World::addConsoleTextWoLang(const string &text) {
}
const string World::getSystemMacroValue(const string key) {
string result = "";
result = key;
std::string result = key;
bool tagApplied = Properties::applyTagsToValue(result);
if(tagApplied == false) {
result = "";

View File

@ -286,8 +286,10 @@ int glob( char const *pattern
if(new_buffer == NULL)
{
result = GLOB_NOSPACE;
free(buffer);
buffer = NULL;
if(buffer) {
free(buffer);
buffer = NULL;
}
break;
}
@ -315,7 +317,10 @@ int glob( char const *pattern
if(new_buffer == NULL)
{
result = GLOB_NOSPACE;
free(buffer);
if(buffer) {
free(buffer);
buffer = NULL;
}
}
else
{
@ -402,7 +407,10 @@ int glob( char const *pattern
if(NULL == pp)
{
result = GLOB_NOSPACE;
free(buffer);
if(buffer) {
free(buffer);
buffer = NULL;
}
}
else
{