diff options
author | Rogier Polak <rogier.l.a.polak@gmail.com> | 2007-03-18 13:54:40 +0000 |
---|---|---|
committer | Rogier Polak <rogier.l.a.polak@gmail.com> | 2007-03-18 13:54:40 +0000 |
commit | 1f1a5efaef0a10187592d29ea7b19e140e7a0196 (patch) | |
tree | 23c9fd117745d6387194e269b9182a9eaf65c3c7 /src | |
parent | 89468a178c60ef4e4d774708a3f6cf10b35f4b42 (diff) | |
download | mana-1f1a5efaef0a10187592d29ea7b19e140e7a0196.tar.gz mana-1f1a5efaef0a10187592d29ea7b19e140e7a0196.tar.bz2 mana-1f1a5efaef0a10187592d29ea7b19e140e7a0196.tar.xz mana-1f1a5efaef0a10187592d29ea7b19e140e7a0196.zip |
Added --version to the arguments, deleted the 'pink-code'.
Diffstat (limited to 'src')
-rw-r--r-- | src/main.cpp | 27 | ||||
-rw-r--r-- | src/resources/image.cpp | 72 |
2 files changed, 26 insertions, 73 deletions
diff --git a/src/main.cpp b/src/main.cpp index 3cc32873..40106c5c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -122,11 +122,13 @@ struct Options */ Options(): printHelp(false), + printVersion(false), skipUpdate(false), chooseDefault(false) {}; bool printHelp; + bool printVersion; bool skipUpdate; bool chooseDefault; std::string username; @@ -334,6 +336,7 @@ void printHelp() << "tmw" << std::endl << std::endl << "Options: " << std::endl << " -h --help : Display this help" << std::endl + << " -v --version : Display the version" << std::endl << " -u --skipupdate : Skip the update process" << std::endl << " -U --username : Login with this username" << std::endl << " -P --password : Login with this password" << std::endl @@ -343,12 +346,22 @@ void printHelp() << std::endl; } +void printVersion() +{ +#ifdef PACKAGE_VERSION + std::cout << "The Mana World version " << PACKAGE_VERSION << std::endl; +#else + std::cout << "The Mana World version " << + "(local build?, PACKAGE_VERSION is not defined)" << std::endl; +#endif +} void parseOptions(int argc, char *argv[], Options &options) { - const char *optstring = "huU:P:Dp:C:"; + const char *optstring = "hvuU:P:Dp:C:"; const struct option long_options[] = { { "help", no_argument, 0, 'h' }, + { "version", no_argument, 0, 'v' }, { "skipupdate", no_argument, 0, 'u' }, { "username", required_argument, 0, 'U' }, { "password", required_argument, 0, 'P' }, @@ -370,6 +383,9 @@ void parseOptions(int argc, char *argv[], Options &options) case 'h': options.printHelp = true; break; + case 'v': + options.printVersion = true; + break; case 'u': options.skipUpdate = true; break; @@ -503,9 +519,6 @@ void mapLogin(Network *network, LoginData *loginData) /** Main */ int main(int argc, char *argv[]) { -#ifdef PACKAGE_VERSION - std::cout << "The Mana World v" << PACKAGE_VERSION << std::endl; -#endif logger = new Logger(); Options options; @@ -517,7 +530,11 @@ int main(int argc, char *argv[]) printHelp(); return 0; } - + else if (options.printVersion) + { + printVersion(); + return 0; + } // Initialize libxml2 and check for potential ABI mismatches between // compiled version and the shared library actually used. xmlInitParser(); diff --git a/src/resources/image.cpp b/src/resources/image.cpp index 9398e06b..fed26851 100644 --- a/src/resources/image.cpp +++ b/src/resources/image.cpp @@ -99,66 +99,6 @@ Image* Image::load(void *buffer, unsigned int bufferSize, amask = 0xff000000; #endif - // Convert the image to a 32 bit software surface for processing - SDL_Surface *formatImage = SDL_CreateRGBSurface(SDL_SWSURFACE, 0, 0, 32, - rmask, gmask, bmask, amask); - - if (formatImage == NULL) { - logger->log("Error, image load failed: not enough memory"); - SDL_FreeSurface(tmpImage); - return NULL; - } - - SDL_Surface *image = SDL_ConvertSurface( - tmpImage, formatImage->format, SDL_SWSURFACE); - - SDL_FreeSurface(formatImage); - - if (image == NULL) { - logger->log("Error, image load failed: not enough memory"); - return NULL; - } - - bool hasPink = false; - bool hasAlpha = false; - int i; - Uint32 pink = SDL_MapRGB(image->format, 255, 0, 255); - - // Figure out whether the image has pink pixels - for (i = 0; i < image->w * image->h; ++i) - { - if (((Uint32*)image->pixels)[i] == pink) - { - hasPink = true; - break; - } - } - - // Figure out whether the image uses its alpha layer - for (i = 0; i < image->w * image->h; ++i) - { - Uint8 r, g, b, a; - SDL_GetRGBA( - ((Uint32*)image->pixels)[i], - image->format, - &r, &g, &b, &a); - - if (a != 255) - { - hasAlpha = true; - break; - } - } - - SDL_FreeSurface(image); - - if (hasPink && !hasAlpha) { - SDL_SetColorKey(tmpImage, SDL_SRCCOLORKEY, - SDL_MapRGB(tmpImage->format, 255, 0, 255)); - } else if (hasAlpha) { - SDL_SetAlpha(tmpImage, SDL_SRCALPHA, SDL_ALPHA_OPAQUE); - } - #ifdef USE_OPENGL if (mUseOpenGL) { @@ -246,14 +186,10 @@ Image* Image::load(void *buffer, unsigned int bufferSize, } #endif - // Set color key and alpha blending optins, and convert the surface to the - // current display format - if (hasAlpha) { - image = SDL_DisplayFormatAlpha(tmpImage); - } - else { - image = SDL_DisplayFormat(tmpImage); - } + SDL_SetAlpha(tmpImage, SDL_SRCALPHA, SDL_ALPHA_OPAQUE); + + SDL_Surface *image = SDL_DisplayFormatAlpha(tmpImage); + SDL_FreeSurface(tmpImage); if (image == NULL) { |