logo logo

 Back to main page

The NWNX Community Forum

 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
nwnx_jvm - native JVM integration
Goto page Previous  1, 2, 3, 4, 5, 6, 7, 8, 9  Next
 
Post new topic   Reply to topic    nwnx.org Forum Index -> Linux development
View previous topic :: View next topic  
Author Message
Zunath



Joined: 06 Jul 2006
Posts: 183

PostPosted: Tue Apr 07, 2015 15:29    Post subject: Reply with quote

Hey Elven,

For once, I don't have a question. Smile

I just wanted to pop in and say thank you again. I've been working on revamping our server's code - a lot of migrations, a lot of rewriting. NWNX_JVM has held up on everything.

The thing that's helped the most though, is being able to use an ORM (Hibernate). It made migrating all the local variables we were storing on PC items to the database much easier.

Once I get most of the code done, my next project will be to put the server in Azure and see how it plays. Eventually I want to hook the DB up to a web site for management purposes.

Anyway - just thought I'd thank you again. This has made developing in NWN so much easier and fun. Much appreciated!


Oh, and if you want to take a look at what I'm doing: https://github.com/zunath/Contagion_JVM/tree/master/src/contagionJVM
Back to top
View user's profile Send private message
elven



Joined: 28 Jul 2006
Posts: 259
Location: Germany

PostPosted: Tue Apr 07, 2015 15:35    Post subject: Reply with quote

I'm really glad people build cool stuff with it. Browsing that code, I can see you had/have lots of fun. :)

How is team development and remote debugging working out for you?

Edit: I see you're calling Scheduler.flushQueues() a lot in your individual event singletons. You should be able to remove all those calls and simply tack it onto SchedulerListener.event() with no side effects.
_________________
silm.pw, a player-driven Forgotten Realms NWN1 persistent world for tinkerers.
Back to top
View user's profile Send private message
Zunath



Joined: 06 Jul 2006
Posts: 183

PostPosted: Tue Apr 07, 2015 15:55    Post subject: Reply with quote

Well, right now I'm the only one doing any development so I'd say team dev is going well! Smile

I think when someone else wants to start coding I'll have to change some things around to make it easier - right now it's specifically set up for what I need to do.

Some of the events were direct copy-paste-fix from NWScript and I haven't gone back to clean them up. What's the deal with SchedulerListener.event() ? Does it flush the queue after the event is finished? I wasn't even aware of it!
Back to top
View user's profile Send private message
elven



Joined: 28 Jul 2006
Posts: 259
Location: Germany

PostPosted: Tue Apr 07, 2015 16:02    Post subject: Reply with quote

Zunath wrote:
Some of the events were direct copy-paste-fix from NWScript and I haven't gone back to clean them up. What's the deal with SchedulerListener.event() ? Does it flush the queue after the event is finished? I wasn't even aware of it!


There is no automatic flushing - the entire Scheduler.assign() queue is java-only.

But since event() is the only entry point into JVM code for now, you could just tack Scheduler.flushQueues() onto the end of that and get the same result as now. There is very little overhead for calling flushQueues() on events that don't schedule anything.

--

Another thing I noticed that you might want to think about is providing a custom Object handler in

https://github.com/zunath/Contagion_JVM/blob/master/src/contagionJVM/StartUp.java#L33

instead of using the default wrapper.

