[Home] [Downloads] [Search] [Help/forum]

Gammon Forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  SMAUG
. -> [Folder]  SMAUG coding
. . -> [Subject]  Remove lines in clan.lst
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

Remove lines in clan.lst

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


Posted by Zeno   USA  (2,871 posts)  [Biography] 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
[Go to top] top

Posted by Nick Cash   USA  (626 posts)  [Biography] 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
[Go to top] top

Posted by Zeno   USA  (2,871 posts)  [Biography] 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
[Go to top] top

Posted by Samson   USA  (683 posts)  [Biography] 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.

SmaugMuds.org: http://www.smaugmuds.org - The Smaug MUDs Community Center

"The past was erased, the erasure was forgotten, the lie became truth." -- George Orwell, 1984
[Go to top] top

Posted by Greven   Canada  (835 posts)  [Biography] 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
[Go to top] top

Posted by Zeno   USA  (2,871 posts)  [Biography] 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
[Go to top] 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.


3,550 views.

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

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

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

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at FutureQuest]