new_changes.c
snippets · 2.9 KB · 2010-03-30
new_changes.c: stores changes in a separate text file so you can edit it without rebooting.
Download « Back to the snippets list
/*****************************************************************************
* This code will allow you to put your changes in a separate text file so *
* you can change it without rebooting the MUD or so you can access it from *
* a website, if you'd like to post your changes there. *
* *
* To install this code, just #define CHANGES_FILE somewhere. I chose merc.h *
* and add this somewhere appropriate. I chose act_info.c *
* *
* This uses Erwin's dynamic buffer code, but you can modify it to use other *
* things (like a really big char array or maybe Rom2.4's buffer system. *
* One other note: Since it uses fread_string, you need to put a ~ at the *
* end of the file. *
* *
* Permission to use this code is given freely provided you email me and *
* me you're using it and that my name is retained with this code. *
* - Rahl (Daniel Anderson), Broken Shadows - email dwa1844@rit.edu *
*****************************************************************************/
/* new_changes by Rahl */
void do_new_changes( CHAR_DATA *ch, char *argument )
{
FILE *fp;
char filename[200];
BUFFER *buffer = buffer_new(3000);
sprintf( filename, "%s", CHANGES_FILE );
fp = fopen( filename, "r" );
if ( !fp )
return;
while( 1 )
{
buffer_strcat( buffer, fread_string( fp ) );
if ( feof( fp ) )
break;
}
fclose( fp );
page_to_char( buffer->data, ch );
buffer_free( buffer );
return;
}
/*
=============================================================================
/ ______ _______ ____ _____ ___ __ _ ______ ____ ____ _____ /
\ | ____|__ __| _ \ / ____\ / _ \| \ / | ____| / __ \| _ \ / ____\ \
/ | |__ | | | |_| | | | |_| | |\/| | |___ | | | | |_| | | /
/ | ___| | | | ___/| | __| _ | | | | ____| | | | | __/| | ___ \
\ | | | | | | | |___| | | | | | | | |____ | |__| | |\ \| |___| | /
/ |_| |_| |_| o \_____/|_| |_|_| |_|______|o \____/|_| \_|\_____/ \
\ /
============================================================================
------------------------------------------------------------------------------
ftp://ftp.game.org/pub/mud FTP.GAME.ORG http://www.game.org/ftpsite/
------------------------------------------------------------------------------
This file came from FTP.GAME.ORG, the ultimate source for MUD resources.
------------------------------------------------------------------------------
*/