Skip to content

Commit

Permalink
Merged the fog branch to trunk
Browse files Browse the repository at this point in the history
  • Loading branch information
RosaryMala committed Dec 16, 2009
1 parent ec2f58c commit 3da163b
Show file tree
Hide file tree
Showing 9 changed files with 824 additions and 701 deletions.
15 changes: 8 additions & 7 deletions Block.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include "dfhack/library/DFTypes.h"


BITMAP* temptile=0;




Expand Down Expand Up @@ -144,12 +144,12 @@ void Block::Draw(BITMAP* target){
{
DrawSpriteFromSheet( BASE_SHADOW_TILE + shadow - 1, target, IMGObjectSheet, drawx, (ramp.type > 0)?(drawy - (WALLHEIGHT/2)):drawy );
}

//Building
bool skipBuilding =
bool skipBuilding =
(building.info.type == BUILDINGTYPE_STOCKPILE && !config.show_stockpiles) ||
(building.info.type == BUILDINGTYPE_ZONE && !config.show_zones);

if(building.info.type != BUILDINGTYPE_NA && !skipBuilding){

int spriteNum = SPRITEOBJECT_NA; //getBuildingSprite(this->building, mirroredBuilding);
Expand All @@ -159,6 +159,7 @@ void Block::Draw(BITMAP* target){
if (!(sprite.animFrames & (1 << currentAnimationFrame)))
continue;
DrawSpriteFromSheet(sprite.sheetIndex , target, imageSheet(sprite,IMGObjectSheet),

drawx + building.sprites[i].x,
drawy + building.sprites[i].y);
}
Expand Down Expand Up @@ -219,7 +220,7 @@ void Block::Draw(BITMAP* target){
//Western border
if(this->depthBorderWest)
line(target, drawx, drawy+(TILEHEIGHT>>1)-1, drawx+(TILEWIDTH>>1)-1, drawy, tileBorderColor);

drawy += (WALLHEIGHT);
}
}
Expand Down Expand Up @@ -247,7 +248,7 @@ void Block::Draw(BITMAP* target){
void Block::DrawRamptops(BITMAP* target){
if (ramp.type > 0)
{

int sheetOffsetX, sheetOffsetY;
/*if(config.hide_outer_blocks){
if(x == ownerSegment->x || x == ownerSegment->x + ownerSegment->sizex - 1) return;
Expand Down Expand Up @@ -310,4 +311,4 @@ bool wallShouldNotHaveBorders( int in ){
break;
};
return false;
}
}
2 changes: 1 addition & 1 deletion BlockFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ Block* BlockFactory::allocateBlock(){
void BlockFactory::deleteBlock(Block *b){
poolSize++;
pool.push_back( b );
}
}
316 changes: 179 additions & 137 deletions Config.cpp
Original file line number Diff line number Diff line change
@@ -1,120 +1,120 @@
#include <iostream>
#include <fstream>
#include <string>
#include "common.h"

using namespace std;

string parseStrFromLine( string keyword, string line ){
string retVal = "";
string trimString = "";
trimString += "[";
trimString += keyword;
trimString += ":";
int length = (int)trimString.length();

if( line.compare(0,length, trimString) == 0){
line.replace(0,length,"");
line.replace(line.length()-1,1,"");
retVal = line;
}

return retVal;
}

int parseIntFromLine( string keyword, string line ){
int retVal = 0;
string trimString = "";
trimString += "[";
trimString += keyword;
trimString += ":";
int length = (int)trimString.length();

if( line.compare(0,length, trimString) == 0){
line.replace(0,length,"");
line.replace(line.length()-1,1,"");
retVal = atoi( line.c_str() );
}

return retVal;
}


void parseConfigLine( string line ){
char c = line[0];
if( c != '[') return;
//some systems don't remove the \r char as a part of the line change:
if(line.size() > 0 && line[line.size() -1 ] == '\r' )
line.resize(line.size() -1);
c = line[ line.length() -1 ];
if( c != ']' ) return;

if( line.find("WIDTH") != -1){
int width = parseIntFromLine( "WIDTH", line );
config.screenWidth = width;
}
if( line.find("HEIGHT") != -1){
int height = parseIntFromLine( "HEIGHT", line );
config.screenHeight = height;
}
if( line.find("WINDOWED") != -1){
string result = parseStrFromLine( "WINDOWED", line );
config.Fullscreen = (result == "NO");
}
if( line.find("SEGMENTSIZE_XY") != -1){
int value = parseIntFromLine( "SEGMENTSIZE_XY", line );
if(value < 5) value = DEFAULT_SEGMENTSIZE;
if(value > 100) value = 100;
//plus 2 to allow edge readings
config.segmentSize.x = value+2;
config.segmentSize.y = value+2;
}
if( line.find("SEGMENTSIZE_Z") != -1){
int value = parseIntFromLine( "SEGMENTSIZE_Z", line );
if(value < 1) value = DEFAULT_SEGMENTSIZE_Z;
if(value > 30) value = 30;
config.segmentSize.z = value;
}

if( line.find("ALLCREATURES") != -1){
string result = parseStrFromLine( "ALLCREATURES", line );
config.show_all_creatures = (result == "YES");
}
if( line.find("AUTO_RELOAD_STEP") != -1){
int value = parseIntFromLine( "AUTO_RELOAD_STEP", line);
if(value < 50) value = 50;
config.automatic_reload_step = value;
}
if( line.find("AUTO_RELOAD_TIME") != -1){
int value = parseIntFromLine( "AUTO_RELOAD_TIME", line);
if(value < 0) value = 0;
config.automatic_reload_time = value;
}
if( line.find("DEBUGMODE") != -1){
string result = parseStrFromLine( "DEBUGMODE", line );
config.debug_mode = (result == "YES");
}
if( line.find("LIFTSEGMENT") != -1){
int value = parseIntFromLine( "LIFTSEGMENT", line);
config.lift_segment_offscreen = value;
}
if( line.find("ANIMATION_RATE") != -1){
int value = parseIntFromLine( "ANIMATION_RATE", line );
if(value < 50) value = 50;
config.animation_step = value;
}
if( line.find("VERBOSE_LOGGING") != -1){
string result = parseStrFromLine( "VERBOSE_LOGGING", line );
config.verbose_logging = (result == "YES");
}
if( line.find("TRACK_CENTER") != -1){
string result = parseStrFromLine( "TRACK_CENTER", line );
config.track_center = (result == "YES");
}
#include <iostream>
#include <fstream>
#include <string>
#include "common.h"

using namespace std;

string parseStrFromLine( string keyword, string line ){
string retVal = "";
string trimString = "";
trimString += "[";
trimString += keyword;
trimString += ":";
int length = (int)trimString.length();


if( line.compare(0,length, trimString) == 0){
line.replace(0,length,"");
line.replace(line.length()-1,1,"");
retVal = line;
}

return retVal;
}

int parseIntFromLine( string keyword, string line ){
int retVal = 0;
string trimString = "";
trimString += "[";
trimString += keyword;
trimString += ":";
int length = (int)trimString.length();


if( line.compare(0,length, trimString) == 0){
line.replace(0,length,"");
line.replace(line.length()-1,1,"");
retVal = atoi( line.c_str() );
}

return retVal;
}


void parseConfigLine( string line ){
char c = line[0];
if( c != '[') return;

//some systems don't remove the \r char as a part of the line change:
if(line.size() > 0 && line[line.size() -1 ] == '\r' )
line.resize(line.size() -1);

c = line[ line.length() -1 ];
if( c != ']' ) return;

if( line.find("WIDTH") != -1){
int width = parseIntFromLine( "WIDTH", line );
config.screenWidth = width;
}
if( line.find("HEIGHT") != -1){
int height = parseIntFromLine( "HEIGHT", line );
config.screenHeight = height;
}
if( line.find("WINDOWED") != -1){
string result = parseStrFromLine( "WINDOWED", line );
config.Fullscreen = (result == "NO");
}
if( line.find("SEGMENTSIZE_XY") != -1){
int value = parseIntFromLine( "SEGMENTSIZE_XY", line );
if(value < 5) value = DEFAULT_SEGMENTSIZE;
if(value > 100) value = 100;
//plus 2 to allow edge readings
config.segmentSize.x = value+2;
config.segmentSize.y = value+2;
}
if( line.find("SEGMENTSIZE_Z") != -1){
int value = parseIntFromLine( "SEGMENTSIZE_Z", line );
if(value < 1) value = DEFAULT_SEGMENTSIZE_Z;
if(value > 30) value = 30;
config.segmentSize.z = value;
}

if( line.find("ALLCREATURES") != -1){
string result = parseStrFromLine( "ALLCREATURES", line );
config.show_all_creatures = (result == "YES");
}
if( line.find("AUTO_RELOAD_STEP") != -1){
int value = parseIntFromLine( "AUTO_RELOAD_STEP", line);
if(value < 50) value = 50;
config.automatic_reload_step = value;
}
if( line.find("AUTO_RELOAD_TIME") != -1){
int value = parseIntFromLine( "AUTO_RELOAD_TIME", line);
if(value < 0) value = 0;
config.automatic_reload_time = value;
}
if( line.find("DEBUGMODE") != -1){
string result = parseStrFromLine( "DEBUGMODE", line );
config.debug_mode = (result == "YES");
}
if( line.find("LIFTSEGMENT") != -1){
int value = parseIntFromLine( "LIFTSEGMENT", line);
config.lift_segment_offscreen = value;
}
if( line.find("ANIMATION_RATE") != -1){
int value = parseIntFromLine( "ANIMATION_RATE", line );
if(value < 50) value = 50;
config.animation_step = value;
}
if( line.find("VERBOSE_LOGGING") != -1){
string result = parseStrFromLine( "VERBOSE_LOGGING", line );
config.verbose_logging = (result == "YES");
}
if( line.find("TRACK_CENTER") != -1){
string result = parseStrFromLine( "TRACK_CENTER", line );
config.track_center = (result == "YES");
}
if( line.find("FOLLOW_DF_SCREEN") != -1){
string result = parseStrFromLine( "FOLLOW_DF_SCREEN", line );
config.follow_DFscreen = (result == "YES");
Expand All @@ -131,26 +131,68 @@ void parseConfigLine( string line ){
string result = parseStrFromLine( "INTRO", line );
config.show_intro = !(result == "OFF");
}
}


bool loadConfigFile(){
string line;
ifstream myfile ("init.txt");
if (myfile.is_open() == false)
{
cout << "Cannot find init file" << endl;
return false;
if( line.find("FOG_RED") != -1){
int value = parseIntFromLine( "FOG_RED", line);
if(value > 255) value = 255;
if(value < 0) value = 0;
config.fogr = value;
}
if( line.find("FOG_GREEN") != -1){
int value = parseIntFromLine( "FOG_GREEN", line);
if(value > 255) value = 255;
if(value < 0) value = 0;
config.fogg = value;
}
if( line.find("FOG_BLUE") != -1){
int value = parseIntFromLine( "FOG_BLUE", line);
if(value > 255) value = 255;
if(value < 0) value = 0;
config.fogb = value;
}
if( line.find("FOG_ALPHA") != -1){
int value = parseIntFromLine( "FOG_ALPHA", line);
if(value > 255) value = 255;
if(value < 0) value = 0;
config.foga = value;
}

while ( !myfile.eof() )
{
getline (myfile,line);
cout << line << endl;
parseConfigLine( line );
if( line.find("BACK_RED") != -1){
int value = parseIntFromLine( "BACK_RED", line);
if(value > 255) value = 255;
if(value < 0) value = 0;
config.backr = value;
}
myfile.close();


return true;
if( line.find("BACK_GREEN") != -1){
int value = parseIntFromLine( "BACK_GREEN", line);
if(value > 255) value = 255;
if(value < 0) value = 0;
config.backg = value;
}
if( line.find("BACK_BLUE") != -1){
int value = parseIntFromLine( "BACK_BLUE", line);
if(value > 255) value = 255;
if(value < 0) value = 0;
config.backb = value;
}
}


bool loadConfigFile(){
string line;
ifstream myfile ("init.txt");
if (myfile.is_open() == false)
{
cout << "Cannot find init file" << endl;
return false;
}

while ( !myfile.eof() )
{
getline (myfile,line);
cout << line << endl;
parseConfigLine( line );
}
myfile.close();


return true;
}
Loading

0 comments on commit 3da163b

Please sign in to comment.