- phase 1 of cppcheck verbose fixes

This commit is contained in:
Mark Vejvoda 2011-08-31 23:10:43 +00:00
parent 34ae6bda1a
commit d44959d69c
29 changed files with 253 additions and 186 deletions

View File

@ -552,7 +552,7 @@ void MainWindow::onPaint(wxPaintEvent &event) {
renderer->renderParticleManager(); renderer->renderParticleManager();
glCanvas->SwapBuffers(); glCanvas->SwapBuffers();
bool haveLoadedParticles = (particleProjectilePathList.size() > 0 || particleSplashPathList.size() > 0); bool haveLoadedParticles = (particleProjectilePathList.empty() == false || particleSplashPathList.empty() == false);
if(autoScreenShotAndExit == true) { if(autoScreenShotAndExit == true) {
printf("Auto exiting app...\n"); printf("Auto exiting app...\n");
@ -563,7 +563,7 @@ void MainWindow::onPaint(wxPaintEvent &event) {
Close(); Close();
return; return;
} }
else if((modelPathList.size() > 0) && resetAnimation && haveLoadedParticles) { else if((modelPathList.empty() == false) && resetAnimation && haveLoadedParticles) {
if(anim >= resetAnim && resetAnim > 0) { if(anim >= resetAnim && resetAnim > 0) {
printf("RESETTING EVERYTHING [%f][%f]...\n",anim,resetAnim); printf("RESETTING EVERYTHING [%f][%f]...\n",anim,resetAnim);
fflush(stdout); fflush(stdout);
@ -647,7 +647,7 @@ void MainWindow::onMouseWheelDown(wxMouseEvent &event) {
onPaint(paintEvent); onPaint(paintEvent);
} }
catch(std::runtime_error e) { catch(std::runtime_error &e) {
std::cout << e.what() << std::endl; std::cout << e.what() << std::endl;
wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Error"), wxOK | wxICON_ERROR).ShowModal(); wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Error"), wxOK | wxICON_ERROR).ShowModal();
} }
@ -664,7 +664,7 @@ void MainWindow::onMouseWheelUp(wxMouseEvent &event) {
onPaint(paintEvent); onPaint(paintEvent);
} }
catch(std::runtime_error e) { catch(std::runtime_error &e) {
std::cout << e.what() << std::endl; std::cout << e.what() << std::endl;
wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Error"), wxOK | wxICON_ERROR).ShowModal(); wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Error"), wxOK | wxICON_ERROR).ShowModal();
} }
@ -699,7 +699,7 @@ void MainWindow::onMouseMove(wxMouseEvent &event){
lastX= x; lastX= x;
lastY= y; lastY= y;
} }
catch(std::runtime_error e) { catch(std::runtime_error &e) {
std::cout << e.what() << std::endl; std::cout << e.what() << std::endl;
wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Error"), wxOK | wxICON_ERROR).ShowModal(); wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Error"), wxOK | wxICON_ERROR).ShowModal();
} }
@ -729,7 +729,7 @@ void MainWindow::onMenuFileLoad(wxCommandEvent &event){
} }
isControlKeyPressed = false; isControlKeyPressed = false;
} }
catch(std::runtime_error e) { catch(std::runtime_error &e) {
std::cout << e.what() << std::endl; std::cout << e.what() << std::endl;
wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Error"), wxOK | wxICON_ERROR).ShowModal(); wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Error"), wxOK | wxICON_ERROR).ShowModal();
} }
@ -763,7 +763,7 @@ void MainWindow::onMenuFileLoadParticleXML(wxCommandEvent &event){
} }
isControlKeyPressed = false; isControlKeyPressed = false;
} }
catch(std::runtime_error e) { catch(std::runtime_error &e) {
std::cout << e.what() << std::endl; std::cout << e.what() << std::endl;
wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Error"), wxOK | wxICON_ERROR).ShowModal(); wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Error"), wxOK | wxICON_ERROR).ShowModal();
} }
@ -797,7 +797,7 @@ void MainWindow::onMenuFileLoadProjectileParticleXML(wxCommandEvent &event){
} }
isControlKeyPressed = false; isControlKeyPressed = false;
} }
catch(std::runtime_error e) { catch(std::runtime_error &e) {
std::cout << e.what() << std::endl; std::cout << e.what() << std::endl;
wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Error"), wxOK | wxICON_ERROR).ShowModal(); wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Error"), wxOK | wxICON_ERROR).ShowModal();
} }
@ -832,7 +832,7 @@ void MainWindow::onMenuFileLoadSplashParticleXML(wxCommandEvent &event){
} }
isControlKeyPressed = false; isControlKeyPressed = false;
} }
catch(std::runtime_error e) { catch(std::runtime_error &e) {
std::cout << e.what() << std::endl; std::cout << e.what() << std::endl;
wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Error"), wxOK | wxICON_ERROR).ShowModal(); wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Error"), wxOK | wxICON_ERROR).ShowModal();
} }
@ -858,7 +858,7 @@ void MainWindow::OnChangeColor(wxCommandEvent &event) {
renderer->setBackgroundColor(col.Red()/255.0f, col.Green()/255.0f, col.Blue()/255.0f); renderer->setBackgroundColor(col.Red()/255.0f, col.Green()/255.0f, col.Blue()/255.0f);
} }
} }
catch(std::runtime_error e) { catch(std::runtime_error &e) {
std::cout << e.what() << std::endl; std::cout << e.what() << std::endl;
wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Error"), wxOK | wxICON_ERROR).ShowModal(); wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Error"), wxOK | wxICON_ERROR).ShowModal();
} }
@ -870,7 +870,7 @@ void MainWindow::onMenumFileToggleScreenshotTransparent(wxCommandEvent &event) {
renderer->setAlphaColor(alpha); renderer->setAlphaColor(alpha);
//printf("alpha = %f\n",alpha); //printf("alpha = %f\n",alpha);
} }
catch(std::runtime_error e) { catch(std::runtime_error &e) {
std::cout << e.what() << std::endl; std::cout << e.what() << std::endl;
wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Error"), wxOK | wxICON_ERROR).ShowModal(); wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Error"), wxOK | wxICON_ERROR).ShowModal();
} }
@ -942,7 +942,7 @@ void MainWindow::saveScreenshot() {
} }
} }
} }
catch(std::runtime_error e) { catch(std::runtime_error &e) {
std::cout << e.what() << std::endl; std::cout << e.what() << std::endl;
wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Error"), wxOK | wxICON_ERROR).ShowModal(); wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Error"), wxOK | wxICON_ERROR).ShowModal();
} }
@ -990,7 +990,7 @@ void MainWindow::onMenuFileClearAll(wxCommandEvent &event) {
if(timer) timer->Start(100); if(timer) timer->Start(100);
} }
catch(std::runtime_error e) { catch(std::runtime_error &e) {
std::cout << e.what() << std::endl; std::cout << e.what() << std::endl;
wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Error"), wxOK | wxICON_ERROR).ShowModal(); wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Error"), wxOK | wxICON_ERROR).ShowModal();
} }
@ -1123,7 +1123,7 @@ void MainWindow::loadUnit(string path, string skillName) {
SetTitle(ToUnicode(titlestring)); SetTitle(ToUnicode(titlestring));
} }
} }
catch(std::runtime_error e) { catch(std::runtime_error &e) {
std::cout << e.what() << std::endl; std::cout << e.what() << std::endl;
wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Not a Mega-Glest particle XML file, or broken"), wxOK | wxICON_ERROR).ShowModal(); wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Not a Mega-Glest particle XML file, or broken"), wxOK | wxICON_ERROR).ShowModal();
} }
@ -1157,7 +1157,7 @@ void MainWindow::loadModel(string path) {
} }
SetTitle(ToUnicode(titlestring)); SetTitle(ToUnicode(titlestring));
} }
catch(std::runtime_error e) { catch(std::runtime_error &e) {
std::cout << e.what() << std::endl; std::cout << e.what() << std::endl;
wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Error"), wxOK | wxICON_ERROR).ShowModal(); wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Error"), wxOK | wxICON_ERROR).ShowModal();
} }
@ -1182,7 +1182,7 @@ void MainWindow::loadParticle(string path) {
} }
try{ try{
if(this->particlePathList.size() > 0) { if(this->particlePathList.empty() == false) {
string titlestring=winHeader; string titlestring=winHeader;
for(unsigned int idx = 0; idx < this->particlePathList.size(); idx++) { for(unsigned int idx = 0; idx < this->particlePathList.size(); idx++) {
string particlePath = this->particlePathList[idx]; string particlePath = this->particlePathList[idx];
@ -1198,8 +1198,8 @@ void MainWindow::loadParticle(string path) {
std::string unitXML = dir + folderDelimiter + extractFileFromDirectoryPath(dir) + ".xml"; std::string unitXML = dir + folderDelimiter + extractFileFromDirectoryPath(dir) + ".xml";
int size = -1; //int size = -1;
int height = -1; //int height = -1;
if(fileExists(unitXML) == true) { if(fileExists(unitXML) == true) {
XmlTree xmlTree; XmlTree xmlTree;
@ -1207,9 +1207,9 @@ void MainWindow::loadParticle(string path) {
const XmlNode *unitNode= xmlTree.getRootNode(); const XmlNode *unitNode= xmlTree.getRootNode();
const XmlNode *parametersNode= unitNode->getChild("parameters"); const XmlNode *parametersNode= unitNode->getChild("parameters");
//size //size
size= parametersNode->getChild("size")->getAttribute("value")->getIntValue(); int size= parametersNode->getChild("size")->getAttribute("value")->getIntValue();
//height //height
height= parametersNode->getChild("height")->getAttribute("value")->getIntValue(); int height= parametersNode->getChild("height")->getAttribute("value")->getIntValue();
// std::cout << "About to load [" << particlePath << "] from [" << dir << "] unit [" << unitXML << "]" << std::endl; // std::cout << "About to load [" << particlePath << "] from [" << dir << "] unit [" << unitXML << "]" << std::endl;
@ -1247,7 +1247,7 @@ void MainWindow::loadParticle(string path) {
SetTitle(ToUnicode(titlestring)); SetTitle(ToUnicode(titlestring));
} }
} }
catch(std::runtime_error e) { catch(std::runtime_error &e) {
std::cout << e.what() << std::endl; std::cout << e.what() << std::endl;
wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Not a Mega-Glest particle XML file, or broken"), wxOK | wxICON_ERROR).ShowModal(); wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Not a Mega-Glest particle XML file, or broken"), wxOK | wxICON_ERROR).ShowModal();
} }
@ -1273,7 +1273,7 @@ void MainWindow::loadProjectileParticle(string path) {
} }
try { try {
if(this->particleProjectilePathList.size() > 0) { if(this->particleProjectilePathList.empty() == false) {
string titlestring=winHeader; string titlestring=winHeader;
for(unsigned int idx = 0; idx < this->particleProjectilePathList.size(); idx++) { for(unsigned int idx = 0; idx < this->particleProjectilePathList.size(); idx++) {
string particlePath = this->particleProjectilePathList[idx]; string particlePath = this->particleProjectilePathList[idx];
@ -1307,7 +1307,7 @@ void MainWindow::loadProjectileParticle(string path) {
XmlTree xmlTree; XmlTree xmlTree;
xmlTree.load(dir + folderDelimiter + particlePath,Properties::getTagReplacementValues()); xmlTree.load(dir + folderDelimiter + particlePath,Properties::getTagReplacementValues());
const XmlNode *particleSystemNode= xmlTree.getRootNode(); //const XmlNode *particleSystemNode= xmlTree.getRootNode();
// std::cout << "Loaded successfully, loading values..." << std::endl; // std::cout << "Loaded successfully, loading values..." << std::endl;
@ -1350,7 +1350,7 @@ void MainWindow::loadProjectileParticle(string path) {
} }
} }
} }
catch(std::runtime_error e) { catch(std::runtime_error &e) {
std::cout << e.what() << std::endl; std::cout << e.what() << std::endl;
wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Not a Mega-Glest projectile particle XML file, or broken"), wxOK | wxICON_ERROR).ShowModal(); wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Not a Mega-Glest projectile particle XML file, or broken"), wxOK | wxICON_ERROR).ShowModal();
} }
@ -1376,7 +1376,7 @@ void MainWindow::loadSplashParticle(string path) { // uses ParticleSystemTypeSp
} }
try { try {
if(this->particleSplashPathList.size() > 0) { if(this->particleSplashPathList.empty() == false) {
string titlestring=winHeader; string titlestring=winHeader;
for(unsigned int idx = 0; idx < this->particleSplashPathList.size(); idx++) { for(unsigned int idx = 0; idx < this->particleSplashPathList.size(); idx++) {
string particlePath = this->particleSplashPathList[idx]; string particlePath = this->particleSplashPathList[idx];
@ -1410,7 +1410,7 @@ void MainWindow::loadSplashParticle(string path) { // uses ParticleSystemTypeSp
XmlTree xmlTree; XmlTree xmlTree;
xmlTree.load(dir + folderDelimiter + particlePath,Properties::getTagReplacementValues()); xmlTree.load(dir + folderDelimiter + particlePath,Properties::getTagReplacementValues());
const XmlNode *particleSystemNode= xmlTree.getRootNode(); //const XmlNode *particleSystemNode= xmlTree.getRootNode();
// std::cout << "Loaded successfully, loading values..." << std::endl; // std::cout << "Loaded successfully, loading values..." << std::endl;
@ -1453,7 +1453,7 @@ void MainWindow::loadSplashParticle(string path) { // uses ParticleSystemTypeSp
} }
} }
} }
catch(std::runtime_error e) { catch(std::runtime_error &e) {
std::cout << e.what() << std::endl; std::cout << e.what() << std::endl;
wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Not a Mega-Glest projectile particle XML file, or broken"), wxOK | wxICON_ERROR).ShowModal(); wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Not a Mega-Glest projectile particle XML file, or broken"), wxOK | wxICON_ERROR).ShowModal();
} }
@ -1465,7 +1465,7 @@ void MainWindow::onMenuModeNormals(wxCommandEvent &event){
renderer->toggleNormals(); renderer->toggleNormals();
menuMode->Check(miModeNormals, renderer->getNormals()); menuMode->Check(miModeNormals, renderer->getNormals());
} }
catch(std::runtime_error e) { catch(std::runtime_error &e) {
std::cout << e.what() << std::endl; std::cout << e.what() << std::endl;
wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Error"), wxOK | wxICON_ERROR).ShowModal(); wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Error"), wxOK | wxICON_ERROR).ShowModal();
} }
@ -1476,7 +1476,7 @@ void MainWindow::onMenuModeWireframe(wxCommandEvent &event){
renderer->toggleWireframe(); renderer->toggleWireframe();
menuMode->Check(miModeWireframe, renderer->getWireframe()); menuMode->Check(miModeWireframe, renderer->getWireframe());
} }
catch(std::runtime_error e) { catch(std::runtime_error &e) {
std::cout << e.what() << std::endl; std::cout << e.what() << std::endl;
wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Error"), wxOK | wxICON_ERROR).ShowModal(); wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Error"), wxOK | wxICON_ERROR).ShowModal();
} }
@ -1487,7 +1487,7 @@ void MainWindow::onMenuModeGrid(wxCommandEvent &event){
renderer->toggleGrid(); renderer->toggleGrid();
menuMode->Check(miModeGrid, renderer->getGrid()); menuMode->Check(miModeGrid, renderer->getGrid());
} }
catch(std::runtime_error e) { catch(std::runtime_error &e) {
std::cout << e.what() << std::endl; std::cout << e.what() << std::endl;
wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Error"), wxOK | wxICON_ERROR).ShowModal(); wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Error"), wxOK | wxICON_ERROR).ShowModal();
} }
@ -1503,7 +1503,7 @@ void MainWindow::onMenuSpeedSlower(wxCommandEvent &event){
string statusTextValue = statusbarText + " animation speed: " + floatToStr(speed * 1000.0) + " anim value: " + floatToStr(anim) + " zoom: " + floatToStr(zoom) + " rotX: " + floatToStr(rotX) + " rotY: " + floatToStr(rotY); string statusTextValue = statusbarText + " animation speed: " + floatToStr(speed * 1000.0) + " anim value: " + floatToStr(anim) + " zoom: " + floatToStr(zoom) + " rotX: " + floatToStr(rotX) + " rotY: " + floatToStr(rotY);
GetStatusBar()->SetStatusText(ToUnicode(statusTextValue.c_str())); GetStatusBar()->SetStatusText(ToUnicode(statusTextValue.c_str()));
} }
catch(std::runtime_error e) { catch(std::runtime_error &e) {
std::cout << e.what() << std::endl; std::cout << e.what() << std::endl;
wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Error"), wxOK | wxICON_ERROR).ShowModal(); wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Error"), wxOK | wxICON_ERROR).ShowModal();
} }
@ -1519,7 +1519,7 @@ void MainWindow::onMenuSpeedFaster(wxCommandEvent &event){
string statusTextValue = statusbarText + " animation speed: " + floatToStr(speed * 1000.0 ) + " anim value: " + floatToStr(anim) + " zoom: " + floatToStr(zoom) + " rotX: " + floatToStr(rotX) + " rotY: " + floatToStr(rotY); string statusTextValue = statusbarText + " animation speed: " + floatToStr(speed * 1000.0 ) + " anim value: " + floatToStr(anim) + " zoom: " + floatToStr(zoom) + " rotX: " + floatToStr(rotX) + " rotY: " + floatToStr(rotY);
GetStatusBar()->SetStatusText(ToUnicode(statusTextValue.c_str())); GetStatusBar()->SetStatusText(ToUnicode(statusTextValue.c_str()));
} }
catch(std::runtime_error e) { catch(std::runtime_error &e) {
std::cout << e.what() << std::endl; std::cout << e.what() << std::endl;
wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Error"), wxOK | wxICON_ERROR).ShowModal(); wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Error"), wxOK | wxICON_ERROR).ShowModal();
} }
@ -1538,7 +1538,7 @@ void MainWindow::onMenuColorRed(wxCommandEvent &event) {
menuCustomColor->Check(miColorOrange, false); menuCustomColor->Check(miColorOrange, false);
menuCustomColor->Check(miColorMagenta, false); menuCustomColor->Check(miColorMagenta, false);
} }
catch(std::runtime_error e) { catch(std::runtime_error &e) {
std::cout << e.what() << std::endl; std::cout << e.what() << std::endl;
wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Error"), wxOK | wxICON_ERROR).ShowModal(); wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Error"), wxOK | wxICON_ERROR).ShowModal();
} }
@ -1556,7 +1556,7 @@ void MainWindow::onMenuColorBlue(wxCommandEvent &event) {
menuCustomColor->Check(miColorOrange, false); menuCustomColor->Check(miColorOrange, false);
menuCustomColor->Check(miColorMagenta, false); menuCustomColor->Check(miColorMagenta, false);
} }
catch(std::runtime_error e) { catch(std::runtime_error &e) {
std::cout << e.what() << std::endl; std::cout << e.what() << std::endl;
wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Error"), wxOK | wxICON_ERROR).ShowModal(); wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Error"), wxOK | wxICON_ERROR).ShowModal();
} }
@ -1574,7 +1574,7 @@ void MainWindow::onMenuColorGreen(wxCommandEvent &event) {
menuCustomColor->Check(miColorOrange, false); menuCustomColor->Check(miColorOrange, false);
menuCustomColor->Check(miColorMagenta, false); menuCustomColor->Check(miColorMagenta, false);
} }
catch(std::runtime_error e) { catch(std::runtime_error &e) {
std::cout << e.what() << std::endl; std::cout << e.what() << std::endl;
wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Error"), wxOK | wxICON_ERROR).ShowModal(); wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Error"), wxOK | wxICON_ERROR).ShowModal();
} }
@ -1592,7 +1592,7 @@ void MainWindow::onMenuColorYellow(wxCommandEvent &event) {
menuCustomColor->Check(miColorOrange, false); menuCustomColor->Check(miColorOrange, false);
menuCustomColor->Check(miColorMagenta, false); menuCustomColor->Check(miColorMagenta, false);
} }
catch(std::runtime_error e) { catch(std::runtime_error &e) {
std::cout << e.what() << std::endl; std::cout << e.what() << std::endl;
wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Error"), wxOK | wxICON_ERROR).ShowModal(); wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Error"), wxOK | wxICON_ERROR).ShowModal();
} }
@ -1610,7 +1610,7 @@ void MainWindow::onMenuColorWhite(wxCommandEvent &event) {
menuCustomColor->Check(miColorOrange, false); menuCustomColor->Check(miColorOrange, false);
menuCustomColor->Check(miColorMagenta, false); menuCustomColor->Check(miColorMagenta, false);
} }
catch(std::runtime_error e) { catch(std::runtime_error &e) {
std::cout << e.what() << std::endl; std::cout << e.what() << std::endl;
wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Error"), wxOK | wxICON_ERROR).ShowModal(); wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Error"), wxOK | wxICON_ERROR).ShowModal();
} }
@ -1628,7 +1628,7 @@ void MainWindow::onMenuColorCyan(wxCommandEvent &event) {
menuCustomColor->Check(miColorOrange, false); menuCustomColor->Check(miColorOrange, false);
menuCustomColor->Check(miColorMagenta, false); menuCustomColor->Check(miColorMagenta, false);
} }
catch(std::runtime_error e) { catch(std::runtime_error &e) {
std::cout << e.what() << std::endl; std::cout << e.what() << std::endl;
wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Error"), wxOK | wxICON_ERROR).ShowModal(); wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Error"), wxOK | wxICON_ERROR).ShowModal();
} }
@ -1646,7 +1646,7 @@ void MainWindow::onMenuColorOrange(wxCommandEvent &event) {
menuCustomColor->Check(miColorOrange, true); menuCustomColor->Check(miColorOrange, true);
menuCustomColor->Check(miColorMagenta, false); menuCustomColor->Check(miColorMagenta, false);
} }
catch(std::runtime_error e) { catch(std::runtime_error &e) {
std::cout << e.what() << std::endl; std::cout << e.what() << std::endl;
wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Error"), wxOK | wxICON_ERROR).ShowModal(); wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Error"), wxOK | wxICON_ERROR).ShowModal();
} }
@ -1664,7 +1664,7 @@ void MainWindow::onMenuColorMagenta(wxCommandEvent &event) {
menuCustomColor->Check(miColorOrange, false); menuCustomColor->Check(miColorOrange, false);
menuCustomColor->Check(miColorMagenta, true); menuCustomColor->Check(miColorMagenta, true);
} }
catch(std::runtime_error e) { catch(std::runtime_error &e) {
std::cout << e.what() << std::endl; std::cout << e.what() << std::endl;
wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Error"), wxOK | wxICON_ERROR).ShowModal(); wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Error"), wxOK | wxICON_ERROR).ShowModal();
} }
@ -1764,7 +1764,7 @@ void MainWindow::onKeyDown(wxKeyEvent &e) {
std::cout << "pressed " << e.GetKeyCode() << std::endl; std::cout << "pressed " << e.GetKeyCode() << std::endl;
} }
catch(std::runtime_error e) { catch(std::runtime_error &e) {
std::cout << e.what() << std::endl; std::cout << e.what() << std::endl;
wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Error"), wxOK | wxICON_ERROR).ShowModal(); wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Error"), wxOK | wxICON_ERROR).ShowModal();
} }
@ -1795,7 +1795,7 @@ void MainWindow::onMenuRestart(wxCommandEvent &event) {
} }
if(timer) timer->Start(100); if(timer) timer->Start(100);
} }
catch(std::runtime_error e) { catch(std::runtime_error &e) {
std::cout << e.what() << std::endl; std::cout << e.what() << std::endl;
wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Error"), wxOK | wxICON_ERROR).ShowModal(); wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Error"), wxOK | wxICON_ERROR).ShowModal();
} }

