diff --git a/mk/windoze/vc2012/glest_game.vcxproj b/mk/windoze/vc2012/glest_game.vcxproj index 591bec3f..2911d2a3 100644 --- a/mk/windoze/vc2012/glest_game.vcxproj +++ b/mk/windoze/vc2012/glest_game.vcxproj @@ -435,6 +435,7 @@ + @@ -562,4 +563,4 @@ - + \ No newline at end of file diff --git a/source/g3d_viewer/main.cpp b/source/g3d_viewer/main.cpp index 98ad3d2a..ba175153 100644 --- a/source/g3d_viewer/main.cpp +++ b/source/g3d_viewer/main.cpp @@ -480,12 +480,15 @@ void MainWindow::setupTimer() { } void MainWindow::setupStartupSettings() { - GLuint err = glewInit(); - if (GLEW_OK != err) { + + glCanvas->setCurrentGLContext(); + + GLuint err = glewInit(); + if (GLEW_OK != err) { fprintf(stderr, "Error [main]: glewInit failed: %s\n", glewGetErrorString(err)); //return 1; throw std::runtime_error((char *)glewGetErrorString(err)); - } + } renderer= Renderer::getInstance(); @@ -567,12 +570,12 @@ MainWindow::~MainWindow(){ void MainWindow::init() { #if wxCHECK_VERSION(2, 9, 3) - glCanvas->setCurrentGLContext(); + //glCanvas->setCurrentGLContext(); //printf("setcurrent #1\n"); #elif wxCHECK_VERSION(2, 9, 1) #else - glCanvas->SetCurrent(); + //glCanvas->SetCurrent(); //printf("setcurrent #2\n"); #endif @@ -585,10 +588,12 @@ void MainWindow::init() { void MainWindow::onPaint(wxPaintEvent &event) { if(!IsShown()) return; -#if wxCHECK_VERSION(2, 9, 3) +#if wxCHECK_VERSION(2, 9, 4) + //glCanvas->setCurrentGLContext(); +#elif wxCHECK_VERSION(2, 9, 3) #elif wxCHECK_VERSION(2, 9, 1) - glCanvas->setCurrentGLContext(); + //glCanvas->setCurrentGLContext(); #endif if(startupSettingsInited == false) { @@ -756,8 +761,8 @@ void MainWindow::onClose(wxCloseEvent &event){ delete timer; timer = NULL; - delete model; - model = NULL; + //delete model; + //model = NULL; delete renderer; renderer = NULL; @@ -2029,7 +2034,7 @@ GlCanvas::GlCanvas(MainWindow * mainWindow, int *args) } GlCanvas::~GlCanvas() { - delete this->context; + if(this->context) delete this->context; this->context = NULL; } @@ -2039,11 +2044,13 @@ void GlCanvas::setCurrentGLContext() { #if wxCHECK_VERSION(2, 9, 1) if(this->context == NULL) { this->context = new wxGLContext(this); + //printf("Set ctx [%p]\n",this->context); } #endif //printf("Set ctx [%p]\n",this->context); if(this->context) { wxGLCanvas::SetCurrent(*this->context); + //printf("Set ctx2 [%p]\n",this->context); } #else this->SetCurrent(); diff --git a/source/g3d_viewer/main.h b/source/g3d_viewer/main.h index d22020d5..e8142b8f 100644 --- a/source/g3d_viewer/main.h +++ b/source/g3d_viewer/main.h @@ -201,6 +201,7 @@ public: void onKeyDown(wxKeyEvent &event); void setCurrentGLContext(); + wxGLContext * getCtx() { return context; } private: MainWindow *mainWindow; wxGLContext *context; diff --git a/source/glest_game/graphics/renderer.cpp b/source/glest_game/graphics/renderer.cpp index 21ccd667..a2a37ef1 100644 --- a/source/glest_game/graphics/renderer.cpp +++ b/source/glest_game/graphics/renderer.cpp @@ -5464,19 +5464,21 @@ void Renderer::renderSelectionEffects(int healthbarMode) { currVec.y+= 0.3f; //selection circle - int finalHealthbarMode=hbvUndefined; - if(healthbarMode==hbvUndefined) { - finalHealthbarMode=unit->getFaction()->getType()->getHealthbarVisible(); - } else { - finalHealthbarMode=healthbarMode; + int finalHealthbarMode = hbvUndefined; + if(healthbarMode == hbvUndefined) { + finalHealthbarMode = unit->getFaction()->getType()->getHealthbarVisible(); } - bool healthbarsVisible=((finalHealthbarMode&hbvAlways)||(finalHealthbarMode&hbvSelected)||(finalHealthbarMode&hbvIfNeeded)); - float selectionCircleThickness=0.2f; - float hpRatio; + else { + finalHealthbarMode = healthbarMode; + } + bool healthbarsVisible =((finalHealthbarMode & hbvAlways) || + (finalHealthbarMode & hbvSelected) || + (finalHealthbarMode & hbvIfNeeded)); + float selectionCircleThickness = 0.2f; + float hpRatio = unit->getHpRatio(); if(healthbarsVisible) { - hpRatio=unit->getHpRatio(); - selectionCircleThickness=0.05f; - hpRatio=1.0f; + selectionCircleThickness = 0.05f; + hpRatio = 1.0f; } if(world->getThisFactionIndex() == unit->getFactionIndex()) { @@ -5493,7 +5495,7 @@ void Renderer::renderSelectionEffects(int healthbarMode) { else if ( world->getThisTeamIndex() == unit->getTeam()) { glColor4f(hpRatio, hpRatio, 0, 0.3f); } - else{ + else { glColor4f(hpRatio, 0, 0, 0.3f); } renderSelectionCircle(currVec, unit->getType()->getSize(), selectionCircleRadius,selectionCircleThickness); diff --git a/source/glest_game/types/skill_type.cpp b/source/glest_game/types/skill_type.cpp index 77ee5b24..57db9210 100644 --- a/source/glest_game/types/skill_type.cpp +++ b/source/glest_game/types/skill_type.cpp @@ -62,7 +62,7 @@ bool AttackBoost::isAffected(const Unit *source, const Unit *dest) const { else { // All units are affected (including enemies) if(targetType == abtAll) { - destUnitMightApply = (boostUnitList.empty() && tags.empty()); + //destUnitMightApply = (boostUnitList.empty() && tags.empty()); destUnitMightApply = isInUnitListOrTags(dest->getType()); } // Only same faction units are affected @@ -70,7 +70,7 @@ bool AttackBoost::isAffected(const Unit *source, const Unit *dest) const { //if(boostUnitList.empty() == true) { if(source->getFactionIndex() == dest->getFactionIndex()) { //destUnitMightApply = true; - destUnitMightApply = (boostUnitList.empty() && tags.empty()); + //destUnitMightApply = (boostUnitList.empty() && tags.empty()); destUnitMightApply = isInUnitListOrTags(dest->getType()); } //} @@ -80,7 +80,7 @@ bool AttackBoost::isAffected(const Unit *source, const Unit *dest) const { //if(boostUnitList.empty() == true) { if(source->isAlly(dest) == true) { //destUnitMightApply = true; - destUnitMightApply = (boostUnitList.empty() && tags.empty()); + //destUnitMightApply = (boostUnitList.empty() && tags.empty()); destUnitMightApply = isInUnitListOrTags(dest->getType()); } //} @@ -90,7 +90,7 @@ bool AttackBoost::isAffected(const Unit *source, const Unit *dest) const { //if(boostUnitList.empty() == true) { if(source->isAlly(dest) == false) { //destUnitMightApply = true; - destUnitMightApply = (boostUnitList.empty() && tags.empty()); + //destUnitMightApply = (boostUnitList.empty() && tags.empty()); destUnitMightApply = isInUnitListOrTags(dest->getType()); } //} diff --git a/source/glest_game/types/unit_type.cpp b/source/glest_game/types/unit_type.cpp index f0f905d5..a96600bf 100644 --- a/source/glest_game/types/unit_type.cpp +++ b/source/glest_game/types/unit_type.cpp @@ -141,6 +141,8 @@ UnitType::UnitType() : ProducibleType() { size=0; renderSize=0; height=0; + burnHeight=0; + targetHeight=0; addItemToVault(&(this->maxHp),this->maxHp); addItemToVault(&(this->hpRegeneration),this->hpRegeneration); @@ -644,7 +646,7 @@ void UnitType::loaddd(int id,const string &dir, const TechTree *techTree, } } sortedItems.clear(); - hasDup = false; + //hasDup = false; // Lootable resources (resources given/lost on death) if(parametersNode->hasChild("resources-death")) { diff --git a/source/glest_game/types/unit_type.h b/source/glest_game/types/unit_type.h index 43c36d81..564ed14b 100644 --- a/source/glest_game/types/unit_type.h +++ b/source/glest_game/types/unit_type.h @@ -79,6 +79,15 @@ private: bool negativeAllowed; public: + LootableResource() { + type=NULL; + amountValue=0; + amountFactionPercent=0; + lossValue=0; + lossFactionPercent=0; + negativeAllowed=false; + } + const ResourceType* getResourceType() const {return type;} void setResourceType(const ResourceType *type) {this->type=type;} @@ -282,7 +291,7 @@ public: int getTargetHeight() const {return targetHeight;} int getStoredResourceCount() const {return (int)storedResources.size();} inline const Resource *getStoredResource(int i) const {return &storedResources[i];} - int getLootableResourceCount() const {return lootableResources.size();} + int getLootableResourceCount() const {return (int)lootableResources.size();} inline const LootableResource getLootableResource(int i) const {return lootableResources.at(i);} const set &getTags() const {return tags;} bool getCellMapCell(int x, int y, CardinalDir facing) const; diff --git a/source/glest_game/types/upgrade_type.cpp b/source/glest_game/types/upgrade_type.cpp index dcb22d5b..17c04643 100644 --- a/source/glest_game/types/upgrade_type.cpp +++ b/source/glest_game/types/upgrade_type.cpp @@ -781,7 +781,7 @@ void UpgradeType::load(const string &dir, const TechTree *techTree, } sortedItems.clear(); - hasDup = false; + //hasDup = false; //effects -- get list of affected units const XmlNode *effectsNode= upgradeNode->getChild("effects"); diff --git a/source/glest_game/types/upgrade_type.h b/source/glest_game/types/upgrade_type.h index 5db3218d..29679d18 100644 --- a/source/glest_game/types/upgrade_type.h +++ b/source/glest_game/types/upgrade_type.h @@ -120,6 +120,8 @@ public: moveSpeedIsMultiplier = false; prodSpeed = 0; prodSpeedIsMultiplier = false; + attackSpeed = 0; + attackSpeedIsMultiplier = false; } virtual ~UpgradeTypeBase() {} diff --git a/source/glest_map_editor/main.cpp b/source/glest_map_editor/main.cpp index 9b2dc57c..aaef12ae 100644 --- a/source/glest_map_editor/main.cpp +++ b/source/glest_map_editor/main.cpp @@ -138,12 +138,12 @@ END_EVENT_TABLE() void MainWindow::init(string fname) { #if wxCHECK_VERSION(2, 9, 3) - glCanvas->setCurrentGLContext(); + //glCanvas->setCurrentGLContext(); //printf("setcurrent #1\n"); #elif wxCHECK_VERSION(2, 9, 1) #else - glCanvas->SetCurrent(); + //glCanvas->SetCurrent(); //printf("setcurrent #2\n"); #endif @@ -638,11 +638,17 @@ void MainWindow::onPaint(wxPaintEvent &event) { return; } -#if wxCHECK_VERSION(2, 9, 3) +//#if wxCHECK_VERSION(2, 9, 3) -#elif wxCHECK_VERSION(2, 9, 1) - glCanvas->setCurrentGLContext(); -#endif +//#elif wxCHECK_VERSION(2, 9, 1) +// glCanvas->setCurrentGLContext(); +//#endif + + static bool contextSet = false; + if(contextSet == false) { + contextSet = true; + glCanvas->setCurrentGLContext(); + } if(lastPaintEvent.getMillis() < 30) { sleep(1); diff --git a/source/shared_lib/sources/graphics/model.cpp b/source/shared_lib/sources/graphics/model.cpp index e3bf3cfb..84becdb8 100644 --- a/source/shared_lib/sources/graphics/model.cpp +++ b/source/shared_lib/sources/graphics/model.cpp @@ -1099,7 +1099,7 @@ Model::Model() { } Model::~Model() { - delete [] meshes; + if(meshes) delete [] meshes; meshes = NULL; } diff --git a/source/shared_lib/sources/platform/common/platform_common.cpp b/source/shared_lib/sources/platform/common/platform_common.cpp index dbc6428e..ffcc25cc 100644 --- a/source/shared_lib/sources/platform/common/platform_common.cpp +++ b/source/shared_lib/sources/platform/common/platform_common.cpp @@ -619,7 +619,7 @@ void updatePathClimbingParts(string &path,bool processPreviousDirTokenCheck) { //printf("x [%d][%c] pos [%ld][%c] [%s]\n",x,path[x],(long int)pos,path[pos],path.substr(0,x+1).c_str()); if((path[x] == '/' || path[x] == '\\') && x != (int)pos) { - string origLoop = path; + //string origLoop = path; path.erase(x,(int)pos-x); //printf("#5 [%d] [%d] [%d] CHANGE relative path from [%s] to [%s]\n",(int)pos,(int)x,(int)origLoop.length(),origLoop.c_str(),path.c_str()); @@ -2455,7 +2455,7 @@ void ValueCheckerVault::checkItemInVault(const void *ptr,int value) const { } string getUserHome() { - string home_folder = ""; + string home_folder; home_folder = safeCharPtrCopy(getenv("HOME"),8095); if(home_folder == "") { #if _BSD_SOURCE || _SVID_SOURCE || _XOPEN_SOURCE >= 500 || _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED diff --git a/source/shared_lib/sources/platform/sdl/platform_util.cpp b/source/shared_lib/sources/platform/sdl/platform_util.cpp index 69bd92a3..de618555 100644 --- a/source/shared_lib/sources/platform/sdl/platform_util.cpp +++ b/source/shared_lib/sources/platform/sdl/platform_util.cpp @@ -136,6 +136,7 @@ static int getFileAndLine(char *function, void *address, char *file, size_t flen #if __APPLE_CC__ //### TODO Will: still working this out int len = fread(buf,1,maxbufSize,f); + pclose(f); buf[len] = 0; fprintf(stderr,"< %s",buf); return -1;