Copyover.help

Copyover.help · 14.1 KB

From the archive copyover7.zip

Download the archive   « Back to the archive contents

/***************************************************************************
*           	Star Wars: Storm of Vengeance Alpha .1			   *
*==========================================================================*
* Sw-Storm Alpha 0.1 Code Changes by Iczer/K.lopes w/ help from Maelfius   *
* Additional Code within go to their respective owners.			   *
*==========================================================================*
* Star Wars Reality Code Additions and changes from the Smaug Code         *
* copyright (c) 1997 by Sean Cooper                                        *
*==========================================================================*
* Starwars and Starwars Names copyright(c) Lucas Film Ltd.                 *
*==========================================================================*
* SMAUG 1.0 (C) 1994, 1995, 1996 by Derek Snider                           *
* SMAUG code team: Thoric, Altrag, Blodkai, Narn, Haus,                    *
* Scryn, Rennard, Swordbearer, Gorog, Grishnakh and Tricops                *
*==========================================================================*
* Merc 2.1 Diku Mud improvments copyright (C) 1992, 1993 by Michael        *
* Chastain, Michael Quan, and Mitchell Tse.                                *
* Original Diku Mud copyright (C) 1990, 1991 by Sebastian Hammer,          *
* Michael Seifert, Hans Henrik St{rfeldt, Tom Madsen, and Katja Nyboe.     *
*==========================================================================*
*                       Warmboot/Copyover Module			   *
****************************************************************************/
/* Origional Copyover Code by Erwin S. Andreasen http://www.andreasen.org/ */

Ok making a layout here so it will be easy to install, Fixed some issues
concerning Player homes and objects over Warmboots in player homes and a 
descriptor issue.


==========================================================================================================================
in File Mud.h

find
and change the Following Connect States CON_PLAYING, and CON_GET_NAME,
to whats below and Add CON_COPYOVER_RECOVER to the last of the Constates
and it should look like this depending on your muds configurations This is what
Mines looks like:
/*
 * Connected state for a channel.
 */
 typedef enum
{
  CON_PLAYING = 0,	CON_GET_NAME = -100,	CON_GET_OLD_PASSWORD,
  CON_CONFIRM_NEW_NAME,	CON_GET_NEW_PASSWORD,	CON_CONFIRM_NEW_PASSWORD,
  CON_GET_NEW_SEX,	CON_READ_MOTD,
  CON_GET_NEW_RACE,	CON_GET_EMULATION,	CON_EDITING,
  CON_GET_WANT_RIPANSI,	CON_TITLE,		CON_PRESS_ENTER,
  CON_WAIT_1,		CON_WAIT_2,		CON_WAIT_3,
  CON_ACCEPTED,         CON_GET_PKILL,		CON_READ_IMOTD,
  CON_GET_NEW_EMAIL,    CON_GET_MSP,            CON_GET_NEW_CLASS,
  CON_ROLL_STATS,	CON_STATS_OK, 		
  CON_ASK_ANSI, CON_GET_EMAIL, CON_NMOTD_CONFIRM, CON_PLAYER_MENU,
  CON_GET_REFFERAL, CON_COPYOVER_RECOVER
} connection_types;

Find
and add to the end of:
/*
 * Utility macros.
 */
#define CH(d)			((d)->original ? (d)->original : (d)->character)


Find
and add in to the top of:
/*
 * Command functions.
 * Defined in act_*.c (mostly).
 */
DECLARE_DO_FUN( do_copyover	);

Find
And add to the Bottom section of:
/*
 * Data files used by the server.
 *
 * AREA_LIST contains a list of areas to boot.
 * All files are read in completely at bootup.
 * Most output files (bug, idea, typo, shutdown) are append-only.
 *
 * The NULL_FILE is held open so that we have a stream handle in reserve,
 *   so players can go ahead and telnet to all the other descriptors.
 * Then we close it whenever we need to open a file (e.g. a save file).
 */
#define COPYOVER_FILE	SYSTEM_DIR "copyover.dat" /* for warm reboots	 */
#define EXE_FILE	"../src/swreality" 	  /*  Executable Path */

Do a Search in Mud.h for and add in to list in:
/* comm.c */
void	log_printf	args( (char *fmt, ...) );
void	copyover_recover	args( (void) );

Do a search in mud.h for and Change in:
/* Db.c */
void	boot_db		args( ( void ) );
to This:
void	boot_db		args( ( bool fCopyOver ) );

Do a Search for in Mud.h:
/* save.c */
and add below
void	save_home	args( ( CHAR_DATA *ch ) );
This:
void	load_home	args( ( CHAR_DATA *ch ) );

==========================================================================================================================
In File Db.c:

Search for:
/*
 * Big mama top level function.
 */
void boot_db( void )

And change it to look like:

