misc/wrapper.c
author unc0rr
Thu, 17 Dec 2015 00:51:20 +0300
branchqmlfrontend
changeset 11464 30397f91571c
parent 4930 5d59bb58c365
permissions -rw-r--r--
Fix a ton of bugs in engine instances queue and ipc
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3495
a6b4f351d400 now engine can be optionally built as library, there's an example wrapper of how to use it
koda
parents:
diff changeset
     1
/*
a6b4f351d400 now engine can be optionally built as library, there's an example wrapper of how to use it
koda
parents:
diff changeset
     2
 This is an experimental main to use with hwLibary
a6b4f351d400 now engine can be optionally built as library, there's an example wrapper of how to use it
koda
parents:
diff changeset
     3
 - create the library with `cmake . -DBUILD_ENGINE_LIBRARY=1' and `make hwengine'
a6b4f351d400 now engine can be optionally built as library, there's an example wrapper of how to use it
koda
parents:
diff changeset
     4
 - compile this file with `gcc libhwLibrary.dylib libSDLmain.a wrapper.c -o wrapper -framework Cocoa -framework SDL'
a6b4f351d400 now engine can be optionally built as library, there's an example wrapper of how to use it
koda
parents:
diff changeset
     5
   (in Mac OS X, but this command line shouldn't be much different in other OSes; make sure to set the correct files/paths)
a6b4f351d400 now engine can be optionally built as library, there's an example wrapper of how to use it
koda
parents:
diff changeset
     6
 - this executable expect a save file "Save.hws" and the data folder "Data" to be in the same launching directory
a6b4f351d400 now engine can be optionally built as library, there's an example wrapper of how to use it
koda
parents:
diff changeset
     7
 */
a6b4f351d400 now engine can be optionally built as library, there's an example wrapper of how to use it
koda
parents:
diff changeset
     8
4930
5d59bb58c365 fix issue 185 :|
koda
parents: 4927
diff changeset
     9
#include <stdlib.h>
3495
a6b4f351d400 now engine can be optionally built as library, there's an example wrapper of how to use it
koda
parents:
diff changeset
    10
a6b4f351d400 now engine can be optionally built as library, there's an example wrapper of how to use it
koda
parents:
diff changeset
    11
extern void Game (const char **);
a6b4f351d400 now engine can be optionally built as library, there's an example wrapper of how to use it
koda
parents:
diff changeset
    12
4926
f9a13dd16f01 update lib wrapper.c so that it actually supplies all arguments required by current Game(), instead of causing a segfault ;D
sheepluva
parents: 3697
diff changeset
    13
int SDL_main (int argc, const char **argv)
f9a13dd16f01 update lib wrapper.c so that it actually supplies all arguments required by current Game(), instead of causing a segfault ;D
sheepluva
parents: 3697
diff changeset
    14
{
f9a13dd16f01 update lib wrapper.c so that it actually supplies all arguments required by current Game(), instead of causing a segfault ;D
sheepluva
parents: 3697
diff changeset
    15
    // Note: if you get a segfault or other unexpected crashes on startup
f9a13dd16f01 update lib wrapper.c so that it actually supplies all arguments required by current Game(), instead of causing a segfault ;D
sheepluva
parents: 3697
diff changeset
    16
    // make sure that these arguments are up-to-date with the ones actual needed
3697
d5b30d6373fc remove trailing spaces from end of line
koda
parents: 3495
diff changeset
    17
4926
f9a13dd16f01 update lib wrapper.c so that it actually supplies all arguments required by current Game(), instead of causing a segfault ;D
sheepluva
parents: 3697
diff changeset
    18
    const char **gameArgs = (const char**) malloc(sizeof(char *) * 11);
3697
d5b30d6373fc remove trailing spaces from end of line
koda
parents: 3495
diff changeset
    19
4926
f9a13dd16f01 update lib wrapper.c so that it actually supplies all arguments required by current Game(), instead of causing a segfault ;D
sheepluva
parents: 3697
diff changeset
    20
    gameArgs[ 0] = "0";          //ipcPort
f9a13dd16f01 update lib wrapper.c so that it actually supplies all arguments required by current Game(), instead of causing a segfault ;D
sheepluva
parents: 3697
diff changeset
    21
    gameArgs[ 1] = "1024";       //cScreenWidth
f9a13dd16f01 update lib wrapper.c so that it actually supplies all arguments required by current Game(), instead of causing a segfault ;D
sheepluva
parents: 3697
diff changeset
    22
    gameArgs[ 2] = "768";        //cScreenHeight
f9a13dd16f01 update lib wrapper.c so that it actually supplies all arguments required by current Game(), instead of causing a segfault ;D
sheepluva
parents: 3697
diff changeset
    23
    gameArgs[ 3] = "0";          //cReducedQuality
f9a13dd16f01 update lib wrapper.c so that it actually supplies all arguments required by current Game(), instead of causing a segfault ;D
sheepluva
parents: 3697
diff changeset
    24
    gameArgs[ 4] = "en.txt";     //cLocaleFName
f9a13dd16f01 update lib wrapper.c so that it actually supplies all arguments required by current Game(), instead of causing a segfault ;D
sheepluva
parents: 3697
diff changeset
    25
    gameArgs[ 5] = "wrapper";    //UserNick
f9a13dd16f01 update lib wrapper.c so that it actually supplies all arguments required by current Game(), instead of causing a segfault ;D
sheepluva
parents: 3697
diff changeset
    26
    gameArgs[ 6] = "1";          //isSoundEnabled
f9a13dd16f01 update lib wrapper.c so that it actually supplies all arguments required by current Game(), instead of causing a segfault ;D
sheepluva
parents: 3697
diff changeset
    27
    gameArgs[ 7] = "1";          //isMusicEnabled
f9a13dd16f01 update lib wrapper.c so that it actually supplies all arguments required by current Game(), instead of causing a segfault ;D
sheepluva
parents: 3697
diff changeset
    28
    gameArgs[ 8] = "1";          //cAltDamage
f9a13dd16f01 update lib wrapper.c so that it actually supplies all arguments required by current Game(), instead of causing a segfault ;D
sheepluva
parents: 3697
diff changeset
    29
    gameArgs[ 9] = "0.0";        //rotationQt
f9a13dd16f01 update lib wrapper.c so that it actually supplies all arguments required by current Game(), instead of causing a segfault ;D
sheepluva
parents: 3697
diff changeset
    30
    gameArgs[10] = "Save.hws";   //recordFileName
3697
d5b30d6373fc remove trailing spaces from end of line
koda
parents: 3495
diff changeset
    31
3495
a6b4f351d400 now engine can be optionally built as library, there's an example wrapper of how to use it
koda
parents:
diff changeset
    32
    Game(gameArgs);
a6b4f351d400 now engine can be optionally built as library, there's an example wrapper of how to use it
koda
parents:
diff changeset
    33
    free(gameArgs);
3697
d5b30d6373fc remove trailing spaces from end of line
koda
parents: 3495
diff changeset
    34
3495
a6b4f351d400 now engine can be optionally built as library, there's an example wrapper of how to use it
koda
parents:
diff changeset
    35
    return 0;
a6b4f351d400 now engine can be optionally built as library, there's an example wrapper of how to use it
koda
parents:
diff changeset
    36
}