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 
 
Bic Files -> Database Entries?
Goto page 1, 2  Next
 
Post new topic   Reply to topic    nwnx.org Forum Index -> Windows development
View previous topic :: View next topic  
Author Message
Baaleos



Joined: 02 Sep 2007
Posts: 830

PostPosted: Mon Nov 16, 2009 16:13    Post subject: Bic Files -> Database Entries? Reply with quote

Hi, Does anyone know if its possible, to translate Bic Files, and their Locations, directly to pwdata entries?

I saw a nwnx plugin a while back, which did file operations, such as get contents of a folder.

I was wondering if anyone had any idea if this could be used to

1. Select * from table (via odbc)
PlayerName = PlayerName from pwdata
Character = Character from pwdata (some sort of name conversion required on the character name, to turn it to bic file name)
2. Locate Bic File via \ServerVault\PlayerName\Character.bic
2.a - If Bic file does not exist - Remove Database Entry.
2.b If Bic File does exist, keep database entry.

The reason I ask this, is because I provided a method for players to delete their bic files via letoscript, however, what I forgot to do, at the same time, was remove all Database Entries relating to those characters.

Which essentially means, if that player makes a character with same character name as the deleted character, he could in effect, gain access to all the previously stored data, regardless of the fact it is in principle, a different character.


I've patched up my PW now, so it deletes Database Entries when characters delete their bic's.

I only ask now, if there is some 'easy' method of mass deleting database entries, but only the ones which have no bic files associated with them.
Eg - Do not delete the entries, which have bic files still using them.
Back to top
View user's profile Send private message
ShaDoOoW



Joined: 20 Aug 2005
Posts: 584

PostPosted: Mon Nov 16, 2009 16:54    Post subject: Reply with quote

You would have to set their Bic File into database first, if you got it, then its possible via my or Terra666 plugin
_________________
Community Patch / NWNX Patch / NWNX Files / NWNX Connect
Back to top
View user's profile Send private message
Baaleos



Joined: 02 Sep 2007
Posts: 830

PostPosted: Mon Nov 16, 2009 17:08    Post subject: why? Reply with quote

I know why your saying that - so that there is some sort of relationship between the vault path to the bic, and all database entries etc.

But could one not just use

This to turn Character Names, into BicFile names?

Code:


string GetBicFileName(object oPC)
{
    string sChar, sBicName;
    string sPCName = GetStringLowerCase(GetName(oPC));
    int i, iNameLength = GetStringLength(sPCName);

    for(i=0; i < iNameLength; i++) {
        sChar = GetSubString(sPCName, i, 1);
        if (TestStringAgainstPattern("(*a|*n|*w|'|-|_)", sChar)) {
            if (sChar != " ") sBicName += sChar;
        }
    }
    return GetStringLeft(sBicName, 16);
}


This is the function that Funky wrote for Higher Ground leveling system, I think at that point, he didnt like the GetNewestBic integrated function in the letoscript dll, so he built this function to return the file name of the bic file.

In all honesty, I've never used it, but was wondering if its feasible.

Eg

Select distinct player,tag from pwdata (returns all unique players and character names - no need to return same data twice)

Code:


while(SQLFetch()==SQL_SUCCESS)
         {
           string sPlayerName, sCharacterBic;
           sPlayerName = SQLGetData(1);
           sCharacterBic = GetBicFileName(SQLGetData(2));
           GetFileExists(sPlayerName,sCharacterBic); //Some sort of function to check whether that bic exists or not.
          }



Does letoscript have a method or function, which can detect the presence of a bic file or not.

Eg - Return false, if not found, and true if found?

If so, Im sure it could be adapted for this purpose, if not, I will likely need that plugin which allows for file operations. - Would u have a link?
Back to top
View user's profile Send private message
ShaDoOoW



Joined: 20 Aug 2005
Posts: 584

PostPosted: Mon Nov 16, 2009 17:50    Post subject: Reply with quote

