Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to "verify" your details, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.
 Entire forum ➜ SMAUG ➜ SMAUG coding ➜ Remove lines in clan.lst

Remove lines in clan.lst

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Zeno   USA  (2,871 posts)  Bio
Date Mon 31 Jan 2005 12:42 AM (UTC)

Amended on Mon 31 Jan 2005 12:55 AM (UTC) by Zeno

Message
I've got in a clan delete command, works fine etc, but I'm not sure how to delete that clan filename from clan.lst. The actual clan file is deleted, but of course it's still in clan.lst, and I don't think fopen will remove that line.

Manual deletion is out of the question, since this is the last part of my custom player creation clan system.

The file looks like this:
combatant.gui
guardian.gui
tclan.cln
some.cln
another.cln
$

Zeno McDohl,
Owner of Bleached InuYasha Galaxy
http://www.biyg.org
Top

Posted by Nick Cash   USA  (626 posts)  Bio
Date Reply #1 on Mon 31 Jan 2005 01:42 AM (UTC)
Message
Why not just save the new list over it? Thats what I do with my asteroids. Since this is used by players, it is obviously online. When you remove the clan from the doubly linked list, just save the new list right afterwards and you should be fine.

~Nick Cash
http://www.nick-cash.com
Top

Posted by Zeno   USA  (2,871 posts)  Bio
Date Reply #2 on Mon 31 Jan 2005 02:01 AM (UTC)
Message
Well the function is write_clan_list, and it appears to only add a new line, not re-write the whole file. At least from what I see it doing. (After the clan file is removed, I call write_clan_list, and clan.lst has not removed the old file reference) This is the stock function...

void write_clan_list( )
{
    CLAN_DATA *tclan;
    FILE *fpout;
    char filename[256];

    sprintf( filename, "%s%s", CLAN_DIR, CLAN_LIST );
    fpout = fopen( filename, "w" );
    if ( !fpout )
    {
        bug( "FATAL: cannot open clan.lst for writing!\n\r", 0 );
        return;
    }
    for ( tclan = first_clan; tclan; tclan = tclan->next )
        fprintf( fpout, "%s\n", tclan->filename );
    fprintf( fpout, "$\n" );
    fclose( fpout );
}

Zeno McDohl,
Owner of Bleached InuYasha Galaxy
http://www.biyg.org
Top

Posted by Samson   USA  (683 posts)  Bio
Date Reply #3 on Mon 31 Jan 2005 04:00 AM (UTC)
Message
Did you remember to unlink the clan data from the clan list?

Did you even delete the clan data from memory when you deleted the file?

In my case when a clan is deleted, either by the administration or automatically by the system, it removed the clan data from memory, unlinks it from the list, and THEN calls write_clan_list to rebuild the file.
Top

Posted by Greven   Canada  (835 posts)  Bio
Date Reply #4 on Mon 31 Jan 2005 05:29 AM (UTC)
Message
The key line with this stuff is this
fpout = fopen( filename, "w" );
The "w" means to write, if the file exists, it overwrite it and creates an empty file. To add a line to the list would be to use "a".

Nobody ever expects the spanish inquisition!

darkwarriors.net:4848
http://darkwarriors.net
Top

Posted by Zeno   USA  (2,871 posts)  Bio
Date Reply #5 on Mon 31 Jan 2005 07:10 PM (UTC)
Message
Yeah, forgot to uncomment the lines that would free that clan from the memory. Remember that as I was going to bed.

Zeno McDohl,
Owner of Bleached InuYasha Galaxy
http://www.biyg.org
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


15,466 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.