2010-03-14 01:49:19 +01:00
// ==============================================================
// This file is part of Glest (www.glest.org)
//
2010-03-27 23:22:33 +01:00
// Copyright (C) 2001-2008 Marti<74> o Figueroa
2010-03-14 01:49:19 +01:00
//
// You can redistribute this code and/or modify it under
// the terms of the GNU General Public License as published
// by the Free Software Foundation; either version 2 of the
// License, or (at your option) any later version
// ==============================================================
# include "game_util.h"
# include "util.h"
# include "lang.h"
# include "game_constants.h"
# include "config.h"
2010-03-22 00:40:35 +01:00
# include <stdlib.h>
# include "platform_util.h"
2010-04-30 04:20:27 +02:00
# include "conversion.h"
2010-03-14 01:49:19 +01:00
# include "leak_dumper.h"
using namespace Shared : : Util ;
2010-03-22 00:40:35 +01:00
using namespace Shared : : Platform ;
2010-03-14 01:49:19 +01:00
namespace Glest { namespace Game {
const string mailString = " contact_game@glest.org " ;
2010-04-18 08:01:20 +02:00
const string glestVersionString = " v3.3.5-dev " ;
2010-03-14 01:49:19 +01:00
string getCrashDumpFileName ( ) {
2010-04-30 03:32:37 +02:00
return " glest " + glestVersionString + " .dmp " ;
2010-03-14 01:49:19 +01:00
}
2010-04-30 03:32:37 +02:00
string getNetworkVersionString ( ) {
2010-04-30 04:20:27 +02:00
string version = glestVersionString + " built: " + string ( __DATE__ ) + " " + string ( __TIME__ ) ;
# if defined(WIN32) && defined(_MSC_VER)
2010-04-30 04:34:19 +02:00
version + = " Compiled using MSC_VER: " + intToStr ( _MSC_VER ) ;
2010-04-30 04:20:27 +02:00
# elif defined(__GNUC__)
# if defined(__GNUC__)
# if defined(__GNUC_PATCHLEVEL__)
# define __GNUC_VERSION__ (__GNUC__ * 10000 \
+ __GNUC_MINOR__ * 100 \
+ __GNUC_PATCHLEVEL__ )
# else
# define __GNUC_VERSION__ (__GNUC__ * 10000 \
+ __GNUC_MINOR__ * 100 )
# endif
# endif
2010-04-30 04:34:19 +02:00
version + = " Compiled using GNUC_VERSION: " + intToStr ( __GNUC_VERSION__ ) ;
2010-04-30 04:20:27 +02:00
# endif
return version ;
2010-04-30 03:32:37 +02:00
}
string getNetworkPlatformFreeVersionString ( ) {
return glestVersionString ;
2010-03-14 01:49:19 +01:00
}
string getAboutString1 ( int i ) {
switch ( i ) {
case 0 : return " Glest " + glestVersionString + " ( " + " Shared Library " + sharedLibVersionString + " ) " ;
case 1 : return " Built: " + string ( __DATE__ ) ;
2010-03-17 21:45:46 +01:00
case 2 : return " Copyright 2001-2010 The Glest Team " ;
2010-03-14 01:49:19 +01:00
}
return " " ;
}
string getAboutString2 ( int i ) {
switch ( i ) {
case 0 : return " Web: http://sourceforge.net/projects/megaglest http://glest.org " ;
case 1 : return " Mail: " + mailString ;
case 2 : return " Irc: irc://irc.freenode.net/glest " ;
}
return " " ;
}
string getTeammateName ( int i ) {
switch ( i ) {
2010-03-27 23:22:33 +01:00
case 0 : return " Marti<EFBFBD> o Figueroa " ;
case 1 : return " Jos<EFBFBD> Luis Gonz<6E> lez " ;
case 2 : return " Tucho Fern<72> ndez " ;
case 3 : return " Jos<EFBFBD> Zanni " ;
case 4 : return " F<EFBFBD> lix Men<65> ndez " ;
2010-03-14 01:49:19 +01:00
case 5 : return " Marcos Caruncho " ;
case 6 : return " Matthias Braun " ;
case 7 : return " Titus Tscharntke " ;
case 8 : return " Mark Vejvoda " ;
}
return " " ;
}
string getTeammateRole ( int i ) {
Lang & l = Lang : : getInstance ( ) ;
switch ( i ) {
case 0 : return l . get ( " Programming " ) ;
case 1 : return l . get ( " SoundAndMusic " ) ;
case 2 : return l . get ( " 3dAnd2dArt " ) ;
case 3 : return l . get ( " 2dArtAndWeb " ) ;
case 4 : return l . get ( " Animation " ) ;
case 5 : return l . get ( " 3dArt " ) ;
case 6 : return l . get ( " LinuxPort " ) ;
case 7 : return l . get ( " Megaglest3d2dProgramming " ) ;
case 8 : return l . get ( " MegaglestProgramming " ) ;
}
return " " ;
}
string formatString ( const string & str ) {
string outStr = str ;
if ( ! outStr . empty ( ) ) {
outStr [ 0 ] = toupper ( outStr [ 0 ] ) ;
}
bool afterSeparator = false ;
for ( int i = 0 ; i < str . size ( ) ; + + i ) {
if ( outStr [ i ] = = ' _ ' ) {
outStr [ i ] = ' ' ;
}
else if ( afterSeparator ) {
outStr [ i ] = toupper ( outStr [ i ] ) ;
afterSeparator = false ;
}
if ( outStr [ i ] = = ' \n ' | | outStr [ i ] = = ' ( ' | | outStr [ i ] = = ' ' ) {
afterSeparator = true ;
}
}
return outStr ;
}
2010-03-22 00:40:35 +01:00
string getGameReadWritePath ( ) {
string path = " " ;
if ( getenv ( " GLESTHOME " ) ! = NULL ) {
path = getenv ( " GLESTHOME " ) ;
if ( path ! = " " & & EndsWith ( path , " / " ) = = false & & EndsWith ( path , " \\ " ) = = false ) {
path + = " / " ;
}
SystemFlags : : OutputDebug ( SystemFlags : : debugSystem , " In [%s::%s Line: %d] path to be used for read/write files [%s] \n " , __FILE__ , __FUNCTION__ , __LINE__ , path . c_str ( ) ) ;
}
return path ;
}
2010-03-14 01:49:19 +01:00
} } //end namespace