> Don't know about that particular case but i had a idnum problem as well
> im running ascii files and it seems that every time a player was deleted
> and re-created he/she got a new idnum in the playerfile but in the index
> the idnum wasn't changed so i ended up with some ppl having the same idnum
> etc.
>
Yes. Have some.
PjD
#!/usr/bin/perl
# House Cleaner v.1, by Pat Dughi 5-30-97
# kinda a substitute for purgeplay once you get that fancy ascii pfile
# thing and they aint removed any more.
#general declares
$DELETE_BIT=1024; #this is 2^10 or (1 << 10)
$NODELETE_BIT=8192; #this is 2^13 or (1 << 13)
$LEVEL_DEL=10; # level to delete after 30 days.
$START_PLAYER_DIR="a";
$PLAYER_DIR="lib/pfiles";
$RENT_DIR="lib/plrobjs";
$ALIAS_DIR="lib/plralias";
$TEMP_DIR="/tmp";
$PLAYER_INDEX="lib/pfiles/plr_index";
# Subroutine "find_old_dir", returns old style directory of character
# being examined.
sub find_old_dir {
my ($character_name) = @_;
$character_name=~ tr/a-z/A-z/;
if ($character_name ge "A" && $character_name le "E") {
return "A-E";
}
if ($character_name ge "F" && $character_name le "J") {
return "F-J";
}
if ($character_name ge "K" && $character_name le "O") {
return "K-O";
}
if ($character_name ge "P" && $character_name le "T") {
return "P-T";
}
if ($character_name ge "U" && $character_name le "Z") {
return "U-Z";
}
#this couldn't possibly happen, but hey, we'll put it in for fun.
return "ZZZ";
}
# find_and_remove subroutine
# Find out if a named player needs to be deleted!
sub find_and_remove {
my $character_name = shift(@_);
$delete=0;
if ($character_name eq "." || $character_name eq "..") {
return 0;
}
open(PFILE, "$PLAYER_DIR/$START_PLAYER_DIR/$character_name");
while(<PFILE>) {
if (/Act /) {
($act,$colon,$actnum)=split(/\s/,$_,3);
if ($actnum & $DELETE_BIT && !($actnum & $NODELETE_BIT)) {
$delete=1;
}
}
if (/Id /) {
($id,$colon,$idnum)=split(/\s+/,$_,3);
chop($idnum);
}
if (/Last/) {
($last,$colon,$lastnum)=split(/\s/,$_,3);
chop($lastnum);
}
if (/Levl/) {
($levl,$colon,$levlnum)=split(/\s/,$_,3);
chop($lastnum);
}
}
# check for level being less than a certain number, and the character not
# having logged in for about a month
if (((time() - $lastnum) > (60*60*24*30)) && ($levlnum < $LEVEL_DIR)) {
#then, its more than a month
$delete=1;
}
close(PFILE);
if($delete) {
print("Deleting $character_name, delete bits set.\n");
unlink("$PLAYER_DIR/$START_PLAYER_DIR/$character_name");
if(-e ($RENT_DIR . "/" . find_old_dir($character_name) .
"/$character_name"
. ".objs")) {
unlink($RENT_DIR . "/" . find_old_dir($character_name) .
"/$character_name" . ".objs");
}
if(-e ($ALIAS_DIR . "/" . find_old_dir($character_name) . "/" .
$character_name . ".alias")) {
unlink($ALIAS_DIR . "/" . find_old_dir($character_name) . "/" .
$character_name . ".alias");
}
return 0; # found and removed.
}
return $idnum; # found, is okay for insertion in index.
}
#this is the main function.
print("House cleaning started.\n");
open(NEW_PLAYER_INDEX, "> $TEMP_DIR/tmpplr_index") or die "Failure to open
tmp
file\n";
while($START_PLAYER_DIR ne "aa") {
opendir TEMPDIR, "$PLAYER_DIR/$START_PLAYER_DIR";
@dir_list= readdir TEMPDIR;
closedir TEMPDIR;
foreach $character (@dir_list) {
if(find_and_remove($character)) {
$their_id=find_and_remove($character);
print NEW_PLAYER_INDEX "$their_id\t$character\n";
}
}
$START_PLAYER_DIR++;
}
close(NEW_PLAYER_INDEX);
#just for reading.
open(NEW_PLAYER_INDEX, "$TEMP_DIR/tmpplr_index") or die "Lost temp
file!\n";
@presort=<NEW_PLAYER_INDEX>;
close(NEW_PLAYER_INDEX);
sub numfirst {
($numbera,$crapa) =split(/\t/,$a);
($numberb,$crapb) =split(/\t/,$b);
$numbera <=> $numberb;
}
@sorted=sort numfirst @presort;
open(PLAYER_INDEX_T, "> $PLAYER_INDEX");
foreach $line (@sorted) {
print PLAYER_INDEX_T $line;
}
close(PLAYER_INDEX_T);
print("All done!\n");
+------------------------------------------------------------+
| Ensure that you have read the CircleMUD Mailing List FAQ: |
| http://democracy.queensu.ca/~fletcher/Circle/list-faq.html |
+------------------------------------------------------------+
This archive was generated by hypermail 2b30 : 12/15/00 PST