The problem comes in with our use of PublicCDKey alone as the tag passed to the persistency functions (in place of a PC object's tag, since PCs don't have tags), as well as the tag of the placeable Corpse of the PC, and the tag of the "body" item. Our functions then tried tricks like getting a pointer to the corpse or body by "GetObjectByTag()", which could have variable effects- in all these cases, though, the system is broken once you have several corpses in circulation which came from the same player. Especially as level 1s can be fairly shortlived, we can expect this to be a problem.
What I'm experimenting with now is, much as was suggested, composing PublicCDKey_CharacterID and using that in place of the tag when a PC is passed to the persistency functions. The downside of this is the IntToString of ACR_GetCharacterID() may be different lengths, but it's easy enough to get the CD Key with GetStringLeft, and some math with GetStringLength lets us perform other operations on it as well.
For now, I've had PC objects use the CDKEY_CHARID in place of tag, changed the corpses (placeables) to be tagged and SetDatabaseName()'s with this same format (CDKEY_CHARID), so they can be used interchangably for ACR_DTH_LOCATION and such. The bodies (item corpse tokens) now take the same tag, but with "_BODY" suffixed, to avoid conflicts with GetObjectByTag() calls used elsewhere.
A few bugs remain with this change in implementation, but I think it will sort out some of the problems I've been having in testing.
New NWNx4 Persistency retrofit discussion
Moderators: ALFA Administrators, Staff - Technical
- AcadiusLost
- Chosen of Forumamus, God of Forums
- Posts: 5061
- Joined: Tue Oct 19, 2004 8:38 am
- Location: Montara, CA [GMT -8]
- Contact:
- AcadiusLost
- Chosen of Forumamus, God of Forums
- Posts: 5061
- Joined: Tue Oct 19, 2004 8:38 am
- Location: Montara, CA [GMT -8]
- Contact:
Since I'm not too sharp on my SQL syntax yet, are there any obvious problem with the query from RestoreCorpsesOnModuleLoad()?
It seems to only return the first record, and not others in the DB (the While loop seems to only iterate once). Do we need to do something like GetNextRecordInQuery() or something from inside the while loop?
Code: Select all
605 // retrieve all the records of dead players with corpses in the game world
606 ACR_SQLQuery("SELECT d1.Name, d1.Tag, d1.Value FROM pwdata as d1, pwdata as d2 WHERE d1.`Key`='" + ACR_DTH_LOCATION + "' and d1.Name=d2.Name and d1.Tag=d2.Tag and d2.`Key`='" + ACR_PLAYER_FLAGS + "' and d2.Value | " + IntToString(ACR_PLAYER_FLAG_DEAD));
607
608 location lLocation; string sDatabaseName; object oCorpse;
609
610 // loop through all the bodies at the morgue and recreate their corpses in the world
611 while (ACR_SQLFetch() == SQL_SUCCESS)
612 {
613 // generate the unique database name
614 sDatabaseName = ACR_SQLGetData("1");
615
616 // get the last resting place of the corpse
617 lLocation = ACR_StringToLocation(ACR_SQLGetData("2"));
....
- ç i p h é r
- Retired
- Posts: 2904
- Joined: Fri Oct 21, 2005 4:12 pm
- Location: US Central (GMT - 6)
ACR_SQLFetch() is supposed to do that (retrieve the next row of the result set). Can you run the query against the database directly and see what results you get?AcadiusLost wrote:It seems to only return the first record, and not others in the DB (the While loop seems to only iterate once). Do we need to do something like GetNextRecordInQuery() or something from inside the while loop?
p.s. It produced the proper results for me but I only had one record in the database at the time IIRC.
- AcadiusLost
- Chosen of Forumamus, God of Forums
- Posts: 5061
- Joined: Tue Oct 19, 2004 8:38 am
- Location: Montara, CA [GMT -8]
- Contact:
Imported your latest commit of acr_persist_db_i.nss - ran into some compilation errors.
Apparently ACR_SQLGetData() now takes an integer for the column number, rather than a string like "0", "2", or "31".
I changed the following files to match the format, locally:
acr_mod_events_i.nss
acr_death_i.nss
acr_pps_i.nss
Not sure if you're working on any of those, or if the ACR_SQLGetData() declaration change was a conscious and intentional one- so I'll hold on committing those until I hear from you.
Apparently ACR_SQLGetData() now takes an integer for the column number, rather than a string like "0", "2", or "31".
I changed the following files to match the format, locally:
acr_mod_events_i.nss
acr_death_i.nss
acr_pps_i.nss
Not sure if you're working on any of those, or if the ACR_SQLGetData() declaration change was a conscious and intentional one- so I'll hold on committing those until I hear from you.
- ç i p h é r
- Retired
- Posts: 2904
- Joined: Fri Oct 21, 2005 4:12 pm
- Location: US Central (GMT - 6)
Yeah, sorry it's a premature commit - I didn't think you were looking! 
I've got a number of other files to commit as well, which apply those changes among other things. Bear in mind, you'll need NWNX4 v1.08 once you sync up. I was planning to wrap it up tonight but I've been consumed by work related issues. Nothing like job stress creeping into your personal life to piss away an otherwise perfect evening.

I've got a number of other files to commit as well, which apply those changes among other things. Bear in mind, you'll need NWNX4 v1.08 once you sync up. I was planning to wrap it up tonight but I've been consumed by work related issues. Nothing like job stress creeping into your personal life to piss away an otherwise perfect evening.
- AcadiusLost
- Chosen of Forumamus, God of Forums
- Posts: 5061
- Joined: Tue Oct 19, 2004 8:38 am
- Location: Montara, CA [GMT -8]
- Contact: