Merge branch 'develop' of github.com:MegaGlest/megaglest-source into develop

This commit is contained in:
titiger 2014-11-29 19:09:37 +01:00
commit 9e676a6e0e
13 changed files with 70 additions and 39 deletions

View File

@ -435,6 +435,7 @@
<ClCompile Include="..\..\..\source\glest_game\network\server_interface.cpp" /> <ClCompile Include="..\..\..\source\glest_game\network\server_interface.cpp" />
<ClCompile Include="..\..\..\source\glest_game\sound\sound_container.cpp" /> <ClCompile Include="..\..\..\source\glest_game\sound\sound_container.cpp" />
<ClCompile Include="..\..\..\source\glest_game\sound\sound_renderer.cpp" /> <ClCompile Include="..\..\..\source\glest_game\sound\sound_renderer.cpp" />
<ClCompile Include="..\..\..\source\glest_game\types\projectile_type.cpp" />
<ClCompile Include="..\..\..\source\glest_game\types\tileset_model_type.cpp" /> <ClCompile Include="..\..\..\source\glest_game\types\tileset_model_type.cpp" />
<ClCompile Include="..\..\..\source\glest_game\type_instances\command.cpp" /> <ClCompile Include="..\..\..\source\glest_game\type_instances\command.cpp" />
<ClCompile Include="..\..\..\source\glest_game\type_instances\faction.cpp" /> <ClCompile Include="..\..\..\source\glest_game\type_instances\faction.cpp" />
@ -562,4 +563,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets"> <ImportGroup Label="ExtensionTargets">
</ImportGroup> </ImportGroup>
</Project> </Project>

View File

