View previous topic :: View next topic |
Author |
Message |
Zebranky
Joined: 04 Jun 2006 Posts: 415
|
Posted: Sat Feb 13, 2010 23:43 Post subject: |
|
|
When I test with the following script attached to OnModuleLoad:
Code: | void message();
void main()
{
DelayCommand(30.0, SendMessageToPC(GetFirstPC(), "DBG1"));
DelayCommand(30.0, message());
}
void message()
{
SendMessageToPC(GetFirstPC(), "DBG2");
} |
I get DBG2 followed by DBG1, both after 30 seconds. This seems like the expected behavior. Is this correct? _________________ Win32 SVN builds: http://www.mercuric.net/nwn/nwnx/
<Fluffy-Kooshy> NWNx plugin is to this as nuclear warheads are to getting rid of fire ants.
<ThriWork> whenever I hear nwn extender, I think what does NWN need a penis extender for? |
|
Back to top |
|
|
Fireboar
Joined: 17 Feb 2008 Posts: 323
|
Posted: Sun Feb 14, 2010 0:32 Post subject: |
|
|
Yep, my mistake, it's the other way around. Logically one might expect everything but the actual command inside the DelayCommand to be executed immediately, but they're not. Same reason can't use AssignCommand(..., ...OBJECT_SELF...).
the.gray.fox, I'm not sure what you're doing to make it not work, but for me, at least, delays OnModuleLoad work fine even using F9. |
|
Back to top |
|
|
Gryphyn
Joined: 20 Jan 2005 Posts: 431
|
Posted: Sun Feb 14, 2010 4:35 Post subject: |
|
|
NWScript uses a 'stack' when processing actions or commands.
This lead to some strange things right from day one. As what you thought was the first action in your script, was in fact the last one to be executed.
push - Delay(-DBG1
push - Delay(-message()
pop message() --Delay(30) @T
pop DBG1 --Delay(30) @T+
(30 later)
@T message()
@T+DBG1 |
|
Back to top |
|
|
the.gray.fox
Joined: 11 Dec 2009 Posts: 21
|
Posted: Sun Feb 14, 2010 18:53 Post subject: |
|
|
Fireboar wrote: | the.gray.fox, I'm not sure what you're doing to make it not work, but for me, at least, delays OnModuleLoad work fine even using F9. |
Hm. I do not know either.
I can not keep it simpler than make a one-line call at the head of OnModuleLoad::main(), compile, save, F9, and see that it does *not* delay.
Nothing will delay until the first player hits the entry area.
But out of F9 mode, all delays do work correctly.
-fox |
|
Back to top |
|
|
ShaDoOoW
Joined: 20 Aug 2005 Posts: 584
|
Posted: Fri Jul 02, 2010 18:02 Post subject: |
|
|
Would be possible to recognize in server script, that player uses NWCX ? _________________ Community Patch / NWNX Patch / NWNX Files / NWNX Connect |
|
Back to top |
|
|
Baaleos
Joined: 02 Sep 2007 Posts: 830
|
Posted: Sun Jul 04, 2010 3:34 Post subject: Yes and No |
|
|
Its possible in some ways.
I dont think that through nss it could be detected.
But UDP communication between client and server 'could' make it possible.
The Client Extender cannot actually affect anything in the Clients character while on the server, all the data and variables are stored server side, and the server side nss only really interacts with server side objects which are representive of the client himself.
In order to get the server to detect a client as having nwncx, it would require some sort of 'outside' of nwn communication method.
I believe I saw in another plugin somewhere, where it actually allowed udp communication and udp sockets to be set up on the fly more a less.
This sort of thing could be integrated into a detection system.
To detect the capabilities of the client etc.
Eg - Program nwnx (server) to send udp query to the clients ip address, on the port associated with nwncx, and if it gets reply, consider that player as having nwncx, if not, then dont.
(udp would be good, because it would be a broadcast, not requiring a tcp stable connection - meaning it wouldnt necessarily have to halt the nwnx server process.)
This sort of idea would have merit, if players are going to start having client extenders, which lets face it, grant even more accessibility and potential to modding, then it would make sense for the nwnx server to be able to detect what capabilities the client is able to experience.
Interaction, between nwnx and nwncx.
Since communications between clients and the server should only be for establishing client capabilities, it would be best if these communications were done once per player login, and then nss scripts wanting to use cx capabilities could conduct a simple check to see if the player was marked as having cx enabled. |
|
Back to top |
|
|
virusman
Joined: 30 Jan 2005 Posts: 1020 Location: Russia
|
Posted: Sun Jul 04, 2010 10:10 Post subject: |
|
|
I think it'd be better to hook the NWN protocol message handlers and add new message type for NWNCX communication. _________________ In Soviet Russia, NWN plays you! |
|
Back to top |
|
|
Skywing
Joined: 03 Jan 2008 Posts: 321
|
Posted: Sun Jul 04, 2010 10:22 Post subject: |
|
|
The way I handle this for the NWN2 Client Extension is to transmit an Input.RunScript request to the server to run a specific server-side script with parameters that identify the CE's version and capabilities (among other data). The server communicates back to the CE with a specially formatted ClientSideMessage.TextMessage style message.
This is particularly nice for NWN2 in that the handling of the CE can then be done entirely from NWScript on the server via a GUI script entrypoint and SendMessageToPC calls to communicate back to the CE.
My recommendation would be to try and create a similar communication channel for NWN1 that invokes a server-side script rather than hardcoding all of your extension functionality in C.
I've got nearly the entire game protocol mapped out for NWN2 at this point so I may be able to provide some assistance if requested. Much of the protocol maps to NWN1, although some portions are different (particularly with respect to GameObjUpdate handling).
I've also got a fair amount of logic for dealing with the underlying message formats (both the underlying UDP reliability/transport protocol and the high level game state protocol atop that), although you most likely will only want to speak the high level protocol. That code should be 100% compatible with NWN1. |
|
Back to top |
|
|
peachykeen
Joined: 13 Feb 2010 Posts: 15 Location: MD, US
|
Posted: Sun Jul 04, 2010 18:32 Post subject: |
|
|
virusman wrote: | I think it'd be better to hook the NWN protocol message handlers and add new message type for NWNCX communication. |
Isn't there a high-level message handler that forks messages out to the specific handlers? I remember seeing a function like that on the client...
I've been playing with getting into the script system, and I think what may be easier would be hooking into the client's whisper chat function. You can send simple data through that, and if you were to manipulate the length parameter, it might even be possible to send binary data. It's also simple, handled by NWN already, and tracked by most of the various message handling functions. I don't remember if it takes a char* or CExoString for data, but it would definitely be the most flexible and probably easiest and most stable way of handling this. No worries about protocol, either.
If you set NWNX up on the server to grab chat whispers starting with a special token, you can grab those and filter them out before they get relayed to other players (either pull them out of the queue or replace them with blanks, both seem to work for stopping a message). |
|
Back to top |
|
|
Skywing
Joined: 03 Jan 2008 Posts: 321
|
Posted: Sun Jul 04, 2010 20:58 Post subject: |
|
|
peachykeen wrote: | virusman wrote: | I think it'd be better to hook the NWN protocol message handlers and add new message type for NWNCX communication. |
Isn't there a high-level message handler that forks messages out to the specific handlers? I remember seeing a function like that on the client...
I've been playing with getting into the script system, and I think what may be easier would be hooking into the client's whisper chat function. You can send simple data through that, and if you were to manipulate the length parameter, it might even be possible to send binary data. It's also simple, handled by NWN already, and tracked by most of the various message handling functions. I don't remember if it takes a char* or CExoString for data, but it would definitely be the most flexible and probably easiest and most stable way of handling this. No worries about protocol, either.
If you set NWNX up on the server to grab chat whispers starting with a special token, you can grab those and filter them out before they get relayed to other players (either pull them out of the queue or replace them with blanks, both seem to work for stopping a message). |
Yes, there is a main message dispatcher function. The way the stock server and client (as well as my implementations for NWN2) operate is to to have a primary dispatcher which switches on the major function code of the message and dispatches it to sub-handlers. These then in turn switch on the minor function code and dispatch the message to its ultimate destination.
http://valera-ext.nynaeve.net/~skywing/nwn2/RecvMessage.cpp should give you an idea as to what you might see (N.B. This is all my implementation and not drawn from the stock server, but the stock server dispatches messages in a roughly similar fashion.).
I suspect the code will have not changed from NWN2, which means that you will probably want to look at CNWSMessage::HandlePlayerToServerMessage (and CNWCMessage::HandlerServerToPlayerMessage).
If you're defining new protocol message major or minor function codes, I'd like to ensure that they don't conflict with an of the new NWN2 messages -- which message numbers were you planning on using (if any)? |
|
Back to top |
|
|
peachykeen
Joined: 13 Feb 2010 Posts: 15 Location: MD, US
|
Posted: Tue Jul 06, 2010 1:34 Post subject: |
|
|
Skywing wrote: |
Yes, there is a main message dispatcher function. The way the stock server and client (as well as my implementations for NWN2) operate is to to have a primary dispatcher which switches on the major function code of the message and dispatches it to sub-handlers. These then in turn switch on the minor function code and dispatch the message to its ultimate destination.
http://valera-ext.nynaeve.net/~skywing/nwn2/RecvMessage.cpp should give you an idea as to what you might see (N.B. This is all my implementation and not drawn from the stock server, but the stock server dispatches messages in a roughly similar fashion.).
I suspect the code will have not changed from NWN2, which means that you will probably want to look at CNWSMessage::HandlePlayerToServerMessage (and CNWCMessage::HandlerServerToPlayerMessage).
If you're defining new protocol message major or minor function codes, I'd like to ensure that they don't conflict with an of the new NWN2 messages -- which message numbers were you planning on using (if any)? |
There seem to be a few ways to do that, then. For the script interface in NWShader, I used this code: (start at line ~260)
http://nwshader.svn.sourceforge.net/viewvc/nwshader/nwshader/src/hook/nwmain_tie.cpp?revision=35&view=markup
In the CNWCMessage class there seem to be all the necessary sub-handlers. By enabling custom handlers, I was able to reliably intercept the message when the engine tried to turn it into a CExoString.
I originally tried intercepting at the add to message queue function, with some help from virusman, but that always corrupted ESP, and I wasn't able to track down why. I shifted it to this function and it's a lot more flexible. Doing the same thing on the server-side (or using NWNX's functions) and just sending chat messages should work fine.
You can also enable/disable internal handlers based on other conditions. If the code receives a whisper or shout, if it starts with a given token... The incoming message can be handled or skipped. Being able to use an if and call the original code means next to no performance hit when none of the handlers are active.
My code is a hack compared to yours, though, but it works just fine.
And I wouldn't be defining anything new, just sending whispers with a special token prepended (all to-NWShader messages start with | and a plugin channel). |
|
Back to top |
|
|
Skywing
Joined: 03 Jan 2008 Posts: 321
|
Posted: Wed Jul 07, 2010 1:47 Post subject: |
|
|
My recommendation is to hook the main message dispatcher (i.e. HandleServerToPlayerMessage/HandlePlayerToServerMessage), parse the message out yourself, then decide whether to send it to its original handler or silently drop it at that point (or even decide to manufacture an entirely new message to loop back through the original message processor).
This gives you a single point to hook and is fully extensible to any other message handler. It's the approach I take in the Client Extension for NWN2 for a number of cases. By avoiding surgery in a number of code places in the game code, logic for extending message functionality can be made much cleaner/simpler to maintain (and less version specific, though this is obviously not a concern for NWN1 anymore).
If you drop by #nwn2cr on irc.nwn2source.net, I could provide more details and/or share some code if you are interested (nick Skywing). My message parsing/constructing logic will handle NWN1 messages just fine, you'll just need to tell it the layout of the individual messagse. Many of those are likely to be quite simpler to my notes for NWN2 outside of GameObjUpdate. |
|
Back to top |
|
|
peachykeen
Joined: 13 Feb 2010 Posts: 15 Location: MD, US
|
Posted: Fri Jul 09, 2010 5:34 Post subject: |
|
|
Skywing wrote: | My recommendation is to hook the main message dispatcher (i.e. HandleServerToPlayerMessage/HandlePlayerToServerMessage), parse the message out yourself, then decide whether to send it to its original handler or silently drop it at that point (or even decide to manufacture an entirely new message to loop back through the original message processor). |
The only issue with doing that at the moment is I don't have code (I'm not sure about virusman or other NWNX devs) to handle the CNWMessage and CNWCMessage classes. I know they're created to wrap CExoStrings (which my code for is sketchy, at best), but from what I've seen, both have the dispatchers in their virtual function table (or actual functions, don't remember ATM). I tried using some function calls and inline ASM to trigger the routines, but both segfaulted (the calls died immediately, the asm worked fine to add the message, but the game crashed when it tried to do the per-frame processing of the queue).
Quote: | If you drop by #nwn2cr on irc.nwn2source.net, I could provide more details and/or share some code if you are interested (nick Skywing). My message parsing/constructing logic will handle NWN1 messages just fine, you'll just need to tell it the layout of the individual messagse. Many of those are likely to be quite simpler to my notes for NWN2 outside of GameObjUpdate. |
I'll certainly stop in, probably lurk the channel for a few days. If you can provide any help in getting this to work, either for NWNCX or my implementation (though most of it could/would be shared), that'd be great. I haven't messed with that part of the code a whole lot yet. |
|
Back to top |
|
|
lordofworms
Joined: 23 Mar 2011 Posts: 5
|
Posted: Tue May 31, 2011 21:16 Post subject: |
|
|
Maybe a silly question but.....
using this system is it feasible to be able to build using all these updated plugins (nwncx) for single-player testing without messing up the original server nwnx2 dll files?
background: I run my server on a seperate machine then my build version. So I build,edit whatever on one machine then move mod to my other PC(server) and relaunch nwnx2 server...
if I am using different plugins for nwnx2....it doesnt affect the MOD itself does it? meaning I can cleanly and safely move the MOD edited with this nwnxc to my other pc running standard nwnx2?
sorry it might be obvious but I just want to know 'for sure' before I go messing things up on my own.
thank you! |
|
Back to top |
|
|
virusman
Joined: 30 Jan 2005 Posts: 1020 Location: Russia
|
Posted: Wed Jun 01, 2011 8:23 Post subject: |
|
|
lordofworms wrote: | Maybe a silly question but.....
using this system is it feasible to be able to build using all these updated plugins (nwncx) for single-player testing without messing up the original server nwnx2 dll files?
background: I run my server on a seperate machine then my build version. So I build,edit whatever on one machine then move mod to my other PC(server) and relaunch nwnx2 server...
if I am using different plugins for nwnx2....it doesnt affect the MOD itself does it? meaning I can cleanly and safely move the MOD edited with this nwnxc to my other pc running standard nwnx2?
sorry it might be obvious but I just want to know 'for sure' before I go messing things up on my own.
thank you! | Yes, the plugins are absolutely the same, NWNCX only uses a 'bridge' plugin to load NWNX plugins. The only modification that was made to the plugins is search address range, since nwmain.exe is larger than nwserver.exe. If you have plugin dlls compiled before 30.01.2010, update them with the dlls from the package. These dlls will work the same on server and client. _________________ In Soviet Russia, NWN plays you! |
|
Back to top |
|
|
|
|
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
|