Unitsync to Java binding

Unitsync to Java binding

Discuss the source code and development of Spring Engine in general from a technical point of view. Patches go here too.

Moderator: Moderators

Post Reply
User avatar
Petah
Posts: 426
Joined: 13 Jan 2008, 19:40

Unitsync to Java binding

Post by Petah »

Has anyone got a working up to date implementation unitsync to Java binding?

Or is there any information about how to do such a thing.

I did it a while ago, but I forgot how I did, and it is old and broken now.
User avatar
Petah
Posts: 426
Joined: 13 Jan 2008, 19:40

Re: Unitsync to Java binding

Post by Petah »

Sweet that works nice.

For anyone else who stumbles accross this thread and wants to know what I did:
User avatar
Petah
Posts: 426
Joined: 13 Jan 2008, 19:40

Re: Unitsync to Java binding

Post by Petah »

Nice one

Do you have any wrapper classes for Mods etc?

At the momemt I do:

Code: Select all

UnitsyncLibrary.GetPrimaryModName(i).getString(0)
Which works, but it would be nice to wrap these calls in a better interface.
User avatar
Cheesecan
Posts: 1571
Joined: 07 Feb 2005, 21:30

Re: Unitsync to Java binding

Post by Cheesecan »

https://github.com/jahwag/cheeselobby/t ... y/unitsync

There's a wrapper mostly written by hoijui, I added some things as well.

If you like you are welcome to create a github project for unitsync for java, and set up maven repo, that way we could develop a better wrapper in cooperation. Not many people use the java unitsync right now but maybe in the future who knows, could be useful to someone.
User avatar
Petah
Posts: 426
Joined: 13 Jan 2008, 19:40

Re: Unitsync to Java binding

Post by Petah »

Yea cool, I defintally post my results to Github if they are good enough.

Do you know how to read unit information from unitsync?
User avatar
Petah
Posts: 426
Joined: 13 Jan 2008, 19:40

Re: Unitsync to Java binding

Post by Petah »

I really cant figgure out how to get unit stats:

Ive tried a mixture of the following:

Code: Select all

    public static void main(String[] args) {
        UnitsyncLibrary.Init(false, 0);

        int modCount = UnitsyncLibrary.GetPrimaryModCount();
        System.err.println(UnitsyncLibrary.GetPrimaryModName(0).getString(0));
        System.err.println(UnitsyncLibrary.GetPrimaryModArchiveCount(0));
        System.err.println(UnitsyncLibrary.GetPrimaryModArchive(0).getString(0));
        System.err.println(UnitsyncLibrary.GetArchivePath("BA712.sdd").getString(0));
        int archiveID = UnitsyncLibrary.OpenArchive("D:\\Users\\David\\Documents\\My Games\\Spring\\mods\\BA712.sdd");
        System.err.println(archiveID);
        System.err.println(UnitsyncLibrary.GetUnitCount());
        System.err.println(UnitsyncLibrary.ProcessUnitsNoChecksum());
        UnitsyncLibrary.CloseArchive(archiveID);

        int modCount = UnitsyncLibrary.GetPrimaryModCount();
        for (int i = 0; i < modCount; i++) {
            Mod mod = new Mod();
            mod.setName(UnitsyncLibrary.GetPrimaryModName(i).getString(0));
            mod.setShortName(UnitsyncLibrary.GetPrimaryModShortName(i).getString(0));
            mod.setDescription(UnitsyncLibrary.GetPrimaryModDescription(i).getString(0));
            mod.setVersion(UnitsyncLibrary.GetPrimaryModVersion(i).getString(0));
            System.err.println(UnitsyncLibrary.GetUnitCount());
            System.err.println(UnitsyncLibrary.ProcessUnits());
            System.err.println(UnitsyncLibrary.GetFullUnitName(0));
            int archiveCount = UnitsyncLibrary.GetPrimaryModArchiveCount(i);
            for (int j = 0; j < archiveCount; j++) {
                Pointer archive = UnitsyncLibrary.GetPrimaryModArchive(j);
                System.out.println(archive.getString(0));
                break;
            }
            mods.add(mod);
        }
        UnitsyncLibrary.UnInit();

//        GUI.main(args);
    }
User avatar
hoijui
Former Engine Dev
Posts: 4344
Joined: 22 Sep 2007, 09:51

Re: Unitsync to Java binding

Post by hoijui »

i already have a much betteer wrapper locally. it has even OSGi support, which allows, next to other stuff, nice reloading of unityznc at runtime, which means you can load it from a different location. it also generates wrappers at comppiletime with maven plugins, and hides all JNA stuff from the interface.
it is quite as i wanted it, i just have to actualiye it for current master unitsznc.
i am not at home right now, will be soon though. just saying.. dont start somethign new ;-)
i will try to do that son, now that i know there is someone that could use it. will be online later.
User avatar
Petah
Posts: 426
Joined: 13 Jan 2008, 19:40

Re: Unitsync to Java binding

Post by Petah »

yay, are you online yet?
User avatar
hoijui
Former Engine Dev
Posts: 4344
Joined: 22 Sep 2007, 09:51

Re: Unitsync to Java binding

Post by hoijui »

woops! :D yes i am. get into #ai if you can, i am there if i am in the lobby.
User avatar
hoijui
Former Engine Dev
Posts: 4344
Joined: 22 Sep 2007, 09:51

Re: Unitsync to Java binding

Post by hoijui »

made it up-to-date now. will just have lunch and then do minor cleanup upload it to github.
User avatar
hoijui
Former Engine Dev
Posts: 4344
Joined: 22 Sep 2007, 09:51

Re: Unitsync to Java binding

Post by hoijui »

https://github.com/spring/JUnitSync

no real docu yet. i will upload a Pax-Exam test soon.
Most basic usage instructions:

You may specify the dir containing unitsync like this:
<code>System.setProperty("jna.library.path", unitsyncDir);</code>
or the path to unitsync like this:
<code>Preferences.userRoot().put("unitsync.path", unitsyncPath);</code>

Then start the bundle, and use either the "Unitsync" or "UnitsyncSimple" service (they only differ in one function, getInfoMapSize).

For further help, it may be best to meet me in the lobby.
User avatar
CarRepairer
Cursed Zero-K Developer
Posts: 3359
Joined: 07 Nov 2007, 21:48

Re: Unitsync to Java binding

Post by CarRepairer »

We had success getting this to work in windows but now I need help getting it to work in linux and mac, both failed. Could you guys hang out in lobbydev more? It's not just for meetings anymore!
User avatar
Cheesecan
Posts: 1571
Joined: 07 Feb 2005, 21:30

Re: Unitsync to Java binding

Post by Cheesecan »

See the cheeselobby unitsync code, it should work under linux(unless it broke, I haven't tested it under linux for months).
User avatar
CarRepairer
Cursed Zero-K Developer
Posts: 3359
Joined: 07 Nov 2007, 21:48

Re: Unitsync to Java binding

Post by CarRepairer »

det has been helping me. Turns out I was pointing to unitsync.dll when that's windows only. I will need to detect OS and let user fix OS if necessary, and base the filename on that.

Ironically, we have not gotten it to work right for him on linux but i managed to get it to work on a macbook. So we're close.
Post Reply

Return to “Engine”