Use name to get bicfilename is not reliable, could work in 95% cases but I can't recommend it to you.
_________________
Community Patch / NWNX Patch / NWNX Files / NWNX Connect
Back to top
View user's profile Send private message
Baaleos



Joined: 02 Sep 2007
Posts: 830

PostPosted: Mon Nov 16, 2009 18:51    Post subject: Reply with quote

In all honesty, I'm just looking for a quick way of pruning a very large database. 5% of those deleted entries belonging to players who still play on my server, I would live with that, worst case scenario is that we have a few database entries to remake. As said b4 Wont have this problem in future, as the delete bic function will now have an embedded database cleaning method too. Any how, would u have a link or idea how to use letoscript to determine if a bic file exists? Eg. Feed in bic path, and it gives true or false as to if it exists or not?
Back to top
View user's profile Send private message
ShaDoOoW



Joined: 20 Aug 2005
Posts: 584

PostPosted: Mon Nov 16, 2009 20:42    Post subject: Reply with quote

Use nwnx_files FileExists or Tera666 nwnx_system2, there will be something similar. I know its possible via letoscript too, but I stop work with that plugin so I don't remeber how and which version, guess only 27 can do it though...
_________________
Community Patch / NWNX Patch / NWNX Files / NWNX Connect
Back to top
View user's profile Send private message
FunkySwerve



Joined: 02 Jun 2005
Posts: 377

PostPosted: Tue Nov 17, 2009 0:48    Post subject: Reply with quote

GetBicFileName is perfectly reliable in doing what it does - which is to only translate characters whose bicfiles actually match their names. They will NOT match if the player has made more than one character with that name, as the character will use the first 15 characters and then an incrementing number for the bic file. Characters that don't match are much rarer than 1 in 20 (I'd guestimate one in a couple hundred), but I still wouldn't recommend doing this - you can instead use leto's findnewest bic function, or acaos' more recent function, if you're running linux.

Funky


Last edited by FunkySwerve on Tue Nov 17, 2009 0:51; edited 1 time in total
Back to top
View user's profile Send private message
FunkySwerve



Joined: 02 Jun 2005
Posts: 377

PostPosted: Tue Nov 17, 2009 0:50    Post subject: Reply with quote

ShaDoOoW wrote:
Use nwnx_files FileExists or Tera666 nwnx_system2, there will be something similar. I know its possible via letoscript too, but I stop work with that plugin so I don't remeber how and which version, guess only 27 can do it though...

27 is a broken version. 24 is the last usable version. For leto, I would just try findnewestbic, renaming to utc as you go, as I don't think findnewestbic will find utcs.

Funky
Back to top
View user's profile Send private message
addicted2rpg



Joined: 01 Aug 2008
Posts: 106

PostPosted: Wed Nov 25, 2009 21:50    Post subject: Reply with quote

You might be over complicating it. A lot of mods award a player 1 xp or something after initialization of a new player so that they don't get processed twice (if xp == 0). Hopefully you have had the foresight for this Smile

If you did, then check if a player has a database record existing and if they are brand new (xp == 0). If both are true, simply delete the record and let them init properly. This will prevent database entry hijacking by new players.

If you're intended purpose is something like disk usage or just the self-satisfaction of having an optimally cleaned database or w/e, well good luck with that Smile

Another potential shortcut is if you got a transaction log lying around you might be able to see who deleted prior to your DB fix.... grep the names out or whatever.... you can script your way to building the statements necessary.
Back to top
View user's profile Send private message
maddogfargo



Joined: 03 Nov 2009
Posts: 49

PostPosted: Wed Dec 23, 2009 0:11    Post subject: Reply with quote

I know the feeling. After just 2 years I have almost 2000 Player folders in my OC server vault. But maybe 20-25 casually active players.

An method to perform an annual cleaning both the player files and database entries together would be nice. You could add a script to log active player accounts for a period, say every 6 months or even a year. But is it possible to use leto or similar to delete all bic files (*.bic) in the folder path specified (by omission, skipping folders matching active player account database entries)?
_________________
* illegible scribble *
Back to top
View user's profile Send private message
virusman



