View previous topic :: View next topic |
Author |
Message |
isilweo
Joined: 29 Dec 2004 Posts: 22 Location: poland
|
Posted: Wed Dec 29, 2004 0:33 Post subject: Ram decoding vs hooking on nwn functions |
|
|
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 |
|
|
Papillon x-man
Joined: 28 Dec 2004 Posts: 1060 Location: Germany
|
Posted: Wed Dec 29, 2004 9:52 Post subject: |
|
|
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 |
|
|
Kokab Guest
|
Posted: Mon Feb 23, 2015 11:10 Post subject: |
|
|
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: 830
|
Posted: Tue Feb 24, 2015 16:51 Post subject: |
|
|
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 |
|
|
|