void CGateCore::_SendTotalGameServerClients(int iClientH, int iTotalClients) { char cData[120],cTempName[22]; uint32_t * dwp; uint16_t * wp; char * cp; int iRet; std::memset(cData, '\0', sizeof(cData)); std::memset(cTempName, '\0', sizeof(cTempName)); dwp = (uint32_t *)(cData + DEF_INDEX4_MSGID); *dwp = MSGID_TOTALGAMESERVERCLIENTS; wp = (uint16_t *)(cData + DEF_INDEX2_MSGTYPE); *wp = DEF_MSGTYPE_CONFIRM; cp = (char *)(cData + DEF_INDEX2_MSGTYPE + 2); wp = (uint16_t *)cp; *wp = iTotalClients; cp += 2; iRet = m_pClientList[iClientH]->m_pXSock->iSendMsg(cData, 8); switch (iRet) { case DEF_XSOCKEVENT_MSGSIZETOOLARGE: case DEF_XSOCKEVENT_QUENEFULL: case DEF_XSOCKEVENT_SOCKETERROR: case DEF_XSOCKEVENT_CRITICALERROR: case DEF_XSOCKEVENT_SOCKETCLOSED: // 메시지를 보낼때 에러가 발생했다면 제거한다. memcpy(cTempName,m_pClientList[iClientH]->m_cName,20) ; delete m_pClientList[iClientH]; m_pClientList[iClientH] = NULL; sprintf(G_cTxt,"*** CRITICAL ERROR! Game Server(%s) connection lost!!! ***", cTempName); PutLogList(G_cTxt); // 서버 다운을 알린다. SendMsgToMonitor(MSGID_GAMESERVERDOWN, DEF_MSGTYPE_CONFIRM, cTempName); return; } }
//============================================================================= void XSocket::_CloseConn() { char cTmp[100]; BOOL bFlag = TRUE; int iRet; PutLogList("_CloseConn"); if (m_Sock == INVALID_SOCKET) return; shutdown(m_Sock, 0x01); while (bFlag == TRUE) { iRet = recv(m_Sock, cTmp, sizeof(cTmp), 0); if (iRet == SOCKET_ERROR) bFlag = FALSE; if (iRet == 0) bFlag = FALSE; } closesocket(m_Sock); m_cType = XSOCK_SHUTDOWNEDSOCK; }
//============================================================================= int XSocket::iOnSocketEvent(WPARAM wParam, LPARAM lParam) { int WSAEvent; PutLogList("iOnSocketEvent"); if (m_cType != XSOCK_NORMALSOCK) return XSOCKEVENT_SOCKETMISMATCH; if (m_cType == NULL) return XSOCKEVENT_NOTINITIALIZED; if ((SOCKET)wParam != m_Sock) return XSOCKEVENT_SOCKETMISMATCH; WSAEvent = WSAGETSELECTEVENT(lParam); switch (WSAEvent) { case FD_CONNECT: if (WSAGETSELECTERROR(lParam) != 0) { if (bConnect(m_pAddr, m_iPortNum, m_uiMsg) == FALSE) return XSOCKEVENT_SOCKETERROR; return XSOCKEVENT_RETRYINGCONNECTION; } else { m_bIsAvailable = TRUE; return XSOCKEVENT_CONNECTIONESTABLISH; } break; case FD_READ: if (WSAGETSELECTERROR(lParam) != 0) { m_WSAErr = WSAGETSELECTERROR(lParam); return XSOCKEVENT_SOCKETERROR; } else return _iOnRead(); break; case FD_WRITE: return _iSendUnsentData(); break; case FD_CLOSE: m_cType = XSOCK_SHUTDOWNEDSOCK; return XSOCKEVENT_SOCKETCLOSED; break; } return XSOCKEVENT_UNKNOWN; }
void CGateCore::CheckGameServerActivity() { register int i; uint32_t dwTime; char cTxt[120]; dwTime = timeGetTime(); for (i = 1; i < DEF_MAXCLIENTS; i++) if (m_pClientList[i] != NULL) { if ((m_pClientList[i]->m_bIsGameServer == true) && ((dwTime - m_pClientList[i]->m_dwAliveTime) > DEF_NORESPONSELIMIT)) { // 이 게임 서버는 현재 동작이 중단되었다. 소켓이 끊어지지도 않았으니 비정상적 실행 중단 상태이다. sprintf(cTxt, "*** CRITICAL ERROR! Game server(%s) does not response!", m_pClientList[i]->m_cName); PutLogList(cTxt); if (m_pClientList[i]->m_sIsActivated > 0) m_pClientList[i]->m_sIsActivated = 0; // Monitor 클라이언트에게 알린다. SendMsgToMonitor(MSGID_GAMESERVERDOWN, DEF_MSGTYPE_CONFIRM, m_pClientList[i]->m_cName); } } }
void CGateCore::ItemLog(char *pData) { char * cp, cGiveName[11], cRecvName[11], cItemName[21], cStr[256]; short * sp, sItemType, sItemV1, sItemV2, sItemV3; std::memset(cGiveName, '\0', sizeof(cGiveName)); std::memset(cRecvName, '\0', sizeof(cRecvName)); std::memset(cItemName, '\0', sizeof(cItemName)); std::memset(cStr, '\0', sizeof(cStr)); cp = (char *)(pData + DEF_INDEX2_MSGTYPE + 2); memcpy(cGiveName, cp, 10); cp += 10; memcpy(cRecvName, cp, 10); cp += 10; memcpy(cItemName, cp, 20); cp += 20; sItemType = (short)*cp; cp++; sp = (short *)cp; sItemV1 = *sp; cp += 2; sp = (short *)cp; sItemV2 = *sp; cp += 2; sp = (short *)cp; sItemV3 = *sp; cp += 2; sprintf(cStr, "Item(%s %d %d %d %d) From(%s)-To(%s)", cItemName, sItemType, sItemV1, sItemV2, sItemV3, cGiveName, cRecvName); PutItemLogFileList(cStr); PutLogList(cStr); }
void CGateCore::ResponseRegisterGameServer(int iClientH, bool bRet) { char cData[20], cTempName[22]; uint32_t * dwp; uint16_t * wp; int iRet; std::memset(cData, '\0', sizeof(cData)); std::memset(cTempName, '\0', sizeof(cTempName)); dwp = (uint32_t *)(cData + DEF_INDEX4_MSGID); *dwp = MSGID_RESPONSE_REGISTERGAMESERVER; wp = (uint16_t *)(cData + DEF_INDEX2_MSGTYPE); if (bRet == true) *wp = DEF_MSGTYPE_CONFIRM; else *wp = DEF_MSGTYPE_REJECT; iRet = m_pClientList[iClientH]->m_pXSock->iSendMsg(cData, 6); switch (iRet) { case DEF_XSOCKEVENT_MSGSIZETOOLARGE: case DEF_XSOCKEVENT_QUENEFULL: case DEF_XSOCKEVENT_SOCKETERROR: case DEF_XSOCKEVENT_CRITICALERROR: case DEF_XSOCKEVENT_SOCKETCLOSED: // 메시지를 보낼때 에러가 발생했다면 제거한다. memcpy(cTempName,m_pClientList[iClientH]->m_cName,20) ; delete m_pClientList[iClientH]; m_pClientList[iClientH] = NULL; sprintf(G_cTxt,"*** CRITICAL ERROR! Game Server(%s) connection lost!!! ***", cTempName); PutLogList(G_cTxt); // 서버 다운을 알린다. SendMsgToMonitor(MSGID_GAMESERVERDOWN, DEF_MSGTYPE_CONFIRM, cTempName); return; } }
//============================================================================= int XSocket::iSendMsg(char * cData, DWORD dwSize, char cKey, BOOL log) { WORD * wp; int iRet; DWORD i; char m_msgBuff[50000], dataBuff[50000]; PutLogList("iSendMsg"); if (dwSize > m_dwBufferSize) return XSOCKEVENT_MSGSIZETOOLARGE; if (m_cType != XSOCK_NORMALSOCK) return XSOCKEVENT_SOCKETMISMATCH; if (m_cType == NULL) return XSOCKEVENT_NOTINITIALIZED; m_pSndBuffer[0] = cKey; wp = (WORD *)(m_pSndBuffer + 1); *wp = (WORD)(dwSize + 3); memcpy((char *)(m_pSndBuffer + 3), cData, dwSize); if(log){ ZeroMemory(m_msgBuff, sizeof(m_msgBuff)); ZeroMemory(dataBuff, sizeof(dataBuff)); wsprintf(m_msgBuff,"Msg [%lu] was sent = ", dwSize); memcpy(dataBuff, cData, dwSize); for(i = 0; i < dwSize; i++) if(dataBuff[i] == NULL) dataBuff[i] = ' '; strcat(m_msgBuff, dataBuff); PutLogFileList(m_msgBuff, XSOCKET_LOGFILE); } if (cKey != NULL) {//Encryption for (i = 0; i < dwSize; i++) { m_pSndBuffer[3+i] += (i ^ cKey); m_pSndBuffer[3+i] = (char)(m_pSndBuffer[3+i] ^ (cKey ^ (dwSize - i))); } } iRet = _iSend(m_pSndBuffer, dwSize + 3, TRUE); if (iRet < 0) return iRet; else return (iRet - 3); }
//============================================================================= int XSocket::_iSend_ForInternalUse(char * cData, int iSize) { int iOutLen, iRet, WSAErr; PutLogList("_iSend_ForInternalUse"); iOutLen = 0; while (iOutLen < iSize) { iRet = send(m_Sock, (cData + iOutLen), iSize - iOutLen, 0); if (iRet == SOCKET_ERROR) { WSAErr = WSAGetLastError(); if (WSAErr != WSAEWOULDBLOCK) { m_WSAErr = WSAErr; return XSOCKEVENT_SOCKETERROR; } else { return iOutLen; } } else iOutLen += iRet; } return iOutLen; }
//============================================================================= SOCKET XSocket::iGetSocket() { PutLogList("iGetSocket"); return m_Sock; }
void CGateCore::OnClientRead(int iClientH) { char * cp, * pData, cTemp[22],cTxt[256] ; uint32_t * dwpMsgID, dwMsgSize, dwTime, * dwp ; uint16_t * wp; int i , iRet; bool bFindGameServer= false ; dwTime = timeGetTime(); pData = m_pClientList[iClientH]->m_pXSock->pGetRcvDataPointer(&dwMsgSize); dwpMsgID = (uint32_t *)(pData + DEF_INDEX4_MSGID); switch (*dwpMsgID) { case MSGID_PARTYOPERATION: PartyOperation(iClientH, pData); break; case MSGID_SERVERSTOCKMSG: // 받은 메시지를 모든 게임 서버들에게 재 전송 SendMsgToAllGameServers(iClientH, pData, dwMsgSize, false); break; case MSGID_REQUEST_GAMESERVER_SHUTDOWN: cp = (char *)(pData + DEF_INDEX2_MSGTYPE); wp = (uint16_t *)cp; if (*wp != 0x5A8E) { // 확인코드 불일치. 삭제. delete m_pClientList[iClientH]; m_pClientList[iClientH] = NULL; return; } cp += 2 ; if (memcmp(cp, "1dkld$#@01", 10 ) != 0) return ; cp += 10 ; strcpy(cTemp,cp) ; for (i = 1; i < DEF_MAXCLIENTS; i++) if ((m_pClientList[i] != NULL) && ( strcmp(m_pClientList[i]->m_cName,cTemp) == 0) && ( m_pClientList[i]->m_bIsGameServer == true)) { std::memset(cTxt, '\0', sizeof(cTxt)); dwp = (uint32_t *)(cTxt + DEF_INDEX4_MSGID); *dwp = MSGID_GAMESERVERSHUTDOWNED; wp = (uint16_t *)(cTxt + DEF_INDEX2_MSGTYPE); *wp = DEF_MSGTYPE_CONFIRM; iRet = m_pClientList[i]->m_pXSock->iSendMsg(cTxt, 6); switch (iRet) { case DEF_XSOCKEVENT_MSGSIZETOOLARGE: case DEF_XSOCKEVENT_QUENEFULL: case DEF_XSOCKEVENT_SOCKETERROR: case DEF_XSOCKEVENT_CRITICALERROR: case DEF_XSOCKEVENT_SOCKETCLOSED: // 메시지를 보낼때 에러가 발생했다면 제거한다. memcpy(cTemp,m_pClientList[i]->m_cName,20) ; delete m_pClientList[i]; m_pClientList[i] = NULL; sprintf(G_cTxt,"*** CRITICAL ERROR! Game Server(%s) connection lost!!! ***", cTemp); PutLogList(G_cTxt); // 서버 다운을 알린다. SendMsgToMonitor(MSGID_GAMESERVERDOWN, DEF_MSGTYPE_CONFIRM, cTemp); } bFindGameServer = true ; } if( bFindGameServer == false) { sprintf(cTxt,"(!) AUTO SHUTDOWN PROCESS (%s) SERVER CAN'T FIND !",cTemp) ; PutLogList(cTxt) ; } break; case MSGID_REQUEST_ALLGAMESERVER_SHUTDOWN: cp = (char *)(pData + DEF_INDEX2_MSGTYPE); wp = (uint16_t *)cp; if (*wp != 0x5A8E) { // 확인코드 불일치. 삭제. delete m_pClientList[iClientH]; m_pClientList[iClientH] = NULL; return; } cp += 2 ; if (memcmp(cp, "1dkld$#@01", 10 ) != 0) return ; PutLogList(" "); PutLogList("(!) AUTO SHUTDOWN PROCESS STARTED!"); for (i = 1; i < DEF_MAXCLIENTS; i++) if ((m_pClientList[i] != NULL) && (m_pClientList[i]->m_bIsGameServer == true)) m_pClientList[i]->m_bIsShutDown = true ; break ; case MSGID_REQUEST_ALL_SERVER_REBOOT: case MSGID_REQUEST_EXEC_1DOTBAT: case MSGID_REQUEST_EXEC_2DOTBAT: cp = (char *)(pData + DEF_INDEX2_MSGTYPE); wp = (uint16_t *)cp; if (*wp != 0x5A8E) { // 확인코드 불일치. 삭제. delete m_pClientList[iClientH]; m_pClientList[iClientH] = NULL; return; } // 받은 메시지를 그대로 모든 모니터에게 전송. SendMsgToMonitor(pData, dwMsgSize); break; case MSGID_GATEWAY_CURRENTCONN: SendMsgToMonitor(pData, dwMsgSize); break; case MSGID_MONITORALIVE: cp = (char *)(pData + DEF_INDEX2_MSGTYPE); wp = (uint16_t *)cp; if (m_cMonitorStatus[*wp] != 1) m_cMonitorStatus[*wp] = 1; else m_cMonitorStatus[*wp] = 2; #if 0 // TODO: Is this code needed? InvalidateRect(m_hWnd, NULL, true); #endif // 받은 메시지를 그대로 모든 모니터에게 전송. char cTemp[20] ; std::memset(cTemp, '\0',sizeof(cTemp)) ; sprintf(cTemp,"Total User %d",iTotalWorldServerClients) ; SendMsgToMonitor(*dwpMsgID, *wp, cTemp); break; case MSGID_ITEMLOG: // 아이템 관련 로그 ItemLog(pData); break; case MSGID_REQUEST_REGISTERGAMESERVER: // 게임서버로부터 등록 요청 RegisterGameServerHandler(iClientH, pData); break; case MSGID_GAMESERVERALIVE: // 게임서버가 살아 있음을 알리는 메시지 m_pClientList[iClientH]->m_dwAliveTime = dwTime; cp = (char *)(pData + DEF_INDEX2_MSGTYPE + 2); wp = (uint16_t *)cp; m_pClientList[iClientH]->m_iTotalClients = (int)*wp; if (m_pClientList[iClientH]->m_sIsActivated >= 0) m_pClientList[iClientH]->m_sIsActivated = 1; SendMsgToMonitor(MSGID_GAMESERVERALIVE, DEF_MSGTYPE_CONFIRM, m_pClientList[iClientH]->m_cName,m_pClientList[iClientH]->m_iTotalClients); break; } }
int XSocket::_iOnRead() { int iRet, WSAErr; WORD * wp; PutLogList("_iOnRead"); if (m_cStatus == XSOCKSTATUS_READINGHEADER) { iRet = recv(m_Sock, (char *)(m_pRcvBuffer + m_dwTotalReadSize), m_dwReadSize, 0); if (iRet == SOCKET_ERROR) { WSAErr = WSAGetLastError(); if (WSAErr != WSAEWOULDBLOCK) { m_WSAErr = WSAErr; return XSOCKEVENT_SOCKETERROR; } else return XSOCKEVENT_BLOCK; } else if (iRet == 0) { m_cType = XSOCK_SHUTDOWNEDSOCK; return XSOCKEVENT_SOCKETCLOSED; } m_dwReadSize -= iRet; m_dwTotalReadSize += iRet; if (m_dwReadSize == 0) { m_cStatus = XSOCKSTATUS_READINGBODY; wp = (WORD *)(m_pRcvBuffer + 1); m_dwReadSize = (int)(*wp - 3); if (m_dwReadSize == 0) { m_cStatus = XSOCKSTATUS_READINGHEADER; m_dwReadSize = 3; m_dwTotalReadSize = 0; return XSOCKEVENT_READCOMPLETE; } else if (m_dwReadSize > m_dwBufferSize) { m_cStatus = XSOCKSTATUS_READINGHEADER; m_dwReadSize = 3; m_dwTotalReadSize = 0; return XSOCKEVENT_MSGSIZETOOLARGE; } } return XSOCKEVENT_ONREAD; } else if (m_cStatus == XSOCKSTATUS_READINGBODY) { iRet = recv(m_Sock, (char *)(m_pRcvBuffer + m_dwTotalReadSize), m_dwReadSize, 0); if (iRet == SOCKET_ERROR) { WSAErr = WSAGetLastError(); if (WSAErr != WSAEWOULDBLOCK) { m_WSAErr = WSAErr; return XSOCKEVENT_SOCKETERROR; } else return XSOCKEVENT_BLOCK; } else if (iRet == 0) { m_cType = XSOCK_SHUTDOWNEDSOCK; return XSOCKEVENT_SOCKETCLOSED; } m_dwReadSize -= iRet; m_dwTotalReadSize += iRet; if (m_dwReadSize == 0) { m_cStatus = XSOCKSTATUS_READINGHEADER; m_dwReadSize = 3; m_dwTotalReadSize = 0; } else return XSOCKEVENT_ONREAD; } return XSOCKEVENT_READCOMPLETE; }
static void _SignalFunc(uv_signal_t * handle, int signum) { PutLogList("(!) Shutting down..."); uv_signal_stop(handle); OnDestroy(); }
void CGateCore::CheckAutoShutdownProcess() { int i, iRet; uint32_t dwTime = timeGetTime(); char cData[128], cTempName[22]; uint16_t * wp; uint32_t * dwp; std::memset(cTempName, '\0',sizeof(cTempName)); m_bIsAutoShutdownProcess = false ; for (i = 1; i < DEF_MAXCLIENTS; i++) if ((m_pClientList[i] != NULL) && (m_pClientList[i]->m_bIsGameServer == true) && (m_pClientList[i]->m_bIsShutDown == true)) m_bIsAutoShutdownProcess = true ; if (m_bIsAutoShutdownProcess == false) return; if ((dwTime - m_dwAutoShutdownTime) > 20000) { m_dwAutoShutdownTime = dwTime; } else return; m_iAutoShutdownCount--; if (m_iAutoShutdownCount <= 0) m_iAutoShutdownCount = 0; switch (m_iAutoShutdownCount) { default: PutLogList(" ") ; SendServerShutDownMsg(1); break; case 2: PutLogList("LAST SHUTDOWN MESSAGE") ; SendServerShutDownMsg(2); break; case 1: for (i = 0; i < DEF_MAXCLIENTS; i++) if ((m_pClientList[i] != NULL) && (m_pClientList[i]->m_bIsGameServer == true) && (m_pClientList[i]->m_bIsShutDown == true)) { sprintf(G_cTxt,"(!) SEND GLOBAL COMMAND: SHUTDOWN (%s) GAME SERVER",m_pClientList[i]->m_cName) ; PutLogList(G_cTxt) ; std::memset(cData, '\0', sizeof(cData)); dwp = (uint32_t *)(cData + DEF_INDEX4_MSGID); *dwp = MSGID_GAMESERVERSHUTDOWNED; wp = (uint16_t *)(cData + DEF_INDEX2_MSGTYPE); *wp = DEF_MSGTYPE_CONFIRM; iRet = m_pClientList[i]->m_pXSock->iSendMsg(cData, 6); switch (iRet) { case DEF_XSOCKEVENT_MSGSIZETOOLARGE: case DEF_XSOCKEVENT_QUENEFULL: case DEF_XSOCKEVENT_SOCKETERROR: case DEF_XSOCKEVENT_CRITICALERROR: case DEF_XSOCKEVENT_SOCKETCLOSED: // 메시지를 보낼때 에러가 발생했다면 제거한다. memcpy(cTempName,m_pClientList[i]->m_cName,20) ; delete m_pClientList[i]; m_pClientList[i] = NULL; sprintf(G_cTxt,"*** CRITICAL ERROR! Game Server(%s) connection lost!!! ***", cTempName); PutLogList(G_cTxt); // 서버 다운을 알린다. SendMsgToMonitor(MSGID_GAMESERVERDOWN, DEF_MSGTYPE_CONFIRM, cTempName); return; } } break; } }
void CItem::InitStats(int iGenLevel) { DWORD statType, statValue, stat2Type, stat2Value; int iResult; switch(m_sItemEffectType) { default: return; case ITEMEFFECTTYPE_ATTACK_MANASAVE: case ITEMEFFECTTYPE_ATTACK: if(m_sItemEffectType == ITEMEFFECTTYPE_ATTACK_MANASAVE) { statType = ITEMSTAT_CASTPROB; m_cItemColor = 5; }else { iResult = dice(1,10000); if ((iResult >= 1) && (iResult <= 299)) { statType = ITEMSTAT_LIGHT; m_cItemColor = 2; } else if ((iResult >= 300) && (iResult <= 999)) { statType = ITEMSTAT_STRONG; m_cItemColor = 3; } else if ((iResult >= 1000) && (iResult <= 2499)) { statType = ITEMSTAT_CRITICAL; m_cItemColor = 5; } else if ((iResult >= 2500) && (iResult <= 4499)) { statType = ITEMSTAT_AGILE; m_cItemColor = 1; } else if ((iResult >= 4500) && (iResult <= 6499)) { statType = ITEMSTAT_RIGHTEOUS; m_cItemColor = 7; } else if ((iResult >= 6500) && (iResult <= 8099)) { statType = ITEMSTAT_POISONING; m_cItemColor = 4; } else if ((iResult >= 8100) && (iResult <= 9699)) { statType = ITEMSTAT_SHARP; m_cItemColor = 6; } else if ((iResult >= 9700) && (iResult <= 10000)) { statType = ITEMSTAT_ANCIENT; m_cItemColor = 8; } } iResult = dice(1, 30000); if ((iResult >= 1) && (iResult < 10000)) statValue = 1; // 10000/29348 = 34% else if ((iResult >= 10000) && (iResult < 17400)) statValue = 2; // 6600/29348 = 22.4% else if ((iResult >= 17400) && (iResult < 22400)) statValue = 3; // 4356/29348 = 14.8% else if ((iResult >= 22400) && (iResult < 25400)) statValue = 4; // 2874/29348 = 9.7% else if ((iResult >= 25400) && (iResult < 27400)) statValue = 5; // 1897/29348 = 6.4% else if ((iResult >= 27400) && (iResult < 28400)) statValue = 6; // 1252/29348 = 4.2% else if ((iResult >= 28400) && (iResult < 28900)) statValue = 7; // 826/29348 = 2.8% else if ((iResult >= 28900) && (iResult < 29300)) statValue = 8; // 545/29348 = 1.85% else if ((iResult >= 29300) && (iResult < 29600)) statValue = 9; // 360/29348 = 1.2% else if ((iResult >= 29600) && (iResult < 29800)) statValue = 10; // 237/29348 = 0.8% else if ((iResult >= 29800) && (iResult < 29900)) statValue = 11; // 156/29348 = 0.5% else if ((iResult >= 29900) && (iResult < 29970)) statValue = 12; // 103/29348 = 0.3% else if ((iResult >= 29970) && (iResult <= 30000)) statValue = 13; // 68/29348 = 0.1% else statValue = 1; switch (statType) { case ITEMSTAT_CRITICAL: if (statValue <= 5) statValue = 5; break; case ITEMSTAT_POISONING: if (statValue <= 4) statValue = 4; break; case ITEMSTAT_LIGHT: if (statValue <= 4) statValue = 4; break; case ITEMSTAT_STRONG: if (statValue <= 2) statValue = 2; break; } if ((iGenLevel <= 2) && (statValue > 7)) statValue = 7; SetNibble(m_dwAttribute, 5, statType); SetNibble(m_dwAttribute, 4, statValue); if (dice(1,10000) >= 6000) { iResult = dice(1,10000); if ((iResult >= 1) && (iResult <= 4999)) stat2Type = ITEMSTAT2_HITPROB; else if ((iResult >= 5000) && (iResult <= 8499)) stat2Type = ITEMSTAT2_CAD; else if ((iResult >= 8500) && (iResult <= 9499)) stat2Type = ITEMSTAT2_GOLD; else if ((iResult >= 9500) && (iResult <= 10000)) stat2Type = ITEMSTAT2_EXP; iResult = dice(1, 30000); if ((iResult >= 1) && (iResult < 10000)) stat2Value = 1; // 33.33% else if ((iResult >= 10000) && (iResult < 17400)) stat2Value = 2; // 24.67% else if ((iResult >= 17400) && (iResult < 22400)) stat2Value = 3; // 16.67% else if ((iResult >= 22400) && (iResult < 25400)) stat2Value = 4; // 10.00% else if ((iResult >= 25400) && (iResult < 27100)) stat2Value = 5; // 5.67% else if ((iResult >= 27100) && (iResult < 28200)) stat2Value = 6; // 3.67% else if ((iResult >= 28200) && (iResult < 28900)) stat2Value = 7; // 2.34% else if ((iResult >= 28900) && (iResult < 29400)) stat2Value = 8; // 1.67% else if ((iResult >= 29400) && (iResult < 29720)) stat2Value = 9; // 1.07% else if ((iResult >= 29720) && (iResult < 29900)) stat2Value = 10; // 0.60% else if ((iResult >= 29900) && (iResult < 29970)) stat2Value = 11; // 0.24% else if ((iResult >= 29970) && (iResult < 29994)) stat2Value = 12; // 0.08% else if ((iResult >= 29994) && (iResult <= 30000)) stat2Value = 13; // 0.02% else stat2Value = 1; switch (stat2Type) { case 2: if (stat2Value <= 3) stat2Value = 3; break; case 10: if (stat2Value > 7) stat2Value = 7; break; case 11: stat2Value = 2; break; case 12: stat2Value = 5; break; } if ((iGenLevel <= 2) && (stat2Value > 7)) stat2Value = 7; SetNibble(m_dwAttribute, 3, stat2Type); SetNibble(m_dwAttribute, 2, stat2Value); } break; case ITEMEFFECTTYPE_DEFENSE: iResult = dice(1,10000); if ((iResult >= 1) && (iResult <= 5999)) statType = ITEMSTAT_STRONG; else if ((iResult >= 6000) && (iResult <= 8999)) statType = ITEMSTAT_LIGHT; else if ((iResult >= 9000) && (iResult <= 9554)) statType = ITEMSTAT_MANACONV; else if ((iResult >= 9555) && (iResult <= 10000)) statType = ITEMSTAT_CRITICAL2; iResult = dice(1, 30000); if ((iResult >= 1) && (iResult < 10000)) statValue = 1; else if ((iResult >= 10000) && (iResult < 17400)) statValue = 2; else if ((iResult >= 17400) && (iResult < 22400)) statValue = 3; else if ((iResult >= 22400) && (iResult < 25400)) statValue = 4; else if ((iResult >= 25400) && (iResult < 27400)) statValue = 5; else if ((iResult >= 27400) && (iResult < 28400)) statValue = 6; else if ((iResult >= 28400) && (iResult < 28900)) statValue = 7; else if ((iResult >= 28900) && (iResult < 29300)) statValue = 8; else if ((iResult >= 29300) && (iResult < 29600)) statValue = 9; else if ((iResult >= 29600) && (iResult < 29800)) statValue = 10; else if ((iResult >= 29800) && (iResult < 29900)) statValue = 11; else if ((iResult >= 29900) && (iResult < 29970)) statValue = 12; else if ((iResult >= 29970) && (iResult <= 30000)) statValue = 13; else statValue = 1; switch (statType) { case ITEMSTAT_LIGHT: if (statValue <= 4) statValue = 4; break; case ITEMSTAT_STRONG: if (statValue <= 2) statValue = 2; break; case ITEMSTAT_MANACONV: case ITEMSTAT_CRITICAL2: statValue = (statValue+1) / 2; if (statValue < 1) statValue = 1; if ((iGenLevel <= 3) && (statValue > 2)) statValue = 2; break; } if ((iGenLevel <= 2) && (statValue > 7)) statValue = 7; SetNibble(m_dwAttribute, 5, statType); SetNibble(m_dwAttribute, 4, statValue); if (dice(1,10000) <= 8500) { iResult = dice(1,10000); if (iResult <= 1000) stat2Type = ITEMSTAT2_PSNRES; // 10 else if (iResult <= 2200) stat2Type = ITEMSTAT2_DEF; // 12 else if (iResult <= 3800) stat2Type = ITEMSTAT2_SPREC; // 16 else if (iResult <= 6100) stat2Type = ITEMSTAT2_HPREC; // 23 else if (iResult <= 8400) stat2Type = ITEMSTAT2_MPREC; // 23 else if (iResult <= 9600) stat2Type = ITEMSTAT2_MR; // 12 else if (iResult <= 9900) stat2Type = ITEMSTAT2_PA; // 3 else if (iResult <= 10000) stat2Type = ITEMSTAT2_MA; // 1 iResult = dice(1, 30017); if ((iResult >= 1) && (iResult < 11800)) stat2Value = 1; else if ((iResult >= 11800) && (iResult < 19800)) stat2Value = 2; else if ((iResult >= 19800) && (iResult < 24300)) stat2Value = 3; else if ((iResult >= 24300) && (iResult < 27000)) stat2Value = 4; else if ((iResult >= 27000) && (iResult < 28500)) stat2Value = 5; else if ((iResult >= 28500) && (iResult < 29250)) stat2Value = 6; else if ((iResult >= 29250) && (iResult < 29650)) stat2Value = 7; else if ((iResult >= 29650) && (iResult < 29850)) stat2Value = 8; else if ((iResult >= 29850) && (iResult < 29950)) stat2Value = 9; else if ((iResult >= 29950) && (iResult < 29995)) stat2Value = 10; else if ((iResult >= 29995) && (iResult < 30011)) stat2Value = 11; else if ((iResult >= 30011) && (iResult < 30016)) stat2Value = 12; else if ((iResult >= 30016) && (iResult <= 30017)) stat2Value = 13; else stat2Value = 1; switch (stat2Type) { case ITEMSTAT2_PSNRES: case ITEMSTAT2_DEF: case ITEMSTAT2_MR: case ITEMSTAT2_PA: case ITEMSTAT2_MA: if (stat2Value <= 3) stat2Value = 3; break; } if ((iGenLevel <= 2) && (stat2Value > 7)) stat2Value = 7; SetNibble(m_dwAttribute, 3, stat2Type); SetNibble(m_dwAttribute, 2, stat2Value); #ifdef LOG_ARMORSTATS wsprintf(g_cTxt, "[I] Armor Drop: %s %s+%u (%u)", m_cName, itemStats2[stat2Type].desc, stat2Value * itemStats2[stat2Type].mult, stat2Value); PutLogList(g_cTxt); #endif } break; case ITEMEFFECTTYPE_JEWELRY: iResult = dice(1,10000); if ((iResult >= 1) && (iResult <= 4999)) statType = ITEMSTAT_LIGHT; else if ((iResult >= 5000) && (iResult <= 7999)) statType = ITEMSTAT_MANACONV; else if ((iResult >= 8000) && (iResult <= 10000)) statType = ITEMSTAT_CRITICAL2; uint32 bonus = m_sItemEffectValue1; iResult = dice(1, 30000-bonus) + bonus; if ((iResult >= 1) && (iResult < 10000)) statValue = 1; else if ((iResult >= 10000) && (iResult < 17400)) statValue = 2; else if ((iResult >= 17400) && (iResult < 22400)) statValue = 3; else if ((iResult >= 22400) && (iResult < 25400)) statValue = 4; else if ((iResult >= 25400) && (iResult < 27400)) statValue = 5; else if ((iResult >= 27400) && (iResult < 28400)) statValue = 6; else if ((iResult >= 28400) && (iResult < 28900)) statValue = 7; else if ((iResult >= 28900) && (iResult < 29300)) statValue = 8; else if ((iResult >= 29300) && (iResult < 29600)) statValue = 9; else if ((iResult >= 29600) && (iResult < 29800)) statValue = 10; else if ((iResult >= 29800) && (iResult < 29900)) statValue = 11; else if ((iResult >= 29900) && (iResult < 29970)) statValue = 12; else if ((iResult >= 29970) && (iResult <= 30000)) statValue = 13; else statValue = 1; switch (statType) { case ITEMSTAT_LIGHT: if (statValue <= 4) statValue = 4; break; case ITEMSTAT_STRONG: if (statValue <= 2) statValue = 2; break; case ITEMSTAT_MANACONV: case ITEMSTAT_CRITICAL2: statValue = (statValue+1) / 2; if (statValue < 1) statValue = 1; if ((iGenLevel <= 3) && (statValue > 2)) statValue = 2; break; } if ((iGenLevel <= 2) && (statValue > 7)) statValue = 7; SetNibble(m_dwAttribute, 5, statType); SetNibble(m_dwAttribute, 4, statValue); if (dice(1,10000) <= 8000) { iResult = dice(1,13000); if (iResult <= 1000) stat2Type = ITEMSTAT2_PSNRES; // 10 else if (iResult <= 2000) stat2Type = ITEMSTAT2_DEF; // 10 else if (iResult <= 3000) stat2Type = ITEMSTAT2_SPREC; // 16 else if (iResult <= 5400) stat2Type = ITEMSTAT2_HPREC; // 24 else if (iResult <= 7800) stat2Type = ITEMSTAT2_MPREC; // 24 else if (iResult <= 9000) stat2Type = ITEMSTAT2_MR; // 12 else if (iResult <= 11000) stat2Type = ITEMSTAT2_EXP; else if (iResult <= 13000) stat2Type = ITEMSTAT2_GOLD; iResult = dice(1, 29980 - bonus) + bonus; if ((iResult >= 1) && (iResult < 15000)) stat2Value = 1; else if ((iResult >= 15000) && (iResult < 22400)) stat2Value = 2; else if ((iResult >= 23000) && (iResult < 26100)) stat2Value = 3; else if ((iResult >= 26100) && (iResult < 27700)) stat2Value = 4; else if ((iResult >= 27700) && (iResult < 28700)) stat2Value = 5; else if ((iResult >= 28700) && (iResult < 29200)) stat2Value = 6; else if ((iResult >= 29200) && (iResult < 29450)) stat2Value = 7; else if ((iResult >= 29450) && (iResult < 29649)) stat2Value = 8; else if ((iResult >= 29649) && (iResult < 29793)) stat2Value = 9; else if ((iResult >= 29793) && (iResult < 29888)) stat2Value = 10; else if ((iResult >= 29888) && (iResult < 29935)) stat2Value = 11; else if ((iResult >= 29935) && (iResult < 29967)) stat2Value = 12; else if ((iResult >= 29967) && (iResult <= 29980)) stat2Value = 13; else stat2Value = 1; switch (stat2Type) { case ITEMSTAT2_PSNRES: case ITEMSTAT2_DEF: case ITEMSTAT2_MR: if (stat2Value <= 3) stat2Value = 3; break; } if (iGenLevel <= 2 && stat2Value > 7) stat2Value = 7; SetNibble(m_dwAttribute, 3, stat2Type); SetNibble(m_dwAttribute, 2, stat2Value); } break; } AdjustByStat(); }
//============================================================================= void _TermWinsock() { PutLogList("_TermWinsock"); WSACleanup(); }
void CGateCore::RegisterGameServerHandler(int iClientH, char * pData) { char cTxt[100], cName[11], cAddress[16], * cp; int i, iPort, iTotalMaps; uint32_t * dwp, dwBuildDate; uint16_t * wp; bool bIsSuccess = true; uint32_t dwProcess; // 게임 서버를 등록한다. std::memset(cName, '\0', sizeof(cName)); std::memset(cAddress, '\0', sizeof(cAddress)); cp = (char *)(pData + DEF_INDEX2_MSGTYPE + 2); memcpy(cName, cp, 10); cp += 10; memcpy(cAddress, cp, 16); cp += 16; wp = (uint16_t *)cp; iPort = (int)*wp; cp += 2; iTotalMaps = (int)*cp; cp++; for (i = 0; i < iTotalMaps; i++) { cp += 11; } dwp =(uint32_t *)cp; dwProcess = (uint32_t)*dwp; // v2.17 고광현 수정 cp += 4; dwp =(uint32_t *)cp; dwBuildDate = *dwp; cp += 4; m_pClientList[iClientH]->m_dwProcessHandle = dwProcess; m_pClientList[iClientH]->m_bIsGameServer = true; if (m_iBuildDate != (int)dwBuildDate) { // 빌드 날짜가 맞지 않는 서버 발견 ResponseRegisterGameServer(iClientH, false); sprintf(cTxt, "(!) Game Server Registration - fail : Server(%s:%s:%d) build date mismatch.", cName, cAddress, (int)dwBuildDate); PutLogList(cTxt); m_pClientList[iClientH]->m_sIsActivated = -1 ; // 서버 이름을 등록한다. memcpy(m_pClientList[iClientH]->m_cName, cName, 10); return; } // 여기까지 // 먼저 같은 이름을 갖고 있는 서버가 있는지 검색한다. for (i = 1; i < DEF_MAXCLIENTS; i++) if ((m_pClientList[i] != NULL) && (memcmp(m_pClientList[i]->m_cName, cName, 10) == 0)) { // 같은 이름을 갖는 게임 서버가 이미 접속되어 있다. ResponseRegisterGameServer(iClientH, false); sprintf(cTxt, "(!) Game Server Registration - fail : Server(%s) already exists.", cName); PutLogList(cTxt); m_pClientList[iClientH]->m_sIsActivated = -2 ; // 서버 이름을 등록한다. memcpy(m_pClientList[iClientH]->m_cName, cName, 10); return; } m_pClientList[iClientH]->m_sIsActivated = 1 ; // 성공적으로 서버등록을 마쳤다. sprintf(cTxt, "(!) Game Server Registration - Success( Name:%s | Hd:%lx | date %d)", cName, dwProcess,(int)dwBuildDate); PutLogList(cTxt); // 서버 이름을 등록한다. memcpy(m_pClientList[iClientH]->m_cName, cName, 10); ResponseRegisterGameServer(iClientH, true); return; // 더이상 등록할 서버공간이 없다. ResponseRegisterGameServer(iClientH, false); PutLogList("(!) Game Server Registeration - Fail : No more Game Server can be connected."); }
bool CGateCore::bReadProgramConfigFile(char * cFn) { uint32_t dwFileSize; char * cp, * token, cReadMode, cTxt[120]; char seps[] = "= ,\t\n"; int iIPindex = 0; cReadMode = 0; std::ifstream ifs(cFn); if (!ifs.is_open()) { // 로그서버의 초기화 파일을 읽을 수 없다. PutLogList("(!) Cannot open configuration file."); return false; } ifs.seekg(0, ifs.end); dwFileSize = ifs.tellg(); ifs.seekg(0, ifs.beg); std::memset(m_cGateServerAddr, '\0', sizeof(m_cGateServerAddr)); PutLogList("(!) Reading configuration file..."); cp = new char[dwFileSize+1]; std::memset(cp, '\0', dwFileSize+1); ifs.read(cp, dwFileSize); token = strtok( cp, seps ); while( token != NULL ) { if (cReadMode != 0) { switch (cReadMode) { case 1: m_iGateServerPort = atoi(token); sprintf(cTxt, "(*) Gate server port : %d", m_iGateServerPort); PutLogList(cTxt); cReadMode = 0; break; // v2.17 2002-6-3 고광현 수정 case 2: m_iBuildDate = atoi(token); sprintf(cTxt, "(*) Build Date : %d", m_iBuildDate); PutLogList(cTxt); cReadMode = 0; break; case 3: strcpy(m_cAddress[iIPindex],token); iIPindex++; cReadMode = 0; break; case 4: std::memset(m_cGateServerAddr, '\0', sizeof(m_cGateServerAddr)); strcpy(m_cGateServerAddr,token ); sprintf(cTxt, "(*) Gate server address : %s", m_cGateServerAddr); PutLogList(cTxt); cReadMode = 0; break; } } else { if (memcmp(token, "gate-server-port", 15) == 0) cReadMode = 1; // v2.17 2002-6-3 고광현 수정 if (memcmp(token, "build-date", 10) == 0) cReadMode = 2; if (memcmp(token, "game-server-list",16) == 0) cReadMode = 3; //2002-11-27일 정진 수정 if (memcmp(token, "gate-server-address",19) == 0) cReadMode = 4 ;//2003-1-17일 문성훈 추가 IP대역 두개 쓰는경우를 위해서 } token = strtok( NULL, seps ); } delete[] cp; //2003-1-17일 문성훈 추가 게이트 서버 아이피를 않넣어 주는 경우 if ( m_cGateServerAddr == NULL) { char ServerAddr[50]; ::gethostname(ServerAddr,50); struct hostent *pHostEnt; pHostEnt = ::gethostbyname(ServerAddr); if( pHostEnt != NULL ){ sprintf(ServerAddr, "%d.%d.%d.%d", ( pHostEnt->h_addr_list[0][0] & 0x00ff ), ( pHostEnt->h_addr_list[0][1] & 0x00ff ), ( pHostEnt->h_addr_list[0][2] & 0x00ff ), ( pHostEnt->h_addr_list[0][3] & 0x00ff ) ); } strcpy(m_cGateServerAddr,ServerAddr ); sprintf(cTxt, "(*) Gate server address : %s", m_cGateServerAddr); PutLogList(cTxt); } return true; }
void CGateCore::OnKeyUp(WPARAM wParam, LPARAM lParam) { int i, iCnt; char cTxt[120]; switch (wParam) { case VK_F1: m_bF1pressed = false; break; // v2.17 2002-6-3 고광현수정 case VK_F2: // 등록되었지만 Activated되지 않은 게임 서버의 리스트를 출력한다. PutLogList(" "); iCnt = 0; for (i = 1; i < DEF_MAXCLIENTS; i++) if ((m_pClientList[i] != NULL) && (m_pClientList[i]->m_bIsGameServer == true) && (m_pClientList[i]->m_sIsActivated <= 0)) { if ( m_pClientList[i]->m_sIsActivated == 0 ) sprintf(cTxt, "(X) Server(%s) Registered but not activated.", m_pClientList[i]->m_cName); else if( m_pClientList[i]->m_sIsActivated == -1 ) sprintf(cTxt, "(X) Server(%s) build date mismatch !", m_pClientList[i]->m_cName); else if( m_pClientList[i]->m_sIsActivated == -2 ) sprintf(cTxt, "(X) Server(%s) have Same Game Name !", m_pClientList[i]->m_cName); PutLogList(cTxt); iCnt++; } sprintf(cTxt, "%d servers are not activated.", iCnt); PutLogList(cTxt); break; case VK_F3: // 작동중인 서버 리스트를 보인다. PutLogList(" "); iCnt = 0; for (i = 1; i < DEF_MAXCLIENTS; i++) if ((m_pClientList[i] != NULL) && (m_pClientList[i]->m_bIsGameServer == true) && (m_pClientList[i]->m_sIsActivated > 0 )) { sprintf(cTxt, "(!) Server(%s) activated.", m_pClientList[i]->m_cName); PutLogList(cTxt); iCnt++; } sprintf(cTxt, "%d servers are activated.", iCnt); PutLogList(cTxt); break; // 여기까지 case VK_F4: // Auto-Shut down process if (m_bF1pressed == true) { m_iAutoShutdownCount = 10; m_dwAutoShutdownTime = timeGetTime(); for (i = 1; i < DEF_MAXCLIENTS; i++) if ((m_pClientList[i] != NULL) && (m_pClientList[i]->m_bIsGameServer == true)) m_pClientList[i]->m_bIsShutDown = true ; PutLogList(" "); PutLogList("(!) AUTO SHUTDOWN PROCESS STARTED!"); } break; /* case VK_F5: // for Test PutLogList("(!) Testing Monitor activity..."); SendMsgToMonitor(MSGID_GAMESERVERDOWN, DEF_MSGTYPE_CONFIRM, m_pClientList[i]->m_cName); break; */ case VK_F6: if (m_bF1pressed == true) { PutLogList("(!) Send Server shutdown Message-1"); SendServerShutDownMsg(1,true); break; } case VK_F7: if (m_bF1pressed == true) { PutLogList("(!) Send Server shutdown Message-2"); SendServerShutDownMsg(2,true); break; } case VK_F12: m_bF12pressed = false; break; } }
void PutLogList(const string msg) { PutLogList(msg.c_str()); }
void LogError(const char * cMsg) { PutLogList(""); PutLogList(cMsg); PutLogList(""); }
void CClient::ValidateSkills(bool logInvalidSkills) { if(IsGM()) return; int invalidSkills = 0; char logMessage[100]; for (int skillIndex = 0; skillIndex < MAXSKILLTYPE; skillIndex++) { switch (skillIndex) { case SKILL_MINING: case SKILL_MANUFACTURING: case SKILL_HANDATTACK: if (m_cSkillMastery[skillIndex] > (GetStr() * 2)) { invalidSkills += m_cSkillMastery[skillIndex] - (GetStr() * 2); m_cSkillMastery[skillIndex] = GetStr() * 2; m_iSkillSSN[skillIndex] = 0; Notify(NULL, NOTIFY_SKILL, skillIndex, m_cSkillMastery[skillIndex], NULL, NULL); } break; case SKILL_MAGICRES: if (m_cSkillMastery[skillIndex] > (m_iLevel * 2)) { invalidSkills += m_cSkillMastery[skillIndex] - (m_iLevel * 2); m_cSkillMastery[skillIndex] = m_iLevel * 2; m_iSkillSSN[skillIndex] = 0; Notify(NULL, NOTIFY_SKILL, skillIndex, m_cSkillMastery[skillIndex], NULL, NULL); } break; case SKILL_MAGIC: case SKILL_STAFF: if (m_cSkillMastery[skillIndex] > (GetMag() * 2)) { invalidSkills += m_cSkillMastery[skillIndex] - (GetMag() * 2); m_cSkillMastery[skillIndex] = GetMag() * 2; m_iSkillSSN[skillIndex] = 0; Notify(NULL, NOTIFY_SKILL, skillIndex, m_cSkillMastery[skillIndex], NULL, NULL); } break; case SKILL_FISHING: case SKILL_ARCHERY: case SKILL_SHORTSWORD: case SKILL_LONGSWORD: case SKILL_FENCING: case SKILL_AXE: case SKILL_SHIELD: case SKILL_HAMMER: if (m_cSkillMastery[skillIndex] > (GetDex() * 2)) { invalidSkills += m_cSkillMastery[skillIndex] - (GetDex() * 2); m_cSkillMastery[skillIndex] = GetDex() * 2; m_iSkillSSN[skillIndex] = 0; Notify(NULL, NOTIFY_SKILL, skillIndex, m_cSkillMastery[skillIndex], NULL, NULL); } break; case SKILL_ALCHEMY: case SKILL_FARMING: case SKILL_PRETENDCORPSE: if (m_cSkillMastery[skillIndex] > (GetInt() * 2)) { invalidSkills += m_cSkillMastery[skillIndex] - (GetInt() * 2); m_cSkillMastery[skillIndex] = GetInt() * 2; m_iSkillSSN[skillIndex] = 0; Notify(NULL, NOTIFY_SKILL, skillIndex, m_cSkillMastery[skillIndex], NULL, NULL); } break; case SKILL_POISONRES: if (m_cSkillMastery[skillIndex] > (GetVit() * 2)) { invalidSkills += m_cSkillMastery[skillIndex] - (GetVit() * 2); m_cSkillMastery[skillIndex] = GetVit() * 2; m_iSkillSSN[skillIndex] = 0; Notify(NULL, NOTIFY_SKILL, skillIndex, m_cSkillMastery[skillIndex], NULL, NULL); } break; default: m_iSkillSSN[skillIndex] = 0; break; } } if(logInvalidSkills && (invalidSkills > 0)) { wsprintf(logMessage, "PC(%s) A skill was too high, reduced by (%d) points", m_cCharName, invalidSkills); PutLogList(logMessage); } }
void parseCommand(char* pMsg) { if (pMsg == NULL) return; char seps[] = "= \t\n"; char * token, * token2; class CStrTok * pStrTok; char * cName[11]; char buff[100]; BOOL bFlag; int i; pStrTok = new class CStrTok(pMsg, seps); token = pStrTok->pGet(); token2 = pStrTok->pGet(); bFlag = false; /* if (memcmp(pMsg,"ascii ",5) == 0) { //if (strlen(token) == 1) { bFlag = TRUE; char znak[1]; memcpy(znak,token,1); wsprintf(buff,"AscII%d/%s.txt",znak[0],token); PutLogList(buff); }*/ if (memcmp(pMsg,"check ",6) == 0) { if(!g_clientList) { PutLogList("No client list! Server is probably off."); return; } if (token2 != NULL) { ZeroMemory(cName, sizeof(cName)); memcpy(cName, token2,11); } if (cName != NULL) { for (i = 1; i < MAXCLIENTS; i++) if ((g_clientList[i] != NULL) && (memcmp(g_clientList[i]->m_cCharName, cName, 10) == 0)) { ZeroMemory(buff, sizeof(buff)); if ((g_clientList[i] != NULL) && (memcmp(g_clientList[i]->m_cCharName, cName, 10) == 0)) { wsprintf(buff, "%s: Str:%d Dex:%d Vit:%d Int:%d Mag:%d Chr:%d Map:%s - %i , %i Admin level:%i", g_clientList[i]->m_cCharName, g_clientList[i]->GetStr(), g_clientList[i]->GetDex(), g_clientList[i]->GetVit(), g_clientList[i]->GetInt(),g_clientList[i]->GetMag(), g_clientList[i]->m_iCharisma, g_clientList[i]->m_cMapName, g_clientList[i]->m_sX, g_clientList[i]->m_sY, g_clientList[i]->m_iAdminUserLevel); PutLogList(buff); }else{ wsprintf(buff,"Player %s is offline.", cName); PutLogList(buff); } } } } /* if (memcmp(pMsg,"start apocalypse",16) == 0) { if(!g_game) { PutLogList("Couldn't get the game server pointer! Server is probably off."); return; } g_game->GlobalStartApocalypseMode(); } if (memcmp(pMsg,"end apocalypse",14) == 0) { if(!g_game) { PutLogList("Couldn't get the game server pointer! Server is probably off."); return; } g_game->GlobalEndApocalypseMode(); } */ else if (memcmp(pMsg,"start heldenian",15) == 0) { if(!g_game) { PutLogList("Couldn't get the game server pointer! Server is probably off."); return; } g_game->StartHeldenianMode(); } else if (memcmp(pMsg,"end heldenian 1",15) == 0) { if(!g_game) { PutLogList("Couldn't get the game server pointer! Server is probably off."); return; } g_game->HeldenianEndWarNow(g_game->m_iHeldenianType, ARESDEN); } else if (memcmp(pMsg,"end heldenian 2",15) == 0) { if(!g_game) { PutLogList("Couldn't get the game server pointer! Server is probably off."); return; } g_game->HeldenianEndWarNow(g_game->m_iHeldenianType, ELVINE); } else if (memcmp(pMsg,"start crusade",13) == 0) { if(!g_game) { PutLogList("Couldn't get the game server pointer! Server is probably off."); return; } g_game->GlobalStartCrusadeMode(); }else if (memcmp(pMsg,"end crusade",11) == 0) { if(!g_game) { PutLogList("Couldn't get the game server pointer! Server is probably off."); return; } g_game->ManualEndCrusadeMode(0); }else if (memcmp(pMsg,"benchmark",9) == 0) { if(!g_game) { PutLogList("Couldn't get the game server pointer! Server is probably off."); return; } int ix = 60, iy = 60; Point p; p.x = p.y = 60; CMap * map = g_game->m_pMapList[1]; DWORD time; time = timeGetTime(); uint32 count = 0; for(uint32 i=0; i < 100000000; i++) { count += map->bGetIsMoveAllowedTile(p); } char txt[50]; ZeroMemory(txt, sizeof(txt)); wsprintf(txt, "time: %u, %u", timeGetTime() - time, count); PutLogList(txt); } else if (memcmp(pMsg,"broadcast ",10) == 0) { if(!g_clientList) { PutLogList("No client list! Server is probably off."); return; } if(!g_game) { PutLogList("Couldn't get the game server pointer! Server is probably off."); return; } //tLogList(token2); char ss[100]; ZeroMemory(ss,100); memcpy(ss,pMsg,strlen(pMsg)); ss[0]=' '; ss[1]=' '; ss[2]=' '; ss[3]=' '; ss[4]=' '; ss[5]=' '; ss[6]=' '; ss[7]=' '; ss[8]=' '; ss[9]=' '; int i; char*p=ss; while(isspace(*p) && (*p))p++; memmove(ss,p,strlen(p)+1); wsprintf(ss,"%s",ss); int do_ilu; do_ilu=0; // Send to clients on current HG for (i = 1; i < MAXCLIENTS; i++) { if (g_clientList[i] != NULL) { g_game->ShowClientMsg(i,ss); do_ilu++; } } // Send to all other HGs through Login Server if (strlen(ss) < 90) { char * cp2; WORD * wp; char * pkt = new char[strlen(ss) + 20]; ZeroMemory(pkt, strlen(ss) + 20); cp2 = (char *)pkt; *cp2 = GSM_CHATMSG; cp2++; *cp2 = CHAT_GM; cp2++; //ip = (int *)cp2; //*ip = NULL; cp2 += 4; strcpy(cp2, "Server"); cp2 += 10; wp = (WORD *)cp2; *wp = (WORD)strlen(ss); cp2 += 2; strcpy(cp2, ss); cp2 += strlen(ss); g_game->bStockMsgToGateServer(pkt, strlen(ss) + 18); } char buff[100]; wsprintf(buff,"(!) The Message '%s' was sent to all players ( %d )",ss,do_ilu); PutLogList(buff); }else if(memcmp(pMsg, "maplist", 7) == 0){ if(!g_mapList) return; for (i = 0; i < MAXMAPS; i++) if (g_mapList[i] != NULL) { wsprintf(buff, "[%d] %s", g_mapList[i]->m_iTotalActiveObject, g_mapList[i]->m_cName); PutLogList(buff); } }else if(memcmp(pMsg, "clientlist", 10) == 0){ if(!g_clientList) return; for (i = 0; i < MAXCLIENTS; i++) if (g_clientList[i] != NULL) { wsprintf(buff, "Char:%s(%d) %s on %s (%s)", g_clientList[i]->m_cCharName, g_clientList[i]->m_iLevel, GetFactionName(g_clientList[i]->GetFaction()), g_clientList[i]->m_cAccountName, g_clientList[i]->m_cIPaddress); PutLogList(buff); } }else{ wsprintf(buff,"(!!!) %s - unrecognized commad",pMsg); PutLogList(buff); } }