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 
 
Ram decoding vs hooking on nwn functions

 
Post new topic   Reply to topic    nwnx.org Forum Index -> Windows development
View previous topic :: View next topic  
Author Message
isilweo



Joined: 29 Dec 2004
Posts: 22
Location: poland

PostPosted: Wed Dec 29, 2004 0:33    Post subject: Ram decoding vs hooking on nwn functions Reply with quote

Hello
Can someone give me cons and pros of decoding structures in ram and hooking to nwn functions? These are often two ways of acomplishing same task.
In example we all now there's dm_modSTR function from dm's console, but there is no such function in nwscript. So you can try to find relation between player object in memory or try to hookup on dm_modSTR function. Wich way is better?
Back to top
View user's profile Send private message
Papillon
x-man


Joined: 28 Dec 2004
Posts: 1058
Location: Germany

PostPosted: Wed Dec 29, 2004 9:52    Post subject: Reply with quote

In this case I'd go for hooking the function. The reason beeing, you can update memory locations in the server (e.g. nwnx functions) but since a large part of this data is cached, changes aren't necessarily transmitted to the client.

On the other hand, it might not be easy to call an engine function with the right set of parameters from an nwnx module. Normally, we call a function from within nwscript and add something to it. In this case, you'd have to create a nwnx module that calls the engine function - that's the other way round. This is something that hasn't been tried yet, but should be at some point of time. Just try it, I might be able to help you if you get stuck.
_________________
Papillon
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Kokab
Guest





PostPosted: Mon Feb 23, 2015 11:10    Post subject: Reply with quote

Would it be possible to create an external (NWNX) function, that allows to send events (OnUserDefined) into the game?

Last edited by Kokab on Fri Mar 06, 2015 7:45; edited 2 times in total
Back to top
Baaleos



Joined: 02 Sep 2007
Posts: 816

PostPosted: Tue Feb 24, 2015 16:51    Post subject: Reply with quote

Firstly - I am not sure how your post relates to this topic - they don't seem to be the same topics?


Secondly - Yes:
You can create a method in nwnx which can then call functions within nwserver.
However- if you call these outside of the nwserver mainloop
Then you risk data contamination

Eg:
The mainloop thread is continuously moving data around,
If you try to arbitrarily invoke the onUserDefined method from an external thread - then the RunScript command could end up getting a random string as the argument etc


In order to do this properly
You need to hook the MainLoop
then have it setup in such a way that it can receive commands from another thread.
The way I do this is I create a collection - which is continuous checked in the mainloop
I can then populate this collection from an external thread, and then MainLoop just acts on the contents of the collection.
The collection contains instructions or messages which can then be parsed, to determine what script to run etc
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    nwnx.org Forum Index -> Windows 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