- proper binary path extraction on all platforms and glest.ini by default can run from search path and will try to find stuff it needs in the real binary path

- fixed error message for untis missing be_built
- fixed mg.ini for html tool and updated perl script
This commit is contained in:
Mark Vejvoda 2011-05-03 11:15:15 +00:00
parent 6d5cd99450
commit cd4ef0eaf7
9 changed files with 60 additions and 9 deletions

View File

@ -19,6 +19,7 @@ ColorBits=32
ConsoleMaxLines=7
ConsoleMaxLinesStored=20
ConsoleTimeout=20
DataPath=$APPLICATIONPATH/
DayTime=1000
DebugLogFile=debug.log
DebugMode=false

View File

@ -215,7 +215,7 @@ MainWindow::MainWindow( std::pair<string,vector<string> > unitToLoad,
startupSettingsInited(false)
{
this->appPath = appPath;
Properties::setApplicationPath(extractDirectoryPathFromFile(appPath));
Properties::setApplicationPath(executable_path(appPath));
Config &config = Config::getInstance();
//getGlPlatformExtensions();

View File

@ -86,7 +86,7 @@ namespace Glest{ namespace Game{
bool disableBacktrace = false;
bool gameInitialized = false;
static char *application_binary=NULL;
static string application_binary="";
static string mg_app_name = "";
static string mailStringSupport = "";
static bool sdl_quitCalled = false;
@ -296,7 +296,7 @@ public:
// prepare command to be executed
// our program need to be passed after the -e parameter
//sprintf (buf, "/usr/bin/addr2line -C -e ./a.out -f -i %lx", addr);
sprintf (buf, "addr2line -C -e %s -f -i %p",application_binary,address);
sprintf (buf, "addr2line -C -e %s -f -i %p",application_binary.c_str(),address);
FILE* f = popen (buf, "r");
@ -1982,7 +1982,7 @@ int glestMain(int argc, char** argv) {
bool foundInvalidArgs = false;
preCacheThread=NULL;
Properties::setApplicationPath(extractDirectoryPathFromFile(argv[0]));
Properties::setApplicationPath(executable_path(argv[0]));
ServerSocket::setMaxPlayerCount(GameConstants::maxPlayers);
SystemFlags::VERBOSE_MODE_ENABLED = false;
@ -2724,7 +2724,8 @@ int glestMainWrapper(int argc, char** argv) {
#ifdef WIN32_STACK_TRACE
__try {
#endif
application_binary=argv[0];
application_binary= executable_path(argv[0]);
//printf("\n\nargv0 [%s] application_binary [%s]\n\n",argv[0],application_binary.c_str());
#if defined(__GNUC__) && !defined(__MINGW32__) && !defined(__FreeBSD__) && !defined(BSD)
signal(SIGSEGV, handleSIGSEGV);

View File

@ -701,7 +701,7 @@ void UnitUpdater::updateBuild(Unit *unit, int frameIndex) {
builtUnit->create();
if(builtUnitType->hasSkillClass(scBeBuilt) == false) {
throw runtime_error("Unit " + builtUnitType->getName() + "has no be_built skill");
throw runtime_error("Unit [" + builtUnitType->getName() + "] has no be_built skill.");
}
builtUnit->setCurrSkill(scBeBuilt);

View File

@ -78,7 +78,7 @@ MainWindow::MainWindow(string appPath)
, program(NULL), boxsizer(NULL), startupSettingsInited(false) {
this->appPath = appPath;
Properties::setApplicationPath(extractDirectoryPathFromFile(appPath));
Properties::setApplicationPath(executable_path(appPath));
this->panel = new wxPanel(this, wxID_ANY);

View File

@ -209,6 +209,7 @@ inline string trim (const string & s, const string & t = SPACES) {
string getFullFileArchiveExtractCommand(string fileArchiveExtractCommand,
string fileArchiveExtractCommandParameters, string outputpath, string archivename);
bool executeShellCommand(string cmd,int expectedResult=IGNORE_CMD_RESULT_VALUE);
string executable_path(string exeName);
class ValueCheckerVault {

View File

@ -1678,6 +1678,53 @@ off_t getFileSize(string filename) {
return 0;
}
string executable_path(string exeName) {
string value = "";
#ifdef _WIN32
char path[MAX_PATH]="";
if( GetModuleFileName(NULL,path,MAX_PATH) == 0 ) {
value = extractDirectoryPathFromFile(exeName);
}
else {
value = extractDirectoryPathFromFile(path);
}
#elif __APPLE__
char path[MAXPATHLEN+1]="";
uint32_t path_len = MAXPATHLEN;
if ( _NSGetExecutablePath(path, &path_len) ) {
value = extractDirectoryPathFromFile(exeName);
}
else {
value = extractDirectoryPathFromFile(path);
}
#else
char exe_link_path[200]="";
int length = readlink("/proc/self/exe", exe_link_path, sizeof(exe_link_path));
if(length < 0 || length >= 200 ) {
char *argv0_path = realpath(exeName.c_str(),NULL);
if(argv0_path != NULL) {
value = extractDirectoryPathFromFile(argv0_path);
free(argv0_path);
argv0_path = NULL;
}
else {
const char *shell_path = getenv("_");
if(shell_path != NULL) {
value = extractDirectoryPathFromFile(shell_path);
}
else {
value = extractDirectoryPathFromFile(exeName);
}
}
}
else {
exe_link_path[length] = '\0';
value = extractDirectoryPathFromFile(exe_link_path);
}
#endif
return value;
}
// =====================================
// ModeInfo
// =====================================

View File

@ -118,6 +118,7 @@ use Cwd;
use File::Glob ':glob';
#use Image::Resize;
use Image::Magick;
BEGIN {
$ENV{APP_ROOT} = Cwd::realpath(File::Spec->rel2abs($FindBin::Bin)) ;
}

View File

@ -14,7 +14,7 @@ export_graph=as_svg;as_png;as_canon;as_text;as_cmapx
# combine png and cmapx to clickable map
build_clickable_map=1
version=Megapack of Megaglest 3.4.0
version=Megapack of Megaglest 3.5.1
# should links to units go the single pages for each unit (vs. the techtree-page if set to 0)
link_to_single_units=1
@ -32,7 +32,7 @@ level_armor=1.5
[files]
g3dviewer_path=../../../mk/linux/glest_g3dviewer
g3dviewer_path=../../../mk/linux/megaglest_g3dviewer
factions_path=../../../data/glest_game/techs/megapack/factions
resources_path=../../../data/glest_game/techs/megapack/resources