void boot_db( bool fCopyOver )
{

down just Alittle lower find

        log_string( "Resetting areas" );
	area_update( );
MOBtrigger = TRUE;	                

And right below Add:
       if (fCopyOver)
        {
         log_string("Running copyover_recover.");
         copyover_recover();
         }

=========================================================================================================================
In File Save.c:

At Toplevel Under Function
void save_home( CHAR_DATA *ch )
{
    if ( ch->plr_home )
    {
       	FILE *fp;
       	char filename[256];
       	sh_int templvl;
       	OBJ_DATA *contents;


       	sprintf( filename, "%s%c/%s.home", PLAYER_DIR, tolower(ch->name[0]),
				 capitalize( ch->name ) );
    	if ( ( fp = fopen( filename, "w" ) ) == NULL )
    	{
    	}
    	else
    	{
		templvl = ch->top_level;
		ch->top_level = LEVEL_AVATAR;		/* make sure EQ doesn't get lost */
        	contents = ch->plr_home->last_content;
        	if (contents)
	  	  fwrite_obj(ch, contents, fp, 0, OS_CARRY );
		fprintf( fp, "#END\n" );
		ch->top_level = templvl;
    		fclose( fp );
    	}
    }
}
Add This function:

void load_home( CHAR_DATA * ch )
    	{
	 char filename[256];
         FILE *fph;
         ROOM_INDEX_DATA *storeroom = ch->plr_home;
         OBJ_DATA *obj;
         OBJ_DATA *obj_next;
           
/*         for ( obj = storeroom->first_content; obj; obj = obj_next )
	 {
	    obj_next = obj->next_content;
	    extract_obj( obj );
	 } */

	 sprintf( filename, "%s%c/%s.home", PLAYER_DIR, tolower(ch->name[0]),
				 capitalize( ch->name ) );
	 if ( ( fph = fopen( filename, "r" ) ) != NULL )
	 {
	    int iNest;
	    bool found;
	    OBJ_DATA *tobj, *tobj_next;

	    rset_supermob(storeroom);
	    for ( iNest = 0; iNest < MAX_NEST; iNest++ )
		rgObjNest[iNest] = NULL;

	    found = TRUE;
	    for ( ; ; )
	    {
		char letter;
		char *word;

		letter = fread_letter( fph );
		if ( letter == '*' )
		{
		    fread_to_eol( fph );
		    continue;
		}

		if ( letter != '#' )
		{
		    bug( "Load_plr_home: # not found.", 0 );
		    bug( ch->name, 0 );
		    break;
		}

		word = fread_word( fph );
		if ( !str_cmp( word, "OBJECT" ) )	/* Objects	*/
		  fread_obj  ( supermob, fph, OS_CARRY );
		else
		if ( !str_cmp( word, "END"    ) )	/* Done		*/
		  break;
		else
		{
		    bug( "Load_plr_home: bad section.", 0 );
		    bug( ch->name, 0 );
		    break;
		}
	    }

	    fclose( fph );

	    for ( tobj = supermob->first_carrying; tobj; tobj = tobj_next )
	    {
		tobj_next = tobj->next_content;
		obj_from_char( tobj );
		obj_to_room( tobj, storeroom );
	    }
	    
	    release_supermob();

         }
}

==========================================================================================================================
In File Comm.c

Search for At Toplevel
and add:
/*
 * Global variables.
 */
int                 port;               /* Port number to be used       */ <--- Add This Variable before these two
int		    control;		/* Controlling descriptor	*/
int		    control2;		/* Controlling descriptor #2	*/

Find the Function:
       
int main( int argc, char **argv )   
{
    struct timeval now_time;
    int port;
    
and change it to look like exactly like this:

int main( int argc, char **argv )
{
    struct timeval now_time;
    bool fCopyOver = !TRUE;
/*    int port;  moved up in to local functions - Iczer */

and just Alittle Lower is:
    /*
     * Get the port number.
     */
    port = 7777;
    if ( argc > 1 )
    {
	if ( !is_number( argv[1] ) )
	{
	    fprintf( stderr, "Usage: %s [port #]\n", argv[0] );
	    exit( 1 );
	}
	else if ( ( port = atoi( argv[1] ) ) <= 1024 )
	{
	    fprintf( stderr, "Port number must be above 1024.\n" );
	    exit( 1 );
	} 
and Add these lines right below :
    if (argv[2] && argv[2][0])
      {
          fCopyOver = TRUE;
          control = atoi(argv[3]);
          control2 = atoi(argv[4]);
          conclient = atoi(argv[5]);
          conjava = atoi(argv[6]);
      }
    else
          fCopyOver = FALSE;
   }    

go Down just alittle more and you will see these lines
        
    /*
     * Run the game.
     */
    log_string("Booting Database");
    boot_db( );
    log_string("Initializing socket");
    control  = init_socket( port   );
    control2 = init_socket( port+1 );
    conclient= init_socket( port+10);
    conjava  = init_socket( port+20);
    sprintf( log_buf, "Star Wars Reality ready on port %d.", port );
    log_string( log_buf );
    game_loop( );
    close( control  );
    close( control2 );
    close( conclient);
    close( conjava  );
    /*
     * That's all, folks.
     */
    log_string( "Normal termination of game." );
    exit( 0 );
    return 0;
}
Change it to Look Like this:
    /*
     * Run the game.
     */
    log_string("Booting Database");
    boot_db(fCopyOver);
    log_string("Initializing socket");
    if (!fCopyOver) /* We have already the port if copyover'ed */
     {
        control = init_socket (port);
        control2 = init_socket( port+1 );
        conclient= init_socket( port+10);
        conjava  = init_socket( port+20); 
     }
    sprintf( log_buf, "Star Wars Reality ready on port %d.", port );                                                                                                                          
    log_string( log_buf );
    game_loop( );
    /*
     * That's all, folks.
     */
    log_string( "Normal termination of game." );
    exit( 0 );
    return 0;
}

Search for This Function:
void pager_printf(CHAR_DATA *ch, char *fmt, ...)
{
    char buf[MAX_STRING_LENGTH*2];
    va_list args;

    va_start(args, fmt);
    vsprintf(buf, fmt, args);
    va_end(args);
	
    send_to_pager(buf, ch);
}
And Right Below it Add this Function:

/*  From Erwin  */
void log_printf(char *fmt, ...)
{
  char buf[MAX_STRING_LENGTH*2];
  va_list args;

  va_start(args, fmt);
  vsprintf(buf, fmt, args);
  va_end(args);
 
  log_string(buf);
}

Search in Comm.c For this Function

void new_descriptor( int new_desc )
{
    char buf[MAX_STRING_LENGTH];
    DESCRIPTOR_DATA *dnew;

and Right Above this function add this Function:
void init_descriptor( DESCRIPTOR_DATA *dnew, int desc)
{
    dnew->next		= NULL;
    dnew->descriptor	= desc;
    dnew->connected	= CON_GET_NAME;
    dnew->outsize	= 2000;
    dnew->idle		= 0;
    dnew->lines		= 0;
    dnew->scrlen	= 24;
    dnew->user		= STRALLOC("unknown");
    dnew->auth_fd	= -1;
    dnew->auth_inc	= 0;
    dnew->auth_state	= 0;
    dnew->newstate	= 0;
    dnew->prevcolor	= 0x07;

    CREATE( dnew->outbuf, char, dnew->outsize );
}
And in the Function void new_descriptor( int new_desc )
comment out These Lines:
    if ( ( desc = accept( new_desc, (struct sockaddr *) &sock, &size) ) < 0 )
    {
/*	perror( "New_descriptor: accept"); <---- This line
	sprintf(buf, "[*****] BUG: New_descriptor: accept"); <----- This Line
	log_string_plus( buf, LOG_COMM, sysdata.log_level ); */ <---- And this line =)
	set_alarm( 0 );
	return;
    } 
Go Down alittle Further and Find these Lines:
/*    dnew->next		= NULL;
    dnew->descriptor	= desc;
    dnew->connected	= CON_GET_NAME;
    dnew->outsize	= 2000;
    dnew->idle		= 0;
    dnew->lines		= 0;
    dnew->scrlen	= 24;
    dnew->port		= ntohs( sock.sin_port );
    dnew->user 		= STRALLOC("unknown");
    dnew->auth_fd	= -1;
    dnew->auth_inc	= 0;
    dnew->auth_state	= 0;
    dnew->newstate	= 0;
    dnew->prevcolor	= 0x07;
    dnew->original      = NULL;
    dnew->character     = NULL; 

    CREATE( dnew->outbuf, char, dnew->outsize ); */ <---- Already Commented out as can see you may
 remove them if	you wish to save alittle space or make your code neater. and then Just below this add these lines:

    init_descriptor(dnew, desc ); /*<--	this line And */
    dnew->port = ntohs(sock.sin_port); /* This Line -Iczer*/
    strcpy( buf, inet_ntoa( sock.sin_addr ) );
    sprintf( log_buf, "Sock.sinaddr:  %s, port %hd.",
		buf, dnew->port );
    log_string_plus( log_buf, LOG_COMM, sysdata.log_level );

    dnew->host = STRALLOC( buf );
=========================================================================================================================
In File Tables.c

Search for These lines:
	if ( !str_cmp( name, "do_consider" ))		return do_consider;
	if ( !str_cmp( name, "do_copyship" ))		return do_copyship;
and Add this line between them:
	if ( !str_cmp( name, "do_copyover" ))		return do_copyover;

Then Search for these lines:
    if ( skill == do_consider )		return "do_consider";
    if ( skill == do_credits )		return "do_credits";
and add this line between them:
    if ( skill == do_copyover )		return "do_copyover";

===========================================================================================================================

Well you are almost done now in the File Makefile add in
copyover.c to the C_FILES = list and copyover.o to the O_FILES = list
Or if you wish you can take what ever functions that are in copyover.c and place them in Comm.c
i made it copyover.c to keep my comm.c from getting way to large and to be modular.
now Type make clean and then make to compile your mud and start it up
once started in the mud type
cedit warmboot create
cedit warmboot code do_copyover
cedit warmboot level 105 ( or Desired level )
cedit save cmdtable

and Warmboot =) this command Warmboot should work straight out of as i have tested it on a unmodified SWR 1.0
before release, depending on the changes in your Swr Code.

- Iczer
sov@hawaii.rr.com
Star Wars: Storm of Vengeance
telnet://mo.wolfpaw.net:10300

Site Stats

Snippets: 1791
Codebases: 571