diff --git a/source/code/BlockGame.hpp b/source/code/BlockGame.hpp index 9b1f464..d9a5e73 100644 --- a/source/code/BlockGame.hpp +++ b/source/code/BlockGame.hpp @@ -1168,7 +1168,7 @@ public: if (chainUsed[i]==true) { if ((vsMode)&&(chainSize[i]>1)) garbageTarget->CreateGarbage(6, chainSize[i]-1); if ((SoundEnabled)&&(chainSize[i]>4))Mix_PlayChannel(1, applause, 0); - if(chainSize[i]>1 && !puzzleMode) + if(chainSize[i]>1 && !puzzleMode && !AI_Enabled) Stats::getInstance()->addOne((string)"chainX"+itoa(chainSize[i])); chainUsed[i]=false; } diff --git a/source/code/common.cc b/source/code/common.cc index 40d8296..7aee337 100644 --- a/source/code/common.cc +++ b/source/code/common.cc @@ -42,6 +42,11 @@ string double2str(double num) return converter.str(); } +/* + * str2double parses a string and returns a double with the value of the string + * if the string is not a double then 0.0 is returned instead of throing an error + * in that way this function will always return a useable value. + */ double str2double(string str2parse) { try{ @@ -55,6 +60,11 @@ double str2double(string str2parse) } } +/* + * str2int parses a string and returns an int with the value of the string + * if the string is not an int then 0 is returned instead of throing an error + * in that way this function will always return a useable value. + */ int str2int(string str2parse) { try{ diff --git a/source/code/common.h b/source/code/common.h index 5c1aa05..82cd458 100644 --- a/source/code/common.h +++ b/source/code/common.h @@ -24,9 +24,20 @@ Copyright (C) 2008 Poul Sander http://blockattack.sf.net */ +/* + *This is the common.h + *It contains some basic functions that nearly all multiplatform games are going + *to need. + */ + #ifndef _COMMON_H #define _COMMON_H +/* + *Files will be saved in: + * HOME/.gamesaves/"+GAMENAME (unix) + *or DOCUMENTS/My Games/GAMENAME (Windows) + */ #define GAMENAME "blockattack" #include @@ -54,6 +65,12 @@ commonTime addTotalTime(commonTime toAdd); #define MAX_VAR_LENGTH 1024 +/*This is the Config class it is a map to hold config variables. + *It is inspired by Quake 3's CVAR system although a lot simpler. + *All variables have keys "varName" that is used to access a variable. + * + *This class is a singleton + */ class Config { private: @@ -68,23 +85,56 @@ protected: public: - + /*Config is a singleton. + *It is accessed like this: + *Config::getInstance()->method2call(paramters); + */ static Config* getInstance(); + /*save() + *forces the config to be written to disk. This will also happened if the + *program terminates normally. + */ void save(); + /*getString(varName) + *Looks in the config file and returns the string that matches the key "varName" + *Returns an empty string if varName does not exist. + */ string getString(string varName); + /*getInt(varName) + *Looks in the config file and returns the int that matches the key "varName" + *Returns "0" if varName does not exist or cannot be parsed. + */ int getInt(string varName); + /*getValue(varName) + *Looks in the config file and returns the double that matches the key "varName" + *Returns "0.0" if varName does not exist or cannot be parsed. + */ double getValue(string varName); + /*setString(varName,content) + *Sets the config variable with key "varName" to the value of "content" + */ void setString(string varName,string content); + /*setInt(varName,content) + *Sets the config variable with key "varName" to the value of "content" + */ void setInt(string varName,int content); + /*setValue(varName,content) + *Sets the config variable with key "varName" to the value of "content" + */ void setValue(string varName,double content); + /*exists(varName) + *returns true if the key varName exists. This is used the first time 1.4.0 + *starts so that it can see that it has to import configs from an earlier + *version. + */ bool exists(string varName); }; diff --git a/source/code/main.cpp b/source/code/main.cpp index a5d57ee..05a5538 100644 --- a/source/code/main.cpp +++ b/source/code/main.cpp @@ -2023,6 +2023,10 @@ void OpenScoresDisplay() } else done = true; + + if ( event.key.keysym.sym == SDLK_F9 ) { + writeScreenShot(); + } if ( (event.key.keysym.sym == SDLK_RETURN)||(event.key.keysym.sym == SDLK_KP_ENTER) ) { done = true;