Joined: 30 Jan 2005
Posts: 1020
Location: Russia

PostPosted: Wed Dec 23, 2009 0:15    Post subject: Reply with quote

Yes. nwn-lib for Ruby is ideal for this.
_________________
In Soviet Russia, NWN plays you!
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger
Baaleos



Joined: 02 Sep 2007
Posts: 830

PostPosted: Wed Dec 23, 2009 0:40    Post subject: Solved Reply with quote

I've implimented a two fold system.

Now - when characters are created, their bicpaths are stored associated with their player/character.

Also - when they are deleted, all pwdata entries are deleted at same time associated to that character and player.



The bic path is stored, as part of a new online player profile system I am making - allows players to delete their characters via an online player profile page.

Tested and works - works by pooling a database query on heartbeat of server - to avoid too much processing, it only runs every 6d(1) server heartbeats (1 out of 6 heartbeats). When it finds a player/character in the delete character queue, it initiates the letoscript delete bic file on the stored bic path.
Back to top
View user's profile Send private message
maddogfargo



Joined: 03 Nov 2009
Posts: 49

PostPosted: Wed Dec 23, 2009 21:02    Post subject: Re: Solved Reply with quote

Baaleos wrote:
I've implimented a two fold system.

Now - when characters are created, their bicpaths are stored associated with their player/character.

Also - when they are deleted, all pwdata entries are deleted at same time associated to that character and player.



The bic path is stored, as part of a new online player profile system I am making - allows players to delete their characters via an online player profile page.

Tested and works - works by pooling a database query on heartbeat of server - to avoid too much processing, it only runs every 6d(1) server heartbeats (1 out of 6 heartbeats). When it finds a player/character in the delete character queue, it initiates the letoscript delete bic file on the stored bic path.


Why make it random?

You could just run the script to do an initial check on mod load and then at the end of the script do a delay command to run itself again after x amount of time. It will run initially and then continue to re-run itself every x seconds or so.
_________________
* illegible scribble *
Back to top
View user's profile Send private message
Baaleos



Joined: 02 Sep 2007
Posts: 830

PostPosted: Wed Dec 23, 2009 22:01    Post subject: Well, the Reply with quote

The only reasonably regular thing I could run such a system of is the heartbeat, but I, like many other servers, have alot of things tied into the heartbeat of the module.

By making the system run once every 10 seconds, instead of once every 6 seconds, can same a reasonable amount of cpu time.

The system also requires that it checks that the player/character bic is logged out, before a letoscript delete can be done.

This in itself, requires yet another loop of all characters, to ensure that one with playername and character name of the bic file are not logged on.

If 200 bic files were being mass deleted via this system, all in one go, it could cause quite alot of lag - I cant remember for sure, but I think I remember hearing before, that letoscript edits/changes are sychronous - meaning it will freeze the server, until it is completed.


Choice of 200 deletion freezes all at once = possible freeze of 10 seconds max freeze time,

or

200 deleteion freezes each less than a second or so, spread over a minute or 2.
Back to top
View user's profile Send private message
ShaDoOoW



Joined: 20 Aug 2005
Posts: 584

PostPosted: Thu Dec 24, 2009 18:20    Post subject: Reply with quote

First: for manipulate with files, use my NWNX_Files or nwnx_systemdata2 from Terra666

Second: I implemented similar system, and I dont understand why you use heartbeat for that. When 0xp PC enter module, you give him id and associate id with his bic file name etc. When he delete his character you get his id by pooling for bic file name. Either from website or ingame you can delete all quests/other entries in database directly, no need to do that elsewhere/otherwhile. If you want to apply this system into already run PW, you just need to make one time script which run for all bic files in all accounts (maybe you didnt think of this because this may be not possible via letoscript, not sure but possible with other plugins).
_________________
Community Patch / NWNX Patch / NWNX Files / NWNX Connect
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 development All times are GMT + 2 Hours
Goto page 1, 2  Next
Page 1 of 2

 
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