summaryrefslogtreecommitdiffstats
path: root/src/common
diff options
context:
space:
mode:
authorkrzys-h <krzys_h@interia.pl>2014-07-01 12:15:38 +0200
committerkrzys-h <krzys_h@interia.pl>2014-07-01 12:16:32 +0200
commitd9fee8b2adad613cf8c10d153cd5cd7b261b7863 (patch)
treef6b71cc2daa719c10c1ce31cf738e1c6ec934a73 /src/common
parent0f2adf05fd2b2b38c2b84aa8d72b3fd756dcfcd4 (diff)
parent1835d2ae580525603308206f7b8e6b4552b3ca0f (diff)
downloadcolobot-d9fee8b2adad613cf8c10d153cd5cd7b261b7863.tar.gz
colobot-d9fee8b2adad613cf8c10d153cd5cd7b261b7863.tar.bz2
colobot-d9fee8b2adad613cf8c10d153cd5cd7b261b7863.zip
Release 0.1.3-alpha
Diffstat (limited to 'src/common')
-rw-r--r--src/common/config.h.cmake2
-rw-r--r--src/common/event.cpp1
-rw-r--r--src/common/event.h1
-rw-r--r--src/common/global.h280
-rw-r--r--src/common/image.cpp41
-rw-r--r--src/common/image.h6
-rw-r--r--src/common/logger.cpp4
-rw-r--r--src/common/misc.cpp33
-rw-r--r--src/common/misc.h1
-rw-r--r--src/common/profile.cpp16
-rw-r--r--src/common/restext.cpp40
-rw-r--r--src/common/restext.h5
-rw-r--r--src/common/stringutils.cpp35
-rw-r--r--src/common/stringutils.h11
14 files changed, 266 insertions, 210 deletions
diff --git a/src/common/config.h.cmake b/src/common/config.h.cmake
index 63cd93b..98ccefe 100644
--- a/src/common/config.h.cmake
+++ b/src/common/config.h.cmake
@@ -3,6 +3,7 @@
// Macros set by CMake
#cmakedefine PLATFORM_WINDOWS @PLATFORM_WINDOWS@
#cmakedefine PLATFORM_LINUX @PLATFORM_LINUX@
+#cmakedefine PLATFORM_GNU @PLATFORM_GNU@
#cmakedefine PLATFORM_MACOSX @PLATFORM_MACOSX@
#cmakedefine PLATFORM_OTHER @PLATFORM_OTHER@
@@ -26,6 +27,7 @@
#define COLOBOT_VERSION "@COLOBOT_VERSION_FULL@"
#define COLOBOT_CODENAME "@COLOBOT_VERSION_CODENAME@"
#define COLOBOT_FULLNAME "Colobot @COLOBOT_VERSION_CODENAME@"
+#define COLOBOT_VERSION_DISPLAY "@COLOBOT_VERSION_DISPLAY@"
#define COLOBOT_DEFAULT_DATADIR "@COLOBOT_INSTALL_DATA_DIR@"
#define COLOBOT_I18N_DIR "@COLOBOT_INSTALL_I18N_DIR@"
diff --git a/src/common/event.cpp b/src/common/event.cpp
index 7acac77..9dc3943 100644
--- a/src/common/event.cpp
+++ b/src/common/event.cpp
@@ -161,7 +161,6 @@ void InitializeEventTypeTexts()
EVENT_TYPE_TEXT[EVENT_INTERFACE_DEFI] = "EVENT_INTERFACE_DEFI";
EVENT_TYPE_TEXT[EVENT_INTERFACE_MISSION] = "EVENT_INTERFACE_MISSION";
EVENT_TYPE_TEXT[EVENT_INTERFACE_FREE] = "EVENT_INTERFACE_FREE";
- EVENT_TYPE_TEXT[EVENT_INTERFACE_PROTO] = "EVENT_INTERFACE_PROTO";
EVENT_TYPE_TEXT[EVENT_INTERFACE_NAME] = "EVENT_INTERFACE_NAME";
EVENT_TYPE_TEXT[EVENT_INTERFACE_SETUP] = "EVENT_INTERFACE_SETUP";
EVENT_TYPE_TEXT[EVENT_INTERFACE_QUIT] = "EVENT_INTERFACE_QUIT";
diff --git a/src/common/event.h b/src/common/event.h
index 9405660..c5eb615 100644
--- a/src/common/event.h
+++ b/src/common/event.h
@@ -184,7 +184,6 @@ enum EventType
EVENT_INTERFACE_DEFI = 401,
EVENT_INTERFACE_MISSION = 402,
EVENT_INTERFACE_FREE = 403,
- EVENT_INTERFACE_PROTO = 404,
EVENT_INTERFACE_NAME = 405,
EVENT_INTERFACE_SETUP = 406,
EVENT_INTERFACE_QUIT = 407,
diff --git a/src/common/global.h b/src/common/global.h
index da62bac..4049bdc 100644
--- a/src/common/global.h
+++ b/src/common/global.h
@@ -28,137 +28,138 @@
*/
enum Error
{
- ERR_OK = 0, //! < ok
- ERR_GENERIC = 1, //! < any error
- ERR_CONTINUE = 2, //! < continues
- ERR_STOP = 3, //! < stops
- ERR_CMD = 4, //! < unknown command
- ERR_MANIP_VEH = 100, //! < inappropriate vehicle
- ERR_MANIP_FLY = 101, //! < impossible in flight
- ERR_MANIP_BUSY = 102, //! < taking: hands already occupied
- ERR_MANIP_NIL = 103, //! < taking: nothing has to take
- ERR_MANIP_MOTOR = 105, //! < busy: impossible to move
- ERR_MANIP_OCC = 106, //! < busy: location already occupied
- ERR_MANIP_FRIEND = 107, //! < no other vehicle
- ERR_MANIP_RADIO = 108, //! < impossible because radioactive
- ERR_MANIP_WATER = 109, //! < not possible under water
- ERR_MANIP_EMPTY = 110, //! < nothing to deposit
- ERR_BUILD_FLY = 120, //! < not possible in flight
- ERR_BUILD_WATER = 121, //! < not possible under water
- ERR_BUILD_ENERGY = 122, //! < not enough energy
- ERR_BUILD_METALAWAY = 123, //! < lack of metal (too far)
- ERR_BUILD_METALNEAR = 124, //! < lack of metal (too close)
- ERR_BUILD_METALINEX = 125, //! < lack of metal
- ERR_BUILD_FLAT = 126, //! < not enough flat ground
- ERR_BUILD_FLATLIT = 127, //! < not enough flat ground space
- ERR_BUILD_BUSY = 128, //! < location occupied
- ERR_BUILD_BASE = 129, //! < too close to the rocket
- ERR_BUILD_NARROW = 130, //! < buildings too close
- ERR_BUILD_MOTOR = 131, //! < built: not possible in movement
- ERR_BUILD_DISABLED = 132, //! < built: can not produce this object in this mission
- ERR_BUILD_RESEARCH = 133, //! < built: can not produce not researched object
- ERR_SEARCH_FLY = 140, //! < not possible in flight
- ERR_SEARCH_VEH = 141, //! < inappropriate vehicle
- ERR_SEARCH_MOTOR = 142, //! < impossible in movement
- ERR_TERRA_VEH = 150, //! < inappropriate vehicle
- ERR_TERRA_ENERGY = 151, //! < not enough energy
- ERR_TERRA_FLOOR = 152, //! < inappropriate ground
- ERR_TERRA_BUILDING = 153, //! < building too close
- ERR_TERRA_OBJECT = 154, //! < object too close
- ERR_FIRE_VEH = 160, //! < inappropriate vehicle
- ERR_FIRE_ENERGY = 161, //! < not enough energy
- ERR_FIRE_FLY = 162, //! < not possible in flight
- ERR_RECOVER_VEH = 170, //! < inappropriate vehicle
- ERR_RECOVER_ENERGY = 171, //! < not enough energy
- ERR_RECOVER_NULL = 172, //! < lack of ruin
- ERR_CONVERT_EMPTY = 180, //! < no stone was transformed
- ERR_SHIELD_VEH = 190, //! < inappropriate vehicle
- ERR_SHIELD_ENERGY = 191, //! < not enough energy
- ERR_MOVE_IMPOSSIBLE = 200, //! < move impossible
- ERR_FIND_IMPOSSIBLE = 201, //! < find impossible
- ERR_GOTO_IMPOSSIBLE = 210, //! < goto impossible
- ERR_GOTO_ITER = 211, //! < goto too complicated
- ERR_GOTO_BUSY = 212, //! < goto destination occupied
- ERR_DERRICK_NULL = 300, //! < no ore underground
- ERR_STATION_NULL = 301, //! < no energy underground
- ERR_TOWER_POWER = 310, //! < no battery
- ERR_TOWER_ENERGY = 311, //! < more energy
- ERR_RESEARCH_POWER = 320, //! < no battery
- ERR_RESEARCH_ENERGY = 321, //! < more energy
- ERR_RESEARCH_TYPE = 322, //! < the wrong type of battery
- ERR_RESEARCH_ALREADY = 323, //! < research already done
- ERR_ENERGY_NULL = 330, //! < no energy underground
- ERR_ENERGY_LOW = 331, //! < not enough energy
- ERR_ENERGY_EMPTY = 332, //! < lack of metal
- ERR_ENERGY_BAD = 333, //! < transforms only the metal
- ERR_BASE_DLOCK = 340, //! < doors locked
- ERR_BASE_DHUMAN = 341, //! < you must be on spaceship
- ERR_LABO_NULL = 350, //! < nothing to analyze
- ERR_LABO_BAD = 351, //! < analyzes only organic ball
- ERR_LABO_ALREADY = 352, //! < analysis already made
- ERR_NUCLEAR_NULL = 360, //! < no energy underground
- ERR_NUCLEAR_LOW = 361, //! < not enough energy
- ERR_NUCLEAR_EMPTY = 362, //! < lack of uranium
- ERR_NUCLEAR_BAD = 363, //! < transforms only uranium
- ERR_FACTORY_NULL = 370, //! < no metal
- ERR_FACTORY_NEAR = 371, //! < vehicle too close
- ERR_RESET_NEAR = 380, //! < vehicle too close
- ERR_INFO_NULL = 390, //! < no information terminal
- ERR_VEH_VIRUS = 400, //! < vehicle infected by a virus
- ERR_BAT_VIRUS = 401, //! < building infected by a virus
- ERR_DESTROY_NOTFOUND = 410, //! < not found anything to destroy
- ERR_WRONG_OBJ = 420, //! < inappropriate vehicle
- ERR_VEH_POWER = 500, //! < no battery
- ERR_VEH_ENERGY = 501, //! < more energy
- ERR_FLAG_FLY = 510, //! < impossible in flight
- ERR_FLAG_WATER = 511, //! < impossible during swimming
- ERR_FLAG_MOTOR = 512, //! < impossible in movement
- ERR_FLAG_BUSY = 513, //! < taking: already creating flag
- ERR_FLAG_CREATE = 514, //! < too many flags
- ERR_FLAG_PROXY = 515, //! < too close
- ERR_FLAG_DELETE = 516, //! < nothing to remove
- ERR_MISSION_NOTERM = 600, //! < Mission not completed
- ERR_DELETEMOBILE = 700, //! < vehicle destroyed
- ERR_DELETEBUILDING = 701, //! < building destroyed
- ERR_TOOMANY = 702, //! < too many objects
- ERR_OBLIGATORYTOKEN = 800, //! < compulsory instruction missing
- ERR_PROHIBITEDTOKEN = 801, //! < instruction prohibited
+ ERR_OK = 0, //! < ok
+ ERR_GENERIC = 1, //! < any error
+ ERR_CONTINUE = 2, //! < continues
+ ERR_STOP = 3, //! < stops
+ ERR_CMD = 4, //! < unknown command
+ ERR_MANIP_VEH = 100, //! < inappropriate vehicle
+ ERR_MANIP_FLY = 101, //! < impossible in flight
+ ERR_MANIP_BUSY = 102, //! < taking: hands already occupied
+ ERR_MANIP_NIL = 103, //! < taking: nothing has to take
+ ERR_MANIP_MOTOR = 105, //! < busy: impossible to move
+ ERR_MANIP_OCC = 106, //! < busy: location already occupied
+ ERR_MANIP_FRIEND = 107, //! < no other vehicle
+ ERR_MANIP_RADIO = 108, //! < impossible because radioactive
+ ERR_MANIP_WATER = 109, //! < not possible under water
+ ERR_MANIP_EMPTY = 110, //! < nothing to deposit
+ ERR_BUILD_FLY = 120, //! < not possible in flight
+ ERR_BUILD_WATER = 121, //! < not possible under water
+ ERR_BUILD_ENERGY = 122, //! < not enough energy
+ ERR_BUILD_METALAWAY = 123, //! < lack of metal (too far)
+ ERR_BUILD_METALNEAR = 124, //! < lack of metal (too close)
+ ERR_BUILD_METALINEX = 125, //! < lack of metal
+ ERR_BUILD_FLAT = 126, //! < not enough flat ground
+ ERR_BUILD_FLATLIT = 127, //! < not enough flat ground space
+ ERR_BUILD_BUSY = 128, //! < location occupied
+ ERR_BUILD_BASE = 129, //! < too close to the rocket
+ ERR_BUILD_NARROW = 130, //! < buildings too close
+ ERR_BUILD_MOTOR = 131, //! < built: not possible in movement
+ ERR_BUILD_DISABLED = 132, //! < built: can not produce this object in this mission
+ ERR_BUILD_RESEARCH = 133, //! < built: can not produce not researched object
+ ERR_SEARCH_FLY = 140, //! < not possible in flight
+ ERR_SEARCH_VEH = 141, //! < inappropriate vehicle
+ ERR_SEARCH_MOTOR = 142, //! < impossible in movement
+ ERR_TERRA_VEH = 150, //! < inappropriate vehicle
+ ERR_TERRA_ENERGY = 151, //! < not enough energy
+ ERR_TERRA_FLOOR = 152, //! < inappropriate ground
+ ERR_TERRA_BUILDING = 153, //! < building too close
+ ERR_TERRA_OBJECT = 154, //! < object too close
+ ERR_FIRE_VEH = 160, //! < inappropriate vehicle
+ ERR_FIRE_ENERGY = 161, //! < not enough energy
+ ERR_FIRE_FLY = 162, //! < not possible in flight
+ ERR_RECOVER_VEH = 170, //! < inappropriate vehicle
+ ERR_RECOVER_ENERGY = 171, //! < not enough energy
+ ERR_RECOVER_NULL = 172, //! < lack of ruin
+ ERR_CONVERT_EMPTY = 180, //! < no stone was transformed
+ ERR_SHIELD_VEH = 190, //! < inappropriate vehicle
+ ERR_SHIELD_ENERGY = 191, //! < not enough energy
+ ERR_MOVE_IMPOSSIBLE = 200, //! < move impossible
+ ERR_FIND_IMPOSSIBLE = 201, //! < find impossible
+ ERR_GOTO_IMPOSSIBLE = 210, //! < goto impossible
+ ERR_GOTO_ITER = 211, //! < goto too complicated
+ ERR_GOTO_BUSY = 212, //! < goto destination occupied
+ ERR_DERRICK_NULL = 300, //! < no ore underground
+ ERR_STATION_NULL = 301, //! < no energy underground
+ ERR_TOWER_POWER = 310, //! < no battery
+ ERR_TOWER_ENERGY = 311, //! < more energy
+ ERR_RESEARCH_POWER = 320, //! < no battery
+ ERR_RESEARCH_ENERGY = 321, //! < more energy
+ ERR_RESEARCH_TYPE = 322, //! < the wrong type of battery
+ ERR_RESEARCH_ALREADY = 323, //! < research already done
+ ERR_ENERGY_NULL = 330, //! < no energy underground
+ ERR_ENERGY_LOW = 331, //! < not enough energy
+ ERR_ENERGY_EMPTY = 332, //! < lack of metal
+ ERR_ENERGY_BAD = 333, //! < transforms only the metal
+ ERR_BASE_DLOCK = 340, //! < doors locked
+ ERR_BASE_DHUMAN = 341, //! < you must be on spaceship
+ ERR_LABO_NULL = 350, //! < nothing to analyze
+ ERR_LABO_BAD = 351, //! < analyzes only organic ball
+ ERR_LABO_ALREADY = 352, //! < analysis already made
+ ERR_NUCLEAR_NULL = 360, //! < no energy underground
+ ERR_NUCLEAR_LOW = 361, //! < not enough energy
+ ERR_NUCLEAR_EMPTY = 362, //! < lack of uranium
+ ERR_NUCLEAR_BAD = 363, //! < transforms only uranium
+ ERR_FACTORY_NULL = 370, //! < no metal
+ ERR_FACTORY_NEAR = 371, //! < vehicle too close
+ ERR_RESET_NEAR = 380, //! < vehicle too close
+ ERR_INFO_NULL = 390, //! < no information terminal
+ ERR_VEH_VIRUS = 400, //! < vehicle infected by a virus
+ ERR_BAT_VIRUS = 401, //! < building infected by a virus
+ ERR_DESTROY_NOTFOUND = 410, //! < not found anything to destroy
+ ERR_WRONG_OBJ = 420, //! < inappropriate vehicle
+ ERR_VEH_POWER = 500, //! < no battery
+ ERR_VEH_ENERGY = 501, //! < more energy
+ ERR_FLAG_FLY = 510, //! < impossible in flight
+ ERR_FLAG_WATER = 511, //! < impossible during swimming
+ ERR_FLAG_MOTOR = 512, //! < impossible in movement
+ ERR_FLAG_BUSY = 513, //! < taking: already creating flag
+ ERR_FLAG_CREATE = 514, //! < too many flags
+ ERR_FLAG_PROXY = 515, //! < too close
+ ERR_FLAG_DELETE = 516, //! < nothing to remove
+ ERR_MISSION_NOTERM = 600, //! < Mission not completed
+ ERR_DELETEMOBILE = 700, //! < vehicle destroyed
+ ERR_DELETEBUILDING = 701, //! < building destroyed
+ ERR_TOOMANY = 702, //! < too many objects
+ ERR_OBLIGATORYTOKEN = 800, //! < compulsory instruction missing
+ ERR_PROHIBITEDTOKEN = 801, //! < instruction prohibited
+ ERR_AIM_IMPOSSIBLE = 900, //! < cannot aim at specified angle(s)
- INFO_FIRST = 10000, //! < first information
- INFO_BUILD = 10001, //! < construction builded
- INFO_CONVERT = 10002, //! < metal available
- INFO_RESEARCH = 10003, //! < search ended
- INFO_FACTORY = 10004, //! < vehicle manufactured
- INFO_LABO = 10005, //! < analysis ended
- INFO_ENERGY = 10006, //! < battery available
- INFO_NUCLEAR = 10007, //! < nuclear battery available
- INFO_FINDING = 10008, //! < nuclear battery available
- INFO_MARKPOWER = 10020, //! < location for station found
- INFO_MARKURANIUM = 10021, //! < location for derrick found
- INFO_MARKSTONE = 10022, //! < location for derrick found
- INFO_MARKKEYa = 10023, //! < location for derrick found
- INFO_MARKKEYb = 10024, //! < location for derrick found
- INFO_MARKKEYc = 10025, //! < location for derrick found
- INFO_MARKKEYd = 10026, //! < location for derrick found
- INFO_RESEARCHTANK = 10030, //! < research ended
- INFO_RESEARCHFLY = 10031, //! < research ended
- INFO_RESEARCHTHUMP = 10032, //! < research ended
- INFO_RESEARCHCANON = 10033, //! < research ended
- INFO_RESEARCHTOWER = 10034, //! < research ended
- INFO_RESEARCHPHAZER = 10035, //! < research ended
- INFO_RESEARCHSHIELD = 10036, //! < research ended
- INFO_RESEARCHATOMIC = 10037, //! < research ended
- INFO_WIN = 10040, //! < win
- INFO_LOST = 10041, //! < lost
- INFO_LOSTq = 10042, //! < lost immediately
- INFO_WRITEOK = 10043, //! < record done
- INFO_DELETEPATH = 10050, //! < way mark deleted
- INFO_DELETEMOTHER = 10100, //! < insect killed
- INFO_DELETEANT = 10101, //! < insect killed
- INFO_DELETEBEE = 10102, //! < insect killed
- INFO_DELETEWORM = 10103, //! < insect killed
- INFO_DELETESPIDER = 10104, //! < insect killed
- INFO_BEGINSATCOM = 10105, //! < use your SatCom
+ INFO_FIRST = 10000, //! < first information
+ INFO_BUILD = 10001, //! < construction builded
+ INFO_CONVERT = 10002, //! < metal available
+ INFO_RESEARCH = 10003, //! < search ended
+ INFO_FACTORY = 10004, //! < vehicle manufactured
+ INFO_LABO = 10005, //! < analysis ended
+ INFO_ENERGY = 10006, //! < battery available
+ INFO_NUCLEAR = 10007, //! < nuclear battery available
+ INFO_FINDING = 10008, //! < nuclear battery available
+ INFO_MARKPOWER = 10020, //! < location for station found
+ INFO_MARKURANIUM = 10021, //! < location for derrick found
+ INFO_MARKSTONE = 10022, //! < location for derrick found
+ INFO_MARKKEYa = 10023, //! < location for derrick found
+ INFO_MARKKEYb = 10024, //! < location for derrick found
+ INFO_MARKKEYc = 10025, //! < location for derrick found
+ INFO_MARKKEYd = 10026, //! < location for derrick found
+ INFO_RESEARCHTANK = 10030, //! < research ended
+ INFO_RESEARCHFLY = 10031, //! < research ended
+ INFO_RESEARCHTHUMP = 10032, //! < research ended
+ INFO_RESEARCHCANON = 10033, //! < research ended
+ INFO_RESEARCHTOWER = 10034, //! < research ended
+ INFO_RESEARCHPHAZER = 10035, //! < research ended
+ INFO_RESEARCHSHIELD = 10036, //! < research ended
+ INFO_RESEARCHATOMIC = 10037, //! < research ended
+ INFO_WIN = 10040, //! < win
+ INFO_LOST = 10041, //! < lost
+ INFO_LOSTq = 10042, //! < lost immediately
+ INFO_WRITEOK = 10043, //! < record done
+ INFO_DELETEPATH = 10050, //! < way mark deleted
+ INFO_DELETEMOTHER = 10100, //! < insect killed
+ INFO_DELETEANT = 10101, //! < insect killed
+ INFO_DELETEBEE = 10102, //! < insect killed
+ INFO_DELETEWORM = 10103, //! < insect killed
+ INFO_DELETESPIDER = 10104, //! < insect killed
+ INFO_BEGINSATCOM = 10105, //! < use your SatCom
ERR_MAX //! < number of values
};
@@ -177,25 +178,6 @@ enum Language
LANGUAGE_RUSSIAN = 4
};
-/**
- * \enum DataDir
- * \brief Directories in data directory
- */
-enum DataDir
-{
- DIR_AI, //! < ai scripts
- DIR_FONT, //! < fonts
- DIR_HELP, //! < help files
- DIR_ICON, //! < icons & images
- DIR_LEVEL, //! < levels
- DIR_MODEL, //! < models
- DIR_MUSIC, //! < music
- DIR_SOUND, //! < sounds
- DIR_TEXTURE, //! < textures
-
- DIR_MAX //! < number of dirs
-};
-
/**
* \enum BuildType
diff --git a/src/common/image.cpp b/src/common/image.cpp
index 8a876e3..e3d1ef7 100644
--- a/src/common/image.cpp
+++ b/src/common/image.cpp
@@ -418,3 +418,44 @@ bool CImage::SavePNG(const std::string& fileName)
return true;
}
+void CImage::SetDataPixels(void *pixels){
+
+ Uint8* srcPixels = static_cast<Uint8*> (pixels);
+ Uint8* resultPixels = static_cast<Uint8*> (m_data->surface->pixels);
+
+ Uint32 pitch = m_data->surface->pitch;
+
+ for(int line = 0; line < m_data->surface->h; ++line) {
+ Uint32 pos = line * pitch;
+ memcpy(&resultPixels[pos], &srcPixels[pos], pitch);
+ }
+}
+
+void CImage::flipVertically(){
+
+ SDL_Surface* result = SDL_CreateRGBSurface( m_data->surface->flags,
+ m_data->surface->w,
+ m_data->surface->h,
+ m_data->surface->format->BytesPerPixel * 8,
+ m_data->surface->format->Rmask,
+ m_data->surface->format->Gmask,
+ m_data->surface->format->Bmask,
+ m_data->surface->format->Amask);
+
+ assert(result != nullptr);
+
+ Uint8* srcPixels = static_cast<Uint8*> (m_data->surface->pixels);
+ Uint8* resultPixels = static_cast<Uint8*> (result->pixels);
+
+ Uint32 pitch = m_data->surface->pitch;
+ Uint32 pxLength = pitch*m_data->surface->h;
+
+ for(int line = 0; line < m_data->surface->h; ++line) {
+ Uint32 pos = line * pitch;
+ memcpy(&resultPixels[pos], &srcPixels[(pxLength-pos)-pitch], pitch);
+ }
+
+ SDL_FreeSurface(m_data->surface);
+
+ m_data->surface = result;
+} \ No newline at end of file
diff --git a/src/common/image.h b/src/common/image.h
index 31dab2d..b93f2f9 100644
--- a/src/common/image.h
+++ b/src/common/image.h
@@ -109,6 +109,12 @@ public:
//! Returns the last error
std::string GetError();
+ //! Flips the image vertically
+ void flipVertically();
+
+ //! sets/replaces the pixels from the surface
+ void SetDataPixels(void *pixels);
+
private:
//! Blit to new RGBA surface with given size
void BlitToNewRGBASurface(int width, int height);
diff --git a/src/common/logger.cpp b/src/common/logger.cpp
index a02854d..7fc8fb0 100644
--- a/src/common/logger.cpp
+++ b/src/common/logger.cpp
@@ -26,7 +26,11 @@ template<> CLogger* CSingleton<CLogger>::m_instance = nullptr;
CLogger::CLogger()
{
m_file = NULL;
+ #if DEV_BUILD
+ m_logLevel = LOG_DEBUG;
+ #else
m_logLevel = LOG_INFO;
+ #endif
}
diff --git a/src/common/misc.cpp b/src/common/misc.cpp
index b96abca..92c3e9a 100644
--- a/src/common/misc.cpp
+++ b/src/common/misc.cpp
@@ -192,18 +192,6 @@ void TimeToAscii(time_t time, char *buffer)
year = when.tm_year+1900;
if ( year < 2000 ) year -= 1900;
else year -= 2000;
-/* TODO
-#if _FRENCH
- sprintf(buffer, "%.2d.%.2d.%.2d %.2d:%.2d",
- when.tm_mday, when.tm_mon+1, year,
- when.tm_hour, when.tm_min);
-#endif
-#if _GERMAN | _WG
- sprintf(buffer, "%.2d.%.2d.%.2d %.2d:%.2d",
- when.tm_mday, when.tm_mon+1, year,
- when.tm_hour, when.tm_min);
-#endif
-#if _ENGLISH*/
char format[10];
int hour;
@@ -222,12 +210,23 @@ void TimeToAscii(time_t time, char *buffer)
sprintf(buffer, "%.2d.%.2d.%.2d %.2d:%.2d %s",
when.tm_mon+1, when.tm_mday, year,
hour, when.tm_min, format);
-/*#endif
-#if _POLISH
- sprintf(buffer, "%.2d.%.2d.%.2d %.2d:%.2d",
- when.tm_mday, when.tm_mon+1, year,
+}
+
+// Converting time to string.
+
+void TimeToAsciiClean(time_t time, char *buffer)
+{
+ struct tm when;
+ int year;
+
+ when = *localtime(&time);
+ year = when.tm_year+1900;
+ if ( year < 2000 ) year -= 1900;
+ else year -= 2000;
+
+ sprintf(buffer, "%.2d%.2d%.2d%.2d%.2d",
+ year, when.tm_mon+1, when.tm_mday,
when.tm_hour, when.tm_min);
-#endif*/
}
// Copy a list of numbered files into the temporary folder.
diff --git a/src/common/misc.h b/src/common/misc.h
index bcebf76..3c147b1 100644
--- a/src/common/misc.h
+++ b/src/common/misc.h
@@ -28,6 +28,7 @@ extern char GetToUpper(char letter);
extern char GetToLower(char letter);
extern void TimeToAscii(time_t time, char *buffer);
+extern void TimeToAsciiClean(time_t time, char *buffer);
extern bool CopyFileListToTemp(char* filename, int* list, int total);
extern void AddExt(char* filename, const char* ext);
diff --git a/src/common/profile.cpp b/src/common/profile.cpp
index 77c70c3..ee3e873 100644
--- a/src/common/profile.cpp
+++ b/src/common/profile.cpp
@@ -91,7 +91,7 @@ bool CProfile::SetLocalProfileString(std::string section, std::string key, std::
}
catch (std::exception & e)
{
- GetLogger()->Error("Error on parsing profile: %s\n", e.what());
+ GetLogger()->Info("Error on parsing profile: %s\n", e.what());
return false;
}
return true;
@@ -106,7 +106,7 @@ bool CProfile::GetLocalProfileString(std::string section, std::string key, std::
}
catch (std::exception & e)
{
- GetLogger()->Error("Error on parsing profile: %s\n", e.what());
+ GetLogger()->Info("Error on parsing profile: %s\n", e.what());
return false;
}
return true;
@@ -122,7 +122,7 @@ bool CProfile::SetLocalProfileInt(std::string section, std::string key, int valu
}
catch (std::exception & e)
{
- GetLogger()->Error("Error on parsing profile: %s\n", e.what());
+ GetLogger()->Info("Error on parsing profile: %s\n", e.what());
return false;
}
return true;
@@ -137,7 +137,7 @@ bool CProfile::GetLocalProfileInt(std::string section, std::string key, int &val
}
catch (std::exception & e)
{
- GetLogger()->Error("Error on parsing profile: %s\n", e.what());
+ GetLogger()->Info("Error on parsing profile: %s\n", e.what());
return false;
}
return true;
@@ -153,7 +153,7 @@ bool CProfile::SetLocalProfileFloat(std::string section, std::string key, float
}
catch (std::exception & e)
{
- GetLogger()->Error("Error on parsing profile: %s\n", e.what());
+ GetLogger()->Info("Error on parsing profile: %s\n", e.what());
return false;
}
return true;
@@ -168,7 +168,7 @@ bool CProfile::GetLocalProfileFloat(std::string section, std::string key, float
}
catch (std::exception & e)
{
- GetLogger()->Error("Error on parsing profile: %s\n", e.what());
+ GetLogger()->Info("Error on parsing profile: %s\n", e.what());
return false;
}
return true;
@@ -178,7 +178,7 @@ bool CProfile::GetLocalProfileFloat(std::string section, std::string key, float
std::vector< std::string > CProfile::GetLocalProfileSection(std::string section, std::string key)
{
std::vector< std::string > ret_list;
- boost::regex re(key + "[0-9]*"); //we want to match all key followed my any number
+ boost::regex re(key + "[0-9]*"); //we want to match all key followed by any number
try
{
@@ -192,7 +192,7 @@ std::vector< std::string > CProfile::GetLocalProfileSection(std::string section,
}
catch (std::exception & e)
{
- GetLogger()->Error("Error on parsing profile: %s\n", e.what());
+ GetLogger()->Info("Error on parsing profile: %s\n", e.what());
}
return ret_list;
diff --git a/src/common/restext.cpp b/src/common/restext.cpp
index d61fa63..b63160d 100644
--- a/src/common/restext.cpp
+++ b/src/common/restext.cpp
@@ -56,14 +56,13 @@ void InitializeRestext()
stringsText[RT_KEY_OR] = " or ";
stringsText[RT_TITLE_BASE] = "COLOBOT";
- stringsText[RT_TITLE_INIT] = "COLOBOT";
+ stringsText[RT_TITLE_INIT] = "COLOBOT: Gold Edition";
stringsText[RT_TITLE_TRAINER] = "Programming exercises";
stringsText[RT_TITLE_DEFI] = "Challenges";
stringsText[RT_TITLE_MISSION] = "Missions";
stringsText[RT_TITLE_FREE] = "Free game";
stringsText[RT_TITLE_TEEN] = "Free game";
stringsText[RT_TITLE_USER] = "User levels";
- stringsText[RT_TITLE_PROTO] = "Prototypes";
stringsText[RT_TITLE_SETUP] = "Options";
stringsText[RT_TITLE_NAME] = "Player's name";
stringsText[RT_TITLE_PERSO] = "Customize your appearance";
@@ -75,14 +74,12 @@ void InitializeRestext()
stringsText[RT_PLAY_CHAPm] = " Planets:";
stringsText[RT_PLAY_CHAPf] = " Planets:";
stringsText[RT_PLAY_CHAPu] = " User levels:";
- stringsText[RT_PLAY_CHAPp] = " Planets:";
stringsText[RT_PLAY_CHAPte] = " Chapters:";
stringsText[RT_PLAY_LISTt] = " Exercises in the chapter:";
stringsText[RT_PLAY_LISTd] = " Challenges in the chapter:";
stringsText[RT_PLAY_LISTm] = " Missions on this planet:";
stringsText[RT_PLAY_LISTf] = " Free game on this planet:";
stringsText[RT_PLAY_LISTu] = " Missions on this level:";
- stringsText[RT_PLAY_LISTp] = " Prototypes on this planet:";
stringsText[RT_PLAY_LISTk] = " Free game on this chapter:";
stringsText[RT_PLAY_RESUME] = " Summary:";
@@ -155,8 +152,7 @@ void InitializeRestext()
stringsEvent[EVENT_INTERFACE_FREE] = "Free game\\Free game without a specific goal";
stringsEvent[EVENT_INTERFACE_TEEN] = "Free game\\Free game without a specific goal";
stringsEvent[EVENT_INTERFACE_USER] = "User\\User levels";
- stringsEvent[EVENT_INTERFACE_PROTO] = "Proto\\Prototypes under development";
- stringsEvent[EVENT_INTERFACE_NAME] = "New player\\Choose player's name";
+ stringsEvent[EVENT_INTERFACE_NAME] = "Change player\\Change player";
stringsEvent[EVENT_INTERFACE_SETUP] = "Options\\Preferences";
stringsEvent[EVENT_INTERFACE_AGAIN] = "Restart\\Restart the mission from the beginning";
stringsEvent[EVENT_INTERFACE_WRITE] = "Save\\Save the current mission ";
@@ -776,9 +772,7 @@ static KeyDesc keyTable[22] =
bool SearchKey(const char *cmd, InputSlot &key)
{
- int i;
-
- for ( i=0 ; i<22 ; i++ )
+ for (int i = 0; i < 22 ;i++)
{
if ( strstr(cmd, keyTable[i].name) == cmd )
{
@@ -791,14 +785,11 @@ bool SearchKey(const char *cmd, InputSlot &key)
// Replaces the commands "\key name;" in a text.
-static void PutKeyName(char* dst, const char* src)
+static void PutKeyName(std::string& dst, const char* src)
{
- InputSlot key;
- char name[50];
- int s, d, n;
- unsigned int res;
+ dst.clear();
- s = d = 0;
+ int s = 0;
while ( src[s] != 0 )
{
if ( src[s+0] == '\\' &&
@@ -807,18 +798,16 @@ static void PutKeyName(char* dst, const char* src)
src[s+3] == 'y' &&
src[s+4] == ' ' )
{
+ InputSlot key;
if ( SearchKey(src+s+5, key) )
{
- res = CRobotMain::GetInstancePointer()->GetInputBinding(key).primary;
+ unsigned int res = CRobotMain::GetInstancePointer()->GetInputBinding(key).primary;
if (res != KEY_INVALID)
{
- if ( GetResource(RES_KEY, res, name) )
+ std::string keyName;
+ if ( GetResource(RES_KEY, res, keyName) )
{
- n = 0;
- while ( name[n] != 0 )
- {
- dst[d++] = name[n++];
- }
+ dst.append(keyName);
while ( src[s++] != ';' );
continue;
}
@@ -826,9 +815,8 @@ static void PutKeyName(char* dst, const char* src)
}
}
- dst[d++] = src[s++];
+ dst.append(1, src[s++]);
}
- dst[d++] = 0;
}
// Returns the translated text of a resource that needs key substitution
@@ -905,13 +893,13 @@ static const char* GetResourceBase(ResType type, int num)
// Returns the text of a resource.
-bool GetResource(ResType type, int num, char* text)
+bool GetResource(ResType type, int num, std::string& text)
{
const char *tmpl = GetResourceBase(type, num);
if (!tmpl)
{
- text[0] = 0;
+ text.clear();
return false;
}
diff --git a/src/common/restext.h b/src/common/restext.h
index e4659e2..cde7203 100644
--- a/src/common/restext.h
+++ b/src/common/restext.h
@@ -66,7 +66,6 @@ enum ResTextType
RT_TITLE_DEFI = 43,
RT_TITLE_MISSION = 44,
RT_TITLE_FREE = 45,
- RT_TITLE_PROTO = 46,
RT_TITLE_SETUP = 47,
RT_TITLE_NAME = 48,
RT_TITLE_PERSO = 49,
@@ -79,12 +78,10 @@ enum ResTextType
RT_PLAY_CHAPd = 61,
RT_PLAY_CHAPm = 62,
RT_PLAY_CHAPf = 63,
- RT_PLAY_CHAPp = 64,
RT_PLAY_LISTt = 65,
RT_PLAY_LISTd = 66,
RT_PLAY_LISTm = 67,
RT_PLAY_LISTf = 68,
- RT_PLAY_LISTp = 69,
RT_PLAY_RESUME = 70,
RT_PLAY_CHAPu = 71,
RT_PLAY_LISTu = 72,
@@ -157,5 +154,5 @@ void InitializeRestext();
void SetGlobalGamerName(std::string name);
bool SearchKey(const char *cmd, InputSlot& slot);
-bool GetResource(ResType type, int num, char* text);
+bool GetResource(ResType type, int num, std::string& text);
diff --git a/src/common/stringutils.cpp b/src/common/stringutils.cpp
index 953abba..03a0f0b 100644
--- a/src/common/stringutils.cpp
+++ b/src/common/stringutils.cpp
@@ -17,6 +17,41 @@
#include "common/stringutils.h"
+#include <cstdarg>
+#include <cstdio>
+#include <vector>
+
+
+static std::string VFormat(const char *fmt, va_list ap)
+{
+ size_t size = 1024;
+ char stackbuf[1024];
+ std::vector<char> dynamicbuf;
+ char *buf = &stackbuf[0];
+
+ while (1)
+ {
+ int needed = vsnprintf (buf, size, fmt, ap);
+
+ if (needed <= static_cast<int>(size) && needed >= 0)
+ {
+ return std::string(buf, static_cast<size_t>(needed));
+ }
+
+ size = (needed > 0) ? (needed+1) : (size*2);
+ dynamicbuf.resize(size);
+ buf = &dynamicbuf[0];
+ }
+}
+
+std::string StrUtils::Format(const char *fmt, ...)
+{
+ va_list ap;
+ va_start(ap, fmt);
+ std::string buf = VFormat(fmt, ap);
+ va_end(ap);
+ return buf;
+}
std::string StrUtils::Replace(const std::string &str, const std::string &oldStr, const std::string &newStr)
{
diff --git a/src/common/stringutils.h b/src/common/stringutils.h
index c60bfb0..e80163a 100644
--- a/src/common/stringutils.h
+++ b/src/common/stringutils.h
@@ -31,11 +31,11 @@ namespace StrUtils {
/** If given, \a ok is set to true/false on success/failure.
Warning: To avoid unnecessary problems, *always* give full template qualifier e.g. ToString\<int\> */
template<class T>
-std::string ToString(T value, bool *ok = NULL)
+std::string ToString(T value, bool *ok = nullptr)
{
std::ostringstream s;
s << value;
- if (ok != NULL)
+ if (ok != nullptr)
*ok = !s.fail();
return s.str();
}
@@ -44,17 +44,20 @@ std::string ToString(T value, bool *ok = NULL)
/** If given, \a ok is set to true/false on success/failure.
Warning: To avoid unnecessary problems, *always* give full template qualifier e.g. FromString\<int\> */
template<class T>
-T FromString(const std::string &str, bool *ok = NULL)
+T FromString(const std::string &str, bool *ok = nullptr)
{
std::istringstream s;
s.str(str);
T value;
s >> value;
- if (ok != NULL)
+ if (ok != nullptr)
*ok = !s.fail();
return value;
}
+//! Replacement for sprintf()
+std::string Format(const char *fmt, ...);
+
//! Returns a string with every occurence of \a oldStr in \a str replaced to \a newStr
std::string Replace(const std::string &str, const std::string &oldStr, const std::string &newStr);