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 
 
Possible Bug - Involves SQL, GetCalendarMonth/SetCalendar

 
Post new topic   Reply to topic    nwnx.org Forum Index -> Windows technical support
View previous topic :: View next topic  
Author Message
Baaleos



Joined: 02 Sep 2007
Posts: 830

PostPosted: Fri Nov 14, 2008 21:44    Post subject: Possible Bug - Involves SQL, GetCalendarMonth/SetCalendar Reply with quote

Ok, its hard to describe what is happening, so I will copy and paste a thread I posted earlier.

(In short - The resetPlugin is being fired, over and over, whenever a certain response is sent from my mySql db.

Specifically when the month number, of the monthfield is over 7.

1-7 works fine, but when it is at 8-12 it causes the server to continuously reset. The system is intended to be an event sort of system. Allowing me to scheduel events that would happen automatically on certain ingame dates. (Uses the time system inside the game, not the tim system in real life.)

-----------------------------------------

Me need your help Smile

I have implimented a persistent time keeping system in my server, not just for uptime, but a system to track the in-game months and years.

The idea is to allow myself to set certain events to happen on certain days, automatically.

However, I find that nwnx is using the reset!plugin everytime I attempt to set the ingame month to anything above 8. (I know you offer no support for this, however I would appreciate if you had any insight on it)

Please have a look at my code, and let me know if there is anything obviously wrong.


This is portion of my heartbeat script... deals with updating the ingame time
Code:


string iDay = IntToString(GetCalendarDay());
string iMonth= IntToString(GetCalendarMonth());
string iYear = IntToString(GetCalendarYear());
SQLExecDirect("UPDATE uptime SET UPTIME = '"+sUptime+"', gameday = '"+iDay+"', gamemonth ='"+iMonth+"', gameyear = '"+iYear+"'");


The next bit is the portion from my onModLoad script.

Code:

SQLExecDirect("SELECT gameday,gamemonth,gameyear from uptime");
if (SQLFetch() == SQL_SUCCESS) {
int iDay = StringToInt(SQLGetData(1));
int iMonth = StringToInt(SQLGetData(2));
int iYear = StringToInt(SQLGetData(3));

DelayCommand(5.00,SetCalendar(iYear,iMonth,iDay));
}


Note - Only just added the delaycommand, to see if it fixes it.

The issue is not that it resets when the time reaches 8th month, it resets when you are restarting the module, and it receives the 8th month from the database.

Result: Continuous resets, until I set the month field in the mySQL database to 7 or less.

The following is from the odbc logfile.
Code:

 Logfile maximum size limit is: 524288 bytes
o Log level: Everything will be logged.
o Using MySQL connection.
o Hooking SCO....hooked at 5d5830
o Hooking RCO....hooked at 5d5710
o Connect successful.
o Got request: SELECT UNIX_TIMESTAMP()
o Sent response (10 bytes): 1226690307
o Got request: SELECT gameday,gamemonth,gameyear from uptime
o Sent response (8 bytes): 591374


The game heartbeat, beats once, then closes the module.

Could this actually be a bug with nwnx2? Since it only happens when it is active, and nwnserver itself is incapable of closing itself down.

Below is an example logfile of what it looks like when working/
Code:

o Logfile maximum size limit is: 524288 bytes
o Log level: Everything will be logged.
o Using MySQL connection.
o Hooking SCO....hooked at 5d5830
o Hooking RCO....hooked at 5d5710
o Connect successful.
o Got request: SELECT UNIX_TIMESTAMP()
o Sent response (10 bytes): 1226690408
o Got request: SELECT gameday,gamemonth,gameyear from uptime
o Sent response (8 bytes): 571374
o Got request: SELECT UNIX_TIMESTAMP() - 1226690408
o Sent response (1 bytes): 8
o Got request: UPDATE uptime SET UPTIME = '8', gameday = '5', gamemonth ='7', gameyear = '1374'
o Got request: SELECT UNIX_TIMESTAMP() - 1226690408
o Sent response (2 bytes): 16
o Got request: UPDATE uptime SET UPTIME = '16', gameday = '5', gamemonth ='7', gameyear = '1374'
o Got request: SELECT UNIX_TIMESTAMP() - 1226690408
o Sent response (2 bytes): 24
Back to top
View user's profile Send private message
Asparius



Joined: 18 Sep 2007
Posts: 52

PostPosted: Fri Nov 14, 2008 23:24    Post subject: Reply with quote

I am no professional, though maybe this will help:


I can guess that in your module is a system that automatically resets server when gamemonth reaches 8 . Before you added date storing it would reset the server after about 1-2 days from start*, so there would be a reset once per 1-2 days**.
Resetting once per day is common, because server running for longer periods = laggy server.

Ok, try to do this:
Check if changing gamemonth - without any SQL queries - to 8 causes server to reset.. If so, check your heartbeat - there should be a call to some time checking and resetting when month >7 (or >= 8 ).

If it won't help:

- Turn on script logging.
- Check last script running before reset.

If this won't help also, try to change all reset plugin calls to log (including name of the script, for instance:
Code:

WriteTimestampedLogEntry ("Script: [i](script name here)[/i] calling reset plugin).


That should give you some clues to cause of the problem.
---
* - Assuming that in module properties starting time is 6 month 1 day
** - time depends on minute per hour setting in module properties it is (28*2*24*(minutes per hour)


PS. Sorry for my language problems - I am not native English speaker. Don't laugh Wink
Back to top
View user's profile Send private message
Baaleos



Joined: 02 Sep 2007
Posts: 830

PostPosted: Fri Nov 14, 2008 23:54    Post subject: actually Reply with quote

Actually...

There is a reset function, however, it is triggered by
delaycommand(295000,...blahblahblahresetfunction)); on the onmodload event.

The day, month, and year system I have does not touch the reset function at all.

Thats why it is a mystery.

It only seems to do this continuous reset, when the month is 8 or above.
Back to top
View user's profile Send private message
acaos



Joined: 08 May 2007
Posts: 153

PostPosted: Sat Nov 15, 2008 0:06    Post subject: Reply with quote

Changing the game clock with SetCalendar accelerates all DelayCommands. So if you delay something for 2 minutes real time and then advance the game clock 1 hour, that delay will happen immediately.

Acaos
Back to top
View user's profile Send private message
Baaleos



Joined: 02 Sep 2007
Posts: 830

PostPosted: Sat Nov 15, 2008 2:39    Post subject: Ahhh Reply with quote

Ahhh, so the remedy would be to do the delay command, after the Calendar is set.
Back to top
View user's profile Send private message
acaos



Joined: 08 May 2007
Posts: 153

PostPosted: Sat Nov 15, 2008 3:49    Post subject: Reply with quote

As long as you remember not to use SetCalendar again after doing DelayCommand, that would work fine.

On Higher Ground we keep a timestamp on the mod updated from SELECT UNIX_TIMESTAMP(); in MySQL in the mod heartbeat and use that to schedule events like this.

Acaos
Back to top
View user's profile Send private message
Disco



Joined: 06 Dec 2006
Posts: 152

PostPosted: Sat Nov 15, 2008 11:45    Post subject: Reply with quote

Take a look at the plugin Terra posted a while ago. It's got all kinds of handy time functions including a "seconds passed since starting the module" option, which is brilliant. Very handy to keep your delay stack sensible too.
Back to top
View user's profile Send private message
Baaleos



Joined: 02 Sep 2007
Posts: 830

PostPosted: Sat Nov 15, 2008 16:12    Post subject: Yeah me too Reply with quote

Yeah, I use the timestamp too for keeping track of uptime.

The SetCalendar only needs to be done at modload, to set the date to be whatever it was when the mod was turned off.

So this should solve it.
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 technical support 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