I've been working on a patch that gives the ability to view OTTD textfiles (readme, changelog and license) ingame
It's functional, but due to the OS specific code, it probably only works on my computer (debian unstable)
therefore, i enclose the patch(es) and ask you to give me some hints as to adding some more (working) OS specific code
Code: Select all
/**
* Get the location of the executable, e.g. openttd.exe
* @return the location of the executable, as a string.
*/
const char *GetExecutableLocation()
{
const char *path;
char buf[1024];
#if defined (WIN32) || defined (WIN64)
GetModuleFileName(path, &size);
#elif defined (__APPLE__)
_NSGetExecutablePath(path, &size);
#elif defined(UNIX)
if (readlink("/proc/self/exe", buf, sizeof(buf)) == -1) path = buf;
#elif defined(__FreeBSD__)
int mib[4];
mib[0] = CTL_KERN;
mib[1] = KERN_PROC;
mib[2] = KERN_PROC_PATHNAME;
mib[3] = -1;
sysctl(mib, 4, buf, sizeof(buf), NULL, 0);
path = buf;
#elif defined(SUNOS)
path = getexecname();
#endif
return path;
}