View File

@ -441,7 +441,7 @@ void Ai::sendScoutPatrol(){
for(int i= 0; i < tt->getResourceTypeCount(); ++i){ for(int i= 0; i < tt->getResourceTypeCount(); ++i){
const ResourceType *rt_= tt->getResourceType(i); const ResourceType *rt_= tt->getResourceType(i);
const Resource *r= aiInterface->getResource(rt); //const Resource *r= aiInterface->getResource(rt);
if(rt_->getClass() == rcTech){ if(rt_->getClass() == rcTech){
rt=rt_; rt=rt_;
@ -640,9 +640,7 @@ void Ai::massiveAttack(const Vec2i &pos, Field field, bool ultraAttack){
void Ai::returnBase(int unitIndex) { void Ai::returnBase(int unitIndex) {
Vec2i pos; Vec2i pos;
CommandResult r; CommandResult r;
int fi; int fi= aiInterface->getFactionIndex();
fi= aiInterface->getFactionIndex();
pos= Vec2i( pos= Vec2i(
random.randRange(-villageRadius, villageRadius), random.randRange(-villageRadius, villageRadius)) + random.randRange(-villageRadius, villageRadius), random.randRange(-villageRadius, villageRadius)) +
getRandomHomePosition(); getRandomHomePosition();
@ -804,17 +802,17 @@ void Ai::unblockUnits() {
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld [START]\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis()); if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld [START]\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
if(signalAdjacentUnits.size() > 0) { if(signalAdjacentUnits.empty() == false) {
//printf("#2 AI units ARE BLOCKED about to unblock\n"); //printf("#2 AI units ARE BLOCKED about to unblock\n");
int unitGroupCommandId = -1; int unitGroupCommandId = -1;
for(std::map<float, std::map<int, const Unit *> >::reverse_iterator iterMap = signalAdjacentUnits.rbegin(); for(std::map<float, std::map<int, const Unit *> >::reverse_iterator iterMap = signalAdjacentUnits.rbegin();
iterMap != signalAdjacentUnits.rend(); iterMap++) { iterMap != signalAdjacentUnits.rend(); ++iterMap) {
for(std::map<int, const Unit *>::iterator iterMap2 = iterMap->second.begin(); for(std::map<int, const Unit *>::iterator iterMap2 = iterMap->second.begin();
iterMap2 != iterMap->second.end(); iterMap2++) { iterMap2 != iterMap->second.end(); ++iterMap2) {
int idx = iterMap2->first; //int idx = iterMap2->first;
const Unit *adjacentUnit = iterMap2->second; const Unit *adjacentUnit = iterMap2->second;
if(adjacentUnit != NULL && adjacentUnit->getType()->getFirstCtOfClass(ccMove) != NULL) { if(adjacentUnit != NULL && adjacentUnit->getType()->getFirstCtOfClass(ccMove) != NULL) {
const CommandType *ct = adjacentUnit->getType()->getFirstCtOfClass(ccMove); const CommandType *ct = adjacentUnit->getType()->getFirstCtOfClass(ccMove);
@ -844,7 +842,7 @@ void Ai::unblockUnits() {
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld [START]\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis()); if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld [START]\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
} }
bool Ai::outputAIBehaviourToConsole() { bool Ai::outputAIBehaviourToConsole() const {
return false; return false;
} }

View File

@ -188,7 +188,7 @@ public:
bool haveBlockedUnits(); bool haveBlockedUnits();
void unblockUnits(); void unblockUnits();
bool outputAIBehaviourToConsole(); bool outputAIBehaviourToConsole() const;
}; };
}}//end namespace }}//end namespace

View File

@ -533,7 +533,7 @@ bool AiInterface::isResourceNear(const Vec2i &pos, const ResourceType *rt, Vec2i
bool AiInterface::getNearestSightedResource(const ResourceType *rt, const Vec2i &pos, bool AiInterface::getNearestSightedResource(const ResourceType *rt, const Vec2i &pos,
Vec2i &resultPos, bool usableResourceTypeOnly) { Vec2i &resultPos, bool usableResourceTypeOnly) {
Faction *faction = world->getFaction(factionIndex); Faction *faction = world->getFaction(factionIndex);
float tmpDist=0; //float tmpDist=0;
float nearestDist= infinity; float nearestDist= infinity;
bool anyResource= false; bool anyResource= false;
resultPos.x = -1; resultPos.x = -1;
@ -572,7 +572,7 @@ bool AiInterface::getNearestSightedResource(const ResourceType *rt, const Vec2i
} }
else { else {
const Map *map = world->getMap(); const Map *map = world->getMap();
Faction *faction = world->getFaction(factionIndex); //Faction *faction = world->getFaction(factionIndex);
for(int i = 0; i < map->getW(); ++i) { for(int i = 0; i < map->getW(); ++i) {
for(int j = 0; j < map->getH(); ++j) { for(int j = 0; j < map->getH(); ++j) {
@ -587,7 +587,7 @@ bool AiInterface::getNearestSightedResource(const ResourceType *rt, const Vec2i
//if resource cell //if resource cell
if(r != NULL) { if(r != NULL) {
if(r->getType() == rt) { if(r->getType() == rt) {
tmpDist= pos.dist(resPos); float tmpDist= pos.dist(resPos);
if(tmpDist < nearestDist) { if(tmpDist < nearestDist) {
anyResource= true; anyResource= true;
nearestDist= tmpDist; nearestDist= tmpDist;

View File

@ -89,9 +89,11 @@ void AiRuleScoutPatrol::execute(){
AiRuleRepair::AiRuleRepair(Ai *ai): AiRuleRepair::AiRuleRepair(Ai *ai):
AiRule(ai) AiRule(ai)
{ {
damagedUnitIndex = 0;
damagedUnitIsCastle = false;
} }
double AiRuleRepair::getMinCastleHpRatio() { double AiRuleRepair::getMinCastleHpRatio() const {
return 0.6; return 0.6;
} }
@ -145,8 +147,8 @@ bool AiRuleRepair::test(){
} }
} }
int candidatedamagedUnitIndex=-1;
if(unitCanProduceWorker == true) { if(unitCanProduceWorker == true) {
int candidatedamagedUnitIndex=-1;
int unitCountAlreadyRepairingDamagedUnit = 0; int unitCountAlreadyRepairingDamagedUnit = 0;
// Now check if any other unit is able to repair this unit // Now check if any other unit is able to repair this unit
for(int i1 = 0; i1 < aiInterface->getMyUnitCount(); ++i1) { for(int i1 = 0; i1 < aiInterface->getMyUnitCount(); ++i1) {
@ -354,6 +356,7 @@ void AiRuleReturnBase::execute(){
AiRuleMassiveAttack::AiRuleMassiveAttack(Ai *ai): AiRuleMassiveAttack::AiRuleMassiveAttack(Ai *ai):
AiRule(ai) AiRule(ai)
{ {
ultraAttack=false;
} }
bool AiRuleMassiveAttack::test(){ bool AiRuleMassiveAttack::test(){
@ -512,6 +515,7 @@ void AiRuleAddTasks::execute(){
AiRuleBuildOneFarm::AiRuleBuildOneFarm(Ai *ai): AiRuleBuildOneFarm::AiRuleBuildOneFarm(Ai *ai):
AiRule(ai) AiRule(ai)
{ {
farm=NULL;
} }
bool AiRuleBuildOneFarm::test(){ bool AiRuleBuildOneFarm::test(){
@ -557,6 +561,7 @@ AiRuleProduceResourceProducer::AiRuleProduceResourceProducer(Ai *ai):
AiRule(ai) AiRule(ai)
{ {
interval= shortInterval; interval= shortInterval;
rt=NULL;
} }
bool AiRuleProduceResourceProducer::test(){ bool AiRuleProduceResourceProducer::test(){
@ -785,7 +790,7 @@ void AiRuleProduce::produceSpecific(const ProduceTask *pt){
int lowestCommandCount=1000000; int lowestCommandCount=1000000;
int currentProducerIndex=producers[randomstart]; int currentProducerIndex=producers[randomstart];
int bestIndex=-1; int bestIndex=-1;
int besti=0; //int besti=0;
int currentCommandCount=0; int currentCommandCount=0;
for(unsigned int i=randomstart; i<producers.size()+randomstart; i++) { for(unsigned int i=randomstart; i<producers.size()+randomstart; i++) {
int prIndex = i; int prIndex = i;
@ -817,7 +822,7 @@ void AiRuleProduce::produceSpecific(const ProduceTask *pt){
{ {
lowestCommandCount=aiInterface->getMyUnit(currentProducerIndex)->getCommandSize(); lowestCommandCount=aiInterface->getMyUnit(currentProducerIndex)->getCommandSize();
bestIndex=currentProducerIndex; bestIndex=currentProducerIndex;
besti=i%(producers.size()); //besti=i%(producers.size());
} }
} }
if( aiInterface->getMyUnit(bestIndex)->getCommandSize() > 2) { if( aiInterface->getMyUnit(bestIndex)->getCommandSize() > 2) {
@ -1173,9 +1178,9 @@ void AiRuleBuild::buildSpecific(const BuildTask *bt) {
const int enemySightDistanceToAvoid = 18; const int enemySightDistanceToAvoid = 18;
vector<Unit*> enemies; vector<Unit*> enemies;
ai->getAiInterface()->getWorld()->getUnitUpdater()->findEnemiesForCell(searchPos,bt->getUnitType()->getSize(),enemySightDistanceToAvoid,ai->getAiInterface()->getMyFaction(),enemies,true); ai->getAiInterface()->getWorld()->getUnitUpdater()->findEnemiesForCell(searchPos,bt->getUnitType()->getSize(),enemySightDistanceToAvoid,ai->getAiInterface()->getMyFaction(),enemies,true);
if(enemies.size() > 0) { if(enemies.empty() == false) {
for(int i1 = 0; i1 < 25 && enemies.size() > 0; ++i1) { for(int i1 = 0; i1 < 25 && enemies.empty() == false; ++i1) {
for(int j1 = 0; j1 < 25 && enemies.size() > 0; ++j1) { for(int j1 = 0; j1 < 25 && enemies.empty() == false; ++j1) {
Vec2i tryPos = searchPos + Vec2i(i1,j1); Vec2i tryPos = searchPos + Vec2i(i1,j1);
const int spacing = 1; const int spacing = 1;
@ -1189,9 +1194,9 @@ void AiRuleBuild::buildSpecific(const BuildTask *bt) {
} }
} }
} }
if(enemies.size() > 0) { if(enemies.empty() == false) {
for(int i1 = -1; i1 >= -25 && enemies.size() > 0; --i1) { for(int i1 = -1; i1 >= -25 && enemies.empty() == false; --i1) {
for(int j1 = -1; j1 >= -25 && enemies.size() > 0; --j1) { for(int j1 = -1; j1 >= -25 && enemies.empty() == false; --j1) {
Vec2i tryPos = searchPos + Vec2i(i1,j1); Vec2i tryPos = searchPos + Vec2i(i1,j1);
const int spacing = 1; const int spacing = 1;

View File

@ -115,7 +115,7 @@ private:
bool damagedUnitIsCastle; bool damagedUnitIsCastle;
int getMinUnitsToRepairCastle(); int getMinUnitsToRepairCastle();
double getMinCastleHpRatio(); double getMinCastleHpRatio() const;
public: public:
AiRuleRepair(Ai *ai); AiRuleRepair(Ai *ai);

View File

@ -101,7 +101,7 @@ void GraphicComponent::applyAllCustomProperties(std::string containerName) {
std::map<std::string, std::map<std::string, GraphicComponent *> >::iterator iterFind1 = GraphicComponent::registeredGraphicComponentList.find(containerName); std::map<std::string, std::map<std::string, GraphicComponent *> >::iterator iterFind1 = GraphicComponent::registeredGraphicComponentList.find(containerName);
if(iterFind1 != GraphicComponent::registeredGraphicComponentList.end()) { if(iterFind1 != GraphicComponent::registeredGraphicComponentList.end()) {
for(std::map<std::string, GraphicComponent *>::iterator iterFind2 = iterFind1->second.begin(); for(std::map<std::string, GraphicComponent *>::iterator iterFind2 = iterFind1->second.begin();
iterFind2 != iterFind1->second.end(); iterFind2++) { iterFind2 != iterFind1->second.end(); ++iterFind2) {
iterFind2->second->applyCustomProperties(containerName); iterFind2->second->applyCustomProperties(containerName);
} }
} }
@ -146,7 +146,7 @@ bool GraphicComponent::saveAllCustomProperties(std::string containerName) {
std::map<std::string, std::map<std::string, GraphicComponent *> >::iterator iterFind1 = GraphicComponent::registeredGraphicComponentList.find(containerName); std::map<std::string, std::map<std::string, GraphicComponent *> >::iterator iterFind1 = GraphicComponent::registeredGraphicComponentList.find(containerName);
if(iterFind1 != GraphicComponent::registeredGraphicComponentList.end()) { if(iterFind1 != GraphicComponent::registeredGraphicComponentList.end()) {
for(std::map<std::string, GraphicComponent *>::iterator iterFind2 = iterFind1->second.begin(); for(std::map<std::string, GraphicComponent *>::iterator iterFind2 = iterFind1->second.begin();
iterFind2 != iterFind1->second.end(); iterFind2++) { iterFind2 != iterFind1->second.end(); ++iterFind2) {
bool saved = iterFind2->second->saveCustomProperties(containerName); bool saved = iterFind2->second->saveCustomProperties(containerName);
foundPropertiesToSave = (saved || foundPropertiesToSave); foundPropertiesToSave = (saved || foundPropertiesToSave);
} }
@ -545,8 +545,8 @@ void GraphicScrollBar::init(int x, int y, bool horizontal,int length, int thickn
this->elementCount=1; this->elementCount=1;
this->visibleSize=1; this->visibleSize=1;
this->visibleStart=0; this->visibleStart=0;
int visibleCompPosStart=0; this->visibleCompPosStart=0;
int visibleCompPosEnd=length; this->visibleCompPosEnd=length;
lighted= false; lighted= false;
} }
@ -628,11 +628,11 @@ bool GraphicScrollBar::mouseMove(int x, int y){
return b; return b;
} }
int GraphicScrollBar::getLength() { int GraphicScrollBar::getLength() const {
return horizontal?getW():getH(); return horizontal?getW():getH();
} }
int GraphicScrollBar::getThickness() { int GraphicScrollBar::getThickness() const {
return horizontal?getH():getW(); return horizontal?getH():getW();
} }

View File

@ -314,9 +314,9 @@ public:
bool getHorizontal() const {return horizontal;} bool getHorizontal() const {return horizontal;}
int getLength(); int getLength() const;
void setLength(int length) {horizontal?setW(length):setH(length);} void setLength(int length) {horizontal?setW(length):setH(length);}
int getThickness(); int getThickness() const;
bool getLighted() const {return lighted;} bool getLighted() const {return lighted;}

View File

@ -43,6 +43,7 @@ ChatManager::ChatManager() {
maxTextLenght=64; maxTextLenght=64;
font=CoreData::getInstance().getConsoleFont(); font=CoreData::getInstance().getConsoleFont();
font3D=CoreData::getInstance().getConsoleFont3D(); font3D=CoreData::getInstance().getConsoleFont3D();
inMenu=false;
} }
void ChatManager::init(Console* console, int thisTeamIndex, const bool inMenu, string manualPlayerNameOverride) { void ChatManager::init(Console* console, int thisTeamIndex, const bool inMenu, string manualPlayerNameOverride) {
@ -207,7 +208,7 @@ void ChatManager::updateNetwork() {
GameNetworkInterface *gameNetworkInterface= NetworkManager::getInstance().getGameNetworkInterface(); GameNetworkInterface *gameNetworkInterface= NetworkManager::getInstance().getGameNetworkInterface();
//string text; //string text;
//string sender; //string sender;
Config &config= Config::getInstance(); //Config &config= Config::getInstance();
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] gameNetworkInterface->getChatText() [%s]\n",__FILE__,__FUNCTION__,__LINE__,gameNetworkInterface->getChatText().c_str()); //SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] gameNetworkInterface->getChatText() [%s]\n",__FILE__,__FUNCTION__,__LINE__,gameNetworkInterface->getChatText().c_str());

View File

@ -85,7 +85,7 @@ void CommanderNetworkThread::execute() {
try { try {
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
unsigned int idx = 0; //unsigned int idx = 0;
for(;this->commanderInterface != NULL;) { for(;this->commanderInterface != NULL;) {
if(getQuitStatus() == true) { if(getQuitStatus() == true) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
@ -135,6 +135,7 @@ Commander::Commander() {
//this->networkThread = new CommanderNetworkThread(this); //this->networkThread = new CommanderNetworkThread(this);
//this->networkThread->setUniqueID(__FILE__); //this->networkThread->setUniqueID(__FILE__);
//this->networkThread->start(); //this->networkThread->start();
world=NULL;
} }
Commander::~Commander() { Commander::~Commander() {
@ -709,7 +710,8 @@ Command* Commander::buildCommand(const NetworkCommand* networkCommand) const {
SystemFlags::OutputDebug(SystemFlags::debugError,"%s\n",szBuf); SystemFlags::OutputDebug(SystemFlags::debugError,"%s\n",szBuf);
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"%s\n",szBuf); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"%s\n",szBuf);
std::string worldLog = world->DumpWorldToLog(); //std::string worldLog = world->DumpWorldToLog();
world->DumpWorldToLog();
GameNetworkInterface *gameNetworkInterface= NetworkManager::getInstance().getGameNetworkInterface(); GameNetworkInterface *gameNetworkInterface= NetworkManager::getInstance().getGameNetworkInterface();
if(gameNetworkInterface != NULL && gameNetworkInterface->isConnected() == true) { if(gameNetworkInterface != NULL && gameNetworkInterface->isConnected() == true) {
@ -769,7 +771,8 @@ Command* Commander::buildCommand(const NetworkCommand* networkCommand) const {
__FILE__,__FUNCTION__,__LINE__,networkCommand->toString().c_str(),unit->getType()->getCommandTypeListDesc().c_str(),unit->getId(), unit->getFullName().c_str(),unit->getDesc().c_str(),unit->getFaction()->getIndex()); __FILE__,__FUNCTION__,__LINE__,networkCommand->toString().c_str(),unit->getType()->getCommandTypeListDesc().c_str(),unit->getId(), unit->getFullName().c_str(),unit->getDesc().c_str(),unit->getFaction()->getIndex());
SystemFlags::OutputDebug(SystemFlags::debugSystem,"%s\n",szBuf); SystemFlags::OutputDebug(SystemFlags::debugSystem,"%s\n",szBuf);
std::string worldLog = world->DumpWorldToLog(); //std::string worldLog = world->DumpWorldToLog();
world->DumpWorldToLog();
GameNetworkInterface *gameNetworkInterface= NetworkManager::getInstance().getGameNetworkInterface(); GameNetworkInterface *gameNetworkInterface= NetworkManager::getInstance().getGameNetworkInterface();
if(gameNetworkInterface != NULL) { if(gameNetworkInterface != NULL) {

View File

@ -46,6 +46,43 @@ Game::Game() : ProgramState(NULL) {
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
originalDisplayMsgCallback = NULL; originalDisplayMsgCallback = NULL;
aiInterfaces.clear(); aiInterfaces.clear();
mouse2d=0;
mouseX=0;
mouseY=0;
updateFps=0;
lastUpdateFps=0;
avgUpdateFps=0;
totalRenderFps=0;
renderFps=0;
lastRenderFps=0;
avgRenderFps=0;
currentAvgRenderFpsTotal=0;
paused=false;
gameOver=false;
renderNetworkStatus=false;
showFullConsole=false;
mouseMoved=false;
scrollSpeed=0;
camLeftButtonDown=false;
camRightButtonDown=false;
camUpButtonDown=false;
camDownButtonDown=false;
speed=sNormal;
weatherParticleSystem=NULL;
isFirstRender=false;
quitTriggeredIndicator=false;
original_updateFps=0;
original_cameraFps=0;
captureAvgTestStatus=false;
updateFpsAvgTest=0;
renderFpsAvgTest=0;
renderExtraTeamColor=0;
photoModeEnabled=false;
visibleHUD=false;
withRainEffect=false;
program=NULL;
gameStarted=false;
} }
Game::Game(Program *program, const GameSettings *gameSettings): Game::Game(Program *program, const GameSettings *gameSettings):
@ -222,7 +259,7 @@ string Game::extractScenarioLogoFile(const GameSettings *settings, string &resul
vector<string> loadScreenList; vector<string> loadScreenList;
findAll(scenarioDir + factionLogoFilter, loadScreenList, false, false); findAll(scenarioDir + factionLogoFilter, loadScreenList, false, false);
if(loadScreenList.size() > 0) { if(loadScreenList.empty() == false) {
string senarioLogo = scenarioDir + loadScreenList[0]; string senarioLogo = scenarioDir + loadScreenList[0];
if(fileExists(senarioLogo) == true) { if(fileExists(senarioLogo) == true) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] found scenario loading screen '%s'\n",__FILE__,__FUNCTION__,senarioLogo.c_str()); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] found scenario loading screen '%s'\n",__FILE__,__FUNCTION__,senarioLogo.c_str());
@ -288,7 +325,7 @@ string Game::extractFactionLogoFile(bool &loadingImageUsed, string factionName,
vector<string> loadScreenList; vector<string> loadScreenList;
findAll(path + factionLogoFilter, loadScreenList, false, false); findAll(path + factionLogoFilter, loadScreenList, false, false);
if(loadScreenList.size() > 0) { if(loadScreenList.empty() == false) {
string factionLogo = path + loadScreenList[0]; string factionLogo = path + loadScreenList[0];
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] looking for loading screen '%s'\n",__FILE__,__FUNCTION__,__LINE__,factionLogo.c_str()); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] looking for loading screen '%s'\n",__FILE__,__FUNCTION__,__LINE__,factionLogo.c_str());
@ -332,7 +369,7 @@ string Game::extractTechLogoFile(string scenarioDir, string techName,
vector<string> loadScreenList; vector<string> loadScreenList;
findAll(path + factionLogoFilter, loadScreenList, false, false); findAll(path + factionLogoFilter, loadScreenList, false, false);
if(loadScreenList.size() > 0) { if(loadScreenList.empty() == false) {
string factionLogo = path + loadScreenList[0]; string factionLogo = path + loadScreenList[0];
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] looking for loading screen '%s'\n",__FILE__,__FUNCTION__,__LINE__,factionLogo.c_str()); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] looking for loading screen '%s'\n",__FILE__,__FUNCTION__,__LINE__,factionLogo.c_str());
@ -379,7 +416,7 @@ void Game::loadHudTexture(const GameSettings *settings)
string path= currentPath + techName + "/" + "factions" + "/" + factionName; string path= currentPath + techName + "/" + "factions" + "/" + factionName;
endPathWithSlash(path); endPathWithSlash(path);
findAll(path + "hud.*", hudList, false, false); findAll(path + "hud.*", hudList, false, false);
if(hudList.size() > 0){ if(hudList.empty() == false){
string hudImageFileName= path + hudList[0]; string hudImageFileName= path + hudList[0];
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled)
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] looking for a HUD '%s'\n",__FILE__,__FUNCTION__,__LINE__,hudImageFileName.c_str()); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] looking for a HUD '%s'\n",__FILE__,__FUNCTION__,__LINE__,hudImageFileName.c_str());
@ -464,7 +501,7 @@ vector<Texture2D *> Game::processTech(string techName) {
endPathWithSlash(techPath); endPathWithSlash(techPath);
findAll(techPath + techName + "/factions/*.", factions, false, false); findAll(techPath + techName + "/factions/*.", factions, false, false);
if(factions.size() > 0) { if(factions.empty() == false) {
for(unsigned int factionIdx = 0; factionIdx < factions.size(); ++factionIdx) { for(unsigned int factionIdx = 0; factionIdx < factions.size(); ++factionIdx) {
bool loadingImageUsed = false; bool loadingImageUsed = false;
string factionLogo = ""; string factionLogo = "";
@ -1950,7 +1987,7 @@ void Game::render3d(){
void Game::render2d(){ void Game::render2d(){
Renderer &renderer= Renderer::getInstance(); Renderer &renderer= Renderer::getInstance();
Config &config= Config::getInstance(); //Config &config= Config::getInstance();
CoreData &coreData= CoreData::getInstance(); CoreData &coreData= CoreData::getInstance();
//init //init
@ -2126,9 +2163,9 @@ void Game::render2d(){
if(renderer.getShowDebugUI() == true) { if(renderer.getShowDebugUI() == true) {
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();
const Vec4f fontColor=getGui()->getDisplay()->getColor(); const Vec4f fontColor=getGui()->getDisplay()->getColor();
@ -2176,9 +2213,9 @@ void Game::render2d(){
if(NetworkManager::getInstance().getGameNetworkInterface() != NULL) { if(NetworkManager::getInstance().getGameNetworkInterface() != NULL) {
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();
const Vec4f fontColor=getGui()->getDisplay()->getColor(); const Vec4f fontColor=getGui()->getDisplay()->getColor();
if(Renderer::renderText3DEnabled == true) { if(Renderer::renderText3DEnabled == true) {

View File

@ -74,6 +74,11 @@ GameCamera::GameCamera() : pos(0.f, defaultHeight, 0.f),
minVAng = -Config::getInstance().getFloat("CameraMaxYaw","77.5"); minVAng = -Config::getInstance().getFloat("CameraMaxYaw","77.5");
maxVAng = -Config::getInstance().getFloat("CameraMinYaw","20"); maxVAng = -Config::getInstance().getFloat("CameraMinYaw","20");
fov = Config::getInstance().getFloat("CameraFov","45"); fov = Config::getInstance().getFloat("CameraFov","45");
lastHAng=0;
lastVAng=0;
limitX=0;
limitY=0;
} }
GameCamera::~GameCamera() { GameCamera::~GameCamera() {

View File

@ -80,6 +80,11 @@ private:
public: public:
GameSettings() { GameSettings() {
defaultUnits=false;
defaultResources=false;
defaultVictoryConditions=false;
mapFilterIndex = 0;
factionCount = 0;
thisFactionIndex = 0; thisFactionIndex = 0;
fogOfWar = true; fogOfWar = true;
allowObservers = false; allowObservers = false;
@ -131,7 +136,7 @@ public:
} }
} }
} }
if(languageList.size() == 0) { if(languageList.empty() == true) {
languageList.push_back(""); languageList.push_back("");
} }
return languageList; return languageList;

View File

@ -220,7 +220,7 @@ void ScriptManager::onTimerTriggerEvent() {
if(SystemFlags::getSystemSettingType(SystemFlags::debugLUA).enabled) SystemFlags::OutputDebug(SystemFlags::debugLUA,"In [%s::%s Line: %d] TimerTriggerEventList.size() = %d\n",__FILE__,__FUNCTION__,__LINE__,TimerTriggerEventList.size()); if(SystemFlags::getSystemSettingType(SystemFlags::debugLUA).enabled) SystemFlags::OutputDebug(SystemFlags::debugLUA,"In [%s::%s Line: %d] TimerTriggerEventList.size() = %d\n",__FILE__,__FUNCTION__,__LINE__,TimerTriggerEventList.size());
for(std::map<int,TimerTriggerEvent>::iterator iterMap = TimerTriggerEventList.begin(); for(std::map<int,TimerTriggerEvent>::iterator iterMap = TimerTriggerEventList.begin();
iterMap != TimerTriggerEventList.end(); iterMap++) { iterMap != TimerTriggerEventList.end(); ++iterMap) {
TimerTriggerEvent &event = iterMap->second; TimerTriggerEvent &event = iterMap->second;
@ -251,7 +251,7 @@ void ScriptManager::onCellTriggerEvent(Unit *movingUnit) {
inCellTriggerEvent = true; inCellTriggerEvent = true;
if(movingUnit != NULL) { if(movingUnit != NULL) {
for(std::map<int,CellTriggerEvent>::iterator iterMap = CellTriggerEventList.begin(); for(std::map<int,CellTriggerEvent>::iterator iterMap = CellTriggerEventList.begin();
iterMap != CellTriggerEventList.end(); iterMap++) { iterMap != CellTriggerEventList.end(); ++iterMap) {
CellTriggerEvent &event = iterMap->second; CellTriggerEvent &event = iterMap->second;
if(SystemFlags::getSystemSettingType(SystemFlags::debugLUA).enabled) SystemFlags::OutputDebug(SystemFlags::debugLUA,"In [%s::%s Line: %d] movingUnit = %d, event.type = %d, movingUnit->getPos() = %s, event.sourceId = %d, event.destId = %d, event.destPos = %s\n", if(SystemFlags::getSystemSettingType(SystemFlags::debugLUA).enabled) SystemFlags::OutputDebug(SystemFlags::debugLUA,"In [%s::%s Line: %d] movingUnit = %d, event.type = %d, movingUnit->getPos() = %s, event.sourceId = %d, event.destId = %d, event.destPos = %s\n",
@ -642,7 +642,7 @@ void ScriptManager::unregisterCellTriggerEvent(int eventId) {
} }
if(inCellTriggerEvent == false) { if(inCellTriggerEvent == false) {
if(unRegisterCellTriggerEventList.size() > 0) { if(unRegisterCellTriggerEventList.empty() == false) {
for(int i = 0; i < unRegisterCellTriggerEventList.size(); ++i) { for(int i = 0; i < unRegisterCellTriggerEventList.size(); ++i) {
int delayedEventId = unRegisterCellTriggerEventList[i]; int delayedEventId = unRegisterCellTriggerEventList[i];
if(CellTriggerEventList.find(delayedEventId) != CellTriggerEventList.end()) { if(CellTriggerEventList.find(delayedEventId) != CellTriggerEventList.end()) {

View File

@ -77,7 +77,7 @@ ParticleSystemType::~ParticleSystemType() {
memoryObjectList[this]--; memoryObjectList[this]--;
assert(memoryObjectList[this] == 0); assert(memoryObjectList[this] == 0);
} }
for(Children::iterator it = children.begin(); it != children.end(); it++) for(Children::iterator it = children.begin(); it != children.end(); ++it)
delete *it; delete *it;
} }
@ -101,7 +101,7 @@ void ParticleSystemType::copyAll(const ParticleSystemType &src) {
this->teamcolorNoEnergy = src.teamcolorNoEnergy; this->teamcolorNoEnergy = src.teamcolorNoEnergy;
this->teamcolorEnergy = src.teamcolorEnergy; this->teamcolorEnergy = src.teamcolorEnergy;
this->alternations = src.alternations; this->alternations = src.alternations;
for(Children::iterator it = children.begin(); it != children.end(); it++) { for(Children::iterator it = children.begin(); it != children.end(); ++it) {
UnitParticleSystemType *child = *it; UnitParticleSystemType *child = *it;
// Deep copy the child particles // Deep copy the child particles
@ -265,7 +265,7 @@ void ParticleSystemType::load(const XmlNode *particleSystemNode, const string &d
void ParticleSystemType::setValues(AttackParticleSystem *ats){ void ParticleSystemType::setValues(AttackParticleSystem *ats){
// add instances of all children; some settings will cascade to all children // add instances of all children; some settings will cascade to all children
for(Children::iterator i=children.begin(); i!=children.end(); i++){ for(Children::iterator i=children.begin(); i!=children.end(); ++i){
UnitParticleSystem *child = new UnitParticleSystem(); UnitParticleSystem *child = new UnitParticleSystem();
(*i)->setValues(child); (*i)->setValues(child);
ats->addChild(child); ats->addChild(child);

View File

@ -273,7 +273,7 @@ void Renderer::simpleTask(BaseThread *callingThread) {
string path=""; string path="";
static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__); static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__);
MutexSafeWrapper safeMutex(&saveScreenShotThreadAccessor,mutexOwnerId); MutexSafeWrapper safeMutex(&saveScreenShotThreadAccessor,mutexOwnerId);
if(saveScreenQueue.size() > 0) { if(saveScreenQueue.empty() == false) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d] saveScreenQueue.size() = %d\n",__FILE__,__FUNCTION__,__LINE__,saveScreenQueue.size()); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d] saveScreenQueue.size() = %d\n",__FILE__,__FUNCTION__,__LINE__,saveScreenQueue.size());
savePixMapBuffer = saveScreenQueue.front().second; savePixMapBuffer = saveScreenQueue.front().second;
@ -797,7 +797,7 @@ void Renderer::computeVisibleQuad() {
br = _unprojectMap(Vec2i(viewport[2],viewport[3]),model,projection,viewport,"br"), br = _unprojectMap(Vec2i(viewport[2],viewport[3]),model,projection,viewport,"br"),
bl = _unprojectMap(Vec2i(0,viewport[3]),model,projection,viewport,"bl"); bl = _unprojectMap(Vec2i(0,viewport[3]),model,projection,viewport,"bl");
// orientate it for map iterator // orientate it for map iterator
bool swapRequiredX = false; //bool swapRequiredX = false;
bool swapRequiredY = false; bool swapRequiredY = false;
int const cellBuffer = 4; int const cellBuffer = 4;
if((tl.x > tr.x) || (bl.x > br.x)) { if((tl.x > tr.x) || (bl.x > br.x)) {
@ -812,7 +812,7 @@ void Renderer::computeVisibleQuad() {
tl.x -= cellBuffer; tl.x -= cellBuffer;
std::swap(tl.x,tr.x); std::swap(tl.x,tr.x);
swapRequiredX = true; //swapRequiredX = true;
} }
else { else {
tl.x += cellBuffer; tl.x += cellBuffer;
@ -825,7 +825,7 @@ void Renderer::computeVisibleQuad() {
br.x -= cellBuffer; br.x -= cellBuffer;
std::swap(bl.x,br.x); std::swap(bl.x,br.x);
swapRequiredX = true; //swapRequiredX = true;
} }
else { else {
br.x += cellBuffer; br.x += cellBuffer;
@ -1135,7 +1135,7 @@ void Renderer::renderTextureQuad(int x, int y, int w, int h, const Texture2D *te
void Renderer::renderConsoleLine3D(int lineIndex, int xPosition, int yPosition, int lineHeight, void Renderer::renderConsoleLine3D(int lineIndex, int xPosition, int yPosition, int lineHeight,
Font3D* font, string stringToHightlight, const ConsoleLineInfo *lineInfo) { Font3D* font, string stringToHightlight, const ConsoleLineInfo *lineInfo) {
Vec4f fontColor; Vec4f fontColor;
const Metrics &metrics= Metrics::getInstance(); //const Metrics &metrics= Metrics::getInstance();
FontMetrics *fontMetrics= font->getMetrics(); FontMetrics *fontMetrics= font->getMetrics();
if(game != NULL) { if(game != NULL) {
@ -2769,15 +2769,15 @@ void Renderer::MapRenderer::Layer::render(VisibleQuadContainerCache &qCache) {
const bool renderOnlyVisibleQuad = true; const bool renderOnlyVisibleQuad = true;
if(renderOnlyVisibleQuad == true) { if(renderOnlyVisibleQuad == true) {
int startIndex = -1;
int lastValidIndex = -1;
vector<pair<int,int> > rowsToRender; vector<pair<int,int> > rowsToRender;
if(rowsToRenderCache.find(qCache.lastVisibleQuad) != rowsToRenderCache.end()) { if(rowsToRenderCache.find(qCache.lastVisibleQuad) != rowsToRenderCache.end()) {
rowsToRender = rowsToRenderCache[qCache.lastVisibleQuad]; rowsToRender = rowsToRenderCache[qCache.lastVisibleQuad];
} }
else { else {
int startIndex = -1;
int lastValidIndex = -1;
for(int visibleIndex = 0; for(int visibleIndex = 0;
visibleIndex < qCache.visibleScaledCellList.size(); ++visibleIndex) { visibleIndex < qCache.visibleScaledCellList.size(); ++visibleIndex) {
Vec2i &pos = qCache.visibleScaledCellList[visibleIndex]; Vec2i &pos = qCache.visibleScaledCellList[visibleIndex];
@ -2806,7 +2806,7 @@ void Renderer::MapRenderer::Layer::render(VisibleQuadContainerCache &qCache) {
rowsToRenderCache[qCache.lastVisibleQuad] = rowsToRender; rowsToRenderCache[qCache.lastVisibleQuad] = rowsToRender;
} }
if(rowsToRender.size() > 0) { if(rowsToRender.empty() == false) {
//printf("Layer has %d rows in visible quad, visible quad has %d cells\n",rowsToRender.size(),qCache.visibleScaledCellList.size()); //printf("Layer has %d rows in visible quad, visible quad has %d cells\n",rowsToRender.size(),qCache.visibleScaledCellList.size());
glVertexPointer(3,GL_FLOAT,0,_bindVBO(vbo_vertices,vertices)); glVertexPointer(3,GL_FLOAT,0,_bindVBO(vbo_vertices,vertices));
@ -2960,11 +2960,8 @@ void Renderer::renderSurface(const int renderFps) {
} }
} }
int lastTex=-1;
int currTex=-1;
const Rect2i mapBounds(0, 0, map->getSurfaceW()-1, map->getSurfaceH()-1); const Rect2i mapBounds(0, 0, map->getSurfaceW()-1, map->getSurfaceH()-1);
glActiveTexture(baseTexUnit); glActiveTexture(baseTexUnit);
VisibleQuadContainerCache &qCache = getQuadCache(); VisibleQuadContainerCache &qCache = getQuadCache();
@ -2975,7 +2972,10 @@ void Renderer::renderSurface(const int renderFps) {
//mapRenderer.render(map,coordStep,qCache); //mapRenderer.render(map,coordStep,qCache);
mapRenderer.renderVisibleLayers(map,coordStep,qCache); mapRenderer.renderVisibleLayers(map,coordStep,qCache);
} }
else if(qCache.visibleScaledCellList.size() > 0) { else if(qCache.visibleScaledCellList.empty() == false) {
int lastTex=-1;
int currTex=-1;
Quad2i snapshotOfvisibleQuad = visibleQuad; Quad2i snapshotOfvisibleQuad = visibleQuad;
@ -3561,7 +3561,7 @@ void Renderer::renderWater() {
void Renderer::renderTeamColorCircle(){ void Renderer::renderTeamColorCircle(){
VisibleQuadContainerCache &qCache = getQuadCache(); VisibleQuadContainerCache &qCache = getQuadCache();
if(qCache.visibleQuadUnitList.size() > 0) { if(qCache.visibleQuadUnitList.empty() == false) {
glPushAttrib(GL_ENABLE_BIT | GL_CURRENT_BIT | GL_DEPTH_BUFFER_BIT); glPushAttrib(GL_ENABLE_BIT | GL_CURRENT_BIT | GL_DEPTH_BUFFER_BIT);
glDisable(GL_LIGHTING); glDisable(GL_LIGHTING);
@ -3586,7 +3586,7 @@ void Renderer::renderTeamColorCircle(){
void Renderer::renderTeamColorPlane(){ void Renderer::renderTeamColorPlane(){
VisibleQuadContainerCache &qCache = getQuadCache(); VisibleQuadContainerCache &qCache = getQuadCache();
if(qCache.visibleQuadUnitList.size() > 0){ if(qCache.visibleQuadUnitList.empty() == false){
glPushAttrib(GL_ENABLE_BIT); glPushAttrib(GL_ENABLE_BIT);
glDisable(GL_LIGHTING); glDisable(GL_LIGHTING);
glEnable(GL_TEXTURE_2D); glEnable(GL_TEXTURE_2D);
@ -3608,8 +3608,8 @@ void Renderer::renderTeamColorPlane(){
void Renderer::renderUnits(const int renderFps) { void Renderer::renderUnits(const int renderFps) {
Unit *unit=NULL; //Unit *unit=NULL;
const World *world= game->getWorld(); //const World *world= game->getWorld();
MeshCallbackTeamColor meshCallbackTeamColor; MeshCallbackTeamColor meshCallbackTeamColor;
//assert //assert
@ -3626,7 +3626,7 @@ void Renderer::renderUnits(const int renderFps) {
bool modelRenderStarted = false; bool modelRenderStarted = false;
VisibleQuadContainerCache &qCache = getQuadCache(); VisibleQuadContainerCache &qCache = getQuadCache();
if(qCache.visibleQuadUnitList.size() > 0) { if(qCache.visibleQuadUnitList.empty() == false) {
for(int visibleUnitIndex = 0; for(int visibleUnitIndex = 0;
visibleUnitIndex < qCache.visibleQuadUnitList.size(); ++visibleUnitIndex) { visibleUnitIndex < qCache.visibleQuadUnitList.size(); ++visibleUnitIndex) {
Unit *unit = qCache.visibleQuadUnitList[visibleUnitIndex]; Unit *unit = qCache.visibleQuadUnitList[visibleUnitIndex];
@ -3674,10 +3674,9 @@ void Renderer::renderUnits(const int renderFps) {
glRotatef(unit->getRotation(), 0.f, 1.f, 0.f); glRotatef(unit->getRotation(), 0.f, 1.f, 0.f);
//dead alpha //dead alpha
float alpha= 1.0f;
const SkillType *st= unit->getCurrSkill(); const SkillType *st= unit->getCurrSkill();
if(st->getClass() == scDie && static_cast<const DieSkillType*>(st)->getFade()) { if(st->getClass() == scDie && static_cast<const DieSkillType*>(st)->getFade()) {
alpha= 1.0f-unit->getAnimProgress(); float alpha= 1.0f-unit->getAnimProgress();
glDisable(GL_COLOR_MATERIAL); glDisable(GL_COLOR_MATERIAL);
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, Vec4f(1.0f, 1.0f, 1.0f, alpha).ptr()); glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, Vec4f(1.0f, 1.0f, 1.0f, alpha).ptr());
} }
@ -3727,9 +3726,9 @@ void Renderer::renderUnits(const int renderFps) {
} }
void Renderer::renderTeamColorEffect(Vec3f &v, int heigth, int size, Vec3f color, const Texture2D *texture) { void Renderer::renderTeamColorEffect(Vec3f &v, int heigth, int size, Vec3f color, const Texture2D *texture) {
GLUquadricObj *disc; //GLUquadricObj *disc;
float halfSize=size; float halfSize=size;
halfSize=halfSize; //halfSize=halfSize;
float heigthoffset=0.5+heigth%25*0.004; float heigthoffset=0.5+heigth%25*0.004;
glPushMatrix(); glPushMatrix();
glBindTexture(GL_TEXTURE_2D, static_cast<const Texture2DGl*>(texture)->getHandle()); glBindTexture(GL_TEXTURE_2D, static_cast<const Texture2DGl*>(texture)->getHandle());
@ -4336,7 +4335,7 @@ void Renderer::renderMinimap(){
//draw units //draw units
VisibleQuadContainerCache &qCache = getQuadCache(); VisibleQuadContainerCache &qCache = getQuadCache();
if(qCache.visibleUnitList.size() > 0) { if(qCache.visibleUnitList.empty() == false) {
uint32 unitIdx=0; uint32 unitIdx=0;
vector<Vec2f> unit_vertices; vector<Vec2f> unit_vertices;
unit_vertices.resize(qCache.visibleUnitList.size()*4); unit_vertices.resize(qCache.visibleUnitList.size()*4);
@ -4827,7 +4826,7 @@ void Renderer::computeSelected( Selection::UnitContainer &units, const Object *&
if(index>=OBJECT_SELECT_OFFSET) if(index>=OBJECT_SELECT_OFFSET)
{ {
Object *object = qCache.visibleObjectList[index-OBJECT_SELECT_OFFSET]; Object *object = qCache.visibleObjectList[index-OBJECT_SELECT_OFFSET];
if(object != NULL && object) { if(object != NULL) {
obj=object; obj=object;
if(withObjectSelection) { if(withObjectSelection) {
break; break;
@ -5303,7 +5302,7 @@ void Renderer::renderUnitsFast(bool renderingShadows) {
bool modelRenderStarted = false; bool modelRenderStarted = false;
VisibleQuadContainerCache &qCache = getQuadCache(); VisibleQuadContainerCache &qCache = getQuadCache();
if(qCache.visibleQuadUnitList.size() > 0) { if(qCache.visibleQuadUnitList.empty() == false) {
for(int visibleUnitIndex = 0; for(int visibleUnitIndex = 0;
visibleUnitIndex < qCache.visibleQuadUnitList.size(); ++visibleUnitIndex) { visibleUnitIndex < qCache.visibleQuadUnitList.size(); ++visibleUnitIndex) {
Unit *unit = qCache.visibleQuadUnitList[visibleUnitIndex]; Unit *unit = qCache.visibleQuadUnitList[visibleUnitIndex];
@ -5372,14 +5371,14 @@ void Renderer::renderUnitsFast(bool renderingShadows) {
//render objects for selection purposes //render objects for selection purposes
void Renderer::renderObjectsFast(bool renderingShadows, bool resourceOnly) { void Renderer::renderObjectsFast(bool renderingShadows, bool resourceOnly) {
const World *world= game->getWorld(); const World *world= game->getWorld();
const Map *map= world->getMap(); //const Map *map= world->getMap();
assertGl(); assertGl();
bool modelRenderStarted = false; bool modelRenderStarted = false;
VisibleQuadContainerCache &qCache = getQuadCache(); VisibleQuadContainerCache &qCache = getQuadCache();
if(qCache.visibleObjectList.size() > 0) { if(qCache.visibleObjectList.empty() == false) {
for(int visibleIndex = 0; for(int visibleIndex = 0;
visibleIndex < qCache.visibleObjectList.size(); ++visibleIndex) { visibleIndex < qCache.visibleObjectList.size(); ++visibleIndex) {
Object *o = qCache.visibleObjectList[visibleIndex]; Object *o = qCache.visibleObjectList[visibleIndex];
@ -6071,7 +6070,7 @@ void Renderer::setAllowRenderUnitTitles(bool value) {
void Renderer::renderUnitTitles3D(Font3D *font, Vec3f color) { void Renderer::renderUnitTitles3D(Font3D *font, Vec3f color) {
std::map<int,bool> unitRenderedList; std::map<int,bool> unitRenderedList;
if(visibleFrameUnitList.size() > 0) { if(visibleFrameUnitList.empty() == false) {
//printf("Render Unit titles ON\n"); //printf("Render Unit titles ON\n");
for(int idx = 0; idx < visibleFrameUnitList.size(); idx++) { for(int idx = 0; idx < visibleFrameUnitList.size(); idx++) {
@ -6105,7 +6104,7 @@ void Renderer::renderUnitTitles3D(Font3D *font, Vec3f color) {
} }
/* /*
if(renderUnitTitleList.size() > 0) { if(renderUnitTitleList.empty() == false) {
for(int idx = 0; idx < renderUnitTitleList.size(); idx++) { for(int idx = 0; idx < renderUnitTitleList.size(); idx++) {
std::pair<Unit *,Vec3f> &unitInfo = renderUnitTitleList[idx]; std::pair<Unit *,Vec3f> &unitInfo = renderUnitTitleList[idx];
Unit *unit = unitInfo.first; Unit *unit = unitInfo.first;
@ -6130,7 +6129,7 @@ void Renderer::renderUnitTitles3D(Font3D *font, Vec3f color) {
void Renderer::renderUnitTitles(Font2D *font, Vec3f color) { void Renderer::renderUnitTitles(Font2D *font, Vec3f color) {
std::map<int,bool> unitRenderedList; std::map<int,bool> unitRenderedList;
if(visibleFrameUnitList.size() > 0) { if(visibleFrameUnitList.empty() == false) {
//printf("Render Unit titles ON\n"); //printf("Render Unit titles ON\n");
for(int idx = 0; idx < visibleFrameUnitList.size(); idx++) { for(int idx = 0; idx < visibleFrameUnitList.size(); idx++) {
@ -6162,7 +6161,7 @@ void Renderer::renderUnitTitles(Font2D *font, Vec3f color) {
} }
/* /*
if(renderUnitTitleList.size() > 0) { if(renderUnitTitleList.empty() == false) {
for(int idx = 0; idx < renderUnitTitleList.size(); idx++) { for(int idx = 0; idx < renderUnitTitleList.size(); idx++) {
std::pair<Unit *,Vec3f> &unitInfo = renderUnitTitleList[idx]; std::pair<Unit *,Vec3f> &unitInfo = renderUnitTitleList[idx];
Unit *unit = unitInfo.first; Unit *unit = unitInfo.first;

View File

@ -270,7 +270,11 @@ private:
class SurfaceData { class SurfaceData {
public: public:
SurfaceData(){}; SurfaceData() {
uniqueId=0;
bufferCount=0;
textureHandle=0;
}
static uint32 nextUniqueId; static uint32 nextUniqueId;
uint32 uniqueId; uint32 uniqueId;
int bufferCount; int bufferCount;

View File

@ -185,7 +185,7 @@ void UnitParticleSystemType::load(const XmlNode *particleSystemNode, const strin
const void UnitParticleSystemType::setValues(UnitParticleSystem *ups){ const void UnitParticleSystemType::setValues(UnitParticleSystem *ups){
// whilst we extend ParticleSystemType we don't use ParticleSystemType::setValues() // whilst we extend ParticleSystemType we don't use ParticleSystemType::setValues()
// add instances of all children; some settings will cascade to all children // add instances of all children; some settings will cascade to all children
for(Children::iterator i=children.begin(); i!=children.end(); i++){ for(Children::iterator i=children.begin(); i!=children.end(); ++i){
UnitParticleSystem *child = new UnitParticleSystem(); UnitParticleSystem *child = new UnitParticleSystem();
(*i)->setValues(child); (*i)->setValues(child);
ups->addChild(child); ups->addChild(child);

View File

@ -94,7 +94,7 @@ void Display::switchColor(){
currentColor= (currentColor+1) % colorCount; currentColor= (currentColor+1) % colorCount;
} }
int Display::computeDownIndex(int x, int y){ int Display::computeDownIndex(int x, int y) const {
y= y-(downY-cellSideCount*imageSize); y= y-(downY-cellSideCount*imageSize);
if(y>imageSize*cellSideCount || y < 0){ if(y>imageSize*cellSideCount || y < 0){

View File

@ -74,8 +74,8 @@ public:
const Texture2D *getUpImage(int index) const {return upImages[index];} const Texture2D *getUpImage(int index) const {return upImages[index];}
const Texture2D *getDownImage(int index) const {return downImages[index];} const Texture2D *getDownImage(int index) const {return downImages[index];}
bool getDownLighted(int index) const {return downLighted[index];} bool getDownLighted(int index) const {return downLighted[index];}
const CommandType *getCommandType(int i) {return commandTypes[i];} const CommandType *getCommandType(int i) const {return commandTypes[i];}
CommandClass getCommandClass(int i) {return commandClasses[i];} CommandClass getCommandClass(int i) const {return commandClasses[i];}
Vec4f getColor() const; Vec4f getColor() const;
int getProgressBar() const {return progressBar;} int getProgressBar() const {return progressBar;}
int getDownSelectedPos() const {return downSelectedPos;} int getDownSelectedPos() const {return downSelectedPos;}
@ -97,7 +97,7 @@ public:
//misc //misc
void clear(); void clear();
void switchColor(); void switchColor();
int computeDownIndex(int x, int y); int computeDownIndex(int x, int y) const;
int computeDownX(int index) const; int computeDownX(int index) const;
int computeDownY(int index) const; int computeDownY(int index) const;
int computeUpX(int index) const; int computeUpX(int index) const;

View File

@ -112,6 +112,12 @@ Gui::Gui(){
minQuadSize=20; minQuadSize=20;
selectedResourceObject=NULL; selectedResourceObject=NULL;
hudTexture=NULL; hudTexture=NULL;
commander=NULL;
world=NULL;
game=NULL;
gameCamera=NULL;
console=NULL;
choosenBuildingType=NULL;
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] END\n",__FILE__,__FUNCTION__); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] END\n",__FILE__,__FUNCTION__);
} }
@ -640,7 +646,7 @@ void Gui::mouseDownDisplayUnitBuild(int posDisplay){
string Gui::computeDefaultInfoString() { string Gui::computeDefaultInfoString() {
Lang &lang= Lang::getInstance(); //Lang &lang= Lang::getInstance();
string result=""; string result="";
//printf("\n\n\n\n********* selection.isCommandable() [%d] selection.isUniform() [%d]\n\n",selection.isCommandable(),selection.isUniform()); //printf("\n\n\n\n********* selection.isCommandable() [%d] selection.isUniform() [%d]\n\n",selection.isCommandable(),selection.isUniform());
@ -972,7 +978,7 @@ void Gui::computeSelected(bool doubleClick, bool force){
activeCommandType= NULL; activeCommandType= NULL;
//select all units of the same type if double click //select all units of the same type if double click
if(doubleClick && units.size()>0){ if(doubleClick && units.empty() == false){
const Unit *refUnit= getRelevantObjectFromSelection(&units); const Unit *refUnit= getRelevantObjectFromSelection(&units);
int factionIndex= refUnit->getFactionIndex(); int factionIndex= refUnit->getFactionIndex();
for(int i=0; i<world->getFaction(factionIndex)->getUnitCount(); ++i){ for(int i=0; i<world->getFaction(factionIndex)->getUnitCount(); ++i){

View File

@ -80,7 +80,7 @@ void BattleEnd::update() {
void BattleEnd::render() { void BattleEnd::render() {
Renderer &renderer= Renderer::getInstance(); Renderer &renderer= Renderer::getInstance();
CoreData &coreData= CoreData::getInstance(); //CoreData &coreData= CoreData::getInstance();
canRender(); canRender();
incrementFps(); incrementFps();
@ -146,7 +146,7 @@ void BattleEnd::render() {
continue; continue;
} }
int team= stats.getTeam(i) + 1; //int team= stats.getTeam(i) + 1;
int kills= stats.getKills(i); int kills= stats.getKills(i);
if(kills > bestKills) { if(kills > bestKills) {
bestKills = kills; bestKills = kills;

View File

@ -47,6 +47,7 @@ Text::Text(const Texture2D *texture, const Vec2i &pos, const Vec2i &size, int ti
this->time= time; this->time= time;
this->texture= texture; this->texture= texture;
this->font= NULL; this->font= NULL;
this->font3D=NULL;
} }
// ===================================================== // =====================================================

View File

@ -1365,14 +1365,14 @@ void setupLogging(Config &config, bool haveSpecialOutputCommandLineOption) {
} }
void runTechValidationForPath(string techPath, string techName, void runTechValidationForPath(string techPath, string techName,
const std::vector<string> filteredFactionList, World &world, const std::vector<string> &filteredFactionList, World &world,
bool purgeUnusedFiles,bool purgeDuplicateFiles, bool showDuplicateFiles, bool purgeUnusedFiles,bool purgeDuplicateFiles, bool showDuplicateFiles,
bool svnPurgeFiles,double &purgedMegaBytes) { bool svnPurgeFiles,double &purgedMegaBytes) {
Config &config = Config::getInstance(); //Config &config = Config::getInstance();
vector<string> factionsList; vector<string> factionsList;
findDirs(techPath + techName + "/factions/", factionsList, false, false); findDirs(techPath + techName + "/factions/", factionsList, false, false);
if(factionsList.size() > 0) { if(factionsList.empty() == false) {
Checksum checksum; Checksum checksum;
set<string> factions; set<string> factions;
for(int j = 0; j < factionsList.size(); ++j) { for(int j = 0; j < factionsList.size(); ++j) {
@ -1391,7 +1391,7 @@ void runTechValidationForPath(string techPath, string techName,
} }
} }
if(factions.size() > 0) { if(factions.empty() == false) {
bool techtree_errors = false; bool techtree_errors = false;
std::map<string,vector<pair<string, string> > > loadedFileList; std::map<string,vector<pair<string, string> > > loadedFileList;
@ -1425,7 +1425,7 @@ void runTechValidationForPath(string techPath, string techName,
// Validate the faction setup to ensure we don't have any bad associations // Validate the faction setup to ensure we don't have any bad associations
std::vector<std::string> resultErrors = world.validateFactionTypes(); std::vector<std::string> resultErrors = world.validateFactionTypes();
if(resultErrors.size() > 0) { if(resultErrors.empty() == false) {
techtree_errors = true; techtree_errors = true;
// Display the validation errors // Display the validation errors
string errorText = "\nErrors were detected:\n=====================\n"; string errorText = "\nErrors were detected:\n=====================\n";
@ -1448,7 +1448,7 @@ void runTechValidationForPath(string techPath, string techName,
} }
resultErrors = world.validateResourceTypes(); resultErrors = world.validateResourceTypes();
if(resultErrors.size() > 0) { if(resultErrors.empty() == false) {
techtree_errors = true; techtree_errors = true;
// Display the validation errors // Display the validation errors
string errorText = "\nErrors were detected:\n=====================\n"; string errorText = "\nErrors were detected:\n=====================\n";
@ -1559,7 +1559,7 @@ void runTechValidationForPath(string techPath, string techName,
std::map<int32,vector<string> > mapDuplicateFiles; std::map<int32,vector<string> > mapDuplicateFiles;
// Now check for duplicate data content // Now check for duplicate data content
for(std::map<string,vector<pair<string, string> > >::iterator iterMap = loadedFileList.begin(); for(std::map<string,vector<pair<string, string> > >::iterator iterMap = loadedFileList.begin();
iterMap != loadedFileList.end(); iterMap++) { iterMap != loadedFileList.end(); ++iterMap) {
string fileName = iterMap->first; string fileName = iterMap->first;
Checksum checksum; Checksum checksum;
checksum.addFile(fileName); checksum.addFile(fileName);
@ -1583,7 +1583,7 @@ void runTechValidationForPath(string techPath, string techName,
bool foundDuplicates = false; bool foundDuplicates = false;
for(std::map<int32,vector<string> >::iterator iterMap = mapDuplicateFiles.begin(); for(std::map<int32,vector<string> >::iterator iterMap = mapDuplicateFiles.begin();
iterMap != mapDuplicateFiles.end(); iterMap++) { iterMap != mapDuplicateFiles.end(); ++iterMap) {
vector<string> &fileList = iterMap->second; vector<string> &fileList = iterMap->second;
if(fileList.size() > 1) { if(fileList.size() > 1) {
if(foundDuplicates == false) { if(foundDuplicates == false) {
@ -1614,7 +1614,7 @@ void runTechValidationForPath(string techPath, string techName,
} }
for(map<string,int>::iterator iterMap1 = parentList.begin(); for(map<string,int>::iterator iterMap1 = parentList.begin();
iterMap1 != parentList.end(); iterMap1++) { iterMap1 != parentList.end(); ++iterMap1) {
if(iterMap1 == parentList.begin()) { if(iterMap1 == parentList.begin()) {
printf("\tParents:\n"); printf("\tParents:\n");
@ -1878,7 +1878,7 @@ void runTechValidationReport(int argc, char** argv) {
string factionList = paramPartTokens[1]; string factionList = paramPartTokens[1];
Tokenize(factionList,filteredFactionList,","); Tokenize(factionList,filteredFactionList,",");
if(filteredFactionList.size() > 0) { if(filteredFactionList.empty() == false) {
printf("Filtering factions and only looking for the following:\n"); printf("Filtering factions and only looking for the following:\n");
for(int idx = 0; idx < filteredFactionList.size(); ++idx) { for(int idx = 0; idx < filteredFactionList.size(); ++idx) {
filteredFactionList[idx] = trim(filteredFactionList[idx]); filteredFactionList[idx] = trim(filteredFactionList[idx]);
@ -1909,7 +1909,7 @@ void runTechValidationReport(int argc, char** argv) {
string techtreeList = paramPartTokens[1]; string techtreeList = paramPartTokens[1];
Tokenize(techtreeList,filteredTechTreeList,","); Tokenize(techtreeList,filteredTechTreeList,",");
if(filteredTechTreeList.size() > 0) { if(filteredTechTreeList.empty() == false) {
printf("Filtering techtrees and only looking for the following:\n"); printf("Filtering techtrees and only looking for the following:\n");
for(int idx = 0; idx < filteredTechTreeList.size(); ++idx) { for(int idx = 0; idx < filteredTechTreeList.size(); ++idx) {
filteredTechTreeList[idx] = trim(filteredTechTreeList[idx]); filteredTechTreeList[idx] = trim(filteredTechTreeList[idx]);
@ -2017,7 +2017,7 @@ void ShowINISettings(int argc, char **argv,Config &config,Config &configKeys) {
string tokenList = paramPartTokens[1]; string tokenList = paramPartTokens[1];
Tokenize(tokenList,filteredPropertyList,","); Tokenize(tokenList,filteredPropertyList,",");
if(filteredPropertyList.size() > 0) { if(filteredPropertyList.empty() == false) {
printf("Filtering properties and only looking for the following:\n"); printf("Filtering properties and only looking for the following:\n");
for(int idx = 0; idx < filteredPropertyList.size(); ++idx) { for(int idx = 0; idx < filteredPropertyList.size(); ++idx) {
filteredPropertyList[idx] = trim(filteredPropertyList[idx]); filteredPropertyList[idx] = trim(filteredPropertyList[idx]);
@ -2038,7 +2038,7 @@ void ShowINISettings(int argc, char **argv,Config &config,Config &configKeys) {
const pair<string,string> &nameValue = mergedMainSettings[i]; const pair<string,string> &nameValue = mergedMainSettings[i];
bool displayProperty = false; bool displayProperty = false;
if(filteredPropertyList.size() > 0) { if(filteredPropertyList.empty() == false) {
if(find(filteredPropertyList.begin(),filteredPropertyList.end(),nameValue.first) != filteredPropertyList.end()) { if(find(filteredPropertyList.begin(),filteredPropertyList.end(),nameValue.first) != filteredPropertyList.end()) {
displayProperty = true; displayProperty = true;
} }
@ -2061,7 +2061,7 @@ void ShowINISettings(int argc, char **argv,Config &config,Config &configKeys) {
const pair<string,string> &nameValue = mergedKeySettings[i]; const pair<string,string> &nameValue = mergedKeySettings[i];
bool displayProperty = false; bool displayProperty = false;
if(filteredPropertyList.size() > 0) { if(filteredPropertyList.empty() == false) {
if(find(filteredPropertyList.begin(),filteredPropertyList.end(),nameValue.first) != filteredPropertyList.end()) { if(find(filteredPropertyList.begin(),filteredPropertyList.end(),nameValue.first) != filteredPropertyList.end()) {
displayProperty = true; displayProperty = true;
} }
@ -2086,7 +2086,7 @@ void ShowINISettings(int argc, char **argv,Config &config,Config &configKeys) {
const pair<string,string> &nameValue = mergedMainSettings[i]; const pair<string,string> &nameValue = mergedMainSettings[i];
bool displayProperty = false; bool displayProperty = false;
if(filteredPropertyList.size() > 0) { if(filteredPropertyList.empty() == false) {
if(find(filteredPropertyList.begin(),filteredPropertyList.end(),nameValue.first) != filteredPropertyList.end()) { if(find(filteredPropertyList.begin(),filteredPropertyList.end(),nameValue.first) != filteredPropertyList.end()) {
displayProperty = true; displayProperty = true;
} }
@ -2114,7 +2114,7 @@ void ShowINISettings(int argc, char **argv,Config &config,Config &configKeys) {
const pair<string,string> &nameValue = mergedKeySettings[i]; const pair<string,string> &nameValue = mergedKeySettings[i];
bool displayProperty = false; bool displayProperty = false;
if(filteredPropertyList.size() > 0) { if(filteredPropertyList.empty() == false) {
if(find(filteredPropertyList.begin(),filteredPropertyList.end(),nameValue.first) != filteredPropertyList.end()) { if(find(filteredPropertyList.begin(),filteredPropertyList.end(),nameValue.first) != filteredPropertyList.end()) {
displayProperty = true; displayProperty = true;
} }
@ -2178,7 +2178,7 @@ void CheckForDuplicateData() {
} }
} }
} }
if(duplicateMapsToRename.size() > 0) { if(duplicateMapsToRename.empty() == false) {
string errorMsg = "Warning duplicate maps were detected and renamed:\n"; string errorMsg = "Warning duplicate maps were detected and renamed:\n";
for(int i = 0; i < duplicateMapsToRename.size(); ++i) { for(int i = 0; i < duplicateMapsToRename.size(); ++i) {
string currentPath = mapPaths[1]; string currentPath = mapPaths[1];
@ -2236,7 +2236,7 @@ void CheckForDuplicateData() {
} }
} }
} }
if(duplicateTilesetsToRename.size() > 0) { if(duplicateTilesetsToRename.empty() == false) {
string errorMsg = "Warning duplicate tilesets were detected and renamed:\n"; string errorMsg = "Warning duplicate tilesets were detected and renamed:\n";
for(int i = 0; i < duplicateTilesetsToRename.size(); ++i) { for(int i = 0; i < duplicateTilesetsToRename.size(); ++i) {
@ -2262,7 +2262,7 @@ void CheckForDuplicateData() {
newFile = newFile + "/" + tilesetName + "_custom.xml"; newFile = newFile + "/" + tilesetName + "_custom.xml";
//printf("\n\n\n###### RENAME [%s] to [%s]\n\n",oldFile.c_str(),newFile.c_str()); //printf("\n\n\n###### RENAME [%s] to [%s]\n\n",oldFile.c_str(),newFile.c_str());
int result2 = rename(oldFile.c_str(),newFile.c_str()); rename(oldFile.c_str(),newFile.c_str());
} }
errorMsg += szBuf; errorMsg += szBuf;
} }
@ -2298,7 +2298,7 @@ void CheckForDuplicateData() {
} }
} }
} }
if(duplicateTechtreesToRename.size() > 0) { if(duplicateTechtreesToRename.empty() == false) {
string errorMsg = "Warning duplicate techtrees were detected and renamed:\n"; string errorMsg = "Warning duplicate techtrees were detected and renamed:\n";
for(int i = 0; i < duplicateTechtreesToRename.size(); ++i) { for(int i = 0; i < duplicateTechtreesToRename.size(); ++i) {
@ -2324,7 +2324,7 @@ void CheckForDuplicateData() {
newFile = newFile + "/" + tilesetName + "_custom.xml"; newFile = newFile + "/" + tilesetName + "_custom.xml";
//printf("\n\n\n###### RENAME [%s] to [%s]\n\n",oldFile.c_str(),newFile.c_str()); //printf("\n\n\n###### RENAME [%s] to [%s]\n\n",oldFile.c_str(),newFile.c_str());
int result2 = rename(oldFile.c_str(),newFile.c_str()); rename(oldFile.c_str(),newFile.c_str());
} }
errorMsg += szBuf; errorMsg += szBuf;
} }

View File

@ -55,6 +55,8 @@ ProgramState::ProgramState(Program *program) {
this->mouse2dAnim = 0; this->mouse2dAnim = 0;
this->fps= 0; this->fps= 0;
this->lastFps= 0; this->lastFps= 0;
this->startX=0;
this->startY=0;
} }
void ProgramState::incrementFps() { void ProgramState::incrementFps() {
@ -546,7 +548,8 @@ void Program::init(WindowGl *window, bool initSound, bool toggleFullScreen){
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
//lang //lang
Lang &lang= Lang::getInstance(); //Lang &lang= Lang::getInstance();
Lang::getInstance();
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);

View File

@ -86,9 +86,9 @@ void MainMenu::init() {
//asynchronus render update //asynchronus render update
void MainMenu::render() { void MainMenu::render() {
Config &config= Config::getInstance(); //Config &config= Config::getInstance();
Renderer &renderer= Renderer::getInstance(); Renderer &renderer= Renderer::getInstance();
CoreData &coreData= CoreData::getInstance(); //CoreData &coreData= CoreData::getInstance();
//fps++; //fps++;
canRender(); canRender();

View File

@ -165,7 +165,7 @@ void MenuStateAbout::keyDown(SDL_KeyboardEvent key){
Config &configKeys= Config::getInstance(std::pair<ConfigType, ConfigType>(cfgMainKeys, cfgUserKeys)); Config &configKeys= Config::getInstance(std::pair<ConfigType, ConfigType>(cfgMainKeys, cfgUserKeys));
//if(key == configKeys.getCharKey("SaveGUILayout")){ //if(key == configKeys.getCharKey("SaveGUILayout")){
if(isKeyPressed(configKeys.getSDLKey("SaveGUILayout"),key) == true) { if(isKeyPressed(configKeys.getSDLKey("SaveGUILayout"),key) == true) {
bool saved= GraphicComponent::saveAllCustomProperties(containerName); GraphicComponent::saveAllCustomProperties(containerName);
//Lang &lang= Lang::getInstance(); //Lang &lang= Lang::getInstance();
//console.addLine(lang.get("GUILayoutSaved") + " [" + (saved ? lang.get("Yes") : lang.get("No"))+ "]"); //console.addLine(lang.get("GUILayoutSaved") + " [" + (saved ? lang.get("Yes") : lang.get("No"))+ "]");
} }

View File

@ -429,7 +429,7 @@ MenuStateConnectedGame::MenuStateConnectedGame(Program *program, MainMenu *mainM
vector<string> mapPathList = config.getPathListForType(ptMaps); vector<string> mapPathList = config.getPathListForType(ptMaps);
std::pair<string,string> mapsPath; std::pair<string,string> mapsPath;
if(mapPathList.size() > 0) { if(mapPathList.empty() == false) {
mapsPath.first = mapPathList[0]; mapsPath.first = mapPathList[0];
} }
if(mapPathList.size() > 1) { if(mapPathList.size() > 1) {
@ -437,7 +437,7 @@ MenuStateConnectedGame::MenuStateConnectedGame(Program *program, MainMenu *mainM
} }
std::pair<string,string> tilesetsPath; std::pair<string,string> tilesetsPath;
vector<string> tilesetsList = Config::getInstance().getPathListForType(ptTilesets); vector<string> tilesetsList = Config::getInstance().getPathListForType(ptTilesets);
if(tilesetsList.size() > 0) { if(tilesetsList.empty() == false) {
tilesetsPath.first = tilesetsList[0]; tilesetsPath.first = tilesetsList[0];
if(tilesetsList.size() > 1) { if(tilesetsList.size() > 1) {
tilesetsPath.second = tilesetsList[1]; tilesetsPath.second = tilesetsList[1];
@ -446,7 +446,7 @@ MenuStateConnectedGame::MenuStateConnectedGame(Program *program, MainMenu *mainM
std::pair<string,string> techtreesPath; std::pair<string,string> techtreesPath;
vector<string> techtreesList = Config::getInstance().getPathListForType(ptTechs); vector<string> techtreesList = Config::getInstance().getPathListForType(ptTechs);
if(techtreesList.size() > 0) { if(techtreesList.empty() == false) {
techtreesPath.first = techtreesList[0]; techtreesPath.first = techtreesList[0];
if(techtreesList.size() > 1) { if(techtreesList.size() > 1) {
techtreesPath.second = techtreesList[1]; techtreesPath.second = techtreesList[1];
@ -455,7 +455,7 @@ MenuStateConnectedGame::MenuStateConnectedGame(Program *program, MainMenu *mainM
std::pair<string,string> scenariosPath; std::pair<string,string> scenariosPath;
vector<string> scenariosList = Config::getInstance().getPathListForType(ptScenarios); vector<string> scenariosList = Config::getInstance().getPathListForType(ptScenarios);
if(scenariosList.size() > 0) { if(scenariosList.empty() == false) {
scenariosPath.first = scenariosList[0]; scenariosPath.first = scenariosList[0];
if(scenariosList.size() > 1) { if(scenariosList.size() > 1) {
scenariosPath.second = scenariosList[1]; scenariosPath.second = scenariosList[1];
@ -588,7 +588,7 @@ void MenuStateConnectedGame::mouseClick(int x, int y, MouseButton mouseButton){
} }
} }
else if(buttonCancelDownloads.mouseClick(x,y)) { else if(buttonCancelDownloads.mouseClick(x,y)) {
if(ftpClientThread != NULL && fileFTPProgressList.size() > 0) { if(ftpClientThread != NULL && fileFTPProgressList.empty() == false) {
ftpClientThread->setCallBackObject(NULL); ftpClientThread->setCallBackObject(NULL);
if(ftpClientThread->shutdownAndWait() == true) { if(ftpClientThread->shutdownAndWait() == true) {
delete ftpClientThread; delete ftpClientThread;
@ -612,7 +612,7 @@ void MenuStateConnectedGame::mouseClick(int x, int y, MouseButton mouseButton){
Config &config = Config::getInstance(); Config &config = Config::getInstance();
vector<string> mapPathList = config.getPathListForType(ptMaps); vector<string> mapPathList = config.getPathListForType(ptMaps);
std::pair<string,string> mapsPath; std::pair<string,string> mapsPath;
if(mapPathList.size() > 0) { if(mapPathList.empty() == false) {
mapsPath.first = mapPathList[0]; mapsPath.first = mapPathList[0];
} }
if(mapPathList.size() > 1) { if(mapPathList.size() > 1) {
@ -620,7 +620,7 @@ void MenuStateConnectedGame::mouseClick(int x, int y, MouseButton mouseButton){
} }
std::pair<string,string> tilesetsPath; std::pair<string,string> tilesetsPath;
vector<string> tilesetsList = Config::getInstance().getPathListForType(ptTilesets); vector<string> tilesetsList = Config::getInstance().getPathListForType(ptTilesets);
if(tilesetsList.size() > 0) { if(tilesetsList.empty() == false) {
tilesetsPath.first = tilesetsList[0]; tilesetsPath.first = tilesetsList[0];
if(tilesetsList.size() > 1) { if(tilesetsList.size() > 1) {
tilesetsPath.second = tilesetsList[1]; tilesetsPath.second = tilesetsList[1];
@ -629,7 +629,7 @@ void MenuStateConnectedGame::mouseClick(int x, int y, MouseButton mouseButton){
std::pair<string,string> techtreesPath; std::pair<string,string> techtreesPath;
vector<string> techtreesList = Config::getInstance().getPathListForType(ptTechs); vector<string> techtreesList = Config::getInstance().getPathListForType(ptTechs);
if(techtreesList.size() > 0) { if(techtreesList.empty() == false) {
techtreesPath.first = techtreesList[0]; techtreesPath.first = techtreesList[0];
if(techtreesList.size() > 1) { if(techtreesList.size() > 1) {
techtreesPath.second = techtreesList[1]; techtreesPath.second = techtreesList[1];
@ -638,7 +638,7 @@ void MenuStateConnectedGame::mouseClick(int x, int y, MouseButton mouseButton){
std::pair<string,string> scenariosPath; std::pair<string,string> scenariosPath;
vector<string> scenariosList = Config::getInstance().getPathListForType(ptScenarios); vector<string> scenariosList = Config::getInstance().getPathListForType(ptScenarios);
if(scenariosList.size() > 0) { if(scenariosList.empty() == false) {
scenariosPath.first = scenariosList[0]; scenariosPath.first = scenariosList[0];
if(scenariosList.size() > 1) { if(scenariosList.size() > 1) {
scenariosPath.second = scenariosList[1]; scenariosPath.second = scenariosList[1];
@ -1014,7 +1014,7 @@ void MenuStateConnectedGame::render() {
renderer.renderListBox(&listBoxNetworkPauseGameForLaggedClients); renderer.renderListBox(&listBoxNetworkPauseGameForLaggedClients);
MutexSafeWrapper safeMutexFTPProgress((ftpClientThread != NULL ? ftpClientThread->getProgressMutex() : NULL),string(__FILE__) + "_" + intToStr(__LINE__)); MutexSafeWrapper safeMutexFTPProgress((ftpClientThread != NULL ? ftpClientThread->getProgressMutex() : NULL),string(__FILE__) + "_" + intToStr(__LINE__));
if(fileFTPProgressList.size() > 0) { if(fileFTPProgressList.empty() == false) {
Lang &lang= Lang::getInstance(); Lang &lang= Lang::getInstance();
renderer.renderButton(&buttonCancelDownloads); renderer.renderButton(&buttonCancelDownloads);
int yLocation = buttonCancelDownloads.getY() - 20; int yLocation = buttonCancelDownloads.getY() - 20;
@ -1192,11 +1192,11 @@ void MenuStateConnectedGame::update() {
factionCRCList.clear(); factionCRCList.clear();
for(unsigned int factionIdx = 0; factionIdx < factionFiles.size(); ++factionIdx) { for(unsigned int factionIdx = 0; factionIdx < factionFiles.size(); ++factionIdx) {
string factionName = factionFiles[factionIdx]; string factionName = factionFiles[factionIdx];
int32 factionCRC = 0;
if(factionName != GameConstants::RANDOMFACTION_SLOTNAME && if(factionName != GameConstants::RANDOMFACTION_SLOTNAME &&
factionName != GameConstants::OBSERVER_SLOTNAME && factionName != GameConstants::OBSERVER_SLOTNAME &&
factionName != ITEM_MISSING) { factionName != ITEM_MISSING) {
int32 factionCRC = 0;
time_t now = time(NULL); time_t now = time(NULL);
time_t lastUpdateDate = getFolderTreeContentsCheckSumRecursivelyLastGenerated(config.getPathListForType(ptTechs,""), "/" + gameSettings->getTech() + "/factions/" + factionName + "/*", ".xml"); time_t lastUpdateDate = getFolderTreeContentsCheckSumRecursivelyLastGenerated(config.getPathListForType(ptTechs,""), "/" + gameSettings->getTech() + "/factions/" + factionName + "/*", ".xml");
@ -1417,7 +1417,7 @@ void MenuStateConnectedGame::update() {
} }
if(mismatchedFactionText != "") { if(mismatchedFactionText != "") {
if(mismatchedFactionTextList.size() > 0) { if(mismatchedFactionTextList.empty() == false) {
if(mismatchedFactionText != "") { if(mismatchedFactionText != "") {
mismatchedFactionText += "."; mismatchedFactionText += ".";
mismatchedFactionTextList.push_back(mismatchedFactionText); mismatchedFactionTextList.push_back(mismatchedFactionText);
@ -1583,7 +1583,7 @@ void MenuStateConnectedGame::update() {
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) chrono.start(); if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) chrono.start();
try { try {
bool mustSwitchPlayerName = false; //bool mustSwitchPlayerName = false;
if(clientInterface->getGameSettingsReceived()) { if(clientInterface->getGameSettingsReceived()) {
updateDataSynchDetailText = true; updateDataSynchDetailText = true;
bool errorOnMissingData = (clientInterface->getAllowGameDataSynchCheck() == false); bool errorOnMissingData = (clientInterface->getAllowGameDataSynchCheck() == false);
@ -1868,7 +1868,7 @@ void MenuStateConnectedGame::update() {
needToSetChangedGameSettings = true; needToSetChangedGameSettings = true;
lastSetChangedGameSettings = time(NULL); lastSetChangedGameSettings = time(NULL);
mustSwitchPlayerName = true; //mustSwitchPlayerName = true;
} }
} }
@ -1992,7 +1992,7 @@ bool MenuStateConnectedGame::loadFactions(const GameSettings *gameSettings, bool
if(gameSettings->getTech() != "") { if(gameSettings->getTech() != "") {
Config &config = Config::getInstance(); Config &config = Config::getInstance();
Lang &lang= Lang::getInstance(); //Lang &lang= Lang::getInstance();
vector<string> techPaths = config.getPathListForType(ptTechs); vector<string> techPaths = config.getPathListForType(ptTechs);
for(int idx = 0; idx < techPaths.size(); idx++) { for(int idx = 0; idx < techPaths.size(); idx++) {
@ -2000,7 +2000,7 @@ bool MenuStateConnectedGame::loadFactions(const GameSettings *gameSettings, bool
endPathWithSlash(techPath); endPathWithSlash(techPath);
//findAll(techPath + gameSettings->getTech() + "/factions/*.", results, false, false); //findAll(techPath + gameSettings->getTech() + "/factions/*.", results, false, false);
findDirs(techPath + gameSettings->getTech() + "/factions/", results, false, false); findDirs(techPath + gameSettings->getTech() + "/factions/", results, false, false);
if(results.size() > 0) { if(results.empty() == false) {
break; break;
} }
} }
@ -2064,7 +2064,7 @@ bool MenuStateConnectedGame::loadFactions(const GameSettings *gameSettings, bool
listBoxFactions[i].setItems(results); listBoxFactions[i].setItems(results);
} }
foundFactions = (results.size() > 0); foundFactions = (results.empty() == false);
} }
} }
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
@ -2427,7 +2427,7 @@ void MenuStateConnectedGame::FTPClient_CallbackEvent(string itemName,
FTP_Client_CallbackType type, pair<FTP_Client_ResultType,string> result, void *userdata) { FTP_Client_CallbackType type, pair<FTP_Client_ResultType,string> result, void *userdata) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
Lang &lang= Lang::getInstance(); //Lang &lang= Lang::getInstance();
if(type == ftp_cct_DownloadProgress) { if(type == ftp_cct_DownloadProgress) {
FTPClientCallbackInterface::FtpProgressStats *stats = (FTPClientCallbackInterface::FtpProgressStats *)userdata; FTPClientCallbackInterface::FtpProgressStats *stats = (FTPClientCallbackInterface::FtpProgressStats *)userdata;
if(stats != NULL) { if(stats != NULL) {

View File

@ -186,7 +186,7 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu, b
string ipText = "none"; string ipText = "none";
std::vector<std::string> ipList = Socket::getLocalIPAddressList(); std::vector<std::string> ipList = Socket::getLocalIPAddressList();
if(ipList.size() > 0) { if(ipList.empty() == false) {
ipText = ""; ipText = "";
for(int idx = 0; idx < ipList.size(); idx++) { for(int idx = 0; idx < ipList.size(); idx++) {
string ip = ipList[idx]; string ip = ipList[idx];
@ -481,12 +481,12 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu, b
//findAll(techPath + techTreeFiles[listBoxTechTree.getSelectedItemIndex()] + "/factions/*.", results, false, false); //findAll(techPath + techTreeFiles[listBoxTechTree.getSelectedItemIndex()] + "/factions/*.", results, false, false);
findDirs(techPath + techTreeFiles[listBoxTechTree.getSelectedItemIndex()] + "/factions/", results, false, false); findDirs(techPath + techTreeFiles[listBoxTechTree.getSelectedItemIndex()] + "/factions/", results, false, false);
if(results.size() > 0) { if(results.empty() == false) {
break; break;
} }
} }
if(results.size() == 0) { if(results.empty() == true) {
//throw runtime_error("(1)There are no factions for the tech tree [" + techTreeFiles[listBoxTechTree.getSelectedItemIndex()] + "]"); //throw runtime_error("(1)There are no factions for the tech tree [" + techTreeFiles[listBoxTechTree.getSelectedItemIndex()] + "]");
showGeneralError=true; showGeneralError=true;
generalErrorToShow = "[#1] There are no factions for the tech tree [" + techTreeFiles[listBoxTechTree.getSelectedItemIndex()] + "]"; generalErrorToShow = "[#1] There are no factions for the tech tree [" + techTreeFiles[listBoxTechTree.getSelectedItemIndex()] + "]";
@ -2052,7 +2052,7 @@ void MenuStateCustomGame::simpleTask(BaseThread *callingThread) {
CURL *handle = SystemFlags::initHTTP(); CURL *handle = SystemFlags::initHTTP();
for(std::map<string,string>::const_iterator iterMap = newPublishToServerInfo.begin(); for(std::map<string,string>::const_iterator iterMap = newPublishToServerInfo.begin();
iterMap != newPublishToServerInfo.end(); iterMap++) { iterMap != newPublishToServerInfo.end(); ++iterMap) {
request += iterMap->first; request += iterMap->first;
request += "="; request += "=";
@ -2713,12 +2713,12 @@ void MenuStateCustomGame::reloadFactions(bool keepExistingSelectedItem) {
//findAll(techPath + techTreeFiles[listBoxTechTree.getSelectedItemIndex()] + "/factions/*.", results, false, false); //findAll(techPath + techTreeFiles[listBoxTechTree.getSelectedItemIndex()] + "/factions/*.", results, false, false);
findDirs(techPath + techTreeFiles[listBoxTechTree.getSelectedItemIndex()] + "/factions/", results, false, false); findDirs(techPath + techTreeFiles[listBoxTechTree.getSelectedItemIndex()] + "/factions/", results, false, false);
if(results.size() > 0) { if(results.empty() == false) {
break; break;
} }
} }
if(results.size() == 0) { if(results.empty() == true) {
//throw runtime_error("(2)There are no factions for the tech tree [" + techTreeFiles[listBoxTechTree.getSelectedItemIndex()] + "]"); //throw runtime_error("(2)There are no factions for the tech tree [" + techTreeFiles[listBoxTechTree.getSelectedItemIndex()] + "]");
showGeneralError=true; showGeneralError=true;
generalErrorToShow = "[#2] There are no factions for the tech tree [" + techTreeFiles[listBoxTechTree.getSelectedItemIndex()] + "]"; generalErrorToShow = "[#2] There are no factions for the tech tree [" + techTreeFiles[listBoxTechTree.getSelectedItemIndex()] + "]";