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 
 
Very Strange Behavior

 
Post new topic   Reply to topic    nwnx.org Forum Index -> Development
View previous topic :: View next topic  
Author Message
seed



Joined: 01 Dec 2006
Posts: 44

PostPosted: Mon Apr 16, 2007 21:48    Post subject: Very Strange Behavior Reply with quote

Here's something that is very strange - sometimes when getting strings from NWN functions such as GetName, GetPCPlayerName and GetPCPublicCDKey, I get results from a recent NWNX4 query returned instead.

Consider this xp_mysql.txt log:

Quote:
01 * Executing: select pl_plid, pl_damage, pl_kills, pl_bind, pl_deaths, pl_pker, pl_pked, pl_bic, pl_delete, pl_ban from player where pl_acid = 1167 and pl_name = 'OK'
02 * Returning: 6162 (column 0)
03 * Returning: 420 (column 1)
04 * Returning: (column 3)
05 * Returning: 0 (column 4)
06 * Returning: 0 (column 5)
07 * Returning: 0 (column 6)
08 * Returning: OK (column 7)
09 * Returning: 0 (column Cool
10 * Returning: 0 (column 9)
11 * Executing: update player set pl_dllogin=now(), pl_logins=pl_logins+1 where pl_plid=6162
12 * Executing: update player set pl_bic=replace('OK', '/', char(92)) where pl_plid=6162
13 * Executing: select ac_acid, ac_ban, ac_bankxp, ac_bankgold, ac_animosity, ac_dm from account where ac_name = 'OK'


and here's the code that is running:

Quote:
string sPlayer = GetName(oPC);
sSQL = "select pl_plid, pl_damage, pl_kills, pl_bind, pl_deaths, pl_pker, pl_pked, pl_bic, pl_delete, pl_ban from player where pl_acid = " + sACID + " and pl_name = " + InQs(sPlayer);
SQLExecDirect(sSQL);
...
...
string sAccount = GetPCPlayerName(oPC);
sSQL = "select ac_acid, ac_ban, ac_bankxp, ac_bankgold, ac_animosity, ac_dm from account where ac_name = " + InQs(sAccount);


As you can see, the strings sPlayer and sAccount both have values of "OK" being used in the SQL statement, which is the last string value returned by a previously run query and not the correct value should be returned from the GetName or GetPCPlayerName functions.

In addition, I am using the NWN4X character dll to get the Bic file name ("NWNX!CHARACTER!GETBIC!" + sVault + "!UNUSED") and it too is returning "OK" (see line 12 above, the "OK" in that sql statement comes from the GetLocalString call after setting the NWNX string).

So I don't know what is going on here. It's really causing havok in my database since I am getting records for Players, Account, and CDKeys with invalid strings.

Anyone else seeing strange data returned with these functions?


Last edited by seed on Mon Apr 16, 2007 21:53; edited 2 times in total
Back to top
View user's profile Send private message
seed



Joined: 01 Dec 2006
Posts: 44

PostPosted: Mon Apr 16, 2007 21:51    Post subject: Reply with quote

Here's another example:

Quote:
* Executing: insert into session (se_added, se_module) values (now(), 'Dungeon Eternal X')
* Executing: select last_insert_id() from session limit 1
* Returning: 861 (column 0)
* Executing: delete from temporaryban where tb_expires<=now()
* Executing: delete from pwdata where adddate(last, expire)<now() and expire > 0
* Executing: delete from chattext where ct_added < date_add(now(), interval -5 day)
* Executing: update player set pl_active=0 where pl_active<>0
* Executing: update faction set fa_artifact=fa_faid where fa_artifact=0
* Executing: select fa_faid, fa_name, fa_aura, fa_aura2, fa_castlewp, fa_artifact, fa_bossname, fa_bossskin, fa_artifactname, fa_aurasef, fa_aurasefg from faction order by fa_faid
* Returning: 1 (column 0)
* Returning: The Dark Legion (column 1)
* Returning: 288 (column 2)
* Returning: 868 (column 3)
* Returning: dp_return (column 4)
* Returning: (empty) (column 5)
* Returning: (empty) (column 6)
* Returning: (empty) (column 7)
* Returning: (empty) (column Cool
* Returning: aura_legion.sef (column 9)
* Returning: aura_legion_g.sef (column 10)
* Returning: 2 (column 0)
* Returning: The Order of the Holy Light (column 1)
* Returning: 289 (column 2)
* Returning: 688 (column 3)
* Returning: dp_return (column 4)
* Returning: (empty) (column 5)
* Returning: (empty) (column 6)
* Returning: (empty) (column 7)
* Returning: (empty) (column Cool
* Returning: aura_order.sef (column 9)
* Returning: aura_order_g.sef (column 10)
* Executing: select (3-date_format(now(), '%h') % 3) * 60-date_format(now(), '%i')
* Returning: 178 (column 0)
* Executing: select ac_acid, ac_ban, ac_bankxp, ac_bankgold, ac_animosity, ac_dm from account where ac_name = 'Dungeon Eternal X'
* Returning: 4782 (column 0)
* Returning: 0 (column 1)
* Returning: 0 (column 2)
* Returning: 0 (column 3)
* Returning: 0 (column 4)
* Returning: 0 (column 5)
* Executing: update account set ac_dllogin=now(), ac_logins=ac_logins+1 where ac_acid=4782
* Executing: select pl_plid, pl_damage, pl_kills, pl_bind, pl_deaths, pl_pker, pl_pked, pl_bic, pl_delete, pl_ban from player where pl_acid = 4782 and pl_name = 'Dungeon Eternal X'
* Returning: 13206 (column 0)


In this example, the 1st Dungeon Eternal X is being inserted in the first query. Then later on, the "update account" query shows this value (returned from GetPCPlayerName), and then again this value makes an appearance in the "select player" query - this time it is returned from the GetName() function.
Back to top
View user's profile Send private message
virusman



Joined: 30 Jan 2005
Posts: 1020
Location: Russia

PostPosted: Mon Apr 16, 2007 23:14    Post subject: Reply with quote

What is NWNX4 Character?
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger
seed



Joined: 01 Dec 2006
Posts: 44

PostPosted: Tue Apr 17, 2007 1:21    Post subject: Reply with quote

http://www.nwnx.org/index.php?id=65

it's a plugin "NWNX4/Character Version 0.0.0.1"
Back to top
View user's profile Send private message
Papillon
x-man


Joined: 28 Dec 2004
Posts: 1060
Location: Germany

PostPosted: Tue Apr 17, 2007 21:43    Post subject: Reply with quote

Just to be sure: Do you use the latest version of NWNX4 (Prototype 1.07) ?
_________________
Papillon
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
seed



Joined: 01 Dec 2006
Posts: 44

PostPosted: Wed Apr 18, 2007 12:11    Post subject: Reply with quote

Yes, I am using 1.07 - the compile date is 1/27/07
Back to top
View user's profile Send private message
Papillon
x-man


Joined: 28 Dec 2004
Posts: 1060
Location: Germany

PostPosted: Sat Apr 21, 2007 11:39    Post subject: Reply with quote

I have no idea what would be causing this, currently. Basically, there are two options:

1) Wait for the next NWNX release, which will use the new OE provided functions for passing data back and forth.

2) Try to reproduce the problem and fix the bug

I am leaning towards option 1, especially as 2 seems to be a difficult task. Of course, if you want, you could try to make a small demo module with a small demo table, that I could use to reproduce the problem.
_________________
Papillon
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
nosfe



Joined: 25 Apr 2007
Posts: 22

PostPosted: Wed Apr 25, 2007 7:45    Post subject: Reply with quote

Very interesting the NWNX4/Charactere

I have begin to export BIC file to XML but it is very heavy... i wait this library charactere in nwnx4
Back to top
View user's profile Send private message
Papillon
x-man


Joined: 28 Dec 2004
Posts: 1060
Location: Germany

PostPosted: Sat May 05, 2007 8:34    Post subject: Reply with quote

seed, do you have more luck with 1.08 ?
_________________
Papillon
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
seed



Joined: 01 Dec 2006
Posts: 44

PostPosted: Sat May 05, 2007 13:54    Post subject: Reply with quote

I haven't actually had a chance to try 1.08. I'll see about running 1.08 on my secondary server for testing this weekend sometime.
Back to top
View user's profile Send private message
seed



Joined: 01 Dec 2006
Posts: 44

PostPosted: Tue Sep 04, 2007 17:44    Post subject: Reply with quote

I am still seeing this behavior but I am also still using 107 because the NWNX4 Functions plug-in is not ported (I need the reboot function from in game).

I'm not sure what the problem could be, nothing I have done in code has helped.

What appears to be happening, is the NWScript functions GetPCPlayerName, GetName, and GetPCPublicCDKey sometimes return the first string value used in the Last SQL Insert statement:

Quote:
* Executing: insert into login (li_seid, li_ckid, li_acid, li_plid, li_caid, li_stsin, li_goldin, li_xpin, li_ip) values (3304,8579,1168,19908,11755,'DEAD',0,0,'T')
* Executing: select last_insert_id() from login limit 1
* Returning: 194510 (column 0)
* Executing: update login set li_logout=now(), li_kills=0,li_xpout=0 where li_liid=194510
* Executing: update player set pl_active=1,pl_damage=0,pl_time=pl_time+0,pl_kills=pl_kills+0,pl_deaths=1 WHERE PL_PLID = 25700
* Executing: update login set li_logout=now(), li_kills=0,li_xpout=18561 where li_liid=194507
* Executing: select ac_acid, ac_ban, ac_bankxp, ac_bankgold, ac_animosity, ac_dm from account where ac_name = 'DEAD'
* Returning: 1533 (column 0)
* Returning: 1 (column 1)
* Executing: select pl_plid, pl_damage, pl_kills, pl_bind, pl_deaths, pl_pker, pl_pked, pl_bic, pl_delete, pl_ban from player where pl_acid = 1533 and pl_name = 'DEAD'


You can see, I insert the value "DEAD" into the login table. Later on, the GetPCPLayerName() returns "DEAD" (see "from account where ac_name = 'DEAD'"), and then again the GetName() also returns "DEAD" (see "from player where pl_acid = 1533 and pl_name = 'DEAD'")

and here is another example:

Quote:
* Executing: insert into logmsg (ct_seid, ct_plid, ct_value, ct_text, ct_toplid) values (3304,25524,'T','relie\n',0)
* Executing: select ac_acid, ac_ban, ac_bankxp, ac_bankgold, ac_animosity, ac_dm from account where ac_name = 'T'
* Returning: 1168 (column 0)
* Returning: 0 (column 1)
* Returning: 0 (column 2)
* Returning: 0 (column 3)
* Returning: 0 (column 4)
* Returning: 0 (column 5)
* Executing: update account set ac_dllogin=now(), ac_logins=ac_logins+1 where ac_acid=1168
* Executing: select pl_plid, pl_damage, pl_kills, pl_bind, pl_deaths, pl_pker, pl_pked, pl_bic, pl_delete, pl_ban from player where pl_acid = 1168 and pl_name = 'T'


The first string in the insert statement is "T" and that is returned for GetPCPlayerName and GetName which are used in the Account and Player queries...

This is strange and it makes my database logging full of crap data. I don't know how to fix it. The GetPCPLayername and GetName eventually start returning proper data but I don't know why or how to force it. The logging listed above is being run in the On-Player-Loaded event if that helps at all.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    nwnx.org Forum Index -> Development 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