?? net.c
字號:
{ CONNECT_LOCK(fd); Connect[fd].lastCAsendtime = *t; CONNECT_UNLOCK(fd);}ANYTHREAD static void CONNECT_getLastCAsendtime( int fd, struct timeval *t ){ CONNECT_LOCK(fd); *t = Connect[fd].lastCAsendtime; CONNECT_UNLOCK(fd);}ANYTHREAD static void CONNECT_setLastCDsendtime( int fd, struct timeval *t ){ CONNECT_LOCK(fd); Connect[fd].lastCDsendtime = *t; CONNECT_UNLOCK(fd); }ANYTHREAD static void CONNECT_getLastCDsendtime( int fd, struct timeval *t ){ CONNECT_LOCK(fd); *t = Connect[fd].lastCDsendtime; CONNECT_UNLOCK(fd);}ANYTHREAD int CONNECT_getUse_debug( int fd, int i ){ int a; CONNECT_LOCK_ARG2(fd,i); a = Connect[fd].use; CONNECT_UNLOCK_ARG2(fd,i); return a; }ANYTHREAD int CONNECT_getUse( int fd ){ int a; CONNECT_LOCK(fd); a = Connect[fd].use; CONNECT_UNLOCK(fd); return a;}void CONNECT_setUse( int fd , int a)//ANYTHREAD static void CONNECT_setUse( int fd , int a){ CONNECT_LOCK(fd); Connect[fd].use = a; CONNECT_UNLOCK(fd);}ANYTHREAD void CONNECT_checkStatecount( int a ){ int i; int count=0; for( i=0; i < ConnectLen; i++ ){ if( Connect[i].use == FALSE || Connect[i].state != a ) continue; if( Connect[i].nstatecount <= 0 ){ Connect[i].nstatecount=(int)time(NULL)+60; }else{ if( Connect[i].nstatecount < (int)time(NULL) ){ CONNECT_endOne_debug(i); close( i ); count++; } } } { memset(StateTable, 0, sizeof(StateTable)); for (i=0; i < ConnectLen; i++) if (Connect[i].use == TRUE) StateTable[Connect[i].state]++; }}ANYTHREAD int CONNECT_checkStateSomeOne( int a, int maxcount){ char temp[80],buffer[1024]; int i, ret=1; if( StateTable[a] >= maxcount ) ret =-1; buffer[0]=0; for (i=0; i <= WHILESAVEWAIT; i++){ sprintf(temp, "%4d", StateTable[i]); strcat(buffer, temp); } print("\nNOW{{%s}}", buffer); return ret;}ANYTHREAD void CONNECT_setState( int fd, int a ){ CONNECT_LOCK(fd); Connect[fd].state = a; Connect[fd].nstatecount = 0; // Nuke start 0829: For debugging { char temp[80],buffer[1024]; int i; memset(StateTable, 0, sizeof(StateTable)); for (i=0; i < ConnectLen; i++) if (Connect[i].use == TRUE) StateTable[Connect[i].state]++; buffer[0]=0; for (i=0; i <= WHILESAVEWAIT; i++){ sprintf(temp, "%4d", StateTable[i]); strcat(buffer, temp); } print("\n{{%s}}", buffer); } // Nuke end CONNECT_UNLOCK(fd);}ANYTHREAD int CONNECT_getState( int fd ){ int a; CONNECT_LOCK(fd); a = Connect[fd].state; CONNECT_UNLOCK(fd); return a;}ANYTHREAD void CONNECT_incrementErrornum(int fd ){ CONNECT_LOCK(fd); Connect[fd].errornum ++; CONNECT_UNLOCK(fd);}ANYTHREAD void CONNECT_setCharaindex( int fd, int a ){ CONNECT_LOCK(fd); Connect[fd].charaindex = a; CONNECT_UNLOCK(fd);}ANYTHREAD int CONNECT_getCharaindex( int fd ){ int a; CONNECT_LOCK(fd); a = Connect[fd].charaindex; CONNECT_UNLOCK(fd); return a;}ANYTHREAD void CONNECT_getCdkey( int fd , char *out, int outlen ){ CONNECT_LOCK(fd); strcpysafe( out, outlen, Connect[fd].cdkey ); CONNECT_UNLOCK(fd);}ANYTHREAD voidCONNECT_setCdkey( int sockfd, char *cd ){ CONNECT_LOCK(sockfd); snprintf( Connect[sockfd].cdkey, sizeof( Connect[sockfd].cdkey ),"%s", cd ); CONNECT_UNLOCK(sockfd);}ANYTHREAD void CONNECT_getPasswd( int fd , char *out, int outlen ){ CONNECT_LOCK(fd); strcpysafe( out, outlen, Connect[fd].passwd ); CONNECT_UNLOCK(fd);}ANYTHREAD void CONNECT_setPasswd( int fd, char *in ){ CONNECT_LOCK(fd); strcpysafe( Connect[fd].passwd, sizeof( Connect[fd].passwd ), in ); CONNECT_UNLOCK(fd);}ANYTHREAD int CONNECT_getCtype( int fd ){ int a; CONNECT_LOCK(fd); a = Connect[fd].ctype; CONNECT_UNLOCK(fd); return a;}ANYTHREAD void CONNECT_setCtype( int fd , int a ){ CONNECT_LOCK(fd); Connect[fd].ctype = a; CONNECT_UNLOCK(fd); }ANYTHREAD void CONNECT_getCharname( int fd , char *out, int outlen ){ CONNECT_LOCK(fd); strcpysafe( out, outlen, Connect[fd].charname ); CONNECT_UNLOCK(fd);}ANYTHREAD void CONNECT_setCharname( int fd, char *in ){ CONNECT_LOCK(fd); strcpysafe( Connect[fd].charname, sizeof( Connect[fd].charname ), in ); CONNECT_UNLOCK(fd);}ANYTHREAD int CONNECT_getFdid( int fd ){ int a; CONNECT_LOCK(fd); a = Connect[fd].fdid; CONNECT_UNLOCK(fd); return a;}ANYTHREAD void CONNECT_setDuelcharaindex( int fd, int i , int a ){ CONNECT_LOCK(fd); Connect[fd].duelcharaindex[i]=a; CONNECT_UNLOCK(fd); }ANYTHREAD int CONNECT_getDuelcharaindex( int fd, int i ){ int a; CONNECT_LOCK(fd); a = Connect[fd].duelcharaindex[i]; CONNECT_UNLOCK(fd); return a;}ANYTHREAD void CONNECT_setBattlecharaindex( int fd, int i , int a ){ CONNECT_LOCK(fd); Connect[fd].battlecharaindex[i] = a; CONNECT_UNLOCK(fd); }ANYTHREAD int CONNECT_getBattlecharaindex( int fd, int i ){ int a; CONNECT_LOCK(fd); a = Connect[fd].battlecharaindex[i]; CONNECT_UNLOCK(fd); return a;}ANYTHREAD void CONNECT_setJoinpartycharaindex( int fd, int i , int a){ CONNECT_LOCK(fd); Connect[fd].joinpartycharaindex[i]=a; CONNECT_UNLOCK(fd);}ANYTHREAD int CONNECT_getJoinpartycharaindex( int fd, int i ){ int a; CONNECT_LOCK(fd); a = Connect[fd].joinpartycharaindex[i]; CONNECT_UNLOCK(fd); return a;}// CoolFish: Trade 2001/4/18ANYTHREAD void CONNECT_setTradecharaindex( int fd, int i , int a ){ CONNECT_LOCK(fd); Connect[fd].tradecharaindex[i] = a; CONNECT_UNLOCK(fd);}// Shan BeginANYTHREAD void CONNECT_setLastrecvtime( int fd, struct timeval *a ){ CONNECT_LOCK(fd); Connect[fd].lastrecvtime = *a; CONNECT_UNLOCK(fd);}ANYTHREAD void CONNECT_getLastrecvtime( int fd, struct timeval *a ){ CONNECT_LOCK(fd); *a = Connect[fd].lastrecvtime; CONNECT_UNLOCK(fd);}ANYTHREAD void CONNECT_setLastrecvtime_D( int fd, struct timeval *a ){ CONNECT_LOCK(fd); Connect[fd].lastrecvtime_d = *a; CONNECT_UNLOCK(fd);}ANYTHREAD void CONNECT_getLastrecvtime_D( int fd, struct timeval *a ){ CONNECT_LOCK(fd); *a = Connect[fd].lastrecvtime_d; CONNECT_UNLOCK(fd);}// 2001/12/26ANYTHREAD void CONNECT_SetBattleRecvTime( int fd, struct timeval *a ){ CONNECT_LOCK(fd); Connect[fd].battle_recvtime = *a; CONNECT_UNLOCK(fd);}ANYTHREAD void CONNECT_GetBattleRecvTime( int fd, struct timeval *a ){ CONNECT_LOCK(fd); *a = Connect[fd].battle_recvtime; CONNECT_UNLOCK(fd);}// Shan End#ifdef _ITEM_PILEFORTRADEANYTHREAD void CONNECT_setTradeList( int fd, int num){ Connect[fd].tradelist = num;}ANYTHREAD int CONNECT_getTradeList(int fd){ return Connect[fd].tradelist;}#endifANYTHREAD void CONNECT_setTradeTmp(int fd, char* a){ CONNECT_LOCK(fd); strcpysafe( Connect[fd].TradeTmp, sizeof(Connect[fd].TradeTmp), a); CONNECT_UNLOCK(fd);}ANYTHREAD void CONNECT_getTradeTmp(int fd, char *trademsg, int trademsglen){ CONNECT_LOCK(fd); strcpysafe(trademsg, trademsglen, Connect[fd].TradeTmp); CONNECT_UNLOCK(fd);} ANYTHREAD void CONNECT_setTradecardcharaindex( int fd, int i , int a ){ CONNECT_LOCK(fd); Connect[fd].joinpartycharaindex[i] = a; CONNECT_UNLOCK(fd);}ANYTHREAD int CONNECT_getTradecardcharaindex( int fd, int i ){ int a; CONNECT_LOCK(fd); a = Connect[fd].joinpartycharaindex[i]; CONNECT_UNLOCK(fd); return a;}ANYTHREAD int CONNECT_getClosed( int fd ){#if USE_MTIO int a; CONNECT_LOCK(fd); a = Connect[fd].closed; CONNECT_UNLOCK(fd); return a;#else return 0;#endif}ANYTHREAD void CONNECT_setClosed( int fd, int a ){#if USE_MTIO CONNECT_LOCK(fd); if( !Connect[fd].use){ CONNECT_UNLOCK(fd); return; } Connect[fd].closed =a; CONNECT_UNLOCK(fd);#endif }ANYTHREAD void CONNECT_setCloseRequest( int fd, int count ){ CONNECT_LOCK(fd); Connect[fd].close_request = count; // Nuke print("關閉請求設置為 %d ",fd); CONNECT_UNLOCK(fd);} /*------------------------------------------------------------ * CAcheck 卅升卞銀歹木月楮醒[ 端卞霜月[ * 婁醒 * fd int 白央奶伙犯奴旦弁伉皿正 * 忒曰襖 * 卅仄 ------------------------------------------------------------*/ANYTHREAD void CAsend( int fd ){ char buf[sizeof(Connect[0].CAbuf)]; int bufuse=0; if( CONNECT_getCAbuf( fd, buf, sizeof(buf), &bufuse ) < 0 )return; if( bufuse == 0 )return; //print("\nshan--->(CAsend)->%s fd->%d", buf, fd); /* 及犯伉立正 ',' 毛'\0' 午井尹月*/ buf[bufuse-1] = '\0'; lssproto_CA_send( fd , buf ); CONNECT_setCAbufsiz( fd, 0 ); }/*------------------------------------------------------------ * CA毛霜月[ * 婁醒 * 忒曰襖 * 卅仄 ------------------------------------------------------------*/ANYTHREAD void CAcheck( void ){ int i; unsigned int interval_us = getCAsendinterval_ms()*1000; /* Connect及蜊醒坌分仃支月井日褐中氏分卅[ */ for( i = 0; i < ConnectLen; i ++) { struct timeval t; if( !CONNECT_getUse_debug(i,1008) )continue; CONNECT_getLastCAsendtime( i, &t ); if( time_diff_us( NowTime, t ) > interval_us ){ CAsend( i); CONNECT_setLastCAsendtime( i, &NowTime ); } }}ANYTHREAD void CAflush( int charaindex ){ int i; i = getfdFromCharaIndex( charaindex); if( i == -1 )return; CAsend(i);}/*------------------------------------------------------------ * CDbuf 卞馨笛允月[ * 婁醒 * fd int 白央奶伙犯奴旦弁伉皿正 * data char* 犯□正 * size int 犯□正及扔奶術 * 忒曰襖 * 岳 TRUE(1) * 撩 FALSE(0) ------------------------------------------------------------*/ANYTHREAD BOOL CONNECT_appendCDbuf( int fd , char* data, int size ){ CONNECT_LOCK(fd); if( ( Connect[fd].CDbufsiz + size ) >= sizeof( Connect[fd].CDbuf )){ CONNECT_UNLOCK(fd); return FALSE; } memcpy( Connect[fd].CDbuf + Connect[fd].CDbufsiz , data, size ); Connect[fd].CDbuf[Connect[fd].CDbufsiz+size] = ','; Connect[fd].CDbufsiz += ( size + 1 ); CONNECT_UNLOCK(fd); return TRUE;}/*------------------------------------------------------------ * CDcheck 卅升卞銀歹木月楮醒[ 端卞霜月[ * 婁醒 * fd int 白央奶伙犯奴旦弁伉皿正 * 忒曰襖 * 卅仄 ------------------------------------------------------------*/ANYTHREAD void CDsend( int fd ){ char buf[sizeof(Connect[0].CAbuf )]; int bufuse=0; if( CONNECT_getCDbuf( fd, buf, sizeof(buf), &bufuse ) < 0 ) return; if( bufuse == 0 ) return;
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -