/* User-level compression toggle */ void do_compress( CHAR_DATA *ch, char *argument ) { if (!ch->desc) { send_to_char("What descriptor?!\n", ch); return; } if (!ch->desc->out_compress) { if (!IS_SET(ch->desc->flags, DESCRIPTOR_COMPRESS2) && str_cmp(argument, "force")) { send_to_char("Your client did not identify itself as supporting MCCP2.\n\r" "If you'd like to try anyways, type: compress force\n\r" "(If you get garbage, type compress again)",ch); return; } if(!compressStart(ch->desc)) { send_to_char("Failed.\n", ch); return; } send_to_char("Ok, compression enabled.\n", ch); } else { if (!compressEnd(ch->desc)) { send_to_char("Failed.\n", ch); return; } send_to_char("Ok, compression disabled.\n", ch); } }
void do_copyover(void) { LIST_ITERATOR *sock_i = newListIterator(socket_list); SOCKET_DATA *sock = NULL; FILE *fp; char buf[100]; char control_buf[20]; char port_buf[20]; if ((fp = fopen(COPYOVER_FILE, "w+")) == NULL) return; sprintf(buf, "\n\r <*> The world starts spinning <*>\n\r"); // For each playing descriptor, save its character and account ITERATE_LIST(sock, sock_i) { compressEnd(sock, sock->compressing, FALSE); // kick off anyone who hasn't yet logged in a character if (!socketGetChar(sock) || !socketGetAccount(sock) || !charGetRoom(socketGetChar(sock))) { text_to_socket(sock, "\r\nSorry, we are rebooting. Come back in a few minutes.\r\n"); close_socket(sock, FALSE); } // save account and player info to file else { fprintf(fp, "%d %s %s %s\n", sock->control, accountGetName(sock->account), charGetName(sock->player), sock->hostname); // save the player save_player(sock->player); save_account(sock->account); text_to_socket(sock, buf); } } deleteListIterator(sock_i);
void do_compress( CHAR_DATA *ch, char *argument ) { if (!ch->desc) { send_to_char("What descriptor?!\n", ch); return; } if (!ch->desc->out_compress) { if ( str_cmp(argument,"2") ) write_to_buffer( ch->desc, compress_on_str, 0 ); if ( str_cmp(argument,"1") ) write_to_buffer( ch->desc, compress2_on_str, 0 ); send_to_char("Ok, compression enabled.\n", ch); } else { if (!compressEnd(ch->desc,ch->desc->compressing)) { send_to_char("Failed.\n", ch); return; } send_to_char("Ok, compression disabled.\n", ch); } return; }
void do_compress( CHAR_DATA * ch, const char *argument ) { if( !ch->desc ) { send_to_char( "What descriptor?!\n", ch ); return; } if( !ch->desc->mccp->out_compress ) { if( !compressStart( ch->desc ) ) send_to_char( "&RCompression failed to start.\n\r", ch ); else send_to_char( "&GOk, compression enabled.\n", ch ); } else { compressEnd( ch->desc ); ch->desc->can_compress = FALSE; send_to_char( "&ROk, compression disabled.\n", ch ); } }
void recycle_sockets() { SOCKET_DATA *dsock; LIST_ITERATOR *sock_i = newListIterator(socket_list); ITERATE_LIST(dsock, sock_i) { if (dsock->lookup_status != TSTATE_CLOSED) continue; /* remove the socket from the main list */ listRemove(socket_list, dsock); propertyTableRemove(sock_table, dsock->uid); /* close the socket */ close(dsock->control); /* stop compression */ compressEnd(dsock, dsock->compressing, TRUE); /* delete the socket from memory */ deleteSocket(dsock); } deleteListIterator(sock_i); }
/* Warm reboot stuff, gotta make sure to thank Erwin for this :) */ void do_hotboot( CHAR_DATA * ch, const char *argument ) { FILE *fp; CHAR_DATA *victim = NULL; DESCRIPTOR_DATA *d, *de_next; char buf[100], buf2[100], buf3[100]; extern int control; int count = 0; bool found = FALSE; for( d = first_descriptor; d; d = d->next ) { if( ( d->connected == CON_PLAYING || d->connected == CON_EDITING ) && ( victim = d->character ) != NULL && !IS_NPC( victim ) && victim->in_room && victim->fighting && victim->top_level >= 1 && victim->top_level <= MAX_LEVEL ) { found = TRUE; count++; } } if( found ) { ch_printf( ch, "Cannot hotboot at this time. There are %d combats in progress.\r\n", count ); return; } found = FALSE; for( d = first_descriptor; d; d = d->next ) { if( d->connected == CON_EDITING && d->character ) { found = TRUE; break; } } if( found ) { send_to_char( "Cannot hotboot at this time. Someone is using the line editor.\r\n", ch ); return; } sprintf( log_buf, "Hotboot initiated by %s.", ch->name ); log_string( log_buf ); fp = fopen( HOTBOOT_FILE, "w" ); if( !fp ) { send_to_char( "Hotboot file not writeable, aborted.\r\n", ch ); bug( "Could not write to hotboot file: %s. Hotboot aborted.", HOTBOOT_FILE ); perror( "do_copyover:fopen" ); return; } /* * And this one here will save the status of all objects and mobs in the game. * * This really should ONLY ever be used here. The less we do stuff like this the better. */ save_world( ch ); #ifdef OLC_SHUTTLE { SHUTTLE_DATA *tshuttle; for( tshuttle = first_shuttle; tshuttle; tshuttle = tshuttle->next ) save_shuttle( tshuttle ); } #endif log_string( "Saving player files and connection states...." ); if( ch && ch->desc ) write_to_descriptor( ch->desc, "\033[0m", 0 ); sprintf( buf, "\r\nYou feel a great disturbance in the Force." ); /* * For each playing descriptor, save its state */ for( d = first_descriptor; d; d = de_next ) { CHAR_DATA *och = CH( d ); de_next = d->next; /* We delete from the list , so need to save this */ if( !d->character || d->connected < CON_PLAYING ) /* drop those logging on */ { write_to_descriptor( d, "\r\nSorry, we are rebooting. Come back in a few minutes.\r\n", 0 ); close_socket( d, FALSE ); /* throw'em out */ } else { /* For test purposes flush_buffer(d, TRUE);*/ fprintf( fp, "%d %d %d %d %d %s %s\n", d->can_compress, d->descriptor, och->in_room->vnum, d->port, d->idle, och->name, d->host ); /* * One of two places this gets changed */ och->pcdata->hotboot = TRUE; save_char_obj( och ); write_to_descriptor( d, buf, 0 ); compressEnd( d ); } } fprintf( fp, "%s", "-1" ); FCLOSE( fp ); #ifdef IMC imc_hotboot( ); #endif /* * added this in case there's a need to debug the contents of the various files */ if( argument && !str_cmp( argument, "debug" ) ) { log_string( "Hotboot debug - Aborting before execl" ); return; } log_string( "Executing hotboot...." ); /* * exec - descriptors are inherited */ snprintf( buf, 100, "%d", port ); snprintf( buf2, 100, "%d", control ); #ifdef IMC if( this_imcmud ) snprintf( buf3, 100, "%d", this_imcmud->desc ); else strncpy( buf3, "-1", 100 ); #else strncpy( buf3, "-1", 100 ); #endif dlclose( sysdata.dlHandle ); execl( EXE_FILE, "swreality", buf, "hotboot", buf2, buf3, ( char * )NULL ); /* * Failed - sucessful exec will not return */ perror( "do_hotboot: execl" ); sysdata.dlHandle = dlopen( NULL, RTLD_LAZY ); if( !sysdata.dlHandle ) { bug( "%s", "FATAL ERROR: Unable to reopen system executable handle!" ); exit( 1 ); } bug( "%s", "Hotboot execution failed!!" ); send_to_char( "Hotboot FAILED!\r\n", ch ); }