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 
 
Run nwnScript from outside game - Proof of Concept
Goto page Previous  1, 2, 3
 
Post new topic   Reply to topic    nwnx.org Forum Index -> Windows development
View previous topic :: View next topic  
Author Message
chaoslink



Joined: 23 Aug 2006
Posts: 37

PostPosted: Tue Aug 29, 2006 4:17    Post subject: Reply with quote

Failed how? Did you add mutex protection?
Back to top
View user's profile Send private message
Zebranky



Joined: 04 Jun 2006
Posts: 415

PostPosted: Tue Aug 29, 2006 19:01    Post subject: Reply with quote

I did. It still crashed at address 40b736. I think our crafting scripts may be too... resource-intensive... for it to handle, somehow.
Back to top
View user's profile Send private message Visit poster's website
XShocK



Joined: 24 Sep 2006
Posts: 8

PostPosted: Tue Sep 26, 2006 0:50    Post subject: Reply with quote

IF all that was is just a synchronization problem, then locking the criticalsection/mutex on the hook to the called function and unlocking on its end will do the job. If it still crashes... after several hours of work the first thing that comes to mind is that you did that criticalsection/mutex stuff wrong. Also check for memory leaks. One way to do that is using valgrind(if *nix), but that tends to be ridiculously slow and not many free alternatives in windoze. Another would be to hook the call to malloc/free(and their analogs). I cannot think of any other reason why program could segfault after several hours of work.

Again, memory leak will not be a source of the thing dieing on you, but if you can see it, then it may help you find the source of the problem.
Back to top
View user's profile Send private message
dumbo



Joined: 21 Aug 2005
Posts: 21

PostPosted: Tue Sep 26, 2006 7:49    Post subject: Reply with quote

ppl, this task can't be done without breaking/freezing nwserver thread in safe place(such as events loop). if you even lock code part with mutex/cs, data will be unsynchronized. amen.
Back to top
View user's profile Send private message
XShocK



Joined: 24 Sep 2006
Posts: 8

PostPosted: Tue Sep 26, 2006 8:12    Post subject: Reply with quote

I would agree with dumbo. To make sure there are no synchronization issues only pausing the thread can help. But why do you initially want to make such a thing anyway? You could simply synthesize the event yourself. Just make NPC speak, move it to the trap, do anything that would cause the event that fire the script. Not a very fancy way, but can be done in minutes without hacking around, plus quite efficient.
Back to top
View user's profile Send private message
Zebranky



Joined: 04 Jun 2006
Posts: 415

PostPosted: Mon Dec 25, 2006 21:11    Post subject: Reply with quote

dumbo wrote:
ppl, this task can't be done without breaking/freezing nwserver thread in safe place(such as events loop). if you even lock code part with mutex/cs, data will be unsynchronized. amen.

Yeah, this isn't a big surprise, but the trick is reverse-engineering the events loop.

XShocK wrote:
But why do you initially want to make such a thing anyway? You could simply synthesize the event yourself. Just make NPC speak, move it to the trap, do anything that would cause the event that fire the script. Not a very fancy way, but can be done in minutes without hacking around, plus quite efficient.

I'm not sure what you mean by synthesizing the event myself. The point of this is to cause something to execute completely based on an external event. This would allow us to avoid polling anything, such as the DB (for Autobic's ELC) or Vaultster. Additionally, it would open the door for causing events efficiently from a web interface: reloading the module, booting players, getting an up-to-date player list, querying a player's current status, and so on.
Back to top
View user's profile Send private message Visit poster's website
virusman



Joined: 30 Jan 2005
Posts: 1020
Location: Russia

PostPosted: Tue Mar 20, 2007 12:31    Post subject: Reply with quote

Zebranky wrote:
Yeah, this isn't a big surprise, but the trick is reverse-engineering the events loop.
NWN Events is hell. I seriously doubt that anyone would really want to work with them (hooking, inserting, etc.).
Zebranky wrote:
I'm not sure what you mean by synthesizing the event myself. The point of this is to cause something to execute completely based on an external event. This would allow us to avoid polling anything, such as the DB (for Autobic's ELC) or Vaultster. Additionally, it would open the door for causing events efficiently from a web interface: reloading the module, booting players, getting an up-to-date player list, querying a player's current status, and so on.
You can do this by:
1. Polling the DB on heartbeat (slow solution, but I use it for my web interface: 6-second delay doesn't matter in most cases);
2. Hooking any nwserver function that gets called frequently enough (maybe even the main nwserver loop) and making your own events queue based on NWNX plugin.
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger
Zebranky



Joined: 04 Jun 2006
Posts: 415

PostPosted: Tue Mar 27, 2007 3:28    Post subject: Reply with quote

Yeah, my new idea is to hook the main loop. I just have to get the time to sit down and write it...
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    nwnx.org Forum Index -> Windows development All times are GMT + 2 Hours
Goto page Previous  1, 2, 3
Page 3 of 3

 
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