- added a new bit style gamesetting flag for future new game settings.

- added ability to see map resources but still keep fog of war (GAE's shroud of darkness), but not activated by UI yet, tested and works
This commit is contained in:
Mark Vejvoda 2010-12-19 08:04:25 +00:00
parent 1c51b6c21d
commit f204d4445c
9 changed files with 89 additions and 29 deletions

View File

@ -117,6 +117,7 @@ public:
//get
GameSettings *getGameSettings() {return &gameSettings;}
const GameSettings *getReadOnlyGameSettings() const {return &gameSettings;}
const GameCamera *getGameCamera() const {return &gameCamera;}
GameCamera *getGameCamera() {return &gameCamera;}

View File

@ -24,6 +24,16 @@ namespace Glest{ namespace Game{
// class GameSettings
// =====================================================
enum FlagTypes1 {
ft1_none = 0x00,
ft1_show_map_resources = 0x01
//ft1_xx = 0x02,
//ft1_xx = 0x04,
//ft1_xx = 0x08,
//ft1_xx = 0x10,
};
class GameSettings{
private:
string description;
@ -57,6 +67,8 @@ private:
bool networkPauseGameForLaggedClients;
PathFinderType pathFinderType;
uint32 flagTypes1;
public:
@ -78,6 +90,8 @@ public:
teams[i] = 0;
startLocationIndex[i] = i;
}
flagTypes1 = ft1_none;
}
// default copy constructor will do fine, and will maintain itself ;)
@ -131,6 +145,7 @@ public:
int getNetworkFramePeriod() const {return networkFramePeriod; }
bool getNetworkPauseGameForLaggedClients() const {return networkPauseGameForLaggedClients; }
PathFinderType getPathFinderType() const { return pathFinderType; }
uint32 getFlagTypes1() const { return flagTypes1;}
//set
void setDescription(const string& description) {this->description= description;}
@ -162,6 +177,7 @@ public:
void setNetworkFramePeriod(int value) {this->networkFramePeriod = value; }
void setNetworkPauseGameForLaggedClients(bool value) {this->networkPauseGameForLaggedClients = value; }
void setPathFinderType(PathFinderType value) {this->pathFinderType = value; }
void setFlagTypes1(uint32 value) {this->flagTypes1 = value; }
string toString() const {
string result = "";
@ -197,6 +213,7 @@ public:
result += "networkFramePeriod = " + intToStr(networkFramePeriod) + "\n";
result += "networkPauseGameForLaggedClients = " + intToStr(networkPauseGameForLaggedClients) + "\n";
result += "pathFinderType = " + intToStr(pathFinderType) + "\n";
result += "flagTypes1 = " + intToStr(flagTypes1) + "\n";
return result;
}

View File

@ -1965,6 +1965,10 @@ void MenuStateCustomGame::loadGameSettings(GameSettings *gameSettings) {
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__);
// Test flags values
//gameSettings->setFlagTypes1(ft1_show_map_resources);
//
gameSettings->setMapFilterIndex(listBoxMapFilter.getSelectedItemIndex());
gameSettings->setDescription(formatString(getCurrentMapFile()));
gameSettings->setMap(getCurrentMapFile());

View File

@ -232,6 +232,7 @@ NetworkMessageLaunch::NetworkMessageLaunch(const GameSettings *gameSettings,int8
data.networkFramePeriod = gameSettings->getNetworkFramePeriod();
data.networkPauseGameForLaggedClients = gameSettings->getNetworkPauseGameForLaggedClients();
data.pathFinderType = gameSettings->getPathFinderType();
data.flagTypes1 = gameSettings->getFlagTypes1();
for(int i= 0; i<data.factionCount; ++i){
data.factionTypeNames[i]= gameSettings->getFactionTypeName(i);
@ -261,6 +262,7 @@ void NetworkMessageLaunch::buildGameSettings(GameSettings *gameSettings) const{
gameSettings->setNetworkFramePeriod(data.networkFramePeriod);
gameSettings->setNetworkPauseGameForLaggedClients((data.networkPauseGameForLaggedClients != 0));
gameSettings->setPathFinderType(static_cast<PathFinderType>(data.pathFinderType));
gameSettings->setFlagTypes1(data.flagTypes1);
for(int i= 0; i<data.factionCount; ++i){
gameSettings->setFactionTypeName(i, data.factionTypeNames[i].getString());

View File

@ -211,6 +211,7 @@ private:
uint8 networkFramePeriod; // allowed values 0 - 255
int8 networkPauseGameForLaggedClients;
int8 pathFinderType;
uint32 flagTypes1;
};
private:

View File

@ -18,6 +18,7 @@
#include "renderer.h"
#include "config.h"
#include "object.h"
#include "game_settings.h"
#include "leak_dumper.h"
using namespace Shared::Graphics;
@ -34,6 +35,7 @@ Minimap::Minimap() {
fowPixmap0= NULL;
fowPixmap1= NULL;
fogOfWar= true;//Config::getInstance().getBool("FogOfWar");
gameSettings= NULL;
}
void Minimap::init(int w, int h, const World *world, bool fogOfWar) {
@ -41,14 +43,28 @@ void Minimap::init(int w, int h, const World *world, bool fogOfWar){
int scaledH= h/Map::cellScale;
this->fogOfWar = fogOfWar;
this->gameSettings = world->getGameSettings();
Renderer &renderer= Renderer::getInstance();
//fow pixmaps
float f= 0.f;
fowPixmap0= new Pixmap2D(next2Power(scaledW), next2Power(scaledH), 1);
fowPixmap1= new Pixmap2D(next2Power(scaledW), next2Power(scaledH), 1);
fowPixmap0->setPixels(&f);
if((this->gameSettings->getFlagTypes1() & ft1_show_map_resources) == ft1_show_map_resources) {
f = 0.f;
fowPixmap1->setPixels(&f);
f = 0.5f;
for (int y=1; y < scaledH - 1; ++y) {
for (int x=1; x < scaledW - 1; ++x) {
fowPixmap1->setPixel(x, y, &f);
}
}
}
else {
fowPixmap1->setPixels(&f);
}
//fow tex
fowTex= renderer.newTexture2D(rsGame);
@ -93,7 +109,19 @@ void Minimap::resetFowTex() {
for(int i=0; i<fowTex->getPixmap()->getW(); ++i){
for(int j=0; j<fowTex->getPixmap()->getH(); ++j){
if(fogOfWar && overridefogOfWarValue){
if ((fogOfWar == false && overridefogOfWarValue == false) &&
(gameSettings->getFlagTypes1() & ft1_show_map_resources) != ft1_show_map_resources) {
float p0 = fowPixmap0->getPixelf(i, j);
float p1 = fowPixmap1->getPixelf(i, j);
if (p0 > p1) {
fowPixmap1->setPixel(i, j, p0);
}
else {
fowPixmap1->setPixel(i, j, p1);
}
}
else if((fogOfWar && overridefogOfWarValue) ||
(gameSettings->getFlagTypes1() & ft1_show_map_resources) != ft1_show_map_resources) {
float p0= fowPixmap0->getPixelf(i, j);
float p1= fowPixmap1->getPixelf(i, j);

View File

@ -25,6 +25,7 @@ using Shared::Graphics::Pixmap2D;
using Shared::Graphics::Texture2D;
class World;
class GameSettings;
enum ExplorationState{
esNotExplored,
@ -45,6 +46,7 @@ private:
Texture2D *tex;
Texture2D *fowTex; //Fog Of War Texture2D
bool fogOfWar;
const GameSettings *gameSettings;
private:
static const float exploredAlpha;

View File

@ -876,7 +876,7 @@ void World::initCells(bool fogOfWar) {
j/(next2Power(map.getSurfaceH())-1.f)));
for (int k = 0; k < GameConstants::maxPlayers; k++) {
sc->setExplored(k, !fogOfWar);
sc->setExplored(k, (game->getGameSettings()->getFlagTypes1() & ft1_show_map_resources) == ft1_show_map_resources);
sc->setVisible(k, !fogOfWar);
}
for (int k = GameConstants::maxPlayers; k < GameConstants::maxPlayers + GameConstants::specialFactions; k++) {
@ -1342,6 +1342,10 @@ void World::computeFow(int factionIdxToTick) {
}
}
const GameSettings * World::getGameSettings() const {
return (game != NULL ? game->getReadOnlyGameSettings() : NULL);
}
// WARNING! This id is critical! Make sure it fits inside the network packet
// (currently cannot be larger than 2,147,483,647)
// Make sure each faction has their own unique section of id #'s for proper

View File

@ -197,6 +197,7 @@ public:
int getUnitCountOfType(int factionIndex, const string &typeName);
Game * getGame() { return game; }
const GameSettings * getGameSettings() const;
std::vector<std::string> validateFactionTypes();
std::vector<std::string> validateResourceTypes();