View previous topic :: View next topic |
Author |
Message |
Baaleos
Joined: 02 Sep 2007 Posts: 830
|
Posted: Wed Mar 30, 2016 16:26 Post subject: Strange ODBC issue - Is it Asynchronous? |
|
|
Code: |
int GetTimeStamp(){
string sQuery = "SELECT UNIX_TIMESTAMP();";
SQLExecDirect(sQuery);
if (SQLFetch() == SQL_SUCCESS){
return StringToInt(SQLGetData(1));
}
return 0;
}
|
Quote: |
NWNX2 ODBC2 version 1.0.1 for Linux.
(c) 2005-2006 dumbo (dumbo@nm.ru)
(c) 2006-2010 virusman (virusman@virusman.ru)
MySQL engine is supported
Plugin link: F77464C0
Plugin link: F77464C0
o SCO located at 82d9c44.
o RCO located at 82d9b60.
o Connecting to 127.0.0.1, default port
o Connect successful.
o Got request: SELECT UNIX_TIMESTAMP();
o Got request: SELECT UNIX_TIMESTAMP();
o Got request: SELECT UNIX_TIMESTAMP();
o Sent result: 1459347065
o Shutdown.
|
How can 3 calls to GetTimeStamp() be returning just a single result?
Surely its synchronous?
Quote: |
NWN Extender v2.8-dev
--------------------------------
SPELLS plugin registered.
STRUCTS plugin registered.
DEFENSES plugin registered.
RESET plugin registered.
DMACTIONS plugin registered.
TWEAKS plugin registered.
FUNCS plugin registered.
RESMAN: Supports the new plugin interface
RESMAN plugin registered.
VISIBILITY plugin registered.
SERVERLIST plugin registered.
WEAPONS plugin registered.
FUNCSEXT plugin registered.
TMI plugin registered.
FIXES plugin registered.
SYSTEM plugin registered.
ODBC: Supports the new plugin interface
ODBC plugin registered.
HAKS plugin registered.
CHAT plugin registered.
EVENTS plugin registered.
EXTEND plugin registered.
AREAS plugin registered.
HASHSET plugin registered.
JVM: Supports the new plugin interface
JVM plugin registered.
FUNCTIONS plugin registered.
NAMES plugin registered.
* NWNX2 activated.
INIT(S): valid ret=0x082041ec
INIT(O): valid ret=0x08203e79
|
Another symptom I have noticed is that the pseudo loop that this GetTimeStamp call is within, seems to get broken.
Eg:
Code: |
void GenomeHeartbeat(){
int iTime = GetTimeStamp();
WriteTimestampedLogEntry("Starting HB");
object oPC = GetFirstPC();
int TimeOfDayCurrent = GetCurrentTime();
while(oPC != OBJECT_INVALID){
//Do stuff here to the players
int IsInHuman = GetIsInhuman(oPC);
if(IsInHuman){
//WriteTimestampedLogEntry("Inhuman Heartbeat on "+GetName(oPC));
HeartbeatProcessGenome(oPC,TimeOfDayCurrent);
}
oPC = GetNextPC();
}
int iSimulatedPCCount = GetLocalInt(oStorer,CREATURES_AS_SIMULATED_PC_COUNT);
int iNPC = 0;
for(iNPC=1;iNPC<=iSimulatedPCCount;iNPC++){
object oNPC = GetLocalObject(oStorer,SIMULATED_PC+IntToString(iNPC));
if(oNPC != OBJECT_INVALID){
HeartbeatProcessGenome(oNPC,TimeOfDayCurrent);
}
}
int iNewTime = GetTimeStamp();
int iTotal = iNewTime - iTime;
WriteTimestampedLogEntry("Server Genome Processing took "+IntToString(iTotal)+" seconds");
DelayCommand(7.00,ExecuteScript("inhuman_hbeat",OBJECT_SELF)); // 7 Seconds
}
|
In the server log, I see a single entry for 'Starting HB'
But it never gets as far as
WriteTimestampedLogEntry("Server Genome Processing took "+IntToString(iTotal)+" seconds"); |
|
Back to top |
|
|
Baaleos
Joined: 02 Sep 2007 Posts: 830
|
Posted: Wed Mar 30, 2016 16:51 Post subject: |
|
|
Suspect this was TMI limit related.
I managed to get around it with
DelayCommand on the HeartbeatProcessGenome(oPC,TimeOfDayCurrent);
In order to ensure that the Heartbeat runs at most every 7 seconds or so for each PC/NPC - it increments an int called iCounter by 1*0.10;
It then adds this to 7 seconds, which is when the next recursion on the method is called.
So the theory is that the method should be able to handle 100+ creatures running off the pseudo-hb, and the next iteration of the hb shouldn't start until the last one has finished. |
|
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
|