@ -480,12 +480,15 @@ void MainWindow::setupTimer() {
} }
void MainWindow::setupStartupSettings() { 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)); fprintf(stderr, "Error [main]: glewInit failed: %s\n", glewGetErrorString(err));
//return 1; //return 1;
throw std::runtime_error((char *)glewGetErrorString(err)); throw std::runtime_error((char *)glewGetErrorString(err));
} }
renderer= Renderer::getInstance(); renderer= Renderer::getInstance();
@ -567,12 +570,12 @@ MainWindow::~MainWindow(){
void MainWindow::init() { void MainWindow::init() {
#if wxCHECK_VERSION(2, 9, 3) #if wxCHECK_VERSION(2, 9, 3)
glCanvas->setCurrentGLContext(); //glCanvas->setCurrentGLContext();
//printf("setcurrent #1\n"); //printf("setcurrent #1\n");
#elif wxCHECK_VERSION(2, 9, 1) #elif wxCHECK_VERSION(2, 9, 1)
#else #else
glCanvas->SetCurrent(); //glCanvas->SetCurrent();
//printf("setcurrent #2\n"); //printf("setcurrent #2\n");
#endif #endif
@ -585,10 +588,12 @@ void MainWindow::init() {
void MainWindow::onPaint(wxPaintEvent &event) { void MainWindow::onPaint(wxPaintEvent &event) {
if(!IsShown()) return; 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) #elif wxCHECK_VERSION(2, 9, 1)
glCanvas->setCurrentGLContext(); //glCanvas->setCurrentGLContext();
#endif #endif
if(startupSettingsInited == false) { if(startupSettingsInited == false) {
@ -756,8 +761,8 @@ void MainWindow::onClose(wxCloseEvent &event){
delete timer; delete timer;
timer = NULL; timer = NULL;
delete model; //delete model;
model = NULL; //model = NULL;
delete renderer; delete renderer;
renderer = NULL; renderer = NULL;
@ -2029,7 +2034,7 @@ GlCanvas::GlCanvas(MainWindow * mainWindow, int *args)
} }
GlCanvas::~GlCanvas() { GlCanvas::~GlCanvas() {
delete this->context; if(this->context) delete this->context;
this->context = NULL; this->context = NULL;
} }
@ -2039,11 +2044,13 @@ void GlCanvas::setCurrentGLContext() {
#if wxCHECK_VERSION(2, 9, 1) #if wxCHECK_VERSION(2, 9, 1)
if(this->context == NULL) { if(this->context == NULL) {
this->context = new wxGLContext(this); this->context = new wxGLContext(this);
//printf("Set ctx [%p]\n",this->context);
} }
#endif #endif
//printf("Set ctx [%p]\n",this->context); //printf("Set ctx [%p]\n",this->context);
if(this->context) { if(this->context) {
wxGLCanvas::SetCurrent(*this->context); wxGLCanvas::SetCurrent(*this->context);
//printf("Set ctx2 [%p]\n",this->context);
} }
#else #else
this->SetCurrent(); this->SetCurrent();

View File

@ -201,6 +201,7 @@ public:
void onKeyDown(wxKeyEvent &event); void onKeyDown(wxKeyEvent &event);
void setCurrentGLContext(); void setCurrentGLContext();
wxGLContext * getCtx() { return context; }
private: private:
MainWindow *mainWindow; MainWindow *mainWindow;
wxGLContext *context; wxGLContext *context;

View File

@ -5464,19 +5464,21 @@ void Renderer::renderSelectionEffects(int healthbarMode) {
currVec.y+= 0.3f; currVec.y+= 0.3f;
//selection circle //selection circle
int finalHealthbarMode=hbvUndefined; int finalHealthbarMode = hbvUndefined;
if(healthbarMode==hbvUndefined) { if(healthbarMode == hbvUndefined) {
finalHealthbarMode=unit->getFaction()->getType()->getHealthbarVisible(); finalHealthbarMode = unit->getFaction()->getType()->getHealthbarVisible();
} else {
finalHealthbarMode=healthbarMode;
} }
bool healthbarsVisible=((finalHealthbarMode&hbvAlways)||(finalHealthbarMode&hbvSelected)||(finalHealthbarMode&hbvIfNeeded)); else {
float selectionCircleThickness=0.2f; finalHealthbarMode = healthbarMode;
float hpRatio; }
bool healthbarsVisible =((finalHealthbarMode & hbvAlways) ||
(finalHealthbarMode & hbvSelected) ||
(finalHealthbarMode & hbvIfNeeded));
float selectionCircleThickness = 0.2f;
float hpRatio = unit->getHpRatio();
if(healthbarsVisible) { if(healthbarsVisible) {
hpRatio=unit->getHpRatio(); selectionCircleThickness = 0.05f;
selectionCircleThickness=0.05f; hpRatio = 1.0f;
hpRatio=1.0f;
} }
if(world->getThisFactionIndex() == unit->getFactionIndex()) { if(world->getThisFactionIndex() == unit->getFactionIndex()) {
@ -5493,7 +5495,7 @@ void Renderer::renderSelectionEffects(int healthbarMode) {
else if ( world->getThisTeamIndex() == unit->getTeam()) { else if ( world->getThisTeamIndex() == unit->getTeam()) {
glColor4f(hpRatio, hpRatio, 0, 0.3f); glColor4f(hpRatio, hpRatio, 0, 0.3f);
} }
else{ else {
glColor4f(hpRatio, 0, 0, 0.3f); glColor4f(hpRatio, 0, 0, 0.3f);
} }
renderSelectionCircle(currVec, unit->getType()->getSize(), selectionCircleRadius,selectionCircleThickness); renderSelectionCircle(currVec, unit->getType()->getSize(), selectionCircleRadius,selectionCircleThickness);

View File

@ -62,7 +62,7 @@ bool AttackBoost::isAffected(const Unit *source, const Unit *dest) const {
else { else {
// All units are affected (including enemies) // All units are affected (including enemies)
if(targetType == abtAll) { if(targetType == abtAll) {
destUnitMightApply = (boostUnitList.empty() && tags.empty()); //destUnitMightApply = (boostUnitList.empty() && tags.empty());
destUnitMightApply = isInUnitListOrTags(dest->getType()); destUnitMightApply = isInUnitListOrTags(dest->getType());
} }
// Only same faction units are affected // 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(boostUnitList.empty() == true) {
if(source->getFactionIndex() == dest->getFactionIndex()) { if(source->getFactionIndex() == dest->getFactionIndex()) {
//destUnitMightApply = true; //destUnitMightApply = true;
destUnitMightApply = (boostUnitList.empty() && tags.empty()); //destUnitMightApply = (boostUnitList.empty() && tags.empty());
destUnitMightApply = isInUnitListOrTags(dest->getType()); destUnitMightApply = isInUnitListOrTags(dest->getType());
} }
//} //}
@ -80,7 +80,7 @@ bool AttackBoost::isAffected(const Unit *source, const Unit *dest) const {
//if(boostUnitList.empty() == true) { //if(boostUnitList.empty() == true) {
if(source->isAlly(dest) == true) { if(source->isAlly(dest) == true) {
//destUnitMightApply = true; //destUnitMightApply = true;
destUnitMightApply = (boostUnitList.empty() && tags.empty()); //destUnitMightApply = (boostUnitList.empty() && tags.empty());
destUnitMightApply = isInUnitListOrTags(dest->getType()); destUnitMightApply = isInUnitListOrTags(dest->getType());
} }
//} //}
@ -90,7 +90,7 @@ bool AttackBoost::isAffected(const Unit *source, const Unit *dest) const {
//if(boostUnitList.empty() == true) { //if(boostUnitList.empty() == true) {
if(source->isAlly(dest) == false) { if(source->isAlly(dest) == false) {
//destUnitMightApply = true; //destUnitMightApply = true;
destUnitMightApply = (boostUnitList.empty() && tags.empty()); //destUnitMightApply = (boostUnitList.empty() && tags.empty());
destUnitMightApply = isInUnitListOrTags(dest->getType()); destUnitMightApply = isInUnitListOrTags(dest->getType());
} }
//} //}

View File

@ -141,6 +141,8 @@ UnitType::UnitType() : ProducibleType() {
size=0; size=0;
renderSize=0; renderSize=0;
height=0; height=0;
burnHeight=0;
targetHeight=0;
addItemToVault(&(this->maxHp),this->maxHp); addItemToVault(&(this->maxHp),this->maxHp);
addItemToVault(&(this->hpRegeneration),this->hpRegeneration); addItemToVault(&(this->hpRegeneration),this->hpRegeneration);
@ -644,7 +646,7 @@ void UnitType::loaddd(int id,const string &dir, const TechTree *techTree,
} }
} }
sortedItems.clear(); sortedItems.clear();
hasDup = false; //hasDup = false;
// Lootable resources (resources given/lost on death) // Lootable resources (resources given/lost on death)
if(parametersNode->hasChild("resources-death")) { if(parametersNode->hasChild("resources-death")) {

View File

@ -79,6 +79,15 @@ private:
bool negativeAllowed; bool negativeAllowed;
public: public:
LootableResource() {
type=NULL;
amountValue=0;
amountFactionPercent=0;
lossValue=0;
lossFactionPercent=0;
negativeAllowed=false;
}
const ResourceType* getResourceType() const {return type;} const ResourceType* getResourceType() const {return type;}
void setResourceType(const ResourceType *type) {this->type=type;} void setResourceType(const ResourceType *type) {this->type=type;}
@ -282,7 +291,7 @@ public:
int getTargetHeight() const {return targetHeight;} int getTargetHeight() const {return targetHeight;}
int getStoredResourceCount() const {return (int)storedResources.size();} int getStoredResourceCount() const {return (int)storedResources.size();}
inline const Resource *getStoredResource(int i) const {return &storedResources[i];} 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);} inline const LootableResource getLootableResource(int i) const {return lootableResources.at(i);}
const set<string> &getTags() const {return tags;} const set<string> &getTags() const {return tags;}
bool getCellMapCell(int x, int y, CardinalDir facing) const; bool getCellMapCell(int x, int y, CardinalDir facing) const;

View File

@ -781,7 +781,7 @@ void UpgradeType::load(const string &dir, const TechTree *techTree,
} }
sortedItems.clear(); sortedItems.clear();
hasDup = false; //hasDup = false;
//effects -- get list of affected units //effects -- get list of affected units
const XmlNode *effectsNode= upgradeNode->getChild("effects"); const XmlNode *effectsNode= upgradeNode->getChild("effects");

View File

@ -120,6 +120,8 @@ public:
moveSpeedIsMultiplier = false; moveSpeedIsMultiplier = false;
prodSpeed = 0; prodSpeed = 0;
prodSpeedIsMultiplier = false; prodSpeedIsMultiplier = false;
attackSpeed = 0;
attackSpeedIsMultiplier = false;
} }
virtual ~UpgradeTypeBase() {} virtual ~UpgradeTypeBase() {}

View File

@ -138,12 +138,12 @@ END_EVENT_TABLE()
void MainWindow::init(string fname) { void MainWindow::init(string fname) {
#if wxCHECK_VERSION(2, 9, 3) #if wxCHECK_VERSION(2, 9, 3)
glCanvas->setCurrentGLContext(); //glCanvas->setCurrentGLContext();
//printf("setcurrent #1\n"); //printf("setcurrent #1\n");
#elif wxCHECK_VERSION(2, 9, 1) #elif wxCHECK_VERSION(2, 9, 1)
#else #else
glCanvas->SetCurrent(); //glCanvas->SetCurrent();
//printf("setcurrent #2\n"); //printf("setcurrent #2\n");
#endif #endif
@ -638,11 +638,17 @@ void MainWindow::onPaint(wxPaintEvent &event) {
return; return;
} }
#if wxCHECK_VERSION(2, 9, 3) //#if wxCHECK_VERSION(2, 9, 3)
#elif wxCHECK_VERSION(2, 9, 1) //#elif wxCHECK_VERSION(2, 9, 1)
glCanvas->setCurrentGLContext(); // glCanvas->setCurrentGLContext();
#endif //#endif
static bool contextSet = false;
if(contextSet == false) {
contextSet = true;
glCanvas->setCurrentGLContext();
}
if(lastPaintEvent.getMillis() < 30) { if(lastPaintEvent.getMillis() < 30) {
sleep(1); sleep(1);

View File

@ -1099,7 +1099,7 @@ Model::Model() {
} }
Model::~Model() { Model::~Model() {
delete [] meshes; if(meshes) delete [] meshes;
meshes = NULL; meshes = NULL;
} }

View File

@ -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()); //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) { if((path[x] == '/' || path[x] == '\\') && x != (int)pos) {
string origLoop = path; //string origLoop = path;
path.erase(x,(int)pos-x); 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()); //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 getUserHome() {
string home_folder = ""; string home_folder;
home_folder = safeCharPtrCopy(getenv("HOME"),8095); home_folder = safeCharPtrCopy(getenv("HOME"),8095);
if(home_folder == "") { if(home_folder == "") {
#if _BSD_SOURCE || _SVID_SOURCE || _XOPEN_SOURCE >= 500 || _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED #if _BSD_SOURCE || _SVID_SOURCE || _XOPEN_SOURCE >= 500 || _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED

View File

@ -136,6 +136,7 @@ static int getFileAndLine(char *function, void *address, char *file, size_t flen
#if __APPLE_CC__ #if __APPLE_CC__
//### TODO Will: still working this out //### TODO Will: still working this out
int len = fread(buf,1,maxbufSize,f); int len = fread(buf,1,maxbufSize,f);
pclose(f);
buf[len] = 0; buf[len] = 0;
fprintf(stderr,"< %s",buf); fprintf(stderr,"< %s",buf);
return -1; return -1;