chuyiwen_gmsv/npc/npc_sysinfo.c

841 lines
26 KiB
C
Raw Normal View History

2016-12-24 08:45:52 +08:00
#include "version.h"
#include <string.h>
#include "char.h"
#include "char_event.h"
#include "object.h"
#include "handletime.h"
#include "magic.h"
#include "npcutil.h"
#include "char_data.h"
#include "chatmagic.h"
#include "net.h"
#include "configfile.h"
#include "npcgen.h"
/*
---------------------------------------------------------------------
sysinfo By Kawata
---------------------------------------------------------------------
*/
#define NPC_SYSINFO_MSGMAX 21
#define NPC_SYSINFO_PASSWD_DEFAULT "longzoro"
#define NPC_SYSINFO_TIMELIMIT_DEFAULT 120
#define NPC_SYSINFO_SHUTDOWNLIMIT_DEFAULT 5
2017-01-13 23:37:03 +08:00
#define NPC_SYSINFO_SHUTDOWN_MSG "再过 %d 分钟後即开始进行server系统维护。"
2016-12-24 08:45:52 +08:00
2017-01-13 23:37:03 +08:00
#define NPC_SYSINFO_SHUTDOWN_MSG_COMP "server已关闭。"
2016-12-24 08:45:52 +08:00
enum {
CHAR_WORK_MODE = CHAR_NPCWORKINT1,
CHAR_WORK_TIME = CHAR_NPCWORKINT2,
CHAR_WORK_TIMELIMIT = CHAR_NPCWORKINT3,
CHAR_WORK_SHUTDOWNTIME = CHAR_NPCWORKINT4,
CHAR_WORK_SHUTDOWNLIMIT = CHAR_NPCWORKINT5,
CHAR_WORK_SHUTDOWNDSPTIME = CHAR_NPCWORKINT6,
CHAR_WORK_MSGCOLOR = CHAR_NPCWORKINT7,
CHAR_WORK_PLAYER = CHAR_NPCWORKINT8,
};
enum {
CHAR_WORKCHAR_PASSWD = CHAR_NPCWORKCHAR1,
};
typedef struct {
char msg[16];
}CMD_MSG;
CMD_MSG cmd_msg[] = {
{ "startinfo"}, {"endinfo"}, {"help"},
{"player"}, {"list"}, {"sendno"},
{"sendmsg"}, {"shutdown"}, {"msgcol"},
{"sysinfo"}, {"info"},
{ "allowaccept" } , { "denyaccept" } ,
{ "closeallsockets" },
{ "allnosee" },
{ "allnobody" },
{ "movenum" },
{ "bornnum" },
{ "enemystate" },
{ "setwalktime"},{ "setcatime" },{"setcdtime"},
{ "setoneloop"},
{ "titlerestart"},
{ "setsaacwrite"}, { "setsaacread"},
};
enum{
NPC_SYSINFO_MSG_STARTINFO,
NPC_SYSINFO_MSG_ENDINFO,
NPC_SYSINFO_MSG_HELP,
NPC_SYSINFO_MSG_PLAYER,
NPC_SYSINFO_MSG_LIST,
NPC_SYSINFO_MSG_SENDNO,
NPC_SYSINFO_MSG_SENDMSG,
NPC_SYSINFO_MSG_SHUTDOWN,
NPC_SYSINFO_MSG_MSGCOL,
NPC_SYSINFO_MSG_SYSINFO,
NPC_SYSINFO_MSG_INFO,
NPC_SYSINFO_MSG_ALLOWACCEPT,
NPC_SYSINFO_MSG_DENYACCEPT,
NPC_SYSINFO_MSG_CLOSEALLSOCKETS,
2017-01-13 23:37:03 +08:00
/* 错痊馨笛 */
2016-12-24 08:45:52 +08:00
NPC_SYSINFO_ALL_NOSEE,
NPC_SYSINFO_ALL_NOBODY,
NPC_SYSINFO_MOVE_NUM,
NPC_SYSINFO_BORN_NUM,
NPC_SYSINFO_ENEMY_STATE,
NPC_SYSINFO_SETWALKTIME,
NPC_SYSINFO_SETCATIME,
NPC_SYSINFO_SETCDTIME,
NPC_SYSINFO_SETONELOOP,
NPC_SYSINFO_TITLERESTART,
NPC_SYSINFO_SETSAACWRITE,
NPC_SYSINFO_SETSAACREAD,
NPC_SYSINFO_MSG_NUM,
};
typedef struct {
char arg[32];
char defMsg[128];
}NPC_Sysinfo_Msg;
static NPC_Sysinfo_Msg msgtable[] = {
2017-01-13 23:37:03 +08:00
{ "def_msg", "我拥有和全世界的人说话的能力。" },
{ "shutdown_msg", "现在开始要进行server系统维护请尽速logout"},
2016-12-24 08:45:52 +08:00
};
enum{
NPC_SYSINFO_ARG_DEF_MSG,
NPC_SYSINFO_ARG_SHUTDOWN_MSG,
};
static void NPC_Sysinfo_SendMsg( int meindex, int pindex, int tblnum);
static char *NPC_Sysinfo_GetMsg( int meindex, char *msgindexstr,
char *out,int outlen, int num );
static void NPC_Sysinfo_SendMsgToAll( int meindex, char *msg);
static void NPC_Sysinfo_Msg_EndInfo( int meindex, int tindex, char *msg);
static void NPC_Sysinfo_Msg_Help( int meindex, int tindex, char *msg);
static void NPC_Sysinfo_Msg_Player( int meindex, int tindex, char *msg);
static void NPC_Sysinfo_Msg_List( int meindex, int tindex, char *msg);
static void NPC_Sysinfo_Msg_SendNo( int meindex, int tindex, char *msg);
static void NPC_Sysinfo_Msg_SendMsg( int meindex, int tindex, char *msg);
static void NPC_Sysinfo_Msg_Shutdown( int meindex, int tindex, char *msg);
static void NPC_Sysinfo_Msg_Msgcol( int meindex, int tindex, char *msg);
2017-01-13 23:37:03 +08:00
/* 错痊馨笛 */
2016-12-24 08:45:52 +08:00
static void NPC_Sysinfo_All_NoBody( int meindex, int tindex, char *msg);
static void NPC_Sysinfo_All_NoSee( int meindex, int tindex, char *msg);
static void NPC_Sysinfo_Move_Num( int meindex, int tindex, char *msg);
static void NPC_Sysinfo_Born_Num( int meindex, int tindex, char *msg);
static void NPC_Sysinfo_Enemy_State( int meindex, int tindex, char *msg);
static void NPC_Sysinfo_SetWalkTime( int meindex, int tindex, char *msg);
static void NPC_Sysinfo_SetCATime( int meindex, int tindex, char *msg);
static void NPC_Sysinfo_SetCDTime( int meindex, int tindex, char *msg);
static void NPC_Sysinfo_SetOneloop( int meindex, int tindex, char *msg);
static void NPC_Sysinfo_TitleRestart( int meindex, int tindex, char *msg);
static void NPC_Sysinfo_SetSaacwrite( int meindex, int tindex, char *msg);
static void NPC_Sysinfo_SetSaacread( int meindex, int tindex, char *msg);
static void NPC_Sysinfo_Msg_allowAccept(int meindex, int tindex, char*msg)
{
SERVSTATE_SetAcceptMore( 1 );
CHAR_talkToCli( tindex, meindex, "allowaccept OK.", CHAR_COLORYELLOW);
}
static void NPC_Sysinfo_Msg_denyAccept(int meindex, int tindex, char*msg)
{
SERVSTATE_SetAcceptMore( 0 );
CHAR_talkToCli( tindex, meindex, "denyaccept OK.", CHAR_COLORYELLOW);
}
static void NPC_Sysinfo_Msg_closeallsockets(int meindex, int tindex,
char*msg)
{
CHAR_talkToCli( tindex, meindex, "closeallsockets OK.", CHAR_COLORYELLOW);
closeAllConnectionandSaveData();
}
static void NPC_Sysinfo_Msg_Sysinfo(int meindex, int tindex, char*msg)
{
CHAR_CHAT_DEBUG_sysinfo( tindex, msg);
}
static void NPC_Sysinfo_Msg_Info(int meindex, int tindex, char*msg)
{
CHAR_CHAT_DEBUG_info( tindex, msg);
}
typedef void (*FUNC)(int,int,char *);
static FUNC functbl[] = {
NULL,
NPC_Sysinfo_Msg_EndInfo,
NPC_Sysinfo_Msg_Help,
NPC_Sysinfo_Msg_Player,
NPC_Sysinfo_Msg_List,
NPC_Sysinfo_Msg_SendNo,
NPC_Sysinfo_Msg_SendMsg,
NPC_Sysinfo_Msg_Shutdown,
NPC_Sysinfo_Msg_Msgcol,
NPC_Sysinfo_Msg_Sysinfo,
NPC_Sysinfo_Msg_Info,
NPC_Sysinfo_Msg_allowAccept,
NPC_Sysinfo_Msg_denyAccept,
NPC_Sysinfo_Msg_closeallsockets,
2017-01-13 23:37:03 +08:00
/* 错痊馨笛 */
2016-12-24 08:45:52 +08:00
NPC_Sysinfo_All_NoSee,
NPC_Sysinfo_All_NoBody,
NPC_Sysinfo_Move_Num,
NPC_Sysinfo_Born_Num,
NPC_Sysinfo_Enemy_State,
NPC_Sysinfo_SetWalkTime,
NPC_Sysinfo_SetCATime,
NPC_Sysinfo_SetCDTime,
NPC_Sysinfo_SetOneloop,
NPC_Sysinfo_TitleRestart,
NPC_Sysinfo_SetSaacwrite,
NPC_Sysinfo_SetSaacread,
};
/*********************************
*********************************/
BOOL NPC_SysinfoInit( int meindex )
{
int tmp;
char argstr[NPC_UTIL_GETARGSTR_BUFSIZE];
char buff[128];
NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr));
CHAR_setWorkInt( meindex, CHAR_WORK_MODE, 0);
2017-01-13 23:37:03 +08:00
/* 由旦伐□玉本永玄 */
2016-12-24 08:45:52 +08:00
if( NPC_Util_GetStrFromStrWithDelim( argstr, "passwd", buff, sizeof( buff)) == NULL)
{
strcpy( buff, NPC_SYSINFO_PASSWD_DEFAULT);
}
CHAR_setWorkChar( meindex, CHAR_WORKCHAR_PASSWD, buff);
tmp = NPC_Util_GetNumFromStrWithDelim( argstr, "time");
if( tmp == -1 ) tmp = NPC_SYSINFO_TIMELIMIT_DEFAULT;
CHAR_setWorkInt( meindex, CHAR_WORK_TIMELIMIT, tmp);
tmp = NPC_Util_GetNumFromStrWithDelim( argstr, "msg_col");
if( tmp < CHAR_COLORRED || tmp > CHAR_COLORWHITE )
tmp = CHAR_COLORYELLOW;
CHAR_setWorkInt( meindex, CHAR_WORK_MSGCOLOR, tmp);
CHAR_setWorkInt( meindex, CHAR_WORK_PLAYER, -1);
CHAR_setWorkInt( meindex, CHAR_WORK_SHUTDOWNTIME, 0);
CHAR_setWorkInt( meindex, CHAR_WORK_SHUTDOWNDSPTIME, 0);
CHAR_setInt( meindex, CHAR_WHICHTYPE, CHAR_TYPEOTHERNPC);
CHAR_setFlg( meindex, CHAR_ISATTACKED, 0);
return TRUE;
}
/*********************************
**********************************/
void NPC_SysinfoLoop( int meindex )
{
int shuttime;
if( CHAR_getWorkInt( meindex, CHAR_WORK_MODE) == 1) {
int oldtime;
2017-01-13 23:37:03 +08:00
/* 凛棉毛褡户月 */
2016-12-24 08:45:52 +08:00
oldtime = CHAR_getWorkInt( meindex, CHAR_WORK_TIME);
2017-01-13 23:37:03 +08:00
/* 孺蜃凛棉左□田□匹骚橘乒□玉尺 */
2016-12-24 08:45:52 +08:00
if( NowTime.tv_sec - oldtime >
CHAR_getWorkInt( meindex, CHAR_WORK_TIMELIMIT))
{
CHAR_setWorkInt( meindex, CHAR_WORK_MODE, 0);
CHAR_setWorkInt( meindex, CHAR_WORK_PLAYER, -1);
}
}
shuttime = CHAR_getWorkInt( meindex, CHAR_WORK_SHUTDOWNTIME);
2017-01-13 23:37:03 +08:00
/* shutdown凛棉民尼永弁 */
2016-12-24 08:45:52 +08:00
if( shuttime > 0 ) {
int diff,limit,hun;
diff = NowTime.tv_sec - shuttime;
limit = CHAR_getWorkInt( meindex, CHAR_WORK_SHUTDOWNLIMIT);
hun = limit - (diff/60);
2017-01-13 23:37:03 +08:00
/* ㄠ坌云五卞丢永本□斥 */
2016-12-24 08:45:52 +08:00
if( hun != CHAR_getWorkInt( meindex, CHAR_WORK_SHUTDOWNDSPTIME)){
char buff[256];
if( hun != 0 ) {
snprintf( buff, sizeof(buff), NPC_SYSINFO_SHUTDOWN_MSG, hun);
}
else {
strcpy( buff, NPC_SYSINFO_SHUTDOWN_MSG_COMP);
}
NPC_Sysinfo_SendMsgToAll( meindex, buff);
CHAR_setWorkInt( meindex, CHAR_WORK_SHUTDOWNDSPTIME, hun);
}
if( hun == 0) {
CHAR_setWorkInt( meindex, CHAR_WORK_SHUTDOWNDSPTIME,0);
CHAR_setWorkInt( meindex, CHAR_WORK_SHUTDOWNLIMIT,0);
CHAR_setWorkInt( meindex, CHAR_WORK_SHUTDOWNTIME,0);
}
}
}
/*********************************
**********************************/
void NPC_SysinfoTalked( int meindex, int tindex, char *msg, int color)
{
char *msgwk;
char *buff;
int len;
int msgno;
len = strlen( msg)+1;
msgwk = calloc( 1, sizeof(char)*len);
buff = calloc( 1, sizeof(char)*len);
strcpy( msgwk, msg);
2017-01-13 23:37:03 +08:00
/* 旦矢□旦毛引午户月 */
2016-12-24 08:45:52 +08:00
deleteSequentChar( msgwk, " ");
if( CHAR_getWorkInt( meindex, CHAR_WORK_MODE) == 0 ) {
msgno = 0;
if( strncmp( msgwk, cmd_msg[NPC_SYSINFO_MSG_STARTINFO].msg,
strlen( cmd_msg[NPC_SYSINFO_MSG_STARTINFO].msg)) == 0)
{
if( getStringFromIndexWithDelim( msgwk, " ", 2, buff, len)
== TRUE )
{
if( strcmp( buff, CHAR_getWorkChar( meindex, CHAR_WORKCHAR_PASSWD))
== 0 )
{
CHAR_setWorkInt( meindex, CHAR_WORK_MODE, 1);
CHAR_setWorkInt( meindex, CHAR_WORK_PLAYER, tindex);
CHAR_setWorkInt( meindex, CHAR_WORK_TIME, NowTime.tv_sec);
CHAR_talkToCli( tindex, meindex,
2017-01-13 23:37:03 +08:00
"已移到指令模式。按下help即会出现说明档。",
2016-12-24 08:45:52 +08:00
CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR));
CHAR_talkToCli( tindex, meindex,
2017-01-13 23:37:03 +08:00
"可以在enemystate 中了解敌人的产生和行动数。",
2016-12-24 08:45:52 +08:00
CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR));
}
}
}
if( CHAR_getWorkInt( meindex, CHAR_WORK_MODE ) == 0 ) {
NPC_Sysinfo_SendMsg( meindex, tindex, NPC_SYSINFO_ARG_DEF_MSG);
}
}else {
if( tindex == CHAR_getWorkInt( meindex, CHAR_WORK_PLAYER)) {
int i;
for( i = NPC_SYSINFO_MSG_ENDINFO; i < NPC_SYSINFO_MSG_NUM; i ++ ) {
if( strncmp( msgwk, cmd_msg[i].msg, strlen( cmd_msg[i].msg)) == 0) {
if( functbl[i] != NULL ) {
functbl[i]( meindex, tindex, msgwk);
}
break;
}
}
CHAR_setWorkInt( meindex, CHAR_WORK_TIME, NowTime.tv_sec);
}
else {
NPC_Sysinfo_SendMsg( meindex, tindex, NPC_SYSINFO_ARG_DEF_MSG);
}
}
free( msgwk);
free( buff);
}
/*------------------------------------------------------------------------
2017-01-13 23:37:03 +08:00
*
2016-12-24 08:45:52 +08:00
*----------------------------------------------------------------------*/
static void NPC_Sysinfo_Msg_EndInfo( int meindex, int tindex, char *msg)
{
CHAR_setWorkInt( meindex, CHAR_WORK_MODE, 0);
CHAR_setWorkInt( meindex, CHAR_WORK_PLAYER, -1);
CHAR_talkToCli( tindex, meindex,
2017-01-13 23:37:03 +08:00
"已移到一般模式",
2016-12-24 08:45:52 +08:00
CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR));
}
/*------------------------------------------------------------------------
2017-01-13 23:37:03 +08:00
* HELP丢永本
2016-12-24 08:45:52 +08:00
*----------------------------------------------------------------------*/
static void NPC_Sysinfo_Msg_Help( int meindex, int tindex, char *msg)
{
int i;
typedef struct {
char str[512];
}SYSINFO_MSGWK;
SYSINFO_MSGWK msgwk[] = {
2017-01-13 23:37:03 +08:00
{ "指令HELP"},
{ "help 此项讯息。"},
{ "player 表示现在LOGIN的玩家人数。"},
{ "list 讯息一览。"},
{ "send number 「number」 是数值。指定讯息的号码後将该讯息内容传送给全部的玩家。"},
{ "sendmsg msgs msgs为想传送的讯息。在send 之後空一格,即可将之後的文章送信给全部的玩家。"},
{ "shutdown min min 代表分。"},
{ "msgcol col 设定传送给玩家讯息的颜色。颜色的指定有red,green,yellow,blue,purple,cyan,white。"},
{ "sysinfo 系统状态"},
{ "info 玩家状态"},
{ "endinfo 回复普通的状态。"},
{ "denyaccept 无法接受CLIENT端的接续。"},
{ "allowaccept 接受CLIENT端的接续。"},
{ "closeallsockets 强迫让CLIENT端LOGOUT。在内部实行denyaccept。"},
{ "titlerestart 再次读取称号名的设定。"},
{ "enemystate 说明NPC的状况。"},
2016-12-24 08:45:52 +08:00
{ ""},
};
for( i = 0; msgwk[i].str[0] != '\0'; i ++ ) {
CHAR_talkToCli( tindex, meindex, msgwk[i].str,
CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR));
}
}
/*------------------------------------------------------------------------
2017-01-13 23:37:03 +08:00
*
2016-12-24 08:45:52 +08:00
*----------------------------------------------------------------------*/
static void NPC_Sysinfo_Msg_Player( int meindex, int tindex, char *msg)
{
int i, cnt = 0;
int playernum=CHAR_getPlayerMaxNum();
char buff[64];
for( i=0 ; i<playernum ; i++ ){
if( CHAR_getCharUse(i) != FALSE ) {
if( CHAR_getInt( i, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER ) {
cnt ++;
}
}
}
2017-01-13 23:37:03 +08:00
snprintf( buff, sizeof( buff), "玩家有%d人。", cnt);
2016-12-24 08:45:52 +08:00
CHAR_talkToCli( tindex, meindex, buff,
CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR));
}
/*------------------------------------------------------------------------
*----------------------------------------------------------------------*/
static void NPC_Sysinfo_Msg_List( int meindex, int tindex, char *msg)
{
char buff[512];
char buff2[512];
int i;
for( i = 1; i < NPC_SYSINFO_MSGMAX; i ++ ) {
if( NPC_Sysinfo_GetMsg( meindex, "sendno", buff, sizeof( buff), i)!= NULL )
{
snprintf( buff2, sizeof(buff2), "No.%d:%s", i, buff);
CHAR_talkToCli( tindex, meindex, buff2,
CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR));
}
}
}
/*------------------------------------------------------------------------
*----------------------------------------------------------------------*/
static void NPC_Sysinfo_Msg_SendNo( int meindex, int tindex, char *msg)
{
char buff[32];
char msgbuf[512];
if( getStringFromIndexWithDelim( msg, " ", 2, buff, sizeof( buff)) == TRUE )
{
int num;
num = atoi( buff);
if( num >=1 && num < NPC_SYSINFO_MSGMAX ) {
if( NPC_Sysinfo_GetMsg( meindex, "sendno", msgbuf,
sizeof( msgbuf), num) != NULL )
{
NPC_Sysinfo_SendMsgToAll( meindex, msgbuf);
}
}
}
}
/*------------------------------------------------------------------------
*----------------------------------------------------------------------*/
static void NPC_Sysinfo_Msg_SendMsg( int meindex, int tindex, char *msg)
{
char buff[512];
if( getStringFromIndexWithDelim( msg, " ", 2, buff, sizeof( buff)) == TRUE )
{
NPC_Sysinfo_SendMsgToAll( meindex, buff);
}
}
/*------------------------------------------------------------------------
*----------------------------------------------------------------------*/
static void NPC_Sysinfo_Msg_Msgcol( int meindex, int tindex, char *msg)
{
char buff[64];
typedef struct {
int color;
char str[10];
}SYSINFO_COLSET;
SYSINFO_COLSET colset[] = {
{ 249, "red"},
{ 250, "green"},
{ 251, "yellow"},
{ 252, "blue"},
{ 253, "purple"},
{ 254, "cyan"},
{ 255, "white"},
};
if( getStringFromIndexWithDelim( msg, " ", 2, buff, sizeof( buff)) == TRUE )
{
int i;
for( i = 0; i < 7; i ++ ) {
if( strstr( buff, colset[i].str) != NULL ) {
CHAR_setWorkInt( meindex, CHAR_WORK_MSGCOLOR, colset[i].color);
2017-01-13 23:37:03 +08:00
CHAR_talkToCli( tindex, meindex, "已改变讯息的颜色。",
2016-12-24 08:45:52 +08:00
CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR));
break;
}
}
}
}
/*------------------------------------------------------------------------
*----------------------------------------------------------------------*/
static char *NPC_Sysinfo_GetMsg( int meindex, char *msgindexstr,
char *out,int outlen, int num )
{
char argstr[NPC_UTIL_GETARGSTR_BUFSIZE];
char *work;
char *buff;
char *cret = NULL;
int worklen;
worklen = strlen( msgindexstr)+3;
work = (char *)calloc( 1, worklen * sizeof( char));
buff = (char *)calloc( 1, outlen * sizeof( char));
NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr));
snprintf( work, worklen, "%s%d", msgindexstr, num);
if( NPC_Util_GetStrFromStrWithDelim( argstr, work,buff, outlen) != NULL )
{
strcpy( out, buff);
cret = out;
}
free( work);
free( buff);
return( cret);
}
/*------------------------------------------------------------------------
*----------------------------------------------------------------------*/
static void NPC_Sysinfo_Msg_Shutdown( int meindex, int tindex, char *msg)
{
char buff[10];
int hun;
NPC_Sysinfo_SendMsg( meindex, tindex, NPC_SYSINFO_ARG_SHUTDOWN_MSG);
2017-01-13 23:37:03 +08:00
/* 凛棉本永玄 */
2016-12-24 08:45:52 +08:00
CHAR_setWorkInt( meindex, CHAR_WORK_SHUTDOWNTIME, NowTime.tv_sec);
if( getStringFromIndexWithDelim( msg, " ", 2, buff, sizeof( buff)) == TRUE )
{
hun = atoi( buff);
if( hun <= 0 ) {
hun = NPC_SYSINFO_SHUTDOWNLIMIT_DEFAULT;
}
}
else {
hun = NPC_SYSINFO_SHUTDOWNLIMIT_DEFAULT;
}
CHAR_setWorkInt( meindex, CHAR_WORK_SHUTDOWNLIMIT, hun);
CHAR_setWorkInt( meindex, CHAR_WORK_SHUTDOWNDSPTIME,0);
}
/*------------------------------------------------------------------------
*----------------------------------------------------------------------*/
static void NPC_Sysinfo_SendMsg( int meindex, int pindex, int tblnum)
{
char argstr[NPC_UTIL_GETARGSTR_BUFSIZE];
char buff[128];
NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr));
if( NPC_Util_GetStrFromStrWithDelim( argstr, msgtable[tblnum].arg,buff, sizeof( buff)) == NULL )
{
strcpy( buff, msgtable[tblnum].defMsg);
}
if( buff[0] != '\0' ) {
CHAR_talkToCli( pindex, meindex, buff,
CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR));
}
}
/*------------------------------------------------------------------------
*----------------------------------------------------------------------*/
static void NPC_Sysinfo_SendMsgToAll( int meindex, char *msg)
{
int i;
int playernum = CHAR_getPlayerMaxNum();
for( i = 0 ; i < playernum ; i++) {
if( CHAR_getCharUse(i) != FALSE ) {
CHAR_talkToCli( i, meindex, msg,
CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR));
}
}
}
2017-01-13 23:37:03 +08:00
/* 蝈衬平乓仿毛 NO_SEE 卞允月井升丹井 */
2016-12-24 08:45:52 +08:00
static void NPC_Sysinfo_All_NoSee( int meindex, int tindex, char *msg ){
char buff[256];
buff[0] = buff[1] = 0;
if( getStringFromIndexWithDelim( msg, " ", 2, buff, sizeof( buff)) == TRUE )
{
if( strncmp( buff, "on", strlen( buff ) ) == 0 ){
all_nosee = 1;
2017-01-13 23:37:03 +08:00
snprintf( buff, sizeof( buff), "已开启all_nosee 。" );
2016-12-24 08:45:52 +08:00
CHAR_talkToCli( tindex, meindex, buff,
CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR));
}else
if( strncmp( buff, "off", strlen( buff ) ) == 0 ){
all_nosee = 0;
2017-01-13 23:37:03 +08:00
snprintf( buff, sizeof( buff), "已关闭all_nosee 。" );
2016-12-24 08:45:52 +08:00
CHAR_talkToCli( tindex, meindex, buff,
CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR));
}
}else
if( all_nosee == 0 ){
2017-01-13 23:37:03 +08:00
snprintf( buff, sizeof( buff), "all_nosee关闭着。" );
2016-12-24 08:45:52 +08:00
CHAR_talkToCli( tindex, meindex, buff,
CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR));
}else{
2017-01-13 23:37:03 +08:00
snprintf( buff, sizeof( buff), "all_nosee开启着。" );
2016-12-24 08:45:52 +08:00
CHAR_talkToCli( tindex, meindex, buff,
CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR));
}
}
2017-01-13 23:37:03 +08:00
/* 蝈衬平乓仿毛 NO_BODY 卞允月井升丹井 */
2016-12-24 08:45:52 +08:00
static void NPC_Sysinfo_All_NoBody( int meindex, int tindex, char *msg ){
char buff[256];
buff[0] = buff[1] = 0;
if( getStringFromIndexWithDelim( msg, " ", 2, buff, sizeof( buff)) == TRUE )
{
if( strncmp( buff, "on", strlen( buff ) ) == 0 ){
all_nobody = 1;
2017-01-13 23:37:03 +08:00
snprintf( buff, sizeof( buff), "已开启all_nobody 。" );
2016-12-24 08:45:52 +08:00
CHAR_talkToCli( tindex, meindex, buff,
CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR));
}else
if( strncmp( buff, "off", strlen( buff ) ) == 0 ){
all_nobody = 0;
2017-01-13 23:37:03 +08:00
snprintf( buff, sizeof( buff), "已关闭all_nobody 。" );
2016-12-24 08:45:52 +08:00
CHAR_talkToCli( tindex, meindex, buff,
CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR));
}
}else
if( all_nobody == 0 ){
2017-01-13 23:37:03 +08:00
snprintf( buff, sizeof( buff), "all_nobody 关闭着。" );
2016-12-24 08:45:52 +08:00
CHAR_talkToCli( tindex, meindex, buff,
CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR));
}else{
2017-01-13 23:37:03 +08:00
snprintf( buff, sizeof( buff), "all_nobody 开启着。" );
2016-12-24 08:45:52 +08:00
CHAR_talkToCli( tindex, meindex, buff,
CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR));
}
}
static void NPC_Sysinfo_Move_Num( int meindex, int tindex, char *msg ){
char buff[256];
int work;
buff[0] = buff[1] = 0;
if( getStringFromIndexWithDelim( msg, " ", 2, buff, sizeof( buff)) == TRUE )
{
work = atoi( buff );
if( work <= 0 ) {
2017-01-13 23:37:03 +08:00
work = 1000; /* 赝癫 */
2016-12-24 08:45:52 +08:00
}
EnemyMoveNum = work;
2017-01-13 23:37:03 +08:00
snprintf( buff, sizeof( buff), "让敌人同时%d动作。",
2016-12-24 08:45:52 +08:00
EnemyMoveNum );
CHAR_talkToCli( tindex, meindex, buff,
CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR));
}else{
2017-01-13 23:37:03 +08:00
snprintf( buff, sizeof( buff), "现在敌人同时在进行%d动作。",
2016-12-24 08:45:52 +08:00
EnemyMoveNum );
CHAR_talkToCli( tindex, meindex, buff,
CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR));
}
}
static void NPC_Sysinfo_Born_Num( int meindex, int tindex, char *msg ){
char buff[256];
int work;
buff[0] = buff[1] = 0;
if( getStringFromIndexWithDelim( msg, " ", 2, buff, sizeof( buff)) == TRUE )
{
work = atoi( buff );
if( work <= 0 ) {
2017-01-13 23:37:03 +08:00
work = 2; /* 赝癫 */
2016-12-24 08:45:52 +08:00
}
one_loop_born = work;
2017-01-13 23:37:03 +08:00
snprintf( buff, sizeof( buff), "敌人同时派出最高的%d。",
2016-12-24 08:45:52 +08:00
one_loop_born );
CHAR_talkToCli( tindex, meindex, buff,
CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR));
}else{
2017-01-13 23:37:03 +08:00
snprintf( buff, sizeof( buff), "现在敌人同时派出最高的%d。",
2016-12-24 08:45:52 +08:00
one_loop_born );
CHAR_talkToCli( tindex, meindex, buff,
CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR));
}
}
static void NPC_Sysinfo_Enemy_State( int meindex, int tindex, char *msg ){
char buff[256];
if( all_nobody == 0 ){
2017-01-13 23:37:03 +08:00
snprintf( buff, sizeof( buff), "allnobody 关闭着。" );
2016-12-24 08:45:52 +08:00
CHAR_talkToCli( tindex, meindex, buff,
CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR));
}else{
2017-01-13 23:37:03 +08:00
snprintf( buff, sizeof( buff), "allnobody 开启着。" );
2016-12-24 08:45:52 +08:00
CHAR_talkToCli( tindex, meindex, buff,
CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR));
}
if( all_nosee == 0 ){
2017-01-13 23:37:03 +08:00
snprintf( buff, sizeof( buff), "allnosee 关闭着。" );
2016-12-24 08:45:52 +08:00
CHAR_talkToCli( tindex, meindex, buff,
CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR));
}else{
2017-01-13 23:37:03 +08:00
snprintf( buff, sizeof( buff), "allnosee 开启着。" );
2016-12-24 08:45:52 +08:00
CHAR_talkToCli( tindex, meindex, buff,
CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR));
}
snprintf( buff, sizeof( buff),
2017-01-13 23:37:03 +08:00
"bornnum 现在敌人同时派出最高的%d。",
2016-12-24 08:45:52 +08:00
one_loop_born );
CHAR_talkToCli( tindex, meindex, buff,
CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR));
snprintf( buff, sizeof( buff),
2017-01-13 23:37:03 +08:00
"movenum 现在敌人同时在进行%d动作。",
2016-12-24 08:45:52 +08:00
EnemyMoveNum );
CHAR_talkToCli( tindex, meindex, buff,
CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR));
}
static void NPC_Sysinfo_SetWalkTime( int meindex, int tindex, char *msg)
{
int interval;
char msgbuf[256];
char buff[256];
if( getStringFromIndexWithDelim( msg, " ", 2, buff, sizeof( buff)) == TRUE ) {
interval = atoi( buff);
if( interval > 0 ) {
setWalksendinterval( (unsigned)interval);
}
}
2017-01-13 23:37:03 +08:00
snprintf( msgbuf, sizeof(msgbuf),"WalkInterval = %d 氂秒",getWalksendinterval());
2016-12-24 08:45:52 +08:00
CHAR_talkToCli( tindex, meindex, msgbuf,
CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR));
}
static void NPC_Sysinfo_SetCATime( int meindex, int tindex, char *msg)
{
int interval;
char msgbuf[256];
char buff[256];
if( getStringFromIndexWithDelim( msg, " ", 2, buff, sizeof( buff)) == TRUE ) {
interval = atoi( buff);
if( interval > 0 ) {
setCAsendinterval_ms( (unsigned)interval);
}
}
2017-01-13 23:37:03 +08:00
snprintf( msgbuf, sizeof(msgbuf),"CAsendInterval = %d 氂秒",
2016-12-24 08:45:52 +08:00
getCAsendinterval_ms());
CHAR_talkToCli( tindex, meindex, msgbuf,
CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR));
}
static void NPC_Sysinfo_SetCDTime( int meindex, int tindex, char *msg)
{
int interval;
char msgbuf[256];
char buff[256];
if( getStringFromIndexWithDelim( msg, " ", 2, buff, sizeof( buff)) == TRUE ) {
interval = atoi( buff);
if( interval > 0 ) {
setCDsendinterval_ms( (unsigned)interval);
}
}
2017-01-13 23:37:03 +08:00
snprintf( msgbuf, sizeof(msgbuf),"CDsendInterval = %d 氂秒",
2016-12-24 08:45:52 +08:00
getCDsendinterval_ms());
CHAR_talkToCli( tindex, meindex, msgbuf,
CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR));
}
static void NPC_Sysinfo_SetOneloop( int meindex, int tindex, char *msg)
{
int interval;
char msgbuf[256];
char buff[256];
if( getStringFromIndexWithDelim( msg, " ", 2, buff, sizeof( buff)) == TRUE ) {
interval = atoi( buff);
if( interval > 0 ) {
setOnelooptime_ms( (unsigned)interval);
}
}
2017-01-13 23:37:03 +08:00
snprintf( msgbuf, sizeof(msgbuf),"Onelooptime = %d 氂秒",
2016-12-24 08:45:52 +08:00
getOnelooptime_ms());
CHAR_talkToCli( tindex, meindex, msgbuf,
CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR));
}
static void NPC_Sysinfo_TitleRestart( int meindex, int tindex, char *msg)
{
int rc;
char msgbuf[256];
rc = TITLE_reinitTitleName();
if( rc) {
2017-01-13 23:37:03 +08:00
snprintf( msgbuf, sizeof(msgbuf),"读取完毕。" );
2016-12-24 08:45:52 +08:00
}
else {
2017-01-13 23:37:03 +08:00
snprintf( msgbuf, sizeof(msgbuf),"发生ERROR。" );
2016-12-24 08:45:52 +08:00
}
CHAR_talkToCli( tindex, meindex, msgbuf,
CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR));
}
static void NPC_Sysinfo_SetSaacwrite( int meindex, int tindex, char *msg)
{
int interval;
char msgbuf[256];
char buff[256];
if( getStringFromIndexWithDelim( msg, " ", 2, buff, sizeof( buff)) == TRUE ) {
interval = atoi( buff);
if( interval > 0 ) {
setSaacwritenum( (unsigned)interval);
}
}
snprintf( msgbuf, sizeof(msgbuf),"Saacwritenum = %d ",getSaacwritenum());
CHAR_talkToCli( tindex, meindex, msgbuf,
CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR));
}
static void NPC_Sysinfo_SetSaacread( int meindex, int tindex, char *msg)
{
int interval;
char msgbuf[256];
char buff[256];
if( getStringFromIndexWithDelim( msg, " ", 2, buff, sizeof( buff)) == TRUE ) {
interval = atoi( buff);
if( interval > 0 ) {
setSaacreadnum( (unsigned)interval);
}
}
snprintf( msgbuf, sizeof(msgbuf),"Saacreadnum = %d ",getSaacreadnum());
CHAR_talkToCli( tindex, meindex, msgbuf,
CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR));
}