static void ShutdownProc( void) { #define SYSINFO_SHUTDOWN_MSG "%d 分钟后开始进行系统停机维护, 请大家提前下线以免数据丢失。" #define SYSINFO_SHUTDOWN_MSG_COMP "服务器已关闭。" int diff,hun; diff = NowTime.tv_sec - SERVSTATE_getShutdown(); hun = SERVSTATE_getLimittime() - (diff/60); if( hun != SERVSTATE_getDsptime() ){ char buff[256]; if( hun != 0 ) { snprintf( buff, sizeof(buff), SYSINFO_SHUTDOWN_MSG, hun); } else { strcpy( buff, SYSINFO_SHUTDOWN_MSG_COMP); } sendmsg_toall( buff); SERVSTATE_setDsptime(hun); if( hun == 1 ) { int i=0; unsigned int MAX_USER=0; MAX_USER=getPlayercharnum(); for(i=0;i<MAX_USER;i++){ if( CHAR_getCharUse( i ) == FALSE )continue; #ifdef _OFFLINE_SYSTEM if(CHAR_getWorkInt( i, CHAR_WORK_OFFLINE )!=0){ CHAR_logout(i,TRUE); }else #endif CONNECT_setCloseRequest( getfdFromCharaIndex(i) , 1 ); }//for i SERVSTATE_SetAcceptMore( 0 ); } } /* closesallsockets */ if( hun == 0) { closeAllConnectionandSaveData(); SERVSTATE_setShutdown(0); SERVSTATE_setDsptime(0); SERVSTATE_setLimittime(0); } }
static void NPC_Sysinfo_Msg_closeallsockets(int meindex, int tindex, char*msg) { CHAR_talkToCli( tindex, meindex, "closeallsockets OK.", CHAR_COLORYELLOW); closeAllConnectionandSaveData(); }