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

 
Post new topic   Reply to topic    nwnx.org Forum Index -> Development
View previous topic :: View next topic  
Author Message
Hialmar



Joined: 15 Jun 2005
Posts: 32

PostPosted: Sun May 29, 2011 18:21    Post subject: NWNX_JVM Reply with quote

I am working on a port of elven's JVM plugin described here:
http://www.nwnx.org/phpBB2/viewtopic.php?t=1478

It is currently available here:
http://alfavault.svn.sourceforge.net/viewvc/alfavault/nwnxjvm/

What doesn't work currently:
- SCORCO and ResMan ;
- most probably all the NWScript calls that got modified from NWN to NWN2 ;
- NWScript calls specific to NWN2.

Edit: if you don't want the source or anything like that just download what is found here:
http://alfavault.svn.sourceforge.net/viewvc/alfavault/nwnxjvm/example/
and the jar file here:
http://alfavault.svn.sourceforge.net/viewvc/alfavault/nwnxjvm/java_example/org.nwnx.nwnx2.jvm.jar?view=log
_________________
Hialmar, A Land Far Away Infrastructure Administrator
Back to top
View user's profile Send private message
Hialmar



Joined: 15 Jun 2005
Posts: 32

PostPosted: Tue May 31, 2011 22:17    Post subject: Reply with quote

It works with JRuby now Smile

What you can see on the following screenshot is several java windows created from the nwn2server.exe thanks to the jvm plugin. Moreover, the HTTP code that appears in the different windows and in the NWN2 console is generated from a ruby script called from java.

http://alandfaraway.org/Hialmar/nwnxjvm_jruby_socket_test.jpg

http://alandfaraway.org/Hialmar/jruby_test.rar
_________________
Hialmar, A Land Far Away Infrastructure Administrator
Back to top
View user's profile Send private message
elven



Joined: 28 Jul 2006
Posts: 259
Location: Germany

PostPosted: Wed Jun 01, 2011 11:21    Post subject: Reply with quote

Very cool.

I'll be interested to see what you come up with for it. :)
Back to top
View user's profile Send private message
elven



Joined: 28 Jul 2006
Posts: 259
Location: Germany

PostPosted: Thu Jun 02, 2011 16:08    Post subject: Reply with quote

For whats it worth, I have merged the jvm git repository into svn/branches/core-2.8.

Edit: Meant my own nwnx2 plugin, of course. Sorry.
Back to top
View user's profile Send private message
raetin



Joined: 11 Nov 2011
Posts: 2

PostPosted: Sat Nov 12, 2011 5:35    Post subject: Reply with quote

Hey there! I've picked up this project for use in a server (Gray Isles) -- we are going the JRuby route as well. I've made a few minor tweaks -- supporting some of the variable script calls and fixing a call that changed from nwn1 to nwn2.

https://github.com/grayisles/nwnx_jvm

Once things calm down a bit I will write up a compile guide and get things a bit better setup, so apologies for the bit of a mess it is at the moment.

If anyone would like to contribute, please drop me a line and I'll tidy it up.

Also, thanks to both of you for your on this. It is very much appreciated. Smile
Back to top
View user's profile Send private message
elven



Joined: 28 Jul 2006
Posts: 259
Location: Germany

PostPosted: Sat Nov 12, 2011 12:29    Post subject: Reply with quote

Hey,

cool stuff. Just a minor text moan: in your README.txt you say that the nwn1 plugin is hosted at git.swordcoast.net - that's not the case anymore. It's in svn for the core-2.8 branch nowadays and being built automagically by CI (There's doxygen & javadoc of the API as well).

Regards
Back to top
View user's profile Send private message
Hialmar



Joined: 15 Jun 2005
Posts: 32

PostPosted: Sat Nov 12, 2011 16:07    Post subject: Reply with quote

Glad someone is using this Smile

If you have some time you might want to add some code to free strings allocated by NWN2.

Here is what Skywing told me to do for this:
Skywing wrote:
Yes. This is based off of the code I use in the CE.

void * NWN2_Heap_Deallocate;

HMODULE hmod = GetModuleHandle( L"NWN2_MemoryMgr_amdxp" ); // server always uses _amdxp version

NWN2_Heap_Deallocate = GetProcAddress(
hmod,
"?Deallocate@NWN2_Heap@@SAXPAX@Z"
);

#define CLIEXT_DECLSPEC_NAKED __declspec(naked)

CLIEXT_DECLSPEC_NAKED
VOID
__cdecl
FreeNwn2(
__in PVOID P
)
/*++

Routine Description:

This routine releases memory to an NWN2 heap. This memory must have come
from an NWN2 heap allocator.

Arguments:

P - Supplies the address of an NWN2 heap allocation.

Return Value:

None.

Environment:

User mode.

--*/
{
UNREFERENCED_PARAMETER( P );

#ifdef _M_IX86
__asm
{
jmp dword ptr [NWN2_Heap_Deallocate]
}
#else
if (P != NULL)
HeapFree( GetProcessHeap( ), 0, P );
#endif
}


(You can ignore the non-x86 build stuff for this safely.)

Remember that it is the contents of the string, i.e. Str.m_sString, not the CExoString object itself, that must be freed this way if it's not NULL.

_________________
Hialmar, A Land Far Away Infrastructure Administrator
Back to top
View user's profile Send private message
raetin



Joined: 11 Nov 2011
Posts: 2

PostPosted: Mon Nov 14, 2011 17:59    Post subject: Reply with quote

Thanks for the info! I've updated the repo location and placed the fix provided in my list of TODOs.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    nwnx.org Forum Index -> Development All times are GMT + 2 Hours
Page 1 of 1

 
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