diff --git a/mk/linux/data b/mk/linux/data index 25450aee..0ddee880 120000 --- a/mk/linux/data +++ b/mk/linux/data @@ -1 +1 @@ -../../data/glest_game/data \ No newline at end of file +../../data/glest_game/data/ \ No newline at end of file diff --git a/mk/linux/makerelease.sh b/mk/linux/makerelease.sh index 80ebdab6..bfa91b57 100755 --- a/mk/linux/makerelease.sh +++ b/mk/linux/makerelease.sh @@ -3,6 +3,9 @@ VERSION=`./mg-version.sh --version` RELEASENAME=megaglest-source RELEASEDIR="`pwd`/release/$RELEASENAME-$VERSION" +RELEASESOURCEDIR=$RELEASEDIR/source +MKDIR=$RELEASEDIR/mk +CMAKEDIR=$MKDIR/cmake echo "Creating source package in $RELEASEDIR" @@ -27,10 +30,12 @@ popd popd cp -p ../../docs/readme*.txt ../../docs/*license*.txt $RELEASEDIR +cp -p ../../build-mg*.sh $RELEASEDIR +cp -p ../../CMakeLists.txt $RELEASEDIR cp -p glest.ini $RELEASEDIR cp -p glestkeys.ini $RELEASEDIR cp -p servers.ini $RELEASEDIR -cp -p glest.ico $RELEASEDIR +cp -p megaglest.ico $RELEASEDIR cp -p glest.ico $RELEASEDIR cp -p ../../CMake* $RELEASEDIR diff --git a/source/glest_game/world/map.cpp b/source/glest_game/world/map.cpp index aff92870..db1764aa 100644 --- a/source/glest_game/world/map.cpp +++ b/source/glest_game/world/map.cpp @@ -271,9 +271,9 @@ Checksum Map::load(const string &path, TechTree *techTree, Tileset *tileset) { return mapChecksum; } -void Map::init() { +void Map::init(Tileset *tileset) { Logger::getInstance().add("Heightmap computations", true); - smoothSurface(); + smoothSurface(tileset); computeNormals(); computeInterpolatedHeights(); computeNearSubmerged(); @@ -1076,34 +1076,61 @@ void Map::computeInterpolatedHeights(){ } -void Map::smoothSurface(){ +void Map::smoothSurface(Tileset *tileset) { - float *oldHeights= new float[getSurfaceCellArraySize()]; + float minCliffHeightDifference=0.0f; + float *oldHeights = new float[getSurfaceCellArraySize()]; - for(int i=0; i < getSurfaceCellArraySize(); ++i) { - oldHeights[i]= surfaceCells[i].getHeight(); + for (int i = 0; i < getSurfaceCellArraySize(); ++i) { + oldHeights[i] = surfaceCells[i].getHeight(); } - for(int i=1; i abs(oldHeights[(j) * surfaceW + (i)] + - oldHeights[(j + k) * surfaceW + (i + l)])) { + height += oldHeights[(j + k) * surfaceW + (i + l)]; + numUsedToSmooth++; + } else { + // we have something which should not be smoothed! + // This is a cliff and must be textured -> set cliff texture + getSurfaceCell(i, j)->setSurfaceType(5); + //set invisible blocking object and replace resource objects + //and non blocking objects with invisible blocker too + Object *formerObject = + getSurfaceCell(i, j)->getObject(); + if (formerObject != NULL) { + if (formerObject->getWalkable() + || formerObject->getResource() != NULL) { + delete formerObject; + formerObject = NULL; + } + } + if (formerObject == NULL) { + Object *o = new Object(tileset->getObjectType(9), + getSurfaceCell(i, j)->getVertex(), Vec2i(i, + j)); + getSurfaceCell(i, j)->setObject(o); + } + } } } - height/= 9.f; + + height /= numUsedToSmooth; getSurfaceCell(i, j)->setHeight(height); - Object *object= getSurfaceCell(i, j)->getObject(); - if(object!=NULL){ + Object *object = getSurfaceCell(i, j)->getObject(); + if (object != NULL) { object->setHeight(height); } } } - - delete [] oldHeights; + delete[] oldHeights; } void Map::computeNearSubmerged(){ diff --git a/source/glest_game/world/map.h b/source/glest_game/world/map.h index 11965c35..22ad1fe9 100755 --- a/source/glest_game/world/map.h +++ b/source/glest_game/world/map.h @@ -175,7 +175,7 @@ public: ~Map(); Checksum * getChecksumValue() { return &checksumValue; } - void init(); + void init(Tileset *tileset); Checksum load(const string &path, TechTree *techTree, Tileset *tileset); //get @@ -250,7 +250,7 @@ public: private: //compute - void smoothSurface(); + void smoothSurface(Tileset *tileset); void computeNearSubmerged(); void computeCellColors(); }; diff --git a/source/glest_game/world/tileset.cpp b/source/glest_game/world/tileset.cpp index a9ab958d..701463cb 100644 --- a/source/glest_game/world/tileset.cpp +++ b/source/glest_game/world/tileset.cpp @@ -136,7 +136,15 @@ void Tileset::load(const string &dir, Checksum *checksum, Checksum *tilesetCheck //surfaces const XmlNode *surfacesNode= tilesetNode->getChild("surfaces"); for(int i=0; igetChild("surface", i); + const XmlNode *surfaceNode; + if(surfacesNode->hasChildAtIndex("surface",i)){ + surfaceNode= surfacesNode->getChild("surface", i); + } + else { + // cliff texture does not exist, use texture 2 instead + surfaceNode= surfacesNode->getChild("surface", 2); + } + int childCount= surfaceNode->getChildCount(); surfPixmaps[i].resize(childCount); diff --git a/source/glest_game/world/tileset.h b/source/glest_game/world/tileset.h index d38f44be..d822d87e 100644 --- a/source/glest_game/world/tileset.h +++ b/source/glest_game/world/tileset.h @@ -100,7 +100,7 @@ public: class Tileset{ public: static const int waterTexCount= 1; - static const int surfCount= 5; + static const int surfCount= 6; static const int objCount= 10; static const int transitionVars= 2; //number or different transition textures diff --git a/source/glest_game/world/world.cpp b/source/glest_game/world/world.cpp index 6fd631ea..99d330a4 100644 --- a/source/glest_game/world/world.cpp +++ b/source/glest_game/world/world.cpp @@ -1224,7 +1224,7 @@ void World::initUnits() { void World::initMap() { SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); - map.init(); + map.init(&tileset); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); }