Game Development Community

T2D, Linux and BinReloc

by James Reeves · in Torque Game Builder · 03/28/2005 (5:23 am) · 3 replies

Currently, with T2D under Linux, you have to open up a console window, CD to the directory your T2D game is, then type in something like "./T2D.bin". In Windows you can just click on T2D.exe. What would be useful is if you could have this same functionality in Linux.

I found an interesting public domain library called BinReloc which should help with this problem. In theory, all one has to do is copy prefix.c and prefix.h to the source directories, and then you get a set of global variables and macros that give you information about the current directory your program is running in.

I suspect a quick hack would look something like:

#include <unistd.h>;
#include "prefix.h";
...

int main(int argc, const char** argv) {
   chdir(SELFPATH);
   ...
}

Once I get my head around how the platform-specific code is integrated into T2D, I'll see if I can make this work.

About the author

Recent Threads

  • Spaceship physics

  • #1
    03/28/2005 (11:52 am)
    Sure, that's one way to do it.

    Alternatively, just use the runtorque.sh script [remember to convert the $* to "$@" with the quotes] to start it, and it correctly prefixes the full path onto argv[0].

    Gary (-;
    #2
    03/28/2005 (12:10 pm)
    Well, sure, if you want to do it the easy way :)

    Seriously though, it might be nice if the binary worked straight off without shellscripts. Just click it and it runs. It shouldn't be too hard to do, so I'll give it a go.
    #3
    03/28/2005 (1:24 pm)
    Basically, you can try, but it turns out that it's non-trivial to do in general.

    Your best bet, *especially* with Torque, is to just use that script, garaunteeing that argv[0] is prefixed with something acceptable, and rely on the torque resource manager to do everything else correctly.

    Note that every Loki game, every LGP game, every ID or Epic game for linux, uses this method [basically, everyone's still using the same FindPath script function that Sam Latinga wrote many many years ago].

    You can try changing how it works, but you'd be surprised how hard it is to do this accurately. Don't forget symlinks and hard links [although if you manage this with hard links, let me know how :-)].

    Gary (-;