ehye_khandee wrote...
OK, as it is, we DO restart the server about twice a week when we update the module, we are still in late beta so it is necessary that we make fixes as we find issues (I'm sure you understand). Still our code is so stable, that if I did not have an update, it would run and run. I might be able to setup an experiment - I can run multiple modules on my server, and I could setup a test module with our scripts in it but fewer areas just for testing this issue. I could then let that instance of the module run until we had well exceeded that time limit to test your above outlined GetTicketCount()
Let me know if this might be interesting to you and if so we'll work out the details.
Fifty days seems like along time to run a server to experment with this. with my luck at the end of the fifty days I would discover I ran the wrong experment. If you do run an experement, I would suggest running two cut down servers, The first being just a shell on a single empty area. The second being the samething with a psydo heart beat script. refirring itself say every 4 hours or so. Just to see if it is still working after the ticket counts resets. I would also compair the ingame date after the fifty days to see if it rolled back with the ticket count or not. That is if either server is still running after the fifty days.
Ok, Im getting nitt picky on this one.
ehye_khandee wrote...
Mainly, each script being two resources, I like that my solution also uses two less resources overall.
It is only one extra resource. Include files never get compiled, they have to be included in a main script. With no .ncs file ever being made from them they will only be one resource. even if it did come tothe point where they where eating up to many resource, you could remove all of the .nss files to an external source. The module does not need any of the .nss files to run. You only need then to compile the .ncs files.
Next, I fired off a message to my favorite genius (Erin) last night, because my own personal brain could not recall the exact error we hit - I asked her if she recalled the error and if so what details she had, this is her reply:
ehye_khandee wrote...
Can't recall the exact error but it was based on Too many functions,
NWN Compiler takes Constants as well. So unlike a normal C/C++ compiler that will treat Constants as numbers given 'human' text for conveniance, NWN takes them as references to a list of constants that has a finite limit.
Its one of the big differences between NWN Scripting and C/C++. the later constants are simply replaced while compiling with the hard numbers.
I Can not dissagree with this at all. just keep in mind that the
list of constants or more like the
list of constants, functions, ints, strings, objects, floats and any other data type in your script are all added to the same list. Also this list is an intermediary step the compiler. That list is used in compiling the .ncs file. Every time a script is compiled the list is build then discarded once the .ncs is made. This happens on a script by script basis. Saying do not use constants because they wast resources, Is the same as saying dont use int's or functions because they waste resources in the same and greater ways. The only differance in NWN and C/C++ is that the constant in C/C++ do not get added to the temperary table during complation.
Out side of that they both compile as a literal constant.
I ran a couple of example To try and help you understand this. I started with a simple script. Then looked at the .ncs file that was compiled from it. Here is the first script with the binary .ncs that was produced.
//script test1
void main()
{
SpeakString ("test");
}
binary .ncs produced a 42 byte file.
4E 43 53 20 56 31 2E 30 42 00 00 00 2A 1E 00 00 00 00 08 20 00 04 03 00 00 00 00 04 05 00 04 74 65 73 74 05 00 00 DD 02 20 00
I then modified it to use a constant instead of a direct constant in the speak string.
//test2
const string TEST = "test";
void main()
{
SpeakString (TEST);
}
binary .ncs produced a 42 byte file.
4E 43 53 20 56 31 2E 30 42 00 00 00 2A 1E 00 00 00 00 08 20 00 04 03 00 00 00 00 04 05 00 04 74 65 73 74 05 00 00 DD 02 20 00
Hmm, Interesting, The compiled code is exaltly the same. It is as if I typed in the literal constant in place of my constant var.
I then added an extra constant that never gets used to the script. Lets see what happens.
//test3
const string TEST3 = "Frizzal Frazzle";
const string TEST = "test";
void main()
{
SpeakString (TEST);
}
binary .ncs produced a 42 byte file.
4E 43 53 20 56 31 2E 30 42 00 00 00 2A 1E 00 00 00 00 08 20 00 04 03 00 00 00 00 04 05 00 04 74 65 73 74 05 00 00 DD 02 20 00
Interesting, As far as the compiled script is concerned that constant never exsisted. It compiled to the same thing it would have if it was not there.
Ok, Lets change that unused string constant to a normal string and see what happens.
//test 4
string TEST4 = "Frizzal Frazzle";
const string TEST = "test";
void main()
{
SpeakString (TEST);
}
binary .ncs produced a 95 byte file.
4E 43 53 20 56 31 2E 30 42 00 00 00 5F 1E 00 00 00 00 08 20 00 02 05 04 05 00 0F 46 72 69 7A 7A 61 6C 20 46 72 61 7A 7A 6C 65 01 01 FF FF FF F8 00 04 1B 00 FF FF FF FC 2A 00 1E 00 00 00 00 10 2B 00 1B 00 FF FF FF FC 20 00 04 03 00 00 00 00 04 05 00 04 74 65 73 74 05 00 00 DD 02 20 00
Hmm, It seems that even though my code never uses it, It still gets added to my compiled code. Well I guess it is a varaiable no after all and need to be pushed onto the stack as a local var also.
Ok lets see what happens if I change the constant I am useing to a varaible.
//test 5
string TEST4 = "Frizzal Frazzle";
string TEST5 = "test";
void main()
{
SpeakString (TEST5);
}
binary .ncs produced a 119 byte file
4E 43 53 20 56 31 2E 30 42 00 00 00 5F 1E 00 00 00 00 08 20 00 02 05 04 05 00 0F 46 72 69 7A 7A 61 6C 20 46 72 61 7A 7A 6C 65 01 01 FF FF FF F8 00 04 1B 00 FF FF FF FC 2A 00 1E 00 00 00 00 10 2B 00 1B 00 FF FF FF FC 20 00 04 03 00 00 00 00 04 05 00 04 74 65 73 74 05 00 00 DD 02 20 00
EEKs, I just made my code even longer and created even another varaiable that is going to have to be pushed onto the stack.
As you can see the use of constants can make your code smaller when used to replace varaiables that are not going to change. I say "can" because it does not always make it smaller when you are useing strings or data types that are larger then a dword. But it does replace any use of your constant in the script with the literal constant it was defined as.
The only porblem ocures when you try and include too many constants/functions/varaiables into a single script. In that case you blow the mind of the compiler trying to keep track of them all. The nwn compiler just does not have enough room in the list to track them. Buut since the list is made and discarded every single a script is compiled. A constant included in one script does not effect any scripts, or anything else for that matter, that is is not included in.
This is why bioware has a lot of includes instead of just one large mega include that you could add to everything.
If you add constants to an include they will only get added into the code if the code uses them. If you add varaiables to an include, they will get added to the code even if the code has no use for them.
I hope this helps you see my point about constants.
As to taking your posts the wrong way, I dont think i have. I worrie more about people taking my posts the wrong way. I know you are only tring to be helpfull. I myself tend to ruffle feathers at times when tring to just help. There are many times I go back and read my posts, Then make the dicison to either post it, leave it or try and find a better way to say it. Other times I just shrug not being able to find a way to make it sound better and just post it anyway.
So I echo your request. Please dont take this the wrong way.
L8.