I saw that you are wrapping NWObject somewhere else in code (Items I think it was), and you could make your code cleaner by doing that with a custom NWObject impl instead. You could conceivably do whole object trees with that if you were feeling fancy, but that is a lot of cornercase work (I did that before and it wasn't fun).

Let me know if you want an example in Java and I'll type it up.
_________________
silm.pw, a player-driven Forgotten Realms NWN1 persistent world for tinkerers.
Back to top
View user's profile Send private message
Zunath



Joined: 06 Jul 2006
Posts: 183

PostPosted: Tue Apr 07, 2015 19:18    Post subject: Reply with quote

Good stuff - I'll make those adjustments tonight. I hadn't even considered flushing the queues in the entry point. D'oh! I'm pretty sure I was just happy to get it set up and working haha.

I'm wrapping items into ItemGO (Item Game Objects) and PCs into PlayerGO all over the place. If there's a cleaner way to handle that, I'd appreciate any guidance you can give. I think I follow your code but if you have time to write up an example that would help me out.
Back to top
View user's profile Send private message
elven



Joined: 28 Jul 2006
Posts: 259
Location: Germany

PostPosted: Wed Apr 08, 2015 17:52    Post subject: Reply with quote

Alrighty then.

As you can see here:

https://github.com/zunath/Contagion_JVM/blob/master/src/contagionJVM/StartUp.java#L33

Scheduler supports so-called object handlers. That's a fancy term for wrappers. For each object, itemproperty, or effect that crosses from NWScript to Java, this handler is called. The default handlers you copy/pasted simply return the default NWObject instance that is made in C.

However, you can return whatever you want from it as long as it subclasses NWOBject. A simple example would, for example, look like this:

Code:

NWObject.registerObjectHandler(new NWObject.ObjectHandler() {
   public NWObject handleObjectClass(NWObject obj, boolean valid,
         int objectType, String resRef, String tag) {

      if (objectType == OBJECT_TYPE_ITEM)
         return new Item(obj);
      else
         return obj;
   }
});


And then, the event handler would receive that object instead of the default NWObject instance. You could, for example, decorate the example Item class with custom methods. Checking if something is a item becomes as simple as
Code:
if (obj instanceof Item) { .. }
..

I apologise for the pseudocode but I think you get the picture.

The hard part is actually making a solid classification of objects; for example, as you will see, GetIsPC() isn't actually a good indicator if a given object ID is a PC.

Let me know if you have questions!
_________________
silm.pw, a player-driven Forgotten Realms NWN1 persistent world for tinkerers.
Back to top
View user's profile Send private message
Zunath



Joined: 06 Jul 2006
Posts: 183

PostPosted: Fri Apr 10, 2015 5:42    Post subject: Reply with quote

Got it. Thanks Elven - this helps a lot. Will let you know if I run into any snags.
Back to top
View user's profile Send private message
Zunath



Joined: 06 Jul 2006
Posts: 183

PostPosted: Tue Sep 22, 2015 0:57    Post subject: Reply with quote

Elven,

I pulled down the latest files from Jenkins and found an issue with the JVM plugin.

The default ResMan class has a method called "demand" but the plugin appears to be looking for a method called "demandRes".

I created a copy of the class, renaming the method to demandRes and my server no longer crashes at start up. I think all you need to do is rename demand to demandRes and it should be good.


- Z
Back to top
View user's profile Send private message
Zunath



Joined: 06 Jul 2006
Posts: 183

PostPosted: Fri Sep 25, 2015 1:13    Post subject: Reply with quote

Hey Elven,

Me again.

I'm getting a segmentation fault on server start up. I've narrowed it down to the JVM plugin - removing it from the directory corrects the problem.

Based on the stack trace it looks like there might be issues with StackPushFloat and StackPopInteger in FunctionHooks.cpp

Code:

Program terminated with signal SIGSEGV, Segmentation fault.
#0  0xb712c735 in StackPushFloat (value=-9.03844739e-06)
    at /var/lib/jenkins/jobs/nwnx2-linux/workspace/plugins/jvm/FunctionHooks.cpp:146
146   /var/lib/jenkins/jobs/nwnx2-linux/workspace/plugins/jvm/FunctionHooks.cpp: No such file or directory.
Traceback (most recent call last):
  File "/usr/share/gdb/auto-load/usr/lib/i386-linux-gnu/libstdc++.so.6.0.19-gdb.py", line 63, in <module>
    from libstdcxx.v6.printers import register_libstdcxx_printers
ImportError: No module named 'libstdcxx'
(gdb) bt
#0  0xb712c735 in StackPushFloat (value=-9.03844739e-06)
    at /var/lib/jenkins/jobs/nwnx2-linux/workspace/plugins/jvm/FunctionHooks.cpp:146
#1  0xb712c5ee in StackPopInteger (buf=0xbfa1b0ef)
    at /var/lib/jenkins/jobs/nwnx2-linux/workspace/plugins/jvm/FunctionHooks.cpp:101
#2  0xb717a3e4 in ?? () from ./nwnx_jvm.so
Backtrace stopped: previous frame inner to this frame (corrupt stack?)
(gdb)



I'm not sure where to begin to start correcting this - it's a little over my head. Would you mind taking a look when you get a chance? Let me know if there's anything I can do to help.
Back to top
View user's profile Send private message
elven



Joined: 28 Jul 2006
Posts: 259
Location: Germany

PostPosted: Sun Sep 27, 2015 9:54    Post subject: Reply with quote

Will check it out the coming week, traveling ATM. See if you can upload that core dump, that would help a lot. Also list nwnx2.so and all plugins and their versions/source revision of possible, or when you pulled them from Jenkins it that's the case.
_________________
silm.pw, a player-driven Forgotten Realms NWN1 persistent world for tinkerers.
Back to top
View user's profile Send private message
Zunath



Joined: 06 Jul 2006
Posts: 183

PostPosted: Mon Sep 28, 2015 15:17    Post subject: Reply with quote

Sure - I'll send you the dump and all of the version numbers tonight when I get off work.

Much appreciated and safe travels.
Back to top
View user's profile Send private message
-Seeker-



Joined: 13 Dec 2009
Posts: 3

PostPosted: Sun Nov 08, 2015 11:42    Post subject: Reply with quote

I get the same error, with the current version of nwnx_jvm. When I try to start the server, I get a segmentation fault. I am using the newest artifacts from Jenkins, of the following plugins: nwnx2, nwnx_odbc (nwnx_odmbc_mysql.so), nwnx_resman and nwnx_jvm. If I remove nwnx_jvm, i no longer get the error.

Link to core dump: https://dl.dropboxusercontent.com/u/21601438/core_segmentation_fault_nwn_jvm.zip
Back to top
View user's profile Send private message
elven



Joined: 28 Jul 2006
Posts: 259
Location: Germany

PostPosted: Sun Nov 08, 2015 13:35    Post subject: Reply with quote

There's a known issue with it. I figured a fix, I just didn't get around to properly test it before pushing it upstream. Please bear with me - hope to have this done by mid next week.
_________________
silm.pw, a player-driven Forgotten Realms NWN1 persistent world for tinkerers.
Back to top
View user's profile Send private message
-Seeker-



Joined: 13 Dec 2009
Posts: 3

PostPosted: Sun Nov 08, 2015 15:16    Post subject: Reply with quote

That sounds good! Thank you for looking into it.
Back to top
View user's profile Send private message
elven



Joined: 28 Jul 2006
Posts: 259
Location: Germany

PostPosted: Sun Nov 08, 2015 16:20    Post subject: Reply with quote

[outdated]
_________________
silm.pw, a player-driven Forgotten Realms NWN1 persistent world for tinkerers.


Last edited by elven on Tue Nov 10, 2015 16:41; edited 1 time in total
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    nwnx.org Forum Index -> Linux development All times are GMT + 2 Hours
Goto page Previous  1, 2, 3, 4, 5, 6, 7, 8, 9  Next
Page 5 of 9

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group